20 #include <linux/videodev2.h>
24 #define VPIF_NUM_CHANNELS (4)
25 #define VPIF_CAPTURE_NUM_CHANNELS (2)
26 #define VPIF_DISPLAY_NUM_CHANNELS (2)
32 #define regr(reg) readl((reg) + vpif_base)
33 #define regw(value, reg) writel(value, (reg + vpif_base))
36 #define VPIF_PID (0x0000)
37 #define VPIF_CH0_CTRL (0x0004)
38 #define VPIF_CH1_CTRL (0x0008)
39 #define VPIF_CH2_CTRL (0x000C)
40 #define VPIF_CH3_CTRL (0x0010)
42 #define VPIF_INTEN (0x0020)
43 #define VPIF_INTEN_SET (0x0024)
44 #define VPIF_INTEN_CLR (0x0028)
45 #define VPIF_STATUS (0x002C)
46 #define VPIF_STATUS_CLR (0x0030)
47 #define VPIF_EMULATION_CTRL (0x0034)
48 #define VPIF_REQ_SIZE (0x0038)
50 #define VPIF_CH0_TOP_STRT_ADD_LUMA (0x0040)
51 #define VPIF_CH0_BTM_STRT_ADD_LUMA (0x0044)
52 #define VPIF_CH0_TOP_STRT_ADD_CHROMA (0x0048)
53 #define VPIF_CH0_BTM_STRT_ADD_CHROMA (0x004c)
54 #define VPIF_CH0_TOP_STRT_ADD_HANC (0x0050)
55 #define VPIF_CH0_BTM_STRT_ADD_HANC (0x0054)
56 #define VPIF_CH0_TOP_STRT_ADD_VANC (0x0058)
57 #define VPIF_CH0_BTM_STRT_ADD_VANC (0x005c)
58 #define VPIF_CH0_SP_CFG (0x0060)
59 #define VPIF_CH0_IMG_ADD_OFST (0x0064)
60 #define VPIF_CH0_HANC_ADD_OFST (0x0068)
61 #define VPIF_CH0_H_CFG (0x006c)
62 #define VPIF_CH0_V_CFG_00 (0x0070)
63 #define VPIF_CH0_V_CFG_01 (0x0074)
64 #define VPIF_CH0_V_CFG_02 (0x0078)
65 #define VPIF_CH0_V_CFG_03 (0x007c)
67 #define VPIF_CH1_TOP_STRT_ADD_LUMA (0x0080)
68 #define VPIF_CH1_BTM_STRT_ADD_LUMA (0x0084)
69 #define VPIF_CH1_TOP_STRT_ADD_CHROMA (0x0088)
70 #define VPIF_CH1_BTM_STRT_ADD_CHROMA (0x008c)
71 #define VPIF_CH1_TOP_STRT_ADD_HANC (0x0090)
72 #define VPIF_CH1_BTM_STRT_ADD_HANC (0x0094)
73 #define VPIF_CH1_TOP_STRT_ADD_VANC (0x0098)
74 #define VPIF_CH1_BTM_STRT_ADD_VANC (0x009c)
75 #define VPIF_CH1_SP_CFG (0x00a0)
76 #define VPIF_CH1_IMG_ADD_OFST (0x00a4)
77 #define VPIF_CH1_HANC_ADD_OFST (0x00a8)
78 #define VPIF_CH1_H_CFG (0x00ac)
79 #define VPIF_CH1_V_CFG_00 (0x00b0)
80 #define VPIF_CH1_V_CFG_01 (0x00b4)
81 #define VPIF_CH1_V_CFG_02 (0x00b8)
82 #define VPIF_CH1_V_CFG_03 (0x00bc)
84 #define VPIF_CH2_TOP_STRT_ADD_LUMA (0x00c0)
85 #define VPIF_CH2_BTM_STRT_ADD_LUMA (0x00c4)
86 #define VPIF_CH2_TOP_STRT_ADD_CHROMA (0x00c8)
87 #define VPIF_CH2_BTM_STRT_ADD_CHROMA (0x00cc)
88 #define VPIF_CH2_TOP_STRT_ADD_HANC (0x00d0)
89 #define VPIF_CH2_BTM_STRT_ADD_HANC (0x00d4)
90 #define VPIF_CH2_TOP_STRT_ADD_VANC (0x00d8)
91 #define VPIF_CH2_BTM_STRT_ADD_VANC (0x00dc)
92 #define VPIF_CH2_SP_CFG (0x00e0)
93 #define VPIF_CH2_IMG_ADD_OFST (0x00e4)
94 #define VPIF_CH2_HANC_ADD_OFST (0x00e8)
95 #define VPIF_CH2_H_CFG (0x00ec)
96 #define VPIF_CH2_V_CFG_00 (0x00f0)
97 #define VPIF_CH2_V_CFG_01 (0x00f4)
98 #define VPIF_CH2_V_CFG_02 (0x00f8)
99 #define VPIF_CH2_V_CFG_03 (0x00fc)
100 #define VPIF_CH2_HANC0_STRT (0x0100)
101 #define VPIF_CH2_HANC0_SIZE (0x0104)
102 #define VPIF_CH2_HANC1_STRT (0x0108)
103 #define VPIF_CH2_HANC1_SIZE (0x010c)
104 #define VPIF_CH2_VANC0_STRT (0x0110)
105 #define VPIF_CH2_VANC0_SIZE (0x0114)
106 #define VPIF_CH2_VANC1_STRT (0x0118)
107 #define VPIF_CH2_VANC1_SIZE (0x011c)
109 #define VPIF_CH3_TOP_STRT_ADD_LUMA (0x0140)
110 #define VPIF_CH3_BTM_STRT_ADD_LUMA (0x0144)
111 #define VPIF_CH3_TOP_STRT_ADD_CHROMA (0x0148)
112 #define VPIF_CH3_BTM_STRT_ADD_CHROMA (0x014c)
113 #define VPIF_CH3_TOP_STRT_ADD_HANC (0x0150)
114 #define VPIF_CH3_BTM_STRT_ADD_HANC (0x0154)
115 #define VPIF_CH3_TOP_STRT_ADD_VANC (0x0158)
116 #define VPIF_CH3_BTM_STRT_ADD_VANC (0x015c)
117 #define VPIF_CH3_SP_CFG (0x0160)
118 #define VPIF_CH3_IMG_ADD_OFST (0x0164)
119 #define VPIF_CH3_HANC_ADD_OFST (0x0168)
120 #define VPIF_CH3_H_CFG (0x016c)
121 #define VPIF_CH3_V_CFG_00 (0x0170)
122 #define VPIF_CH3_V_CFG_01 (0x0174)
123 #define VPIF_CH3_V_CFG_02 (0x0178)
124 #define VPIF_CH3_V_CFG_03 (0x017c)
125 #define VPIF_CH3_HANC0_STRT (0x0180)
126 #define VPIF_CH3_HANC0_SIZE (0x0184)
127 #define VPIF_CH3_HANC1_STRT (0x0188)
128 #define VPIF_CH3_HANC1_SIZE (0x018c)
129 #define VPIF_CH3_VANC0_STRT (0x0190)
130 #define VPIF_CH3_VANC0_SIZE (0x0194)
131 #define VPIF_CH3_VANC1_STRT (0x0198)
132 #define VPIF_CH3_VANC1_SIZE (0x019c)
134 #define VPIF_IODFT_CTRL (0x01c0)
139 regw((
regr(reg)) | (0x01 << bit), reg);
144 regw(((
regr(reg)) & ~(0x01 << bit)), reg);
152 #define GENERATE_MASK(bits, pos) \
153 ((((0xFFFFFFFF) << (32 - bits)) >> (32 - bits)) << pos)
156 #define VPIF_CH_DATA_MODE_BIT (2)
157 #define VPIF_CH_YC_MUX_BIT (3)
158 #define VPIF_CH_SDR_FMT_BIT (4)
159 #define VPIF_CH_HANC_EN_BIT (8)
160 #define VPIF_CH_VANC_EN_BIT (9)
162 #define VPIF_CAPTURE_CH_NIP (10)
163 #define VPIF_DISPLAY_CH_NIP (11)
165 #define VPIF_DISPLAY_PIX_EN_BIT (10)
167 #define VPIF_CH_INPUT_FIELD_FRAME_BIT (12)
169 #define VPIF_CH_FID_POLARITY_BIT (15)
170 #define VPIF_CH_V_VALID_POLARITY_BIT (14)
171 #define VPIF_CH_H_VALID_POLARITY_BIT (13)
172 #define VPIF_CH_DATA_WIDTH_BIT (28)
174 #define VPIF_CH_CLK_EDGE_CTRL_BIT (31)
177 #define VPIF_CH_EAVSAV_MASK GENERATE_MASK(13, 0)
178 #define VPIF_CH_LEN_MASK GENERATE_MASK(12, 0)
179 #define VPIF_CH_WIDTH_MASK GENERATE_MASK(13, 0)
180 #define VPIF_CH_LEN_SHIFT (16)
183 #define VPIF_REQ_SIZE_MASK (0x1ff)
186 #define VPIF_INTEN_FRAME_CH0 (0x00000001)
187 #define VPIF_INTEN_FRAME_CH1 (0x00000002)
188 #define VPIF_INTEN_FRAME_CH2 (0x00000004)
189 #define VPIF_INTEN_FRAME_CH3 (0x00000008)
193 #define VPIF_CH0_CLK_EN (0x00000002)
194 #define VPIF_CH0_EN (0x00000001)
195 #define VPIF_CH1_CLK_EN (0x00000002)
196 #define VPIF_CH1_EN (0x00000001)
197 #define VPIF_CH2_CLK_EN (0x00000002)
198 #define VPIF_CH2_EN (0x00000001)
199 #define VPIF_CH3_CLK_EN (0x00000002)
200 #define VPIF_CH3_EN (0x00000001)
201 #define VPIF_CH_CLK_EN (0x00000002)
202 #define VPIF_CH_EN (0x00000001)
204 #define VPIF_INT_TOP (0x00)
205 #define VPIF_INT_BOTTOM (0x01)
206 #define VPIF_INT_BOTH (0x02)
208 #define VPIF_CH0_INT_CTRL_SHIFT (6)
209 #define VPIF_CH1_INT_CTRL_SHIFT (6)
210 #define VPIF_CH2_INT_CTRL_SHIFT (6)
211 #define VPIF_CH3_INT_CTRL_SHIFT (6)
212 #define VPIF_CH_INT_CTRL_SHIFT (6)
214 #define VPIF_CH2_CLIP_ANC_EN 14
215 #define VPIF_CH2_CLIP_ACTIVE_EN 13
217 #define VPIF_CH3_CLIP_ANC_EN 14
218 #define VPIF_CH3_CLIP_ACTIVE_EN 13
221 #define channel0_intr_assert() (regw((regr(VPIF_CH0_CTRL)|\
222 (VPIF_INT_BOTH << VPIF_CH0_INT_CTRL_SHIFT)), VPIF_CH0_CTRL))
225 #define channel1_intr_assert() (regw((regr(VPIF_CH1_CTRL)|\
226 (VPIF_INT_BOTH << VPIF_CH1_INT_CTRL_SHIFT)), VPIF_CH1_CTRL))
229 #define channel2_intr_assert() (regw((regr(VPIF_CH2_CTRL)|\
230 (VPIF_INT_BOTH << VPIF_CH2_INT_CTRL_SHIFT)), VPIF_CH2_CTRL))
233 #define channel3_intr_assert() (regw((regr(VPIF_CH3_CTRL)|\
234 (VPIF_INT_BOTH << VPIF_CH3_INT_CTRL_SHIFT)), VPIF_CH3_CTRL))
236 #define VPIF_CH_FID_MASK (0x20)
237 #define VPIF_CH_FID_SHIFT (5)
239 #define VPIF_NTSC_VBI_START_FIELD0 (1)
240 #define VPIF_NTSC_VBI_START_FIELD1 (263)
241 #define VPIF_PAL_VBI_START_FIELD0 (624)
242 #define VPIF_PAL_VBI_START_FIELD1 (311)
244 #define VPIF_NTSC_HBI_START_FIELD0 (1)
245 #define VPIF_NTSC_HBI_START_FIELD1 (263)
246 #define VPIF_PAL_HBI_START_FIELD0 (624)
247 #define VPIF_PAL_HBI_START_FIELD1 (311)
249 #define VPIF_NTSC_VBI_COUNT_FIELD0 (20)
250 #define VPIF_NTSC_VBI_COUNT_FIELD1 (19)
251 #define VPIF_PAL_VBI_COUNT_FIELD0 (24)
252 #define VPIF_PAL_VBI_COUNT_FIELD1 (25)
254 #define VPIF_NTSC_HBI_COUNT_FIELD0 (263)
255 #define VPIF_NTSC_HBI_COUNT_FIELD1 (262)
256 #define VPIF_PAL_HBI_COUNT_FIELD0 (312)
257 #define VPIF_PAL_HBI_COUNT_FIELD1 (313)
259 #define VPIF_NTSC_VBI_SAMPLES_PER_LINE (720)
260 #define VPIF_PAL_VBI_SAMPLES_PER_LINE (720)
261 #define VPIF_NTSC_HBI_SAMPLES_PER_LINE (268)
262 #define VPIF_PAL_HBI_SAMPLES_PER_LINE (280)
264 #define VPIF_CH_VANC_EN (0x20)
265 #define VPIF_DMA_REQ_SIZE (0x080)
266 #define VPIF_EMULATION_DISABLE (0x01)
271 static inline void enable_channel0(
int enable)
280 static inline void enable_channel1(
int enable)
289 static inline void channel0_intr_enable(
int enable)
307 spin_unlock_irqrestore(&vpif_lock, flags);
311 static inline void channel1_intr_enable(
int enable)
329 spin_unlock_irqrestore(&vpif_lock, flags);
333 static inline void ch0_set_videobuf_addr_yc_nmux(
unsigned long top_strt_luma,
334 unsigned long btm_strt_luma,
335 unsigned long top_strt_chroma,
336 unsigned long btm_strt_chroma)
345 static inline void ch0_set_videobuf_addr(
unsigned long top_strt_luma,
346 unsigned long btm_strt_luma,
347 unsigned long top_strt_chroma,
348 unsigned long btm_strt_chroma)
356 static inline void ch1_set_videobuf_addr(
unsigned long top_strt_luma,
357 unsigned long btm_strt_luma,
358 unsigned long top_strt_chroma,
359 unsigned long btm_strt_chroma)
368 static inline void ch0_set_vbi_addr(
unsigned long top_vbi,
369 unsigned long btm_vbi,
unsigned long a,
unsigned long b)
375 static inline void ch0_set_hbi_addr(
unsigned long top_vbi,
376 unsigned long btm_vbi,
unsigned long a,
unsigned long b)
382 static inline void ch1_set_vbi_addr(
unsigned long top_vbi,
383 unsigned long btm_vbi,
unsigned long a,
unsigned long b)
389 static inline void ch1_set_hbi_addr(
unsigned long top_vbi,
390 unsigned long btm_vbi,
unsigned long a,
unsigned long b)
397 static inline void disable_raw_feature(
u8 channel_id,
u8 index)
411 static inline void enable_raw_feature(
u8 channel_id,
u8 index)
426 static inline void enable_channel2(
int enable)
438 static inline void enable_channel3(
int enable)
450 static inline void channel2_intr_enable(
int enable)
467 spin_unlock_irqrestore(&vpif_lock, flags);
471 static inline void channel3_intr_enable(
int enable)
489 spin_unlock_irqrestore(&vpif_lock, flags);
493 static inline void channel2_raw_enable(
int enable,
u8 index)
509 static inline void channel3_raw_enable(
int enable,
u8 index)
525 static inline void channel2_clipping_enable(
int enable)
537 static inline void channel3_clipping_enable(
int enable)
549 static inline void ch2_set_videobuf_addr_yc_nmux(
unsigned long top_strt_luma,
550 unsigned long btm_strt_luma,
551 unsigned long top_strt_chroma,
552 unsigned long btm_strt_chroma)
561 static inline void ch2_set_videobuf_addr(
unsigned long top_strt_luma,
562 unsigned long btm_strt_luma,
563 unsigned long top_strt_chroma,
564 unsigned long btm_strt_chroma)
572 static inline void ch3_set_videobuf_addr(
unsigned long top_strt_luma,
573 unsigned long btm_strt_luma,
574 unsigned long top_strt_chroma,
575 unsigned long btm_strt_chroma)
584 static inline void ch2_set_vbi_addr(
unsigned long top_strt_luma,
585 unsigned long btm_strt_luma,
586 unsigned long top_strt_chroma,
587 unsigned long btm_strt_chroma)
593 static inline void ch3_set_vbi_addr(
unsigned long top_strt_luma,
594 unsigned long btm_strt_luma,
595 unsigned long top_strt_chroma,
596 unsigned long btm_strt_chroma)
602 static inline int vpif_intr_status(
int channel)
617 #define VPIF_MAX_NAME (30)