aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/omapdrm')
-rw-r--r--drivers/gpu/drm/omapdrm/dss/venc.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 5bd7788357b2..d58da6f32693 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -263,6 +263,12 @@ static const struct venc_config venc_config_pal_bdghi = {
263 .fid_ext_start_y__fid_ext_offset_y = 0x01380005, 263 .fid_ext_start_y__fid_ext_offset_y = 0x01380005,
264}; 264};
265 265
266enum venc_videomode {
267 VENC_MODE_UNKNOWN,
268 VENC_MODE_PAL,
269 VENC_MODE_NTSC,
270};
271
266static const struct videomode omap_dss_pal_vm = { 272static const struct videomode omap_dss_pal_vm = {
267 .hactive = 720, 273 .hactive = 720,
268 .vactive = 574, 274 .vactive = 574,
@@ -297,6 +303,24 @@ static const struct videomode omap_dss_ntsc_vm = {
297 DISPLAY_FLAGS_SYNC_NEGEDGE, 303 DISPLAY_FLAGS_SYNC_NEGEDGE,
298}; 304};
299 305
306static enum venc_videomode venc_get_videomode(const struct videomode *vm)
307{
308 if (!(vm->flags & DISPLAY_FLAGS_INTERLACED))
309 return VENC_MODE_UNKNOWN;
310
311 if (vm->pixelclock == omap_dss_pal_vm.pixelclock &&
312 vm->hactive == omap_dss_pal_vm.hactive &&
313 vm->vactive == omap_dss_pal_vm.vactive)
314 return VENC_MODE_PAL;
315
316 if (vm->pixelclock == omap_dss_ntsc_vm.pixelclock &&
317 vm->hactive == omap_dss_ntsc_vm.hactive &&
318 vm->vactive == omap_dss_ntsc_vm.vactive)
319 return VENC_MODE_NTSC;
320
321 return VENC_MODE_UNKNOWN;
322}
323
300static struct { 324static struct {
301 struct platform_device *pdev; 325 struct platform_device *pdev;
302 void __iomem *base; 326 void __iomem *base;
@@ -423,14 +447,14 @@ static void venc_runtime_put(void)
423 447
424static const struct venc_config *venc_timings_to_config(struct videomode *vm) 448static const struct venc_config *venc_timings_to_config(struct videomode *vm)
425{ 449{
426 if (memcmp(&omap_dss_pal_vm, vm, sizeof(*vm)) == 0) 450 switch (venc_get_videomode(vm)) {
451 default:
452 WARN_ON_ONCE(1);
453 case VENC_MODE_PAL:
427 return &venc_config_pal_trm; 454 return &venc_config_pal_trm;
428 455 case VENC_MODE_NTSC:
429 if (memcmp(&omap_dss_ntsc_vm, vm, sizeof(*vm)) == 0)
430 return &venc_config_ntsc_trm; 456 return &venc_config_ntsc_trm;
431 457 }
432 BUG();
433 return NULL;
434} 458}
435 459
436static int venc_power_on(struct omap_dss_device *dssdev) 460static int venc_power_on(struct omap_dss_device *dssdev)
@@ -541,15 +565,28 @@ static void venc_display_disable(struct omap_dss_device *dssdev)
541static void venc_set_timings(struct omap_dss_device *dssdev, 565static void venc_set_timings(struct omap_dss_device *dssdev,
542 struct videomode *vm) 566 struct videomode *vm)
543{ 567{
568 struct videomode actual_vm;
569
544 DSSDBG("venc_set_timings\n"); 570 DSSDBG("venc_set_timings\n");
545 571
546 mutex_lock(&venc.venc_lock); 572 mutex_lock(&venc.venc_lock);
547 573
574 switch (venc_get_videomode(vm)) {
575 default:
576 WARN_ON_ONCE(1);
577 case VENC_MODE_PAL:
578 actual_vm = omap_dss_pal_vm;
579 break;
580 case VENC_MODE_NTSC:
581 actual_vm = omap_dss_ntsc_vm;
582 break;
583 }
584
548 /* Reset WSS data when the TV standard changes. */ 585 /* Reset WSS data when the TV standard changes. */
549 if (memcmp(&venc.vm, vm, sizeof(*vm))) 586 if (memcmp(&venc.vm, &actual_vm, sizeof(actual_vm)))
550 venc.wss_data = 0; 587 venc.wss_data = 0;
551 588
552 venc.vm = *vm; 589 venc.vm = actual_vm;
553 590
554 dispc_set_tv_pclk(13500000); 591 dispc_set_tv_pclk(13500000);
555 592
@@ -561,13 +598,13 @@ static int venc_check_timings(struct omap_dss_device *dssdev,
561{ 598{
562 DSSDBG("venc_check_timings\n"); 599 DSSDBG("venc_check_timings\n");
563 600
564 if (memcmp(&omap_dss_pal_vm, vm, sizeof(*vm)) == 0) 601 switch (venc_get_videomode(vm)) {
602 case VENC_MODE_PAL:
603 case VENC_MODE_NTSC:
565 return 0; 604 return 0;
566 605 default:
567 if (memcmp(&omap_dss_ntsc_vm, vm, sizeof(*vm)) == 0) 606 return -EINVAL;
568 return 0; 607 }
569
570 return -EINVAL;
571} 608}
572 609
573static void venc_get_timings(struct omap_dss_device *dssdev, 610static void venc_get_timings(struct omap_dss_device *dssdev,