Subject: [PATCH] [acpi video] Add ability to probe for video bus devices - Add helper is_handle() for determining whether or not a named method exists in the device's namespace. - Add video_bus_test() for checking whether or not a particular device is a real video device. - Call from video_probe() in driver.c. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/device.c | 57 +++++++++++++++++++++++++++++++++++ drivers/acpi/drivers/video/driver.c | 6 ++++ drivers/acpi/drivers/video/video.h | 3 +- 3 files changed, 64 insertions(+), 2 deletions(-) applies-to: 724fae855e48e7022a6b163cc9a11881235c01e5 6517cae822b7b8376d47c115b7413e22cb2f9c88 diff --git a/drivers/acpi/drivers/video/device.c b/drivers/acpi/drivers/video/device.c index 79f8a67..7a11dda 100644 --- a/drivers/acpi/drivers/video/device.c +++ b/drivers/acpi/drivers/video/device.c @@ -11,3 +11,60 @@ */ #include "video.h" + + +/** + * is_handle - Check if a named object exists in the namespace + * @ad: The ACPI device whose namespace we're checking + * @obj: The name of the handle to check for + * + */ + +static int is_handle(struct acpi_dev * ad, char * obj) +{ + acpi_handle h; + acpi_status status; + + status = acpi_get_handle(ad->acpi_device->handle, obj, &h); + return ACPI_SUCCESS(status) ? 1 : 0; +} + + +/** + * video_bus_test - Check device to see if it's a video bus + * @ad: The ACPI device that we're checking + * + * Since there is no HID or CID for ACPI Video devices, we have + * to check well known required nodes for each feature we support. + * + * We bind to a device if it supports one of the following: + * - Video switching (via _DOD or _DOS) + * - Retrieving video ROM (via _ROM) + * - Ability to configure head to be POSTed (via _VPD, _GPD and _SPD) + * + * Returns %1 if the device is a video device; %0 otherwise. + */ + +int video_bus_test(struct acpi_dev * ad) +{ + /* + * Video switching + */ + if (is_handle(ad, "_DOD") && is_handle(ad, "_DOS")) + return 1; + + /* + * ROM retrieval + */ + if (is_handle(ad, "_ROM")) + return 1; + + /* + * POST configuration + */ + if (is_handle(ad, "_VPD") && + is_handle(ad, "_GPD") && + is_handle(ad, "_SPD")) + return 1; + return 0; +} diff --git a/drivers/acpi/drivers/video/driver.c b/drivers/acpi/drivers/video/driver.c index 0311ca9..10f2825 100644 --- a/drivers/acpi/drivers/video/driver.c +++ b/drivers/acpi/drivers/video/driver.c @@ -12,6 +12,11 @@ #include "video.h" +static int video_probe(struct acpi_dev * ad) +{ + return video_bus_test(ad); +} + static int video_add(struct acpi_dev * ad) { struct acpi_video * av; @@ -38,6 +43,7 @@ static int video_remove(struct acpi_dev return 0; } + acpi_no_start(video); acpi_no_stop(video); acpi_no_shutdown(video); diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index 57dea68..1e1ea01 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -16,5 +16,4 @@ struct acpi_video { struct acpi_dev * v_ad; }; -extern int video_get_state(struct acpi_video * av); -extern int video_set_state(struct acpi_video * av, unsigned int state); +extern int video_bus_test(struct acpi_dev * ad); --- 0.99.9.GIT