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()
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()
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()
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()
451 * information from AIM blocks, a non-zero addin offset is in lvds_is_present_in_vbt()
454 if (child->addin_offset) 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
494 if (!dev_priv->lvds_enabled_in_vbt) 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()
524 /* Set up the DDC bus. */ in cdv_intel_lvds_init()
527 dev_printk(KERN_ERR, dev->dev, in cdv_intel_lvds_init()
528 "DDC bus registration " "failed.\n"); in cdv_intel_lvds_init()
535 &ddc_bus->base); in cdv_intel_lvds_init()
544 gma_encoder->type = INTEL_OUTPUT_LVDS; 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()
562 * Set up I2C bus 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()
576 * 1) check for EDID on DDC in cdv_intel_lvds_init()
585 * Attempt to get the fixed panel mode from DDC. Assume that the 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()
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()
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()