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
114 .name = "video",
125 u8 multihead:1; /* can switch video heads */
126 u8 rom:1; /* can retrieve a video rom */
137 u8 _VPO:1; /* Video POST Options */
214 struct acpi_video_bus *video; member
222 static void acpi_video_device_rebind(struct acpi_video_bus *video);
223 static void acpi_video_device_bind(struct acpi_video_bus *video,
225 static int acpi_video_device_enumerate(struct acpi_video_bus *video);
271 struct acpi_video_device *video = acpi_driver_data(device); in video_get_max_state() local
273 *state = video->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; in video_get_max_state()
281 struct acpi_video_device *video = acpi_driver_data(device); in video_get_cur_state() local
285 if (acpi_video_device_lcd_get_level_current(video, &level, false)) in video_get_cur_state()
287 for (offset = ACPI_VIDEO_FIRST_LEVEL; offset < video->brightness->count; in video_get_cur_state()
289 if (level == video->brightness->levels[offset]) { in video_get_cur_state()
290 *state = video->brightness->count - offset - 1; in video_get_cur_state()
301 struct acpi_video_device *video = acpi_driver_data(device); in video_set_cur_state() local
304 if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL) in video_set_cur_state()
307 state = video->brightness->count - state; in video_set_cur_state()
308 level = video->brightness->levels[state - 1]; in video_set_cur_state()
309 return acpi_video_device_lcd_set_level(video, level); in video_set_cur_state()
320 * Video Management
480 * Some machines have multiple video output devices, but only the one
482 * register backlight interface for other video output devices.
497 * events, in this case acpi-video is considered the canonical source
608 * ACPI video backlight still works w/ buggy _BQC. in acpi_video_device_lcd_get_level_current()
664 * video : video bus device pointer
688 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) in acpi_video_bus_DOS() argument
692 if (!video->cap._DOS) in acpi_video_bus_DOS()
697 video->dos_setting = (lcd_flag << 2) | bios_flag; in acpi_video_bus_DOS()
698 status = acpi_execute_simple_method(video->device->handle, "_DOS", in acpi_video_bus_DOS()
905 * device : video output device (LCD, CRT, ..)
979 * device : video output device (LCD, CRT, ..)
1010 * device : video output device (VGA)
1015 * Find out all required AML methods defined under the video bus device.
1018 static void acpi_video_bus_find_cap(struct acpi_video_bus *video) in acpi_video_bus_find_cap() argument
1020 if (acpi_has_method(video->device->handle, "_DOS")) in acpi_video_bus_find_cap()
1021 video->cap._DOS = 1; in acpi_video_bus_find_cap()
1022 if (acpi_has_method(video->device->handle, "_DOD")) in acpi_video_bus_find_cap()
1023 video->cap._DOD = 1; in acpi_video_bus_find_cap()
1024 if (acpi_has_method(video->device->handle, "_ROM")) in acpi_video_bus_find_cap()
1025 video->cap._ROM = 1; in acpi_video_bus_find_cap()
1026 if (acpi_has_method(video->device->handle, "_GPD")) in acpi_video_bus_find_cap()
1027 video->cap._GPD = 1; in acpi_video_bus_find_cap()
1028 if (acpi_has_method(video->device->handle, "_SPD")) in acpi_video_bus_find_cap()
1029 video->cap._SPD = 1; in acpi_video_bus_find_cap()
1030 if (acpi_has_method(video->device->handle, "_VPO")) in acpi_video_bus_find_cap()
1031 video->cap._VPO = 1; in acpi_video_bus_find_cap()
1035 * Check whether the video bus device has required AML method to
1039 static int acpi_video_bus_check(struct acpi_video_bus *video) in acpi_video_bus_check() argument
1044 if (!video) in acpi_video_bus_check()
1047 dev = acpi_get_pci_dev(video->device->handle); in acpi_video_bus_check()
1057 /* Does this device support video switching? */ in acpi_video_bus_check()
1058 if (video->cap._DOS || video->cap._DOD) { in acpi_video_bus_check()
1059 if (!video->cap._DOS) { in acpi_video_bus_check()
1061 acpi_device_bid(video->device)); in acpi_video_bus_check()
1063 video->flags.multihead = 1; in acpi_video_bus_check()
1067 /* Does this device support retrieving a video ROM? */ in acpi_video_bus_check()
1068 if (video->cap._ROM) { in acpi_video_bus_check()
1069 video->flags.rom = 1; in acpi_video_bus_check()
1073 /* Does this device support configuring which video device to POST? */ in acpi_video_bus_check()
1074 if (video->cap._GPD && video->cap._SPD && video->cap._VPO) { in acpi_video_bus_check()
1075 video->flags.post = 1; in acpi_video_bus_check()
1090 acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id) in acpi_video_get_device_attr() argument
1095 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_attr()
1096 ids = &video->attached_array[i]; in acpi_video_get_device_attr()
1105 acpi_video_get_device_type(struct acpi_video_bus *video, in acpi_video_get_device_type() argument
1111 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_device_type()
1112 ids = &video->attached_array[i]; in acpi_video_get_device_type()
1122 struct acpi_video_bus *video = arg; in acpi_video_bus_get_one_device() local
1145 data->video = video; in acpi_video_bus_get_one_device()
1150 attribute = acpi_video_get_device_attr(video, device_id); in acpi_video_bus_get_one_device()
1174 device_type = acpi_video_get_device_type(video, device_id); in acpi_video_bus_get_one_device()
1191 acpi_video_device_bind(video, data); in acpi_video_bus_get_one_device()
1197 mutex_lock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1198 list_add_tail(&data->entry, &video->video_device_list); in acpi_video_bus_get_one_device()
1199 mutex_unlock(&video->device_list_lock); in acpi_video_bus_get_one_device()
1202 video->child_count++; in acpi_video_bus_get_one_device()
1208 * video : video bus device
1213 * Enumerate the video device list of the video bus,
1214 * bind the ids with the corresponding video devices
1215 * under the video bus.
1218 static void acpi_video_device_rebind(struct acpi_video_bus *video) in acpi_video_device_rebind() argument
1222 mutex_lock(&video->device_list_lock); in acpi_video_device_rebind()
1224 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_device_rebind()
1225 acpi_video_device_bind(video, dev); in acpi_video_device_rebind()
1227 mutex_unlock(&video->device_list_lock); in acpi_video_device_rebind()
1232 * video : video bus device
1233 * device : video output device under the video
1239 * Bind the ids with the corresponding video devices
1240 * under the video bus.
1244 acpi_video_device_bind(struct acpi_video_bus *video, in acpi_video_device_bind() argument
1250 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_bind()
1251 ids = &video->attached_array[i]; in acpi_video_device_bind()
1254 acpi_handle_debug(video->device->handle, "%s: %d\n", in acpi_video_device_bind()
1262 struct acpi_video_bus *video = device->video; in acpi_video_device_in_dod() local
1270 if (!video->attached_count || video->child_count > 8) in acpi_video_device_in_dod()
1273 for (i = 0; i < video->attached_count; i++) { in acpi_video_device_in_dod()
1274 if ((video->attached_array[i].value.int_val & 0xfff) == in acpi_video_device_in_dod()
1284 * video : video bus device
1293 static int acpi_video_device_enumerate(struct acpi_video_bus *video) in acpi_video_device_enumerate() argument
1303 if (!video->cap._DOD) in acpi_video_device_enumerate()
1306 status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer); in acpi_video_device_enumerate()
1308 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1316 acpi_handle_info(video->device->handle, "Invalid _DOD data\n"); in acpi_video_device_enumerate()
1321 acpi_handle_debug(video->device->handle, "Found %d video heads in _DOD\n", in acpi_video_device_enumerate()
1337 acpi_handle_info(video->device->handle, in acpi_video_device_enumerate()
1345 acpi_handle_debug(video->device->handle, in acpi_video_device_enumerate()
1352 kfree(video->attached_array); in acpi_video_device_enumerate()
1354 video->attached_array = active_list; in acpi_video_device_enumerate()
1355 video->attached_count = count; in acpi_video_device_enumerate()
1446 struct acpi_video_bus *video; in acpi_video_get_edid() local
1455 video = acpi_driver_data(device); in acpi_video_get_edid()
1457 for (i = 0; i < video->attached_count; i++) { in acpi_video_get_edid()
1458 video_device = video->attached_array[i].bind_info; in acpi_video_get_edid()
1512 acpi_video_bus_get_devices(struct acpi_video_bus *video, in acpi_video_bus_get_devices() argument
1516 * There are systems where video module known to work fine regardless in acpi_video_bus_get_devices()
1520 acpi_video_device_enumerate(video); in acpi_video_bus_get_devices()
1522 return acpi_dev_for_each_child(device, acpi_video_bus_get_one_device, video); in acpi_video_bus_get_devices()
1531 static int acpi_video_bus_start_devices(struct acpi_video_bus *video) in acpi_video_bus_start_devices() argument
1533 return acpi_video_bus_DOS(video, 0, in acpi_video_bus_start_devices()
1537 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) in acpi_video_bus_stop_devices() argument
1539 return acpi_video_bus_DOS(video, 0, in acpi_video_bus_stop_devices()
1545 struct acpi_video_bus *video = acpi_driver_data(device); in acpi_video_bus_notify() local
1549 if (!video || !video->input) in acpi_video_bus_notify()
1552 input = video->input; in acpi_video_bus_notify()
1560 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video in acpi_video_bus_notify()
1562 acpi_video_device_enumerate(video); in acpi_video_bus_notify()
1563 acpi_video_device_rebind(video); in acpi_video_bus_notify()
1617 bus = video_device->video; in acpi_video_device_notify()
1670 struct acpi_video_bus *video; in acpi_video_resume() local
1678 video = container_of(nb, struct acpi_video_bus, pm_nb); in acpi_video_resume()
1680 dev_info(&video->device->dev, "Restoring backlight state\n"); in acpi_video_resume()
1682 for (i = 0; i < video->attached_count; i++) { in acpi_video_resume()
1683 video_device = video->attached_array[i].bind_info; in acpi_video_resume()
1769 * register video output if cooling device registration failed? in acpi_video_dev_register_backlight()
1790 static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video) in acpi_video_run_bcl_for_osi() argument
1795 mutex_lock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1796 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_run_bcl_for_osi()
1800 mutex_unlock(&video->device_list_lock); in acpi_video_run_bcl_for_osi()
1806 * Do not create backlight device for video output in acpi_video_should_register_backlight()
1819 static int acpi_video_bus_register_backlight(struct acpi_video_bus *video) in acpi_video_bus_register_backlight() argument
1823 if (video->backlight_registered) in acpi_video_bus_register_backlight()
1829 mutex_lock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1830 list_for_each_entry(dev, &video->video_device_list, entry) { in acpi_video_bus_register_backlight()
1834 mutex_unlock(&video->device_list_lock); in acpi_video_bus_register_backlight()
1836 video->backlight_registered = true; in acpi_video_bus_register_backlight()
1838 video->pm_nb.notifier_call = acpi_video_resume; in acpi_video_bus_register_backlight()
1839 video->pm_nb.priority = 0; in acpi_video_bus_register_backlight()
1840 return register_pm_notifier(&video->pm_nb); in acpi_video_bus_register_backlight()
1862 static int acpi_video_bus_unregister_backlight(struct acpi_video_bus *video) in acpi_video_bus_unregister_backlight() argument
1867 if (!video->backlight_registered) in acpi_video_bus_unregister_backlight()
1870 error = unregister_pm_notifier(&video->pm_nb); in acpi_video_bus_unregister_backlight()
1872 mutex_lock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1873 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_unregister_backlight()
1875 mutex_unlock(&video->device_list_lock); in acpi_video_bus_unregister_backlight()
1877 video->backlight_registered = false; in acpi_video_bus_unregister_backlight()
1895 static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video) in acpi_video_bus_add_notify_handler() argument
1901 video->input = input = input_allocate_device(); in acpi_video_bus_add_notify_handler()
1907 error = acpi_video_bus_start_devices(video); in acpi_video_bus_add_notify_handler()
1911 snprintf(video->phys, sizeof(video->phys), in acpi_video_bus_add_notify_handler()
1912 "%s/video/input0", acpi_device_hid(video->device)); in acpi_video_bus_add_notify_handler()
1914 input->name = acpi_device_name(video->device); in acpi_video_bus_add_notify_handler()
1915 input->phys = video->phys; in acpi_video_bus_add_notify_handler()
1918 input->dev.parent = &video->device->dev; in acpi_video_bus_add_notify_handler()
1933 mutex_lock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1934 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_add_notify_handler()
1936 mutex_unlock(&video->device_list_lock); in acpi_video_bus_add_notify_handler()
1941 acpi_video_bus_stop_devices(video); in acpi_video_bus_add_notify_handler()
1944 video->input = NULL; in acpi_video_bus_add_notify_handler()
1958 static void acpi_video_bus_remove_notify_handler(struct acpi_video_bus *video) in acpi_video_bus_remove_notify_handler() argument
1962 mutex_lock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1963 list_for_each_entry(dev, &video->video_device_list, entry) in acpi_video_bus_remove_notify_handler()
1965 mutex_unlock(&video->device_list_lock); in acpi_video_bus_remove_notify_handler()
1967 acpi_video_bus_stop_devices(video); in acpi_video_bus_remove_notify_handler()
1968 input_unregister_device(video->input); in acpi_video_bus_remove_notify_handler()
1969 video->input = NULL; in acpi_video_bus_remove_notify_handler()
1972 static int acpi_video_bus_put_devices(struct acpi_video_bus *video) in acpi_video_bus_put_devices() argument
1976 mutex_lock(&video->device_list_lock); in acpi_video_bus_put_devices()
1977 list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { in acpi_video_bus_put_devices()
1981 mutex_unlock(&video->device_list_lock); in acpi_video_bus_put_devices()
1990 struct acpi_video_bus *video; in acpi_video_bus_add() local
2000 "Duplicate ACPI video bus devices for the" in acpi_video_bus_add()
2002 "parameter \"video.allow_duplicates=1\"" in acpi_video_bus_add()
2008 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); in acpi_video_bus_add()
2009 if (!video) in acpi_video_bus_add()
2025 video->device = device; in acpi_video_bus_add()
2028 device->driver_data = video; in acpi_video_bus_add()
2030 acpi_video_bus_find_cap(video); in acpi_video_bus_add()
2031 error = acpi_video_bus_check(video); in acpi_video_bus_add()
2035 mutex_init(&video->device_list_lock); in acpi_video_bus_add()
2036 INIT_LIST_HEAD(&video->video_device_list); in acpi_video_bus_add()
2038 error = acpi_video_bus_get_devices(video, device); in acpi_video_bus_add()
2044 video->flags.multihead ? "yes" : "no", in acpi_video_bus_add()
2045 video->flags.rom ? "yes" : "no", in acpi_video_bus_add()
2046 video->flags.post ? "yes" : "no"); in acpi_video_bus_add()
2048 list_add_tail(&video->entry, &video_bus_head); in acpi_video_bus_add()
2055 acpi_video_run_bcl_for_osi(video); in acpi_video_bus_add()
2056 acpi_video_bus_add_notify_handler(video); in acpi_video_bus_add()
2061 acpi_video_bus_put_devices(video); in acpi_video_bus_add()
2062 kfree(video->attached_array); in acpi_video_bus_add()
2064 kfree(video); in acpi_video_bus_add()
2072 struct acpi_video_bus *video = NULL; in acpi_video_bus_remove() local
2078 video = acpi_driver_data(device); in acpi_video_bus_remove()
2081 list_del(&video->entry); in acpi_video_bus_remove()
2084 acpi_video_bus_remove_notify_handler(video); in acpi_video_bus_remove()
2085 acpi_video_bus_unregister_backlight(video); in acpi_video_bus_remove()
2086 acpi_video_bus_put_devices(video); in acpi_video_bus_remove()
2088 kfree(video->attached_array); in acpi_video_bus_remove()
2089 kfree(video); in acpi_video_bus_remove()
2242 struct acpi_video_bus *video; in acpi_video_register_backlight() local
2245 list_for_each_entry(video, &video_bus_head, entry) in acpi_video_register_backlight()
2246 acpi_video_bus_register_backlight(video); in acpi_video_register_backlight()
2260 * the video opregion code to be run first in order to initialise
2261 * state before any ACPI video calls are made. To handle this we defer
2262 * registration of the video class until the opregion code has run.