2 * Copyright (C) 2007-2009 Texas Instruments Inc
3 * Copyright (C) 2007 MontaVista Software, Inc.
5 * Andy Lowe (alowe@mvista.com), MontaVista Software
7 * Murali Karicheri (mkaricheri@gmail.com), Texas Instruments Ltd.
8 * - ported to sub device interface
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..
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.
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
27 #include <media/davinci/vpbe_types.h>
29 #define VPBE_OSD_SUBDEV_NAME "vpbe-osd"
33 * @WIN_OSD0: On-Screen Display Window 0
34 * @WIN_VID0: Video Window 0
35 * @WIN_OSD1: On-Screen Display Window 1
36 * @WIN_VID1: Video Window 1
39 * An enumeration of the osd display layers.
50 * @OSDWIN_OSD0: On-Screen Display Window 0
51 * @OSDWIN_OSD1: On-Screen Display Window 1
54 * An enumeration of the OSD Window layers.
63 * @PIXFMT_1BPP: 1-bit-per-pixel bitmap
64 * @PIXFMT_2BPP: 2-bits-per-pixel bitmap
65 * @PIXFMT_4BPP: 4-bits-per-pixel bitmap
66 * @PIXFMT_8BPP: 8-bits-per-pixel bitmap
67 * @PIXFMT_RGB565: 16-bits-per-pixel RGB565
68 * @PIXFMT_YCbCrI: YUV 4:2:2
69 * @PIXFMT_RGB888: 24-bits-per-pixel RGB888
70 * @PIXFMT_YCrCbI: YUV 4:2:2 with chroma swap
71 * @PIXFMT_NV12: YUV 4:2:0 planar
72 * @PIXFMT_OSD_ATTR: OSD Attribute Window pixel format (4bpp)
75 * An enumeration of the DaVinci pixel formats.
91 * enum osd_h_exp_ratio
92 * @H_EXP_OFF: no expansion (1/1)
93 * @H_EXP_9_OVER_8: 9/8 expansion ratio
94 * @H_EXP_3_OVER_2: 3/2 expansion ratio
97 * An enumeration of the available horizontal expansion ratios.
99 enum osd_h_exp_ratio
{
106 * enum osd_v_exp_ratio
107 * @V_EXP_OFF: no expansion (1/1)
108 * @V_EXP_6_OVER_5: 6/5 expansion ratio
111 * An enumeration of the available vertical expansion ratios.
113 enum osd_v_exp_ratio
{
119 * enum osd_zoom_factor
120 * @ZOOM_X1: no zoom (x1)
125 * An enumeration of the available zoom factors.
127 enum osd_zoom_factor
{
135 * @ROM_CLUT: ROM CLUT
136 * @RAM_CLUT: RAM CLUT
139 * An enumeration of the available Color Lookup Tables (CLUTs).
148 * @ROM_CLUT0: Macintosh CLUT
149 * @ROM_CLUT1: CLUT from DM270 and prior devices
152 * An enumeration of the ROM Color Lookup Table (CLUT) options.
160 * enum osd_blending_factor
161 * @OSD_0_VID_8: OSD pixels are fully transparent
162 * @OSD_1_VID_7: OSD pixels contribute 1/8, video pixels contribute 7/8
163 * @OSD_2_VID_6: OSD pixels contribute 2/8, video pixels contribute 6/8
164 * @OSD_3_VID_5: OSD pixels contribute 3/8, video pixels contribute 5/8
165 * @OSD_4_VID_4: OSD pixels contribute 4/8, video pixels contribute 4/8
166 * @OSD_5_VID_3: OSD pixels contribute 5/8, video pixels contribute 3/8
167 * @OSD_6_VID_2: OSD pixels contribute 6/8, video pixels contribute 2/8
168 * @OSD_8_VID_0: OSD pixels are fully opaque
171 * An enumeration of the DaVinci pixel blending factor options.
173 enum osd_blending_factor
{
185 * enum osd_blink_interval
186 * @BLINK_X1: blink interval is 1 vertical refresh cycle
187 * @BLINK_X2: blink interval is 2 vertical refresh cycles
188 * @BLINK_X3: blink interval is 3 vertical refresh cycles
189 * @BLINK_X4: blink interval is 4 vertical refresh cycles
192 * An enumeration of the DaVinci pixel blinking interval options.
194 enum osd_blink_interval
{
202 * enum osd_cursor_h_width
203 * @H_WIDTH_1: horizontal line width is 1 pixel
204 * @H_WIDTH_4: horizontal line width is 4 pixels
205 * @H_WIDTH_8: horizontal line width is 8 pixels
206 * @H_WIDTH_12: horizontal line width is 12 pixels
207 * @H_WIDTH_16: horizontal line width is 16 pixels
208 * @H_WIDTH_20: horizontal line width is 20 pixels
209 * @H_WIDTH_24: horizontal line width is 24 pixels
210 * @H_WIDTH_28: horizontal line width is 28 pixels
212 enum osd_cursor_h_width
{
224 * enum davinci_cursor_v_width
225 * @V_WIDTH_1: vertical line width is 1 line
226 * @V_WIDTH_2: vertical line width is 2 lines
227 * @V_WIDTH_4: vertical line width is 4 lines
228 * @V_WIDTH_6: vertical line width is 6 lines
229 * @V_WIDTH_8: vertical line width is 8 lines
230 * @V_WIDTH_10: vertical line width is 10 lines
231 * @V_WIDTH_12: vertical line width is 12 lines
232 * @V_WIDTH_14: vertical line width is 14 lines
234 enum osd_cursor_v_width
{
246 * struct osd_cursor_config
247 * @xsize: horizontal size in pixels
248 * @ysize: vertical size in lines
249 * @xpos: horizontal offset in pixels from the left edge of the display
250 * @ypos: vertical offset in lines from the top of the display
251 * @interlaced: Non-zero if the display is interlaced, or zero otherwise
252 * @h_width: horizontal line width
253 * @v_width: vertical line width
254 * @clut: the CLUT selector (ROM or RAM) for the cursor color
255 * @clut_index: an index into the CLUT for the cursor color
258 * A structure describing the configuration parameters of the hardware
259 * rectangular cursor.
261 struct osd_cursor_config
{
267 enum osd_cursor_h_width h_width
;
268 enum osd_cursor_v_width v_width
;
270 unsigned char clut_index
;
274 * struct osd_layer_config
275 * @pixfmt: pixel format
276 * @line_length: offset in bytes between start of each line in memory
277 * @xsize: number of horizontal pixels displayed per line
278 * @ysize: number of lines displayed
279 * @xpos: horizontal offset in pixels from the left edge of the display
280 * @ypos: vertical offset in lines from the top of the display
281 * @interlaced: Non-zero if the display is interlaced, or zero otherwise
284 * A structure describing the configuration parameters of an On-Screen Display
285 * (OSD) or video layer related to how the image is stored in memory.
286 * @line_length must be a multiple of the cache line size (32 bytes).
288 struct osd_layer_config
{
289 enum osd_pix_format pixfmt
;
290 unsigned line_length
;
298 /* parameters that apply on a per-window (OSD or video) basis */
299 struct osd_window_state
{
302 unsigned long fb_base_phys
;
303 enum osd_zoom_factor h_zoom
;
304 enum osd_zoom_factor v_zoom
;
305 struct osd_layer_config lconfig
;
308 /* parameters that apply on a per-OSD-window basis */
309 struct osd_osdwin_state
{
311 enum osd_blending_factor blend
;
312 int colorkey_blending
;
314 int rec601_attenuation
;
315 /* index is pixel value */
316 unsigned char palette_map
[16];
319 /* hardware rectangular cursor parameters */
320 struct osd_cursor_state
{
322 struct osd_cursor_config config
;
327 struct vpbe_osd_ops
{
328 int (*initialize
)(struct osd_state
*sd
);
329 int (*request_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
330 void (*release_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
331 int (*enable_layer
)(struct osd_state
*sd
, enum osd_layer layer
,
333 void (*disable_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
334 int (*set_layer_config
)(struct osd_state
*sd
, enum osd_layer layer
,
335 struct osd_layer_config
*lconfig
);
336 void (*get_layer_config
)(struct osd_state
*sd
, enum osd_layer layer
,
337 struct osd_layer_config
*lconfig
);
338 void (*start_layer
)(struct osd_state
*sd
, enum osd_layer layer
,
339 unsigned long fb_base_phys
,
340 unsigned long cbcr_ofst
);
341 void (*set_left_margin
)(struct osd_state
*sd
, u32 val
);
342 void (*set_top_margin
)(struct osd_state
*sd
, u32 val
);
343 void (*set_interpolation_filter
)(struct osd_state
*sd
, int filter
);
344 int (*set_vid_expansion
)(struct osd_state
*sd
,
345 enum osd_h_exp_ratio h_exp
,
346 enum osd_v_exp_ratio v_exp
);
347 void (*get_vid_expansion
)(struct osd_state
*sd
,
348 enum osd_h_exp_ratio
*h_exp
,
349 enum osd_v_exp_ratio
*v_exp
);
350 void (*set_zoom
)(struct osd_state
*sd
, enum osd_layer layer
,
351 enum osd_zoom_factor h_zoom
,
352 enum osd_zoom_factor v_zoom
);
356 enum vpbe_version vpbe_type
;
359 dma_addr_t osd_base_phys
;
360 unsigned long osd_base
;
361 unsigned long osd_size
;
362 /* 1-->the isr will toggle the VID0 ping-pong buffer */
364 int interpolation_filter
;
366 enum osd_h_exp_ratio osd_h_exp
;
367 enum osd_v_exp_ratio osd_v_exp
;
368 enum osd_h_exp_ratio vid_h_exp
;
369 enum osd_v_exp_ratio vid_v_exp
;
370 enum osd_clut backg_clut
;
371 unsigned backg_clut_index
;
372 enum osd_rom_clut rom_clut
;
374 /* attribute window blinking enabled */
375 enum osd_blink_interval blink
;
376 /* YCbCrI or YCrCbI */
377 enum osd_pix_format yc_pixfmt
;
378 /* columns are Y, Cb, Cr */
379 unsigned char clut_ram
[256][3];
380 struct osd_cursor_state cursor
;
381 /* OSD0, VID0, OSD1, VID1 */
382 struct osd_window_state win
[4];
384 struct osd_osdwin_state osdwin
[2];
385 /* OSD device Operations */
386 struct vpbe_osd_ops ops
;
389 struct osd_platform_data
{
390 enum vpbe_version vpbe_type
;
391 int field_inv_wa_enable
;