Subject: [PATCH] [acpi video] Cache video bus capabilities - Add video_bus_check() that checks for familiar methods in device's namespace (the same as video_bus_test()). - Break out checks for each capability into their own 1-line helpers and update video_bus_test(). - If a bus supports each, set a flag in struct acpi_video_bus. - Call video_bus_check() and print bus capabilities when device is bound. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/bus-device.c | 88 ++++++++++++++++++++++++------- drivers/acpi/drivers/video/bus-driver.c | 9 ++- drivers/acpi/drivers/video/video.h | 6 ++ 3 files changed, 81 insertions(+), 22 deletions(-) applies-to: eacc8fd705f55f35b250b298cda818175c0b6ac4 69413b3a8214d2a5f9cd86e0f5fdfcf55a28f396 diff --git a/drivers/acpi/drivers/video/bus-device.c b/drivers/acpi/drivers/video/bus-device.c index 7a11dda..60d9564 100644 --- a/drivers/acpi/drivers/video/bus-device.c +++ b/drivers/acpi/drivers/video/bus-device.c @@ -31,6 +31,49 @@ static int is_handle(struct acpi_dev * a /** + * can_switch - Check if a video bus supports video switching + * @ad: The ACPI device representing the video bus + * + * Determine if bus support switching by checking for availability + * of _DOD and _DOS. + */ + +static int can_switch(struct acpi_dev * ad) +{ + return (is_handle(ad, "_DOD") && is_handle(ad, "_DOS")); +} + + +/** + * has_rom - Check if a video bus has an attached ROM + * @ad: The ACPI device representing the video bus + * + * Determine if bus has a ROM bus by checking for _ROM. + */ + +static int has_rom(struct acpi_dev * ad) +{ + return is_handle(ad, "_ROM"); +} + + +/** + * can_post - Check if a video bus can configure device to POST + * @ad: The ACPI device representing the video bus + * + * Determine if bus supports POST configuration by checking for + * _GPD, _SPD and _VPD. + */ + +static int can_post(struct acpi_dev * ad) +{ + return (is_handle(ad, "_VPD") && + is_handle(ad, "_GPD") && + is_handle(ad, "_SPD")); +} + + +/** * video_bus_test - Check device to see if it's a video bus * @ad: The ACPI device that we're checking * @@ -47,24 +90,29 @@ static int is_handle(struct acpi_dev * a 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; + return (can_switch(ad) || has_rom(ad) || can_post(ad)); +} + + + +/** + * video_bus_check - Determine a bus's capabilities + * @vb: The ACPI video device to check + * + * This does the same checks as video_bus_test(), but it always + * runs all of the checks, so it can set the flags. And, we now + * have a struct acpi_video_bus with which we can cache the + * values.. + */ + +void video_bus_check(struct acpi_video_bus * vb) +{ + if (can_switch(vb->v_ad)) + vb->v_can_switch = 1; + + if (has_rom(vb->v_ad)) + vb->v_has_rom = 1; + + if (can_post(vb->v_ad)) + vb->v_can_post = 1; } diff --git a/drivers/acpi/drivers/video/bus-driver.c b/drivers/acpi/drivers/video/bus-driver.c index 2e0202a..efd9492 100644 --- a/drivers/acpi/drivers/video/bus-driver.c +++ b/drivers/acpi/drivers/video/bus-driver.c @@ -27,10 +27,15 @@ static int video_bus_add(struct acpi_dev av->v_ad = ad; + video_bus_check(av); + dev_set_drvdata(&ad->dev, av); - printk(KERN_INFO PREFIX "video bus [%s]\n", - acpi_dev_bid(ad)); + printk(KERN_INFO PREFIX "video bus [%s] : %s %s %s\n", + acpi_dev_bid(ad), + av->v_can_switch ? "multi-head" : "", + av->v_has_rom ? "rom" : "", + av->v_can_post ? "post" : ""); return 0; } diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index 78f3a2a..e1e2d5b 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -13,7 +13,13 @@ ACPI_MODULE_NAME("acpi_video"); struct acpi_video_bus { + int v_can_switch; + int v_has_rom; + int v_can_post; + struct acpi_dev * v_ad; }; extern int video_bus_test(struct acpi_dev * ad); + +extern void video_bus_check(struct acpi_video_bus * vb); --- 0.99.9.GIT