Lines Matching +full:cap +full:- +full:get
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");
120 u8 _ROM:1; /* Get ROM Data */
121 u8 _GPD:1; /* Get POST Device */
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. */
163 struct acpi_video_bus_cap cap; member
188 u8 _BQC:1; /* Get current brightness level */
196 struct acpi_video_device_cap cap; member
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_video_device *video = cooling_dev->devdata; in video_get_max_state()
258 *state = video->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; in video_get_max_state()
265 struct acpi_video_device *video = cooling_dev->devdata; in video_get_cur_state()
270 return -EINVAL; in video_get_cur_state()
271 for (offset = ACPI_VIDEO_FIRST_LEVEL; offset < video->brightness->count; in video_get_cur_state()
273 if (level == video->brightness->levels[offset]) { in video_get_cur_state()
274 *state = video->brightness->count - offset - 1; in video_get_cur_state()
278 return -EINVAL; in video_get_cur_state()
284 struct acpi_video_device *video = cooling_dev->devdata; in video_set_cur_state()
287 if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL) in video_set_cur_state()
288 return -EINVAL; in video_set_cur_state()
290 state = video->brightness->count - state; in video_set_cur_state()
291 level = video->brightness->levels[state - 1]; in video_set_cur_state()
302 * --------------------------------------------------------------------------
304 * --------------------------------------------------------------------------
322 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { in acpi_video_device_lcd_query_levels()
324 status = -EFAULT; in acpi_video_device_lcd_query_levels()
344 status = acpi_execute_simple_method(device->dev->handle, in acpi_video_device_lcd_set_level()
347 acpi_handle_info(device->dev->handle, "_BCM evaluation failed\n"); in acpi_video_device_lcd_set_level()
348 return -EIO; in acpi_video_device_lcd_set_level()
351 device->brightness->curr = level; in acpi_video_device_lcd_set_level()
352 for (state = ACPI_VIDEO_FIRST_LEVEL; state < device->brightness->count; in acpi_video_device_lcd_set_level()
354 if (level == device->brightness->levels[state]) { in acpi_video_device_lcd_set_level()
355 if (device->backlight) in acpi_video_device_lcd_set_level()
356 device->backlight->props.brightness = in acpi_video_device_lcd_set_level()
357 state - ACPI_VIDEO_FIRST_LEVEL; in acpi_video_device_lcd_set_level()
361 acpi_handle_info(device->dev->handle, "Current brightness invalid\n"); in acpi_video_device_lcd_set_level()
362 return -EINVAL; in acpi_video_device_lcd_set_level()
367 * the _BQC return value to get the actual current brightness level
391 if (report_key_events == -1) in video_set_report_key_events()
392 report_key_events = (uintptr_t)id->driver_data; in video_set_report_key_events()
399 if (hw_changes_brightness == -1) in video_hw_changes_brightness()
477 * Some machines report wrong key events on the acpi-bus, suppress
479 * around events which are plain wrong. In some cases we get double
480 * events, in this case acpi-video is considered the canonical source
483 * vendor acpi/wmi driver or by using /lib/udev/hwdb.d/60-keyboard.hwdb
536 if (device->brightness->flags._BQC_use_index) { in acpi_video_bqc_value_to_level()
542 if (device->brightness->flags._BCL_reversed) in acpi_video_bqc_value_to_level()
543 bqc_value = device->brightness->count - in acpi_video_bqc_value_to_level()
544 ACPI_VIDEO_FIRST_LEVEL - 1 - bqc_value; in acpi_video_bqc_value_to_level()
546 level = device->brightness->levels[bqc_value + in acpi_video_bqc_value_to_level()
564 if (device->cap._BQC || device->cap._BCQ) { in acpi_video_device_lcd_get_level_current()
565 char *buf = device->cap._BQC ? "_BQC" : "_BCQ"; in acpi_video_device_lcd_get_level_current()
567 status = acpi_evaluate_integer(device->dev->handle, buf, in acpi_video_device_lcd_get_level_current()
582 i < device->brightness->count; i++) in acpi_video_device_lcd_get_level_current()
583 if (device->brightness->levels[i] == *level) { in acpi_video_device_lcd_get_level_current()
584 device->brightness->curr = *level; in acpi_video_device_lcd_get_level_current()
591 acpi_handle_info(device->dev->handle, in acpi_video_device_lcd_get_level_current()
593 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_device_lcd_get_level_current()
598 * dev->brightness->curr is a cached value which stores in acpi_video_device_lcd_get_level_current()
603 acpi_handle_info(device->dev->handle, in acpi_video_device_lcd_get_level_current()
605 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_device_lcd_get_level_current()
609 *level = device->brightness->curr; in acpi_video_device_lcd_get_level_current()
614 * acpi_video_device_EDID() - Get EDID from ACPI _DDC
619 * Get EDID from ACPI _DDC. On success, a pointer to the EDID data is written
639 return -ENODEV; in acpi_video_device_EDID()
641 return -EINVAL; in acpi_video_device_EDID()
645 status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer); in acpi_video_device_EDID()
647 return -ENODEV; in acpi_video_device_EDID()
651 if (obj && obj->type == ACPI_TYPE_BUFFER) { in acpi_video_device_EDID()
652 *edid = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL); in acpi_video_device_EDID()
653 ret = *edid ? obj->buffer.length : -ENOMEM; in acpi_video_device_EDID()
655 acpi_handle_debug(device->dev->handle, in acpi_video_device_EDID()
657 ret = -EFAULT; in acpi_video_device_EDID()
681 * - the power changes from AC to DC (ACPI appendix B)
682 * - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
685 * - the power changes from AC to DC (ACPI appendix B)
686 * - a brightness hotkey gets pressed (implied by Win7/8 backlight docs)
688 * -EINVAL wrong arg.
696 if (!video->cap._DOS) in acpi_video_bus_DOS()
700 return -EINVAL; in acpi_video_bus_DOS()
701 video->dos_setting = (lcd_flag << 2) | bios_flag; in acpi_video_bus_DOS()
702 status = acpi_execute_simple_method(video->device->handle, "_DOS", in acpi_video_bus_DOS()
705 return -EIO; in acpi_video_bus_DOS()
717 return *(int *)a - *(int *)b; in acpi_video_cmp_level()
730 struct acpi_video_device_brightness *br = device->brightness; in acpi_video_bqc_quirk()
745 * (br->levels[2]) is likely to be 0, and if the number of levels in acpi_video_bqc_quirk()
762 * xbacklight -set 10; xbacklight -set 20; in acpi_video_bqc_quirk()
770 ? br->levels[ACPI_VIDEO_FIRST_LEVEL + 1] in acpi_video_bqc_quirk()
783 if (level < br->count) { in acpi_video_bqc_quirk()
784 if (br->flags._BCL_reversed) in acpi_video_bqc_quirk()
785 level = br->count - ACPI_VIDEO_FIRST_LEVEL - 1 - level; in acpi_video_bqc_quirk()
786 if (br->levels[level + ACPI_VIDEO_FIRST_LEVEL] == test_level) in acpi_video_bqc_quirk()
787 br->flags._BQC_use_index = 1; in acpi_video_bqc_quirk()
790 if (!br->flags._BQC_use_index) in acpi_video_bqc_quirk()
791 device->cap._BQC = device->cap._BCQ = 0; in acpi_video_bqc_quirk()
808 if (ACPI_FAILURE(acpi_video_device_lcd_query_levels(device->handle, &obj))) { in acpi_video_get_levels()
809 acpi_handle_debug(device->handle, in acpi_video_get_levels()
811 result = -ENODEV; in acpi_video_get_levels()
815 if (obj->package.count < ACPI_VIDEO_FIRST_LEVEL) { in acpi_video_get_levels()
816 result = -EINVAL; in acpi_video_get_levels()
822 result = -ENOMEM; in acpi_video_get_levels()
831 br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL, in acpi_video_get_levels()
832 sizeof(*br->levels), in acpi_video_get_levels()
834 if (!br->levels) { in acpi_video_get_levels()
835 result = -ENOMEM; in acpi_video_get_levels()
839 for (i = 0; i < obj->package.count; i++) { in acpi_video_get_levels()
840 o = (union acpi_object *)&obj->package.elements[i]; in acpi_video_get_levels()
841 if (o->type != ACPI_TYPE_INTEGER) { in acpi_video_get_levels()
842 acpi_handle_info(device->handle, "Invalid data\n"); in acpi_video_get_levels()
845 value = (u32) o->integer.value; in acpi_video_get_levels()
848 && br->levels[count - 1] == value) in acpi_video_get_levels()
851 br->levels[count] = value; in acpi_video_get_levels()
853 if (br->levels[count] > max_level) in acpi_video_get_levels()
854 max_level = br->levels[count]; in acpi_video_get_levels()
865 if (br->levels[i] == br->levels[ACPI_VIDEO_AC_LEVEL]) in acpi_video_get_levels()
867 if (br->levels[i] == br->levels[ACPI_VIDEO_BATTERY_LEVEL]) in acpi_video_get_levels()
872 level_ac_battery = ACPI_VIDEO_FIRST_LEVEL - level_ac_battery; in acpi_video_get_levels()
873 br->flags._BCL_no_ac_battery_levels = 1; in acpi_video_get_levels()
874 for (i = (count - 1 + level_ac_battery); in acpi_video_get_levels()
875 i >= ACPI_VIDEO_FIRST_LEVEL; i--) in acpi_video_get_levels()
876 br->levels[i] = br->levels[i - level_ac_battery]; in acpi_video_get_levels()
879 acpi_handle_info(device->handle, in acpi_video_get_levels()
883 if (max_level == br->levels[ACPI_VIDEO_FIRST_LEVEL]) { in acpi_video_get_levels()
884 br->flags._BCL_reversed = 1; in acpi_video_get_levels()
885 sort(&br->levels[ACPI_VIDEO_FIRST_LEVEL], in acpi_video_get_levels()
886 count - ACPI_VIDEO_FIRST_LEVEL, in acpi_video_get_levels()
887 sizeof(br->levels[ACPI_VIDEO_FIRST_LEVEL]), in acpi_video_get_levels()
889 } else if (max_level != br->levels[count - 1]) in acpi_video_get_levels()
890 acpi_handle_info(device->handle, in acpi_video_get_levels()
893 br->count = count; in acpi_video_get_levels()
914 * Allocate and initialize device->brightness.
925 result = acpi_video_get_levels(device->dev, &br, &max_level); in acpi_video_init_brightness()
928 device->brightness = br; in acpi_video_init_brightness()
931 br->curr = level = max_level; in acpi_video_init_brightness()
933 if (!device->cap._BQC) in acpi_video_init_brightness()
945 * cap._BQC may get cleared due to _BQC is found to be broken in acpi_video_init_brightness()
948 if (!device->cap._BQC) in acpi_video_init_brightness()
958 for (i = ACPI_VIDEO_FIRST_LEVEL; i < br->count; i++) in acpi_video_init_brightness()
959 if (level == br->levels[i]) in acpi_video_init_brightness()
961 if (i == br->count || !level) in acpi_video_init_brightness()
969 acpi_handle_debug(device->dev->handle, "found %d brightness levels\n", in acpi_video_init_brightness()
970 br->count - ACPI_VIDEO_FIRST_LEVEL); in acpi_video_init_brightness()
975 kfree(br->levels); in acpi_video_init_brightness()
977 device->brightness = NULL; in acpi_video_init_brightness()
994 if (acpi_has_method(device->dev->handle, "_ADR")) in acpi_video_device_find_cap()
995 device->cap._ADR = 1; in acpi_video_device_find_cap()
996 if (acpi_has_method(device->dev->handle, "_BCL")) in acpi_video_device_find_cap()
997 device->cap._BCL = 1; in acpi_video_device_find_cap()
998 if (acpi_has_method(device->dev->handle, "_BCM")) in acpi_video_device_find_cap()
999 device->cap._BCM = 1; in acpi_video_device_find_cap()
1000 if (acpi_has_method(device->dev->handle, "_BQC")) { in acpi_video_device_find_cap()
1001 device->cap._BQC = 1; in acpi_video_device_find_cap()
1002 } else if (acpi_has_method(device->dev->handle, "_BCQ")) { in acpi_video_device_find_cap()
1003 acpi_handle_info(device->dev->handle, in acpi_video_device_find_cap()
1005 device->cap._BCQ = 1; in acpi_video_device_find_cap()
1008 if (acpi_has_method(device->dev->handle, "_DDC")) in acpi_video_device_find_cap()
1009 device->cap._DDC = 1; in acpi_video_device_find_cap()
1024 if (acpi_has_method(video->device->handle, "_DOS")) in acpi_video_bus_find_cap()
1025 video->cap._DOS = 1; in acpi_video_bus_find_cap()
1026 if (acpi_has_method(video->device->handle, "_DOD")) in acpi_video_bus_find_cap()
1027 video->cap._DOD = 1; in acpi_video_bus_find_cap()
1028 if (acpi_has_method(video->device->handle, "_ROM")) in acpi_video_bus_find_cap()
1029 video->cap._ROM = 1; in acpi_video_bus_find_cap()
1030 if (acpi_has_method(video->device->handle, "_GPD")) in acpi_video_bus_find_cap()
1031 video->cap._GPD = 1; in acpi_video_bus_find_cap()
1032 if (acpi_has_method(video->device->handle, "_SPD")) in acpi_video_bus_find_cap()
1033 video->cap._SPD = 1; in acpi_video_bus_find_cap()
1034 if (acpi_has_method(video->device->handle, "_VPO")) in acpi_video_bus_find_cap()
1035 video->cap._VPO = 1; in acpi_video_bus_find_cap()
1045 acpi_status status = -ENOENT; in acpi_video_bus_check()
1049 return -EINVAL; in acpi_video_bus_check()
1051 dev = acpi_get_pci_dev(video->device->handle); in acpi_video_bus_check()
1053 return -ENODEV; in acpi_video_bus_check()
1062 if (video->cap._DOS || video->cap._DOD) { in acpi_video_bus_check()
1063 if (!video->cap._DOS) { in acpi_video_bus_check()
1065 acpi_device_bid(video->device)); in acpi_video_bus_check()
1067 video->flags.multihead = 1; in acpi_video_bus_check()
1072 if (video->cap._ROM) { in acpi_video_bus_check()
1073 video->flags.rom = 1; in acpi_video_bus_check()
1078 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) { in acpi_video_bus_check()
1079 video->flags.post = 1; in acpi_video_bus_check()
1087 * --------------------------------------------------------------------------
1089 * --------------------------------------------------------------------------
1099 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_attr()
1100 ids = &video->attached_array[i]; in acpi_video_get_device_attr()
1101 if ((ids->value.int_val & 0xffff) == device_id) in acpi_video_get_device_attr()
1102 return &ids->value.attrib; in acpi_video_get_device_attr()
1115 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_type()
1116 ids = &video->attached_array[i]; in acpi_video_get_device_type()
1117 if ((ids->value.int_val & 0xffff) == device_id) in acpi_video_get_device_type()
1118 return ids->value.int_val; in acpi_video_get_device_type()
1133 status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); in acpi_video_bus_get_one_device()
1140 dev_dbg(&device->dev, "Cannot attach\n"); in acpi_video_bus_get_one_device()
1141 return -ENOMEM; in acpi_video_bus_get_one_device()
1147 data->device_id = device_id; in acpi_video_bus_get_one_device()
1148 data->video = video; in acpi_video_bus_get_one_device()
1149 data->dev = device; in acpi_video_bus_get_one_device()
1150 INIT_DELAYED_WORK(&data->switch_brightness_work, in acpi_video_bus_get_one_device()
1155 if (attribute && (attribute->device_id_scheme || device_id_scheme)) { in acpi_video_bus_get_one_device()
1156 switch (attribute->display_type) { in acpi_video_bus_get_one_device()
1158 data->flags.crt = 1; in acpi_video_bus_get_one_device()
1161 data->flags.tvout = 1; in acpi_video_bus_get_one_device()
1164 data->flags.dvi = 1; in acpi_video_bus_get_one_device()
1167 data->flags.lcd = 1; in acpi_video_bus_get_one_device()
1170 data->flags.unknown = 1; in acpi_video_bus_get_one_device()
1173 if (attribute->bios_can_detect) in acpi_video_bus_get_one_device()
1174 data->flags.bios = 1; in acpi_video_bus_get_one_device()
1178 /* Ignore bits 16 and 18-20 */ in acpi_video_bus_get_one_device()
1181 data->flags.crt = 1; in acpi_video_bus_get_one_device()
1184 data->flags.lcd = 1; in acpi_video_bus_get_one_device()
1187 data->flags.tvout = 1; in acpi_video_bus_get_one_device()
1190 data->flags.unknown = 1; in acpi_video_bus_get_one_device()
1197 if (data->cap._BCM && data->cap._BCL) in acpi_video_bus_get_one_device()
1200 mutex_lock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1201 list_add_tail(&data->entry, &video->video_device_list); in acpi_video_bus_get_one_device()
1202 mutex_unlock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1205 video->child_count++; in acpi_video_bus_get_one_device()
1225 mutex_lock(&video->device_list_lock); in acpi_video_device_rebind()
1227 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_device_rebind()
1230 mutex_unlock(&video->device_list_lock); in acpi_video_device_rebind()
1253 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_bind()
1254 ids = &video->attached_array[i]; in acpi_video_device_bind()
1255 if (device->device_id == (ids->value.int_val & 0xffff)) { in acpi_video_device_bind()
1256 ids->bind_info = device; in acpi_video_device_bind()
1257 acpi_handle_debug(video->device->handle, "%s: %d\n", in acpi_video_device_bind()
1265 struct acpi_video_bus *video = device->video; in acpi_video_device_in_dod()
1273 if (!video->attached_count || video->child_count > 8) in acpi_video_device_in_dod()
1276 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_in_dod()
1277 if ((video->attached_array[i].value.int_val & 0xfff) == in acpi_video_device_in_dod()
1278 (device->device_id & 0xfff)) in acpi_video_device_in_dod()
1306 if (!video->cap._DOD) in acpi_video_device_enumerate()
1309 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer); in acpi_video_device_enumerate()
1311 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1318 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { in acpi_video_device_enumerate()
1319 acpi_handle_info(video->device->handle, "Invalid _DOD data\n"); in acpi_video_device_enumerate()
1320 status = -EFAULT; in acpi_video_device_enumerate()
1324 acpi_handle_debug(video->device->handle, "Found %d video heads in _DOD\n", in acpi_video_device_enumerate()
1325 dod->package.count); in acpi_video_device_enumerate()
1327 active_list = kcalloc(1 + dod->package.count, in acpi_video_device_enumerate()
1331 status = -ENOMEM; in acpi_video_device_enumerate()
1336 for (i = 0; i < dod->package.count; i++) { in acpi_video_device_enumerate()
1337 obj = &dod->package.elements[i]; in acpi_video_device_enumerate()
1339 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_video_device_enumerate()
1340 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1345 active_list[count].value.int_val = obj->integer.value; in acpi_video_device_enumerate()
1348 acpi_handle_debug(video->device->handle, in acpi_video_device_enumerate()
1350 (int)obj->integer.value); in acpi_video_device_enumerate()
1355 kfree(video->attached_array); in acpi_video_device_enumerate()
1357 video->attached_array = active_list; in acpi_video_device_enumerate()
1358 video->attached_count = count; in acpi_video_device_enumerate()
1373 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { in acpi_video_get_next_level()
1374 l = device->brightness->levels[i]; in acpi_video_get_next_level()
1375 if (abs(l - level_current) < abs(delta)) { in acpi_video_get_next_level()
1376 delta = l - level_current; in acpi_video_get_next_level()
1383 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { in acpi_video_get_next_level()
1384 l = device->brightness->levels[i]; in acpi_video_get_next_level()
1416 int event = device->switch_brightness_event; in acpi_video_switch_brightness()
1417 int result = -EINVAL; in acpi_video_switch_brightness()
1420 if (!device->backlight) in acpi_video_switch_brightness()
1423 if (!device->brightness) in acpi_video_switch_brightness()
1437 backlight_force_update(device->backlight, in acpi_video_switch_brightness()
1442 acpi_handle_info(device->dev->handle, in acpi_video_switch_brightness()
1454 return -EINVAL; in acpi_video_get_edid()
1458 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_edid()
1459 video_device = video->attached_array[i].bind_info; in acpi_video_get_edid()
1464 if (!video_device->cap._DDC) in acpi_video_get_edid()
1470 if (!video_device->flags.crt) in acpi_video_get_edid()
1474 if (!video_device->flags.tvout) in acpi_video_get_edid()
1478 if (!video_device->flags.dvi) in acpi_video_get_edid()
1482 if (!video_device->flags.lcd) in acpi_video_get_edid()
1486 } else if (video_device->device_id != device_id) { in acpi_video_get_edid()
1490 for (length = 512; length > 0; length -= 128) { in acpi_video_get_edid()
1497 return -ENODEV; in acpi_video_get_edid()
1540 if (!video || !video->input) in acpi_video_bus_notify()
1543 input = video->input; in acpi_video_bus_notify()
1569 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_video_bus_notify()
1592 video_device->switch_brightness_event = event; in brightness_switch_event()
1593 schedule_delayed_work(&video_device->switch_brightness_work, HZ / 10); in brightness_switch_event()
1607 device = video_device->dev; in acpi_video_device_notify()
1608 bus = video_device->video; in acpi_video_device_notify()
1609 input = bus->input; in acpi_video_device_notify()
1612 if (video_device->backlight) in acpi_video_device_notify()
1613 backlight_force_update(video_device->backlight, in acpi_video_device_notify()
1671 dev_info(&video->device->dev, "Restoring backlight state\n"); in acpi_video_resume()
1673 for (i = 0; i < video->attached_count; i++) { in acpi_video_resume()
1674 video_device = video->attached_array[i].bind_info; in acpi_video_resume()
1675 if (video_device && video_device->brightness) in acpi_video_resume()
1677 video_device->brightness->curr); in acpi_video_resume()
1692 if (handle == device->handle) in acpi_video_bus_match()
1724 if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) { in acpi_video_dev_register_backlight()
1727 parent = &pdev->dev; in acpi_video_dev_register_backlight()
1735 device->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; in acpi_video_dev_register_backlight()
1736 device->backlight = backlight_device_register(name, in acpi_video_dev_register_backlight()
1742 if (IS_ERR(device->backlight)) { in acpi_video_dev_register_backlight()
1743 device->backlight = NULL; in acpi_video_dev_register_backlight()
1751 device->backlight->props.brightness = in acpi_video_dev_register_backlight()
1752 acpi_video_get_brightness(device->backlight); in acpi_video_dev_register_backlight()
1754 device->cooling_dev = thermal_cooling_device_register("LCD", device, in acpi_video_dev_register_backlight()
1756 if (IS_ERR(device->cooling_dev)) { in acpi_video_dev_register_backlight()
1761 * -- dtor in acpi_video_dev_register_backlight()
1763 device->cooling_dev = NULL; in acpi_video_dev_register_backlight()
1767 dev_info(&device->dev->dev, "registered as cooling_device%d\n", in acpi_video_dev_register_backlight()
1768 device->cooling_dev->id); in acpi_video_dev_register_backlight()
1769 result = sysfs_create_link(&device->dev->dev.kobj, in acpi_video_dev_register_backlight()
1770 &device->cooling_dev->device.kobj, in acpi_video_dev_register_backlight()
1775 result = sysfs_create_link(&device->cooling_dev->device.kobj, in acpi_video_dev_register_backlight()
1776 &device->dev->dev.kobj, "device"); in acpi_video_dev_register_backlight()
1786 mutex_lock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1787 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_run_bcl_for_osi()
1788 if (!acpi_video_device_lcd_query_levels(dev->dev->handle, &levels)) in acpi_video_run_bcl_for_osi()
1791 mutex_unlock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1801 dev_dbg(&dev->dev->dev, "not in _DOD list, ignore\n"); in acpi_video_should_register_backlight()
1806 return dev->flags.lcd; in acpi_video_should_register_backlight()
1814 if (video->backlight_registered) in acpi_video_bus_register_backlight()
1820 mutex_lock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1821 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_bus_register_backlight()
1825 mutex_unlock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1827 video->backlight_registered = true; in acpi_video_bus_register_backlight()
1829 video->pm_nb.notifier_call = acpi_video_resume; in acpi_video_bus_register_backlight()
1830 video->pm_nb.priority = 0; in acpi_video_bus_register_backlight()
1831 return register_pm_notifier(&video->pm_nb); in acpi_video_bus_register_backlight()
1836 if (device->backlight) { in acpi_video_dev_unregister_backlight()
1837 backlight_device_unregister(device->backlight); in acpi_video_dev_unregister_backlight()
1838 device->backlight = NULL; in acpi_video_dev_unregister_backlight()
1840 if (device->brightness) { in acpi_video_dev_unregister_backlight()
1841 kfree(device->brightness->levels); in acpi_video_dev_unregister_backlight()
1842 kfree(device->brightness); in acpi_video_dev_unregister_backlight()
1843 device->brightness = NULL; in acpi_video_dev_unregister_backlight()
1845 if (device->cooling_dev) { in acpi_video_dev_unregister_backlight()
1846 sysfs_remove_link(&device->dev->dev.kobj, "thermal_cooling"); in acpi_video_dev_unregister_backlight()
1847 sysfs_remove_link(&device->cooling_dev->device.kobj, "device"); in acpi_video_dev_unregister_backlight()
1848 thermal_cooling_device_unregister(device->cooling_dev); in acpi_video_dev_unregister_backlight()
1849 device->cooling_dev = NULL; in acpi_video_dev_unregister_backlight()
1858 if (!video->backlight_registered) in acpi_video_bus_unregister_backlight()
1861 error = unregister_pm_notifier(&video->pm_nb); in acpi_video_bus_unregister_backlight()
1863 mutex_lock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1864 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_unregister_backlight()
1866 mutex_unlock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1868 video->backlight_registered = false; in acpi_video_bus_unregister_backlight()
1876 struct acpi_device *adev = device->dev; in acpi_video_dev_add_notify_handler()
1878 status = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, in acpi_video_dev_add_notify_handler()
1881 dev_err(&adev->dev, "Error installing notify handler\n"); in acpi_video_dev_add_notify_handler()
1883 device->flags.notify = 1; in acpi_video_dev_add_notify_handler()
1892 video->input = input = input_allocate_device(); in acpi_video_bus_add_notify_handler()
1894 error = -ENOMEM; in acpi_video_bus_add_notify_handler()
1902 snprintf(video->phys, sizeof(video->phys), in acpi_video_bus_add_notify_handler()
1903 "%s/video/input0", acpi_device_hid(video->device)); in acpi_video_bus_add_notify_handler()
1905 input->name = acpi_device_name(video->device); in acpi_video_bus_add_notify_handler()
1906 input->phys = video->phys; in acpi_video_bus_add_notify_handler()
1907 input->id.bustype = BUS_HOST; in acpi_video_bus_add_notify_handler()
1908 input->id.product = 0x06; in acpi_video_bus_add_notify_handler()
1909 input->dev.parent = &video->device->dev; in acpi_video_bus_add_notify_handler()
1910 input->evbit[0] = BIT(EV_KEY); in acpi_video_bus_add_notify_handler()
1911 set_bit(KEY_SWITCHVIDEOMODE, input->keybit); in acpi_video_bus_add_notify_handler()
1912 set_bit(KEY_VIDEO_NEXT, input->keybit); in acpi_video_bus_add_notify_handler()
1913 set_bit(KEY_VIDEO_PREV, input->keybit); in acpi_video_bus_add_notify_handler()
1914 set_bit(KEY_BRIGHTNESS_CYCLE, input->keybit); in acpi_video_bus_add_notify_handler()
1915 set_bit(KEY_BRIGHTNESSUP, input->keybit); in acpi_video_bus_add_notify_handler()
1916 set_bit(KEY_BRIGHTNESSDOWN, input->keybit); in acpi_video_bus_add_notify_handler()
1917 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); in acpi_video_bus_add_notify_handler()
1918 set_bit(KEY_DISPLAY_OFF, input->keybit); in acpi_video_bus_add_notify_handler()
1924 mutex_lock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1925 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_add_notify_handler()
1927 mutex_unlock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1935 video->input = NULL; in acpi_video_bus_add_notify_handler()
1942 if (dev->flags.notify) { in acpi_video_dev_remove_notify_handler()
1943 acpi_remove_notify_handler(dev->dev->handle, ACPI_DEVICE_NOTIFY, in acpi_video_dev_remove_notify_handler()
1945 dev->flags.notify = 0; in acpi_video_dev_remove_notify_handler()
1953 mutex_lock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1954 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_remove_notify_handler()
1956 mutex_unlock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1959 input_unregister_device(video->input); in acpi_video_bus_remove_notify_handler()
1960 video->input = NULL; in acpi_video_bus_remove_notify_handler()
1967 mutex_lock(&video->device_list_lock); in acpi_video_bus_put_devices()
1968 list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { in acpi_video_bus_put_devices()
1969 list_del(&dev->entry); in acpi_video_bus_put_devices()
1972 mutex_unlock(&video->device_list_lock); in acpi_video_bus_put_devices()
1987 acpi_dev_parent(device)->handle, 1, in acpi_video_bus_add()
1997 return -ENODEV; in acpi_video_bus_add()
2002 return -ENOMEM; in acpi_video_bus_add()
2005 if (!strcmp(device->pnp.bus_id, "VID")) { in acpi_video_bus_add()
2007 device->pnp.bus_id[3] = '0' + instance; in acpi_video_bus_add()
2011 if (!strcmp(device->pnp.bus_id, "VGA")) { in acpi_video_bus_add()
2013 device->pnp.bus_id[3] = '0' + instance; in acpi_video_bus_add()
2017 video->device = device; in acpi_video_bus_add()
2020 device->driver_data = video; in acpi_video_bus_add()
2027 mutex_init(&video->device_list_lock); in acpi_video_bus_add()
2028 INIT_LIST_HEAD(&video->video_device_list); in acpi_video_bus_add()
2040 pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n", in acpi_video_bus_add()
2042 video->flags.multihead ? "yes" : "no", in acpi_video_bus_add()
2043 video->flags.rom ? "yes" : "no", in acpi_video_bus_add()
2044 video->flags.post ? "yes" : "no"); in acpi_video_bus_add()
2046 list_add_tail(&video->entry, &video_bus_head); in acpi_video_bus_add()
2050 * If backlight-type auto-detection is used then a native backlight may in acpi_video_bus_add()
2055 * Register the backlight now when not using auto-detection, so that in acpi_video_bus_add()
2056 * when the kernel cmdline or DMI-quirks are used the backlight will in acpi_video_bus_add()
2057 * get registered even if acpi_video_register_backlight() is not called. in acpi_video_bus_add()
2079 list_del(&video->entry); in acpi_video_bus_add()
2084 kfree(video->attached_array); in acpi_video_bus_add()
2087 device->driver_data = NULL; in acpi_video_bus_add()
2106 list_del(&video->entry); in acpi_video_bus_remove()
2113 kfree(video->attached_array); in acpi_video_bus_remove()
2119 if (dev->device == 0x00D1) in is_i740()
2121 if (dev->device == 0x7000) in is_i740()
2133 if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) in intel_opregion_present()
2135 if (dev->vendor != PCI_VENDOR_ID_INTEL) in intel_opregion_present()
2223 * acpi_video_register() will report -ENODEV later as well due in acpi_video_init()