Lines Matching +full:sun4i +full:- +full:a10 +full:- +full:display +full:- +full:engine
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
54 #define SUN4I_TVE_NOTCH_DAC0_TO_DAC_DLY(dac, x) ((4 - (x)) << (dac * 3))
301 mode->name, tv_mode->name); in sun4i_tv_find_tv_by_mode()
303 if (!strcmp(mode->name, tv_mode->name)) in sun4i_tv_find_tv_by_mode()
312 mode->name, tv_mode->name, in sun4i_tv_find_tv_by_mode()
313 mode->vdisplay, tv_mode->vdisplay); in sun4i_tv_find_tv_by_mode()
315 if (mode->vdisplay == tv_mode->vdisplay) in sun4i_tv_find_tv_by_mode()
325 DRM_DEBUG_DRIVER("Creating mode %s\n", mode->name); in sun4i_tv_mode_to_drm_mode()
327 mode->type = DRM_MODE_TYPE_DRIVER; in sun4i_tv_mode_to_drm_mode()
328 mode->clock = 13500; in sun4i_tv_mode_to_drm_mode()
329 mode->flags = DRM_MODE_FLAG_INTERLACE; in sun4i_tv_mode_to_drm_mode()
331 mode->hdisplay = tv_mode->hdisplay; in sun4i_tv_mode_to_drm_mode()
332 mode->hsync_start = mode->hdisplay + tv_mode->hfront_porch; in sun4i_tv_mode_to_drm_mode()
333 mode->hsync_end = mode->hsync_start + tv_mode->hsync_len; in sun4i_tv_mode_to_drm_mode()
334 mode->htotal = mode->hsync_end + tv_mode->hback_porch; in sun4i_tv_mode_to_drm_mode()
336 mode->vdisplay = tv_mode->vdisplay; in sun4i_tv_mode_to_drm_mode()
337 mode->vsync_start = mode->vdisplay + tv_mode->vfront_porch; in sun4i_tv_mode_to_drm_mode()
338 mode->vsync_end = mode->vsync_start + tv_mode->vsync_len; in sun4i_tv_mode_to_drm_mode()
339 mode->vtotal = mode->vsync_end + tv_mode->vback_porch; in sun4i_tv_mode_to_drm_mode()
345 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc); in sun4i_tv_disable()
349 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_disable()
353 sunxi_engine_disable_color_correction(crtc->engine); in sun4i_tv_disable()
359 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc); in sun4i_tv_enable()
363 sunxi_engine_apply_color_correction(crtc->engine); in sun4i_tv_enable()
365 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_enable()
378 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_mode_set()
386 regmap_write(tv->regs, SUN4I_TVE_CFG0_REG, in sun4i_tv_mode_set()
387 tv_mode->mode | in sun4i_tv_mode_set()
388 (tv_mode->yc_en ? SUN4I_TVE_CFG0_YC_EN : 0) | in sun4i_tv_mode_set()
395 regmap_write(tv->regs, SUN4I_TVE_DAC0_REG, in sun4i_tv_mode_set()
397 (tv_mode->dac3_en ? SUN4I_TVE_DAC0_DAC_EN(3) : 0) | in sun4i_tv_mode_set()
402 (tv_mode->dac_bit25_en ? BIT(25) : 0) | in sun4i_tv_mode_set()
406 regmap_write(tv->regs, SUN4I_TVE_NOTCH_REG, in sun4i_tv_mode_set()
410 regmap_write(tv->regs, SUN4I_TVE_CHROMA_FREQ_REG, in sun4i_tv_mode_set()
411 tv_mode->chroma_freq); in sun4i_tv_mode_set()
414 regmap_write(tv->regs, SUN4I_TVE_PORCH_REG, in sun4i_tv_mode_set()
415 SUN4I_TVE_PORCH_BACK(tv_mode->back_porch) | in sun4i_tv_mode_set()
416 SUN4I_TVE_PORCH_FRONT(tv_mode->front_porch)); in sun4i_tv_mode_set()
419 regmap_write(tv->regs, SUN4I_TVE_LINE_REG, in sun4i_tv_mode_set()
421 SUN4I_TVE_LINE_NUMBER(tv_mode->line_number)); in sun4i_tv_mode_set()
423 regmap_write(tv->regs, SUN4I_TVE_LEVEL_REG, in sun4i_tv_mode_set()
424 SUN4I_TVE_LEVEL_BLANK(tv_mode->video_levels->blank) | in sun4i_tv_mode_set()
425 SUN4I_TVE_LEVEL_BLACK(tv_mode->video_levels->black)); in sun4i_tv_mode_set()
427 regmap_write(tv->regs, SUN4I_TVE_DAC1_REG, in sun4i_tv_mode_set()
433 regmap_write(tv->regs, SUN4I_TVE_CB_CR_LVL_REG, in sun4i_tv_mode_set()
434 SUN4I_TVE_CB_CR_LVL_CB_BURST(tv_mode->burst_levels->cb) | in sun4i_tv_mode_set()
435 SUN4I_TVE_CB_CR_LVL_CR_BURST(tv_mode->burst_levels->cr)); in sun4i_tv_mode_set()
438 regmap_write(tv->regs, SUN4I_TVE_BURST_WIDTH_REG, in sun4i_tv_mode_set()
443 regmap_write(tv->regs, SUN4I_TVE_CB_CR_GAIN_REG, in sun4i_tv_mode_set()
444 SUN4I_TVE_CB_CR_GAIN_CB(tv_mode->color_gains->cb) | in sun4i_tv_mode_set()
445 SUN4I_TVE_CB_CR_GAIN_CR(tv_mode->color_gains->cr)); in sun4i_tv_mode_set()
447 regmap_write(tv->regs, SUN4I_TVE_SYNC_VBI_REG, in sun4i_tv_mode_set()
449 SUN4I_TVE_SYNC_VBI_VBLANK(tv_mode->vblank_level)); in sun4i_tv_mode_set()
451 regmap_write(tv->regs, SUN4I_TVE_ACTIVE_LINE_REG, in sun4i_tv_mode_set()
455 regmap_write(tv->regs, SUN4I_TVE_CHROMA_REG, in sun4i_tv_mode_set()
458 regmap_write(tv->regs, SUN4I_TVE_12C_REG, in sun4i_tv_mode_set()
462 regmap_write(tv->regs, SUN4I_TVE_RESYNC_REG, in sun4i_tv_mode_set()
463 SUN4I_TVE_RESYNC_PIXEL(tv_mode->resync_params->pixel) | in sun4i_tv_mode_set()
464 SUN4I_TVE_RESYNC_LINE(tv_mode->resync_params->line) | in sun4i_tv_mode_set()
465 (tv_mode->resync_params->field ? in sun4i_tv_mode_set()
468 regmap_write(tv->regs, SUN4I_TVE_SLAVE_REG, 0); in sun4i_tv_mode_set()
485 mode = drm_mode_create(connector->dev); in sun4i_tv_comp_get_modes()
487 DRM_ERROR("Failed to create a new display mode\n"); in sun4i_tv_comp_get_modes()
491 strcpy(mode->name, tv_mode->name); in sun4i_tv_comp_get_modes()
531 .name = "tv-encoder",
539 struct sun4i_drv *drv = drm->dev_private; in sun4i_tv_bind()
547 return -ENOMEM; in sun4i_tv_bind()
548 tv->drv = drv; in sun4i_tv_bind()
558 tv->regs = devm_regmap_init_mmio(dev, regs, in sun4i_tv_bind()
560 if (IS_ERR(tv->regs)) { in sun4i_tv_bind()
562 return PTR_ERR(tv->regs); in sun4i_tv_bind()
565 tv->reset = devm_reset_control_get(dev, NULL); in sun4i_tv_bind()
566 if (IS_ERR(tv->reset)) { in sun4i_tv_bind()
568 return PTR_ERR(tv->reset); in sun4i_tv_bind()
571 ret = reset_control_deassert(tv->reset); in sun4i_tv_bind()
577 tv->clk = devm_clk_get(dev, NULL); in sun4i_tv_bind()
578 if (IS_ERR(tv->clk)) { in sun4i_tv_bind()
580 ret = PTR_ERR(tv->clk); in sun4i_tv_bind()
583 clk_prepare_enable(tv->clk); in sun4i_tv_bind()
585 drm_encoder_helper_add(&tv->encoder, in sun4i_tv_bind()
587 ret = drm_simple_encoder_init(drm, &tv->encoder, in sun4i_tv_bind()
594 tv->encoder.possible_crtcs = drm_of_find_possible_crtcs(drm, in sun4i_tv_bind()
595 dev->of_node); in sun4i_tv_bind()
596 if (!tv->encoder.possible_crtcs) { in sun4i_tv_bind()
597 ret = -EPROBE_DEFER; in sun4i_tv_bind()
601 drm_connector_helper_add(&tv->connector, in sun4i_tv_bind()
603 ret = drm_connector_init(drm, &tv->connector, in sun4i_tv_bind()
611 tv->connector.interlace_allowed = true; in sun4i_tv_bind()
613 drm_connector_attach_encoder(&tv->connector, &tv->encoder); in sun4i_tv_bind()
618 drm_encoder_cleanup(&tv->encoder); in sun4i_tv_bind()
620 clk_disable_unprepare(tv->clk); in sun4i_tv_bind()
622 reset_control_assert(tv->reset); in sun4i_tv_bind()
631 drm_connector_cleanup(&tv->connector); in sun4i_tv_unbind()
632 drm_encoder_cleanup(&tv->encoder); in sun4i_tv_unbind()
633 clk_disable_unprepare(tv->clk); in sun4i_tv_unbind()
643 return component_add(&pdev->dev, &sun4i_tv_ops); in sun4i_tv_probe()
648 component_del(&pdev->dev, &sun4i_tv_ops); in sun4i_tv_remove()
654 { .compatible = "allwinner,sun4i-a10-tv-encoder" },
663 .name = "sun4i-tve",
669 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
670 MODULE_DESCRIPTION("Allwinner A10 TV Encoder Driver");