From: Mario Limonciello <mario.limonciello@amd.com>
To: <amd-gfx@lists.freedesktop.org>,
Alex Deucher <alexander.deucher@amd.com>,
Harry Wentland <harry.wentland@amd.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Hans de Goede <hdegoede@redhat.com>
Cc: "open list:ACPI" <linux-acpi@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
Melissa Wen <mwen@igalia.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v3 1/5] ACPI: video: Handle fetching EDID that is longer than 256 bytes
Date: Thu, 1 Feb 2024 16:11:15 -0600 [thread overview]
Message-ID: <20240201221119.42564-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20240201221119.42564-1-mario.limonciello@amd.com>
The ACPI specification allows for an EDID to be up to 512 bytes but
the _DDC EDID fetching code will only try up to 256 bytes.
Modify the code to instead start at 512 bytes and work it's way
down instead.
As _DDC is now called up to 4 times on a machine debugging messages
are noisier than necessary. Decrease from info to debug.
Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/Apx_B_Video_Extensions/output-device-specific-methods.html#ddc-return-the-edid-for-this-device
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
* Use for loop for acpi_video_get_edid()
* Use one of Rafael's suggestions for acpi_video_device_EDID()
* Decrease message level too
---
drivers/acpi/acpi_video.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 4afdda9db019..3bfd013e09d2 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -625,12 +625,9 @@ acpi_video_device_EDID(struct acpi_video_device *device,
if (!device)
return -ENODEV;
- if (length == 128)
- arg0.integer.value = 1;
- else if (length == 256)
- arg0.integer.value = 2;
- else
+ if (!length || (length % 128))
return -EINVAL;
+ arg0.integer.value = length / 128;
status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer);
if (ACPI_FAILURE(status))
@@ -641,7 +638,8 @@ acpi_video_device_EDID(struct acpi_video_device *device,
if (obj && obj->type == ACPI_TYPE_BUFFER)
*edid = obj;
else {
- acpi_handle_info(device->dev->handle, "Invalid _DDC data\n");
+ acpi_handle_debug(device->dev->handle,
+ "Invalid _DDC data for length %ld\n", length);
status = -EFAULT;
kfree(obj);
}
@@ -1447,7 +1445,6 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
for (i = 0; i < video->attached_count; i++) {
video_device = video->attached_array[i].bind_info;
- length = 256;
if (!video_device)
continue;
@@ -1478,18 +1475,14 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
continue;
}
- status = acpi_video_device_EDID(video_device, &buffer, length);
-
- if (ACPI_FAILURE(status) || !buffer ||
- buffer->type != ACPI_TYPE_BUFFER) {
- length = 128;
+ for (length = 512; length > 0; length -= 128) {
status = acpi_video_device_EDID(video_device, &buffer,
length);
- if (ACPI_FAILURE(status) || !buffer ||
- buffer->type != ACPI_TYPE_BUFFER) {
- continue;
- }
+ if (ACPI_SUCCESS(status))
+ break;
}
+ if (!length)
+ continue;
*edid = buffer->buffer.pointer;
return length;
--
2.34.1
next prev parent reply other threads:[~2024-02-01 22:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 22:11 [PATCH v3 0/5] Add support for fetching EDID from ACPI _DDC Mario Limonciello
2024-02-01 22:11 ` Mario Limonciello [this message]
2024-02-02 16:07 ` [PATCH v3 1/5] ACPI: video: Handle fetching EDID that is longer than 256 bytes Rafael J. Wysocki
2024-02-02 16:09 ` Mario Limonciello
2024-02-06 19:43 ` Rafael J. Wysocki
2024-02-01 22:11 ` [PATCH v3 2/5] drm: Add drm_get_acpi_edid() helper Mario Limonciello
2024-02-02 10:24 ` Pranjal Ramajor Asha Kanojiya
2024-02-02 10:29 ` Jani Nikula
2024-02-02 15:19 ` Mario Limonciello
2024-02-01 22:11 ` [PATCH v3 3/5] drm/amd: Fetch the EDID from _DDC if available for eDP Mario Limonciello
2024-02-03 12:53 ` kernel test robot
2024-02-01 22:11 ` [PATCH v3 4/5] drm/nouveau: Use drm_get_acpi_edid() helper Mario Limonciello
2024-02-01 22:11 ` [PATCH v3 5/5] drm: Drop unneeded selects in DRM drivers Mario Limonciello
2024-02-02 10:12 ` Pranjal Ramajor Asha Kanojiya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201221119.42564-2-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=hdegoede@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=mwen@igalia.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).