Lines Matching +full:ddc +full:- +full:i2c +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2011 Intel Corporation
12 #include <linux/i2c.h>
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()
124 dev_priv->mode_dev.backlight_duty_cycle); in cdv_intel_lvds_set_power()
139 struct drm_device *dev = encoder->dev; 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()
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()
194 && tmp_encoder->crtc == encoder->crtc) { 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()
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()
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()
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()
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()
297 * Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
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()
326 gma_i2c_destroy(to_gma_i2c_chan(connector->ddc)); in cdv_intel_lvds_destroy()
327 gma_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_destroy()
336 struct drm_encoder *encoder = connector->encoder; in cdv_intel_lvds_set_property()
338 if (!strcmp(property->name, "scaling mode") && encoder) { in cdv_intel_lvds_set_property()
339 struct gma_crtc *crtc = to_gma_crtc(encoder->crtc); in cdv_intel_lvds_set_property()
343 return -1; in cdv_intel_lvds_set_property()
353 return -1; in cdv_intel_lvds_set_property()
356 if (drm_object_property_get_value(&connector->base, in cdv_intel_lvds_set_property()
359 return -1; in cdv_intel_lvds_set_property()
364 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
367 return -1; in cdv_intel_lvds_set_property()
369 if (crtc->saved_mode.hdisplay != 0 && in cdv_intel_lvds_set_property()
370 crtc->saved_mode.vdisplay != 0) { in cdv_intel_lvds_set_property()
371 if (!drm_crtc_helper_set_mode(encoder->crtc, in cdv_intel_lvds_set_property()
372 &crtc->saved_mode, in cdv_intel_lvds_set_property()
373 encoder->crtc->x, in cdv_intel_lvds_set_property()
374 encoder->crtc->y, in cdv_intel_lvds_set_property()
375 encoder->crtc->primary->fb)) in cdv_intel_lvds_set_property()
376 return -1; in cdv_intel_lvds_set_property()
378 } else if (!strcmp(property->name, "backlight") && encoder) { in cdv_intel_lvds_set_property()
379 if (drm_object_property_set_value(&connector->base, in cdv_intel_lvds_set_property()
382 return -1; in cdv_intel_lvds_set_property()
384 gma_backlight_set(encoder->dev, value); in cdv_intel_lvds_set_property()
385 } else if (!strcmp(property->name, "DPMS") && encoder) { in cdv_intel_lvds_set_property()
387 encoder->helper_private; in cdv_intel_lvds_set_property()
388 helpers->dpms(encoder, value); in cdv_intel_lvds_set_property()
429 if (!dev_priv->child_dev_num) in lvds_is_present_in_vbt()
432 for (i = 0; i < dev_priv->child_dev_num; i++) { in lvds_is_present_in_vbt()
433 struct child_device_config *child = dev_priv->child_dev + i; in lvds_is_present_in_vbt()
439 if (child->device_type != DEVICE_TYPE_INT_LFP && in lvds_is_present_in_vbt()
440 child->device_type != DEVICE_TYPE_LFP) in lvds_is_present_in_vbt()
443 if (child->i2c_pin) in lvds_is_present_in_vbt()
444 *i2c_pin = child->i2c_pin; in lvds_is_present_in_vbt()
448 * information from AIM blocks, a non-zero addin offset is in lvds_is_present_in_vbt()
451 if (child->addin_offset) in lvds_is_present_in_vbt()
459 if (dev_priv->opregion.vbt) in lvds_is_present_in_vbt()
467 * cdv_intel_lvds_init - setup LVDS connectors on this device
471 * Create the connector, register the LVDS DDC bus, and try to figure out what
491 if (!dev_priv->lvds_enabled_in_vbt) in cdv_intel_lvds_init()
514 gma_encoder->dev_priv = lvds_priv; in cdv_intel_lvds_init()
516 connector = &gma_connector->base; in cdv_intel_lvds_init()
517 gma_connector->save = cdv_intel_lvds_save; in cdv_intel_lvds_init()
518 gma_connector->restore = cdv_intel_lvds_restore; in cdv_intel_lvds_init()
519 encoder = &gma_encoder->base; in cdv_intel_lvds_init()
521 /* Set up the DDC bus. */ in cdv_intel_lvds_init()
524 dev_printk(KERN_ERR, dev->dev, in cdv_intel_lvds_init()
525 "DDC bus registration " "failed.\n"); in cdv_intel_lvds_init()
532 &ddc_bus->base); in cdv_intel_lvds_init()
541 gma_encoder->type = INTEL_OUTPUT_LVDS; in cdv_intel_lvds_init()
546 connector->display_info.subpixel_order = SubPixelHorizontalRGB; in cdv_intel_lvds_init()
547 connector->interlace_allowed = false; in cdv_intel_lvds_init()
548 connector->doublescan_allowed = false; in cdv_intel_lvds_init()
551 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
552 dev->mode_config.scaling_mode_property, in cdv_intel_lvds_init()
554 drm_object_attach_property(&connector->base, in cdv_intel_lvds_init()
555 dev_priv->backlight_property, in cdv_intel_lvds_init()
559 * Set up I2C bus in cdv_intel_lvds_init()
562 gma_encoder->i2c_bus = gma_i2c_create(dev, GPIOB, "LVDSBLC_B"); in cdv_intel_lvds_init()
563 if (!gma_encoder->i2c_bus) { in cdv_intel_lvds_init()
565 dev->dev, "I2C bus registration failed.\n"); in cdv_intel_lvds_init()
568 gma_encoder->i2c_bus->slave_addr = 0x2C; in cdv_intel_lvds_init()
569 dev_priv->lvds_i2c_bus = gma_encoder->i2c_bus; in cdv_intel_lvds_init()
573 * 1) check for EDID on DDC in cdv_intel_lvds_init()
582 * Attempt to get the fixed panel mode from DDC. Assume that the in cdv_intel_lvds_init()
585 mutex_lock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
586 psb_intel_ddc_get_modes(connector, &ddc_bus->base); in cdv_intel_lvds_init()
588 list_for_each_entry(scan, &connector->probed_modes, head) { in cdv_intel_lvds_init()
589 if (scan->type & DRM_MODE_TYPE_PREFERRED) { in cdv_intel_lvds_init()
590 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
597 if (dev_priv->lfp_lvds_vbt_mode) { in cdv_intel_lvds_init()
598 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
599 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); in cdv_intel_lvds_init()
600 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
601 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
616 mode_dev->panel_fixed_mode = in cdv_intel_lvds_init()
618 if (mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
619 mode_dev->panel_fixed_mode->type |= in cdv_intel_lvds_init()
626 if (!mode_dev->panel_fixed_mode) { in cdv_intel_lvds_init()
646 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
650 mutex_unlock(&dev->mode_config.mutex); in cdv_intel_lvds_init()
651 gma_i2c_destroy(gma_encoder->i2c_bus); in cdv_intel_lvds_init()