vpbe_osd.h 10 KB

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