diff options
author | Sandor Yu <R01008@freescale.com> | 2014-04-04 01:37:32 -0400 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-17 22:19:11 -0400 |
commit | f8fd69100cc9a83fc4bc4b9e4c7bc1d37cc5b61a (patch) | |
tree | dfc8f4edb4051e75f4bdff25ad71dd0740a3fe48 | |
parent | 9b381fab1942405ec16f1322ab1186e453d17d08 (diff) |
ENGR00307014-02 csi: update csi driver to support vadc
-Add csi control register 18 define.
-Add csi_tvdec_enable and csi_deinterlace_mode for vadc.
-Add csi_set_32bit_imagpara function to support YUV444 format.
Signed-off-by: Sandor Yu <R01008@freescale.com>
-rw-r--r-- | drivers/media/platform/mxc/capture/fsl_csi.c | 83 | ||||
-rw-r--r-- | drivers/media/platform/mxc/capture/fsl_csi.h | 15 |
2 files changed, 86 insertions, 12 deletions
diff --git a/drivers/media/platform/mxc/capture/fsl_csi.c b/drivers/media/platform/mxc/capture/fsl_csi.c index 0a1770648a3a..2839e9fa0d8e 100644 --- a/drivers/media/platform/mxc/capture/fsl_csi.c +++ b/drivers/media/platform/mxc/capture/fsl_csi.c | |||
@@ -126,9 +126,7 @@ void csi_init_interface(void) | |||
126 | val |= BIT_REDGE; | 126 | val |= BIT_REDGE; |
127 | val |= BIT_GCLK_MODE; | 127 | val |= BIT_GCLK_MODE; |
128 | val |= BIT_HSYNC_POL; | 128 | val |= BIT_HSYNC_POL; |
129 | val |= BIT_PACK_DIR; | ||
130 | val |= BIT_FCC; | 129 | val |= BIT_FCC; |
131 | val |= BIT_SWAP16_EN; | ||
132 | val |= 1 << SHIFT_MCLKDIV; | 130 | val |= 1 << SHIFT_MCLKDIV; |
133 | val |= BIT_MCLKEN; | 131 | val |= BIT_MCLKEN; |
134 | __raw_writel(val, CSI_CSICR1); | 132 | __raw_writel(val, CSI_CSICR1); |
@@ -142,23 +140,22 @@ void csi_init_interface(void) | |||
142 | } | 140 | } |
143 | EXPORT_SYMBOL(csi_init_interface); | 141 | EXPORT_SYMBOL(csi_init_interface); |
144 | 142 | ||
145 | void csi_init_format(int fmt) | 143 | void csi_format_swap16(bool enable) |
146 | { | 144 | { |
147 | unsigned int val; | 145 | unsigned int val; |
148 | 146 | ||
149 | val = __raw_readl(CSI_CSICR1); | 147 | val = __raw_readl(CSI_CSICR1); |
150 | if (fmt == V4L2_PIX_FMT_YUYV) { | 148 | if (enable) { |
151 | val &= ~BIT_PACK_DIR; | ||
152 | val &= ~BIT_SWAP16_EN; | ||
153 | } else if (fmt == V4L2_PIX_FMT_UYVY) { | ||
154 | val |= BIT_PACK_DIR; | 149 | val |= BIT_PACK_DIR; |
155 | val |= BIT_SWAP16_EN; | 150 | val |= BIT_SWAP16_EN; |
156 | } else | 151 | } else { |
157 | pr_warning("unsupported format, old format remains.\n"); | 152 | val &= ~BIT_PACK_DIR; |
153 | val &= ~BIT_SWAP16_EN; | ||
154 | } | ||
158 | 155 | ||
159 | __raw_writel(val, CSI_CSICR1); | 156 | __raw_writel(val, CSI_CSICR1); |
160 | } | 157 | } |
161 | EXPORT_SYMBOL(csi_init_format); | 158 | EXPORT_SYMBOL(csi_format_swap16); |
162 | 159 | ||
163 | /*! | 160 | /*! |
164 | * csi_read_mclk_flag | 161 | * csi_read_mclk_flag |
@@ -226,6 +223,72 @@ void csi_enable(int arg) | |||
226 | } | 223 | } |
227 | EXPORT_SYMBOL(csi_enable); | 224 | EXPORT_SYMBOL(csi_enable); |
228 | 225 | ||
226 | void csi_buf_stride_set(u32 stride) | ||
227 | { | ||
228 | __raw_writel(stride, CSI_CSIFBUF_PARA); | ||
229 | } | ||
230 | EXPORT_SYMBOL(csi_buf_stride_set); | ||
231 | |||
232 | void csi_deinterlace_enable(bool enable) | ||
233 | { | ||
234 | unsigned long cr18 = __raw_readl(CSI_CSICR18); | ||
235 | |||
236 | if (enable == true) | ||
237 | cr18 |= BIT_DEINTERLACE_EN; | ||
238 | else | ||
239 | cr18 &= ~BIT_DEINTERLACE_EN; | ||
240 | |||
241 | __raw_writel(cr18, CSI_CSICR18); | ||
242 | } | ||
243 | EXPORT_SYMBOL(csi_deinterlace_enable); | ||
244 | |||
245 | void csi_deinterlace_mode(int mode) | ||
246 | { | ||
247 | unsigned long cr18 = __raw_readl(CSI_CSICR18); | ||
248 | |||
249 | if (mode == V4L2_STD_NTSC) | ||
250 | cr18 |= BIT_NTSC_EN; | ||
251 | else | ||
252 | cr18 &= ~BIT_NTSC_EN; | ||
253 | |||
254 | __raw_writel(cr18, CSI_CSICR18); | ||
255 | } | ||
256 | EXPORT_SYMBOL(csi_deinterlace_mode); | ||
257 | |||
258 | void csi_tvdec_enable(bool enable) | ||
259 | { | ||
260 | unsigned long cr18 = __raw_readl(CSI_CSICR18); | ||
261 | unsigned long cr1 = __raw_readl(CSI_CSICR1); | ||
262 | |||
263 | if (enable == true) { | ||
264 | cr18 |= (BIT_TVDECODER_IN_EN | BIT_BASEADDR_SWITCH_EN); | ||
265 | cr1 |= BIT_CCIR_MODE | BIT_EXT_VSYNC; | ||
266 | cr1 &= ~(BIT_SOF_POL | BIT_REDGE); | ||
267 | } else { | ||
268 | cr18 &= ~(BIT_TVDECODER_IN_EN | BIT_BASEADDR_SWITCH_EN); | ||
269 | cr1 &= ~(BIT_CCIR_MODE | BIT_EXT_VSYNC); | ||
270 | cr1 |= BIT_SOF_POL | BIT_REDGE; | ||
271 | } | ||
272 | |||
273 | __raw_writel(cr18, CSI_CSICR18); | ||
274 | __raw_writel(cr1, CSI_CSICR1); | ||
275 | } | ||
276 | EXPORT_SYMBOL(csi_tvdec_enable); | ||
277 | |||
278 | void csi_set_32bit_imagpara(int width, int height) | ||
279 | { | ||
280 | int imag_para = 0; | ||
281 | unsigned long cr3 = __raw_readl(CSI_CSICR3); | ||
282 | |||
283 | imag_para = (width << 16) | height; | ||
284 | __raw_writel(imag_para, CSI_CSIIMAG_PARA); | ||
285 | |||
286 | |||
287 | /* reflash the embeded DMA controller */ | ||
288 | __raw_writel(cr3 | BIT_DMA_REFLASH_RFF, CSI_CSICR3); | ||
289 | } | ||
290 | EXPORT_SYMBOL(csi_set_32bit_imagpara); | ||
291 | |||
229 | void csi_set_16bit_imagpara(int width, int height) | 292 | void csi_set_16bit_imagpara(int width, int height) |
230 | { | 293 | { |
231 | int imag_para = 0; | 294 | int imag_para = 0; |
diff --git a/drivers/media/platform/mxc/capture/fsl_csi.h b/drivers/media/platform/mxc/capture/fsl_csi.h index d9d179b41da4..78b393ef9151 100644 --- a/drivers/media/platform/mxc/capture/fsl_csi.h +++ b/drivers/media/platform/mxc/capture/fsl_csi.h | |||
@@ -96,7 +96,13 @@ | |||
96 | #define BIT_DRDY (0x1 << 0) | 96 | #define BIT_DRDY (0x1 << 0) |
97 | 97 | ||
98 | /* csi control reg 18 */ | 98 | /* csi control reg 18 */ |
99 | #define BIT_CSI_ENABLE (0x1 << 31) | 99 | #define BIT_CSI_ENABLE (0x1 << 31) |
100 | #define BIT_BASEADDR_SWITCH_SEL (0x1 << 5) | ||
101 | #define BIT_BASEADDR_SWITCH_EN (0x1 << 4) | ||
102 | #define BIT_PARALLEL24_EN (0x1 << 3) | ||
103 | #define BIT_DEINTERLACE_EN (0x1 << 2) | ||
104 | #define BIT_TVDECODER_IN_EN (0x1 << 1) | ||
105 | #define BIT_NTSC_EN (0x1 << 0) | ||
100 | 106 | ||
101 | #define CSI_MCLK_VF 1 | 107 | #define CSI_MCLK_VF 1 |
102 | #define CSI_MCLK_ENC 2 | 108 | #define CSI_MCLK_ENC 2 |
@@ -190,13 +196,18 @@ struct csi_config_t { | |||
190 | typedef void (*csi_irq_callback_t) (void *data, unsigned long status); | 196 | typedef void (*csi_irq_callback_t) (void *data, unsigned long status); |
191 | 197 | ||
192 | void csi_init_interface(void); | 198 | void csi_init_interface(void); |
193 | void csi_init_format(int fmt); | 199 | void csi_set_32bit_imagpara(int width, int height); |
194 | void csi_set_16bit_imagpara(int width, int height); | 200 | void csi_set_16bit_imagpara(int width, int height); |
195 | void csi_set_12bit_imagpara(int width, int height); | 201 | void csi_set_12bit_imagpara(int width, int height); |
202 | void csi_format_swap16(bool enable); | ||
196 | int csi_read_mclk_flag(void); | 203 | int csi_read_mclk_flag(void); |
197 | void csi_start_callback(void *data); | 204 | void csi_start_callback(void *data); |
198 | void csi_stop_callback(void *data); | 205 | void csi_stop_callback(void *data); |
199 | void csi_enable_int(int arg); | 206 | void csi_enable_int(int arg); |
207 | void csi_buf_stride_set(u32 stride); | ||
208 | void csi_deinterlace_mode(int mode); | ||
209 | void csi_deinterlace_enable(bool enable); | ||
210 | void csi_tvdec_enable(bool enable); | ||
200 | void csi_enable(int arg); | 211 | void csi_enable(int arg); |
201 | void csi_disable_int(void); | 212 | void csi_disable_int(void); |
202 | void csi_clk_enable(void); | 213 | void csi_clk_enable(void); |