public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: amd-gfx@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	Harry Wentland <harry.wentland@amd.com>,
	Hans de Goede <hdegoede@redhat.com>,
	"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>
Subject: Re: [PATCH 1/2] ACPI: video: Handle fetching EDID that is longer than 256 bytes
Date: Mon, 29 Jan 2024 10:12:13 -0600	[thread overview]
Message-ID: <ad625d5f-6b4b-41bb-a9c0-edb513697802@amd.com> (raw)
In-Reply-To: <CAJZ5v0iX5=u5y0JS2OzYMvYNnjZBCM2YfSTsSdg3CtH4rBMyUw@mail.gmail.com>

On 1/29/2024 07:54, Rafael J. Wysocki wrote:
> On Fri, Jan 26, 2024 at 7:55 PM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
>>
>> 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.
>>
>> 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>
>> ---
>>   drivers/acpi/acpi_video.c | 23 ++++++++++++++++-------
>>   1 file changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
>> index 62f4364e4460..b3b15dd4755d 100644
>> --- a/drivers/acpi/acpi_video.c
>> +++ b/drivers/acpi/acpi_video.c
>> @@ -624,6 +624,10 @@ acpi_video_device_EDID(struct acpi_video_device *device,
>>                  arg0.integer.value = 1;
>>          else if (length == 256)
>>                  arg0.integer.value = 2;
>> +       else if (length == 384)
>> +               arg0.integer.value = 3;
>> +       else if (length == 512)
>> +               arg0.integer.value = 4;
> 
> It looks like switch () would be somewhat better.
> 
> Or maybe even
> 
> arg0.integer.value = length / 128;
> 
> The validation could be added too:
> 
> if (arg0.integer.value > 4 || arg0.integer.value * 128 != length)
>          return -EINVAL;
> 
> but it is pointless, because the caller is never passing an invalid
> number to it AFAICS.
> 

Thanks.  I'll swap over to one of these suggestions.

I will also split this patch separately from the other as the other will 
take some time with refactoring necessary in DRM that will take a cycle 
or two.

>>          else
>>                  return -EINVAL;
>>
>> @@ -1443,7 +1447,7 @@ 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;
>> +               length = 512;
>>
>>                  if (!video_device)
>>                          continue;
>> @@ -1478,13 +1482,18 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
>>
>>                  if (ACPI_FAILURE(status) || !buffer ||
>>                      buffer->type != ACPI_TYPE_BUFFER) {
>> -                       length = 128;
>> -                       status = acpi_video_device_EDID(video_device, &buffer,
>> -                                                       length);
>> -                       if (ACPI_FAILURE(status) || !buffer ||
>> -                           buffer->type != ACPI_TYPE_BUFFER) {
>> -                               continue;
>> +                       while (length) {
> 
> I would prefer a do {} while () loop here, which could include the
> first invocation of acpi_video_device_EDID() too (and reduce code
> duplication a bit).
> 
>> +                               length -= 128;
>> +                               status = acpi_video_device_EDID(video_device, &buffer,
>> +                                                               length);
> 
> No line break, please.
> 
>> +                               if (ACPI_FAILURE(status) || !buffer ||
>> +                                   buffer->type != ACPI_TYPE_BUFFER) {
>> +                                       continue;
>> +                               }
>> +                               break;
>>                          }
>> +                       if (!length)
>> +                               continue;
>>                  }
>>
>>                  *edid = buffer->buffer.pointer;
>> --


  reply	other threads:[~2024-01-29 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 18:46 [PATCH 0/2] Fetch EDID from ACPI _DDC method if available Mario Limonciello
2024-01-26 18:46 ` [PATCH 1/2] ACPI: video: Handle fetching EDID that is longer than 256 bytes Mario Limonciello
2024-01-29 13:54   ` Rafael J. Wysocki
2024-01-29 16:12     ` Mario Limonciello [this message]
2024-01-26 18:46 ` [PATCH 2/2] drm/amd: Fetch the EDID from _DDC if available for eDP Mario Limonciello
2024-01-29  9:39   ` Jani Nikula
2024-01-29 16:09     ` Mario Limonciello
2024-01-29 16:46       ` Jani Nikula
2024-01-29 16:54         ` Mario Limonciello

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=ad625d5f-6b4b-41bb-a9c0-edb513697802@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