acpi_video.c (83f1bfd6f57c422da70d1e296df1becc35c868be) | acpi_video.c (de588b8ff057d4de0751f337b930f90ca522bab2) |
---|---|
1/* 2 * video.c - ACPI Video Driver 3 * 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> 6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net> 7 * 8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- 63 unchanged lines hidden (view full) --- 72 * under the same VGA controller 73 */ 74static bool allow_duplicates; 75module_param(allow_duplicates, bool, 0644); 76 77static int disable_backlight_sysfs_if = -1; 78module_param(disable_backlight_sysfs_if, int, 0444); 79 | 1/* 2 * video.c - ACPI Video Driver 3 * 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> 6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net> 7 * 8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- 63 unchanged lines hidden (view full) --- 72 * under the same VGA controller 73 */ 74static bool allow_duplicates; 75module_param(allow_duplicates, bool, 0644); 76 77static int disable_backlight_sysfs_if = -1; 78module_param(disable_backlight_sysfs_if, int, 0444); 79 |
80#define REPORT_OUTPUT_KEY_EVENTS 0x01 81#define REPORT_BRIGHTNESS_KEY_EVENTS 0x02 82static int report_key_events = -1; 83module_param(report_key_events, int, 0644); 84MODULE_PARM_DESC(report_key_events, 85 "0: none, 1: output changes, 2: brightness changes, 3: all"); 86 |
|
80static bool device_id_scheme = false; 81module_param(device_id_scheme, bool, 0444); 82 83static bool only_lcd = false; 84module_param(only_lcd, bool, 0444); 85 | 87static bool device_id_scheme = false; 88module_param(device_id_scheme, bool, 0444); 89 90static bool only_lcd = false; 91module_param(only_lcd, bool, 0444); 92 |
86static int register_count; 87static DEFINE_MUTEX(register_count_mutex); | 93static DECLARE_COMPLETION(register_done); 94static DEFINE_MUTEX(register_done_mutex); |
88static struct mutex video_list_lock; 89static struct list_head video_bus_head; 90static int acpi_video_bus_add(struct acpi_device *device); 91static int acpi_video_bus_remove(struct acpi_device *device); 92static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 93void acpi_video_detect_exit(void); 94 95static const struct acpi_device_id video_device_ids[] = { --- 311 unchanged lines hidden (view full) --- 407} 408 409static int video_enable_only_lcd(const struct dmi_system_id *d) 410{ 411 only_lcd = true; 412 return 0; 413} 414 | 95static struct mutex video_list_lock; 96static struct list_head video_bus_head; 97static int acpi_video_bus_add(struct acpi_device *device); 98static int acpi_video_bus_remove(struct acpi_device *device); 99static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 100void acpi_video_detect_exit(void); 101 102static const struct acpi_device_id video_device_ids[] = { --- 311 unchanged lines hidden (view full) --- 414} 415 416static int video_enable_only_lcd(const struct dmi_system_id *d) 417{ 418 only_lcd = true; 419 return 0; 420} 421 |
422static int video_set_report_key_events(const struct dmi_system_id *id) 423{ 424 if (report_key_events == -1) 425 report_key_events = (uintptr_t)id->driver_data; 426 return 0; 427} 428 |
|
415static struct dmi_system_id video_dmi_table[] = { 416 /* 417 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121 418 */ 419 { 420 .callback = video_set_bqc_offset, 421 .ident = "Acer Aspire 5720", 422 .matches = { --- 37 unchanged lines hidden (view full) --- 460 /* 461 * Some machines have a broken acpi-video interface for brightness 462 * control, but still need an acpi_video_device_lcd_set_level() call 463 * on resume to turn the backlight power on. We Enable backlight 464 * control on these systems, but do not register a backlight sysfs 465 * as brightness control does not work. 466 */ 467 { | 429static struct dmi_system_id video_dmi_table[] = { 430 /* 431 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121 432 */ 433 { 434 .callback = video_set_bqc_offset, 435 .ident = "Acer Aspire 5720", 436 .matches = { --- 37 unchanged lines hidden (view full) --- 474 /* 475 * Some machines have a broken acpi-video interface for brightness 476 * control, but still need an acpi_video_device_lcd_set_level() call 477 * on resume to turn the backlight power on. We Enable backlight 478 * control on these systems, but do not register a backlight sysfs 479 * as brightness control does not work. 480 */ 481 { |
482 /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */ 483 .callback = video_disable_backlight_sysfs_if, 484 .ident = "Toshiba Portege R700", 485 .matches = { 486 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 487 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"), 488 }, 489 }, 490 { |
|
468 /* https://bugs.freedesktop.org/show_bug.cgi?id=82634 */ 469 .callback = video_disable_backlight_sysfs_if, 470 .ident = "Toshiba Portege R830", 471 .matches = { 472 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 473 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R830"), 474 }, 475 }, --- 19 unchanged lines hidden (view full) --- 495 /* https://bugzilla.kernel.org/show_bug.cgi?id=104121 */ 496 .callback = video_enable_only_lcd, 497 .ident = "ESPRIMO Mobile M9410", 498 .matches = { 499 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 500 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile M9410"), 501 }, 502 }, | 491 /* https://bugs.freedesktop.org/show_bug.cgi?id=82634 */ 492 .callback = video_disable_backlight_sysfs_if, 493 .ident = "Toshiba Portege R830", 494 .matches = { 495 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 496 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R830"), 497 }, 498 }, --- 19 unchanged lines hidden (view full) --- 518 /* https://bugzilla.kernel.org/show_bug.cgi?id=104121 */ 519 .callback = video_enable_only_lcd, 520 .ident = "ESPRIMO Mobile M9410", 521 .matches = { 522 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 523 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile M9410"), 524 }, 525 }, |
526 /* 527 * Some machines report wrong key events on the acpi-bus, suppress 528 * key event reporting on these. Note this is only intended to work 529 * around events which are plain wrong. In some cases we get double 530 * events, in this case acpi-video is considered the canonical source 531 * and the events from the other source should be filtered. E.g. 532 * by calling acpi_video_handles_brightness_key_presses() from the 533 * vendor acpi/wmi driver or by using /lib/udev/hwdb.d/60-keyboard.hwdb 534 */ 535 { 536 .callback = video_set_report_key_events, 537 .driver_data = (void *)((uintptr_t)REPORT_OUTPUT_KEY_EVENTS), 538 .ident = "Dell Vostro V131", 539 .matches = { 540 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 541 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"), 542 }, 543 }, |
|
503 {} 504}; 505 506static unsigned long long 507acpi_video_bqc_value_to_level(struct acpi_video_device *device, 508 unsigned long long bqc_value) 509{ 510 unsigned long long level; --- 964 unchanged lines hidden (view full) --- 1475 "Unsupported event [0x%x]\n", event)); 1476 break; 1477 } 1478 1479 if (acpi_notifier_call_chain(device, event, 0)) 1480 /* Something vetoed the keypress. */ 1481 keycode = 0; 1482 | 544 {} 545}; 546 547static unsigned long long 548acpi_video_bqc_value_to_level(struct acpi_video_device *device, 549 unsigned long long bqc_value) 550{ 551 unsigned long long level; --- 964 unchanged lines hidden (view full) --- 1516 "Unsupported event [0x%x]\n", event)); 1517 break; 1518 } 1519 1520 if (acpi_notifier_call_chain(device, event, 0)) 1521 /* Something vetoed the keypress. */ 1522 keycode = 0; 1523 |
1483 if (keycode) { | 1524 if (keycode && (report_key_events & REPORT_OUTPUT_KEY_EVENTS)) { |
1484 input_report_key(input, keycode, 1); 1485 input_sync(input); 1486 input_report_key(input, keycode, 0); 1487 input_sync(input); 1488 } 1489 1490 return; 1491} --- 47 unchanged lines hidden (view full) --- 1539 default: 1540 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1541 "Unsupported event [0x%x]\n", event)); 1542 break; 1543 } 1544 1545 acpi_notifier_call_chain(device, event, 0); 1546 | 1525 input_report_key(input, keycode, 1); 1526 input_sync(input); 1527 input_report_key(input, keycode, 0); 1528 input_sync(input); 1529 } 1530 1531 return; 1532} --- 47 unchanged lines hidden (view full) --- 1580 default: 1581 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1582 "Unsupported event [0x%x]\n", event)); 1583 break; 1584 } 1585 1586 acpi_notifier_call_chain(device, event, 0); 1587 |
1547 if (keycode) { | 1588 if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) { |
1548 input_report_key(input, keycode, 1); 1549 input_sync(input); 1550 input_report_key(input, keycode, 0); 1551 input_sync(input); 1552 } 1553 1554 return; 1555} --- 456 unchanged lines hidden (view full) --- 2012 } 2013 return opregion; 2014} 2015 2016int acpi_video_register(void) 2017{ 2018 int ret = 0; 2019 | 1589 input_report_key(input, keycode, 1); 1590 input_sync(input); 1591 input_report_key(input, keycode, 0); 1592 input_sync(input); 1593 } 1594 1595 return; 1596} --- 456 unchanged lines hidden (view full) --- 2053 } 2054 return opregion; 2055} 2056 2057int acpi_video_register(void) 2058{ 2059 int ret = 0; 2060 |
2020 mutex_lock(®ister_count_mutex); 2021 if (register_count) { | 2061 mutex_lock(®ister_done_mutex); 2062 if (completion_done(®ister_done)) { |
2022 /* 2023 * if the function of acpi_video_register is already called, 2024 * don't register the acpi_vide_bus again and return no error. 2025 */ 2026 goto leave; 2027 } 2028 2029 mutex_init(&video_list_lock); --- 4 unchanged lines hidden (view full) --- 2034 ret = acpi_bus_register_driver(&acpi_video_bus); 2035 if (ret) 2036 goto leave; 2037 2038 /* 2039 * When the acpi_video_bus is loaded successfully, increase 2040 * the counter reference. 2041 */ | 2063 /* 2064 * if the function of acpi_video_register is already called, 2065 * don't register the acpi_vide_bus again and return no error. 2066 */ 2067 goto leave; 2068 } 2069 2070 mutex_init(&video_list_lock); --- 4 unchanged lines hidden (view full) --- 2075 ret = acpi_bus_register_driver(&acpi_video_bus); 2076 if (ret) 2077 goto leave; 2078 2079 /* 2080 * When the acpi_video_bus is loaded successfully, increase 2081 * the counter reference. 2082 */ |
2042 register_count = 1; | 2083 complete(®ister_done); |
2043 2044leave: | 2084 2085leave: |
2045 mutex_unlock(®ister_count_mutex); | 2086 mutex_unlock(®ister_done_mutex); |
2046 return ret; 2047} 2048EXPORT_SYMBOL(acpi_video_register); 2049 2050void acpi_video_unregister(void) 2051{ | 2087 return ret; 2088} 2089EXPORT_SYMBOL(acpi_video_register); 2090 2091void acpi_video_unregister(void) 2092{ |
2052 mutex_lock(®ister_count_mutex); 2053 if (register_count) { | 2093 mutex_lock(®ister_done_mutex); 2094 if (completion_done(®ister_done)) { |
2054 acpi_bus_unregister_driver(&acpi_video_bus); | 2095 acpi_bus_unregister_driver(&acpi_video_bus); |
2055 register_count = 0; | 2096 reinit_completion(®ister_done); |
2056 } | 2097 } |
2057 mutex_unlock(®ister_count_mutex); | 2098 mutex_unlock(®ister_done_mutex); |
2058} 2059EXPORT_SYMBOL(acpi_video_unregister); 2060 2061void acpi_video_unregister_backlight(void) 2062{ 2063 struct acpi_video_bus *video; 2064 | 2099} 2100EXPORT_SYMBOL(acpi_video_unregister); 2101 2102void acpi_video_unregister_backlight(void) 2103{ 2104 struct acpi_video_bus *video; 2105 |
2065 mutex_lock(®ister_count_mutex); 2066 if (register_count) { | 2106 mutex_lock(®ister_done_mutex); 2107 if (completion_done(®ister_done)) { |
2067 mutex_lock(&video_list_lock); 2068 list_for_each_entry(video, &video_bus_head, entry) 2069 acpi_video_bus_unregister_backlight(video); 2070 mutex_unlock(&video_list_lock); 2071 } | 2108 mutex_lock(&video_list_lock); 2109 list_for_each_entry(video, &video_bus_head, entry) 2110 acpi_video_bus_unregister_backlight(video); 2111 mutex_unlock(&video_list_lock); 2112 } |
2072 mutex_unlock(®ister_count_mutex); | 2113 mutex_unlock(®ister_done_mutex); |
2073} 2074 | 2114} 2115 |
2116bool acpi_video_handles_brightness_key_presses(void) 2117{ 2118 bool have_video_busses; 2119 2120 wait_for_completion(®ister_done); 2121 mutex_lock(&video_list_lock); 2122 have_video_busses = !list_empty(&video_bus_head); 2123 mutex_unlock(&video_list_lock); 2124 2125 return have_video_busses && 2126 (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS); 2127} 2128EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses); 2129 |
|
2075/* 2076 * This is kind of nasty. Hardware using Intel chipsets may require 2077 * the video opregion code to be run first in order to initialise 2078 * state before any ACPI video calls are made. To handle this we defer 2079 * registration of the video class until the opregion code has run. 2080 */ 2081 2082static int __init acpi_video_init(void) --- 28 unchanged lines hidden --- | 2130/* 2131 * This is kind of nasty. Hardware using Intel chipsets may require 2132 * the video opregion code to be run first in order to initialise 2133 * state before any ACPI video calls are made. To handle this we defer 2134 * registration of the video class until the opregion code has run. 2135 */ 2136 2137static int __init acpi_video_init(void) --- 28 unchanged lines hidden --- |