From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Jani Nikula <jani.nikula@intel.com>, dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, Iaroslav Boliukin <iam@lach.pw>
Subject: Re: [PATCH 3/4] drm/displayid: provide access to DisplayID version and primary use case
Date: Tue, 21 Feb 2023 19:27:37 +0300 [thread overview]
Message-ID: <3b090fb3-266e-74c1-c2dd-4ae3d4701e30@collabora.com> (raw)
In-Reply-To: <ad8a35c109f97ffe115e6b18e4a132b592f11089.1676580180.git.jani.nikula@intel.com>
On 2/16/23 23:45, Jani Nikula wrote:
> The DisplayID structure version and primary use case are stored in the
> DisplayID Base Section. We should be checking them in a number of places
> when parsing the DisplayID blocks. Currently, we completely ignore the
> primary use case, and just look at the block tags without cross-checking
> against structure version.
>
> Store the version and primary use case in the DisplayID iterator, and
> provide accessors to them. In general, the information is needed when
> iterating the blocks, and this is a convenient place to both store and
> retrieve the information during parsing.
>
> Promote using accessors rather than users poking at the iterator
> directly.
>
> Cc: Iaroslav Boliukin <iam@lach.pw>
> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/drm_displayid.c | 30 ++++++++++++++++++++++++++++++
> include/drm/drm_displayid.h | 12 +++++++++++-
> 2 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c
> index 0de9b5530393..9edc111be7ee 100644
> --- a/drivers/gpu/drm/drm_displayid.c
> +++ b/drivers/gpu/drm/drm_displayid.c
> @@ -123,6 +123,9 @@ __displayid_iter_next(struct displayid_iter *iter)
> }
>
> for (;;) {
> + /* The first section we encounter is the base section */
> + bool base_section = !iter->section;
> +
> iter->section = drm_find_displayid_extension(iter->drm_edid,
> &iter->length,
> &iter->idx,
> @@ -132,6 +135,18 @@ __displayid_iter_next(struct displayid_iter *iter)
> return NULL;
> }
>
> + /* Save the structure version and primary use case. */
> + if (base_section) {
> + const struct displayid_header *base;
> +
> + base = displayid_get_header(iter->section, iter->length,
> + iter->idx);
> + if (!IS_ERR(base)) {
> + iter->version = base->rev;
> + iter->primary_use = base->prod_id;
> + }
> + }
> +
> iter->idx += sizeof(struct displayid_header);
>
> block = displayid_iter_block(iter);
> @@ -144,3 +159,18 @@ void displayid_iter_end(struct displayid_iter *iter)
> {
> memset(iter, 0, sizeof(*iter));
> }
> +
> +/* DisplayID Structure Version/Revision from the Base Section. */
> +u8 displayid_version(const struct displayid_iter *iter)
> +{
> + return iter->version;
> +}
> +
> +/*
> + * DisplayID Primary Use Case (2.0+) or Product Type Identifier (1.0-1.3) from
> + * the Base Section.
> + */
> +u8 displayid_primary_use(const struct displayid_iter *iter)
> +{
> + return iter->primary_use;
> +}
> diff --git a/include/drm/drm_displayid.h b/include/drm/drm_displayid.h
> index 49649eb8447e..566497eeb3b8 100644
> --- a/include/drm/drm_displayid.h
> +++ b/include/drm/drm_displayid.h
> @@ -139,7 +139,11 @@ struct displayid_vesa_vendor_specific_block {
> u8 mso;
> } __packed;
>
> -/* DisplayID iteration */
> +/*
> + * DisplayID iteration.
> + *
> + * Do not access directly, this is private.
> + */
> struct displayid_iter {
> const struct drm_edid *drm_edid;
>
> @@ -147,6 +151,9 @@ struct displayid_iter {
> int length;
> int idx;
> int ext_index;
> +
> + u8 version;
> + u8 primary_use;
> };
>
> void displayid_iter_edid_begin(const struct drm_edid *drm_edid,
> @@ -157,4 +164,7 @@ __displayid_iter_next(struct displayid_iter *iter);
> while (((__block) = __displayid_iter_next(__iter)))
> void displayid_iter_end(struct displayid_iter *iter);
>
> +u8 displayid_version(const struct displayid_iter *iter);
> +u8 displayid_primary_use(const struct displayid_iter *iter);
> +
> #endif
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
next prev parent reply other threads:[~2023-02-21 16:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 20:44 [PATCH 0/4] drm/displayid: use primary use case to figure out non-desktop Jani Nikula
2023-02-16 20:44 ` [PATCH 1/4] drm/displayid: add displayid_get_header() and check bounds better Jani Nikula
2023-02-21 16:27 ` Dmitry Osipenko
2023-02-16 20:44 ` [PATCH 2/4] drm/displayid: return struct displayid_header from validate_displayid() Jani Nikula
2023-02-21 16:27 ` Dmitry Osipenko
2023-02-16 20:45 ` [PATCH 3/4] drm/displayid: provide access to DisplayID version and primary use case Jani Nikula
2023-02-21 16:27 ` Dmitry Osipenko [this message]
2023-02-16 20:45 ` [PATCH 4/4] drm/edid: update non-desktop use also from DisplayID Jani Nikula
2023-02-21 16:27 ` Dmitry Osipenko
2023-02-17 10:46 ` [PATCH 5/4] drm/edid: parse Tiled Display Topology Data Block for DisplayID 2.0 Jani Nikula
2023-02-21 16:28 ` Dmitry Osipenko
2023-02-20 15:44 ` [PATCH 0/4] drm/displayid: use primary use case to figure out non-desktop Dmitry Osipenko
2023-02-21 16:29 ` Dmitry Osipenko
2023-02-27 0:03 ` Dmitry Osipenko
2023-02-27 14:57 ` Jani Nikula
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=3b090fb3-266e-74c1-c2dd-4ae3d4701e30@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=iam@lach.pw \
--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