Lines Matching +full:tcon +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
27 struct sun4i_tcon *tcon; member
51 return drm_panel_get_modes(rgb->panel, connector); in sun4i_rgb_get_modes()
57 * good default tolerance for the EDID-based modes. Define it to 5 per
66 struct sun4i_tcon *tcon = rgb->tcon; in sun4i_rgb_mode_valid() local
67 u32 hsync = mode->hsync_end - mode->hsync_start; in sun4i_rgb_mode_valid()
68 u32 vsync = mode->vsync_end - mode->vsync_start; in sun4i_rgb_mode_valid()
69 unsigned long long rate = mode->clock * 1000; in sun4i_rgb_mode_valid()
81 if ((mode->hdisplay < 1) || (mode->htotal < 1)) in sun4i_rgb_mode_valid()
84 if ((mode->hdisplay > 0x7ff) || (mode->htotal > 0xfff)) in sun4i_rgb_mode_valid()
95 if ((mode->vdisplay < 1) || (mode->vtotal < 1)) in sun4i_rgb_mode_valid()
98 if ((mode->vdisplay > 0x7ff) || (mode->vtotal > 0xfff)) in sun4i_rgb_mode_valid()
109 if (rgb->panel) { in sun4i_rgb_mode_valid()
118 if (!rgb->bridge) in sun4i_rgb_mode_valid()
121 tcon->dclk_min_div = 6; in sun4i_rgb_mode_valid()
122 tcon->dclk_max_div = 127; in sun4i_rgb_mode_valid()
123 rounded_rate = clk_round_rate(tcon->dclk, rate); in sun4i_rgb_mode_valid()
125 lowest = rate * (1000 - SUN4I_RGB_DOTCLOCK_TOLERANCE_PER_MILLE); in sun4i_rgb_mode_valid()
165 if (rgb->panel) { in sun4i_rgb_encoder_enable()
166 drm_panel_prepare(rgb->panel); in sun4i_rgb_encoder_enable()
167 drm_panel_enable(rgb->panel); in sun4i_rgb_encoder_enable()
177 if (rgb->panel) { in sun4i_rgb_encoder_disable()
178 drm_panel_disable(rgb->panel); in sun4i_rgb_encoder_disable()
179 drm_panel_unprepare(rgb->panel); in sun4i_rgb_encoder_disable()
189 int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon) in sun4i_rgb_init() argument
195 rgb = devm_kzalloc(drm->dev, sizeof(*rgb), GFP_KERNEL); in sun4i_rgb_init()
197 return -ENOMEM; in sun4i_rgb_init()
198 rgb->tcon = tcon; in sun4i_rgb_init()
199 encoder = &rgb->encoder; in sun4i_rgb_init()
201 ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0, in sun4i_rgb_init()
202 &rgb->panel, &rgb->bridge); in sun4i_rgb_init()
204 dev_info(drm->dev, "No panel or bridge found... RGB output disabled\n"); in sun4i_rgb_init()
208 drm_encoder_helper_add(&rgb->encoder, in sun4i_rgb_init()
210 ret = drm_simple_encoder_init(drm, &rgb->encoder, in sun4i_rgb_init()
213 dev_err(drm->dev, "Couldn't initialise the rgb encoder\n"); in sun4i_rgb_init()
217 /* The RGB encoder can only work with the TCON channel 0 */ in sun4i_rgb_init()
218 rgb->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc); in sun4i_rgb_init()
220 if (rgb->panel) { in sun4i_rgb_init()
221 drm_connector_helper_add(&rgb->connector, in sun4i_rgb_init()
223 ret = drm_connector_init(drm, &rgb->connector, in sun4i_rgb_init()
227 dev_err(drm->dev, "Couldn't initialise the rgb connector\n"); in sun4i_rgb_init()
231 drm_connector_attach_encoder(&rgb->connector, in sun4i_rgb_init()
232 &rgb->encoder); in sun4i_rgb_init()
235 if (rgb->bridge) { in sun4i_rgb_init()
236 ret = drm_bridge_attach(encoder, rgb->bridge, NULL, 0); in sun4i_rgb_init()
244 drm_encoder_cleanup(&rgb->encoder); in sun4i_rgb_init()