aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/davinci/vpif.h
diff options
context:
space:
mode:
authorChaithrika U S <chaithrika@ti.com>2009-06-09 04:54:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:18:01 -0400
commit63a8e71c4453a38c3468f84f0f452e2643abdad3 (patch)
treedcaf503593b2923acbd50408a54cce06be2c6522 /drivers/media/video/davinci/vpif.h
parentbb3baf89d197f392c011c64935b79ed67a6542db (diff)
V4L/DVB (12175): davinci/vpif: Add Video Port Interface (VPIF) driver
This code be used by the display and capture drivers. Signed-off-by: Manjunath Hadli <mrh@ti.com> Signed-off-by: Brijesh Jadav <brijesh.j@ti.com> Signed-off-by: Chaithrika U S <chaithrika@ti.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/davinci/vpif.h')
-rw-r--r--drivers/media/video/davinci/vpif.h632
1 files changed, 632 insertions, 0 deletions
diff --git a/drivers/media/video/davinci/vpif.h b/drivers/media/video/davinci/vpif.h
new file mode 100644
index 000000000000..fca26dcb54de
--- /dev/null
+++ b/drivers/media/video/davinci/vpif.h
@@ -0,0 +1,632 @@
1/*
2 * VPIF header file
3 *
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed .as is. WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef VPIF_H
17#define VPIF_H
18
19#include <linux/io.h>
20#include <linux/videodev2.h>
21#include <mach/hardware.h>
22
23/* Maximum channel allowed */
24#define VPIF_NUM_CHANNELS (4)
25#define VPIF_CAPTURE_NUM_CHANNELS (2)
26#define VPIF_DISPLAY_NUM_CHANNELS (2)
27
28/* Macros to read/write registers */
29static void __iomem *vpif_base;
30#define regr(reg) readl((reg) + vpif_base)
31#define regw(value, reg) writel(value, (reg + vpif_base))
32
33/* Register Addresss Offsets */
34#define VPIF_PID (0x0000)
35#define VPIF_CH0_CTRL (0x0004)
36#define VPIF_CH1_CTRL (0x0008)
37#define VPIF_CH2_CTRL (0x000C)
38#define VPIF_CH3_CTRL (0x0010)
39
40#define VPIF_INTEN (0x0020)
41#define VPIF_INTEN_SET (0x0024)
42#define VPIF_INTEN_CLR (0x0028)
43#define VPIF_STATUS (0x002C)
44#define VPIF_STATUS_CLR (0x0030)
45#define VPIF_EMULATION_CTRL (0x0034)
46#define VPIF_REQ_SIZE (0x0038)
47
48#define VPIF_CH0_TOP_STRT_ADD_LUMA (0x0040)
49#define VPIF_CH0_BTM_STRT_ADD_LUMA (0x0044)
50#define VPIF_CH0_TOP_STRT_ADD_CHROMA (0x0048)
51#define VPIF_CH0_BTM_STRT_ADD_CHROMA (0x004c)
52#define VPIF_CH0_TOP_STRT_ADD_HANC (0x0050)
53#define VPIF_CH0_BTM_STRT_ADD_HANC (0x0054)
54#define VPIF_CH0_TOP_STRT_ADD_VANC (0x0058)
55#define VPIF_CH0_BTM_STRT_ADD_VANC (0x005c)
56#define VPIF_CH0_SP_CFG (0x0060)
57#define VPIF_CH0_IMG_ADD_OFST (0x0064)
58#define VPIF_CH0_HANC_ADD_OFST (0x0068)
59#define VPIF_CH0_H_CFG (0x006c)
60#define VPIF_CH0_V_CFG_00 (0x0070)
61#define VPIF_CH0_V_CFG_01 (0x0074)
62#define VPIF_CH0_V_CFG_02 (0x0078)
63#define VPIF_CH0_V_CFG_03 (0x007c)
64
65#define VPIF_CH1_TOP_STRT_ADD_LUMA (0x0080)
66#define VPIF_CH1_BTM_STRT_ADD_LUMA (0x0084)
67#define VPIF_CH1_TOP_STRT_ADD_CHROMA (0x0088)
68#define VPIF_CH1_BTM_STRT_ADD_CHROMA (0x008c)
69#define VPIF_CH1_TOP_STRT_ADD_HANC (0x0090)
70#define VPIF_CH1_BTM_STRT_ADD_HANC (0x0094)
71#define VPIF_CH1_TOP_STRT_ADD_VANC (0x0098)
72#define VPIF_CH1_BTM_STRT_ADD_VANC (0x009c)
73#define VPIF_CH1_SP_CFG (0x00a0)
74#define VPIF_CH1_IMG_ADD_OFST (0x00a4)
75#define VPIF_CH1_HANC_ADD_OFST (0x00a8)
76#define VPIF_CH1_H_CFG (0x00ac)
77#define VPIF_CH1_V_CFG_00 (0x00b0)
78#define VPIF_CH1_V_CFG_01 (0x00b4)
79#define VPIF_CH1_V_CFG_02 (0x00b8)
80#define VPIF_CH1_V_CFG_03 (0x00bc)
81
82#define VPIF_CH2_TOP_STRT_ADD_LUMA (0x00c0)
83#define VPIF_CH2_BTM_STRT_ADD_LUMA (0x00c4)
84#define VPIF_CH2_TOP_STRT_ADD_CHROMA (0x00c8)
85#define VPIF_CH2_BTM_STRT_ADD_CHROMA (0x00cc)
86#define VPIF_CH2_TOP_STRT_ADD_HANC (0x00d0)
87#define VPIF_CH2_BTM_STRT_ADD_HANC (0x00d4)
88#define VPIF_CH2_TOP_STRT_ADD_VANC (0x00d8)
89#define VPIF_CH2_BTM_STRT_ADD_VANC (0x00dc)
90#define VPIF_CH2_SP_CFG (0x00e0)
91#define VPIF_CH2_IMG_ADD_OFST (0x00e4)
92#define VPIF_CH2_HANC_ADD_OFST (0x00e8)
93#define VPIF_CH2_H_CFG (0x00ec)
94#define VPIF_CH2_V_CFG_00 (0x00f0)
95#define VPIF_CH2_V_CFG_01 (0x00f4)
96#define VPIF_CH2_V_CFG_02 (0x00f8)
97#define VPIF_CH2_V_CFG_03 (0x00fc)
98#define VPIF_CH2_HANC0_STRT (0x0100)
99#define VPIF_CH2_HANC0_SIZE (0x0104)
100#define VPIF_CH2_HANC1_STRT (0x0108)
101#define VPIF_CH2_HANC1_SIZE (0x010c)
102#define VPIF_CH2_VANC0_STRT (0x0110)
103#define VPIF_CH2_VANC0_SIZE (0x0114)
104#define VPIF_CH2_VANC1_STRT (0x0118)
105#define VPIF_CH2_VANC1_SIZE (0x011c)
106
107#define VPIF_CH3_TOP_STRT_ADD_LUMA (0x0140)
108#define VPIF_CH3_BTM_STRT_ADD_LUMA (0x0144)
109#define VPIF_CH3_TOP_STRT_ADD_CHROMA (0x0148)
110#define VPIF_CH3_BTM_STRT_ADD_CHROMA (0x014c)
111#define VPIF_CH3_TOP_STRT_ADD_HANC (0x0150)
112#define VPIF_CH3_BTM_STRT_ADD_HANC (0x0154)
113#define VPIF_CH3_TOP_STRT_ADD_VANC (0x0158)
114#define VPIF_CH3_BTM_STRT_ADD_VANC (0x015c)
115#define VPIF_CH3_SP_CFG (0x0160)
116#define VPIF_CH3_IMG_ADD_OFST (0x0164)
117#define VPIF_CH3_HANC_ADD_OFST (0x0168)
118#define VPIF_CH3_H_CFG (0x016c)
119#define VPIF_CH3_V_CFG_00 (0x0170)
120#define VPIF_CH3_V_CFG_01 (0x0174)
121#define VPIF_CH3_V_CFG_02 (0x0178)
122#define VPIF_CH3_V_CFG_03 (0x017c)
123#define VPIF_CH3_HANC0_STRT (0x0180)
124#define VPIF_CH3_HANC0_SIZE (0x0184)
125#define VPIF_CH3_HANC1_STRT (0x0188)
126#define VPIF_CH3_HANC1_SIZE (0x018c)
127#define VPIF_CH3_VANC0_STRT (0x0190)
128#define VPIF_CH3_VANC0_SIZE (0x0194)
129#define VPIF_CH3_VANC1_STRT (0x0198)
130#define VPIF_CH3_VANC1_SIZE (0x019c)
131
132#define VPIF_IODFT_CTRL (0x01c0)
133
134/* Functions for bit Manipulation */
135static inline void vpif_set_bit(u32 reg, u32 bit)
136{
137 regw((regr(reg)) | (0x01 << bit), reg);
138}
139
140static inline void vpif_clr_bit(u32 reg, u32 bit)
141{
142 regw(((regr(reg)) & ~(0x01 << bit)), reg);
143}
144
145/* Macro for Generating mask */
146#ifdef GENERATE_MASK
147#undef GENERATE_MASK
148#endif
149
150#define GENERATE_MASK(bits, pos) \
151 ((((0xFFFFFFFF) << (32 - bits)) >> (32 - bits)) << pos)
152
153/* Bit positions in the channel control registers */
154#define VPIF_CH_DATA_MODE_BIT (2)
155#define VPIF_CH_YC_MUX_BIT (3)
156#define VPIF_CH_SDR_FMT_BIT (4)
157#define VPIF_CH_HANC_EN_BIT (8)
158#define VPIF_CH_VANC_EN_BIT (9)
159
160#define VPIF_CAPTURE_CH_NIP (10)
161#define VPIF_DISPLAY_CH_NIP (11)
162
163#define VPIF_DISPLAY_PIX_EN_BIT (10)
164
165#define VPIF_CH_INPUT_FIELD_FRAME_BIT (12)
166
167#define VPIF_CH_FID_POLARITY_BIT (15)
168#define VPIF_CH_V_VALID_POLARITY_BIT (14)
169#define VPIF_CH_H_VALID_POLARITY_BIT (13)
170#define VPIF_CH_DATA_WIDTH_BIT (28)
171
172#define VPIF_CH_CLK_EDGE_CTRL_BIT (31)
173
174/* Mask various length */
175#define VPIF_CH_EAVSAV_MASK GENERATE_MASK(13, 0)
176#define VPIF_CH_LEN_MASK GENERATE_MASK(12, 0)
177#define VPIF_CH_WIDTH_MASK GENERATE_MASK(13, 0)
178#define VPIF_CH_LEN_SHIFT (16)
179
180/* VPIF masks for registers */
181#define VPIF_REQ_SIZE_MASK (0x1ff)
182
183/* bit posotion of interrupt vpif_ch_intr register */
184#define VPIF_INTEN_FRAME_CH0 (0x00000001)
185#define VPIF_INTEN_FRAME_CH1 (0x00000002)
186#define VPIF_INTEN_FRAME_CH2 (0x00000004)
187#define VPIF_INTEN_FRAME_CH3 (0x00000008)
188
189/* bit position of clock and channel enable in vpif_chn_ctrl register */
190
191#define VPIF_CH0_CLK_EN (0x00000002)
192#define VPIF_CH0_EN (0x00000001)
193#define VPIF_CH1_CLK_EN (0x00000002)
194#define VPIF_CH1_EN (0x00000001)
195#define VPIF_CH2_CLK_EN (0x00000002)
196#define VPIF_CH2_EN (0x00000001)
197#define VPIF_CH3_CLK_EN (0x00000002)
198#define VPIF_CH3_EN (0x00000001)
199#define VPIF_CH_CLK_EN (0x00000002)
200#define VPIF_CH_EN (0x00000001)
201
202#define VPIF_INT_TOP (0x00)
203#define VPIF_INT_BOTTOM (0x01)
204#define VPIF_INT_BOTH (0x02)
205
206#define VPIF_CH0_INT_CTRL_SHIFT (6)
207#define VPIF_CH1_INT_CTRL_SHIFT (6)
208#define VPIF_CH2_INT_CTRL_SHIFT (6)
209#define VPIF_CH3_INT_CTRL_SHIFT (6)
210#define VPIF_CH_INT_CTRL_SHIFT (6)
211
212/* enabled interrupt on both the fields on vpid_ch0_ctrl register */
213#define channel0_intr_assert() (regw((regr(VPIF_CH0_CTRL)|\
214 (VPIF_INT_BOTH << VPIF_CH0_INT_CTRL_SHIFT)), VPIF_CH0_CTRL))
215
216/* enabled interrupt on both the fields on vpid_ch1_ctrl register */
217#define channel1_intr_assert() (regw((regr(VPIF_CH1_CTRL)|\
218 (VPIF_INT_BOTH << VPIF_CH1_INT_CTRL_SHIFT)), VPIF_CH1_CTRL))
219
220/* enabled interrupt on both the fields on vpid_ch0_ctrl register */
221#define channel2_intr_assert() (regw((regr(VPIF_CH2_CTRL)|\
222 (VPIF_INT_BOTH << VPIF_CH2_INT_CTRL_SHIFT)), VPIF_CH2_CTRL))
223
224/* enabled interrupt on both the fields on vpid_ch1_ctrl register */
225#define channel3_intr_assert() (regw((regr(VPIF_CH3_CTRL)|\
226 (VPIF_INT_BOTH << VPIF_CH3_INT_CTRL_SHIFT)), VPIF_CH3_CTRL))
227
228#define VPIF_CH_FID_MASK (0x20)
229#define VPIF_CH_FID_SHIFT (5)
230
231#define VPIF_NTSC_VBI_START_FIELD0 (1)
232#define VPIF_NTSC_VBI_START_FIELD1 (263)
233#define VPIF_PAL_VBI_START_FIELD0 (624)
234#define VPIF_PAL_VBI_START_FIELD1 (311)
235
236#define VPIF_NTSC_HBI_START_FIELD0 (1)
237#define VPIF_NTSC_HBI_START_FIELD1 (263)
238#define VPIF_PAL_HBI_START_FIELD0 (624)
239#define VPIF_PAL_HBI_START_FIELD1 (311)
240
241#define VPIF_NTSC_VBI_COUNT_FIELD0 (20)
242#define VPIF_NTSC_VBI_COUNT_FIELD1 (19)
243#define VPIF_PAL_VBI_COUNT_FIELD0 (24)
244#define VPIF_PAL_VBI_COUNT_FIELD1 (25)
245
246#define VPIF_NTSC_HBI_COUNT_FIELD0 (263)
247#define VPIF_NTSC_HBI_COUNT_FIELD1 (262)
248#define VPIF_PAL_HBI_COUNT_FIELD0 (312)
249#define VPIF_PAL_HBI_COUNT_FIELD1 (313)
250
251#define VPIF_NTSC_VBI_SAMPLES_PER_LINE (720)
252#define VPIF_PAL_VBI_SAMPLES_PER_LINE (720)
253#define VPIF_NTSC_HBI_SAMPLES_PER_LINE (268)
254#define VPIF_PAL_HBI_SAMPLES_PER_LINE (280)
255
256#define VPIF_CH_VANC_EN (0x20)
257#define VPIF_DMA_REQ_SIZE (0x080)
258#define VPIF_EMULATION_DISABLE (0x01)
259
260extern u8 irq_vpif_capture_channel[VPIF_NUM_CHANNELS];
261
262/* inline function to enable/disable channel0 */
263static inline void enable_channel0(int enable)
264{
265 if (enable)
266 regw((regr(VPIF_CH0_CTRL) | (VPIF_CH0_EN)), VPIF_CH0_CTRL);
267 else
268 regw((regr(VPIF_CH0_CTRL) & (~VPIF_CH0_EN)), VPIF_CH0_CTRL);
269}
270
271/* inline function to enable/disable channel1 */
272static inline void enable_channel1(int enable)
273{
274 if (enable)
275 regw((regr(VPIF_CH1_CTRL) | (VPIF_CH1_EN)), VPIF_CH1_CTRL);
276 else
277 regw((regr(VPIF_CH1_CTRL) & (~VPIF_CH1_EN)), VPIF_CH1_CTRL);
278}
279
280/* inline function to enable interrupt for channel0 */
281static inline void channel0_intr_enable(int enable)
282{
283 if (enable) {
284 regw((regr(VPIF_INTEN) | 0x10), VPIF_INTEN);
285 regw((regr(VPIF_INTEN_SET) | 0x10), VPIF_INTEN_SET);
286
287 regw((regr(VPIF_INTEN) | VPIF_INTEN_FRAME_CH0), VPIF_INTEN);
288 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH0),
289 VPIF_INTEN_SET);
290 } else {
291 regw((regr(VPIF_INTEN) & (~VPIF_INTEN_FRAME_CH0)), VPIF_INTEN);
292 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH0),
293 VPIF_INTEN_SET);
294 }
295}
296
297/* inline function to enable interrupt for channel1 */
298static inline void channel1_intr_enable(int enable)
299{
300 if (enable) {
301 regw((regr(VPIF_INTEN) | 0x10), VPIF_INTEN);
302 regw((regr(VPIF_INTEN_SET) | 0x10), VPIF_INTEN_SET);
303
304 regw((regr(VPIF_INTEN) | VPIF_INTEN_FRAME_CH1), VPIF_INTEN);
305 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH1),
306 VPIF_INTEN_SET);
307 } else {
308 regw((regr(VPIF_INTEN) & (~VPIF_INTEN_FRAME_CH1)), VPIF_INTEN);
309 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH1),
310 VPIF_INTEN_SET);
311 }
312}
313
314/* inline function to set buffer addresses in case of Y/C non mux mode */
315static inline void ch0_set_videobuf_addr_yc_nmux(unsigned long top_strt_luma,
316 unsigned long btm_strt_luma,
317 unsigned long top_strt_chroma,
318 unsigned long btm_strt_chroma)
319{
320 regw(top_strt_luma, VPIF_CH0_TOP_STRT_ADD_LUMA);
321 regw(btm_strt_luma, VPIF_CH0_BTM_STRT_ADD_LUMA);
322 regw(top_strt_chroma, VPIF_CH1_TOP_STRT_ADD_CHROMA);
323 regw(btm_strt_chroma, VPIF_CH1_BTM_STRT_ADD_CHROMA);
324}
325
326/* inline function to set buffer addresses in VPIF registers for video data */
327static inline void ch0_set_videobuf_addr(unsigned long top_strt_luma,
328 unsigned long btm_strt_luma,
329 unsigned long top_strt_chroma,
330 unsigned long btm_strt_chroma)
331{
332 regw(top_strt_luma, VPIF_CH0_TOP_STRT_ADD_LUMA);
333 regw(btm_strt_luma, VPIF_CH0_BTM_STRT_ADD_LUMA);
334 regw(top_strt_chroma, VPIF_CH0_TOP_STRT_ADD_CHROMA);
335 regw(btm_strt_chroma, VPIF_CH0_BTM_STRT_ADD_CHROMA);
336}
337
338static inline void ch1_set_videobuf_addr(unsigned long top_strt_luma,
339 unsigned long btm_strt_luma,
340 unsigned long top_strt_chroma,
341 unsigned long btm_strt_chroma)
342{
343
344 regw(top_strt_luma, VPIF_CH1_TOP_STRT_ADD_LUMA);
345 regw(btm_strt_luma, VPIF_CH1_BTM_STRT_ADD_LUMA);
346 regw(top_strt_chroma, VPIF_CH1_TOP_STRT_ADD_CHROMA);
347 regw(btm_strt_chroma, VPIF_CH1_BTM_STRT_ADD_CHROMA);
348}
349
350static inline void ch0_set_vbi_addr(unsigned long top_vbi,
351 unsigned long btm_vbi, unsigned long a, unsigned long b)
352{
353 regw(top_vbi, VPIF_CH0_TOP_STRT_ADD_VANC);
354 regw(btm_vbi, VPIF_CH0_BTM_STRT_ADD_VANC);
355}
356
357static inline void ch0_set_hbi_addr(unsigned long top_vbi,
358 unsigned long btm_vbi, unsigned long a, unsigned long b)
359{
360 regw(top_vbi, VPIF_CH0_TOP_STRT_ADD_HANC);
361 regw(btm_vbi, VPIF_CH0_BTM_STRT_ADD_HANC);
362}
363
364static inline void ch1_set_vbi_addr(unsigned long top_vbi,
365 unsigned long btm_vbi, unsigned long a, unsigned long b)
366{
367 regw(top_vbi, VPIF_CH1_TOP_STRT_ADD_VANC);
368 regw(btm_vbi, VPIF_CH1_BTM_STRT_ADD_VANC);
369}
370
371static inline void ch1_set_hbi_addr(unsigned long top_vbi,
372 unsigned long btm_vbi, unsigned long a, unsigned long b)
373{
374 regw(top_vbi, VPIF_CH1_TOP_STRT_ADD_HANC);
375 regw(btm_vbi, VPIF_CH1_BTM_STRT_ADD_HANC);
376}
377
378/* Inline function to enable raw vbi in the given channel */
379static inline void disable_raw_feature(u8 channel_id, u8 index)
380{
381 u32 ctrl_reg;
382 if (0 == channel_id)
383 ctrl_reg = VPIF_CH0_CTRL;
384 else
385 ctrl_reg = VPIF_CH1_CTRL;
386
387 if (1 == index)
388 vpif_clr_bit(ctrl_reg, VPIF_CH_VANC_EN_BIT);
389 else
390 vpif_clr_bit(ctrl_reg, VPIF_CH_HANC_EN_BIT);
391}
392
393static inline void enable_raw_feature(u8 channel_id, u8 index)
394{
395 u32 ctrl_reg;
396 if (0 == channel_id)
397 ctrl_reg = VPIF_CH0_CTRL;
398 else
399 ctrl_reg = VPIF_CH1_CTRL;
400
401 if (1 == index)
402 vpif_set_bit(ctrl_reg, VPIF_CH_VANC_EN_BIT);
403 else
404 vpif_set_bit(ctrl_reg, VPIF_CH_HANC_EN_BIT);
405}
406
407/* inline function to enable/disable channel2 */
408static inline void enable_channel2(int enable)
409{
410 if (enable) {
411 regw((regr(VPIF_CH2_CTRL) | (VPIF_CH2_CLK_EN)), VPIF_CH2_CTRL);
412 regw((regr(VPIF_CH2_CTRL) | (VPIF_CH2_EN)), VPIF_CH2_CTRL);
413 } else {
414 regw((regr(VPIF_CH2_CTRL) & (~VPIF_CH2_CLK_EN)), VPIF_CH2_CTRL);
415 regw((regr(VPIF_CH2_CTRL) & (~VPIF_CH2_EN)), VPIF_CH2_CTRL);
416 }
417}
418
419/* inline function to enable/disable channel3 */
420static inline void enable_channel3(int enable)
421{
422 if (enable) {
423 regw((regr(VPIF_CH3_CTRL) | (VPIF_CH3_CLK_EN)), VPIF_CH3_CTRL);
424 regw((regr(VPIF_CH3_CTRL) | (VPIF_CH3_EN)), VPIF_CH3_CTRL);
425 } else {
426 regw((regr(VPIF_CH3_CTRL) & (~VPIF_CH3_CLK_EN)), VPIF_CH3_CTRL);
427 regw((regr(VPIF_CH3_CTRL) & (~VPIF_CH3_EN)), VPIF_CH3_CTRL);
428 }
429}
430
431/* inline function to enable interrupt for channel2 */
432static inline void channel2_intr_enable(int enable)
433{
434 if (enable) {
435 regw((regr(VPIF_INTEN) | 0x10), VPIF_INTEN);
436 regw((regr(VPIF_INTEN_SET) | 0x10), VPIF_INTEN_SET);
437 regw((regr(VPIF_INTEN) | VPIF_INTEN_FRAME_CH2), VPIF_INTEN);
438 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH2),
439 VPIF_INTEN_SET);
440 } else {
441 regw((regr(VPIF_INTEN) & (~VPIF_INTEN_FRAME_CH2)), VPIF_INTEN);
442 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH2),
443 VPIF_INTEN_SET);
444 }
445}
446
447/* inline function to enable interrupt for channel3 */
448static inline void channel3_intr_enable(int enable)
449{
450 if (enable) {
451 regw((regr(VPIF_INTEN) | 0x10), VPIF_INTEN);
452 regw((regr(VPIF_INTEN_SET) | 0x10), VPIF_INTEN_SET);
453
454 regw((regr(VPIF_INTEN) | VPIF_INTEN_FRAME_CH3), VPIF_INTEN);
455 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH3),
456 VPIF_INTEN_SET);
457 } else {
458 regw((regr(VPIF_INTEN) & (~VPIF_INTEN_FRAME_CH3)), VPIF_INTEN);
459 regw((regr(VPIF_INTEN_SET) | VPIF_INTEN_FRAME_CH3),
460 VPIF_INTEN_SET);
461 }
462}
463
464/* inline function to enable raw vbi data for channel2 */
465static inline void channel2_raw_enable(int enable, u8 index)
466{
467 u32 mask;
468
469 if (1 == index)
470 mask = VPIF_CH_VANC_EN_BIT;
471 else
472 mask = VPIF_CH_HANC_EN_BIT;
473
474 if (enable)
475 vpif_set_bit(VPIF_CH2_CTRL, mask);
476 else
477 vpif_clr_bit(VPIF_CH2_CTRL, mask);
478}
479
480/* inline function to enable raw vbi data for channel3*/
481static inline void channel3_raw_enable(int enable, u8 index)
482{
483 u32 mask;
484
485 if (1 == index)
486 mask = VPIF_CH_VANC_EN_BIT;
487 else
488 mask = VPIF_CH_HANC_EN_BIT;
489
490 if (enable)
491 vpif_set_bit(VPIF_CH3_CTRL, mask);
492 else
493 vpif_clr_bit(VPIF_CH3_CTRL, mask);
494}
495
496/* inline function to set buffer addresses in case of Y/C non mux mode */
497static inline void ch2_set_videobuf_addr_yc_nmux(unsigned long top_strt_luma,
498 unsigned long btm_strt_luma,
499 unsigned long top_strt_chroma,
500 unsigned long btm_strt_chroma)
501{
502 regw(top_strt_luma, VPIF_CH2_TOP_STRT_ADD_LUMA);
503 regw(btm_strt_luma, VPIF_CH2_BTM_STRT_ADD_LUMA);
504 regw(top_strt_chroma, VPIF_CH3_TOP_STRT_ADD_CHROMA);
505 regw(btm_strt_chroma, VPIF_CH3_BTM_STRT_ADD_CHROMA);
506}
507
508/* inline function to set buffer addresses in VPIF registers for video data */
509static inline void ch2_set_videobuf_addr(unsigned long top_strt_luma,
510 unsigned long btm_strt_luma,
511 unsigned long top_strt_chroma,
512 unsigned long btm_strt_chroma)
513{
514 regw(top_strt_luma, VPIF_CH2_TOP_STRT_ADD_LUMA);
515 regw(btm_strt_luma, VPIF_CH2_BTM_STRT_ADD_LUMA);
516 regw(top_strt_chroma, VPIF_CH2_TOP_STRT_ADD_CHROMA);
517 regw(btm_strt_chroma, VPIF_CH2_BTM_STRT_ADD_CHROMA);
518}
519
520static inline void ch3_set_videobuf_addr(unsigned long top_strt_luma,
521 unsigned long btm_strt_luma,
522 unsigned long top_strt_chroma,
523 unsigned long btm_strt_chroma)
524{
525 regw(top_strt_luma, VPIF_CH3_TOP_STRT_ADD_LUMA);
526 regw(btm_strt_luma, VPIF_CH3_BTM_STRT_ADD_LUMA);
527 regw(top_strt_chroma, VPIF_CH3_TOP_STRT_ADD_CHROMA);
528 regw(btm_strt_chroma, VPIF_CH3_BTM_STRT_ADD_CHROMA);
529}
530
531/* inline function to set buffer addresses in VPIF registers for vbi data */
532static inline void ch2_set_vbi_addr(unsigned long top_strt_luma,
533 unsigned long btm_strt_luma,
534 unsigned long top_strt_chroma,
535 unsigned long btm_strt_chroma)
536{
537 regw(top_strt_luma, VPIF_CH2_TOP_STRT_ADD_VANC);
538 regw(btm_strt_luma, VPIF_CH2_BTM_STRT_ADD_VANC);
539}
540
541static inline void ch3_set_vbi_addr(unsigned long top_strt_luma,
542 unsigned long btm_strt_luma,
543 unsigned long top_strt_chroma,
544 unsigned long btm_strt_chroma)
545{
546 regw(top_strt_luma, VPIF_CH3_TOP_STRT_ADD_VANC);
547 regw(btm_strt_luma, VPIF_CH3_BTM_STRT_ADD_VANC);
548}
549
550#define VPIF_MAX_NAME (30)
551
552/* This structure will store size parameters as per the mode selected by user */
553struct vpif_channel_config_params {
554 char name[VPIF_MAX_NAME]; /* Name of the mode */
555 u16 width; /* Indicates width of the image */
556 u16 height; /* Indicates height of the image */
557 u8 fps;
558 u8 frm_fmt; /* Indicates whether this is interlaced
559 * or progressive format */
560 u8 ycmux_mode; /* Indicates whether this mode requires
561 * single or two channels */
562 u16 eav2sav; /* length of sav 2 eav */
563 u16 sav2eav; /* length of sav 2 eav */
564 u16 l1, l3, l5, l7, l9, l11; /* Other parameter configurations */
565 u16 vsize; /* Vertical size of the image */
566 u8 capture_format; /* Indicates whether capture format
567 * is in BT or in CCD/CMOS */
568 u8 vbi_supported; /* Indicates whether this mode
569 * supports capturing vbi or not */
570 u8 hd_sd;
571 v4l2_std_id stdid;
572};
573
574struct vpif_interface;
575struct vpif_params;
576struct vpif_vbi_params;
577
578int vpif_set_video_params(struct vpif_params *vpifparams, u8 channel_id);
579void vpif_set_vbi_display_params(struct vpif_vbi_params *vbiparams,
580 u8 channel_id);
581int vpif_channel_getfid(u8 channel_id);
582void vpif_base_addr_init(void __iomem *base);
583
584/* Enumerated data types */
585enum vpif_capture_pinpol {
586 VPIF_CAPTURE_PINPOL_SAME = 0,
587 VPIF_CAPTURE_PINPOL_INVERT = 1
588};
589
590enum data_size {
591 _8BITS = 0,
592 _10BITS,
593 _12BITS,
594};
595
596struct vpif_capture_params_raw {
597 enum data_size data_sz;
598 enum vpif_capture_pinpol fid_pol;
599 enum vpif_capture_pinpol vd_pol;
600 enum vpif_capture_pinpol hd_pol;
601};
602
603/* Structure for vpif parameters for raw vbi data */
604struct vpif_vbi_params {
605 __u32 hstart0; /* Horizontal start of raw vbi data for first field */
606 __u32 vstart0; /* Vertical start of raw vbi data for first field */
607 __u32 hsize0; /* Horizontal size of raw vbi data for first field */
608 __u32 vsize0; /* Vertical size of raw vbi data for first field */
609 __u32 hstart1; /* Horizontal start of raw vbi data for second field */
610 __u32 vstart1; /* Vertical start of raw vbi data for second field */
611 __u32 hsize1; /* Horizontal size of raw vbi data for second field */
612 __u32 vsize1; /* Vertical size of raw vbi data for second field */
613};
614
615/* structure for vpif parameters */
616struct vpif_interface {
617 __u8 storage_mode; /* Indicates field or frame mode */
618 unsigned long hpitch;
619 v4l2_std_id stdid;
620};
621
622struct vpif_params {
623 struct vpif_interface video_params;
624 struct vpif_channel_config_params std_info;
625 union param {
626 struct vpif_vbi_params vbi_params;
627 struct vpif_capture_params_raw raw_params;
628 } params;
629};
630
631#endif /* End of #ifndef VPIF_H */
632