g2d.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Samsung S5P G2D - 2D Graphics Accelerator Driver
  3. *
  4. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5. * Kamil Debski, <k.debski@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the
  10. * License, or (at your option) any later version
  11. */
  12. #include <media/v4l2-device.h>
  13. #include <media/v4l2-ctrls.h>
  14. #define G2D_NAME "s5p-g2d"
  15. struct g2d_dev {
  16. struct v4l2_device v4l2_dev;
  17. struct v4l2_m2m_dev *m2m_dev;
  18. struct video_device *vfd;
  19. struct mutex mutex;
  20. spinlock_t ctrl_lock;
  21. atomic_t num_inst;
  22. struct vb2_alloc_ctx *alloc_ctx;
  23. struct resource *res_regs;
  24. void __iomem *regs;
  25. struct clk *clk;
  26. struct clk *gate;
  27. struct g2d_ctx *curr;
  28. int irq;
  29. wait_queue_head_t irq_queue;
  30. };
  31. struct g2d_frame {
  32. /* Original dimensions */
  33. u32 width;
  34. u32 height;
  35. /* Crop size */
  36. u32 c_width;
  37. u32 c_height;
  38. /* Offset */
  39. u32 o_width;
  40. u32 o_height;
  41. /* Image format */
  42. struct g2d_fmt *fmt;
  43. /* Variables that can calculated once and reused */
  44. u32 stride;
  45. u32 bottom;
  46. u32 right;
  47. u32 size;
  48. };
  49. struct g2d_ctx {
  50. struct v4l2_fh fh;
  51. struct g2d_dev *dev;
  52. struct v4l2_m2m_ctx *m2m_ctx;
  53. struct g2d_frame in;
  54. struct g2d_frame out;
  55. struct v4l2_ctrl *ctrl_hflip;
  56. struct v4l2_ctrl *ctrl_vflip;
  57. struct v4l2_ctrl_handler ctrl_handler;
  58. u32 rop;
  59. u32 flip;
  60. };
  61. struct g2d_fmt {
  62. char *name;
  63. u32 fourcc;
  64. int depth;
  65. u32 hw;
  66. };
  67. void g2d_reset(struct g2d_dev *d);
  68. void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f);
  69. void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a);
  70. void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f);
  71. void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a);
  72. void g2d_start(struct g2d_dev *d);
  73. void g2d_clear_int(struct g2d_dev *d);
  74. void g2d_set_rop4(struct g2d_dev *d, u32 r);
  75. void g2d_set_flip(struct g2d_dev *d, u32 r);
  76. u32 g2d_cmd_stretch(u32 e);
  77. void g2d_set_cmd(struct g2d_dev *d, u32 c);