diff options
author | Muralidharan Karicheri <m-karicheri2@ti.com> | 2010-01-13 18:27:07 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:45 -0500 |
commit | 8d1b5946bf53b2593e633caba2330863838b7bf7 (patch) | |
tree | 2361df67d54a1169c60e7856c27ea421b19d1b91 /drivers/media/video | |
parent | c70fc2d2ccff1ce4cf0441ed060045022e6cc5c8 (diff) |
V4L/DVB: vpfe-capture: converting dm644x ccdc driver to a platform driver
1) clocks are configured using generic clock names
2) converting the driver to a platform driver
3) cleanup - consolidate all static variables inside a structure, ccdc_cfg
The ccdc driver now uses generic names for clocks - master and slave. On individual platforms
these clocks will inherit from the platform specific clock. This will allow re-use of
the driver for the same IP across different SoCs.
Reviewed-by: Kevin Hilman <khilman@deeprootsystems.com>
Reviewed-by: Vaibhav Hiremath <hvaibhav@ti.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/davinci/dm644x_ccdc.c | 361 |
1 files changed, 225 insertions, 136 deletions
diff --git a/drivers/media/video/davinci/dm644x_ccdc.c b/drivers/media/video/davinci/dm644x_ccdc.c index d5fa193f32d2..0c394cade22a 100644 --- a/drivers/media/video/davinci/dm644x_ccdc.c +++ b/drivers/media/video/davinci/dm644x_ccdc.c | |||
@@ -37,8 +37,12 @@ | |||
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/uaccess.h> | 38 | #include <linux/uaccess.h> |
39 | #include <linux/videodev2.h> | 39 | #include <linux/videodev2.h> |
40 | #include <linux/clk.h> | ||
41 | #include <linux/err.h> | ||
42 | |||
40 | #include <media/davinci/dm644x_ccdc.h> | 43 | #include <media/davinci/dm644x_ccdc.h> |
41 | #include <media/davinci/vpss.h> | 44 | #include <media/davinci/vpss.h> |
45 | |||
42 | #include "dm644x_ccdc_regs.h" | 46 | #include "dm644x_ccdc_regs.h" |
43 | #include "ccdc_hw_device.h" | 47 | #include "ccdc_hw_device.h" |
44 | 48 | ||
@@ -46,32 +50,44 @@ MODULE_LICENSE("GPL"); | |||
46 | MODULE_DESCRIPTION("CCDC Driver for DM6446"); | 50 | MODULE_DESCRIPTION("CCDC Driver for DM6446"); |
47 | MODULE_AUTHOR("Texas Instruments"); | 51 | MODULE_AUTHOR("Texas Instruments"); |
48 | 52 | ||
49 | static struct device *dev; | 53 | static struct ccdc_oper_config { |
50 | 54 | struct device *dev; | |
51 | /* Object for CCDC raw mode */ | 55 | /* CCDC interface type */ |
52 | static struct ccdc_params_raw ccdc_hw_params_raw = { | 56 | enum vpfe_hw_if_type if_type; |
53 | .pix_fmt = CCDC_PIXFMT_RAW, | 57 | /* Raw Bayer configuration */ |
54 | .frm_fmt = CCDC_FRMFMT_PROGRESSIVE, | 58 | struct ccdc_params_raw bayer; |
55 | .win = CCDC_WIN_VGA, | 59 | /* YCbCr configuration */ |
56 | .fid_pol = VPFE_PINPOL_POSITIVE, | 60 | struct ccdc_params_ycbcr ycbcr; |
57 | .vd_pol = VPFE_PINPOL_POSITIVE, | 61 | /* Master clock */ |
58 | .hd_pol = VPFE_PINPOL_POSITIVE, | 62 | struct clk *mclk; |
59 | .config_params = { | 63 | /* slave clock */ |
60 | .data_sz = CCDC_DATA_10BITS, | 64 | struct clk *sclk; |
65 | /* ccdc base address */ | ||
66 | void __iomem *base_addr; | ||
67 | } ccdc_cfg = { | ||
68 | /* Raw configurations */ | ||
69 | .bayer = { | ||
70 | .pix_fmt = CCDC_PIXFMT_RAW, | ||
71 | .frm_fmt = CCDC_FRMFMT_PROGRESSIVE, | ||
72 | .win = CCDC_WIN_VGA, | ||
73 | .fid_pol = VPFE_PINPOL_POSITIVE, | ||
74 | .vd_pol = VPFE_PINPOL_POSITIVE, | ||
75 | .hd_pol = VPFE_PINPOL_POSITIVE, | ||
76 | .config_params = { | ||
77 | .data_sz = CCDC_DATA_10BITS, | ||
78 | }, | ||
79 | }, | ||
80 | .ycbcr = { | ||
81 | .pix_fmt = CCDC_PIXFMT_YCBCR_8BIT, | ||
82 | .frm_fmt = CCDC_FRMFMT_INTERLACED, | ||
83 | .win = CCDC_WIN_PAL, | ||
84 | .fid_pol = VPFE_PINPOL_POSITIVE, | ||
85 | .vd_pol = VPFE_PINPOL_POSITIVE, | ||
86 | .hd_pol = VPFE_PINPOL_POSITIVE, | ||
87 | .bt656_enable = 1, | ||
88 | .pix_order = CCDC_PIXORDER_CBYCRY, | ||
89 | .buf_type = CCDC_BUFTYPE_FLD_INTERLEAVED | ||
61 | }, | 90 | }, |
62 | }; | ||
63 | |||
64 | /* Object for CCDC ycbcr mode */ | ||
65 | static struct ccdc_params_ycbcr ccdc_hw_params_ycbcr = { | ||
66 | .pix_fmt = CCDC_PIXFMT_YCBCR_8BIT, | ||
67 | .frm_fmt = CCDC_FRMFMT_INTERLACED, | ||
68 | .win = CCDC_WIN_PAL, | ||
69 | .fid_pol = VPFE_PINPOL_POSITIVE, | ||
70 | .vd_pol = VPFE_PINPOL_POSITIVE, | ||
71 | .hd_pol = VPFE_PINPOL_POSITIVE, | ||
72 | .bt656_enable = 1, | ||
73 | .pix_order = CCDC_PIXORDER_CBYCRY, | ||
74 | .buf_type = CCDC_BUFTYPE_FLD_INTERLEAVED | ||
75 | }; | 91 | }; |
76 | 92 | ||
77 | #define CCDC_MAX_RAW_YUV_FORMATS 2 | 93 | #define CCDC_MAX_RAW_YUV_FORMATS 2 |
@@ -84,25 +100,15 @@ static u32 ccdc_raw_bayer_pix_formats[] = | |||
84 | static u32 ccdc_raw_yuv_pix_formats[] = | 100 | static u32 ccdc_raw_yuv_pix_formats[] = |
85 | {V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_YUYV}; | 101 | {V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_YUYV}; |
86 | 102 | ||
87 | static void *__iomem ccdc_base_addr; | ||
88 | static int ccdc_addr_size; | ||
89 | static enum vpfe_hw_if_type ccdc_if_type; | ||
90 | |||
91 | /* register access routines */ | 103 | /* register access routines */ |
92 | static inline u32 regr(u32 offset) | 104 | static inline u32 regr(u32 offset) |
93 | { | 105 | { |
94 | return __raw_readl(ccdc_base_addr + offset); | 106 | return __raw_readl(ccdc_cfg.base_addr + offset); |
95 | } | 107 | } |
96 | 108 | ||
97 | static inline void regw(u32 val, u32 offset) | 109 | static inline void regw(u32 val, u32 offset) |
98 | { | 110 | { |
99 | __raw_writel(val, ccdc_base_addr + offset); | 111 | __raw_writel(val, ccdc_cfg.base_addr + offset); |
100 | } | ||
101 | |||
102 | static void ccdc_set_ccdc_base(void *addr, int size) | ||
103 | { | ||
104 | ccdc_base_addr = addr; | ||
105 | ccdc_addr_size = size; | ||
106 | } | 112 | } |
107 | 113 | ||
108 | static void ccdc_enable(int flag) | 114 | static void ccdc_enable(int flag) |
@@ -132,7 +138,7 @@ void ccdc_setwin(struct v4l2_rect *image_win, | |||
132 | int vert_start, vert_nr_lines; | 138 | int vert_start, vert_nr_lines; |
133 | int val = 0, mid_img = 0; | 139 | int val = 0, mid_img = 0; |
134 | 140 | ||
135 | dev_dbg(dev, "\nStarting ccdc_setwin..."); | 141 | dev_dbg(ccdc_cfg.dev, "\nStarting ccdc_setwin..."); |
136 | /* | 142 | /* |
137 | * ppc - per pixel count. indicates how many pixels per cell | 143 | * ppc - per pixel count. indicates how many pixels per cell |
138 | * output to SDRAM. example, for ycbcr, it is one y and one c, so 2. | 144 | * output to SDRAM. example, for ycbcr, it is one y and one c, so 2. |
@@ -171,7 +177,7 @@ void ccdc_setwin(struct v4l2_rect *image_win, | |||
171 | regw((vert_start << CCDC_VERT_START_SLV0_SHIFT) | vert_start, | 177 | regw((vert_start << CCDC_VERT_START_SLV0_SHIFT) | vert_start, |
172 | CCDC_VERT_START); | 178 | CCDC_VERT_START); |
173 | regw(vert_nr_lines, CCDC_VERT_LINES); | 179 | regw(vert_nr_lines, CCDC_VERT_LINES); |
174 | dev_dbg(dev, "\nEnd of ccdc_setwin..."); | 180 | dev_dbg(ccdc_cfg.dev, "\nEnd of ccdc_setwin..."); |
175 | } | 181 | } |
176 | 182 | ||
177 | static void ccdc_readregs(void) | 183 | static void ccdc_readregs(void) |
@@ -179,39 +185,39 @@ static void ccdc_readregs(void) | |||
179 | unsigned int val = 0; | 185 | unsigned int val = 0; |
180 | 186 | ||
181 | val = regr(CCDC_ALAW); | 187 | val = regr(CCDC_ALAW); |
182 | dev_notice(dev, "\nReading 0x%x to ALAW...\n", val); | 188 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to ALAW...\n", val); |
183 | val = regr(CCDC_CLAMP); | 189 | val = regr(CCDC_CLAMP); |
184 | dev_notice(dev, "\nReading 0x%x to CLAMP...\n", val); | 190 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to CLAMP...\n", val); |
185 | val = regr(CCDC_DCSUB); | 191 | val = regr(CCDC_DCSUB); |
186 | dev_notice(dev, "\nReading 0x%x to DCSUB...\n", val); | 192 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to DCSUB...\n", val); |
187 | val = regr(CCDC_BLKCMP); | 193 | val = regr(CCDC_BLKCMP); |
188 | dev_notice(dev, "\nReading 0x%x to BLKCMP...\n", val); | 194 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to BLKCMP...\n", val); |
189 | val = regr(CCDC_FPC_ADDR); | 195 | val = regr(CCDC_FPC_ADDR); |
190 | dev_notice(dev, "\nReading 0x%x to FPC_ADDR...\n", val); | 196 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to FPC_ADDR...\n", val); |
191 | val = regr(CCDC_FPC); | 197 | val = regr(CCDC_FPC); |
192 | dev_notice(dev, "\nReading 0x%x to FPC...\n", val); | 198 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to FPC...\n", val); |
193 | val = regr(CCDC_FMTCFG); | 199 | val = regr(CCDC_FMTCFG); |
194 | dev_notice(dev, "\nReading 0x%x to FMTCFG...\n", val); | 200 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to FMTCFG...\n", val); |
195 | val = regr(CCDC_COLPTN); | 201 | val = regr(CCDC_COLPTN); |
196 | dev_notice(dev, "\nReading 0x%x to COLPTN...\n", val); | 202 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to COLPTN...\n", val); |
197 | val = regr(CCDC_FMT_HORZ); | 203 | val = regr(CCDC_FMT_HORZ); |
198 | dev_notice(dev, "\nReading 0x%x to FMT_HORZ...\n", val); | 204 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to FMT_HORZ...\n", val); |
199 | val = regr(CCDC_FMT_VERT); | 205 | val = regr(CCDC_FMT_VERT); |
200 | dev_notice(dev, "\nReading 0x%x to FMT_VERT...\n", val); | 206 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to FMT_VERT...\n", val); |
201 | val = regr(CCDC_HSIZE_OFF); | 207 | val = regr(CCDC_HSIZE_OFF); |
202 | dev_notice(dev, "\nReading 0x%x to HSIZE_OFF...\n", val); | 208 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to HSIZE_OFF...\n", val); |
203 | val = regr(CCDC_SDOFST); | 209 | val = regr(CCDC_SDOFST); |
204 | dev_notice(dev, "\nReading 0x%x to SDOFST...\n", val); | 210 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to SDOFST...\n", val); |
205 | val = regr(CCDC_VP_OUT); | 211 | val = regr(CCDC_VP_OUT); |
206 | dev_notice(dev, "\nReading 0x%x to VP_OUT...\n", val); | 212 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to VP_OUT...\n", val); |
207 | val = regr(CCDC_SYN_MODE); | 213 | val = regr(CCDC_SYN_MODE); |
208 | dev_notice(dev, "\nReading 0x%x to SYN_MODE...\n", val); | 214 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to SYN_MODE...\n", val); |
209 | val = regr(CCDC_HORZ_INFO); | 215 | val = regr(CCDC_HORZ_INFO); |
210 | dev_notice(dev, "\nReading 0x%x to HORZ_INFO...\n", val); | 216 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to HORZ_INFO...\n", val); |
211 | val = regr(CCDC_VERT_START); | 217 | val = regr(CCDC_VERT_START); |
212 | dev_notice(dev, "\nReading 0x%x to VERT_START...\n", val); | 218 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to VERT_START...\n", val); |
213 | val = regr(CCDC_VERT_LINES); | 219 | val = regr(CCDC_VERT_LINES); |
214 | dev_notice(dev, "\nReading 0x%x to VERT_LINES...\n", val); | 220 | dev_notice(ccdc_cfg.dev, "\nReading 0x%x to VERT_LINES...\n", val); |
215 | } | 221 | } |
216 | 222 | ||
217 | static int validate_ccdc_param(struct ccdc_config_params_raw *ccdcparam) | 223 | static int validate_ccdc_param(struct ccdc_config_params_raw *ccdcparam) |
@@ -220,7 +226,7 @@ static int validate_ccdc_param(struct ccdc_config_params_raw *ccdcparam) | |||
220 | if ((ccdcparam->alaw.gama_wd > CCDC_GAMMA_BITS_09_0) || | 226 | if ((ccdcparam->alaw.gama_wd > CCDC_GAMMA_BITS_09_0) || |
221 | (ccdcparam->alaw.gama_wd < CCDC_GAMMA_BITS_15_6) || | 227 | (ccdcparam->alaw.gama_wd < CCDC_GAMMA_BITS_15_6) || |
222 | (ccdcparam->alaw.gama_wd < ccdcparam->data_sz)) { | 228 | (ccdcparam->alaw.gama_wd < ccdcparam->data_sz)) { |
223 | dev_dbg(dev, "\nInvalid data line select"); | 229 | dev_dbg(ccdc_cfg.dev, "\nInvalid data line select"); |
224 | return -1; | 230 | return -1; |
225 | } | 231 | } |
226 | } | 232 | } |
@@ -230,7 +236,7 @@ static int validate_ccdc_param(struct ccdc_config_params_raw *ccdcparam) | |||
230 | static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params) | 236 | static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params) |
231 | { | 237 | { |
232 | struct ccdc_config_params_raw *config_params = | 238 | struct ccdc_config_params_raw *config_params = |
233 | &ccdc_hw_params_raw.config_params; | 239 | &ccdc_cfg.bayer.config_params; |
234 | unsigned int *fpc_virtaddr = NULL; | 240 | unsigned int *fpc_virtaddr = NULL; |
235 | unsigned int *fpc_physaddr = NULL; | 241 | unsigned int *fpc_physaddr = NULL; |
236 | 242 | ||
@@ -266,7 +272,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params) | |||
266 | FP_NUM_BYTES)); | 272 | FP_NUM_BYTES)); |
267 | 273 | ||
268 | if (fpc_virtaddr == NULL) { | 274 | if (fpc_virtaddr == NULL) { |
269 | dev_dbg(dev, | 275 | dev_dbg(ccdc_cfg.dev, |
270 | "\nUnable to allocate memory for FPC"); | 276 | "\nUnable to allocate memory for FPC"); |
271 | return -EFAULT; | 277 | return -EFAULT; |
272 | } | 278 | } |
@@ -279,7 +285,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params) | |||
279 | if (copy_from_user(fpc_virtaddr, | 285 | if (copy_from_user(fpc_virtaddr, |
280 | (void __user *)raw_params->fault_pxl.fpc_table_addr, | 286 | (void __user *)raw_params->fault_pxl.fpc_table_addr, |
281 | config_params->fault_pxl.fp_num * FP_NUM_BYTES)) { | 287 | config_params->fault_pxl.fp_num * FP_NUM_BYTES)) { |
282 | dev_dbg(dev, "\n copy_from_user failed"); | 288 | dev_dbg(ccdc_cfg.dev, "\n copy_from_user failed"); |
283 | return -EFAULT; | 289 | return -EFAULT; |
284 | } | 290 | } |
285 | config_params->fault_pxl.fpc_table_addr = (unsigned int)fpc_physaddr; | 291 | config_params->fault_pxl.fpc_table_addr = (unsigned int)fpc_physaddr; |
@@ -289,7 +295,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params) | |||
289 | static int ccdc_close(struct device *dev) | 295 | static int ccdc_close(struct device *dev) |
290 | { | 296 | { |
291 | struct ccdc_config_params_raw *config_params = | 297 | struct ccdc_config_params_raw *config_params = |
292 | &ccdc_hw_params_raw.config_params; | 298 | &ccdc_cfg.bayer.config_params; |
293 | unsigned int *fpc_physaddr = NULL, *fpc_virtaddr = NULL; | 299 | unsigned int *fpc_physaddr = NULL, *fpc_virtaddr = NULL; |
294 | 300 | ||
295 | fpc_physaddr = (unsigned int *)config_params->fault_pxl.fpc_table_addr; | 301 | fpc_physaddr = (unsigned int *)config_params->fault_pxl.fpc_table_addr; |
@@ -323,9 +329,8 @@ static void ccdc_restore_defaults(void) | |||
323 | 329 | ||
324 | static int ccdc_open(struct device *device) | 330 | static int ccdc_open(struct device *device) |
325 | { | 331 | { |
326 | dev = device; | ||
327 | ccdc_restore_defaults(); | 332 | ccdc_restore_defaults(); |
328 | if (ccdc_if_type == VPFE_RAW_BAYER) | 333 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
329 | ccdc_enable_vport(1); | 334 | ccdc_enable_vport(1); |
330 | return 0; | 335 | return 0; |
331 | } | 336 | } |
@@ -341,12 +346,12 @@ static int ccdc_set_params(void __user *params) | |||
341 | struct ccdc_config_params_raw ccdc_raw_params; | 346 | struct ccdc_config_params_raw ccdc_raw_params; |
342 | int x; | 347 | int x; |
343 | 348 | ||
344 | if (ccdc_if_type != VPFE_RAW_BAYER) | 349 | if (ccdc_cfg.if_type != VPFE_RAW_BAYER) |
345 | return -EINVAL; | 350 | return -EINVAL; |
346 | 351 | ||
347 | x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params)); | 352 | x = copy_from_user(&ccdc_raw_params, params, sizeof(ccdc_raw_params)); |
348 | if (x) { | 353 | if (x) { |
349 | dev_dbg(dev, "ccdc_set_params: error in copying" | 354 | dev_dbg(ccdc_cfg.dev, "ccdc_set_params: error in copying" |
350 | "ccdc params, %d\n", x); | 355 | "ccdc params, %d\n", x); |
351 | return -EFAULT; | 356 | return -EFAULT; |
352 | } | 357 | } |
@@ -364,10 +369,10 @@ static int ccdc_set_params(void __user *params) | |||
364 | */ | 369 | */ |
365 | void ccdc_config_ycbcr(void) | 370 | void ccdc_config_ycbcr(void) |
366 | { | 371 | { |
367 | struct ccdc_params_ycbcr *params = &ccdc_hw_params_ycbcr; | 372 | struct ccdc_params_ycbcr *params = &ccdc_cfg.ycbcr; |
368 | u32 syn_mode; | 373 | u32 syn_mode; |
369 | 374 | ||
370 | dev_dbg(dev, "\nStarting ccdc_config_ycbcr..."); | 375 | dev_dbg(ccdc_cfg.dev, "\nStarting ccdc_config_ycbcr..."); |
371 | /* | 376 | /* |
372 | * first restore the CCDC registers to default values | 377 | * first restore the CCDC registers to default values |
373 | * This is important since we assume default values to be set in | 378 | * This is important since we assume default values to be set in |
@@ -428,7 +433,7 @@ void ccdc_config_ycbcr(void) | |||
428 | regw(CCDC_SDOFST_FIELD_INTERLEAVED, CCDC_SDOFST); | 433 | regw(CCDC_SDOFST_FIELD_INTERLEAVED, CCDC_SDOFST); |
429 | 434 | ||
430 | ccdc_sbl_reset(); | 435 | ccdc_sbl_reset(); |
431 | dev_dbg(dev, "\nEnd of ccdc_config_ycbcr...\n"); | 436 | dev_dbg(ccdc_cfg.dev, "\nEnd of ccdc_config_ycbcr...\n"); |
432 | ccdc_readregs(); | 437 | ccdc_readregs(); |
433 | } | 438 | } |
434 | 439 | ||
@@ -440,9 +445,9 @@ static void ccdc_config_black_clamp(struct ccdc_black_clamp *bclamp) | |||
440 | /* configure DCSub */ | 445 | /* configure DCSub */ |
441 | val = (bclamp->dc_sub) & CCDC_BLK_DC_SUB_MASK; | 446 | val = (bclamp->dc_sub) & CCDC_BLK_DC_SUB_MASK; |
442 | regw(val, CCDC_DCSUB); | 447 | regw(val, CCDC_DCSUB); |
443 | dev_dbg(dev, "\nWriting 0x%x to DCSUB...\n", val); | 448 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to DCSUB...\n", val); |
444 | regw(CCDC_CLAMP_DEFAULT_VAL, CCDC_CLAMP); | 449 | regw(CCDC_CLAMP_DEFAULT_VAL, CCDC_CLAMP); |
445 | dev_dbg(dev, "\nWriting 0x0000 to CLAMP...\n"); | 450 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x0000 to CLAMP...\n"); |
446 | return; | 451 | return; |
447 | } | 452 | } |
448 | /* | 453 | /* |
@@ -457,10 +462,10 @@ static void ccdc_config_black_clamp(struct ccdc_black_clamp *bclamp) | |||
457 | ((bclamp->sample_pixel & CCDC_BLK_SAMPLE_LN_MASK) << | 462 | ((bclamp->sample_pixel & CCDC_BLK_SAMPLE_LN_MASK) << |
458 | CCDC_BLK_SAMPLE_LN_SHIFT) | CCDC_BLK_CLAMP_ENABLE); | 463 | CCDC_BLK_SAMPLE_LN_SHIFT) | CCDC_BLK_CLAMP_ENABLE); |
459 | regw(val, CCDC_CLAMP); | 464 | regw(val, CCDC_CLAMP); |
460 | dev_dbg(dev, "\nWriting 0x%x to CLAMP...\n", val); | 465 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to CLAMP...\n", val); |
461 | /* If Black clamping is enable then make dcsub 0 */ | 466 | /* If Black clamping is enable then make dcsub 0 */ |
462 | regw(CCDC_DCSUB_DEFAULT_VAL, CCDC_DCSUB); | 467 | regw(CCDC_DCSUB_DEFAULT_VAL, CCDC_DCSUB); |
463 | dev_dbg(dev, "\nWriting 0x00000000 to DCSUB...\n"); | 468 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x00000000 to DCSUB...\n"); |
464 | } | 469 | } |
465 | 470 | ||
466 | static void ccdc_config_black_compense(struct ccdc_black_compensation *bcomp) | 471 | static void ccdc_config_black_compense(struct ccdc_black_compensation *bcomp) |
@@ -490,17 +495,17 @@ static void ccdc_config_fpc(struct ccdc_fault_pixel *fpc) | |||
490 | 495 | ||
491 | /* Configure Fault pixel if needed */ | 496 | /* Configure Fault pixel if needed */ |
492 | regw(fpc->fpc_table_addr, CCDC_FPC_ADDR); | 497 | regw(fpc->fpc_table_addr, CCDC_FPC_ADDR); |
493 | dev_dbg(dev, "\nWriting 0x%x to FPC_ADDR...\n", | 498 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FPC_ADDR...\n", |
494 | (fpc->fpc_table_addr)); | 499 | (fpc->fpc_table_addr)); |
495 | /* Write the FPC params with FPC disable */ | 500 | /* Write the FPC params with FPC disable */ |
496 | val = fpc->fp_num & CCDC_FPC_FPC_NUM_MASK; | 501 | val = fpc->fp_num & CCDC_FPC_FPC_NUM_MASK; |
497 | regw(val, CCDC_FPC); | 502 | regw(val, CCDC_FPC); |
498 | 503 | ||
499 | dev_dbg(dev, "\nWriting 0x%x to FPC...\n", val); | 504 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FPC...\n", val); |
500 | /* read the FPC register */ | 505 | /* read the FPC register */ |
501 | val = regr(CCDC_FPC) | CCDC_FPC_ENABLE; | 506 | val = regr(CCDC_FPC) | CCDC_FPC_ENABLE; |
502 | regw(val, CCDC_FPC); | 507 | regw(val, CCDC_FPC); |
503 | dev_dbg(dev, "\nWriting 0x%x to FPC...\n", val); | 508 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FPC...\n", val); |
504 | } | 509 | } |
505 | 510 | ||
506 | /* | 511 | /* |
@@ -509,13 +514,13 @@ static void ccdc_config_fpc(struct ccdc_fault_pixel *fpc) | |||
509 | */ | 514 | */ |
510 | void ccdc_config_raw(void) | 515 | void ccdc_config_raw(void) |
511 | { | 516 | { |
512 | struct ccdc_params_raw *params = &ccdc_hw_params_raw; | 517 | struct ccdc_params_raw *params = &ccdc_cfg.bayer; |
513 | struct ccdc_config_params_raw *config_params = | 518 | struct ccdc_config_params_raw *config_params = |
514 | &ccdc_hw_params_raw.config_params; | 519 | &ccdc_cfg.bayer.config_params; |
515 | unsigned int syn_mode = 0; | 520 | unsigned int syn_mode = 0; |
516 | unsigned int val; | 521 | unsigned int val; |
517 | 522 | ||
518 | dev_dbg(dev, "\nStarting ccdc_config_raw..."); | 523 | dev_dbg(ccdc_cfg.dev, "\nStarting ccdc_config_raw..."); |
519 | 524 | ||
520 | /* Reset CCDC */ | 525 | /* Reset CCDC */ |
521 | ccdc_restore_defaults(); | 526 | ccdc_restore_defaults(); |
@@ -545,7 +550,7 @@ void ccdc_config_raw(void) | |||
545 | val = ((config_params->alaw.gama_wd & | 550 | val = ((config_params->alaw.gama_wd & |
546 | CCDC_ALAW_GAMA_WD_MASK) | CCDC_ALAW_ENABLE); | 551 | CCDC_ALAW_GAMA_WD_MASK) | CCDC_ALAW_ENABLE); |
547 | regw(val, CCDC_ALAW); | 552 | regw(val, CCDC_ALAW); |
548 | dev_dbg(dev, "\nWriting 0x%x to ALAW...\n", val); | 553 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to ALAW...\n", val); |
549 | } | 554 | } |
550 | 555 | ||
551 | /* Configure video window */ | 556 | /* Configure video window */ |
@@ -582,11 +587,11 @@ void ccdc_config_raw(void) | |||
582 | /* Write value in FMTCFG */ | 587 | /* Write value in FMTCFG */ |
583 | regw(val, CCDC_FMTCFG); | 588 | regw(val, CCDC_FMTCFG); |
584 | 589 | ||
585 | dev_dbg(dev, "\nWriting 0x%x to FMTCFG...\n", val); | 590 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FMTCFG...\n", val); |
586 | /* Configure the color pattern according to mt9t001 sensor */ | 591 | /* Configure the color pattern according to mt9t001 sensor */ |
587 | regw(CCDC_COLPTN_VAL, CCDC_COLPTN); | 592 | regw(CCDC_COLPTN_VAL, CCDC_COLPTN); |
588 | 593 | ||
589 | dev_dbg(dev, "\nWriting 0xBB11BB11 to COLPTN...\n"); | 594 | dev_dbg(ccdc_cfg.dev, "\nWriting 0xBB11BB11 to COLPTN...\n"); |
590 | /* | 595 | /* |
591 | * Configure Data formatter(Video port) pixel selection | 596 | * Configure Data formatter(Video port) pixel selection |
592 | * (FMT_HORZ, FMT_VERT) | 597 | * (FMT_HORZ, FMT_VERT) |
@@ -596,7 +601,7 @@ void ccdc_config_raw(void) | |||
596 | (params->win.width & CCDC_FMT_HORZ_FMTLNH_MASK); | 601 | (params->win.width & CCDC_FMT_HORZ_FMTLNH_MASK); |
597 | regw(val, CCDC_FMT_HORZ); | 602 | regw(val, CCDC_FMT_HORZ); |
598 | 603 | ||
599 | dev_dbg(dev, "\nWriting 0x%x to FMT_HORZ...\n", val); | 604 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FMT_HORZ...\n", val); |
600 | val = (params->win.top & CCDC_FMT_VERT_FMTSLV_MASK) | 605 | val = (params->win.top & CCDC_FMT_VERT_FMTSLV_MASK) |
601 | << CCDC_FMT_VERT_FMTSLV_SHIFT; | 606 | << CCDC_FMT_VERT_FMTSLV_SHIFT; |
602 | if (params->frm_fmt == CCDC_FRMFMT_PROGRESSIVE) | 607 | if (params->frm_fmt == CCDC_FRMFMT_PROGRESSIVE) |
@@ -604,13 +609,13 @@ void ccdc_config_raw(void) | |||
604 | else | 609 | else |
605 | val |= (params->win.height >> 1) & CCDC_FMT_VERT_FMTLNV_MASK; | 610 | val |= (params->win.height >> 1) & CCDC_FMT_VERT_FMTLNV_MASK; |
606 | 611 | ||
607 | dev_dbg(dev, "\nparams->win.height 0x%x ...\n", | 612 | dev_dbg(ccdc_cfg.dev, "\nparams->win.height 0x%x ...\n", |
608 | params->win.height); | 613 | params->win.height); |
609 | regw(val, CCDC_FMT_VERT); | 614 | regw(val, CCDC_FMT_VERT); |
610 | 615 | ||
611 | dev_dbg(dev, "\nWriting 0x%x to FMT_VERT...\n", val); | 616 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to FMT_VERT...\n", val); |
612 | 617 | ||
613 | dev_dbg(dev, "\nbelow regw(val, FMT_VERT)..."); | 618 | dev_dbg(ccdc_cfg.dev, "\nbelow regw(val, FMT_VERT)..."); |
614 | 619 | ||
615 | /* | 620 | /* |
616 | * Configure Horizontal offset register. If pack 8 is enabled then | 621 | * Configure Horizontal offset register. If pack 8 is enabled then |
@@ -631,17 +636,17 @@ void ccdc_config_raw(void) | |||
631 | if (params->image_invert_enable) { | 636 | if (params->image_invert_enable) { |
632 | /* For intelace inverse mode */ | 637 | /* For intelace inverse mode */ |
633 | regw(CCDC_INTERLACED_IMAGE_INVERT, CCDC_SDOFST); | 638 | regw(CCDC_INTERLACED_IMAGE_INVERT, CCDC_SDOFST); |
634 | dev_dbg(dev, "\nWriting 0x4B6D to SDOFST...\n"); | 639 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x4B6D to SDOFST..\n"); |
635 | } | 640 | } |
636 | 641 | ||
637 | else { | 642 | else { |
638 | /* For intelace non inverse mode */ | 643 | /* For intelace non inverse mode */ |
639 | regw(CCDC_INTERLACED_NO_IMAGE_INVERT, CCDC_SDOFST); | 644 | regw(CCDC_INTERLACED_NO_IMAGE_INVERT, CCDC_SDOFST); |
640 | dev_dbg(dev, "\nWriting 0x0249 to SDOFST...\n"); | 645 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x0249 to SDOFST..\n"); |
641 | } | 646 | } |
642 | } else if (params->frm_fmt == CCDC_FRMFMT_PROGRESSIVE) { | 647 | } else if (params->frm_fmt == CCDC_FRMFMT_PROGRESSIVE) { |
643 | regw(CCDC_PROGRESSIVE_NO_IMAGE_INVERT, CCDC_SDOFST); | 648 | regw(CCDC_PROGRESSIVE_NO_IMAGE_INVERT, CCDC_SDOFST); |
644 | dev_dbg(dev, "\nWriting 0x0000 to SDOFST...\n"); | 649 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x0000 to SDOFST...\n"); |
645 | } | 650 | } |
646 | 651 | ||
647 | /* | 652 | /* |
@@ -662,18 +667,18 @@ void ccdc_config_raw(void) | |||
662 | val |= (params->win.left) & CCDC_VP_OUT_HORZ_ST_MASK; | 667 | val |= (params->win.left) & CCDC_VP_OUT_HORZ_ST_MASK; |
663 | regw(val, CCDC_VP_OUT); | 668 | regw(val, CCDC_VP_OUT); |
664 | 669 | ||
665 | dev_dbg(dev, "\nWriting 0x%x to VP_OUT...\n", val); | 670 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to VP_OUT...\n", val); |
666 | regw(syn_mode, CCDC_SYN_MODE); | 671 | regw(syn_mode, CCDC_SYN_MODE); |
667 | dev_dbg(dev, "\nWriting 0x%x to SYN_MODE...\n", syn_mode); | 672 | dev_dbg(ccdc_cfg.dev, "\nWriting 0x%x to SYN_MODE...\n", syn_mode); |
668 | 673 | ||
669 | ccdc_sbl_reset(); | 674 | ccdc_sbl_reset(); |
670 | dev_dbg(dev, "\nend of ccdc_config_raw..."); | 675 | dev_dbg(ccdc_cfg.dev, "\nend of ccdc_config_raw..."); |
671 | ccdc_readregs(); | 676 | ccdc_readregs(); |
672 | } | 677 | } |
673 | 678 | ||
674 | static int ccdc_configure(void) | 679 | static int ccdc_configure(void) |
675 | { | 680 | { |
676 | if (ccdc_if_type == VPFE_RAW_BAYER) | 681 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
677 | ccdc_config_raw(); | 682 | ccdc_config_raw(); |
678 | else | 683 | else |
679 | ccdc_config_ycbcr(); | 684 | ccdc_config_ycbcr(); |
@@ -682,24 +687,24 @@ static int ccdc_configure(void) | |||
682 | 687 | ||
683 | static int ccdc_set_buftype(enum ccdc_buftype buf_type) | 688 | static int ccdc_set_buftype(enum ccdc_buftype buf_type) |
684 | { | 689 | { |
685 | if (ccdc_if_type == VPFE_RAW_BAYER) | 690 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
686 | ccdc_hw_params_raw.buf_type = buf_type; | 691 | ccdc_cfg.bayer.buf_type = buf_type; |
687 | else | 692 | else |
688 | ccdc_hw_params_ycbcr.buf_type = buf_type; | 693 | ccdc_cfg.ycbcr.buf_type = buf_type; |
689 | return 0; | 694 | return 0; |
690 | } | 695 | } |
691 | 696 | ||
692 | static enum ccdc_buftype ccdc_get_buftype(void) | 697 | static enum ccdc_buftype ccdc_get_buftype(void) |
693 | { | 698 | { |
694 | if (ccdc_if_type == VPFE_RAW_BAYER) | 699 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
695 | return ccdc_hw_params_raw.buf_type; | 700 | return ccdc_cfg.bayer.buf_type; |
696 | return ccdc_hw_params_ycbcr.buf_type; | 701 | return ccdc_cfg.ycbcr.buf_type; |
697 | } | 702 | } |
698 | 703 | ||
699 | static int ccdc_enum_pix(u32 *pix, int i) | 704 | static int ccdc_enum_pix(u32 *pix, int i) |
700 | { | 705 | { |
701 | int ret = -EINVAL; | 706 | int ret = -EINVAL; |
702 | if (ccdc_if_type == VPFE_RAW_BAYER) { | 707 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) { |
703 | if (i < ARRAY_SIZE(ccdc_raw_bayer_pix_formats)) { | 708 | if (i < ARRAY_SIZE(ccdc_raw_bayer_pix_formats)) { |
704 | *pix = ccdc_raw_bayer_pix_formats[i]; | 709 | *pix = ccdc_raw_bayer_pix_formats[i]; |
705 | ret = 0; | 710 | ret = 0; |
@@ -715,17 +720,17 @@ static int ccdc_enum_pix(u32 *pix, int i) | |||
715 | 720 | ||
716 | static int ccdc_set_pixel_format(u32 pixfmt) | 721 | static int ccdc_set_pixel_format(u32 pixfmt) |
717 | { | 722 | { |
718 | if (ccdc_if_type == VPFE_RAW_BAYER) { | 723 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) { |
719 | ccdc_hw_params_raw.pix_fmt = CCDC_PIXFMT_RAW; | 724 | ccdc_cfg.bayer.pix_fmt = CCDC_PIXFMT_RAW; |
720 | if (pixfmt == V4L2_PIX_FMT_SBGGR8) | 725 | if (pixfmt == V4L2_PIX_FMT_SBGGR8) |
721 | ccdc_hw_params_raw.config_params.alaw.enable = 1; | 726 | ccdc_cfg.bayer.config_params.alaw.enable = 1; |
722 | else if (pixfmt != V4L2_PIX_FMT_SBGGR16) | 727 | else if (pixfmt != V4L2_PIX_FMT_SBGGR16) |
723 | return -EINVAL; | 728 | return -EINVAL; |
724 | } else { | 729 | } else { |
725 | if (pixfmt == V4L2_PIX_FMT_YUYV) | 730 | if (pixfmt == V4L2_PIX_FMT_YUYV) |
726 | ccdc_hw_params_ycbcr.pix_order = CCDC_PIXORDER_YCBYCR; | 731 | ccdc_cfg.ycbcr.pix_order = CCDC_PIXORDER_YCBYCR; |
727 | else if (pixfmt == V4L2_PIX_FMT_UYVY) | 732 | else if (pixfmt == V4L2_PIX_FMT_UYVY) |
728 | ccdc_hw_params_ycbcr.pix_order = CCDC_PIXORDER_CBYCRY; | 733 | ccdc_cfg.ycbcr.pix_order = CCDC_PIXORDER_CBYCRY; |
729 | else | 734 | else |
730 | return -EINVAL; | 735 | return -EINVAL; |
731 | } | 736 | } |
@@ -734,17 +739,16 @@ static int ccdc_set_pixel_format(u32 pixfmt) | |||
734 | 739 | ||
735 | static u32 ccdc_get_pixel_format(void) | 740 | static u32 ccdc_get_pixel_format(void) |
736 | { | 741 | { |
737 | struct ccdc_a_law *alaw = | 742 | struct ccdc_a_law *alaw = &ccdc_cfg.bayer.config_params.alaw; |
738 | &ccdc_hw_params_raw.config_params.alaw; | ||
739 | u32 pixfmt; | 743 | u32 pixfmt; |
740 | 744 | ||
741 | if (ccdc_if_type == VPFE_RAW_BAYER) | 745 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
742 | if (alaw->enable) | 746 | if (alaw->enable) |
743 | pixfmt = V4L2_PIX_FMT_SBGGR8; | 747 | pixfmt = V4L2_PIX_FMT_SBGGR8; |
744 | else | 748 | else |
745 | pixfmt = V4L2_PIX_FMT_SBGGR16; | 749 | pixfmt = V4L2_PIX_FMT_SBGGR16; |
746 | else { | 750 | else { |
747 | if (ccdc_hw_params_ycbcr.pix_order == CCDC_PIXORDER_YCBYCR) | 751 | if (ccdc_cfg.ycbcr.pix_order == CCDC_PIXORDER_YCBYCR) |
748 | pixfmt = V4L2_PIX_FMT_YUYV; | 752 | pixfmt = V4L2_PIX_FMT_YUYV; |
749 | else | 753 | else |
750 | pixfmt = V4L2_PIX_FMT_UYVY; | 754 | pixfmt = V4L2_PIX_FMT_UYVY; |
@@ -754,53 +758,53 @@ static u32 ccdc_get_pixel_format(void) | |||
754 | 758 | ||
755 | static int ccdc_set_image_window(struct v4l2_rect *win) | 759 | static int ccdc_set_image_window(struct v4l2_rect *win) |
756 | { | 760 | { |
757 | if (ccdc_if_type == VPFE_RAW_BAYER) | 761 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
758 | ccdc_hw_params_raw.win = *win; | 762 | ccdc_cfg.bayer.win = *win; |
759 | else | 763 | else |
760 | ccdc_hw_params_ycbcr.win = *win; | 764 | ccdc_cfg.ycbcr.win = *win; |
761 | return 0; | 765 | return 0; |
762 | } | 766 | } |
763 | 767 | ||
764 | static void ccdc_get_image_window(struct v4l2_rect *win) | 768 | static void ccdc_get_image_window(struct v4l2_rect *win) |
765 | { | 769 | { |
766 | if (ccdc_if_type == VPFE_RAW_BAYER) | 770 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
767 | *win = ccdc_hw_params_raw.win; | 771 | *win = ccdc_cfg.bayer.win; |
768 | else | 772 | else |
769 | *win = ccdc_hw_params_ycbcr.win; | 773 | *win = ccdc_cfg.ycbcr.win; |
770 | } | 774 | } |
771 | 775 | ||
772 | static unsigned int ccdc_get_line_length(void) | 776 | static unsigned int ccdc_get_line_length(void) |
773 | { | 777 | { |
774 | struct ccdc_config_params_raw *config_params = | 778 | struct ccdc_config_params_raw *config_params = |
775 | &ccdc_hw_params_raw.config_params; | 779 | &ccdc_cfg.bayer.config_params; |
776 | unsigned int len; | 780 | unsigned int len; |
777 | 781 | ||
778 | if (ccdc_if_type == VPFE_RAW_BAYER) { | 782 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) { |
779 | if ((config_params->alaw.enable) || | 783 | if ((config_params->alaw.enable) || |
780 | (config_params->data_sz == CCDC_DATA_8BITS)) | 784 | (config_params->data_sz == CCDC_DATA_8BITS)) |
781 | len = ccdc_hw_params_raw.win.width; | 785 | len = ccdc_cfg.bayer.win.width; |
782 | else | 786 | else |
783 | len = ccdc_hw_params_raw.win.width * 2; | 787 | len = ccdc_cfg.bayer.win.width * 2; |
784 | } else | 788 | } else |
785 | len = ccdc_hw_params_ycbcr.win.width * 2; | 789 | len = ccdc_cfg.ycbcr.win.width * 2; |
786 | return ALIGN(len, 32); | 790 | return ALIGN(len, 32); |
787 | } | 791 | } |
788 | 792 | ||
789 | static int ccdc_set_frame_format(enum ccdc_frmfmt frm_fmt) | 793 | static int ccdc_set_frame_format(enum ccdc_frmfmt frm_fmt) |
790 | { | 794 | { |
791 | if (ccdc_if_type == VPFE_RAW_BAYER) | 795 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
792 | ccdc_hw_params_raw.frm_fmt = frm_fmt; | 796 | ccdc_cfg.bayer.frm_fmt = frm_fmt; |
793 | else | 797 | else |
794 | ccdc_hw_params_ycbcr.frm_fmt = frm_fmt; | 798 | ccdc_cfg.ycbcr.frm_fmt = frm_fmt; |
795 | return 0; | 799 | return 0; |
796 | } | 800 | } |
797 | 801 | ||
798 | static enum ccdc_frmfmt ccdc_get_frame_format(void) | 802 | static enum ccdc_frmfmt ccdc_get_frame_format(void) |
799 | { | 803 | { |
800 | if (ccdc_if_type == VPFE_RAW_BAYER) | 804 | if (ccdc_cfg.if_type == VPFE_RAW_BAYER) |
801 | return ccdc_hw_params_raw.frm_fmt; | 805 | return ccdc_cfg.bayer.frm_fmt; |
802 | else | 806 | else |
803 | return ccdc_hw_params_ycbcr.frm_fmt; | 807 | return ccdc_cfg.ycbcr.frm_fmt; |
804 | } | 808 | } |
805 | 809 | ||
806 | static int ccdc_getfid(void) | 810 | static int ccdc_getfid(void) |
@@ -816,14 +820,14 @@ static inline void ccdc_setfbaddr(unsigned long addr) | |||
816 | 820 | ||
817 | static int ccdc_set_hw_if_params(struct vpfe_hw_if_param *params) | 821 | static int ccdc_set_hw_if_params(struct vpfe_hw_if_param *params) |
818 | { | 822 | { |
819 | ccdc_if_type = params->if_type; | 823 | ccdc_cfg.if_type = params->if_type; |
820 | 824 | ||
821 | switch (params->if_type) { | 825 | switch (params->if_type) { |
822 | case VPFE_BT656: | 826 | case VPFE_BT656: |
823 | case VPFE_YCBCR_SYNC_16: | 827 | case VPFE_YCBCR_SYNC_16: |
824 | case VPFE_YCBCR_SYNC_8: | 828 | case VPFE_YCBCR_SYNC_8: |
825 | ccdc_hw_params_ycbcr.vd_pol = params->vdpol; | 829 | ccdc_cfg.ycbcr.vd_pol = params->vdpol; |
826 | ccdc_hw_params_ycbcr.hd_pol = params->hdpol; | 830 | ccdc_cfg.ycbcr.hd_pol = params->hdpol; |
827 | break; | 831 | break; |
828 | default: | 832 | default: |
829 | /* TODO add support for raw bayer here */ | 833 | /* TODO add support for raw bayer here */ |
@@ -838,7 +842,6 @@ static struct ccdc_hw_device ccdc_hw_dev = { | |||
838 | .hw_ops = { | 842 | .hw_ops = { |
839 | .open = ccdc_open, | 843 | .open = ccdc_open, |
840 | .close = ccdc_close, | 844 | .close = ccdc_close, |
841 | .set_ccdc_base = ccdc_set_ccdc_base, | ||
842 | .reset = ccdc_sbl_reset, | 845 | .reset = ccdc_sbl_reset, |
843 | .enable = ccdc_enable, | 846 | .enable = ccdc_enable, |
844 | .set_hw_if_params = ccdc_set_hw_if_params, | 847 | .set_hw_if_params = ccdc_set_hw_if_params, |
@@ -859,19 +862,105 @@ static struct ccdc_hw_device ccdc_hw_dev = { | |||
859 | }, | 862 | }, |
860 | }; | 863 | }; |
861 | 864 | ||
862 | static int __init dm644x_ccdc_init(void) | 865 | static int __init dm644x_ccdc_probe(struct platform_device *pdev) |
863 | { | 866 | { |
864 | printk(KERN_NOTICE "dm644x_ccdc_init\n"); | 867 | struct resource *res; |
865 | if (vpfe_register_ccdc_device(&ccdc_hw_dev) < 0) | 868 | int status = 0; |
866 | return -1; | 869 | |
867 | printk(KERN_NOTICE "%s is registered with vpfe.\n", | 870 | /* |
868 | ccdc_hw_dev.name); | 871 | * first try to register with vpfe. If not correct platform, then we |
872 | * don't have to iomap | ||
873 | */ | ||
874 | status = vpfe_register_ccdc_device(&ccdc_hw_dev); | ||
875 | if (status < 0) | ||
876 | return status; | ||
877 | |||
878 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
879 | if (!res) { | ||
880 | status = -ENODEV; | ||
881 | goto fail_nores; | ||
882 | } | ||
883 | |||
884 | res = request_mem_region(res->start, resource_size(res), res->name); | ||
885 | if (!res) { | ||
886 | status = -EBUSY; | ||
887 | goto fail_nores; | ||
888 | } | ||
889 | |||
890 | ccdc_cfg.base_addr = ioremap_nocache(res->start, resource_size(res)); | ||
891 | if (!ccdc_cfg.base_addr) { | ||
892 | status = -ENOMEM; | ||
893 | goto fail_nomem; | ||
894 | } | ||
895 | |||
896 | /* Get and enable Master clock */ | ||
897 | ccdc_cfg.mclk = clk_get(&pdev->dev, "master"); | ||
898 | if (IS_ERR(ccdc_cfg.mclk)) { | ||
899 | status = PTR_ERR(ccdc_cfg.mclk); | ||
900 | goto fail_nomap; | ||
901 | } | ||
902 | if (clk_enable(ccdc_cfg.mclk)) { | ||
903 | status = -ENODEV; | ||
904 | goto fail_mclk; | ||
905 | } | ||
906 | |||
907 | /* Get and enable Slave clock */ | ||
908 | ccdc_cfg.sclk = clk_get(&pdev->dev, "slave"); | ||
909 | if (IS_ERR(ccdc_cfg.sclk)) { | ||
910 | status = PTR_ERR(ccdc_cfg.sclk); | ||
911 | goto fail_mclk; | ||
912 | } | ||
913 | if (clk_enable(ccdc_cfg.sclk)) { | ||
914 | status = -ENODEV; | ||
915 | goto fail_sclk; | ||
916 | } | ||
917 | ccdc_cfg.dev = &pdev->dev; | ||
918 | printk(KERN_NOTICE "%s is registered with vpfe.\n", ccdc_hw_dev.name); | ||
869 | return 0; | 919 | return 0; |
920 | fail_sclk: | ||
921 | clk_put(ccdc_cfg.sclk); | ||
922 | fail_mclk: | ||
923 | clk_put(ccdc_cfg.mclk); | ||
924 | fail_nomap: | ||
925 | iounmap(ccdc_cfg.base_addr); | ||
926 | fail_nomem: | ||
927 | release_mem_region(res->start, resource_size(res)); | ||
928 | fail_nores: | ||
929 | vpfe_unregister_ccdc_device(&ccdc_hw_dev); | ||
930 | return status; | ||
870 | } | 931 | } |
871 | 932 | ||
872 | static void __exit dm644x_ccdc_exit(void) | 933 | static int dm644x_ccdc_remove(struct platform_device *pdev) |
873 | { | 934 | { |
935 | struct resource *res; | ||
936 | |||
937 | clk_put(ccdc_cfg.mclk); | ||
938 | clk_put(ccdc_cfg.sclk); | ||
939 | iounmap(ccdc_cfg.base_addr); | ||
940 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
941 | if (res) | ||
942 | release_mem_region(res->start, resource_size(res)); | ||
874 | vpfe_unregister_ccdc_device(&ccdc_hw_dev); | 943 | vpfe_unregister_ccdc_device(&ccdc_hw_dev); |
944 | return 0; | ||
945 | } | ||
946 | |||
947 | static struct platform_driver dm644x_ccdc_driver = { | ||
948 | .driver = { | ||
949 | .name = "dm644x_ccdc", | ||
950 | .owner = THIS_MODULE, | ||
951 | }, | ||
952 | .remove = __devexit_p(dm644x_ccdc_remove), | ||
953 | .probe = dm644x_ccdc_probe, | ||
954 | }; | ||
955 | |||
956 | static int __init dm644x_ccdc_init(void) | ||
957 | { | ||
958 | return platform_driver_register(&dm644x_ccdc_driver); | ||
959 | } | ||
960 | |||
961 | static void __exit dm644x_ccdc_exit(void) | ||
962 | { | ||
963 | platform_driver_unregister(&dm644x_ccdc_driver); | ||
875 | } | 964 | } |
876 | 965 | ||
877 | module_init(dm644x_ccdc_init); | 966 | module_init(dm644x_ccdc_init); |