omap_voutdef.h 5.3 KB

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