Lines Matching refs:venc

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