Lines Matching +full:lvds +full:- +full:encoder
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2011 Intel Corporation
27 * LVDS I2C backlight control macros
72 retval = ((dev_priv->regs.saveBLC_PWM_CTL & in cdv_intel_lvds_get_max_backlight()
97 blc_pwm_ctl = dev_priv->regs.saveBLC_PWM_CTL & in cdv_intel_lvds_set_backlight()
99 dev_priv->regs.saveBLC_PWM_CTL = (blc_pwm_ctl | in cdv_intel_lvds_set_backlight()
108 struct drm_encoder *encoder, bool on) in cdv_intel_lvds_set_power() argument
124 dev_priv->mode_dev.backlight_duty_cycle); in cdv_intel_lvds_set_power()
137 static void cdv_intel_lvds_encoder_dpms(struct drm_encoder *encoder, int mode) in cdv_intel_lvds_encoder_dpms() argument
139 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_encoder_dpms()
141 cdv_intel_lvds_set_power(dev, encoder, true); in cdv_intel_lvds_encoder_dpms()
143 cdv_intel_lvds_set_power(dev, encoder, false); in cdv_intel_lvds_encoder_dpms()
144 /* XXX: We never power down the LVDS pairs. */ in cdv_intel_lvds_encoder_dpms()
158 struct drm_device *dev = connector->dev; in cdv_intel_lvds_mode_valid()
161 dev_priv->mode_dev.panel_fixed_mode; in cdv_intel_lvds_mode_valid()
164 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) in cdv_intel_lvds_mode_valid()
168 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in cdv_intel_lvds_mode_valid()
172 if (mode->hdisplay > fixed_mode->hdisplay) in cdv_intel_lvds_mode_valid()
174 if (mode->vdisplay > fixed_mode->vdisplay) in cdv_intel_lvds_mode_valid()
180 static bool cdv_intel_lvds_mode_fixup(struct drm_encoder *encoder, in cdv_intel_lvds_mode_fixup() argument
184 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_mode_fixup()
186 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_mode_fixup()
188 struct drm_display_mode *panel_fixed_mode = mode_dev->panel_fixed_mode; in cdv_intel_lvds_mode_fixup()
191 list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, in cdv_intel_lvds_mode_fixup()
193 if (tmp_encoder != encoder in cdv_intel_lvds_mode_fixup()
194 && tmp_encoder->crtc == encoder->crtc) { in cdv_intel_lvds_mode_fixup()
195 pr_err("Can't enable LVDS and another encoder on the same pipe\n"); in cdv_intel_lvds_mode_fixup()
207 adjusted_mode->hdisplay = panel_fixed_mode->hdisplay; in cdv_intel_lvds_mode_fixup()
208 adjusted_mode->hsync_start = panel_fixed_mode->hsync_start; in cdv_intel_lvds_mode_fixup()
209 adjusted_mode->hsync_end = panel_fixed_mode->hsync_end; in cdv_intel_lvds_mode_fixup()
210 adjusted_mode->htotal = panel_fixed_mode->htotal; in cdv_intel_lvds_mode_fixup()
211 adjusted_mode->vdisplay = panel_fixed_mode->vdisplay; in cdv_intel_lvds_mode_fixup()
212 adjusted_mode->vsync_start = panel_fixed_mode->vsync_start; in cdv_intel_lvds_mode_fixup()
213 adjusted_mode->vsync_end = panel_fixed_mode->vsync_end; in cdv_intel_lvds_mode_fixup()
214 adjusted_mode->vtotal = panel_fixed_mode->vtotal; in cdv_intel_lvds_mode_fixup()
215 adjusted_mode->clock = panel_fixed_mode->clock; in cdv_intel_lvds_mode_fixup()
229 static void cdv_intel_lvds_prepare(struct drm_encoder *encoder) in cdv_intel_lvds_prepare() argument
231 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_prepare()
233 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_prepare()
238 mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL); in cdv_intel_lvds_prepare()
239 mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL & in cdv_intel_lvds_prepare()
242 cdv_intel_lvds_set_power(dev, encoder, false); in cdv_intel_lvds_prepare()
247 static void cdv_intel_lvds_commit(struct drm_encoder *encoder) in cdv_intel_lvds_commit() argument
249 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_commit()
251 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_commit()
253 if (mode_dev->backlight_duty_cycle == 0) in cdv_intel_lvds_commit()
254 mode_dev->backlight_duty_cycle = in cdv_intel_lvds_commit()
257 cdv_intel_lvds_set_power(dev, encoder, true); in cdv_intel_lvds_commit()
260 static void cdv_intel_lvds_mode_set(struct drm_encoder *encoder, in cdv_intel_lvds_mode_set() argument
264 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_mode_set()
266 struct gma_crtc *gma_crtc = to_gma_crtc(encoder->crtc); in cdv_intel_lvds_mode_set()
270 * The LVDS pin pair will already have been turned on in the in cdv_intel_lvds_mode_set()
276 * Enable automatic panel scaling so that non-native modes fill the in cdv_intel_lvds_mode_set()
280 if (mode->hdisplay != adjusted_mode->hdisplay || in cdv_intel_lvds_mode_set()
281 mode->vdisplay != adjusted_mode->vdisplay) in cdv_intel_lvds_mode_set()
288 pfit_control |= gma_crtc->pipe << PFIT_PIPE_SHIFT; in cdv_intel_lvds_mode_set()
290 if (dev_priv->lvds_dither) in cdv_intel_lvds_mode_set()
301 struct drm_device *dev = connector->dev; in cdv_intel_lvds_get_modes()
303 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_get_modes()
306 ret = psb_intel_ddc_get_modes(connector, connector->ddc); in cdv_intel_lvds_get_modes()
311 if (mode_dev->panel_fixed_mode != NULL) { in cdv_intel_lvds_get_modes()
313 drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); in cdv_intel_lvds_get_modes()
329 gma_i2c_destroy(to_gma_i2c_chan(connector->ddc)); in cdv_intel_lvds_destroy()
330 gma_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_destroy()
339 struct drm_encoder *encoder = connector->encoder; in cdv_intel_lvds_set_property() local
341 if (!strcmp(property->name, "scaling mode") && encoder) { in cdv_intel_lvds_set_property()
342 struct gma_crtc *crtc = to_gma_crtc(encoder->crtc); in cdv_intel_lvds_set_property()
346 return -1; in cdv_intel_lvds_set_property()
356 return -1; in cdv_intel_lvds_set_property()
359 if (drm_object_property_get_value(&connector->base, in cdv_intel_lvds_set_property()
362 return -1; in cdv_intel_lvds_set_property()
367 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
370 return -1; in cdv_intel_lvds_set_property()
372 if (crtc->saved_mode.hdisplay != 0 && in cdv_intel_lvds_set_property()
373 crtc->saved_mode.vdisplay != 0) { in cdv_intel_lvds_set_property()
374 if (!drm_crtc_helper_set_mode(encoder->crtc, in cdv_intel_lvds_set_property()
375 &crtc->saved_mode, in cdv_intel_lvds_set_property()
376 encoder->crtc->x, in cdv_intel_lvds_set_property()
377 encoder->crtc->y, in cdv_intel_lvds_set_property()
378 encoder->crtc->primary->fb)) in cdv_intel_lvds_set_property()
379 return -1; in cdv_intel_lvds_set_property()
381 } else if (!strcmp(property->name, "backlight") && encoder) { in cdv_intel_lvds_set_property()
382 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
385 return -1; in cdv_intel_lvds_set_property()
387 gma_backlight_set(encoder->dev, value); in cdv_intel_lvds_set_property()
388 } else if (!strcmp(property->name, "DPMS") && encoder) { in cdv_intel_lvds_set_property()
390 encoder->helper_private; in cdv_intel_lvds_set_property()
391 helpers->dpms(encoder, value); in cdv_intel_lvds_set_property()
421 * the LVDS is present.
424 * If no child dev is parsed from VBT, it assumes that the LVDS is present.
432 if (!dev_priv->child_dev_num) in lvds_is_present_in_vbt()
435 for (i = 0; i < dev_priv->child_dev_num; i++) { in lvds_is_present_in_vbt()
436 struct child_device_config *child = dev_priv->child_dev + i; in lvds_is_present_in_vbt()
442 if (child->device_type != DEVICE_TYPE_INT_LFP && in lvds_is_present_in_vbt()
443 child->device_type != DEVICE_TYPE_LFP) in lvds_is_present_in_vbt()
446 if (child->i2c_pin) in lvds_is_present_in_vbt()
447 *i2c_pin = child->i2c_pin; in lvds_is_present_in_vbt()
450 * the VBT correctly. Since LVDS requires additional in lvds_is_present_in_vbt()
451 * information from AIM blocks, a non-zero addin offset is in lvds_is_present_in_vbt()
452 * a good indicator that the LVDS is actually present. in lvds_is_present_in_vbt()
454 if (child->addin_offset) in lvds_is_present_in_vbt()
460 * the OpRegion then they have validated the LVDS's existence. in lvds_is_present_in_vbt()
462 if (dev_priv->opregion.vbt) in lvds_is_present_in_vbt()
470 * cdv_intel_lvds_init - setup LVDS connectors on this device
474 * Create the connector, register the LVDS DDC bus, and try to figure out what
475 * modes we can display on the LVDS panel (if present).
484 struct drm_encoder *encoder; in cdv_intel_lvds_init() local
489 u32 lvds; in cdv_intel_lvds_init() local
494 if (!dev_priv->lvds_enabled_in_vbt) in cdv_intel_lvds_init()
499 DRM_DEBUG_KMS("LVDS is not present in VBT\n"); in cdv_intel_lvds_init()
517 gma_encoder->dev_priv = lvds_priv; in cdv_intel_lvds_init()
519 connector = &gma_connector->base; in cdv_intel_lvds_init()
520 gma_connector->save = cdv_intel_lvds_save; in cdv_intel_lvds_init()
521 gma_connector->restore = cdv_intel_lvds_restore; in cdv_intel_lvds_init()
522 encoder = &gma_encoder->base; in cdv_intel_lvds_init()
527 dev_printk(KERN_ERR, dev->dev, in cdv_intel_lvds_init()
535 &ddc_bus->base); in cdv_intel_lvds_init()
539 ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS); in cdv_intel_lvds_init()
544 gma_encoder->type = INTEL_OUTPUT_LVDS; in cdv_intel_lvds_init()
546 drm_encoder_helper_add(encoder, &cdv_intel_lvds_helper_funcs); in cdv_intel_lvds_init()
549 connector->display_info.subpixel_order = SubPixelHorizontalRGB; in cdv_intel_lvds_init()
550 connector->interlace_allowed = false; in cdv_intel_lvds_init()
551 connector->doublescan_allowed = false; in cdv_intel_lvds_init()
554 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
555 dev->mode_config.scaling_mode_property, in cdv_intel_lvds_init()
557 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
558 dev_priv->backlight_property, in cdv_intel_lvds_init()
565 gma_encoder->i2c_bus = gma_i2c_create(dev, GPIOB, "LVDSBLC_B"); in cdv_intel_lvds_init()
566 if (!gma_encoder->i2c_bus) { in cdv_intel_lvds_init()
568 dev->dev, "I2C bus registration failed.\n"); in cdv_intel_lvds_init()
571 gma_encoder->i2c_bus->target_addr = 0x2C; in cdv_intel_lvds_init()
572 dev_priv->lvds_i2c_bus = gma_encoder->i2c_bus; in cdv_intel_lvds_init()
575 * LVDS discovery: in cdv_intel_lvds_init()
578 * 3) check to see if LVDS is already on in cdv_intel_lvds_init()
588 mutex_lock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
589 psb_intel_ddc_get_modes(connector, &ddc_bus->base); in cdv_intel_lvds_init()
591 list_for_each_entry(scan, &connector->probed_modes, head) { in cdv_intel_lvds_init()
592 if (scan->type & DRM_MODE_TYPE_PREFERRED) { in cdv_intel_lvds_init()
593 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
600 if (dev_priv->lfp_lvds_vbt_mode) { in cdv_intel_lvds_init()
601 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
602 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); in cdv_intel_lvds_init()
603 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
604 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
614 lvds = REG_READ(LVDS); in cdv_intel_lvds_init()
615 pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; in cdv_intel_lvds_init()
618 if (crtc && (lvds & LVDS_PORT_EN)) { in cdv_intel_lvds_init()
619 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
621 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
622 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
629 if (!mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
631 ("Found no modes on the lvds, ignoring the LVDS\n"); in cdv_intel_lvds_init()
649 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
653 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
654 gma_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_init()
656 drm_encoder_cleanup(encoder); in cdv_intel_lvds_init()