31 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
65 x = y = width = height = 0;
72 switch (fitting_mode) {
76 x = (adjusted_mode->
hdisplay - width + 1)/2;
77 y = (adjusted_mode->
vdisplay - height + 1)/2;
85 if (scaled_width > scaled_height) {
86 width = scaled_height / mode->
vdisplay;
89 x = (adjusted_mode->
hdisplay - width + 1) / 2;
92 }
else if (scaled_width < scaled_height) {
93 height = scaled_width / mode->
hdisplay;
96 y = (adjusted_mode->
vdisplay - height + 1) / 2;
120 static int is_backlight_combination_mode(
struct drm_device *
dev)
143 }
else if (val == 0) {
153 }
else if (val == 0) {
165 static u32 _intel_panel_get_max_backlight(
struct drm_device *dev)
170 max = i915_read_blc_pwm_ctl(dev_priv);
180 if (is_backlight_combination_mode(dev))
191 max = _intel_panel_get_max_backlight(dev);
200 DRM_DEBUG_DRIVER(
"max backlight PWM = %d\n", max);
204 static int i915_panel_invert_brightness;
206 "(-1 force normal, 0 machine defaults, 1 force inversion), please "
207 "report PCI device ID, subsystem vendor and subsystem device ID "
209 "It will then be included in an upcoming module version.");
215 if (i915_panel_invert_brightness < 0)
218 if (i915_panel_invert_brightness > 0 ||
237 if (is_backlight_combination_mode(dev)) {
240 pci_read_config_byte(dev->pdev,
PCI_LBPC, &lbpc);
245 val = intel_panel_compute_brightness(dev, val);
246 DRM_DEBUG_DRIVER(
"get backlight PWM = %d\n", val);
262 DRM_DEBUG_DRIVER(
"set backlight PWM = %d\n", level);
263 level = intel_panel_compute_brightness(dev, level);
266 return intel_pch_panel_set_backlight(dev, level);
268 if (is_backlight_combination_mode(dev)) {
272 lbpc = level * 0xfe / max + 1;
274 pci_write_config_byte(dev->pdev,
PCI_LBPC, lbpc);
290 intel_panel_actually_set_backlight(dev, level);
298 intel_panel_actually_set_backlight(dev, 0);
343 tmp &= ~BLM_PWM_ENABLE;
366 static void intel_panel_init_backlight(
struct drm_device *dev)
381 if (i915_panel_ignore_lid)
382 return i915_panel_ignore_lid > 0 ?
399 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
416 .get_brightness = intel_panel_get_brightness,
425 intel_panel_init_backlight(dev);
434 memset(&props, 0,
sizeof(props));
436 props.max_brightness = _intel_panel_get_max_backlight(dev);
437 if (props.max_brightness == 0) {
438 DRM_DEBUG_DRIVER(
"Failed to get maximum backlight value\n");
443 &connector->
kdev, dev,
444 &intel_panel_bl_ops, &props);
447 DRM_ERROR(
"Failed to register backlight: %ld\n",
452 dev_priv->
backlight->props.brightness = intel_panel_get_backlight(dev);
465 intel_panel_init_backlight(dev);