vpbe_osd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. * Copyright (C) 2007-2009 Texas Instruments Inc
  3. * Copyright (C) 2007 MontaVista Software, Inc.
  4. *
  5. * Andy Lowe (alowe@mvista.com), MontaVista Software
  6. * - Initial version
  7. * Murali Karicheri (mkaricheri@gmail.com), Texas Instruments Ltd.
  8. * - ported to sub device interface
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation version 2..
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef _OSD_H
  25. #define _OSD_H
  26. #include <media/davinci/vpbe_types.h>
  27. #define VPBE_OSD_SUBDEV_NAME "vpbe-osd"
  28. /**
  29. * enum osd_layer
  30. * @WIN_OSD0: On-Screen Display Window 0
  31. * @WIN_VID0: Video Window 0
  32. * @WIN_OSD1: On-Screen Display Window 1
  33. * @WIN_VID1: Video Window 1
  34. *
  35. * Description:
  36. * An enumeration of the osd display layers.
  37. */
  38. enum osd_layer {
  39. WIN_OSD0,
  40. WIN_VID0,
  41. WIN_OSD1,
  42. WIN_VID1,
  43. };
  44. /**
  45. * enum osd_win_layer
  46. * @OSDWIN_OSD0: On-Screen Display Window 0
  47. * @OSDWIN_OSD1: On-Screen Display Window 1
  48. *
  49. * Description:
  50. * An enumeration of the OSD Window layers.
  51. */
  52. enum osd_win_layer {
  53. OSDWIN_OSD0,
  54. OSDWIN_OSD1,
  55. };
  56. /**
  57. * enum osd_pix_format
  58. * @PIXFMT_1BPP: 1-bit-per-pixel bitmap
  59. * @PIXFMT_2BPP: 2-bits-per-pixel bitmap
  60. * @PIXFMT_4BPP: 4-bits-per-pixel bitmap
  61. * @PIXFMT_8BPP: 8-bits-per-pixel bitmap
  62. * @PIXFMT_RGB565: 16-bits-per-pixel RGB565
  63. * @PIXFMT_YCbCrI: YUV 4:2:2
  64. * @PIXFMT_RGB888: 24-bits-per-pixel RGB888
  65. * @PIXFMT_YCrCbI: YUV 4:2:2 with chroma swap
  66. * @PIXFMT_NV12: YUV 4:2:0 planar
  67. * @PIXFMT_OSD_ATTR: OSD Attribute Window pixel format (4bpp)
  68. *
  69. * Description:
  70. * An enumeration of the DaVinci pixel formats.
  71. */
  72. enum osd_pix_format {
  73. PIXFMT_1BPP = 0,
  74. PIXFMT_2BPP,
  75. PIXFMT_4BPP,
  76. PIXFMT_8BPP,
  77. PIXFMT_RGB565,
  78. PIXFMT_YCbCrI,
  79. PIXFMT_RGB888,
  80. PIXFMT_YCrCbI,
  81. PIXFMT_NV12,
  82. PIXFMT_OSD_ATTR,
  83. };
  84. /**
  85. * enum osd_h_exp_ratio
  86. * @H_EXP_OFF: no expansion (1/1)
  87. * @H_EXP_9_OVER_8: 9/8 expansion ratio
  88. * @H_EXP_3_OVER_2: 3/2 expansion ratio
  89. *
  90. * Description:
  91. * An enumeration of the available horizontal expansion ratios.
  92. */
  93. enum osd_h_exp_ratio {
  94. H_EXP_OFF,
  95. H_EXP_9_OVER_8,
  96. H_EXP_3_OVER_2,
  97. };
  98. /**
  99. * enum osd_v_exp_ratio
  100. * @V_EXP_OFF: no expansion (1/1)
  101. * @V_EXP_6_OVER_5: 6/5 expansion ratio
  102. *
  103. * Description:
  104. * An enumeration of the available vertical expansion ratios.
  105. */
  106. enum osd_v_exp_ratio {
  107. V_EXP_OFF,
  108. V_EXP_6_OVER_5,
  109. };
  110. /**
  111. * enum osd_zoom_factor
  112. * @ZOOM_X1: no zoom (x1)
  113. * @ZOOM_X2: x2 zoom
  114. * @ZOOM_X4: x4 zoom
  115. *
  116. * Description:
  117. * An enumeration of the available zoom factors.
  118. */
  119. enum osd_zoom_factor {
  120. ZOOM_X1,
  121. ZOOM_X2,
  122. ZOOM_X4,
  123. };
  124. /**
  125. * enum osd_clut
  126. * @ROM_CLUT: ROM CLUT
  127. * @RAM_CLUT: RAM CLUT
  128. *
  129. * Description:
  130. * An enumeration of the available Color Lookup Tables (CLUTs).
  131. */
  132. enum osd_clut {
  133. ROM_CLUT,
  134. RAM_CLUT,
  135. };
  136. /**
  137. * enum osd_rom_clut
  138. * @ROM_CLUT0: Macintosh CLUT
  139. * @ROM_CLUT1: CLUT from DM270 and prior devices
  140. *
  141. * Description:
  142. * An enumeration of the ROM Color Lookup Table (CLUT) options.
  143. */
  144. enum osd_rom_clut {
  145. ROM_CLUT0,
  146. ROM_CLUT1,
  147. };
  148. /**
  149. * enum osd_blending_factor
  150. * @OSD_0_VID_8: OSD pixels are fully transparent
  151. * @OSD_1_VID_7: OSD pixels contribute 1/8, video pixels contribute 7/8
  152. * @OSD_2_VID_6: OSD pixels contribute 2/8, video pixels contribute 6/8
  153. * @OSD_3_VID_5: OSD pixels contribute 3/8, video pixels contribute 5/8
  154. * @OSD_4_VID_4: OSD pixels contribute 4/8, video pixels contribute 4/8
  155. * @OSD_5_VID_3: OSD pixels contribute 5/8, video pixels contribute 3/8
  156. * @OSD_6_VID_2: OSD pixels contribute 6/8, video pixels contribute 2/8
  157. * @OSD_8_VID_0: OSD pixels are fully opaque
  158. *
  159. * Description:
  160. * An enumeration of the DaVinci pixel blending factor options.
  161. */
  162. enum osd_blending_factor {
  163. OSD_0_VID_8,
  164. OSD_1_VID_7,
  165. OSD_2_VID_6,
  166. OSD_3_VID_5,
  167. OSD_4_VID_4,
  168. OSD_5_VID_3,
  169. OSD_6_VID_2,
  170. OSD_8_VID_0,
  171. };
  172. /**
  173. * enum osd_blink_interval
  174. * @BLINK_X1: blink interval is 1 vertical refresh cycle
  175. * @BLINK_X2: blink interval is 2 vertical refresh cycles
  176. * @BLINK_X3: blink interval is 3 vertical refresh cycles
  177. * @BLINK_X4: blink interval is 4 vertical refresh cycles
  178. *
  179. * Description:
  180. * An enumeration of the DaVinci pixel blinking interval options.
  181. */
  182. enum osd_blink_interval {
  183. BLINK_X1,
  184. BLINK_X2,
  185. BLINK_X3,
  186. BLINK_X4,
  187. };
  188. /**
  189. * enum osd_cursor_h_width
  190. * @H_WIDTH_1: horizontal line width is 1 pixel
  191. * @H_WIDTH_4: horizontal line width is 4 pixels
  192. * @H_WIDTH_8: horizontal line width is 8 pixels
  193. * @H_WIDTH_12: horizontal line width is 12 pixels
  194. * @H_WIDTH_16: horizontal line width is 16 pixels
  195. * @H_WIDTH_20: horizontal line width is 20 pixels
  196. * @H_WIDTH_24: horizontal line width is 24 pixels
  197. * @H_WIDTH_28: horizontal line width is 28 pixels
  198. */
  199. enum osd_cursor_h_width {
  200. H_WIDTH_1,
  201. H_WIDTH_4,
  202. H_WIDTH_8,
  203. H_WIDTH_12,
  204. H_WIDTH_16,
  205. H_WIDTH_20,
  206. H_WIDTH_24,
  207. H_WIDTH_28,
  208. };
  209. /**
  210. * enum davinci_cursor_v_width
  211. * @V_WIDTH_1: vertical line width is 1 line
  212. * @V_WIDTH_2: vertical line width is 2 lines
  213. * @V_WIDTH_4: vertical line width is 4 lines
  214. * @V_WIDTH_6: vertical line width is 6 lines
  215. * @V_WIDTH_8: vertical line width is 8 lines
  216. * @V_WIDTH_10: vertical line width is 10 lines
  217. * @V_WIDTH_12: vertical line width is 12 lines
  218. * @V_WIDTH_14: vertical line width is 14 lines
  219. */
  220. enum osd_cursor_v_width {
  221. V_WIDTH_1,
  222. V_WIDTH_2,
  223. V_WIDTH_4,
  224. V_WIDTH_6,
  225. V_WIDTH_8,
  226. V_WIDTH_10,
  227. V_WIDTH_12,
  228. V_WIDTH_14,
  229. };
  230. /**
  231. * struct osd_cursor_config
  232. * @xsize: horizontal size in pixels
  233. * @ysize: vertical size in lines
  234. * @xpos: horizontal offset in pixels from the left edge of the display
  235. * @ypos: vertical offset in lines from the top of the display
  236. * @interlaced: Non-zero if the display is interlaced, or zero otherwise
  237. * @h_width: horizontal line width
  238. * @v_width: vertical line width
  239. * @clut: the CLUT selector (ROM or RAM) for the cursor color
  240. * @clut_index: an index into the CLUT for the cursor color
  241. *
  242. * Description:
  243. * A structure describing the configuration parameters of the hardware
  244. * rectangular cursor.
  245. */
  246. struct osd_cursor_config {
  247. unsigned xsize;
  248. unsigned ysize;
  249. unsigned xpos;
  250. unsigned ypos;
  251. int interlaced;
  252. enum osd_cursor_h_width h_width;
  253. enum osd_cursor_v_width v_width;
  254. enum osd_clut clut;
  255. unsigned char clut_index;
  256. };
  257. /**
  258. * struct osd_layer_config
  259. * @pixfmt: pixel format
  260. * @line_length: offset in bytes between start of each line in memory
  261. * @xsize: number of horizontal pixels displayed per line
  262. * @ysize: number of lines displayed
  263. * @xpos: horizontal offset in pixels from the left edge of the display
  264. * @ypos: vertical offset in lines from the top of the display
  265. * @interlaced: Non-zero if the display is interlaced, or zero otherwise
  266. *
  267. * Description:
  268. * A structure describing the configuration parameters of an On-Screen Display
  269. * (OSD) or video layer related to how the image is stored in memory.
  270. * @line_length must be a multiple of the cache line size (32 bytes).
  271. */
  272. struct osd_layer_config {
  273. enum osd_pix_format pixfmt;
  274. unsigned line_length;
  275. unsigned xsize;
  276. unsigned ysize;
  277. unsigned xpos;
  278. unsigned ypos;
  279. int interlaced;
  280. };
  281. /* parameters that apply on a per-window (OSD or video) basis */
  282. struct osd_window_state {
  283. int is_allocated;
  284. int is_enabled;
  285. unsigned long fb_base_phys;
  286. enum osd_zoom_factor h_zoom;
  287. enum osd_zoom_factor v_zoom;
  288. struct osd_layer_config lconfig;
  289. };
  290. /* parameters that apply on a per-OSD-window basis */
  291. struct osd_osdwin_state {
  292. enum osd_clut clut;
  293. enum osd_blending_factor blend;
  294. int colorkey_blending;
  295. unsigned colorkey;
  296. int rec601_attenuation;
  297. /* index is pixel value */
  298. unsigned char palette_map[16];
  299. };
  300. /* hardware rectangular cursor parameters */
  301. struct osd_cursor_state {
  302. int is_enabled;
  303. struct osd_cursor_config config;
  304. };
  305. struct osd_state;
  306. struct vpbe_osd_ops {
  307. int (*initialize)(struct osd_state *sd);
  308. int (*request_layer)(struct osd_state *sd, enum osd_layer layer);
  309. void (*release_layer)(struct osd_state *sd, enum osd_layer layer);
  310. int (*enable_layer)(struct osd_state *sd, enum osd_layer layer,
  311. int otherwin);
  312. void (*disable_layer)(struct osd_state *sd, enum osd_layer layer);
  313. int (*set_layer_config)(struct osd_state *sd, enum osd_layer layer,
  314. struct osd_layer_config *lconfig);
  315. void (*get_layer_config)(struct osd_state *sd, enum osd_layer layer,
  316. struct osd_layer_config *lconfig);
  317. void (*start_layer)(struct osd_state *sd, enum osd_layer layer,
  318. unsigned long fb_base_phys,
  319. unsigned long cbcr_ofst);
  320. void (*set_left_margin)(struct osd_state *sd, u32 val);
  321. void (*set_top_margin)(struct osd_state *sd, u32 val);
  322. void (*set_interpolation_filter)(struct osd_state *sd, int filter);
  323. int (*set_vid_expansion)(struct osd_state *sd,
  324. enum osd_h_exp_ratio h_exp,
  325. enum osd_v_exp_ratio v_exp);
  326. void (*get_vid_expansion)(struct osd_state *sd,
  327. enum osd_h_exp_ratio *h_exp,
  328. enum osd_v_exp_ratio *v_exp);
  329. void (*set_zoom)(struct osd_state *sd, enum osd_layer layer,
  330. enum osd_zoom_factor h_zoom,
  331. enum osd_zoom_factor v_zoom);
  332. };
  333. struct osd_state {
  334. enum vpbe_version vpbe_type;
  335. spinlock_t lock;
  336. struct device *dev;
  337. dma_addr_t osd_base_phys;
  338. unsigned long osd_base;
  339. unsigned long osd_size;
  340. /* 1-->the isr will toggle the VID0 ping-pong buffer */
  341. int pingpong;
  342. int interpolation_filter;
  343. int field_inversion;
  344. enum osd_h_exp_ratio osd_h_exp;
  345. enum osd_v_exp_ratio osd_v_exp;
  346. enum osd_h_exp_ratio vid_h_exp;
  347. enum osd_v_exp_ratio vid_v_exp;
  348. enum osd_clut backg_clut;
  349. unsigned backg_clut_index;
  350. enum osd_rom_clut rom_clut;
  351. int is_blinking;
  352. /* attribute window blinking enabled */
  353. enum osd_blink_interval blink;
  354. /* YCbCrI or YCrCbI */
  355. enum osd_pix_format yc_pixfmt;
  356. /* columns are Y, Cb, Cr */
  357. unsigned char clut_ram[256][3];
  358. struct osd_cursor_state cursor;
  359. /* OSD0, VID0, OSD1, VID1 */
  360. struct osd_window_state win[4];
  361. /* OSD0, OSD1 */
  362. struct osd_osdwin_state osdwin[2];
  363. /* OSD device Operations */
  364. struct vpbe_osd_ops ops;
  365. };
  366. struct osd_platform_data {
  367. enum vpbe_version vpbe_type;
  368. int field_inv_wa_enable;
  369. };
  370. #endif