aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/davinci/vpbe_osd.h
diff options
context:
space:
mode:
authorManjunath Hadli <manjunath.hadli@ti.com>2011-06-17 03:01:33 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:10 -0400
commitff0f23dd0edf4a5bd5fa3ee0eda71d8a1c8201d4 (patch)
tree596ace1af7c7603752f61b4846a287cbebb96c87 /include/media/davinci/vpbe_osd.h
parent66715cdc3224a4e241c1a92856b9a4af3b70e06d (diff)
[media] davinci vpbe: OSD(On Screen Display) block
This patch implements the functionality of the OSD block of the VPBE. The OSD in total supports 4 planes or Video sources - 2 mainly RGB and 2 Video. The patch implements general handling of all the planes, with specific emphasis on the Video plane capabilities as the Video planes are supported through the V4L2 driver. Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Muralidharan Karicheri <m-karicheri2@ti.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/davinci/vpbe_osd.h')
-rw-r--r--include/media/davinci/vpbe_osd.h394
1 files changed, 394 insertions, 0 deletions
diff --git a/include/media/davinci/vpbe_osd.h b/include/media/davinci/vpbe_osd.h
new file mode 100644
index 000000000000..d7e397a444e6
--- /dev/null
+++ b/include/media/davinci/vpbe_osd.h
@@ -0,0 +1,394 @@
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
27#include <media/davinci/vpbe_types.h>
28
29#define VPBE_OSD_SUBDEV_NAME "vpbe-osd"
30
31/**
32 * enum osd_layer
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
37 *
38 * Description:
39 * An enumeration of the osd display layers.
40 */
41enum osd_layer {
42 WIN_OSD0,
43 WIN_VID0,
44 WIN_OSD1,
45 WIN_VID1,
46};
47
48/**
49 * enum osd_win_layer
50 * @OSDWIN_OSD0: On-Screen Display Window 0
51 * @OSDWIN_OSD1: On-Screen Display Window 1
52 *
53 * Description:
54 * An enumeration of the OSD Window layers.
55 */
56enum osd_win_layer {
57 OSDWIN_OSD0,
58 OSDWIN_OSD1,
59};
60
61/**
62 * enum osd_pix_format
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)
73 *
74 * Description:
75 * An enumeration of the DaVinci pixel formats.
76 */
77enum osd_pix_format {
78 PIXFMT_1BPP = 0,
79 PIXFMT_2BPP,
80 PIXFMT_4BPP,
81 PIXFMT_8BPP,
82 PIXFMT_RGB565,
83 PIXFMT_YCbCrI,
84 PIXFMT_RGB888,
85 PIXFMT_YCrCbI,
86 PIXFMT_NV12,
87 PIXFMT_OSD_ATTR,
88};
89
90/**
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
95 *
96 * Description:
97 * An enumeration of the available horizontal expansion ratios.
98 */
99enum osd_h_exp_ratio {
100 H_EXP_OFF,
101 H_EXP_9_OVER_8,
102 H_EXP_3_OVER_2,
103};
104
105/**
106 * enum osd_v_exp_ratio
107 * @V_EXP_OFF: no expansion (1/1)
108 * @V_EXP_6_OVER_5: 6/5 expansion ratio
109 *
110 * Description:
111 * An enumeration of the available vertical expansion ratios.
112 */
113enum osd_v_exp_ratio {
114 V_EXP_OFF,
115 V_EXP_6_OVER_5,
116};
117
118/**
119 * enum osd_zoom_factor
120 * @ZOOM_X1: no zoom (x1)
121 * @ZOOM_X2: x2 zoom
122 * @ZOOM_X4: x4 zoom
123 *
124 * Description:
125 * An enumeration of the available zoom factors.
126 */
127enum osd_zoom_factor {
128 ZOOM_X1,
129 ZOOM_X2,
130 ZOOM_X4,
131};
132
133/**
134 * enum osd_clut
135 * @ROM_CLUT: ROM CLUT
136 * @RAM_CLUT: RAM CLUT
137 *
138 * Description:
139 * An enumeration of the available Color Lookup Tables (CLUTs).
140 */
141enum osd_clut {
142 ROM_CLUT,
143 RAM_CLUT,
144};
145
146/**
147 * enum osd_rom_clut
148 * @ROM_CLUT0: Macintosh CLUT
149 * @ROM_CLUT1: CLUT from DM270 and prior devices
150 *
151 * Description:
152 * An enumeration of the ROM Color Lookup Table (CLUT) options.
153 */
154enum osd_rom_clut {
155 ROM_CLUT0,
156 ROM_CLUT1,
157};
158
159/**
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
169 *
170 * Description:
171 * An enumeration of the DaVinci pixel blending factor options.
172 */
173enum osd_blending_factor {
174 OSD_0_VID_8,
175 OSD_1_VID_7,
176 OSD_2_VID_6,
177 OSD_3_VID_5,
178 OSD_4_VID_4,
179 OSD_5_VID_3,
180 OSD_6_VID_2,
181 OSD_8_VID_0,
182};
183
184/**
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
190 *
191 * Description:
192 * An enumeration of the DaVinci pixel blinking interval options.
193 */
194enum osd_blink_interval {
195 BLINK_X1,
196 BLINK_X2,
197 BLINK_X3,
198 BLINK_X4,
199};
200
201/**
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
211 */
212enum osd_cursor_h_width {
213 H_WIDTH_1,
214 H_WIDTH_4,
215 H_WIDTH_8,
216 H_WIDTH_12,
217 H_WIDTH_16,
218 H_WIDTH_20,
219 H_WIDTH_24,
220 H_WIDTH_28,
221};
222
223/**
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
233 */
234enum osd_cursor_v_width {
235 V_WIDTH_1,
236 V_WIDTH_2,
237 V_WIDTH_4,
238 V_WIDTH_6,
239 V_WIDTH_8,
240 V_WIDTH_10,
241 V_WIDTH_12,
242 V_WIDTH_14,
243};
244
245/**
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
256 *
257 * Description:
258 * A structure describing the configuration parameters of the hardware
259 * rectangular cursor.
260 */
261struct osd_cursor_config {
262 unsigned xsize;
263 unsigned ysize;
264 unsigned xpos;
265 unsigned ypos;
266 int interlaced;
267 enum osd_cursor_h_width h_width;
268 enum osd_cursor_v_width v_width;
269 enum osd_clut clut;
270 unsigned char clut_index;
271};
272
273/**
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
282 *
283 * Description:
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).
287 */
288struct osd_layer_config {
289 enum osd_pix_format pixfmt;
290 unsigned line_length;
291 unsigned xsize;
292 unsigned ysize;
293 unsigned xpos;
294 unsigned ypos;
295 int interlaced;
296};
297
298/* parameters that apply on a per-window (OSD or video) basis */
299struct osd_window_state {
300 int is_allocated;
301 int is_enabled;
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;
306};
307
308/* parameters that apply on a per-OSD-window basis */
309struct osd_osdwin_state {
310 enum osd_clut clut;
311 enum osd_blending_factor blend;
312 int colorkey_blending;
313 unsigned colorkey;
314 int rec601_attenuation;
315 /* index is pixel value */
316 unsigned char palette_map[16];
317};
318
319/* hardware rectangular cursor parameters */
320struct osd_cursor_state {
321 int is_enabled;
322 struct osd_cursor_config config;
323};
324
325struct osd_state;
326
327struct 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,
332 int otherwin);
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);
353};
354
355struct osd_state {
356 enum vpbe_version vpbe_type;
357 spinlock_t lock;
358 struct device *dev;
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 */
363 int pingpong;
364 int interpolation_filter;
365 int field_inversion;
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;
373 int is_blinking;
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];
383 /* OSD0, OSD1 */
384 struct osd_osdwin_state osdwin[2];
385 /* OSD device Operations */
386 struct vpbe_osd_ops ops;
387};
388
389struct osd_platform_data {
390 enum vpbe_version vpbe_type;
391 int field_inv_wa_enable;
392};
393
394#endif