g2d.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. void __iomem *regs;
  26. struct clk *clk;
  27. struct clk *gate;
  28. struct g2d_ctx *curr;
  29. struct g2d_variant *variant;
  30. int irq;
  31. };
  32. struct g2d_frame {
  33. /* Original dimensions */
  34. u32 width;
  35. u32 height;
  36. /* Crop size */
  37. u32 c_width;
  38. u32 c_height;
  39. /* Offset */
  40. u32 o_width;
  41. u32 o_height;
  42. /* Image format */
  43. struct g2d_fmt *fmt;
  44. /* Variables that can calculated once and reused */
  45. u32 stride;
  46. u32 bottom;
  47. u32 right;
  48. u32 size;
  49. };
  50. struct g2d_ctx {
  51. struct v4l2_fh fh;
  52. struct g2d_dev *dev;
  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. struct g2d_variant {
  68. unsigned short hw_rev;
  69. };
  70. void g2d_reset(struct g2d_dev *d);
  71. void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f);
  72. void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a);
  73. void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f);
  74. void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a);
  75. void g2d_start(struct g2d_dev *d);
  76. void g2d_clear_int(struct g2d_dev *d);
  77. void g2d_set_rop4(struct g2d_dev *d, u32 r);
  78. void g2d_set_flip(struct g2d_dev *d, u32 r);
  79. void g2d_set_v41_stretch(struct g2d_dev *d,
  80. struct g2d_frame *src, struct g2d_frame *dst);
  81. void g2d_set_cmd(struct g2d_dev *d, u32 c);