vpbe_osd.h 9.7 KB

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