Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/displayid: provide access to DisplayID version and primary use case

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>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ad8a35c109f97ffe115e6b18e4a132b592f11089.1676580180.git.jani.nikula@intel.com

authored by

Jani Nikula and committed by
Dmitry Osipenko
b568e6bb 5631f6a0

+41 -1
+30
drivers/gpu/drm/drm_displayid.c
··· 123 123 } 124 124 125 125 for (;;) { 126 + /* The first section we encounter is the base section */ 127 + bool base_section = !iter->section; 128 + 126 129 iter->section = drm_find_displayid_extension(iter->drm_edid, 127 130 &iter->length, 128 131 &iter->idx, ··· 133 130 if (!iter->section) { 134 131 iter->drm_edid = NULL; 135 132 return NULL; 133 + } 134 + 135 + /* Save the structure version and primary use case. */ 136 + if (base_section) { 137 + const struct displayid_header *base; 138 + 139 + base = displayid_get_header(iter->section, iter->length, 140 + iter->idx); 141 + if (!IS_ERR(base)) { 142 + iter->version = base->rev; 143 + iter->primary_use = base->prod_id; 144 + } 136 145 } 137 146 138 147 iter->idx += sizeof(struct displayid_header); ··· 158 143 void displayid_iter_end(struct displayid_iter *iter) 159 144 { 160 145 memset(iter, 0, sizeof(*iter)); 146 + } 147 + 148 + /* DisplayID Structure Version/Revision from the Base Section. */ 149 + u8 displayid_version(const struct displayid_iter *iter) 150 + { 151 + return iter->version; 152 + } 153 + 154 + /* 155 + * DisplayID Primary Use Case (2.0+) or Product Type Identifier (1.0-1.3) from 156 + * the Base Section. 157 + */ 158 + u8 displayid_primary_use(const struct displayid_iter *iter) 159 + { 160 + return iter->primary_use; 161 161 }
+11 -1
include/drm/drm_displayid.h
··· 139 139 u8 mso; 140 140 } __packed; 141 141 142 - /* DisplayID iteration */ 142 + /* 143 + * DisplayID iteration. 144 + * 145 + * Do not access directly, this is private. 146 + */ 143 147 struct displayid_iter { 144 148 const struct drm_edid *drm_edid; 145 149 ··· 151 147 int length; 152 148 int idx; 153 149 int ext_index; 150 + 151 + u8 version; 152 + u8 primary_use; 154 153 }; 155 154 156 155 void displayid_iter_edid_begin(const struct drm_edid *drm_edid, ··· 163 156 #define displayid_iter_for_each(__block, __iter) \ 164 157 while (((__block) = __displayid_iter_next(__iter))) 165 158 void displayid_iter_end(struct displayid_iter *iter); 159 + 160 + u8 displayid_version(const struct displayid_iter *iter); 161 + u8 displayid_primary_use(const struct displayid_iter *iter); 166 162 167 163 #endif