g2d.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. void __iomem *regs;
  24. struct clk *clk;
  25. struct clk *gate;
  26. struct g2d_ctx *curr;
  27. int irq;
  28. wait_queue_head_t irq_queue;
  29. };
  30. struct g2d_frame {
  31. /* Original dimensions */
  32. u32 width;
  33. u32 height;
  34. /* Crop size */
  35. u32 c_width;
  36. u32 c_height;
  37. /* Offset */
  38. u32 o_width;
  39. u32 o_height;
  40. /* Image format */
  41. struct g2d_fmt *fmt;
  42. /* Variables that can calculated once and reused */
  43. u32 stride;
  44. u32 bottom;
  45. u32 right;
  46. u32 size;
  47. };
  48. struct g2d_ctx {
  49. struct v4l2_fh fh;
  50. struct g2d_dev *dev;
  51. struct v4l2_m2m_ctx *m2m_ctx;
  52. struct g2d_frame in;
  53. struct g2d_frame out;
  54. struct v4l2_ctrl *ctrl_hflip;
  55. struct v4l2_ctrl *ctrl_vflip;
  56. struct v4l2_ctrl_handler ctrl_handler;
  57. u32 rop;
  58. u32 flip;
  59. };
  60. struct g2d_fmt {
  61. char *name;
  62. u32 fourcc;
  63. int depth;
  64. u32 hw;
  65. };
  66. void g2d_reset(struct g2d_dev *d);
  67. void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f);
  68. void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a);
  69. void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f);
  70. void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a);
  71. void g2d_start(struct g2d_dev *d);
  72. void g2d_clear_int(struct g2d_dev *d);
  73. void g2d_set_rop4(struct g2d_dev *d, u32 r);
  74. void g2d_set_flip(struct g2d_dev *d, u32 r);
  75. u32 g2d_cmd_stretch(u32 e);
  76. void g2d_set_cmd(struct g2d_dev *d, u32 c);