From: Jani Nikula <jani.nikula@linux.intel.com>
To: Douglas Anderson <dianders@chromium.org>,
Thierry Reding <thierry.reding@gmail.com>,
Rob Herring <robh+dt@kernel.org>, Sam Ravnborg <sam@ravnborg.org>
Cc: devicetree@vger.kernel.org, Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Linus W <linus.walleij@linaro.org>,
Daniel Vetter <daniel@ffwll.ch>,
linux-arm-msm@vger.kernel.org,
Steev Klimaszewski <steev@kali.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org,
Douglas Anderson <dianders@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 02/15] drm/edid: Break out reading block 0 of the EDID
Date: Tue, 14 Sep 2021 21:50:15 +0300 [thread overview]
Message-ID: <878rzz0z6g.fsf@intel.com> (raw)
In-Reply-To: <20210909135838.v4.2.I62e76a034ac78c994d40a23cd4ec5aeee56fa77c@changeid>
On Thu, 09 Sep 2021, Douglas Anderson <dianders@chromium.org> wrote:
> A future change wants to be able to read just block 0 of the EDID, so
> break it out of drm_do_get_edid() into a sub-function.
>
> This is intended to be a no-op change--just code movement.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
>
> Changes in v4:
> - "u8 *edid" => "void *edid" to avoid cast.
> - Don't put kmalloc() in the "if" test even if the old code did.
> - drm_do_get_edid_blk0() => drm_do_get_edid_base_block()
>
> drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++-----------
> 1 file changed, 45 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 6325877c5fd6..520fe1391769 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1905,6 +1905,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector)
> }
> EXPORT_SYMBOL(drm_add_override_edid_modes);
>
> +static struct edid *drm_do_get_edid_base_block(
> + int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
> + size_t len),
> + void *data, bool *edid_corrupt, int *null_edid_counter)
> +{
> + int i;
> + void *edid;
> +
> + edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
> + if (edid == NULL)
> + return NULL;
> +
> + /* base block fetch */
> + for (i = 0; i < 4; i++) {
> + if (get_edid_block(data, edid, 0, EDID_LENGTH))
> + goto out;
> + if (drm_edid_block_valid(edid, 0, false, edid_corrupt))
> + break;
> + if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) {
> + if (null_edid_counter)
> + (*null_edid_counter)++;
> + goto carp;
> + }
> + }
> + if (i == 4)
> + goto carp;
> +
> + return edid;
> +
> +carp:
> + kfree(edid);
> + return ERR_PTR(-EINVAL);
> +
> +out:
> + kfree(edid);
> + return NULL;
> +}
> +
> /**
> * drm_do_get_edid - get EDID data using a custom EDID block read function
> * @connector: connector we're probing
> @@ -1938,25 +1976,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
> if (override)
> return override;
>
> - if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
> + edid = (u8 *)drm_do_get_edid_base_block(get_edid_block, data,
> + &connector->edid_corrupt,
> + &connector->null_edid_counter);
> + if (IS_ERR_OR_NULL(edid)) {
> + if (IS_ERR(edid))
> + connector_bad_edid(connector, edid, 1);
> return NULL;
> -
> - /* base block fetch */
> - for (i = 0; i < 4; i++) {
> - if (get_edid_block(data, edid, 0, EDID_LENGTH))
> - goto out;
> - if (drm_edid_block_valid(edid, 0, false,
> - &connector->edid_corrupt))
> - break;
> - if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) {
> - connector->null_edid_counter++;
> - goto carp;
> - }
> }
> - if (i == 4)
> - goto carp;
>
> - /* if there's no extensions, we're done */
> + /* if there's no extensions or no connector, we're done */
> valid_extensions = edid[0x7e];
> if (valid_extensions == 0)
> return (struct edid *)edid;
> @@ -2010,8 +2039,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>
> return (struct edid *)edid;
>
> -carp:
> - connector_bad_edid(connector, edid, 1);
> out:
> kfree(edid);
> return NULL;
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2021-09-14 18:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 21:00 [PATCH v4 00/15] eDP: Support probing eDP panels dynamically instead of hardcoding Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 01/15] dt-bindings: drm/panel-simple-edp: Introduce generic eDP panels Douglas Anderson
2021-09-14 19:11 ` Stephen Boyd
2021-09-14 20:13 ` Doug Anderson
2021-09-09 21:00 ` [PATCH v4 02/15] drm/edid: Break out reading block 0 of the EDID Douglas Anderson
2021-09-14 18:50 ` Jani Nikula [this message]
2021-09-09 21:00 ` [PATCH v4 03/15] drm/edid: Allow querying/working with the panel ID from " Douglas Anderson
2021-09-14 18:53 ` Jani Nikula
2021-09-09 21:00 ` [PATCH v4 04/15] drm/edid: Use new encoded panel id style for quirks matching Douglas Anderson
2021-09-14 18:16 ` Jani Nikula
2021-09-14 18:31 ` Doug Anderson
2021-09-14 18:59 ` Jani Nikula
2021-09-14 19:36 ` Andrzej Hajda
2021-09-14 20:02 ` Doug Anderson
2021-09-14 18:55 ` Jani Nikula
2021-09-09 21:00 ` [PATCH v4 05/15] ARM: configs: Everyone who had PANEL_SIMPLE now gets PANEL_EDP Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 06/15] arm64: defconfig: " Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 07/15] drm/panel-edp: Split eDP panels out of panel-simple Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 08/15] drm/panel-edp: Move some wayward panels to the eDP driver Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 09/15] drm/panel-simple: Non-eDP panels don't need "HPD" handling Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 10/15] drm/panel-edp: Split the delay structure out Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 11/15] drm/panel-edp: Better describe eDP panel delays Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 12/15] drm/panel-edp: hpd_reliable shouldn't be subtraced from hpd_absent Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 13/15] drm/panel-edp: Fix "prepare_to_enable" if panel doesn't handle HPD Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 14/15] drm/panel-edp: Don't re-read the EDID every time we power off the panel Douglas Anderson
2021-09-09 21:00 ` [PATCH v4 15/15] drm/panel-edp: Implement generic "edp-panel"s probed by EDID Douglas Anderson
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=878rzz0z6g.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=bjorn.andersson@linaro.org \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sam@ravnborg.org \
--cc=steev@kali.org \
--cc=thierry.reding@gmail.com \
--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 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).