Lines Matching +full:panel +full:- +full:lvds
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2011 Intel Corporation
23 * LVDS I2C backlight control macros
58 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_get_max_backlight()
68 retval = ((dev_priv->regs.saveBLC_PWM_CTL & in cdv_intel_lvds_get_max_backlight()
77 * Set LVDS backlight level by I2C command
82 struct drm_psb_private *dev_priv = dev->dev_private;
83 struct psb_intel_i2c_chan *lvds_i2c_bus = dev_priv->lvds_i2c_bus;
89 .addr = lvds_i2c_bus->slave_addr,
100 if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
101 blc_i2c_brightness = BRIGHTNESS_MASK - blc_i2c_brightness;
103 out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
106 if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1)
110 return -1;
116 struct drm_psb_private *dev_priv = dev->dev_private;
128 if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
129 blc_pwm_duty_cycle = max_pwm_blc - blc_pwm_duty_cycle;
140 * Set LVDS backlight level either by I2C or PWM
144 struct drm_psb_private *dev_priv = dev->dev_private;
146 if (!dev_priv->lvds_bl) {
147 DRM_ERROR("NO LVDS Backlight Info\n");
151 if (dev_priv->lvds_bl->type == BLC_I2C_TYPE)
165 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_set_backlight()
176 blc_pwm_ctl = dev_priv->regs.saveBLC_PWM_CTL & in cdv_intel_lvds_set_backlight()
178 dev_priv->regs.saveBLC_PWM_CTL = (blc_pwm_ctl | in cdv_intel_lvds_set_backlight()
184 * Sets the power state for the panel.
189 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_set_power()
203 dev_priv->mode_dev.backlight_duty_cycle); in cdv_intel_lvds_set_power()
218 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_encoder_dpms()
223 /* XXX: We never power down the LVDS pairs. */ in cdv_intel_lvds_encoder_dpms()
237 struct drm_device *dev = connector->dev; in cdv_intel_lvds_mode_valid()
238 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_mode_valid()
240 dev_priv->mode_dev.panel_fixed_mode; in cdv_intel_lvds_mode_valid()
243 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) in cdv_intel_lvds_mode_valid()
247 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in cdv_intel_lvds_mode_valid()
251 if (mode->hdisplay > fixed_mode->hdisplay) in cdv_intel_lvds_mode_valid()
253 if (mode->vdisplay > fixed_mode->vdisplay) in cdv_intel_lvds_mode_valid()
263 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_mode_fixup()
264 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_mode_fixup()
265 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_mode_fixup()
267 struct drm_display_mode *panel_fixed_mode = mode_dev->panel_fixed_mode; in cdv_intel_lvds_mode_fixup()
270 list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, in cdv_intel_lvds_mode_fixup()
273 && tmp_encoder->crtc == encoder->crtc) { in cdv_intel_lvds_mode_fixup()
274 pr_err("Can't enable LVDS and another encoder on the same pipe\n"); in cdv_intel_lvds_mode_fixup()
280 * If we have timings from the BIOS for the panel, put them in in cdv_intel_lvds_mode_fixup()
282 * with the panel scaling set up to source from the H/VDisplay in cdv_intel_lvds_mode_fixup()
286 adjusted_mode->hdisplay = panel_fixed_mode->hdisplay; in cdv_intel_lvds_mode_fixup()
287 adjusted_mode->hsync_start = panel_fixed_mode->hsync_start; in cdv_intel_lvds_mode_fixup()
288 adjusted_mode->hsync_end = panel_fixed_mode->hsync_end; in cdv_intel_lvds_mode_fixup()
289 adjusted_mode->htotal = panel_fixed_mode->htotal; in cdv_intel_lvds_mode_fixup()
290 adjusted_mode->vdisplay = panel_fixed_mode->vdisplay; in cdv_intel_lvds_mode_fixup()
291 adjusted_mode->vsync_start = panel_fixed_mode->vsync_start; in cdv_intel_lvds_mode_fixup()
292 adjusted_mode->vsync_end = panel_fixed_mode->vsync_end; in cdv_intel_lvds_mode_fixup()
293 adjusted_mode->vtotal = panel_fixed_mode->vtotal; in cdv_intel_lvds_mode_fixup()
294 adjusted_mode->clock = panel_fixed_mode->clock; in cdv_intel_lvds_mode_fixup()
310 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_prepare()
311 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_prepare()
312 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_prepare()
317 mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL); in cdv_intel_lvds_prepare()
318 mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL & in cdv_intel_lvds_prepare()
328 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_commit()
329 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_commit()
330 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_commit()
332 if (mode_dev->backlight_duty_cycle == 0) in cdv_intel_lvds_commit()
333 mode_dev->backlight_duty_cycle = in cdv_intel_lvds_commit()
343 struct drm_device *dev = encoder->dev; in cdv_intel_lvds_mode_set()
344 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_mode_set()
345 struct gma_crtc *gma_crtc = to_gma_crtc(encoder->crtc); in cdv_intel_lvds_mode_set()
349 * The LVDS pin pair will already have been turned on in the in cdv_intel_lvds_mode_set()
355 * Enable automatic panel scaling so that non-native modes fill the in cdv_intel_lvds_mode_set()
359 if (mode->hdisplay != adjusted_mode->hdisplay || in cdv_intel_lvds_mode_set()
360 mode->vdisplay != adjusted_mode->vdisplay) in cdv_intel_lvds_mode_set()
367 pfit_control |= gma_crtc->pipe << PFIT_PIPE_SHIFT; in cdv_intel_lvds_mode_set()
369 if (dev_priv->lvds_dither) in cdv_intel_lvds_mode_set()
380 struct drm_device *dev = connector->dev; in cdv_intel_lvds_get_modes()
381 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_get_modes()
383 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; in cdv_intel_lvds_get_modes()
386 ret = psb_intel_ddc_get_modes(connector, &gma_encoder->i2c_bus->adapter); in cdv_intel_lvds_get_modes()
391 if (mode_dev->panel_fixed_mode != NULL) { in cdv_intel_lvds_get_modes()
393 drm_mode_duplicate(dev, mode_dev->panel_fixed_mode); in cdv_intel_lvds_get_modes()
402 * cdv_intel_lvds_destroy - unregister and free LVDS structures
412 psb_intel_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_destroy()
422 struct drm_encoder *encoder = connector->encoder; in cdv_intel_lvds_set_property()
424 if (!strcmp(property->name, "scaling mode") && encoder) { in cdv_intel_lvds_set_property()
425 struct gma_crtc *crtc = to_gma_crtc(encoder->crtc); in cdv_intel_lvds_set_property()
429 return -1; in cdv_intel_lvds_set_property()
439 return -1; in cdv_intel_lvds_set_property()
442 if (drm_object_property_get_value(&connector->base, in cdv_intel_lvds_set_property()
445 return -1; in cdv_intel_lvds_set_property()
450 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
453 return -1; in cdv_intel_lvds_set_property()
455 if (crtc->saved_mode.hdisplay != 0 && in cdv_intel_lvds_set_property()
456 crtc->saved_mode.vdisplay != 0) { in cdv_intel_lvds_set_property()
457 if (!drm_crtc_helper_set_mode(encoder->crtc, in cdv_intel_lvds_set_property()
458 &crtc->saved_mode, in cdv_intel_lvds_set_property()
459 encoder->crtc->x, in cdv_intel_lvds_set_property()
460 encoder->crtc->y, in cdv_intel_lvds_set_property()
461 encoder->crtc->primary->fb)) in cdv_intel_lvds_set_property()
462 return -1; in cdv_intel_lvds_set_property()
464 } else if (!strcmp(property->name, "backlight") && encoder) { in cdv_intel_lvds_set_property()
465 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
468 return -1; in cdv_intel_lvds_set_property()
470 gma_backlight_set(encoder->dev, value); in cdv_intel_lvds_set_property()
471 } else if (!strcmp(property->name, "DPMS") && encoder) { in cdv_intel_lvds_set_property()
473 encoder->helper_private; in cdv_intel_lvds_set_property()
474 helpers->dpms(encoder, value); in cdv_intel_lvds_set_property()
514 * the LVDS is present.
517 * If no child dev is parsed from VBT, it assumes that the LVDS is present.
522 struct drm_psb_private *dev_priv = dev->dev_private; in lvds_is_present_in_vbt()
525 if (!dev_priv->child_dev_num) in lvds_is_present_in_vbt()
528 for (i = 0; i < dev_priv->child_dev_num; i++) { in lvds_is_present_in_vbt()
529 struct child_device_config *child = dev_priv->child_dev + i; in lvds_is_present_in_vbt()
535 if (child->device_type != DEVICE_TYPE_INT_LFP && in lvds_is_present_in_vbt()
536 child->device_type != DEVICE_TYPE_LFP) in lvds_is_present_in_vbt()
539 if (child->i2c_pin) in lvds_is_present_in_vbt()
540 *i2c_pin = child->i2c_pin; in lvds_is_present_in_vbt()
543 * the VBT correctly. Since LVDS requires additional in lvds_is_present_in_vbt()
544 * information from AIM blocks, a non-zero addin offset is in lvds_is_present_in_vbt()
545 * a good indicator that the LVDS is actually present. in lvds_is_present_in_vbt()
547 if (child->addin_offset) in lvds_is_present_in_vbt()
553 * the OpRegion then they have validated the LVDS's existence. in lvds_is_present_in_vbt()
555 if (dev_priv->opregion.vbt) in lvds_is_present_in_vbt()
563 * cdv_intel_lvds_init - setup LVDS connectors on this device
566 * Create the connector, register the LVDS DDC bus, and try to figure out what
567 * modes we can display on the LVDS panel (if present).
579 struct drm_psb_private *dev_priv = dev->dev_private; in cdv_intel_lvds_init()
580 u32 lvds; in cdv_intel_lvds_init() local
584 if (!dev_priv->lvds_enabled_in_vbt) in cdv_intel_lvds_init()
589 DRM_DEBUG_KMS("LVDS is not present in VBT\n"); in cdv_intel_lvds_init()
607 gma_encoder->dev_priv = lvds_priv; in cdv_intel_lvds_init()
609 connector = &gma_connector->base; in cdv_intel_lvds_init()
610 gma_connector->save = cdv_intel_lvds_save; in cdv_intel_lvds_init()
611 gma_connector->restore = cdv_intel_lvds_restore; in cdv_intel_lvds_init()
612 encoder = &gma_encoder->base; in cdv_intel_lvds_init()
625 gma_encoder->type = INTEL_OUTPUT_LVDS; in cdv_intel_lvds_init()
630 connector->display_info.subpixel_order = SubPixelHorizontalRGB; in cdv_intel_lvds_init()
631 connector->interlace_allowed = false; in cdv_intel_lvds_init()
632 connector->doublescan_allowed = false; in cdv_intel_lvds_init()
635 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
636 dev->mode_config.scaling_mode_property, in cdv_intel_lvds_init()
638 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
639 dev_priv->backlight_property, in cdv_intel_lvds_init()
646 gma_encoder->i2c_bus = psb_intel_i2c_create(dev, in cdv_intel_lvds_init()
649 if (!gma_encoder->i2c_bus) { in cdv_intel_lvds_init()
651 &dev->pdev->dev, "I2C bus registration failed.\n"); in cdv_intel_lvds_init()
654 gma_encoder->i2c_bus->slave_addr = 0x2C; in cdv_intel_lvds_init()
655 dev_priv->lvds_i2c_bus = gma_encoder->i2c_bus; in cdv_intel_lvds_init()
658 * LVDS discovery: in cdv_intel_lvds_init()
661 * 3) check to see if LVDS is already on in cdv_intel_lvds_init()
662 * if none of the above, no panel in cdv_intel_lvds_init()
668 gma_encoder->ddc_bus = psb_intel_i2c_create(dev, in cdv_intel_lvds_init()
671 if (!gma_encoder->ddc_bus) { in cdv_intel_lvds_init()
672 dev_printk(KERN_ERR, &dev->pdev->dev, in cdv_intel_lvds_init()
678 * Attempt to get the fixed panel mode from DDC. Assume that the in cdv_intel_lvds_init()
681 mutex_lock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
683 &gma_encoder->ddc_bus->adapter); in cdv_intel_lvds_init()
684 list_for_each_entry(scan, &connector->probed_modes, head) { in cdv_intel_lvds_init()
685 if (scan->type & DRM_MODE_TYPE_PREFERRED) { in cdv_intel_lvds_init()
686 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
693 if (dev_priv->lfp_lvds_vbt_mode) { in cdv_intel_lvds_init()
694 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
695 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); in cdv_intel_lvds_init()
696 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
697 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
703 * If we didn't get EDID, try checking if the panel is already turned in cdv_intel_lvds_init()
707 lvds = REG_READ(LVDS); in cdv_intel_lvds_init()
708 pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; in cdv_intel_lvds_init()
711 if (crtc && (lvds & LVDS_PORT_EN)) { in cdv_intel_lvds_init()
712 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
714 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
715 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
722 if (!mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
724 ("Found no modes on the lvds, ignoring the LVDS\n"); in cdv_intel_lvds_init()
742 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
747 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
749 psb_intel_i2c_destroy(gma_encoder->ddc_bus); in cdv_intel_lvds_init()
752 psb_intel_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_init()