Subject: [PATCH] [acpi video] Add probing capabilities to video device driver - Add video_dev_test() that checks for _ADR function, which is the only known way of determining whether or not a particular ACPI object is a video device (and that it is under a video bus device). - Add video_probe() that calls video_dev_test(), and checks that the parent device is bound to the "video_bus" driver. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/dev-device.c | 30 ++++++++++++++++++++++++++++++ drivers/acpi/drivers/video/dev-driver.c | 22 +++++++++++++++++++++- drivers/acpi/drivers/video/video.h | 3 +++ 3 files changed, 54 insertions(+), 1 deletions(-) applies-to: 96aaadec677cf56ebd1a9e9a6035648f76d2ec13 3a513703d7c0ca3a4c83a9a9161a445d9c80a9d7 diff --git a/drivers/acpi/drivers/video/dev-device.c b/drivers/acpi/drivers/video/dev-device.c index de96792..5907c16 100644 --- a/drivers/acpi/drivers/video/dev-device.c +++ b/drivers/acpi/drivers/video/dev-device.c @@ -12,3 +12,33 @@ #include #include "video.h" + + +static int get_int(struct acpi_dev * ad, char * method, unsigned long * val) +{ + acpi_status status; + + status = acpi_evaluate_integer(ad->acpi_device->handle, method, + NULL, val); + return ACPI_SUCCESS(status) ? 0 : -ENODEV; +} + + +/** + * video_dev_test - Determine whether this is a video device + * @ad: The ACPI device that we're testing + * + * Check if this is a video device as best as we can, which + * solely involves checking for the existence of the _ADR + * method. + * + * Returns %0/%1 depending on whether we think it's a video + * device or not. + */ + +int video_dev_test(struct acpi_dev * ad) +{ + unsigned long device_id; + + return get_int(ad, "_ADR", &device_id) == 0 ? 1 : 0; +} diff --git a/drivers/acpi/drivers/video/dev-driver.c b/drivers/acpi/drivers/video/dev-driver.c index 750220c..584dfbb 100644 --- a/drivers/acpi/drivers/video/dev-driver.c +++ b/drivers/acpi/drivers/video/dev-driver.c @@ -14,6 +14,27 @@ #include #include "video.h" +static int video_probe(struct acpi_dev * ad) +{ + /* + * Unfortunately, video devices do not have any unique + * distinguishing feature (like a HID). + * So, we do two things to determine whether or not this + * is a video device. + * - Verify that the parent to this device is bound to the + * "video_bus" driver. + * - Make sure that the device has an _ADR method. + */ + if (ad->dev.parent && ad->dev.parent->driver) { + if (!strcmp(ad->dev.parent->driver->name, "video_bus")) + goto CheckAdr; + return 0; + } + + CheckAdr: + return video_dev_test(ad); +} + static int video_add(struct acpi_dev * ad) { struct acpi_video_dev * vd; @@ -40,7 +61,6 @@ static int video_remove(struct acpi_dev return 0; } -acpi_no_probe(video); 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 bf6a593..1c3c061 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -29,6 +29,9 @@ struct acpi_video_dev { struct acpi_dev * v_ad; }; +extern int video_dev_test(struct acpi_dev * ad); + + struct acpi_video_enum { union { struct { --- 0.99.9.GIT