Lines Matching +full:lvds +full:- +full:encoder

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2009 Intel Corporation
14 #include <asm/intel-mid.h>
26 /* The max/min PWM frequency in BPCR[31:17] - */
28 * 15-bit field of the and then*/
29 /* shifts to the left by one bit to get the actual 16-bit
30 * value that the 15-bits correspond to.*/
53 dev_priv->is_lvds_on = true; in oaktrail_lvds_set_power()
54 if (dev_priv->ops->lvds_bl_power) in oaktrail_lvds_set_power()
55 dev_priv->ops->lvds_bl_power(dev, true); in oaktrail_lvds_set_power()
57 if (dev_priv->ops->lvds_bl_power) in oaktrail_lvds_set_power()
58 dev_priv->ops->lvds_bl_power(dev, false); in oaktrail_lvds_set_power()
64 dev_priv->is_lvds_on = false; in oaktrail_lvds_set_power()
69 static void oaktrail_lvds_dpms(struct drm_encoder *encoder, int mode) in oaktrail_lvds_dpms() argument
71 struct drm_device *dev = encoder->dev; in oaktrail_lvds_dpms()
72 struct gma_encoder *gma_encoder = to_gma_encoder(encoder); in oaktrail_lvds_dpms()
79 /* XXX: We never power down the LVDS pairs. */ in oaktrail_lvds_dpms()
82 static void oaktrail_lvds_mode_set(struct drm_encoder *encoder, in oaktrail_lvds_mode_set() argument
86 struct drm_device *dev = encoder->dev; in oaktrail_lvds_mode_set()
88 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in oaktrail_lvds_mode_set()
91 struct drm_crtc *crtc = encoder->crtc; in oaktrail_lvds_mode_set()
99 * The LVDS pin pair will already have been turned on in the in oaktrail_lvds_mode_set()
103 lvds_port = (REG_READ(LVDS) & in oaktrail_lvds_mode_set()
110 if (mode_dev->panel_wants_dither || dev_priv->lvds_dither) in oaktrail_lvds_mode_set()
113 REG_WRITE(LVDS, lvds_port); in oaktrail_lvds_mode_set()
118 if (connector->encoder && connector->encoder->crtc == crtc) in oaktrail_lvds_mode_set()
129 drm_object_property_get_value( &connector->base, in oaktrail_lvds_mode_set()
130 dev->mode_config.scaling_mode_property, &v); in oaktrail_lvds_mode_set()
136 if ((mode->vdisplay != adjusted_mode->crtc_vdisplay) || in oaktrail_lvds_mode_set()
137 (mode->hdisplay != adjusted_mode->crtc_hdisplay)) { in oaktrail_lvds_mode_set()
138 if ((adjusted_mode->crtc_hdisplay * mode->vdisplay) == in oaktrail_lvds_mode_set()
139 (mode->hdisplay * adjusted_mode->crtc_vdisplay)) in oaktrail_lvds_mode_set()
141 else if ((adjusted_mode->crtc_hdisplay * in oaktrail_lvds_mode_set()
142 mode->vdisplay) > (mode->hdisplay * in oaktrail_lvds_mode_set()
143 adjusted_mode->crtc_vdisplay)) in oaktrail_lvds_mode_set()
157 static void oaktrail_lvds_prepare(struct drm_encoder *encoder) in oaktrail_lvds_prepare() argument
159 struct drm_device *dev = encoder->dev; in oaktrail_lvds_prepare()
161 struct gma_encoder *gma_encoder = to_gma_encoder(encoder); in oaktrail_lvds_prepare()
162 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in oaktrail_lvds_prepare()
167 mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL); in oaktrail_lvds_prepare()
168 mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL & in oaktrail_lvds_prepare()
186 ret = ((dev_priv->regs.saveBLC_PWM_CTL & in oaktrail_lvds_get_max_backlight()
193 static void oaktrail_lvds_commit(struct drm_encoder *encoder) in oaktrail_lvds_commit() argument
195 struct drm_device *dev = encoder->dev; in oaktrail_lvds_commit()
197 struct gma_encoder *gma_encoder = to_gma_encoder(encoder); in oaktrail_lvds_commit()
198 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in oaktrail_lvds_commit()
200 if (mode_dev->backlight_duty_cycle == 0) in oaktrail_lvds_commit()
201 mode_dev->backlight_duty_cycle = in oaktrail_lvds_commit()
221 struct oaktrail_timing_info *ti = &dev_priv->gct_data.DTD; in oaktrail_lvds_get_configuration_mode()
223 mode_dev->panel_fixed_mode = NULL; in oaktrail_lvds_get_configuration_mode()
226 if (dev_priv->has_gct) { in oaktrail_lvds_get_configuration_mode()
231 mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo; in oaktrail_lvds_get_configuration_mode()
232 mode->vdisplay = (ti->vactive_hi << 8) | ti->vactive_lo; in oaktrail_lvds_get_configuration_mode()
233 mode->hsync_start = mode->hdisplay + \ in oaktrail_lvds_get_configuration_mode()
234 ((ti->hsync_offset_hi << 8) | \ in oaktrail_lvds_get_configuration_mode()
235 ti->hsync_offset_lo); in oaktrail_lvds_get_configuration_mode()
236 mode->hsync_end = mode->hsync_start + \ in oaktrail_lvds_get_configuration_mode()
237 ((ti->hsync_pulse_width_hi << 8) | \ in oaktrail_lvds_get_configuration_mode()
238 ti->hsync_pulse_width_lo); in oaktrail_lvds_get_configuration_mode()
239 mode->htotal = mode->hdisplay + ((ti->hblank_hi << 8) | \ in oaktrail_lvds_get_configuration_mode()
240 ti->hblank_lo); in oaktrail_lvds_get_configuration_mode()
241 mode->vsync_start = \ in oaktrail_lvds_get_configuration_mode()
242 mode->vdisplay + ((ti->vsync_offset_hi << 4) | \ in oaktrail_lvds_get_configuration_mode()
243 ti->vsync_offset_lo); in oaktrail_lvds_get_configuration_mode()
244 mode->vsync_end = \ in oaktrail_lvds_get_configuration_mode()
245 mode->vsync_start + ((ti->vsync_pulse_width_hi << 4) | \ in oaktrail_lvds_get_configuration_mode()
246 ti->vsync_pulse_width_lo); in oaktrail_lvds_get_configuration_mode()
247 mode->vtotal = mode->vdisplay + \ in oaktrail_lvds_get_configuration_mode()
248 ((ti->vblank_hi << 8) | ti->vblank_lo); in oaktrail_lvds_get_configuration_mode()
249 mode->clock = ti->pixel_clock * 10; in oaktrail_lvds_get_configuration_mode()
251 pr_info("hdisplay is %d\n", mode->hdisplay); in oaktrail_lvds_get_configuration_mode()
252 pr_info("vdisplay is %d\n", mode->vdisplay); in oaktrail_lvds_get_configuration_mode()
253 pr_info("HSS is %d\n", mode->hsync_start); in oaktrail_lvds_get_configuration_mode()
254 pr_info("HSE is %d\n", mode->hsync_end); in oaktrail_lvds_get_configuration_mode()
255 pr_info("htotal is %d\n", mode->htotal); in oaktrail_lvds_get_configuration_mode()
256 pr_info("VSS is %d\n", mode->vsync_start); in oaktrail_lvds_get_configuration_mode()
257 pr_info("VSE is %d\n", mode->vsync_end); in oaktrail_lvds_get_configuration_mode()
258 pr_info("vtotal is %d\n", mode->vtotal); in oaktrail_lvds_get_configuration_mode()
259 pr_info("clock is %d\n", mode->clock); in oaktrail_lvds_get_configuration_mode()
261 mode_dev->panel_fixed_mode = mode; in oaktrail_lvds_get_configuration_mode()
265 if (mode_dev->panel_fixed_mode == NULL && mode_dev->vbt_mode) in oaktrail_lvds_get_configuration_mode()
266 mode_dev->panel_fixed_mode = drm_mode_duplicate(dev, in oaktrail_lvds_get_configuration_mode()
267 mode_dev->vbt_mode); in oaktrail_lvds_get_configuration_mode()
269 /* Then try the LVDS VBT mode */ in oaktrail_lvds_get_configuration_mode()
270 if (mode_dev->panel_fixed_mode == NULL) in oaktrail_lvds_get_configuration_mode()
271 if (dev_priv->lfp_lvds_vbt_mode) in oaktrail_lvds_get_configuration_mode()
272 mode_dev->panel_fixed_mode = in oaktrail_lvds_get_configuration_mode()
274 dev_priv->lfp_lvds_vbt_mode); in oaktrail_lvds_get_configuration_mode()
277 if (mode_dev->panel_fixed_mode == NULL) in oaktrail_lvds_get_configuration_mode()
280 drm_mode_set_name(mode_dev->panel_fixed_mode); in oaktrail_lvds_get_configuration_mode()
281 drm_mode_set_crtcinfo(mode_dev->panel_fixed_mode, 0); in oaktrail_lvds_get_configuration_mode()
285 * oaktrail_lvds_init - setup LVDS connectors on this device
289 * Create the connector, register the LVDS DDC bus, and try to figure out what
290 * modes we can display on the LVDS panel (if present).
299 struct drm_encoder *encoder; in oaktrail_lvds_init() local
314 connector = &gma_connector->base; in oaktrail_lvds_init()
315 encoder = &gma_encoder->base; in oaktrail_lvds_init()
316 dev_priv->is_lvds_on = true; in oaktrail_lvds_init()
323 ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS); in oaktrail_lvds_init()
328 gma_encoder->type = INTEL_OUTPUT_LVDS; in oaktrail_lvds_init()
330 drm_encoder_helper_add(encoder, &oaktrail_lvds_helper_funcs); in oaktrail_lvds_init()
333 connector->display_info.subpixel_order = SubPixelHorizontalRGB; in oaktrail_lvds_init()
334 connector->interlace_allowed = false; in oaktrail_lvds_init()
335 connector->doublescan_allowed = false; in oaktrail_lvds_init()
337 drm_object_attach_property(&connector->base, in oaktrail_lvds_init()
338 dev->mode_config.scaling_mode_property, in oaktrail_lvds_init()
340 drm_object_attach_property(&connector->base, in oaktrail_lvds_init()
341 dev_priv->backlight_property, in oaktrail_lvds_init()
344 mode_dev->panel_wants_dither = false; in oaktrail_lvds_init()
345 if (dev_priv->has_gct) in oaktrail_lvds_init()
346 mode_dev->panel_wants_dither = (dev_priv->gct_data. in oaktrail_lvds_init()
348 if (dev_priv->lvds_dither) in oaktrail_lvds_init()
349 mode_dev->panel_wants_dither = 1; in oaktrail_lvds_init()
352 * LVDS discovery: in oaktrail_lvds_init()
355 * 3) check to see if LVDS is already on in oaktrail_lvds_init()
362 mutex_lock(&dev->mode_config.mutex); in oaktrail_lvds_init()
364 i2c_adap = i2c_get_adapter(dev_priv->ops->i2c_bus); in oaktrail_lvds_init()
368 if (edid == NULL && dev_priv->lpc_gpio_base) { in oaktrail_lvds_init()
371 i2c_adap = &ddc_bus->base; in oaktrail_lvds_init()
379 * but must instead set connector->ddc manually here. in oaktrail_lvds_init()
381 connector->ddc = i2c_adap; in oaktrail_lvds_init()
392 list_for_each_entry(scan, &connector->probed_modes, head) { in oaktrail_lvds_init()
393 if (scan->type & DRM_MODE_TYPE_PREFERRED) { in oaktrail_lvds_init()
394 mode_dev->panel_fixed_mode = in oaktrail_lvds_init()
400 dev_err(dev->dev, "No ddc adapter available!\n"); in oaktrail_lvds_init()
407 if (mode_dev->panel_fixed_mode) { in oaktrail_lvds_init()
408 mode_dev->panel_fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; in oaktrail_lvds_init()
413 if (!mode_dev->panel_fixed_mode) { in oaktrail_lvds_init()
414 dev_err(dev->dev, "Found no modes on the lvds, ignoring the LVDS\n"); in oaktrail_lvds_init()
419 mutex_unlock(&dev->mode_config.mutex); in oaktrail_lvds_init()
424 mutex_unlock(&dev->mode_config.mutex); in oaktrail_lvds_init()
425 gma_i2c_destroy(to_gma_i2c_chan(connector->ddc)); in oaktrail_lvds_init()
426 drm_encoder_cleanup(encoder); in oaktrail_lvds_init()