28 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35 #include <drm/i915_drm.h>
42 #define OPREGION_HEADER_OFFSET 0
43 #define OPREGION_ACPI_OFFSET 0x100
44 #define ACPI_CLID 0x01ac
45 #define ACPI_CDCK 0x01b0
46 #define OPREGION_SWSCI_OFFSET 0x200
47 #define OPREGION_ASLE_OFFSET 0x300
48 #define OPREGION_VBT_OFFSET 0x400
50 #define OPREGION_SIGNATURE "IntelGraphicsMem"
51 #define MBOX_ACPI (1<<0)
52 #define MBOX_SWSCI (1<<1)
53 #define MBOX_ASLE (1<<2)
114 #define ASLE_SET_ALS_ILLUM (1 << 0)
115 #define ASLE_SET_BACKLIGHT (1 << 1)
116 #define ASLE_SET_PFIT (1 << 2)
117 #define ASLE_SET_PWM_FREQ (1 << 3)
118 #define ASLE_REQ_MSK 0xf
121 #define ASLE_ALS_ILLUM_FAILED (1<<10)
122 #define ASLE_BACKLIGHT_FAILED (1<<12)
123 #define ASLE_PFIT_FAILED (1<<14)
124 #define ASLE_PWM_FREQ_FAILED (1<<16)
127 #define ASLE_BCLP_VALID (1<<31)
128 #define ASLE_BCLP_MSK (~(1<<31))
131 #define ASLE_PFIT_VALID (1<<31)
132 #define ASLE_PFIT_CENTER (1<<0)
133 #define ASLE_PFIT_STRETCH_TEXT (1<<1)
134 #define ASLE_PFIT_STRETCH_GFX (1<<2)
137 #define ASLE_PFMB_BRIGHTNESS_MASK (0xff)
138 #define ASLE_PFMB_BRIGHTNESS_VALID (1<<8)
139 #define ASLE_PFMB_PWM_MASK (0x7ffffe00)
140 #define ASLE_PFMB_PWM_VALID (1<<31)
142 #define ASLE_CBLV_VALID (1<<31)
144 #define ACPI_OTHER_OUTPUT (0<<8)
145 #define ACPI_VGA_OUTPUT (1<<8)
146 #define ACPI_TV_OUTPUT (2<<8)
147 #define ACPI_DIGITAL_OUTPUT (3<<8)
148 #define ACPI_LVDS_OUTPUT (4<<8)
200 void intel_opregion_asle_intr(
struct drm_device *dev)
213 DRM_DEBUG_DRIVER(
"non asle set request??\n");
218 asle_stat |= asle_set_als_illum(dev,
ioread32(&asle->
alsi));
221 asle_stat |= asle_set_backlight(dev,
ioread32(&asle->
bclp));
227 asle_stat |= asle_set_pwm_freq(dev,
ioread32(&asle->
pfmb));
232 void intel_opregion_gse_intr(
struct drm_device *dev)
245 DRM_DEBUG_DRIVER(
"non asle set request??\n");
249 if (asle_req & ASLE_SET_ALS_ILLUM) {
250 DRM_DEBUG_DRIVER(
"Illum is not supported\n");
254 if (asle_req & ASLE_SET_BACKLIGHT)
255 asle_stat |= asle_set_backlight(dev,
ioread32(&asle->
bclp));
257 if (asle_req & ASLE_SET_PFIT) {
258 DRM_DEBUG_DRIVER(
"Pfit is not supported\n");
262 if (asle_req & ASLE_SET_PWM_FREQ) {
263 DRM_DEBUG_DRIVER(
"PWM freq is not supported\n");
269 #define ASLE_ALS_EN (1<<0)
270 #define ASLE_BLC_EN (1<<1)
271 #define ASLE_PFIT_EN (1<<2)
272 #define ASLE_PFMB_EN (1<<3)
274 void intel_opregion_enable_asle(
struct drm_device *dev)
290 #define ACPI_EV_DISPLAY_SWITCH (1<<0)
291 #define ACPI_EV_LID (1<<1)
292 #define ACPI_EV_DOCK (1<<2)
305 struct acpi_bus_event *
event =
data;
311 if (!system_opregion)
314 acpi = system_opregion->
acpi;
316 if (
event->type == 0x80 &&
335 static void intel_didl_outputs(
struct drm_device *dev)
347 handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev);
352 acpi_video_bus = acpi_dev;
356 acpi_video_bus = acpi_cdev;
362 if (!acpi_video_bus) {
363 pr_warn(
"No ACPI video bus found\n");
369 dev_printk(
KERN_ERR, &dev->pdev->dev,
370 "More than 8 outputs detected\n");
380 &opregion->
acpi->didl[i]);
396 dev_printk(
KERN_ERR, &dev->pdev->dev,
397 "More than 8 outputs detected\n");
423 iowrite32(temp | (1<<31) | output_type | i,
424 &opregion->
acpi->didl[i]);
430 static void intel_setup_cadls(
struct drm_device *dev)
446 }
while (++i < 8 && disp_id != 0);
449 void intel_opregion_init(
struct drm_device *dev)
457 if (opregion->
acpi) {
458 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
459 intel_didl_outputs(dev);
460 intel_setup_cadls(dev);
469 system_opregion = opregion;
474 intel_opregion_enable_asle(dev);
477 void intel_opregion_fini(
struct drm_device *dev)
485 if (opregion->
acpi) {
488 system_opregion =
NULL;
511 pci_read_config_dword(dev->pdev,
PCI_ASLS, &asls);
512 DRM_DEBUG_DRIVER(
"graphic opregion physical addr: 0x%x\n", asls);
514 DRM_DEBUG_DRIVER(
"ACPI OpRegion not supported!\n");
525 DRM_DEBUG_DRIVER(
"opregion signature mismatch\n");
536 DRM_DEBUG_DRIVER(
"Public ACPI methods supported\n");
541 DRM_DEBUG_DRIVER(
"SWSCI supported\n");
545 DRM_DEBUG_DRIVER(
"ASLE supported\n");