Subject: [PATCH] [acpi video] Add helpers for reading/writing device state - video_dev_get_state() - Queries the device state via _DCS and _DGS - video_dev_set_state() - Sets state via _DSS Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/dev-device.c | 38 +++++++++++++++++++++++++++++++ drivers/acpi/drivers/video/video.h | 3 ++ 2 files changed, 41 insertions(+), 0 deletions(-) applies-to: 9cedbecfa198f4ec20d6b9a12e9fac3e48802229 de9ffd5025cd716b20f7c058dde1bee48c91d8b5 diff --git a/drivers/acpi/drivers/video/dev-device.c b/drivers/acpi/drivers/video/dev-device.c index c504576..8b79528 100644 --- a/drivers/acpi/drivers/video/dev-device.c +++ b/drivers/acpi/drivers/video/dev-device.c @@ -306,3 +306,41 @@ int video_dev_edid(struct acpi_video_dev return ret; } +/** + * video_dev_get_state - Get the device state via _DCS + * @vd: The ACPI video device + * @output: The returned state of the output device (montior) + * @graphics: The returned state of the graphics device (card) + */ + +int video_dev_get_state(struct acpi_video_dev * vd, u32 * output, u32 * graphics) +{ + unsigned long s; + int ret = 0; + + if (vd->v_hotkey) { + ret = get_int(vd->v_ad, "_DCS", &s); + if (!ret) + *output = s; + else + return ret; + + ret = get_int(vd->v_ad, "_DGS", &s); + if (!ret) + *graphics = s; + } + return ret; +} + + +/** + * video_dev_set_state - Set the device state via _DCS + * @vd: The ACPI video device + * @state: The state we're setting + */ + +int video_dev_set_state(struct acpi_video_dev * vd, u32 state) +{ + return vd->v_hotkey ? set_int(vd->v_ad, "_DSS", state) : -EIO; +} + diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index 49d7399..4453576 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -76,6 +76,9 @@ extern int video_dev_init(struct acpi_vi extern const char * video_dev_string(struct acpi_video_dev * vd); extern int video_dev_edid(struct acpi_video_dev * vd, char ** buffer, size_t * len); +extern int video_dev_get_state(struct acpi_video_dev *, u32 *, u32 *); +extern int video_dev_set_state(struct acpi_video_dev * vd, u32 output_state); + extern int video_bus_attach(struct acpi_video_dev * vd); extern void video_bus_detach(struct acpi_video_dev * vd); --- 0.99.9.GIT