All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <quic_jesszhan@quicinc.com>,
	 Sam Ravnborg <sam@ravnborg.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] drm/panel: panel-edp: Match edp_panels with panel name
Date: Wed, 28 Feb 2024 16:21:37 -0800	[thread overview]
Message-ID: <CAD=FV=VMVr+eJ7eyuLGa671fMgH6ZX9zPOkbKzYJ0H79MZ2k9A@mail.gmail.com> (raw)
In-Reply-To: <20240228011133.1238439-3-hsinyi@chromium.org>

Hi,

On Tue, Feb 27, 2024 at 5:11 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
>
> @@ -2107,13 +2113,41 @@ static const struct edp_panel_entry edp_panels[] = {
>         { /* sentinal */ }
>  };
>
> -static const struct edp_panel_entry *find_edp_panel(u32 panel_id)
> +static bool edid_has_name(struct edid *edid, const char *panel_name)
> +{
> +       int i, j;
> +       char buf[13];
> +

Should have some comment about why this can't use
drm_edid_get_monitor_name(). AKA because panels seem to be storing the
monitor name tagged as raw strings instead of as the name. Should
probably also have some of the other checks from
is_display_descriptor() like checking for clock of 0 and pad1 of 0.


> +       for (i = 0; i < 4; i++) {

Instead of 4, I think this can be ARRAY_SIZE(edid->detailed_timings), right?


> +               strncpy(buf, edid->detailed_timings[i].data.other_data.data.str.str,
> +                       sizeof(buf));

I can never quite remember which of the strXcpy() routines are frowned
upon and which are the golden children at the moment. ...but I don't
think we really need the copy nor the local buffer anyway, right?
You're already going through this thing 1 byte at a time so just
compare it straight away.


> +               for (j = 0; j < 13; j++) {
> +                       if (buf[j] == 0x0a) {

Instead of hardcoding 0x0a, I think you want '\n', no?


> +                               buf[j] = '\0';
> +                               break;
> +                       }
> +               }
> +               buf[12] = '\0';
> +               if (strncmp(panel_name, buf, strlen(panel_name)) == 0)
> +                       return true;

Untested, but I think with my suggestions above the function becomes this:

static bool edid_has_name(struct edid *edid, const char *panel_name)
{
    int i, j;

    /*
     * We can't use drm_edid_get_monitor_name() since many eDP panels store
     * their name as a raw string. We'll accept either a string or name
     * match as long as the panel ID also matches.
     */
    for (i = 0; i < ARRAY_SIZE(edid->detailed_timings); i++) {
        struct detailed_timing *timing = &edid->detailed_timings[i];

        if (timing->pixel_clock != 0 ||
            timing->data.other_data.pad1 != 0 ||
            (timing->data.other_data.type != EDID_DETAIL_MONITOR_NAME &&
             timing->data.other_data.type != EDID_DETAIL_MONITOR_STRING))
                continue;

        for (j = 0; j < ARRAY_SIZE(timing->data.other_data.data.str.str); j++) {
            const char *str = timing->data.other_data.data.str.str;

            if (panel_name[j] == '\0') {
                if (str[j] == '\0' || str[j] == '\n')
                    return true;
                break;
            }
        }
        if (j == ARRAY_SIZE(timing->data.other_data.data.str.str) &&
            panel_name[j] == '\0')
            return true;
    }

    return false;
}

  parent reply	other threads:[~2024-02-29  0:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  1:05 [PATCH v2 0/3] Match panel with id and name Hsin-Yi Wang
2024-02-28  1:05 ` [PATCH v2 1/3] drm_edid: Support getting EDID through ddc without connector Hsin-Yi Wang
2024-02-28  1:28   ` Hsin-Yi Wang
2024-02-29  0:21   ` Doug Anderson
2024-02-29  0:54     ` Hsin-Yi Wang
2024-02-28  1:05 ` [PATCH v2 2/3] drm/panel: panel-edp: Match edp_panels with panel name Hsin-Yi Wang
2024-02-28  3:59   ` Dmitry Baryshkov
2024-02-29  0:21   ` Doug Anderson [this message]
2024-02-28  1:06 ` [PATCH v2 3/3] drm/panel: panel-edp: Fix AUO 0x405c panel naming and add a variant Hsin-Yi Wang
2024-02-29  0:22   ` Doug Anderson
2024-02-29  1:04     ` Hsin-Yi Wang
2024-02-29  1:12       ` Dmitry Baryshkov
2024-02-29  1:17         ` Hsin-Yi Wang
2024-03-04 20:05     ` Hsin-Yi Wang

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='CAD=FV=VMVr+eJ7eyuLGa671fMgH6ZX9zPOkbKzYJ0H79MZ2k9A@mail.gmail.com' \
    --to=dianders@chromium.org \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hsinyi@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_jesszhan@quicinc.com \
    --cc=sam@ravnborg.org \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.