omap_voutdef.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * omap_voutdef.h
  3. *
  4. * Copyright (C) 2010 Texas Instruments.
  5. *
  6. * This file is licensed under the terms of the GNU General Public License
  7. * version 2. This program is licensed "as is" without any warranty of any
  8. * kind, whether express or implied.
  9. */
  10. #ifndef OMAP_VOUTDEF_H
  11. #define OMAP_VOUTDEF_H
  12. #include <video/omapdss.h>
  13. #include <video/omapvrfb.h>
  14. #define YUYV_BPP 2
  15. #define RGB565_BPP 2
  16. #define RGB24_BPP 3
  17. #define RGB32_BPP 4
  18. #define TILE_SIZE 32
  19. #define YUYV_VRFB_BPP 2
  20. #define RGB_VRFB_BPP 1
  21. #define MAX_CID 3
  22. #define MAC_VRFB_CTXS 4
  23. #define MAX_VOUT_DEV 2
  24. #define MAX_OVLS 3
  25. #define MAX_DISPLAYS 10
  26. #define MAX_MANAGERS 3
  27. #define QQVGA_WIDTH 160
  28. #define QQVGA_HEIGHT 120
  29. /* Max Resolution supported by the driver */
  30. #define VID_MAX_WIDTH 1280 /* Largest width */
  31. #define VID_MAX_HEIGHT 720 /* Largest height */
  32. /* Mimimum requirement is 2x2 for DSS */
  33. #define VID_MIN_WIDTH 2
  34. #define VID_MIN_HEIGHT 2
  35. /* 2048 x 2048 is max res supported by OMAP display controller */
  36. #define MAX_PIXELS_PER_LINE 2048
  37. #define VRFB_TX_TIMEOUT 1000
  38. #define VRFB_NUM_BUFS 4
  39. /* Max buffer size tobe allocated during init */
  40. #define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4)
  41. enum dma_channel_state {
  42. DMA_CHAN_NOT_ALLOTED,
  43. DMA_CHAN_ALLOTED,
  44. };
  45. /* Enum for Rotation
  46. * DSS understands rotation in 0, 1, 2, 3 context
  47. * while V4L2 driver understands it as 0, 90, 180, 270
  48. */
  49. enum dss_rotation {
  50. dss_rotation_0_degree = 0,
  51. dss_rotation_90_degree = 1,
  52. dss_rotation_180_degree = 2,
  53. dss_rotation_270_degree = 3,
  54. };
  55. /* Enum for choosing rotation type for vout
  56. * DSS2 doesn't understand no rotation as an
  57. * option while V4L2 driver doesn't support
  58. * rotation in the case where VRFB is not built in
  59. * the kernel
  60. */
  61. enum vout_rotaion_type {
  62. VOUT_ROT_NONE = 0,
  63. VOUT_ROT_VRFB = 1,
  64. };
  65. /*
  66. * This structure is used to store the DMA transfer parameters
  67. * for VRFB hidden buffer
  68. */
  69. struct vid_vrfb_dma {
  70. int dev_id;
  71. int dma_ch;
  72. int req_status;
  73. int tx_status;
  74. wait_queue_head_t wait;
  75. };
  76. struct omapvideo_info {
  77. int id;
  78. int num_overlays;
  79. struct omap_overlay *overlays[MAX_OVLS];
  80. enum vout_rotaion_type rotation_type;
  81. };
  82. struct omap2video_device {
  83. struct mutex mtx;
  84. int state;
  85. struct v4l2_device v4l2_dev;
  86. struct omap_vout_device *vouts[MAX_VOUT_DEV];
  87. int num_displays;
  88. struct omap_dss_device *displays[MAX_DISPLAYS];
  89. int num_overlays;
  90. struct omap_overlay *overlays[MAX_OVLS];
  91. int num_managers;
  92. struct omap_overlay_manager *managers[MAX_MANAGERS];
  93. };
  94. /* per-device data structure */
  95. struct omap_vout_device {
  96. struct omapvideo_info vid_info;
  97. struct video_device *vfd;
  98. struct omap2video_device *vid_dev;
  99. int vid;
  100. int opened;
  101. /* we don't allow to change image fmt/size once buffer has
  102. * been allocated
  103. */
  104. int buffer_allocated;
  105. /* allow to reuse previously allocated buffer which is big enough */
  106. int buffer_size;
  107. /* keep buffer info across opens */
  108. unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
  109. unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
  110. enum omap_color_mode dss_mode;
  111. /* we don't allow to request new buffer when old buffers are
  112. * still mmaped
  113. */
  114. int mmap_count;
  115. spinlock_t vbq_lock; /* spinlock for videobuf queues */
  116. unsigned long field_count; /* field counter for videobuf_buffer */
  117. /* non-NULL means streaming is in progress. */
  118. bool streaming;
  119. struct v4l2_pix_format pix;
  120. struct v4l2_rect crop;
  121. struct v4l2_window win;
  122. struct v4l2_framebuffer fbuf;
  123. /* Lock to protect the shared data structures in ioctl */
  124. struct mutex lock;
  125. /* V4L2 control structure for different control id */
  126. struct v4l2_control control[MAX_CID];
  127. enum dss_rotation rotation;
  128. bool mirror;
  129. int flicker_filter;
  130. /* V4L2 control structure for different control id */
  131. int bpp; /* bytes per pixel */
  132. int vrfb_bpp; /* bytes per pixel with respect to VRFB */
  133. struct vid_vrfb_dma vrfb_dma_tx;
  134. unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
  135. unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
  136. struct vrfb vrfb_context[MAC_VRFB_CTXS];
  137. bool vrfb_static_allocation;
  138. unsigned int smsshado_size;
  139. unsigned char pos;
  140. int ps, vr_ps, line_length, first_int, field_id;
  141. enum v4l2_memory memory;
  142. struct videobuf_buffer *cur_frm, *next_frm;
  143. struct list_head dma_queue;
  144. u8 *queued_buf_addr[VIDEO_MAX_FRAME];
  145. u32 cropped_offset;
  146. s32 tv_field1_offset;
  147. void *isr_handle;
  148. /* Buffer queue variables */
  149. struct omap_vout_device *vout;
  150. enum v4l2_buf_type type;
  151. struct videobuf_queue vbq;
  152. int io_allowed;
  153. };
  154. /*
  155. * Return true if rotation is 90 or 270
  156. */
  157. static inline int is_rotation_90_or_270(const struct omap_vout_device *vout)
  158. {
  159. return (vout->rotation == dss_rotation_90_degree ||
  160. vout->rotation == dss_rotation_270_degree);
  161. }
  162. /*
  163. * Return true if rotation is enabled
  164. */
  165. static inline int is_rotation_enabled(const struct omap_vout_device *vout)
  166. {
  167. return vout->rotation || vout->mirror;
  168. }
  169. /*
  170. * Reverse the rotation degree if mirroring is enabled
  171. */
  172. static inline int calc_rotation(const struct omap_vout_device *vout)
  173. {
  174. if (!vout->mirror)
  175. return vout->rotation;
  176. switch (vout->rotation) {
  177. case dss_rotation_90_degree:
  178. return dss_rotation_270_degree;
  179. case dss_rotation_270_degree:
  180. return dss_rotation_90_degree;
  181. case dss_rotation_180_degree:
  182. return dss_rotation_0_degree;
  183. default:
  184. return dss_rotation_180_degree;
  185. }
  186. }
  187. void omap_vout_free_buffers(struct omap_vout_device *vout);
  188. #endif /* ifndef OMAP_VOUTDEF_H */