From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v1 01/13] drm/edid: add block count and data helper functions for drm_edid
Date: Thu, 2 Jun 2022 19:54:59 +0300 [thread overview]
Message-ID: <YpjrYx13Bh6Gwj68@intel.com> (raw)
In-Reply-To: <a08352924ad49a32213d8979d43d480f3f7b4a11.1653381821.git.jani.nikula@intel.com>
On Tue, May 24, 2022 at 01:39:23PM +0300, Jani Nikula wrote:
> Add drm_edid based block count and data access helper functions that
> take the EDID allocated size into account.
>
> At the moment, the allocated size should always match the EDID size
> indicated by the extension count, but this will change in the future.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/drm_edid.c | 42 +++++++++++++++++++++++++++++++-------
> 1 file changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 929fc0e46751..682d954a9e42 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1613,6 +1613,35 @@ static const void *edid_extension_block_data(const struct edid *edid, int index)
> return edid_block_data(edid, index + 1);
> }
>
> +static int drm_edid_block_count(const struct drm_edid *drm_edid)
> +{
> + int num_blocks;
> +
> + /* Starting point */
> + num_blocks = edid_block_count(drm_edid->edid);
> +
> + /* Limit by allocated size */
> + num_blocks = min(num_blocks, (int)drm_edid->size / EDID_LENGTH);
Hmm. Is there a particular reason we couldn't just always
return drm_edid->size/EDID_LENGTH here? That is, why would we not
set drm_edid->size to always reflect the actual size of the EDID?
> +
> + return num_blocks;
> +}
> +
> +static int drm_edid_extension_block_count(const struct drm_edid *drm_edid)
> +{
> + return drm_edid_block_count(drm_edid) - 1;
> +}
> +
> +static const void *drm_edid_block_data(const struct drm_edid *drm_edid, int index)
> +{
> + return edid_block_data(drm_edid->edid, index);
> +}
> +
> +static const void *drm_edid_extension_block_data(const struct drm_edid *drm_edid,
> + int index)
> +{
> + return edid_extension_block_data(drm_edid->edid, index);
> +}
> +
> /*
> * Initializer helper for legacy interfaces, where we have no choice but to
> * trust edid size. Not for general purpose use.
> @@ -1665,8 +1694,8 @@ static const void *__drm_edid_iter_next(struct drm_edid_iter *iter)
> if (!iter->drm_edid)
> return NULL;
>
> - if (iter->index < edid_block_count(iter->drm_edid->edid))
> - block = edid_block_data(iter->drm_edid->edid, iter->index++);
> + if (iter->index < drm_edid_block_count(iter->drm_edid))
> + block = drm_edid_block_data(iter->drm_edid, iter->index++);
>
> return block;
> }
> @@ -3574,22 +3603,21 @@ static int add_detailed_modes(struct drm_connector *connector,
> const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid,
> int ext_id, int *ext_index)
> {
> - const struct edid *edid = drm_edid ? drm_edid->edid : NULL;
> const u8 *edid_ext = NULL;
> int i;
>
> /* No EDID or EDID extensions */
> - if (!edid || !edid_extension_block_count(edid))
> + if (!drm_edid || !drm_edid_extension_block_count(drm_edid))
> return NULL;
>
> /* Find CEA extension */
> - for (i = *ext_index; i < edid_extension_block_count(edid); i++) {
> - edid_ext = edid_extension_block_data(edid, i);
> + for (i = *ext_index; i < drm_edid_extension_block_count(drm_edid); i++) {
> + edid_ext = drm_edid_extension_block_data(drm_edid, i);
> if (edid_block_tag(edid_ext) == ext_id)
> break;
> }
>
> - if (i >= edid_extension_block_count(edid))
> + if (i >= drm_edid_extension_block_count(drm_edid))
> return NULL;
>
> *ext_index = i + 1;
> --
> 2.30.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2022-06-02 16:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 10:39 [Intel-gfx] [PATCH v1 00/13] drm/edid: expand on struct drm_edid usage Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 01/13] drm/edid: add block count and data helper functions for drm_edid Jani Nikula
2022-05-24 13:29 ` Andrzej Hajda
2022-05-24 13:41 ` Jani Nikula
2022-06-02 16:54 ` Ville Syrjälä [this message]
2022-06-02 17:08 ` Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 02/13] drm/edid: keep track of alloc size in drm_do_get_edid() Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 03/13] drm/edid: add new interfaces around struct drm_edid Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 04/13] drm/edid: add drm_edid_connector_update() Jani Nikula
2022-06-02 17:09 ` Ville Syrjälä
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 05/13] drm/probe-helper: abstract .get_modes() connector helper call Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 06/13] drm/probe-helper: make .get_modes() optional, add default action Jani Nikula
2022-06-02 17:14 ` Ville Syrjälä
2022-06-07 11:14 ` Jani Nikula
2022-06-07 19:43 ` Ville Syrjälä
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 07/13] drm/probe-helper: add .get_edid() callback Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 08/13] drm/edid: add drm_edid_raw() to access the raw EDID data Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 09/13] drm/i915/edid: convert DP, HDMI and LVDS to drm_edid Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 10/13] drm/edid: do invalid block filtering in-place Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 11/13] drm/edid: add HF-EEODB support to EDID read and allocation Jani Nikula
2022-06-03 17:13 ` Ville Syrjälä
2022-06-07 11:26 ` Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 12/13] drm/edid: take HF-EEODB extension count into account Jani Nikula
2022-05-24 10:39 ` [Intel-gfx] [PATCH v1 13/13] drm/todo: add entry for converting the subsystem to struct drm_edid Jani Nikula
2022-05-24 11:02 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: expand on struct drm_edid usage Patchwork
2022-05-24 11:02 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-05-24 11:34 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-05-24 11:37 ` Jani Nikula
2022-05-24 11:41 ` Sarvela, Tomi P
2022-05-25 8:48 ` Jani Nikula
2022-05-24 15:58 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: expand on struct drm_edid usage (rev2) Patchwork
2022-05-24 15:58 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-05-24 19:58 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-05-24 22:25 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=YpjrYx13Bh6Gwj68@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
/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