Subject: [PATCH] [acpi video] Add helper for getting a device's EDID - Add video_dev_edid() that returns a buffer and a size - Add get_buffer() helper that gets a buffer from the namespace Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/dev-device.c | 51 +++++++++++++++++++++++++++++++ drivers/acpi/drivers/video/video.h | 1 + 2 files changed, 52 insertions(+), 0 deletions(-) applies-to: 1bcce000434df10653d3b0efb3456d5b09d090bc 57e52cf4e80832a9959b4895ae6ebd459fe7cfd2 diff --git a/drivers/acpi/drivers/video/dev-device.c b/drivers/acpi/drivers/video/dev-device.c index 66b0591..658d080 100644 --- a/drivers/acpi/drivers/video/dev-device.c +++ b/drivers/acpi/drivers/video/dev-device.c @@ -88,6 +88,38 @@ static int get_int_array(struct acpi_dev return 0; } +static int get_buffer(struct acpi_dev * ad, char * method, + size_t ask_len, char ** buffer, size_t * len) +{ + union acpi_object arg = { + .type = ACPI_TYPE_INTEGER, + .integer = { + .value = ask_len, + }, + }; + struct acpi_object_list arg_list = { + .count = 1, + .pointer = &arg, + }; + struct acpi_buffer ab = { + .length = ACPI_ALLOCATE_BUFFER, + }; + acpi_status status; + + status = acpi_evaluate_object(ad->acpi_device->handle, method, + &arg_list, &ab); + if (ACPI_SUCCESS(status)) { + union acpi_object * obj = ab.pointer; + + if (obj && obj->type == ACPI_TYPE_BUFFER) { + *len = obj->buffer.length; + *buffer = obj->buffer.pointer; + return 0; + } + } + return -ENODEV; +} + /** * video_dev_test - Determine whether this is a video device * @ad: The ACPI device that we're testing @@ -185,3 +217,22 @@ const char * video_dev_string(struct acp } return str; } + + +int video_dev_edid(struct acpi_video_dev * vd, char ** buffer, size_t * len) +{ + int ret; + + /* + * First try for 128 bytes + */ + ret = get_buffer(vd->v_ad, "_DDC", 1, buffer, len); + if (ret) { + /* + * No love, so try 256 + */ + ret = get_buffer(vd->v_ad, "_DDC", 2, buffer, len); + } + return ret; +} + diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index aedd495..58504c1 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -70,6 +70,7 @@ struct acpi_video_dev { extern int video_dev_test(struct acpi_dev * ad); extern int video_dev_init(struct acpi_video_dev * vd); 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_bus_attach(struct acpi_video_dev * vd); extern void video_bus_detach(struct acpi_video_dev * vd); --- 0.99.9.GIT