Lines Matching full:video

3  *  video.c - ACPI Video Driver
10 #define pr_fmt(fmt) "ACPI: video: " fmt
28 #include <acpi/video.h>
31 #define ACPI_VIDEO_BUS_NAME "Video Bus"
32 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
37 MODULE_DESCRIPTION("ACPI Video Driver");
44 * By default, we don't allow duplicate ACPI video bus devices
101 .name = "video",
111 u8 multihead:1; /* can switch video heads */
112 u8 rom:1; /* can retrieve a video rom */
123 u8 _VPO:1; /* Video POST Options */
200 struct acpi_video_bus *video; member
208 static void acpi_video_device_rebind(struct acpi_video_bus *video);
209 static void acpi_video_device_bind(struct acpi_video_bus *video,
211 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
256 struct acpi_video_device *video = cooling_dev->devdata; in video_get_max_state() local
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() local
269 if (acpi_video_device_lcd_get_level_current(video, &level, false)) 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()
284 struct acpi_video_device *video = cooling_dev->devdata; in video_set_cur_state() local
287 if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL) 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()
292 return acpi_video_device_lcd_set_level(video, level); in video_set_cur_state()
303 * Video Management
463 * Some machines have multiple video output devices, but only the one
465 * register backlight interface for other video output devices.
480 * events, in this case acpi-video is considered the canonical source
600 * ACPI video backlight still works w/ buggy _BQC. in acpi_video_device_lcd_get_level_current()
656 * video : video bus device pointer
680 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) in acpi_video_bus_DOS() argument
684 if (!video->cap._DOS) in acpi_video_bus_DOS()
689 video->dos_setting = (lcd_flag << 2) | bios_flag; in acpi_video_bus_DOS()
690 status = acpi_execute_simple_method(video->device->handle, "_DOS", in acpi_video_bus_DOS()
897 * device : video output device (LCD, CRT, ..)
971 * device : video output device (LCD, CRT, ..)
1002 * device : video output device (VGA)
1007 * Find out all required AML methods defined under the video bus device.
1010 static void acpi_video_bus_find_cap(struct acpi_video_bus *video) in acpi_video_bus_find_cap() argument
1012 if (acpi_has_method(video->device->handle, "_DOS")) in acpi_video_bus_find_cap()
1013 video->cap._DOS = 1; in acpi_video_bus_find_cap()
1014 if (acpi_has_method(video->device->handle, "_DOD")) in acpi_video_bus_find_cap()
1015 video->cap._DOD = 1; in acpi_video_bus_find_cap()
1016 if (acpi_has_method(video->device->handle, "_ROM")) in acpi_video_bus_find_cap()
1017 video->cap._ROM = 1; in acpi_video_bus_find_cap()
1018 if (acpi_has_method(video->device->handle, "_GPD")) in acpi_video_bus_find_cap()
1019 video->cap._GPD = 1; in acpi_video_bus_find_cap()
1020 if (acpi_has_method(video->device->handle, "_SPD")) in acpi_video_bus_find_cap()
1021 video->cap._SPD = 1; in acpi_video_bus_find_cap()
1022 if (acpi_has_method(video->device->handle, "_VPO")) in acpi_video_bus_find_cap()
1023 video->cap._VPO = 1; in acpi_video_bus_find_cap()
1027 * Check whether the video bus device has required AML method to
1031 static int acpi_video_bus_check(struct acpi_video_bus *video) in acpi_video_bus_check() argument
1036 if (!video) in acpi_video_bus_check()
1039 dev = acpi_get_pci_dev(video->device->handle); in acpi_video_bus_check()
1049 /* Does this device support video switching? */ in acpi_video_bus_check()
1050 if (video->cap._DOS || video->cap._DOD) { in acpi_video_bus_check()
1051 if (!video->cap._DOS) { in acpi_video_bus_check()
1053 acpi_device_bid(video->device)); in acpi_video_bus_check()
1055 video->flags.multihead = 1; in acpi_video_bus_check()
1059 /* Does this device support retrieving a video ROM? */ in acpi_video_bus_check()
1060 if (video->cap._ROM) { in acpi_video_bus_check()
1061 video->flags.rom = 1; in acpi_video_bus_check()
1065 /* Does this device support configuring which video device to POST? */ in acpi_video_bus_check()
1066 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) { in acpi_video_bus_check()
1067 video->flags.post = 1; in acpi_video_bus_check()
1082 acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id) in acpi_video_get_device_attr() argument
1087 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_attr()
1088 ids = &video->attached_array[i]; in acpi_video_get_device_attr()
1097 acpi_video_get_device_type(struct acpi_video_bus *video, in acpi_video_get_device_type() argument
1103 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_type()
1104 ids = &video->attached_array[i]; in acpi_video_get_device_type()
1114 struct acpi_video_bus *video = arg; in acpi_video_bus_get_one_device() local
1136 data->video = video; in acpi_video_bus_get_one_device()
1141 attribute = acpi_video_get_device_attr(video, device_id); in acpi_video_bus_get_one_device()
1165 device_type = acpi_video_get_device_type(video, device_id); in acpi_video_bus_get_one_device()
1182 acpi_video_device_bind(video, data); in acpi_video_bus_get_one_device()
1188 mutex_lock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1189 list_add_tail(&data->entry, &video->video_device_list); in acpi_video_bus_get_one_device()
1190 mutex_unlock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1193 video->child_count++; in acpi_video_bus_get_one_device()
1199 * video : video bus device
1204 * Enumerate the video device list of the video bus,
1205 * bind the ids with the corresponding video devices
1206 * under the video bus.
1209 static void acpi_video_device_rebind(struct acpi_video_bus *video) in acpi_video_device_rebind() argument
1213 mutex_lock(&video->device_list_lock); in acpi_video_device_rebind()
1215 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_device_rebind()
1216 acpi_video_device_bind(video, dev); in acpi_video_device_rebind()
1218 mutex_unlock(&video->device_list_lock); in acpi_video_device_rebind()
1223 * video : video bus device
1224 * device : video output device under the video
1230 * Bind the ids with the corresponding video devices
1231 * under the video bus.
1235 acpi_video_device_bind(struct acpi_video_bus *video, in acpi_video_device_bind() argument
1241 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_bind()
1242 ids = &video->attached_array[i]; in acpi_video_device_bind()
1245 acpi_handle_debug(video->device->handle, "%s: %d\n", in acpi_video_device_bind()
1253 struct acpi_video_bus *video = device->video; in acpi_video_device_in_dod() local
1261 if (!video->attached_count || video->child_count > 8) in acpi_video_device_in_dod()
1264 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_in_dod()
1265 if ((video->attached_array[i].value.int_val & 0xfff) == in acpi_video_device_in_dod()
1275 * video : video bus device
1284 static int acpi_video_device_enumerate(struct acpi_video_bus *video) in acpi_video_device_enumerate() argument
1294 if (!video->cap._DOD) in acpi_video_device_enumerate()
1297 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer); in acpi_video_device_enumerate()
1299 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1307 acpi_handle_info(video->device->handle, "Invalid _DOD data\n"); in acpi_video_device_enumerate()
1312 acpi_handle_debug(video->device->handle, "Found %d video heads in _DOD\n", in acpi_video_device_enumerate()
1328 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1336 acpi_handle_debug(video->device->handle, in acpi_video_device_enumerate()
1343 kfree(video->attached_array); in acpi_video_device_enumerate()
1345 video->attached_array = active_list; in acpi_video_device_enumerate()
1346 video->attached_count = count; in acpi_video_device_enumerate()
1437 struct acpi_video_bus *video; in acpi_video_get_edid() local
1446 video = acpi_driver_data(device); in acpi_video_get_edid()
1448 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_edid()
1449 video_device = video->attached_array[i].bind_info; in acpi_video_get_edid()
1503 acpi_video_bus_get_devices(struct acpi_video_bus *video, in acpi_video_bus_get_devices() argument
1507 * There are systems where video module known to work fine regardless in acpi_video_bus_get_devices()
1511 acpi_video_device_enumerate(video); in acpi_video_bus_get_devices()
1513 return acpi_dev_for_each_child(device, acpi_video_bus_get_one_device, video); in acpi_video_bus_get_devices()
1522 static int acpi_video_bus_start_devices(struct acpi_video_bus *video) in acpi_video_bus_start_devices() argument
1524 return acpi_video_bus_DOS(video, 0, in acpi_video_bus_start_devices()
1528 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) in acpi_video_bus_stop_devices() argument
1530 return acpi_video_bus_DOS(video, 0, in acpi_video_bus_stop_devices()
1537 struct acpi_video_bus *video = acpi_driver_data(device); in acpi_video_bus_notify() local
1541 if (!video || !video->input) in acpi_video_bus_notify()
1544 input = video->input; in acpi_video_bus_notify()
1552 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video in acpi_video_bus_notify()
1554 acpi_video_device_enumerate(video); in acpi_video_bus_notify()
1555 acpi_video_device_rebind(video); in acpi_video_bus_notify()
1609 bus = video_device->video; in acpi_video_device_notify()
1662 struct acpi_video_bus *video; in acpi_video_resume() local
1670 video = container_of(nb, struct acpi_video_bus, pm_nb); in acpi_video_resume()
1672 dev_info(&video->device->dev, "Restoring backlight state\n"); in acpi_video_resume()
1674 for (i = 0; i < video->attached_count; i++) { in acpi_video_resume()
1675 video_device = video->attached_array[i].bind_info; in acpi_video_resume()
1761 * register video output if cooling device registration failed? in acpi_video_dev_register_backlight()
1782 static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video) in acpi_video_run_bcl_for_osi() argument
1787 mutex_lock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1788 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_run_bcl_for_osi()
1792 mutex_unlock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1798 * Do not create backlight device for video output in acpi_video_should_register_backlight()
1811 static int acpi_video_bus_register_backlight(struct acpi_video_bus *video) in acpi_video_bus_register_backlight() argument
1815 if (video->backlight_registered) in acpi_video_bus_register_backlight()
1821 mutex_lock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1822 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_bus_register_backlight()
1826 mutex_unlock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1828 video->backlight_registered = true; in acpi_video_bus_register_backlight()
1830 video->pm_nb.notifier_call = acpi_video_resume; in acpi_video_bus_register_backlight()
1831 video->pm_nb.priority = 0; in acpi_video_bus_register_backlight()
1832 return register_pm_notifier(&video->pm_nb); in acpi_video_bus_register_backlight()
1854 static int acpi_video_bus_unregister_backlight(struct acpi_video_bus *video) in acpi_video_bus_unregister_backlight() argument
1859 if (!video->backlight_registered) in acpi_video_bus_unregister_backlight()
1862 error = unregister_pm_notifier(&video->pm_nb); in acpi_video_bus_unregister_backlight()
1864 mutex_lock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1865 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_unregister_backlight()
1867 mutex_unlock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1869 video->backlight_registered = false; in acpi_video_bus_unregister_backlight()
1887 static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video) in acpi_video_bus_add_notify_handler() argument
1893 video->input = input = input_allocate_device(); in acpi_video_bus_add_notify_handler()
1899 error = acpi_video_bus_start_devices(video); in acpi_video_bus_add_notify_handler()
1903 snprintf(video->phys, sizeof(video->phys), in acpi_video_bus_add_notify_handler()
1904 "%s/video/input0", acpi_device_hid(video->device)); in acpi_video_bus_add_notify_handler()
1906 input->name = acpi_device_name(video->device); in acpi_video_bus_add_notify_handler()
1907 input->phys = video->phys; in acpi_video_bus_add_notify_handler()
1910 input->dev.parent = &video->device->dev; in acpi_video_bus_add_notify_handler()
1925 mutex_lock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1926 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_add_notify_handler()
1928 mutex_unlock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1933 acpi_video_bus_stop_devices(video); in acpi_video_bus_add_notify_handler()
1936 video->input = NULL; in acpi_video_bus_add_notify_handler()
1950 static void acpi_video_bus_remove_notify_handler(struct acpi_video_bus *video) in acpi_video_bus_remove_notify_handler() argument
1954 mutex_lock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1955 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_remove_notify_handler()
1957 mutex_unlock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1959 acpi_video_bus_stop_devices(video); in acpi_video_bus_remove_notify_handler()
1960 input_unregister_device(video->input); in acpi_video_bus_remove_notify_handler()
1961 video->input = NULL; in acpi_video_bus_remove_notify_handler()
1964 static int acpi_video_bus_put_devices(struct acpi_video_bus *video) in acpi_video_bus_put_devices() argument
1968 mutex_lock(&video->device_list_lock); in acpi_video_bus_put_devices()
1969 list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { in acpi_video_bus_put_devices()
1973 mutex_unlock(&video->device_list_lock); in acpi_video_bus_put_devices()
1982 struct acpi_video_bus *video; in acpi_video_bus_add() local
1993 "Duplicate ACPI video bus devices for the" in acpi_video_bus_add()
1995 "parameter \"video.allow_duplicates=1\"" in acpi_video_bus_add()
2001 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); in acpi_video_bus_add()
2002 if (!video) in acpi_video_bus_add()
2018 video->device = device; in acpi_video_bus_add()
2021 device->driver_data = video; in acpi_video_bus_add()
2023 acpi_video_bus_find_cap(video); in acpi_video_bus_add()
2024 error = acpi_video_bus_check(video); in acpi_video_bus_add()
2028 mutex_init(&video->device_list_lock); in acpi_video_bus_add()
2029 INIT_LIST_HEAD(&video->video_device_list); in acpi_video_bus_add()
2031 error = acpi_video_bus_get_devices(video, device); in acpi_video_bus_add()
2036 * HP ZBook Fury 16 G10 requires ACPI video's child devices have _PS0 in acpi_video_bus_add()
2043 video->flags.multihead ? "yes" : "no", in acpi_video_bus_add()
2044 video->flags.rom ? "yes" : "no", in acpi_video_bus_add()
2045 video->flags.post ? "yes" : "no"); in acpi_video_bus_add()
2047 list_add_tail(&video->entry, &video_bus_head); in acpi_video_bus_add()
2052 * show up later and this may change the result from video to native. in acpi_video_bus_add()
2060 acpi_video_run_bcl_for_osi(video); in acpi_video_bus_add()
2063 acpi_video_bus_register_backlight(video); in acpi_video_bus_add()
2065 error = acpi_video_bus_add_notify_handler(video); in acpi_video_bus_add()
2077 acpi_video_bus_remove_notify_handler(video); in acpi_video_bus_add()
2080 list_del(&video->entry); in acpi_video_bus_add()
2082 acpi_video_bus_unregister_backlight(video); in acpi_video_bus_add()
2084 acpi_video_bus_put_devices(video); in acpi_video_bus_add()
2085 kfree(video->attached_array); in acpi_video_bus_add()
2087 kfree(video); in acpi_video_bus_add()
2095 struct acpi_video_bus *video = NULL; in acpi_video_bus_remove() local
2101 video = acpi_driver_data(device); in acpi_video_bus_remove()
2107 list_del(&video->entry); in acpi_video_bus_remove()
2110 acpi_video_bus_remove_notify_handler(video); in acpi_video_bus_remove()
2111 acpi_video_bus_unregister_backlight(video); in acpi_video_bus_remove()
2112 acpi_video_bus_put_devices(video); in acpi_video_bus_remove()
2114 kfree(video->attached_array); in acpi_video_bus_remove()
2115 kfree(video); in acpi_video_bus_remove()
2248 struct acpi_video_bus *video; in acpi_video_register_backlight() local
2251 list_for_each_entry(video, &video_bus_head, entry) in acpi_video_register_backlight()
2252 acpi_video_bus_register_backlight(video); in acpi_video_register_backlight()
2266 * the video opregion code to be run first in order to initialise
2267 * state before any ACPI video calls are made. To handle this we defer
2268 * registration of the video class until the opregion code has run.