Lines Matching refs:venc
344 static inline void venc_write_reg(struct venc_device *venc, int idx, u32 val) in venc_write_reg() argument
346 __raw_writel(val, venc->base + idx); in venc_write_reg()
349 static inline u32 venc_read_reg(struct venc_device *venc, int idx) in venc_read_reg() argument
351 u32 l = __raw_readl(venc->base + idx); in venc_read_reg()
355 static void venc_write_config(struct venc_device *venc, in venc_write_config() argument
360 venc_write_reg(venc, VENC_LLEN, config->llen); in venc_write_config()
361 venc_write_reg(venc, VENC_FLENS, config->flens); in venc_write_config()
362 venc_write_reg(venc, VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr); in venc_write_config()
363 venc_write_reg(venc, VENC_C_PHASE, config->c_phase); in venc_write_config()
364 venc_write_reg(venc, VENC_GAIN_U, config->gain_u); in venc_write_config()
365 venc_write_reg(venc, VENC_GAIN_V, config->gain_v); in venc_write_config()
366 venc_write_reg(venc, VENC_GAIN_Y, config->gain_y); in venc_write_config()
367 venc_write_reg(venc, VENC_BLACK_LEVEL, config->black_level); in venc_write_config()
368 venc_write_reg(venc, VENC_BLANK_LEVEL, config->blank_level); in venc_write_config()
369 venc_write_reg(venc, VENC_M_CONTROL, config->m_control); in venc_write_config()
370 venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data | in venc_write_config()
371 venc->wss_data); in venc_write_config()
372 venc_write_reg(venc, VENC_S_CARR, config->s_carr); in venc_write_config()
373 venc_write_reg(venc, VENC_L21__WC_CTL, config->l21__wc_ctl); in venc_write_config()
374 venc_write_reg(venc, VENC_SAVID__EAVID, config->savid__eavid); in venc_write_config()
375 venc_write_reg(venc, VENC_FLEN__FAL, config->flen__fal); in venc_write_config()
376 venc_write_reg(venc, VENC_LAL__PHASE_RESET, config->lal__phase_reset); in venc_write_config()
377 venc_write_reg(venc, VENC_HS_INT_START_STOP_X, in venc_write_config()
379 venc_write_reg(venc, VENC_HS_EXT_START_STOP_X, in venc_write_config()
381 venc_write_reg(venc, VENC_VS_INT_START_X, config->vs_int_start_x); in venc_write_config()
382 venc_write_reg(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y, in venc_write_config()
384 venc_write_reg(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X, in venc_write_config()
386 venc_write_reg(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y, in venc_write_config()
388 venc_write_reg(venc, VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y); in venc_write_config()
389 venc_write_reg(venc, VENC_AVID_START_STOP_X, config->avid_start_stop_x); in venc_write_config()
390 venc_write_reg(venc, VENC_AVID_START_STOP_Y, config->avid_start_stop_y); in venc_write_config()
391 venc_write_reg(venc, VENC_FID_INT_START_X__FID_INT_START_Y, in venc_write_config()
393 venc_write_reg(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X, in venc_write_config()
395 venc_write_reg(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y, in venc_write_config()
398 venc_write_reg(venc, VENC_DAC_B__DAC_C, in venc_write_config()
399 venc_read_reg(venc, VENC_DAC_B__DAC_C)); in venc_write_config()
400 venc_write_reg(venc, VENC_VIDOUT_CTRL, config->vidout_ctrl); in venc_write_config()
401 venc_write_reg(venc, VENC_HFLTR_CTRL, config->hfltr_ctrl); in venc_write_config()
402 venc_write_reg(venc, VENC_X_COLOR, config->x_color); in venc_write_config()
403 venc_write_reg(venc, VENC_LINE21, config->line21); in venc_write_config()
404 venc_write_reg(venc, VENC_LN_SEL, config->ln_sel); in venc_write_config()
405 venc_write_reg(venc, VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger); in venc_write_config()
406 venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_X, in venc_write_config()
408 venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_Y, in venc_write_config()
410 venc_write_reg(venc, VENC_GEN_CTRL, config->gen_ctrl); in venc_write_config()
411 venc_write_reg(venc, VENC_F_CONTROL, config->f_control); in venc_write_config()
412 venc_write_reg(venc, VENC_SYNC_CTRL, config->sync_ctrl); in venc_write_config()
415 static void venc_reset(struct venc_device *venc) in venc_reset() argument
419 venc_write_reg(venc, VENC_F_CONTROL, 1<<8); in venc_reset()
420 while (venc_read_reg(venc, VENC_F_CONTROL) & (1<<8)) { in venc_reset()
434 static int venc_runtime_get(struct venc_device *venc) in venc_runtime_get() argument
440 r = pm_runtime_get_sync(&venc->pdev->dev); in venc_runtime_get()
445 static void venc_runtime_put(struct venc_device *venc) in venc_runtime_put() argument
451 r = pm_runtime_put_sync(&venc->pdev->dev); in venc_runtime_put()
467 static int venc_power_on(struct venc_device *venc) in venc_power_on() argument
472 r = venc_runtime_get(venc); in venc_power_on()
476 venc_reset(venc); in venc_power_on()
477 venc_write_config(venc, venc_timings_to_config(&venc->vm)); in venc_power_on()
479 dss_set_venc_output(venc->dss, venc->type); in venc_power_on()
480 dss_set_dac_pwrdn_bgz(venc->dss, 1); in venc_power_on()
484 if (venc->type == OMAP_DSS_VENC_TYPE_COMPOSITE) in venc_power_on()
489 if (venc->invert_polarity == false) in venc_power_on()
492 venc_write_reg(venc, VENC_OUTPUT_CONTROL, l); in venc_power_on()
494 dss_mgr_set_timings(&venc->output, &venc->vm); in venc_power_on()
496 r = regulator_enable(venc->vdda_dac_reg); in venc_power_on()
500 r = dss_mgr_enable(&venc->output); in venc_power_on()
507 regulator_disable(venc->vdda_dac_reg); in venc_power_on()
509 venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0); in venc_power_on()
510 dss_set_dac_pwrdn_bgz(venc->dss, 0); in venc_power_on()
512 venc_runtime_put(venc); in venc_power_on()
517 static void venc_power_off(struct venc_device *venc) in venc_power_off() argument
519 venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0); in venc_power_off()
520 dss_set_dac_pwrdn_bgz(venc->dss, 0); in venc_power_off()
522 dss_mgr_disable(&venc->output); in venc_power_off()
524 regulator_disable(venc->vdda_dac_reg); in venc_power_off()
526 venc_runtime_put(venc); in venc_power_off()
531 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_display_enable() local
536 mutex_lock(&venc->venc_lock); in venc_display_enable()
544 r = venc_power_on(venc); in venc_display_enable()
548 venc->wss_data = 0; in venc_display_enable()
550 mutex_unlock(&venc->venc_lock); in venc_display_enable()
554 mutex_unlock(&venc->venc_lock); in venc_display_enable()
560 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_display_disable() local
564 mutex_lock(&venc->venc_lock); in venc_display_disable()
566 venc_power_off(venc); in venc_display_disable()
568 mutex_unlock(&venc->venc_lock); in venc_display_disable()
574 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_set_timings() local
579 mutex_lock(&venc->venc_lock); in venc_set_timings()
593 if (memcmp(&venc->vm, &actual_vm, sizeof(actual_vm))) in venc_set_timings()
594 venc->wss_data = 0; in venc_set_timings()
596 venc->vm = actual_vm; in venc_set_timings()
598 dispc_set_tv_pclk(venc->dss->dispc, 13500000); in venc_set_timings()
600 mutex_unlock(&venc->venc_lock); in venc_set_timings()
620 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_get_timings() local
622 mutex_lock(&venc->venc_lock); in venc_get_timings()
624 *vm = venc->vm; in venc_get_timings()
626 mutex_unlock(&venc->venc_lock); in venc_get_timings()
631 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_get_wss() local
634 return (venc->wss_data >> 8) ^ 0xfffff; in venc_get_wss()
639 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_set_wss() local
645 mutex_lock(&venc->venc_lock); in venc_set_wss()
647 config = venc_timings_to_config(&venc->vm); in venc_set_wss()
650 venc->wss_data = (wss ^ 0xfffff) << 8; in venc_set_wss()
652 r = venc_runtime_get(venc); in venc_set_wss()
656 venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data | in venc_set_wss()
657 venc->wss_data); in venc_set_wss()
659 venc_runtime_put(venc); in venc_set_wss()
662 mutex_unlock(&venc->venc_lock); in venc_set_wss()
667 static int venc_init_regulator(struct venc_device *venc) in venc_init_regulator() argument
671 if (venc->vdda_dac_reg != NULL) in venc_init_regulator()
674 vdda_dac = devm_regulator_get(&venc->pdev->dev, "vdda"); in venc_init_regulator()
681 venc->vdda_dac_reg = vdda_dac; in venc_init_regulator()
688 struct venc_device *venc = s->private; in venc_dump_regs() local
690 #define DUMPREG(venc, r) \ in venc_dump_regs() argument
691 seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(venc, r)) in venc_dump_regs()
693 if (venc_runtime_get(venc)) in venc_dump_regs()
696 DUMPREG(venc, VENC_F_CONTROL); in venc_dump_regs()
697 DUMPREG(venc, VENC_VIDOUT_CTRL); in venc_dump_regs()
698 DUMPREG(venc, VENC_SYNC_CTRL); in venc_dump_regs()
699 DUMPREG(venc, VENC_LLEN); in venc_dump_regs()
700 DUMPREG(venc, VENC_FLENS); in venc_dump_regs()
701 DUMPREG(venc, VENC_HFLTR_CTRL); in venc_dump_regs()
702 DUMPREG(venc, VENC_CC_CARR_WSS_CARR); in venc_dump_regs()
703 DUMPREG(venc, VENC_C_PHASE); in venc_dump_regs()
704 DUMPREG(venc, VENC_GAIN_U); in venc_dump_regs()
705 DUMPREG(venc, VENC_GAIN_V); in venc_dump_regs()
706 DUMPREG(venc, VENC_GAIN_Y); in venc_dump_regs()
707 DUMPREG(venc, VENC_BLACK_LEVEL); in venc_dump_regs()
708 DUMPREG(venc, VENC_BLANK_LEVEL); in venc_dump_regs()
709 DUMPREG(venc, VENC_X_COLOR); in venc_dump_regs()
710 DUMPREG(venc, VENC_M_CONTROL); in venc_dump_regs()
711 DUMPREG(venc, VENC_BSTAMP_WSS_DATA); in venc_dump_regs()
712 DUMPREG(venc, VENC_S_CARR); in venc_dump_regs()
713 DUMPREG(venc, VENC_LINE21); in venc_dump_regs()
714 DUMPREG(venc, VENC_LN_SEL); in venc_dump_regs()
715 DUMPREG(venc, VENC_L21__WC_CTL); in venc_dump_regs()
716 DUMPREG(venc, VENC_HTRIGGER_VTRIGGER); in venc_dump_regs()
717 DUMPREG(venc, VENC_SAVID__EAVID); in venc_dump_regs()
718 DUMPREG(venc, VENC_FLEN__FAL); in venc_dump_regs()
719 DUMPREG(venc, VENC_LAL__PHASE_RESET); in venc_dump_regs()
720 DUMPREG(venc, VENC_HS_INT_START_STOP_X); in venc_dump_regs()
721 DUMPREG(venc, VENC_HS_EXT_START_STOP_X); in venc_dump_regs()
722 DUMPREG(venc, VENC_VS_INT_START_X); in venc_dump_regs()
723 DUMPREG(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y); in venc_dump_regs()
724 DUMPREG(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X); in venc_dump_regs()
725 DUMPREG(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y); in venc_dump_regs()
726 DUMPREG(venc, VENC_VS_EXT_STOP_Y); in venc_dump_regs()
727 DUMPREG(venc, VENC_AVID_START_STOP_X); in venc_dump_regs()
728 DUMPREG(venc, VENC_AVID_START_STOP_Y); in venc_dump_regs()
729 DUMPREG(venc, VENC_FID_INT_START_X__FID_INT_START_Y); in venc_dump_regs()
730 DUMPREG(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X); in venc_dump_regs()
731 DUMPREG(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y); in venc_dump_regs()
732 DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_X); in venc_dump_regs()
733 DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_Y); in venc_dump_regs()
734 DUMPREG(venc, VENC_GEN_CTRL); in venc_dump_regs()
735 DUMPREG(venc, VENC_OUTPUT_CONTROL); in venc_dump_regs()
736 DUMPREG(venc, VENC_OUTPUT_TEST); in venc_dump_regs()
738 venc_runtime_put(venc); in venc_dump_regs()
744 static int venc_get_clocks(struct venc_device *venc) in venc_get_clocks() argument
748 if (venc->requires_tv_dac_clk) { in venc_get_clocks()
749 clk = devm_clk_get(&venc->pdev->dev, "tv_dac_clk"); in venc_get_clocks()
758 venc->tv_dac_clk = clk; in venc_get_clocks()
766 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_connect() local
769 r = venc_init_regulator(venc); in venc_connect()
773 r = dss_mgr_connect(&venc->output, dssdev); in venc_connect()
781 dss_mgr_disconnect(&venc->output, dssdev); in venc_connect()
791 struct venc_device *venc = dssdev_to_venc(dssdev); in venc_disconnect() local
800 dss_mgr_disconnect(&venc->output, dssdev); in venc_disconnect()
818 static void venc_init_output(struct venc_device *venc) in venc_init_output() argument
820 struct omap_dss_device *out = &venc->output; in venc_init_output()
822 out->dev = &venc->pdev->dev; in venc_init_output()
833 static void venc_uninit_output(struct venc_device *venc) in venc_uninit_output() argument
835 omapdss_unregister_output(&venc->output); in venc_uninit_output()
838 static int venc_probe_of(struct venc_device *venc) in venc_probe_of() argument
840 struct device_node *node = venc->pdev->dev.of_node; in venc_probe_of()
849 venc->invert_polarity = of_property_read_bool(ep, "ti,invert-polarity"); in venc_probe_of()
853 dev_err(&venc->pdev->dev, in venc_probe_of()
860 venc->type = OMAP_DSS_VENC_TYPE_COMPOSITE; in venc_probe_of()
863 venc->type = OMAP_DSS_VENC_TYPE_SVIDEO; in venc_probe_of()
866 dev_err(&venc->pdev->dev, "bad channel propert '%d'\n", in venc_probe_of()
892 struct venc_device *venc; in venc_bind() local
897 venc = kzalloc(sizeof(*venc), GFP_KERNEL); in venc_bind()
898 if (!venc) in venc_bind()
901 venc->pdev = pdev; in venc_bind()
902 venc->dss = dss; in venc_bind()
903 dev_set_drvdata(dev, venc); in venc_bind()
907 venc->requires_tv_dac_clk = true; in venc_bind()
909 mutex_init(&venc->venc_lock); in venc_bind()
911 venc->wss_data = 0; in venc_bind()
913 venc_mem = platform_get_resource(venc->pdev, IORESOURCE_MEM, 0); in venc_bind()
914 venc->base = devm_ioremap_resource(&pdev->dev, venc_mem); in venc_bind()
915 if (IS_ERR(venc->base)) { in venc_bind()
916 r = PTR_ERR(venc->base); in venc_bind()
920 r = venc_get_clocks(venc); in venc_bind()
926 r = venc_runtime_get(venc); in venc_bind()
930 rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff); in venc_bind()
933 venc_runtime_put(venc); in venc_bind()
935 r = venc_probe_of(venc); in venc_bind()
941 venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs, in venc_bind()
942 venc); in venc_bind()
944 venc_init_output(venc); in venc_bind()
952 kfree(venc); in venc_bind()
958 struct venc_device *venc = dev_get_drvdata(dev); in venc_unbind() local
960 dss_debugfs_remove_file(venc->debugfs); in venc_unbind()
962 venc_uninit_output(venc); in venc_unbind()
966 kfree(venc); in venc_unbind()
987 struct venc_device *venc = dev_get_drvdata(dev); in venc_runtime_suspend() local
989 if (venc->tv_dac_clk) in venc_runtime_suspend()
990 clk_disable_unprepare(venc->tv_dac_clk); in venc_runtime_suspend()
992 dispc_runtime_put(venc->dss->dispc); in venc_runtime_suspend()
999 struct venc_device *venc = dev_get_drvdata(dev); in venc_runtime_resume() local
1002 r = dispc_runtime_get(venc->dss->dispc); in venc_runtime_resume()
1006 if (venc->tv_dac_clk) in venc_runtime_resume()
1007 clk_prepare_enable(venc->tv_dac_clk); in venc_runtime_resume()