Lines Matching +full:pixel +full:- +full:engine

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
55 #define SUN4I_TVE_NOTCH_DAC0_TO_DAC_DLY(dac, x) ((4 - (x)) << (dac * 3))
138 u16 pixel; member
198 .field = false, .line = 14, .pixel = 12,
202 .field = true, .line = 13, .pixel = 12,
256 if (tv_mode->tv_mode == mode) in sun4i_tv_find_tv_by_mode()
267 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc); in sun4i_tv_disable()
271 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_disable()
275 sunxi_engine_disable_color_correction(crtc->engine); in sun4i_tv_disable()
282 struct sun4i_crtc *crtc = drm_crtc_to_sun4i_crtc(encoder->crtc); in sun4i_tv_enable()
284 drm_atomic_get_new_crtc_state(state, encoder->crtc); in sun4i_tv_enable()
285 struct drm_display_mode *mode = &crtc_state->mode; in sun4i_tv_enable()
286 struct drm_connector *connector = &tv->connector; in sun4i_tv_enable()
290 sun4i_tv_find_tv_by_mode(conn_state->tv.mode); in sun4i_tv_enable()
295 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_enable()
303 regmap_write(tv->regs, SUN4I_TVE_CFG0_REG, in sun4i_tv_enable()
304 tv_mode->mode | in sun4i_tv_enable()
305 (tv_mode->yc_en ? SUN4I_TVE_CFG0_YC_EN : 0) | in sun4i_tv_enable()
312 regmap_write(tv->regs, SUN4I_TVE_DAC0_REG, in sun4i_tv_enable()
314 (tv_mode->dac3_en ? SUN4I_TVE_DAC0_DAC_EN(3) : 0) | in sun4i_tv_enable()
319 (tv_mode->dac_bit25_en ? BIT(25) : 0) | in sun4i_tv_enable()
323 regmap_write(tv->regs, SUN4I_TVE_NOTCH_REG, in sun4i_tv_enable()
327 regmap_write(tv->regs, SUN4I_TVE_CHROMA_FREQ_REG, in sun4i_tv_enable()
328 tv_mode->chroma_freq); in sun4i_tv_enable()
331 regmap_write(tv->regs, SUN4I_TVE_PORCH_REG, in sun4i_tv_enable()
332 SUN4I_TVE_PORCH_BACK(tv_mode->back_porch) | in sun4i_tv_enable()
333 SUN4I_TVE_PORCH_FRONT(tv_mode->front_porch)); in sun4i_tv_enable()
336 regmap_write(tv->regs, SUN4I_TVE_LINE_REG, in sun4i_tv_enable()
338 SUN4I_TVE_LINE_NUMBER(mode->vtotal)); in sun4i_tv_enable()
340 regmap_write(tv->regs, SUN4I_TVE_LEVEL_REG, in sun4i_tv_enable()
341 SUN4I_TVE_LEVEL_BLANK(tv_mode->video_levels->blank) | in sun4i_tv_enable()
342 SUN4I_TVE_LEVEL_BLACK(tv_mode->video_levels->black)); in sun4i_tv_enable()
344 regmap_write(tv->regs, SUN4I_TVE_DAC1_REG, in sun4i_tv_enable()
350 regmap_write(tv->regs, SUN4I_TVE_CB_CR_LVL_REG, in sun4i_tv_enable()
351 SUN4I_TVE_CB_CR_LVL_CB_BURST(tv_mode->burst_levels->cb) | in sun4i_tv_enable()
352 SUN4I_TVE_CB_CR_LVL_CR_BURST(tv_mode->burst_levels->cr)); in sun4i_tv_enable()
355 regmap_write(tv->regs, SUN4I_TVE_BURST_WIDTH_REG, in sun4i_tv_enable()
360 regmap_write(tv->regs, SUN4I_TVE_CB_CR_GAIN_REG, in sun4i_tv_enable()
361 SUN4I_TVE_CB_CR_GAIN_CB(tv_mode->color_gains->cb) | in sun4i_tv_enable()
362 SUN4I_TVE_CB_CR_GAIN_CR(tv_mode->color_gains->cr)); in sun4i_tv_enable()
364 regmap_write(tv->regs, SUN4I_TVE_SYNC_VBI_REG, in sun4i_tv_enable()
366 SUN4I_TVE_SYNC_VBI_VBLANK(tv_mode->vblank_level)); in sun4i_tv_enable()
368 regmap_write(tv->regs, SUN4I_TVE_ACTIVE_LINE_REG, in sun4i_tv_enable()
372 regmap_write(tv->regs, SUN4I_TVE_CHROMA_REG, in sun4i_tv_enable()
375 regmap_write(tv->regs, SUN4I_TVE_12C_REG, in sun4i_tv_enable()
379 regmap_write(tv->regs, SUN4I_TVE_RESYNC_REG, in sun4i_tv_enable()
380 SUN4I_TVE_RESYNC_PIXEL(tv_mode->resync_params->pixel) | in sun4i_tv_enable()
381 SUN4I_TVE_RESYNC_LINE(tv_mode->resync_params->line) | in sun4i_tv_enable()
382 (tv_mode->resync_params->field ? in sun4i_tv_enable()
385 regmap_write(tv->regs, SUN4I_TVE_SLAVE_REG, 0); in sun4i_tv_enable()
387 sunxi_engine_apply_color_correction(crtc->engine); in sun4i_tv_enable()
389 regmap_update_bits(tv->regs, SUN4I_TVE_EN_REG, in sun4i_tv_enable()
423 .name = "tv-encoder",
431 struct sun4i_drv *drv = drm->dev_private; in sun4i_tv_bind()
438 return -ENOMEM; in sun4i_tv_bind()
439 tv->drv = drv; in sun4i_tv_bind()
448 tv->regs = devm_regmap_init_mmio(dev, regs, in sun4i_tv_bind()
450 if (IS_ERR(tv->regs)) { in sun4i_tv_bind()
452 return PTR_ERR(tv->regs); in sun4i_tv_bind()
455 tv->reset = devm_reset_control_get(dev, NULL); in sun4i_tv_bind()
456 if (IS_ERR(tv->reset)) { in sun4i_tv_bind()
458 return PTR_ERR(tv->reset); in sun4i_tv_bind()
461 ret = reset_control_deassert(tv->reset); in sun4i_tv_bind()
467 tv->clk = devm_clk_get(dev, NULL); in sun4i_tv_bind()
468 if (IS_ERR(tv->clk)) { in sun4i_tv_bind()
470 ret = PTR_ERR(tv->clk); in sun4i_tv_bind()
473 clk_prepare_enable(tv->clk); in sun4i_tv_bind()
475 drm_encoder_helper_add(&tv->encoder, in sun4i_tv_bind()
477 ret = drm_simple_encoder_init(drm, &tv->encoder, in sun4i_tv_bind()
484 tv->encoder.possible_crtcs = drm_of_find_possible_crtcs(drm, in sun4i_tv_bind()
485 dev->of_node); in sun4i_tv_bind()
486 if (!tv->encoder.possible_crtcs) { in sun4i_tv_bind()
487 ret = -EPROBE_DEFER; in sun4i_tv_bind()
491 drm_connector_helper_add(&tv->connector, in sun4i_tv_bind()
493 ret = drm_connector_init(drm, &tv->connector, in sun4i_tv_bind()
501 tv->connector.interlace_allowed = true; in sun4i_tv_bind()
503 drm_connector_attach_encoder(&tv->connector, &tv->encoder); in sun4i_tv_bind()
511 drm_object_attach_property(&tv->connector.base, in sun4i_tv_bind()
512 drm->mode_config.tv_mode_property, in sun4i_tv_bind()
518 drm_connector_cleanup(&tv->connector); in sun4i_tv_bind()
520 drm_encoder_cleanup(&tv->encoder); in sun4i_tv_bind()
522 clk_disable_unprepare(tv->clk); in sun4i_tv_bind()
524 reset_control_assert(tv->reset); in sun4i_tv_bind()
533 drm_connector_cleanup(&tv->connector); in sun4i_tv_unbind()
534 drm_encoder_cleanup(&tv->encoder); in sun4i_tv_unbind()
535 clk_disable_unprepare(tv->clk); in sun4i_tv_unbind()
536 reset_control_assert(tv->reset); in sun4i_tv_unbind()
546 return component_add(&pdev->dev, &sun4i_tv_ops); in sun4i_tv_probe()
551 component_del(&pdev->dev, &sun4i_tv_ops); in sun4i_tv_remove()
555 { .compatible = "allwinner,sun4i-a10-tv-encoder" },
564 .name = "sun4i-tve",
570 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");