g2d.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <linux/platform_device.h>
  13. #include <media/v4l2-device.h>
  14. #include <media/v4l2-ctrls.h>
  15. #define G2D_NAME "s5p-g2d"
  16. #define TYPE_G2D_3X 3
  17. #define TYPE_G2D_4X 4
  18. struct g2d_dev {
  19. struct v4l2_device v4l2_dev;
  20. struct v4l2_m2m_dev *m2m_dev;
  21. struct video_device *vfd;
  22. struct mutex mutex;
  23. spinlock_t ctrl_lock;
  24. atomic_t num_inst;
  25. struct vb2_alloc_ctx *alloc_ctx;
  26. void __iomem *regs;
  27. struct clk *clk;
  28. struct clk *gate;
  29. struct g2d_ctx *curr;
  30. struct g2d_variant *variant;
  31. int irq;
  32. wait_queue_head_t irq_queue;
  33. };
  34. struct g2d_frame {
  35. /* Original dimensions */
  36. u32 width;
  37. u32 height;
  38. /* Crop size */
  39. u32 c_width;
  40. u32 c_height;
  41. /* Offset */
  42. u32 o_width;
  43. u32 o_height;
  44. /* Image format */
  45. struct g2d_fmt *fmt;
  46. /* Variables that can calculated once and reused */
  47. u32 stride;
  48. u32 bottom;
  49. u32 right;
  50. u32 size;
  51. };
  52. struct g2d_ctx {
  53. struct v4l2_fh fh;
  54. struct g2d_dev *dev;
  55. struct g2d_frame in;
  56. struct g2d_frame out;
  57. struct v4l2_ctrl *ctrl_hflip;
  58. struct v4l2_ctrl *ctrl_vflip;
  59. struct v4l2_ctrl_handler ctrl_handler;
  60. u32 rop;
  61. u32 flip;
  62. };
  63. struct g2d_fmt {
  64. char *name;
  65. u32 fourcc;
  66. int depth;
  67. u32 hw;
  68. };
  69. struct g2d_variant {
  70. unsigned short hw_rev;
  71. };
  72. void g2d_reset(struct g2d_dev *d);
  73. void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f);
  74. void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a);
  75. void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f);
  76. void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a);
  77. void g2d_start(struct g2d_dev *d);
  78. void g2d_clear_int(struct g2d_dev *d);
  79. void g2d_set_rop4(struct g2d_dev *d, u32 r);
  80. void g2d_set_flip(struct g2d_dev *d, u32 r);
  81. void g2d_set_v41_stretch(struct g2d_dev *d,
  82. struct g2d_frame *src, struct g2d_frame *dst);
  83. void g2d_set_cmd(struct g2d_dev *d, u32 c);
  84. static inline struct g2d_variant *g2d_get_drv_data(struct platform_device *pdev)
  85. {
  86. return (struct g2d_variant *)platform_get_device_id(pdev)->driver_data;
  87. }