Lines Matching +full:battery +full:- +full:profile

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * video.c - ACPI Video Driver
7 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
52 static int report_key_events = -1;
57 static int hw_changes_brightness = -1;
61 "a hotkey is pressed: -1: auto, 0: normal 1: hw-changes-brightness");
70 static int only_lcd = -1;
128 u32 display_index:4; /* A zero-based instance of the Display */
133 u32 depend_on_vga:1; /* Non-VGA output device whose power is related to
135 u32 pipe_id:3; /* For VGA multiple-head devices. */
229 return -EINVAL; in acpi_video_get_brightness()
230 for (i = ACPI_VIDEO_FIRST_LEVEL; i < vd->brightness->count; i++) { in acpi_video_get_brightness()
231 if (vd->brightness->levels[i] == cur_level) in acpi_video_get_brightness()
232 return i - ACPI_VIDEO_FIRST_LEVEL; in acpi_video_get_brightness()
239 int request_level = bd->props.brightness + ACPI_VIDEO_FIRST_LEVEL; in acpi_video_set_brightness()
242 cancel_delayed_work(&vd->switch_brightness_work); in acpi_video_set_brightness()
244 vd->brightness->levels[request_level]); in acpi_video_set_brightness()
256 struct acpi_device *device = cooling_dev->devdata; in video_get_max_state()
259 *state = video->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; in video_get_max_state()
266 struct acpi_device *device = cooling_dev->devdata; in video_get_cur_state()
272 return -EINVAL; in video_get_cur_state()
273 for (offset = ACPI_VIDEO_FIRST_LEVEL; offset < video->brightness->count; in video_get_cur_state()
275 if (level == video->brightness->levels[offset]) { in video_get_cur_state()
276 *state = video->brightness->count - offset - 1; in video_get_cur_state()
280 return -EINVAL; in video_get_cur_state()
286 struct acpi_device *device = cooling_dev->devdata; in video_set_cur_state()
290 if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL) in video_set_cur_state()
291 return -EINVAL; in video_set_cur_state()
293 state = video->brightness->count - state; in video_set_cur_state()
294 level = video->brightness->levels[state - 1]; in video_set_cur_state()
305 * --------------------------------------------------------------------------
307 * --------------------------------------------------------------------------
325 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { in acpi_video_device_lcd_query_levels()
327 status = -EFAULT; in acpi_video_device_lcd_query_levels()
347 status = acpi_execute_simple_method(device->dev->handle, in acpi_video_device_lcd_set_level()
350 acpi_handle_info(device->dev->handle, "_BCM evaluation failed\n"); in acpi_video_device_lcd_set_level()
351 return -EIO; in acpi_video_device_lcd_set_level()
354 device->brightness->curr = level; in acpi_video_device_lcd_set_level()
355 for (state = ACPI_VIDEO_FIRST_LEVEL; state < device->brightness->count; in acpi_video_device_lcd_set_level()
357 if (level == device->brightness->levels[state]) { in acpi_video_device_lcd_set_level()
358 if (device->backlight) in acpi_video_device_lcd_set_level()
359 device->backlight->props.brightness = in acpi_video_device_lcd_set_level()
360 state - ACPI_VIDEO_FIRST_LEVEL; in acpi_video_device_lcd_set_level()
364 acpi_handle_info(device->dev->handle, "Current brightness invalid\n"); in acpi_video_device_lcd_set_level()
365 return -EINVAL; in acpi_video_device_lcd_set_level()
394 if (report_key_events == -1) in video_set_report_key_events()
395 report_key_events = (uintptr_t)id->driver_data; in video_set_report_key_events()
402 if (hw_changes_brightness == -1) in video_hw_changes_brightness()
480 * Some machines report wrong key events on the acpi-bus, suppress
483 * events, in this case acpi-video is considered the canonical source
486 * vendor acpi/wmi driver or by using /lib/udev/hwdb.d/60-keyboard.hwdb
530 if (device->brightness->flags._BQC_use_index) { in acpi_video_bqc_value_to_level()
536 if (device->brightness->flags._BCL_reversed) in acpi_video_bqc_value_to_level()
537 bqc_value = device->brightness->count - in acpi_video_bqc_value_to_level()
538 ACPI_VIDEO_FIRST_LEVEL - 1 - bqc_value; in acpi_video_bqc_value_to_level()
540 level = device->brightness->levels[bqc_value + in acpi_video_bqc_value_to_level()
558 if (device->cap._BQC || device->cap._BCQ) { in acpi_video_device_lcd_get_level_current()
559 char *buf = device->cap._BQC ? "_BQC" : "_BCQ"; in acpi_video_device_lcd_get_level_current()
561 status = acpi_evaluate_integer(device->dev->handle, buf, in acpi_video_device_lcd_get_level_current()
576 i < device->brightness->count; i++) in acpi_video_device_lcd_get_level_current()
577 if (device->brightness->levels[i] == *level) { in acpi_video_device_lcd_get_level_current()
578 device->brightness->curr = *level; in acpi_video_device_lcd_get_level_current()
585 acpi_handle_info(device->dev->handle, in acpi_video_device_lcd_get_level_current()
587 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_device_lcd_get_level_current()
592 * dev->brightness->curr is a cached value which stores in acpi_video_device_lcd_get_level_current()
597 acpi_handle_info(device->dev->handle, in acpi_video_device_lcd_get_level_current()
599 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_device_lcd_get_level_current()
603 *level = device->brightness->curr; in acpi_video_device_lcd_get_level_current()
621 return -ENODEV; in acpi_video_device_EDID()
627 return -EINVAL; in acpi_video_device_EDID()
629 status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer); in acpi_video_device_EDID()
631 return -ENODEV; in acpi_video_device_EDID()
635 if (obj && obj->type == ACPI_TYPE_BUFFER) in acpi_video_device_EDID()
638 acpi_handle_info(device->dev->handle, "Invalid _DDC data\n"); in acpi_video_device_EDID()
639 status = -EFAULT; in acpi_video_device_EDID()
663 * - the power changes from AC to DC (ACPI appendix B)
664 * - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
667 * - the power changes from AC to DC (ACPI appendix B)
668 * - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
670 * -EINVAL wrong arg.
678 if (!video->cap._DOS) in acpi_video_bus_DOS()
682 return -EINVAL; in acpi_video_bus_DOS()
683 video->dos_setting = (lcd_flag << 2) | bios_flag; in acpi_video_bus_DOS()
684 status = acpi_execute_simple_method(video->device->handle, "_DOS", in acpi_video_bus_DOS()
687 return -EIO; in acpi_video_bus_DOS()
699 return *(int *)a - *(int *)b; in acpi_video_cmp_level()
712 struct acpi_video_device_brightness *br = device->brightness; in acpi_video_bqc_quirk()
727 * (br->levels[2]) is likely to be 0, and if the number of levels in acpi_video_bqc_quirk()
744 * xbacklight -set 10; xbacklight -set 20; in acpi_video_bqc_quirk()
752 ? br->levels[ACPI_VIDEO_FIRST_LEVEL + 1] in acpi_video_bqc_quirk()
765 if (level < br->count) { in acpi_video_bqc_quirk()
766 if (br->flags._BCL_reversed) in acpi_video_bqc_quirk()
767 level = br->count - ACPI_VIDEO_FIRST_LEVEL - 1 - level; in acpi_video_bqc_quirk()
768 if (br->levels[level + ACPI_VIDEO_FIRST_LEVEL] == test_level) in acpi_video_bqc_quirk()
769 br->flags._BQC_use_index = 1; in acpi_video_bqc_quirk()
772 if (!br->flags._BQC_use_index) in acpi_video_bqc_quirk()
773 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_bqc_quirk()
790 if (ACPI_FAILURE(acpi_video_device_lcd_query_levels(device->handle, &obj))) { in acpi_video_get_levels()
791 acpi_handle_debug(device->handle, in acpi_video_get_levels()
793 result = -ENODEV; in acpi_video_get_levels()
797 if (obj->package.count < ACPI_VIDEO_FIRST_LEVEL) { in acpi_video_get_levels()
798 result = -EINVAL; in acpi_video_get_levels()
804 result = -ENOMEM; in acpi_video_get_levels()
813 br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL, in acpi_video_get_levels()
814 sizeof(*br->levels), in acpi_video_get_levels()
816 if (!br->levels) { in acpi_video_get_levels()
817 result = -ENOMEM; in acpi_video_get_levels()
821 for (i = 0; i < obj->package.count; i++) { in acpi_video_get_levels()
822 o = (union acpi_object *)&obj->package.elements[i]; in acpi_video_get_levels()
823 if (o->type != ACPI_TYPE_INTEGER) { in acpi_video_get_levels()
824 acpi_handle_info(device->handle, "Invalid data\n"); in acpi_video_get_levels()
827 value = (u32) o->integer.value; in acpi_video_get_levels()
830 && br->levels[count - 1] == value) in acpi_video_get_levels()
833 br->levels[count] = value; in acpi_video_get_levels()
835 if (br->levels[count] > max_level) in acpi_video_get_levels()
836 max_level = br->levels[count]; in acpi_video_get_levels()
842 * when machine is on AC/Battery in _BCL package. in acpi_video_get_levels()
847 if (br->levels[i] == br->levels[ACPI_VIDEO_AC_LEVEL]) in acpi_video_get_levels()
849 if (br->levels[i] == br->levels[ACPI_VIDEO_BATTERY_LEVEL]) in acpi_video_get_levels()
854 level_ac_battery = ACPI_VIDEO_FIRST_LEVEL - level_ac_battery; in acpi_video_get_levels()
855 br->flags._BCL_no_ac_battery_levels = 1; in acpi_video_get_levels()
856 for (i = (count - 1 + level_ac_battery); in acpi_video_get_levels()
857 i >= ACPI_VIDEO_FIRST_LEVEL; i--) in acpi_video_get_levels()
858 br->levels[i] = br->levels[i - level_ac_battery]; in acpi_video_get_levels()
861 acpi_handle_info(device->handle, in acpi_video_get_levels()
865 if (max_level == br->levels[ACPI_VIDEO_FIRST_LEVEL]) { in acpi_video_get_levels()
866 br->flags._BCL_reversed = 1; in acpi_video_get_levels()
867 sort(&br->levels[ACPI_VIDEO_FIRST_LEVEL], in acpi_video_get_levels()
868 count - ACPI_VIDEO_FIRST_LEVEL, in acpi_video_get_levels()
869 sizeof(br->levels[ACPI_VIDEO_FIRST_LEVEL]), in acpi_video_get_levels()
871 } else if (max_level != br->levels[count - 1]) in acpi_video_get_levels()
872 acpi_handle_info(device->handle, in acpi_video_get_levels()
875 br->count = count; in acpi_video_get_levels()
896 * Allocate and initialize device->brightness.
907 result = acpi_video_get_levels(device->dev, &br, &max_level); in acpi_video_init_brightness()
910 device->brightness = br; in acpi_video_init_brightness()
913 br->curr = level = max_level; in acpi_video_init_brightness()
915 if (!device->cap._BQC) in acpi_video_init_brightness()
930 if (!device->cap._BQC) in acpi_video_init_brightness()
940 for (i = ACPI_VIDEO_FIRST_LEVEL; i < br->count; i++) in acpi_video_init_brightness()
941 if (level == br->levels[i]) in acpi_video_init_brightness()
943 if (i == br->count || !level) in acpi_video_init_brightness()
951 acpi_handle_debug(device->dev->handle, "found %d brightness levels\n", in acpi_video_init_brightness()
952 br->count - ACPI_VIDEO_FIRST_LEVEL); in acpi_video_init_brightness()
957 kfree(br->levels); in acpi_video_init_brightness()
959 device->brightness = NULL; in acpi_video_init_brightness()
976 if (acpi_has_method(device->dev->handle, "_ADR")) in acpi_video_device_find_cap()
977 device->cap._ADR = 1; in acpi_video_device_find_cap()
978 if (acpi_has_method(device->dev->handle, "_BCL")) in acpi_video_device_find_cap()
979 device->cap._BCL = 1; in acpi_video_device_find_cap()
980 if (acpi_has_method(device->dev->handle, "_BCM")) in acpi_video_device_find_cap()
981 device->cap._BCM = 1; in acpi_video_device_find_cap()
982 if (acpi_has_method(device->dev->handle, "_BQC")) { in acpi_video_device_find_cap()
983 device->cap._BQC = 1; in acpi_video_device_find_cap()
984 } else if (acpi_has_method(device->dev->handle, "_BCQ")) { in acpi_video_device_find_cap()
985 acpi_handle_info(device->dev->handle, in acpi_video_device_find_cap()
987 device->cap._BCQ = 1; in acpi_video_device_find_cap()
990 if (acpi_has_method(device->dev->handle, "_DDC")) in acpi_video_device_find_cap()
991 device->cap._DDC = 1; in acpi_video_device_find_cap()
1006 if (acpi_has_method(video->device->handle, "_DOS")) in acpi_video_bus_find_cap()
1007 video->cap._DOS = 1; in acpi_video_bus_find_cap()
1008 if (acpi_has_method(video->device->handle, "_DOD")) in acpi_video_bus_find_cap()
1009 video->cap._DOD = 1; in acpi_video_bus_find_cap()
1010 if (acpi_has_method(video->device->handle, "_ROM")) in acpi_video_bus_find_cap()
1011 video->cap._ROM = 1; in acpi_video_bus_find_cap()
1012 if (acpi_has_method(video->device->handle, "_GPD")) in acpi_video_bus_find_cap()
1013 video->cap._GPD = 1; in acpi_video_bus_find_cap()
1014 if (acpi_has_method(video->device->handle, "_SPD")) in acpi_video_bus_find_cap()
1015 video->cap._SPD = 1; in acpi_video_bus_find_cap()
1016 if (acpi_has_method(video->device->handle, "_VPO")) in acpi_video_bus_find_cap()
1017 video->cap._VPO = 1; in acpi_video_bus_find_cap()
1027 acpi_status status = -ENOENT; in acpi_video_bus_check()
1031 return -EINVAL; in acpi_video_bus_check()
1033 dev = acpi_get_pci_dev(video->device->handle); in acpi_video_bus_check()
1035 return -ENODEV; in acpi_video_bus_check()
1044 if (video->cap._DOS || video->cap._DOD) { in acpi_video_bus_check()
1045 if (!video->cap._DOS) { in acpi_video_bus_check()
1047 acpi_device_bid(video->device)); in acpi_video_bus_check()
1049 video->flags.multihead = 1; in acpi_video_bus_check()
1054 if (video->cap._ROM) { in acpi_video_bus_check()
1055 video->flags.rom = 1; in acpi_video_bus_check()
1060 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) { in acpi_video_bus_check()
1061 video->flags.post = 1; in acpi_video_bus_check()
1069 * --------------------------------------------------------------------------
1071 * --------------------------------------------------------------------------
1081 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_attr()
1082 ids = &video->attached_array[i]; in acpi_video_get_device_attr()
1083 if ((ids->value.int_val & 0xffff) == device_id) in acpi_video_get_device_attr()
1084 return &ids->value.attrib; in acpi_video_get_device_attr()
1097 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_type()
1098 ids = &video->attached_array[i]; in acpi_video_get_device_type()
1099 if ((ids->value.int_val & 0xffff) == device_id) in acpi_video_get_device_type()
1100 return ids->value.int_val; in acpi_video_get_device_type()
1115 status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); in acpi_video_bus_get_one_device()
1122 dev_dbg(&device->dev, "Cannot attach\n"); in acpi_video_bus_get_one_device()
1123 return -ENOMEM; in acpi_video_bus_get_one_device()
1128 device->driver_data = data; in acpi_video_bus_get_one_device()
1130 data->device_id = device_id; in acpi_video_bus_get_one_device()
1131 data->video = video; in acpi_video_bus_get_one_device()
1132 data->dev = device; in acpi_video_bus_get_one_device()
1133 INIT_DELAYED_WORK(&data->switch_brightness_work, in acpi_video_bus_get_one_device()
1138 if (attribute && (attribute->device_id_scheme || device_id_scheme)) { in acpi_video_bus_get_one_device()
1139 switch (attribute->display_type) { in acpi_video_bus_get_one_device()
1141 data->flags.crt = 1; in acpi_video_bus_get_one_device()
1144 data->flags.tvout = 1; in acpi_video_bus_get_one_device()
1147 data->flags.dvi = 1; in acpi_video_bus_get_one_device()
1150 data->flags.lcd = 1; in acpi_video_bus_get_one_device()
1153 data->flags.unknown = 1; in acpi_video_bus_get_one_device()
1156 if (attribute->bios_can_detect) in acpi_video_bus_get_one_device()
1157 data->flags.bios = 1; in acpi_video_bus_get_one_device()
1161 /* Ignore bits 16 and 18-20 */ in acpi_video_bus_get_one_device()
1164 data->flags.crt = 1; in acpi_video_bus_get_one_device()
1167 data->flags.lcd = 1; in acpi_video_bus_get_one_device()
1170 data->flags.tvout = 1; in acpi_video_bus_get_one_device()
1173 data->flags.unknown = 1; in acpi_video_bus_get_one_device()
1180 if (data->cap._BCM && data->cap._BCL) in acpi_video_bus_get_one_device()
1183 mutex_lock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1184 list_add_tail(&data->entry, &video->video_device_list); in acpi_video_bus_get_one_device()
1185 mutex_unlock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1188 video->child_count++; in acpi_video_bus_get_one_device()
1208 mutex_lock(&video->device_list_lock); in acpi_video_device_rebind()
1210 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_device_rebind()
1213 mutex_unlock(&video->device_list_lock); in acpi_video_device_rebind()
1236 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_bind()
1237 ids = &video->attached_array[i]; in acpi_video_device_bind()
1238 if (device->device_id == (ids->value.int_val & 0xffff)) { in acpi_video_device_bind()
1239 ids->bind_info = device; in acpi_video_device_bind()
1240 acpi_handle_debug(video->device->handle, "%s: %d\n", in acpi_video_device_bind()
1248 struct acpi_video_bus *video = device->video; in acpi_video_device_in_dod()
1256 if (!video->attached_count || video->child_count > 8) in acpi_video_device_in_dod()
1259 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_in_dod()
1260 if ((video->attached_array[i].value.int_val & 0xfff) == in acpi_video_device_in_dod()
1261 (device->device_id & 0xfff)) in acpi_video_device_in_dod()
1289 if (!video->cap._DOD) in acpi_video_device_enumerate()
1292 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer); in acpi_video_device_enumerate()
1294 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1301 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { in acpi_video_device_enumerate()
1302 acpi_handle_info(video->device->handle, "Invalid _DOD data\n"); in acpi_video_device_enumerate()
1303 status = -EFAULT; in acpi_video_device_enumerate()
1307 acpi_handle_debug(video->device->handle, "Found %d video heads in _DOD\n", in acpi_video_device_enumerate()
1308 dod->package.count); in acpi_video_device_enumerate()
1310 active_list = kcalloc(1 + dod->package.count, in acpi_video_device_enumerate()
1314 status = -ENOMEM; in acpi_video_device_enumerate()
1319 for (i = 0; i < dod->package.count; i++) { in acpi_video_device_enumerate()
1320 obj = &dod->package.elements[i]; in acpi_video_device_enumerate()
1322 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_video_device_enumerate()
1323 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1328 active_list[count].value.int_val = obj->integer.value; in acpi_video_device_enumerate()
1331 acpi_handle_debug(video->device->handle, in acpi_video_device_enumerate()
1333 (int)obj->integer.value); in acpi_video_device_enumerate()
1338 kfree(video->attached_array); in acpi_video_device_enumerate()
1340 video->attached_array = active_list; in acpi_video_device_enumerate()
1341 video->attached_count = count; in acpi_video_device_enumerate()
1356 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { in acpi_video_get_next_level()
1357 l = device->brightness->levels[i]; in acpi_video_get_next_level()
1358 if (abs(l - level_current) < abs(delta)) { in acpi_video_get_next_level()
1359 delta = l - level_current; in acpi_video_get_next_level()
1366 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { in acpi_video_get_next_level()
1367 l = device->brightness->levels[i]; in acpi_video_get_next_level()
1399 int event = device->switch_brightness_event; in acpi_video_switch_brightness()
1400 int result = -EINVAL; in acpi_video_switch_brightness()
1403 if (!device->backlight) in acpi_video_switch_brightness()
1406 if (!device->brightness) in acpi_video_switch_brightness()
1420 backlight_force_update(device->backlight, in acpi_video_switch_brightness()
1425 acpi_handle_info(device->dev->handle, in acpi_video_switch_brightness()
1439 return -EINVAL; in acpi_video_get_edid()
1443 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_edid()
1444 video_device = video->attached_array[i].bind_info; in acpi_video_get_edid()
1450 if (!video_device->cap._DDC) in acpi_video_get_edid()
1456 if (!video_device->flags.crt) in acpi_video_get_edid()
1460 if (!video_device->flags.tvout) in acpi_video_get_edid()
1464 if (!video_device->flags.dvi) in acpi_video_get_edid()
1468 if (!video_device->flags.lcd) in acpi_video_get_edid()
1472 } else if (video_device->device_id != device_id) { in acpi_video_get_edid()
1479 buffer->type != ACPI_TYPE_BUFFER) { in acpi_video_get_edid()
1484 buffer->type != ACPI_TYPE_BUFFER) { in acpi_video_get_edid()
1489 *edid = buffer->buffer.pointer; in acpi_video_get_edid()
1493 return -ENODEV; in acpi_video_get_edid()
1536 if (!video || !video->input) in acpi_video_bus_notify()
1539 input = video->input; in acpi_video_bus_notify()
1565 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_video_bus_notify()
1588 video_device->switch_brightness_event = event; in brightness_switch_event()
1589 schedule_delayed_work(&video_device->switch_brightness_work, HZ / 10); in brightness_switch_event()
1603 device = video_device->dev; in acpi_video_device_notify()
1604 bus = video_device->video; in acpi_video_device_notify()
1605 input = bus->input; in acpi_video_device_notify()
1608 if (video_device->backlight) in acpi_video_device_notify()
1609 backlight_force_update(video_device->backlight, in acpi_video_device_notify()
1667 dev_info(&video->device->dev, "Restoring backlight state\n"); in acpi_video_resume()
1669 for (i = 0; i < video->attached_count; i++) { in acpi_video_resume()
1670 video_device = video->attached_array[i].bind_info; in acpi_video_resume()
1671 if (video_device && video_device->brightness) in acpi_video_resume()
1673 video_device->brightness->curr); in acpi_video_resume()
1688 if (handle == device->handle) in acpi_video_bus_match()
1720 acpi_get_parent(device->dev->handle, &acpi_parent); in acpi_video_dev_register_backlight()
1724 parent = &pdev->dev; in acpi_video_dev_register_backlight()
1731 device->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; in acpi_video_dev_register_backlight()
1732 device->backlight = backlight_device_register(name, in acpi_video_dev_register_backlight()
1738 if (IS_ERR(device->backlight)) { in acpi_video_dev_register_backlight()
1739 device->backlight = NULL; in acpi_video_dev_register_backlight()
1747 device->backlight->props.brightness = in acpi_video_dev_register_backlight()
1748 acpi_video_get_brightness(device->backlight); in acpi_video_dev_register_backlight()
1750 device->cooling_dev = thermal_cooling_device_register("LCD", in acpi_video_dev_register_backlight()
1751 device->dev, &video_cooling_ops); in acpi_video_dev_register_backlight()
1752 if (IS_ERR(device->cooling_dev)) { in acpi_video_dev_register_backlight()
1757 * -- dtor in acpi_video_dev_register_backlight()
1759 device->cooling_dev = NULL; in acpi_video_dev_register_backlight()
1763 dev_info(&device->dev->dev, "registered as cooling_device%d\n", in acpi_video_dev_register_backlight()
1764 device->cooling_dev->id); in acpi_video_dev_register_backlight()
1765 result = sysfs_create_link(&device->dev->dev.kobj, in acpi_video_dev_register_backlight()
1766 &device->cooling_dev->device.kobj, in acpi_video_dev_register_backlight()
1771 result = sysfs_create_link(&device->cooling_dev->device.kobj, in acpi_video_dev_register_backlight()
1772 &device->dev->dev.kobj, "device"); in acpi_video_dev_register_backlight()
1782 mutex_lock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1783 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_run_bcl_for_osi()
1784 if (!acpi_video_device_lcd_query_levels(dev->dev->handle, &levels)) in acpi_video_run_bcl_for_osi()
1787 mutex_unlock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1797 dev_dbg(&dev->dev->dev, "not in _DOD list, ignore\n"); in acpi_video_should_register_backlight()
1802 return dev->flags.lcd; in acpi_video_should_register_backlight()
1810 if (video->backlight_registered) in acpi_video_bus_register_backlight()
1816 mutex_lock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1817 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_bus_register_backlight()
1821 mutex_unlock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1823 video->backlight_registered = true; in acpi_video_bus_register_backlight()
1825 video->pm_nb.notifier_call = acpi_video_resume; in acpi_video_bus_register_backlight()
1826 video->pm_nb.priority = 0; in acpi_video_bus_register_backlight()
1827 return register_pm_notifier(&video->pm_nb); in acpi_video_bus_register_backlight()
1832 if (device->backlight) { in acpi_video_dev_unregister_backlight()
1833 backlight_device_unregister(device->backlight); in acpi_video_dev_unregister_backlight()
1834 device->backlight = NULL; in acpi_video_dev_unregister_backlight()
1836 if (device->brightness) { in acpi_video_dev_unregister_backlight()
1837 kfree(device->brightness->levels); in acpi_video_dev_unregister_backlight()
1838 kfree(device->brightness); in acpi_video_dev_unregister_backlight()
1839 device->brightness = NULL; in acpi_video_dev_unregister_backlight()
1841 if (device->cooling_dev) { in acpi_video_dev_unregister_backlight()
1842 sysfs_remove_link(&device->dev->dev.kobj, "thermal_cooling"); in acpi_video_dev_unregister_backlight()
1843 sysfs_remove_link(&device->cooling_dev->device.kobj, "device"); in acpi_video_dev_unregister_backlight()
1844 thermal_cooling_device_unregister(device->cooling_dev); in acpi_video_dev_unregister_backlight()
1845 device->cooling_dev = NULL; in acpi_video_dev_unregister_backlight()
1854 if (!video->backlight_registered) in acpi_video_bus_unregister_backlight()
1857 error = unregister_pm_notifier(&video->pm_nb); in acpi_video_bus_unregister_backlight()
1859 mutex_lock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1860 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_unregister_backlight()
1862 mutex_unlock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1864 video->backlight_registered = false; in acpi_video_bus_unregister_backlight()
1872 struct acpi_device *adev = device->dev; in acpi_video_dev_add_notify_handler()
1874 status = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, in acpi_video_dev_add_notify_handler()
1877 dev_err(&adev->dev, "Error installing notify handler\n"); in acpi_video_dev_add_notify_handler()
1879 device->flags.notify = 1; in acpi_video_dev_add_notify_handler()
1888 video->input = input = input_allocate_device(); in acpi_video_bus_add_notify_handler()
1890 error = -ENOMEM; in acpi_video_bus_add_notify_handler()
1898 snprintf(video->phys, sizeof(video->phys), in acpi_video_bus_add_notify_handler()
1899 "%s/video/input0", acpi_device_hid(video->device)); in acpi_video_bus_add_notify_handler()
1901 input->name = acpi_device_name(video->device); in acpi_video_bus_add_notify_handler()
1902 input->phys = video->phys; in acpi_video_bus_add_notify_handler()
1903 input->id.bustype = BUS_HOST; in acpi_video_bus_add_notify_handler()
1904 input->id.product = 0x06; in acpi_video_bus_add_notify_handler()
1905 input->dev.parent = &video->device->dev; in acpi_video_bus_add_notify_handler()
1906 input->evbit[0] = BIT(EV_KEY); in acpi_video_bus_add_notify_handler()
1907 set_bit(KEY_SWITCHVIDEOMODE, input->keybit); in acpi_video_bus_add_notify_handler()
1908 set_bit(KEY_VIDEO_NEXT, input->keybit); in acpi_video_bus_add_notify_handler()
1909 set_bit(KEY_VIDEO_PREV, input->keybit); in acpi_video_bus_add_notify_handler()
1910 set_bit(KEY_BRIGHTNESS_CYCLE, input->keybit); in acpi_video_bus_add_notify_handler()
1911 set_bit(KEY_BRIGHTNESSUP, input->keybit); in acpi_video_bus_add_notify_handler()
1912 set_bit(KEY_BRIGHTNESSDOWN, input->keybit); in acpi_video_bus_add_notify_handler()
1913 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); in acpi_video_bus_add_notify_handler()
1914 set_bit(KEY_DISPLAY_OFF, input->keybit); in acpi_video_bus_add_notify_handler()
1920 mutex_lock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1921 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_add_notify_handler()
1923 mutex_unlock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1931 video->input = NULL; in acpi_video_bus_add_notify_handler()
1938 if (dev->flags.notify) { in acpi_video_dev_remove_notify_handler()
1939 acpi_remove_notify_handler(dev->dev->handle, ACPI_DEVICE_NOTIFY, in acpi_video_dev_remove_notify_handler()
1941 dev->flags.notify = 0; in acpi_video_dev_remove_notify_handler()
1949 mutex_lock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1950 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_remove_notify_handler()
1952 mutex_unlock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1955 input_unregister_device(video->input); in acpi_video_bus_remove_notify_handler()
1956 video->input = NULL; in acpi_video_bus_remove_notify_handler()
1963 mutex_lock(&video->device_list_lock); in acpi_video_bus_put_devices()
1964 list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { in acpi_video_bus_put_devices()
1965 list_del(&dev->entry); in acpi_video_bus_put_devices()
1968 mutex_unlock(&video->device_list_lock); in acpi_video_bus_put_devices()
1983 acpi_dev_parent(device)->handle, 1, in acpi_video_bus_add()
1993 return -ENODEV; in acpi_video_bus_add()
1998 return -ENOMEM; in acpi_video_bus_add()
2001 if (!strcmp(device->pnp.bus_id, "VID")) { in acpi_video_bus_add()
2003 device->pnp.bus_id[3] = '0' + instance; in acpi_video_bus_add()
2007 if (!strcmp(device->pnp.bus_id, "VGA")) { in acpi_video_bus_add()
2009 device->pnp.bus_id[3] = '0' + instance; in acpi_video_bus_add()
2013 video->device = device; in acpi_video_bus_add()
2016 device->driver_data = video; in acpi_video_bus_add()
2023 mutex_init(&video->device_list_lock); in acpi_video_bus_add()
2024 INIT_LIST_HEAD(&video->video_device_list); in acpi_video_bus_add()
2036 pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n", in acpi_video_bus_add()
2038 video->flags.multihead ? "yes" : "no", in acpi_video_bus_add()
2039 video->flags.rom ? "yes" : "no", in acpi_video_bus_add()
2040 video->flags.post ? "yes" : "no"); in acpi_video_bus_add()
2042 list_add_tail(&video->entry, &video_bus_head); in acpi_video_bus_add()
2046 * If backlight-type auto-detection is used then a native backlight may in acpi_video_bus_add()
2051 * Register the backlight now when not using auto-detection, so that in acpi_video_bus_add()
2052 * when the kernel cmdline or DMI-quirks are used the backlight will in acpi_video_bus_add()
2075 list_del(&video->entry); in acpi_video_bus_add()
2080 kfree(video->attached_array); in acpi_video_bus_add()
2083 device->driver_data = NULL; in acpi_video_bus_add()
2102 list_del(&video->entry); in acpi_video_bus_remove()
2109 kfree(video->attached_array); in acpi_video_bus_remove()
2115 if (dev->device == 0x00D1) in is_i740()
2117 if (dev->device == 0x7000) in is_i740()
2129 if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) in intel_opregion_present()
2131 if (dev->vendor != PCI_VENDOR_ID_INTEL) in intel_opregion_present()
2144 /* Check if the chassis-type indicates there is no builtin LCD panel */
2159 case 0x04: /* Low Profile Desktop */ in dmi_is_desktop()
2177 * 2.1 Report a desktop/server DMI chassis-type, or
2178 * 2.2 Are an ACPI-reduced-hardware platform (and thus won't use the EC for
2208 if (only_lcd == -1) in acpi_video_register()
2273 * acpi_video_register() will report -ENODEV later as well due in acpi_video_init()