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 DM644X_VPBE_OSD_SUBDEV_NAME "dm644x,vpbe-osd"
30 #define DM365_VPBE_OSD_SUBDEV_NAME "dm365,vpbe-osd"
31 #define DM355_VPBE_OSD_SUBDEV_NAME "dm355,vpbe-osd"
35 * @WIN_OSD0: On-Screen Display Window 0
36 * @WIN_VID0: Video Window 0
37 * @WIN_OSD1: On-Screen Display Window 1
38 * @WIN_VID1: Video Window 1
41 * An enumeration of the osd display layers.
52 * @OSDWIN_OSD0: On-Screen Display Window 0
53 * @OSDWIN_OSD1: On-Screen Display Window 1
56 * An enumeration of the OSD Window layers.
65 * @PIXFMT_1BPP: 1-bit-per-pixel bitmap
66 * @PIXFMT_2BPP: 2-bits-per-pixel bitmap
67 * @PIXFMT_4BPP: 4-bits-per-pixel bitmap
68 * @PIXFMT_8BPP: 8-bits-per-pixel bitmap
69 * @PIXFMT_RGB565: 16-bits-per-pixel RGB565
70 * @PIXFMT_YCbCrI: YUV 4:2:2
71 * @PIXFMT_RGB888: 24-bits-per-pixel RGB888
72 * @PIXFMT_YCrCbI: YUV 4:2:2 with chroma swap
73 * @PIXFMT_NV12: YUV 4:2:0 planar
74 * @PIXFMT_OSD_ATTR: OSD Attribute Window pixel format (4bpp)
77 * An enumeration of the DaVinci pixel formats.
93 * enum osd_h_exp_ratio
94 * @H_EXP_OFF: no expansion (1/1)
95 * @H_EXP_9_OVER_8: 9/8 expansion ratio
96 * @H_EXP_3_OVER_2: 3/2 expansion ratio
99 * An enumeration of the available horizontal expansion ratios.
101 enum osd_h_exp_ratio
{
108 * enum osd_v_exp_ratio
109 * @V_EXP_OFF: no expansion (1/1)
110 * @V_EXP_6_OVER_5: 6/5 expansion ratio
113 * An enumeration of the available vertical expansion ratios.
115 enum osd_v_exp_ratio
{
121 * enum osd_zoom_factor
122 * @ZOOM_X1: no zoom (x1)
127 * An enumeration of the available zoom factors.
129 enum osd_zoom_factor
{
137 * @ROM_CLUT: ROM CLUT
138 * @RAM_CLUT: RAM CLUT
141 * An enumeration of the available Color Lookup Tables (CLUTs).
150 * @ROM_CLUT0: Macintosh CLUT
151 * @ROM_CLUT1: CLUT from DM270 and prior devices
154 * An enumeration of the ROM Color Lookup Table (CLUT) options.
162 * enum osd_blending_factor
163 * @OSD_0_VID_8: OSD pixels are fully transparent
164 * @OSD_1_VID_7: OSD pixels contribute 1/8, video pixels contribute 7/8
165 * @OSD_2_VID_6: OSD pixels contribute 2/8, video pixels contribute 6/8
166 * @OSD_3_VID_5: OSD pixels contribute 3/8, video pixels contribute 5/8
167 * @OSD_4_VID_4: OSD pixels contribute 4/8, video pixels contribute 4/8
168 * @OSD_5_VID_3: OSD pixels contribute 5/8, video pixels contribute 3/8
169 * @OSD_6_VID_2: OSD pixels contribute 6/8, video pixels contribute 2/8
170 * @OSD_8_VID_0: OSD pixels are fully opaque
173 * An enumeration of the DaVinci pixel blending factor options.
175 enum osd_blending_factor
{
187 * enum osd_blink_interval
188 * @BLINK_X1: blink interval is 1 vertical refresh cycle
189 * @BLINK_X2: blink interval is 2 vertical refresh cycles
190 * @BLINK_X3: blink interval is 3 vertical refresh cycles
191 * @BLINK_X4: blink interval is 4 vertical refresh cycles
194 * An enumeration of the DaVinci pixel blinking interval options.
196 enum osd_blink_interval
{
204 * enum osd_cursor_h_width
205 * @H_WIDTH_1: horizontal line width is 1 pixel
206 * @H_WIDTH_4: horizontal line width is 4 pixels
207 * @H_WIDTH_8: horizontal line width is 8 pixels
208 * @H_WIDTH_12: horizontal line width is 12 pixels
209 * @H_WIDTH_16: horizontal line width is 16 pixels
210 * @H_WIDTH_20: horizontal line width is 20 pixels
211 * @H_WIDTH_24: horizontal line width is 24 pixels
212 * @H_WIDTH_28: horizontal line width is 28 pixels
214 enum osd_cursor_h_width
{
226 * enum davinci_cursor_v_width
227 * @V_WIDTH_1: vertical line width is 1 line
228 * @V_WIDTH_2: vertical line width is 2 lines
229 * @V_WIDTH_4: vertical line width is 4 lines
230 * @V_WIDTH_6: vertical line width is 6 lines
231 * @V_WIDTH_8: vertical line width is 8 lines
232 * @V_WIDTH_10: vertical line width is 10 lines
233 * @V_WIDTH_12: vertical line width is 12 lines
234 * @V_WIDTH_14: vertical line width is 14 lines
236 enum osd_cursor_v_width
{
248 * struct osd_cursor_config
249 * @xsize: horizontal size in pixels
250 * @ysize: vertical size in lines
251 * @xpos: horizontal offset in pixels from the left edge of the display
252 * @ypos: vertical offset in lines from the top of the display
253 * @interlaced: Non-zero if the display is interlaced, or zero otherwise
254 * @h_width: horizontal line width
255 * @v_width: vertical line width
256 * @clut: the CLUT selector (ROM or RAM) for the cursor color
257 * @clut_index: an index into the CLUT for the cursor color
260 * A structure describing the configuration parameters of the hardware
261 * rectangular cursor.
263 struct osd_cursor_config
{
269 enum osd_cursor_h_width h_width
;
270 enum osd_cursor_v_width v_width
;
272 unsigned char clut_index
;
276 * struct osd_layer_config
277 * @pixfmt: pixel format
278 * @line_length: offset in bytes between start of each line in memory
279 * @xsize: number of horizontal pixels displayed per line
280 * @ysize: number of lines displayed
281 * @xpos: horizontal offset in pixels from the left edge of the display
282 * @ypos: vertical offset in lines from the top of the display
283 * @interlaced: Non-zero if the display is interlaced, or zero otherwise
286 * A structure describing the configuration parameters of an On-Screen Display
287 * (OSD) or video layer related to how the image is stored in memory.
288 * @line_length must be a multiple of the cache line size (32 bytes).
290 struct osd_layer_config
{
291 enum osd_pix_format pixfmt
;
292 unsigned line_length
;
300 /* parameters that apply on a per-window (OSD or video) basis */
301 struct osd_window_state
{
304 unsigned long fb_base_phys
;
305 enum osd_zoom_factor h_zoom
;
306 enum osd_zoom_factor v_zoom
;
307 struct osd_layer_config lconfig
;
310 /* parameters that apply on a per-OSD-window basis */
311 struct osd_osdwin_state
{
313 enum osd_blending_factor blend
;
314 int colorkey_blending
;
316 int rec601_attenuation
;
317 /* index is pixel value */
318 unsigned char palette_map
[16];
321 /* hardware rectangular cursor parameters */
322 struct osd_cursor_state
{
324 struct osd_cursor_config config
;
329 struct vpbe_osd_ops
{
330 int (*initialize
)(struct osd_state
*sd
);
331 int (*request_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
332 void (*release_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
333 int (*enable_layer
)(struct osd_state
*sd
, enum osd_layer layer
,
335 void (*disable_layer
)(struct osd_state
*sd
, enum osd_layer layer
);
336 int (*set_layer_config
)(struct osd_state
*sd
, enum osd_layer layer
,
337 struct osd_layer_config
*lconfig
);
338 void (*get_layer_config
)(struct osd_state
*sd
, enum osd_layer layer
,
339 struct osd_layer_config
*lconfig
);
340 void (*start_layer
)(struct osd_state
*sd
, enum osd_layer layer
,
341 unsigned long fb_base_phys
,
342 unsigned long cbcr_ofst
);
343 void (*set_left_margin
)(struct osd_state
*sd
, u32 val
);
344 void (*set_top_margin
)(struct osd_state
*sd
, u32 val
);
345 void (*set_interpolation_filter
)(struct osd_state
*sd
, int filter
);
346 int (*set_vid_expansion
)(struct osd_state
*sd
,
347 enum osd_h_exp_ratio h_exp
,
348 enum osd_v_exp_ratio v_exp
);
349 void (*get_vid_expansion
)(struct osd_state
*sd
,
350 enum osd_h_exp_ratio
*h_exp
,
351 enum osd_v_exp_ratio
*v_exp
);
352 void (*set_zoom
)(struct osd_state
*sd
, enum osd_layer layer
,
353 enum osd_zoom_factor h_zoom
,
354 enum osd_zoom_factor v_zoom
);
358 enum vpbe_version vpbe_type
;
361 dma_addr_t osd_base_phys
;
362 void __iomem
*osd_base
;
363 unsigned long osd_size
;
364 /* 1-->the isr will toggle the VID0 ping-pong buffer */
366 int interpolation_filter
;
368 enum osd_h_exp_ratio osd_h_exp
;
369 enum osd_v_exp_ratio osd_v_exp
;
370 enum osd_h_exp_ratio vid_h_exp
;
371 enum osd_v_exp_ratio vid_v_exp
;
372 enum osd_clut backg_clut
;
373 unsigned backg_clut_index
;
374 enum osd_rom_clut rom_clut
;
376 /* attribute window blinking enabled */
377 enum osd_blink_interval blink
;
378 /* YCbCrI or YCrCbI */
379 enum osd_pix_format yc_pixfmt
;
380 /* columns are Y, Cb, Cr */
381 unsigned char clut_ram
[256][3];
382 struct osd_cursor_state cursor
;
383 /* OSD0, VID0, OSD1, VID1 */
384 struct osd_window_state win
[4];
386 struct osd_osdwin_state osdwin
[2];
387 /* OSD device Operations */
388 struct vpbe_osd_ops ops
;
391 struct osd_platform_data
{
392 int field_inv_wa_enable
;