Subject: [PATCH] [acpi video] Add helper to determine the bus POST options - Add video_bus_post_options() that executes _VPO, if can_post() is true. - Set ->v_post_options with returned value, so we can use it later - Add #defines for bit masks of that value - Call when device is added, so we can know the options later on Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/bus-device.c | 57 +++++++++++++++++++++++++++++++ drivers/acpi/drivers/video/bus-driver.c | 1 + drivers/acpi/drivers/video/video.h | 7 ++++ 3 files changed, 65 insertions(+), 0 deletions(-) applies-to: 49899495eb804f1acf39bc4fa417e4a3ef069fac 80b0077373b86e9f14020c002fa822e5e4a2988e diff --git a/drivers/acpi/drivers/video/bus-device.c b/drivers/acpi/drivers/video/bus-device.c index 60d9564..10f125e 100644 --- a/drivers/acpi/drivers/video/bus-device.c +++ b/drivers/acpi/drivers/video/bus-device.c @@ -30,6 +30,16 @@ static int is_handle(struct acpi_dev * a } +static int get_int(struct acpi_dev * ad, char * obj, unsigned long * val) +{ + acpi_status status; + + status = acpi_evaluate_integer(ad->acpi_device->handle, + obj, NULL, val); + return ACPI_SUCCESS(status) ? 0 : -ENODEV; +} + + /** * can_switch - Check if a video bus supports video switching * @ad: The ACPI device representing the video bus @@ -116,3 +126,50 @@ void video_bus_check(struct acpi_video_b if (can_post(vb->v_ad)) vb->v_can_post = 1; } + + +/** + * video_bus_post_options - Query the POST options of the bus + * @vb: The ACPI video bus + * + * If the device is capable of POSTing, then get the integer mask + * stored at _VPO, which will tell us what devices it is capable of + * executing the POST on. + * + * The device should always be capable of posting the on-board video, + * but apparently the BIOS may incorrectly tell us that it cannot. + * Do a sanity check of this and give the user an ominous message + * if it doesn't hold true. + * + * NOTE: The original driver masked the returned value with '3', but + * later checked e.g. + * if (options & 4) ... + * Assuming that we want to keep that bit, the mask has changed to 0x7. + */ + +int video_bus_post_options(struct acpi_video_bus * vb) +{ + unsigned long o; + int ret = 0; + + if (can_post(vb->v_ad)) { + ret = get_int(vb->v_ad, "_VPO", &o); + + if (!ret) { + vb->v_post_options = o & 0x7; + + /* + * Make sure integrated video can post. + * Warn user if it cannot. + */ + if (!(o & ACPI_VIDEO_BUS_POST_INTEGRATED)) { + err("The motherboard VGA device is not"); + err("listed as a possible POST device."); + err("This indicate a BIOS bug."); + err("Please contact the manufacturer."); + err("options = %#01lx", o); + } + } + } + return ret; +} diff --git a/drivers/acpi/drivers/video/bus-driver.c b/drivers/acpi/drivers/video/bus-driver.c index efd9492..c49417d 100644 --- a/drivers/acpi/drivers/video/bus-driver.c +++ b/drivers/acpi/drivers/video/bus-driver.c @@ -28,6 +28,7 @@ static int video_bus_add(struct acpi_dev av->v_ad = ad; video_bus_check(av); + video_bus_post_options(av); dev_set_drvdata(&ad->dev, av); diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index e1e2d5b..ff2eac8 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -12,14 +12,21 @@ ACPI_MODULE_NAME("acpi_video"); +#define ACPI_VIDEO_BUS_POST_INTEGRATED 0x01 +#define ACPI_VIDEO_BUS_POST_PCI 0x02 +#define ACPI_VIDEO_BUS_POST_AGP 0x04 + struct acpi_video_bus { int v_can_switch; int v_has_rom; int v_can_post; + int v_post_options; + struct acpi_dev * v_ad; }; extern int video_bus_test(struct acpi_dev * ad); extern void video_bus_check(struct acpi_video_bus * vb); +int video_bus_post_options(struct acpi_video_bus * vb); --- 0.99.9.GIT