Lines 32-37
Link Here
|
32 |
#include <dev/drm2/i915/i915_drm.h> |
32 |
#include <dev/drm2/i915/i915_drm.h> |
33 |
#include <dev/drm2/i915/i915_drv.h> |
33 |
#include <dev/drm2/i915/i915_drv.h> |
34 |
#include <dev/drm2/i915/intel_drv.h> |
34 |
#include <dev/drm2/i915/intel_drv.h> |
|
|
35 |
#include <contrib/dev/acpica/include/acpi.h> |
36 |
#include <contrib/dev/acpica/include/accommon.h> |
37 |
#include <dev/acpica/acpivar.h> |
35 |
|
38 |
|
36 |
#define PCI_ASLE 0xe4 |
39 |
#define PCI_ASLE 0xe4 |
37 |
#define PCI_ASLS 0xfc |
40 |
#define PCI_ASLS 0xfc |
Lines 144-150
Link Here
|
144 |
#define ACPI_DIGITAL_OUTPUT (3<<8) |
147 |
#define ACPI_DIGITAL_OUTPUT (3<<8) |
145 |
#define ACPI_LVDS_OUTPUT (4<<8) |
148 |
#define ACPI_LVDS_OUTPUT (4<<8) |
146 |
|
149 |
|
147 |
#ifdef CONFIG_ACPI |
150 |
#if 1 |
148 |
static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) |
151 |
static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) |
149 |
{ |
152 |
{ |
150 |
struct drm_i915_private *dev_priv = dev->dev_private; |
153 |
struct drm_i915_private *dev_priv = dev->dev_private; |
Lines 289-294
Link Here
|
289 |
|
292 |
|
290 |
static struct intel_opregion *system_opregion; |
293 |
static struct intel_opregion *system_opregion; |
291 |
|
294 |
|
|
|
295 |
#if 0 |
292 |
static int intel_opregion_video_event(struct notifier_block *nb, |
296 |
static int intel_opregion_video_event(struct notifier_block *nb, |
293 |
unsigned long val, void *data) |
297 |
unsigned long val, void *data) |
294 |
{ |
298 |
{ |
Lines 319-324
Link Here
|
319 |
static struct notifier_block intel_opregion_notifier = { |
323 |
static struct notifier_block intel_opregion_notifier = { |
320 |
.notifier_call = intel_opregion_video_event, |
324 |
.notifier_call = intel_opregion_video_event, |
321 |
}; |
325 |
}; |
|
|
326 |
#endif |
322 |
|
327 |
|
323 |
/* |
328 |
/* |
324 |
* Initialise the DIDL field in opregion. This passes a list of devices to |
329 |
* Initialise the DIDL field in opregion. This passes a list of devices to |
Lines 326-349
Link Here
|
326 |
* (version 3) |
331 |
* (version 3) |
327 |
*/ |
332 |
*/ |
328 |
|
333 |
|
|
|
334 |
static int acpi_is_video_device(ACPI_HANDLE devh) { |
335 |
ACPI_HANDLE h; |
336 |
if (ACPI_FAILURE(AcpiGetHandle(devh, "_DOD", &h)) || |
337 |
ACPI_FAILURE(AcpiGetHandle(devh, "_DOS", &h))) { |
338 |
return 0; |
339 |
} |
340 |
return 1; |
341 |
} |
342 |
|
329 |
static void intel_didl_outputs(struct drm_device *dev) |
343 |
static void intel_didl_outputs(struct drm_device *dev) |
330 |
{ |
344 |
{ |
331 |
struct drm_i915_private *dev_priv = dev->dev_private; |
345 |
struct drm_i915_private *dev_priv = dev->dev_private; |
332 |
struct intel_opregion *opregion = &dev_priv->opregion; |
346 |
struct intel_opregion *opregion = &dev_priv->opregion; |
333 |
struct drm_connector *connector; |
347 |
struct drm_connector *connector; |
334 |
acpi_handle handle; |
348 |
u32 device_id; |
335 |
struct acpi_device *acpi_dev, *acpi_cdev, *acpi_video_bus = NULL; |
349 |
ACPI_HANDLE handle, acpi_video_bus, acpi_cdev; |
336 |
unsigned long long device_id; |
350 |
ACPI_STATUS status; |
337 |
acpi_status status; |
|
|
338 |
int i = 0; |
351 |
int i = 0; |
339 |
|
352 |
|
340 |
handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev); |
353 |
handle = acpi_get_handle(dev->device); |
341 |
if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) |
354 |
if (!handle) |
342 |
return; |
355 |
return; |
343 |
|
356 |
|
344 |
if (acpi_is_video_device(acpi_dev)) |
357 |
if (acpi_is_video_device(handle)) |
345 |
acpi_video_bus = acpi_dev; |
358 |
acpi_video_bus = handle; |
346 |
else { |
359 |
else { |
|
|
360 |
acpi_cdev = NULL; |
361 |
acpi_video_bus = NULL; |
362 |
while (AcpiGetNextObject(ACPI_TYPE_DEVICE, handle, acpi_cdev, |
363 |
&acpi_cdev) != AE_NOT_FOUND) { |
364 |
if (acpi_is_video_device(acpi_cdev)) { |
365 |
acpi_video_bus = acpi_cdev; |
366 |
break; |
367 |
} |
368 |
} |
369 |
#if 0 |
347 |
list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { |
370 |
list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { |
348 |
if (acpi_is_video_device(acpi_cdev)) { |
371 |
if (acpi_is_video_device(acpi_cdev)) { |
349 |
acpi_video_bus = acpi_cdev; |
372 |
acpi_video_bus = acpi_cdev; |
Lines 350-362
Link Here
|
350 |
break; |
373 |
break; |
351 |
} |
374 |
} |
352 |
} |
375 |
} |
|
|
376 |
#endif |
353 |
} |
377 |
} |
354 |
|
378 |
|
355 |
if (!acpi_video_bus) { |
379 |
if (!acpi_video_bus) { |
356 |
printk(KERN_WARNING "No ACPI video bus found\n"); |
380 |
device_printf(dev->device, "No ACPI video bus found\n"); |
357 |
return; |
381 |
return; |
358 |
} |
382 |
} |
359 |
|
383 |
|
|
|
384 |
acpi_cdev = NULL; |
385 |
while (AcpiGetNextObject(ACPI_TYPE_DEVICE, acpi_video_bus, acpi_cdev, |
386 |
&acpi_cdev) != AE_NOT_FOUND) { |
387 |
if (i >= 8) { |
388 |
device_printf(dev->device, "More than 8 outputs detected\n"); |
389 |
return; |
390 |
} |
391 |
status = acpi_GetInteger(acpi_cdev, "_ADR", &device_id); |
392 |
if (ACPI_SUCCESS(status)) { |
393 |
if (!device_id) |
394 |
goto blind_set; |
395 |
opregion->acpi->didl[i] = (u32)(device_id & 0x0f0f); |
396 |
i++; |
397 |
} |
398 |
} |
399 |
#if 0 |
360 |
list_for_each_entry(acpi_cdev, &acpi_video_bus->children, node) { |
400 |
list_for_each_entry(acpi_cdev, &acpi_video_bus->children, node) { |
361 |
if (i >= 8) { |
401 |
if (i >= 8) { |
362 |
dev_printk(KERN_ERR, &dev->pdev->dev, |
402 |
dev_printk(KERN_ERR, &dev->pdev->dev, |
Lines 373-378
Link Here
|
373 |
i++; |
413 |
i++; |
374 |
} |
414 |
} |
375 |
} |
415 |
} |
|
|
416 |
#endif |
376 |
|
417 |
|
377 |
end: |
418 |
end: |
378 |
/* If fewer than 8 outputs, the list must be null terminated */ |
419 |
/* If fewer than 8 outputs, the list must be null terminated */ |
Lines 417-422
Link Here
|
417 |
goto end; |
458 |
goto end; |
418 |
} |
459 |
} |
419 |
|
460 |
|
|
|
461 |
static void intel_setup_cadls(struct drm_device *dev) |
462 |
{ |
463 |
struct drm_i915_private *dev_priv = dev->dev_private; |
464 |
struct intel_opregion *opregion = &dev_priv->opregion; |
465 |
int i = 0; |
466 |
u32 disp_id; |
467 |
|
468 |
/* Initialize the CADL field by duplicating the DIDL values. |
469 |
* Technically, this is not always correct as display outputs may exist, |
470 |
* but not active. This initialization is necessary for some Clevo |
471 |
* laptops that check this field before processing the brightness and |
472 |
* display switching hotkeys. Just like DIDL, CADL is NULL-terminated if |
473 |
* there are less than eight devices. */ |
474 |
do { |
475 |
disp_id = opregion->acpi->didl[i]; |
476 |
opregion->acpi->cadl[i] = disp_id; |
477 |
} while (++i < 8 && disp_id != 0); |
478 |
} |
479 |
|
420 |
void intel_opregion_init(struct drm_device *dev) |
480 |
void intel_opregion_init(struct drm_device *dev) |
421 |
{ |
481 |
{ |
422 |
struct drm_i915_private *dev_priv = dev->dev_private; |
482 |
struct drm_i915_private *dev_priv = dev->dev_private; |
Lines 426-433
Link Here
|
426 |
return; |
486 |
return; |
427 |
|
487 |
|
428 |
if (opregion->acpi) { |
488 |
if (opregion->acpi) { |
429 |
if (drm_core_check_feature(dev, DRIVER_MODESET)) |
489 |
if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
430 |
intel_didl_outputs(dev); |
490 |
intel_didl_outputs(dev); |
|
|
491 |
intel_setup_cadls(dev); |
492 |
} |
431 |
|
493 |
|
432 |
/* Notify BIOS we are ready to handle ACPI video ext notifs. |
494 |
/* Notify BIOS we are ready to handle ACPI video ext notifs. |
433 |
* Right now, all the events are handled by the ACPI video module. |
495 |
* Right now, all the events are handled by the ACPI video module. |
Lines 436-442
Link Here
|
436 |
opregion->acpi->drdy = 1; |
498 |
opregion->acpi->drdy = 1; |
437 |
|
499 |
|
438 |
system_opregion = opregion; |
500 |
system_opregion = opregion; |
|
|
501 |
#if 0 |
439 |
register_acpi_notifier(&intel_opregion_notifier); |
502 |
register_acpi_notifier(&intel_opregion_notifier); |
|
|
503 |
#endif |
440 |
} |
504 |
} |
441 |
|
505 |
|
442 |
if (opregion->asle) |
506 |
if (opregion->asle) |
Lines 455-465
Link Here
|
455 |
opregion->acpi->drdy = 0; |
519 |
opregion->acpi->drdy = 0; |
456 |
|
520 |
|
457 |
system_opregion = NULL; |
521 |
system_opregion = NULL; |
|
|
522 |
#if 0 |
458 |
unregister_acpi_notifier(&intel_opregion_notifier); |
523 |
unregister_acpi_notifier(&intel_opregion_notifier); |
|
|
524 |
#endif |
459 |
} |
525 |
} |
460 |
|
526 |
|
461 |
/* just clear all opregion memory pointers now */ |
527 |
/* just clear all opregion memory pointers now */ |
462 |
iounmap(opregion->header); |
528 |
pmap_unmapdev((vm_offset_t)opregion->header, OPREGION_SIZE); |
463 |
opregion->header = NULL; |
529 |
opregion->header = NULL; |
464 |
opregion->acpi = NULL; |
530 |
opregion->acpi = NULL; |
465 |
opregion->swsci = NULL; |
531 |
opregion->swsci = NULL; |