Lines Matching refs:venc

268 static inline void venc_write_reg(struct venc_device *venc, int idx, u32 val)  in venc_write_reg()  argument
270 __raw_writel(val, venc->base + idx); in venc_write_reg()
273 static inline u32 venc_read_reg(struct venc_device *venc, int idx) in venc_read_reg() argument
275 u32 l = __raw_readl(venc->base + idx); in venc_read_reg()
279 static void venc_write_config(struct venc_device *venc, in venc_write_config() argument
284 venc_write_reg(venc, VENC_LLEN, config->llen); in venc_write_config()
285 venc_write_reg(venc, VENC_FLENS, config->flens); in venc_write_config()
286 venc_write_reg(venc, VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr); in venc_write_config()
287 venc_write_reg(venc, VENC_C_PHASE, config->c_phase); in venc_write_config()
288 venc_write_reg(venc, VENC_GAIN_U, config->gain_u); in venc_write_config()
289 venc_write_reg(venc, VENC_GAIN_V, config->gain_v); in venc_write_config()
290 venc_write_reg(venc, VENC_GAIN_Y, config->gain_y); in venc_write_config()
291 venc_write_reg(venc, VENC_BLACK_LEVEL, config->black_level); in venc_write_config()
292 venc_write_reg(venc, VENC_BLANK_LEVEL, config->blank_level); in venc_write_config()
293 venc_write_reg(venc, VENC_M_CONTROL, config->m_control); in venc_write_config()
294 venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data); in venc_write_config()
295 venc_write_reg(venc, VENC_S_CARR, config->s_carr); in venc_write_config()
296 venc_write_reg(venc, VENC_L21__WC_CTL, config->l21__wc_ctl); in venc_write_config()
297 venc_write_reg(venc, VENC_SAVID__EAVID, config->savid__eavid); in venc_write_config()
298 venc_write_reg(venc, VENC_FLEN__FAL, config->flen__fal); in venc_write_config()
299 venc_write_reg(venc, VENC_LAL__PHASE_RESET, config->lal__phase_reset); in venc_write_config()
300 venc_write_reg(venc, VENC_HS_INT_START_STOP_X, in venc_write_config()
302 venc_write_reg(venc, VENC_HS_EXT_START_STOP_X, in venc_write_config()
304 venc_write_reg(venc, VENC_VS_INT_START_X, config->vs_int_start_x); in venc_write_config()
305 venc_write_reg(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y, in venc_write_config()
307 venc_write_reg(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X, in venc_write_config()
309 venc_write_reg(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y, in venc_write_config()
311 venc_write_reg(venc, VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y); in venc_write_config()
312 venc_write_reg(venc, VENC_AVID_START_STOP_X, config->avid_start_stop_x); in venc_write_config()
313 venc_write_reg(venc, VENC_AVID_START_STOP_Y, config->avid_start_stop_y); in venc_write_config()
314 venc_write_reg(venc, VENC_FID_INT_START_X__FID_INT_START_Y, in venc_write_config()
316 venc_write_reg(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X, in venc_write_config()
318 venc_write_reg(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y, in venc_write_config()
321 venc_write_reg(venc, VENC_DAC_B__DAC_C, in venc_write_config()
322 venc_read_reg(venc, VENC_DAC_B__DAC_C)); in venc_write_config()
323 venc_write_reg(venc, VENC_VIDOUT_CTRL, config->vidout_ctrl); in venc_write_config()
324 venc_write_reg(venc, VENC_HFLTR_CTRL, config->hfltr_ctrl); in venc_write_config()
325 venc_write_reg(venc, VENC_X_COLOR, config->x_color); in venc_write_config()
326 venc_write_reg(venc, VENC_LINE21, config->line21); in venc_write_config()
327 venc_write_reg(venc, VENC_LN_SEL, config->ln_sel); in venc_write_config()
328 venc_write_reg(venc, VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger); in venc_write_config()
329 venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_X, in venc_write_config()
331 venc_write_reg(venc, VENC_TVDETGP_INT_START_STOP_Y, in venc_write_config()
333 venc_write_reg(venc, VENC_GEN_CTRL, config->gen_ctrl); in venc_write_config()
334 venc_write_reg(venc, VENC_F_CONTROL, config->f_control); in venc_write_config()
335 venc_write_reg(venc, VENC_SYNC_CTRL, config->sync_ctrl); in venc_write_config()
338 static void venc_reset(struct venc_device *venc) in venc_reset() argument
342 venc_write_reg(venc, VENC_F_CONTROL, 1<<8); in venc_reset()
343 while (venc_read_reg(venc, VENC_F_CONTROL) & (1<<8)) { in venc_reset()
357 static int venc_runtime_get(struct venc_device *venc) in venc_runtime_get() argument
363 r = pm_runtime_get_sync(&venc->pdev->dev); in venc_runtime_get()
365 pm_runtime_put_noidle(&venc->pdev->dev); in venc_runtime_get()
371 static void venc_runtime_put(struct venc_device *venc) in venc_runtime_put() argument
377 r = pm_runtime_put_sync(&venc->pdev->dev); in venc_runtime_put()
381 static int venc_power_on(struct venc_device *venc) in venc_power_on() argument
386 r = venc_runtime_get(venc); in venc_power_on()
390 venc_reset(venc); in venc_power_on()
391 venc_write_config(venc, venc->config); in venc_power_on()
393 dss_set_venc_output(venc->dss, venc->type); in venc_power_on()
394 dss_set_dac_pwrdn_bgz(venc->dss, 1); in venc_power_on()
398 if (venc->type == OMAP_DSS_VENC_TYPE_COMPOSITE) in venc_power_on()
403 if (venc->invert_polarity == false) in venc_power_on()
406 venc_write_reg(venc, VENC_OUTPUT_CONTROL, l); in venc_power_on()
408 r = regulator_enable(venc->vdda_dac_reg); in venc_power_on()
412 r = dss_mgr_enable(&venc->output); in venc_power_on()
419 regulator_disable(venc->vdda_dac_reg); in venc_power_on()
421 venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0); in venc_power_on()
422 dss_set_dac_pwrdn_bgz(venc->dss, 0); in venc_power_on()
424 venc_runtime_put(venc); in venc_power_on()
429 static void venc_power_off(struct venc_device *venc) in venc_power_off() argument
431 venc_write_reg(venc, VENC_OUTPUT_CONTROL, 0); in venc_power_off()
432 dss_set_dac_pwrdn_bgz(venc->dss, 0); in venc_power_off()
434 dss_mgr_disable(&venc->output); in venc_power_off()
436 regulator_disable(venc->vdda_dac_reg); in venc_power_off()
438 venc_runtime_put(venc); in venc_power_off()
461 struct venc_device *venc = s->private; in venc_dump_regs() local
463 #define DUMPREG(venc, r) \ in venc_dump_regs() argument
464 seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(venc, r)) in venc_dump_regs()
466 if (venc_runtime_get(venc)) in venc_dump_regs()
469 DUMPREG(venc, VENC_F_CONTROL); in venc_dump_regs()
470 DUMPREG(venc, VENC_VIDOUT_CTRL); in venc_dump_regs()
471 DUMPREG(venc, VENC_SYNC_CTRL); in venc_dump_regs()
472 DUMPREG(venc, VENC_LLEN); in venc_dump_regs()
473 DUMPREG(venc, VENC_FLENS); in venc_dump_regs()
474 DUMPREG(venc, VENC_HFLTR_CTRL); in venc_dump_regs()
475 DUMPREG(venc, VENC_CC_CARR_WSS_CARR); in venc_dump_regs()
476 DUMPREG(venc, VENC_C_PHASE); in venc_dump_regs()
477 DUMPREG(venc, VENC_GAIN_U); in venc_dump_regs()
478 DUMPREG(venc, VENC_GAIN_V); in venc_dump_regs()
479 DUMPREG(venc, VENC_GAIN_Y); in venc_dump_regs()
480 DUMPREG(venc, VENC_BLACK_LEVEL); in venc_dump_regs()
481 DUMPREG(venc, VENC_BLANK_LEVEL); in venc_dump_regs()
482 DUMPREG(venc, VENC_X_COLOR); in venc_dump_regs()
483 DUMPREG(venc, VENC_M_CONTROL); in venc_dump_regs()
484 DUMPREG(venc, VENC_BSTAMP_WSS_DATA); in venc_dump_regs()
485 DUMPREG(venc, VENC_S_CARR); in venc_dump_regs()
486 DUMPREG(venc, VENC_LINE21); in venc_dump_regs()
487 DUMPREG(venc, VENC_LN_SEL); in venc_dump_regs()
488 DUMPREG(venc, VENC_L21__WC_CTL); in venc_dump_regs()
489 DUMPREG(venc, VENC_HTRIGGER_VTRIGGER); in venc_dump_regs()
490 DUMPREG(venc, VENC_SAVID__EAVID); in venc_dump_regs()
491 DUMPREG(venc, VENC_FLEN__FAL); in venc_dump_regs()
492 DUMPREG(venc, VENC_LAL__PHASE_RESET); in venc_dump_regs()
493 DUMPREG(venc, VENC_HS_INT_START_STOP_X); in venc_dump_regs()
494 DUMPREG(venc, VENC_HS_EXT_START_STOP_X); in venc_dump_regs()
495 DUMPREG(venc, VENC_VS_INT_START_X); in venc_dump_regs()
496 DUMPREG(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y); in venc_dump_regs()
497 DUMPREG(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X); in venc_dump_regs()
498 DUMPREG(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y); in venc_dump_regs()
499 DUMPREG(venc, VENC_VS_EXT_STOP_Y); in venc_dump_regs()
500 DUMPREG(venc, VENC_AVID_START_STOP_X); in venc_dump_regs()
501 DUMPREG(venc, VENC_AVID_START_STOP_Y); in venc_dump_regs()
502 DUMPREG(venc, VENC_FID_INT_START_X__FID_INT_START_Y); in venc_dump_regs()
503 DUMPREG(venc, VENC_FID_INT_OFFSET_Y__FID_EXT_START_X); in venc_dump_regs()
504 DUMPREG(venc, VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y); in venc_dump_regs()
505 DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_X); in venc_dump_regs()
506 DUMPREG(venc, VENC_TVDETGP_INT_START_STOP_Y); in venc_dump_regs()
507 DUMPREG(venc, VENC_GEN_CTRL); in venc_dump_regs()
508 DUMPREG(venc, VENC_OUTPUT_CONTROL); in venc_dump_regs()
509 DUMPREG(venc, VENC_OUTPUT_TEST); in venc_dump_regs()
511 venc_runtime_put(venc); in venc_dump_regs()
517 static int venc_get_clocks(struct venc_device *venc) in venc_get_clocks() argument
521 if (venc->requires_tv_dac_clk) { in venc_get_clocks()
522 clk = devm_clk_get(&venc->pdev->dev, "tv_dac_clk"); in venc_get_clocks()
531 venc->tv_dac_clk = clk; in venc_get_clocks()
543 struct venc_device *venc = drm_bridge_to_venc(bridge); in venc_bridge_attach() local
548 return drm_bridge_attach(bridge->encoder, venc->output.next_bridge, in venc_bridge_attach()
597 struct venc_device *venc = drm_bridge_to_venc(bridge); in venc_bridge_mode_set() local
605 venc->config = &venc_config_pal_trm; in venc_bridge_mode_set()
609 venc->config = &venc_config_ntsc_trm; in venc_bridge_mode_set()
613 dispc_set_tv_pclk(venc->dss->dispc, 13500000); in venc_bridge_mode_set()
618 struct venc_device *venc = drm_bridge_to_venc(bridge); in venc_bridge_enable() local
620 venc_power_on(venc); in venc_bridge_enable()
625 struct venc_device *venc = drm_bridge_to_venc(bridge); in venc_bridge_disable() local
627 venc_power_off(venc); in venc_bridge_disable()
664 static void venc_bridge_init(struct venc_device *venc) in venc_bridge_init() argument
666 venc->bridge.funcs = &venc_bridge_funcs; in venc_bridge_init()
667 venc->bridge.of_node = venc->pdev->dev.of_node; in venc_bridge_init()
668 venc->bridge.ops = DRM_BRIDGE_OP_MODES; in venc_bridge_init()
669 venc->bridge.type = DRM_MODE_CONNECTOR_SVIDEO; in venc_bridge_init()
670 venc->bridge.interlace_allowed = true; in venc_bridge_init()
672 drm_bridge_add(&venc->bridge); in venc_bridge_init()
675 static void venc_bridge_cleanup(struct venc_device *venc) in venc_bridge_cleanup() argument
677 drm_bridge_remove(&venc->bridge); in venc_bridge_cleanup()
687 struct venc_device *venc = dev_get_drvdata(dev); in venc_bind() local
691 venc->dss = dss; in venc_bind()
693 r = venc_runtime_get(venc); in venc_bind()
697 rev_id = (u8)(venc_read_reg(venc, VENC_REV_ID) & 0xff); in venc_bind()
700 venc_runtime_put(venc); in venc_bind()
702 venc->debugfs = dss_debugfs_create_file(dss, "venc", venc_dump_regs, in venc_bind()
703 venc); in venc_bind()
710 struct venc_device *venc = dev_get_drvdata(dev); in venc_unbind() local
712 dss_debugfs_remove_file(venc->debugfs); in venc_unbind()
724 static int venc_init_output(struct venc_device *venc) in venc_init_output() argument
726 struct omap_dss_device *out = &venc->output; in venc_init_output()
729 venc_bridge_init(venc); in venc_init_output()
731 out->dev = &venc->pdev->dev; in venc_init_output()
738 r = omapdss_device_init_output(out, &venc->bridge); in venc_init_output()
740 venc_bridge_cleanup(venc); in venc_init_output()
749 static void venc_uninit_output(struct venc_device *venc) in venc_uninit_output() argument
751 omapdss_device_unregister(&venc->output); in venc_uninit_output()
752 omapdss_device_cleanup_output(&venc->output); in venc_uninit_output()
754 venc_bridge_cleanup(venc); in venc_uninit_output()
757 static int venc_probe_of(struct venc_device *venc) in venc_probe_of() argument
759 struct device_node *node = venc->pdev->dev.of_node; in venc_probe_of()
768 venc->invert_polarity = of_property_read_bool(ep, "ti,invert-polarity"); in venc_probe_of()
772 dev_err(&venc->pdev->dev, in venc_probe_of()
779 venc->type = OMAP_DSS_VENC_TYPE_COMPOSITE; in venc_probe_of()
782 venc->type = OMAP_DSS_VENC_TYPE_SVIDEO; in venc_probe_of()
785 dev_err(&venc->pdev->dev, "bad channel property '%d'\n", in venc_probe_of()
808 struct venc_device *venc; in venc_probe() local
812 venc = kzalloc(sizeof(*venc), GFP_KERNEL); in venc_probe()
813 if (!venc) in venc_probe()
816 venc->pdev = pdev; in venc_probe()
818 platform_set_drvdata(pdev, venc); in venc_probe()
822 venc->requires_tv_dac_clk = true; in venc_probe()
824 venc->config = &venc_config_pal_trm; in venc_probe()
826 venc_mem = platform_get_resource(venc->pdev, IORESOURCE_MEM, 0); in venc_probe()
827 venc->base = devm_ioremap_resource(&pdev->dev, venc_mem); in venc_probe()
828 if (IS_ERR(venc->base)) { in venc_probe()
829 r = PTR_ERR(venc->base); in venc_probe()
833 venc->vdda_dac_reg = devm_regulator_get(&pdev->dev, "vdda"); in venc_probe()
834 if (IS_ERR(venc->vdda_dac_reg)) { in venc_probe()
835 r = PTR_ERR(venc->vdda_dac_reg); in venc_probe()
841 r = venc_get_clocks(venc); in venc_probe()
845 r = venc_probe_of(venc); in venc_probe()
851 r = venc_init_output(venc); in venc_probe()
862 venc_uninit_output(venc); in venc_probe()
866 kfree(venc); in venc_probe()
872 struct venc_device *venc = platform_get_drvdata(pdev); in venc_remove() local
876 venc_uninit_output(venc); in venc_remove()
880 kfree(venc); in venc_remove()
886 struct venc_device *venc = dev_get_drvdata(dev); in venc_runtime_suspend() local
888 if (venc->tv_dac_clk) in venc_runtime_suspend()
889 clk_disable_unprepare(venc->tv_dac_clk); in venc_runtime_suspend()
896 struct venc_device *venc = dev_get_drvdata(dev); in venc_runtime_resume() local
898 if (venc->tv_dac_clk) in venc_runtime_resume()
899 clk_prepare_enable(venc->tv_dac_clk); in venc_runtime_resume()