aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/davinci
diff options
context:
space:
mode:
authorManjunath Hadli <manjunath.hadli@ti.com>2011-09-10 01:19:55 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-06 07:09:26 -0500
commit194ed21925032b366e693373ba9bde62fbbf16ed (patch)
tree2c66a8f9283d117ca0f93e371fb6792c1d7e5b31 /drivers/media/video/davinci
parent4be54445508764defe1c149e420287e62d3dd9ca (diff)
[media] davinci vpbe: add VENC block changes to enable dm365 and dm355
This patch implements necessary changes for enabling dm365 and dm355 hardware for vpbe. The patch contains additional HD mode support for dm365 (720p60, 1080i30) and appropriate register modifications based on version numbers. VPBE_VERSION_2 = dm365 specific VPBE_VERSION_3 = dm355 specific Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/davinci')
-rw-r--r--drivers/media/video/davinci/vpbe_venc.c205
1 files changed, 181 insertions, 24 deletions
diff --git a/drivers/media/video/davinci/vpbe_venc.c b/drivers/media/video/davinci/vpbe_venc.c
index 03a3e5c65ee7..53c29943e91f 100644
--- a/drivers/media/video/davinci/vpbe_venc.c
+++ b/drivers/media/video/davinci/vpbe_venc.c
@@ -99,6 +99,8 @@ static inline u32 vdaccfg_write(struct v4l2_subdev *sd, u32 val)
99 return val; 99 return val;
100} 100}
101 101
102#define VDAC_COMPONENT 0x543
103#define VDAC_S_VIDEO 0x210
102/* This function sets the dac of the VPBE for various outputs 104/* This function sets the dac of the VPBE for various outputs
103 */ 105 */
104static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index) 106static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
@@ -109,11 +111,12 @@ static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
109 venc_write(sd, VENC_DACSEL, 0); 111 venc_write(sd, VENC_DACSEL, 0);
110 break; 112 break;
111 case 1: 113 case 1:
112 v4l2_dbg(debug, 1, sd, "Setting output to S-Video\n"); 114 v4l2_dbg(debug, 1, sd, "Setting output to Component\n");
113 venc_write(sd, VENC_DACSEL, 0x210); 115 venc_write(sd, VENC_DACSEL, VDAC_COMPONENT);
114 break; 116 break;
115 case 2: 117 case 2:
116 venc_write(sd, VENC_DACSEL, 0x543); 118 v4l2_dbg(debug, 1, sd, "Setting output to S-video\n");
119 venc_write(sd, VENC_DACSEL, VDAC_S_VIDEO);
117 break; 120 break;
118 default: 121 default:
119 return -EINVAL; 122 return -EINVAL;
@@ -124,6 +127,8 @@ static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
124 127
125static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable) 128static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
126{ 129{
130 struct venc_state *venc = to_state(sd);
131 struct venc_platform_data *pdata = venc->pdata;
127 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n"); 132 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n");
128 133
129 if (benable) { 134 if (benable) {
@@ -155,7 +160,8 @@ static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
155 160
156 /* Disable LCD output control (accepting default polarity) */ 161 /* Disable LCD output control (accepting default polarity) */
157 venc_write(sd, VENC_LCDOUT, 0); 162 venc_write(sd, VENC_LCDOUT, 0);
158 venc_write(sd, VENC_CMPNT, 0x100); 163 if (pdata->venc_type != VPBE_VERSION_3)
164 venc_write(sd, VENC_CMPNT, 0x100);
159 venc_write(sd, VENC_HSPLS, 0); 165 venc_write(sd, VENC_HSPLS, 0);
160 venc_write(sd, VENC_HINT, 0); 166 venc_write(sd, VENC_HINT, 0);
161 venc_write(sd, VENC_HSTART, 0); 167 venc_write(sd, VENC_HSTART, 0);
@@ -178,11 +184,14 @@ static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
178 } 184 }
179} 185}
180 186
187#define VDAC_CONFIG_SD_V3 0x0E21A6B6
188#define VDAC_CONFIG_SD_V2 0x081141CF
181/* 189/*
182 * setting NTSC mode 190 * setting NTSC mode
183 */ 191 */
184static int venc_set_ntsc(struct v4l2_subdev *sd) 192static int venc_set_ntsc(struct v4l2_subdev *sd)
185{ 193{
194 u32 val;
186 struct venc_state *venc = to_state(sd); 195 struct venc_state *venc = to_state(sd);
187 struct venc_platform_data *pdata = venc->pdata; 196 struct venc_platform_data *pdata = venc->pdata;
188 197
@@ -195,12 +204,22 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
195 204
196 venc_enabledigitaloutput(sd, 0); 205 venc_enabledigitaloutput(sd, 0);
197 206
198 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */ 207 if (pdata->venc_type == VPBE_VERSION_3) {
199 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); 208 venc_write(sd, VENC_CLKCTL, 0x01);
200 /* Set REC656 Mode */ 209 venc_write(sd, VENC_VIDCTL, 0);
201 venc_write(sd, VENC_YCCCTL, 0x1); 210 val = vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
202 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ); 211 } else if (pdata->venc_type == VPBE_VERSION_2) {
203 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS); 212 venc_write(sd, VENC_CLKCTL, 0x01);
213 venc_write(sd, VENC_VIDCTL, 0);
214 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
215 } else {
216 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
217 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1);
218 /* Set REC656 Mode */
219 venc_write(sd, VENC_YCCCTL, 0x1);
220 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ);
221 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS);
222 }
204 223
205 venc_write(sd, VENC_VMOD, 0); 224 venc_write(sd, VENC_VMOD, 0);
206 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 225 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
@@ -220,6 +239,7 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
220static int venc_set_pal(struct v4l2_subdev *sd) 239static int venc_set_pal(struct v4l2_subdev *sd)
221{ 240{
222 struct venc_state *venc = to_state(sd); 241 struct venc_state *venc = to_state(sd);
242 struct venc_platform_data *pdata = venc->pdata;
223 243
224 v4l2_dbg(debug, 2, sd, "venc_set_pal\n"); 244 v4l2_dbg(debug, 2, sd, "venc_set_pal\n");
225 245
@@ -230,10 +250,20 @@ static int venc_set_pal(struct v4l2_subdev *sd)
230 250
231 venc_enabledigitaloutput(sd, 0); 251 venc_enabledigitaloutput(sd, 0);
232 252
233 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */ 253 if (pdata->venc_type == VPBE_VERSION_3) {
234 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); 254 venc_write(sd, VENC_CLKCTL, 0x1);
235 /* Set REC656 Mode */ 255 venc_write(sd, VENC_VIDCTL, 0);
236 venc_write(sd, VENC_YCCCTL, 0x1); 256 vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
257 } else if (pdata->venc_type == VPBE_VERSION_2) {
258 venc_write(sd, VENC_CLKCTL, 0x1);
259 venc_write(sd, VENC_VIDCTL, 0);
260 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
261 } else {
262 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
263 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1);
264 /* Set REC656 Mode */
265 venc_write(sd, VENC_YCCCTL, 0x1);
266 }
237 267
238 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT, 268 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT,
239 VENC_SYNCCTL_OVD); 269 VENC_SYNCCTL_OVD);
@@ -252,6 +282,7 @@ static int venc_set_pal(struct v4l2_subdev *sd)
252 return 0; 282 return 0;
253} 283}
254 284
285#define VDAC_CONFIG_HD_V2 0x081141EF
255/* 286/*
256 * venc_set_480p59_94 287 * venc_set_480p59_94
257 * 288 *
@@ -263,6 +294,9 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
263 struct venc_platform_data *pdata = venc->pdata; 294 struct venc_platform_data *pdata = venc->pdata;
264 295
265 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n"); 296 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n");
297 if ((pdata->venc_type != VPBE_VERSION_1) &&
298 (pdata->venc_type != VPBE_VERSION_2))
299 return -EINVAL;
266 300
267 /* Setup clock at VPSS & VENC for SD */ 301 /* Setup clock at VPSS & VENC for SD */
268 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_480P59_94) < 0) 302 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_480P59_94) < 0)
@@ -270,12 +304,18 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
270 304
271 venc_enabledigitaloutput(sd, 0); 305 venc_enabledigitaloutput(sd, 0);
272 306
307 if (pdata->venc_type == VPBE_VERSION_2)
308 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
273 venc_write(sd, VENC_OSDCLK0, 0); 309 venc_write(sd, VENC_OSDCLK0, 0);
274 venc_write(sd, VENC_OSDCLK1, 1); 310 venc_write(sd, VENC_OSDCLK1, 1);
275 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 311
276 VENC_VDPRO_DAFRQ); 312 if (pdata->venc_type == VPBE_VERSION_1) {
277 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 313 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
278 VENC_VDPRO_DAUPS); 314 VENC_VDPRO_DAFRQ);
315 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
316 VENC_VDPRO_DAUPS);
317 }
318
279 venc_write(sd, VENC_VMOD, 0); 319 venc_write(sd, VENC_VMOD, 0);
280 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 320 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
281 VENC_VMOD_VIE); 321 VENC_VMOD_VIE);
@@ -302,19 +342,27 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
302 342
303 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n"); 343 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n");
304 344
345 if ((pdata->venc_type != VPBE_VERSION_1) &&
346 (pdata->venc_type != VPBE_VERSION_2))
347 return -EINVAL;
305 /* Setup clock at VPSS & VENC for SD */ 348 /* Setup clock at VPSS & VENC for SD */
306 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_576P50) < 0) 349 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_576P50) < 0)
307 return -EINVAL; 350 return -EINVAL;
308 351
309 venc_enabledigitaloutput(sd, 0); 352 venc_enabledigitaloutput(sd, 0);
310 353
354 if (pdata->venc_type == VPBE_VERSION_2)
355 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
356
311 venc_write(sd, VENC_OSDCLK0, 0); 357 venc_write(sd, VENC_OSDCLK0, 0);
312 venc_write(sd, VENC_OSDCLK1, 1); 358 venc_write(sd, VENC_OSDCLK1, 1);
313 359
314 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 360 if (pdata->venc_type == VPBE_VERSION_1) {
315 VENC_VDPRO_DAFRQ); 361 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
316 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 362 VENC_VDPRO_DAFRQ);
317 VENC_VDPRO_DAUPS); 363 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
364 VENC_VDPRO_DAUPS);
365 }
318 366
319 venc_write(sd, VENC_VMOD, 0); 367 venc_write(sd, VENC_VMOD, 0);
320 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 368 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
@@ -330,6 +378,63 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
330 return 0; 378 return 0;
331} 379}
332 380
381/*
382 * venc_set_720p60_internal - Setup 720p60 in venc for dm365 only
383 */
384static int venc_set_720p60_internal(struct v4l2_subdev *sd)
385{
386 struct venc_state *venc = to_state(sd);
387 struct venc_platform_data *pdata = venc->pdata;
388
389 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_720P60) < 0)
390 return -EINVAL;
391
392 venc_enabledigitaloutput(sd, 0);
393
394 venc_write(sd, VENC_OSDCLK0, 0);
395 venc_write(sd, VENC_OSDCLK1, 1);
396
397 venc_write(sd, VENC_VMOD, 0);
398 /* DM365 component HD mode */
399 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
400 VENC_VMOD_VIE);
401 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD);
402 venc_modify(sd, VENC_VMOD, (HDTV_720P << VENC_VMOD_TVTYP_SHIFT),
403 VENC_VMOD_TVTYP);
404 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC);
405 venc_write(sd, VENC_XHINTVL, 0);
406 return 0;
407}
408
409/*
410 * venc_set_1080i30_internal - Setup 1080i30 in venc for dm365 only
411 */
412static int venc_set_1080i30_internal(struct v4l2_subdev *sd)
413{
414 struct venc_state *venc = to_state(sd);
415 struct venc_platform_data *pdata = venc->pdata;
416
417 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_1080P30) < 0)
418 return -EINVAL;
419
420 venc_enabledigitaloutput(sd, 0);
421
422 venc_write(sd, VENC_OSDCLK0, 0);
423 venc_write(sd, VENC_OSDCLK1, 1);
424
425
426 venc_write(sd, VENC_VMOD, 0);
427 /* DM365 component HD mode */
428 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
429 VENC_VMOD_VIE);
430 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD);
431 venc_modify(sd, VENC_VMOD, (HDTV_1080I << VENC_VMOD_TVTYP_SHIFT),
432 VENC_VMOD_TVTYP);
433 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC);
434 venc_write(sd, VENC_XHINTVL, 0);
435 return 0;
436}
437
333static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm) 438static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm)
334{ 439{
335 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n"); 440 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n");
@@ -345,13 +450,30 @@ static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm)
345static int venc_s_dv_preset(struct v4l2_subdev *sd, 450static int venc_s_dv_preset(struct v4l2_subdev *sd,
346 struct v4l2_dv_preset *dv_preset) 451 struct v4l2_dv_preset *dv_preset)
347{ 452{
453 struct venc_state *venc = to_state(sd);
454 int ret;
455
348 v4l2_dbg(debug, 1, sd, "venc_s_dv_preset\n"); 456 v4l2_dbg(debug, 1, sd, "venc_s_dv_preset\n");
349 457
350 if (dv_preset->preset == V4L2_DV_576P50) 458 if (dv_preset->preset == V4L2_DV_576P50)
351 return venc_set_576p50(sd); 459 return venc_set_576p50(sd);
352 else if (dv_preset->preset == V4L2_DV_480P59_94) 460 else if (dv_preset->preset == V4L2_DV_480P59_94)
353 return venc_set_480p59_94(sd); 461 return venc_set_480p59_94(sd);
354 462 else if ((dv_preset->preset == V4L2_DV_720P60) &&
463 (venc->pdata->venc_type == VPBE_VERSION_2)) {
464 /* TBD setup internal 720p mode here */
465 ret = venc_set_720p60_internal(sd);
466 /* for DM365 VPBE, there is DAC inside */
467 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
468 return ret;
469 } else if ((dv_preset->preset == V4L2_DV_1080I30) &&
470 (venc->pdata->venc_type == VPBE_VERSION_2)) {
471 /* TBD setup internal 1080i mode here */
472 ret = venc_set_1080i30_internal(sd);
473 /* for DM365 VPBE, there is DAC inside */
474 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
475 return ret;
476 }
355 return -EINVAL; 477 return -EINVAL;
356} 478}
357 479
@@ -508,11 +630,41 @@ static int venc_probe(struct platform_device *pdev)
508 goto release_venc_mem_region; 630 goto release_venc_mem_region;
509 } 631 }
510 632
633 if (venc->pdata->venc_type != VPBE_VERSION_1) {
634 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
635 if (!res) {
636 dev_err(venc->pdev,
637 "Unable to get VDAC_CONFIG address map\n");
638 ret = -ENODEV;
639 goto unmap_venc_io;
640 }
641
642 if (!request_mem_region(res->start,
643 resource_size(res), "venc")) {
644 dev_err(venc->pdev,
645 "Unable to reserve VDAC_CONFIG MMIO region\n");
646 ret = -ENODEV;
647 goto unmap_venc_io;
648 }
649
650 venc->vdaccfg_reg = ioremap_nocache(res->start,
651 resource_size(res));
652 if (!venc->vdaccfg_reg) {
653 dev_err(venc->pdev,
654 "Unable to map VDAC_CONFIG IO space\n");
655 ret = -ENODEV;
656 goto release_vdaccfg_mem_region;
657 }
658 }
511 spin_lock_init(&venc->lock); 659 spin_lock_init(&venc->lock);
512 platform_set_drvdata(pdev, venc); 660 platform_set_drvdata(pdev, venc);
513 dev_notice(venc->pdev, "VENC sub device probe success\n"); 661 dev_notice(venc->pdev, "VENC sub device probe success\n");
514 return 0; 662 return 0;
515 663
664release_vdaccfg_mem_region:
665 release_mem_region(res->start, resource_size(res));
666unmap_venc_io:
667 iounmap(venc->venc_base);
516release_venc_mem_region: 668release_venc_mem_region:
517 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 669 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
518 release_mem_region(res->start, resource_size(res)); 670 release_mem_region(res->start, resource_size(res));
@@ -529,6 +681,11 @@ static int venc_remove(struct platform_device *pdev)
529 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 681 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
530 iounmap((void *)venc->venc_base); 682 iounmap((void *)venc->venc_base);
531 release_mem_region(res->start, resource_size(res)); 683 release_mem_region(res->start, resource_size(res));
684 if (venc->pdata->venc_type != VPBE_VERSION_1) {
685 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
686 iounmap((void *)venc->vdaccfg_reg);
687 release_mem_region(res->start, resource_size(res));
688 }
532 kfree(venc); 689 kfree(venc);
533 690
534 return 0; 691 return 0;