[PATCH i-g-t v3 2/5] lib/monitor_edids: Add helper to get an EDID by its name
Kamil Konieczny
kamil.konieczny at linux.intel.com
Fri Dec 20 17:29:02 UTC 2024
Hi Louis,
On 2024-11-22 at 16:51:35 +0100, Louis Chauvet wrote:
> For testing specific EDID, it is useful to be able to retrieve an EDID by
> a verbose name.
>
> Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
> lib/monitor_edids/monitor_edids_helper.c | 28 ++++++++++++++++++++++++++++
> lib/monitor_edids/monitor_edids_helper.h | 1 +
> 2 files changed, 29 insertions(+)
>
> diff --git a/lib/monitor_edids/monitor_edids_helper.c b/lib/monitor_edids/monitor_edids_helper.c
> index a7a945659f751be99ecd9d55f9b7307df256d543..4d739937ede1e8f09eb6e8bf225f047d5c3dfd04 100644
> --- a/lib/monitor_edids/monitor_edids_helper.c
> +++ b/lib/monitor_edids/monitor_edids_helper.c
> @@ -19,6 +19,16 @@
> #include "dp_edids.h"
> #include "hdmi_edids.h"
>
> +struct {
Consider adding here list name.
> + struct monitor_edid *edid_list;
> + int list_size;
> +} ALL_EDIDS[] = {
> + {DP_EDIDS_NON_4K, DP_EDIDS_NON_4K_COUNT},
> + {DP_EDIDS_4K, DP_EDIDS_4K_COUNT},
> + {HDMI_EDIDS_NON_4K, HDMI_EDIDS_NON_4K_COUNT},
> + {HDMI_EDIDS_4K, HDMI_EDIDS_4K_COUNT},
> +};
> +
> static uint8_t convert_hex_char_to_byte(char c)
> {
> if (c >= '0' && c <= '9')
> @@ -167,3 +177,21 @@ struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count,
> }
> }
> }
> +
> +/*
Start with '/**', for example look into lib/drmtest.c
> + * get_edid_by_name() - Return the struct associated with a specific
> + * name
> + * @name: Name to search in available EDIDs
Add empty line ' *' here.
With above
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> + * Returns NULL if no edid are found
> + */
> +struct edid *get_edid_by_name(char *name)
> +{
> + for (int i = 0; i < ARRAY_SIZE(ALL_EDIDS); i++) {
> + for (int j = 0; j < ALL_EDIDS[i].list_size; j++) {
> + if (strcmp(ALL_EDIDS[i].edid_list[j].name, name) == 0)
> + return edid_from_monitor_edid(&ALL_EDIDS[i].edid_list[j]);
> + }
> + }
> +
> + return NULL;
> +}
> diff --git a/lib/monitor_edids/monitor_edids_helper.h b/lib/monitor_edids/monitor_edids_helper.h
> index e5069868683d97053d8e66666e83692f1b733db3..a45dca870eb20f66c9472be6643019d23bc18b9a 100644
> --- a/lib/monitor_edids/monitor_edids_helper.h
> +++ b/lib/monitor_edids/monitor_edids_helper.h
> @@ -34,5 +34,6 @@ void free_chamelium_edid_from_monitor_edid(struct chamelium_edid *edid);
>
> struct edid *edid_from_monitor_edid(const monitor_edid *monitor_edid);
> struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count, bool four_k);
> +struct edid *get_edid_by_name(char *name);
>
> #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
>
> --
> 2.47.0
>
More information about the igt-dev
mailing list