mirror of
https://gitlab.freedesktop.org/emersion/libdisplay-info.git
synced 2024-11-16 19:48:30 +01:00
info: use byte descriptors in di_info_get_product_name()
These contain more user-friendly names. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
4346c405b8
commit
b4544c5012
1 changed files with 27 additions and 7 deletions
34
info.c
34
info.c
|
@ -43,22 +43,42 @@ di_info_get_edid(const struct di_info *info)
|
|||
char *
|
||||
di_info_get_product_name(const struct di_info *info)
|
||||
{
|
||||
char name[64], serial[32];
|
||||
char name[256], product_code[32], serial_code[32];
|
||||
const char *product, *serial;
|
||||
const struct di_edid_vendor_product *edid_vendor_product;
|
||||
const struct di_edid_display_descriptor *const *display_descs;
|
||||
size_t i;
|
||||
|
||||
edid_vendor_product = di_edid_get_vendor_product(info->edid);
|
||||
|
||||
snprintf(product_code, sizeof(product_code), "0x%X" PRIu16,
|
||||
edid_vendor_product->product);
|
||||
if (edid_vendor_product->serial != 0) {
|
||||
snprintf(serial, sizeof(serial), " 0x%X" PRIu32,
|
||||
snprintf(serial_code, sizeof(serial), " 0x%X" PRIu32,
|
||||
edid_vendor_product->serial);
|
||||
} else {
|
||||
serial[0] = '\0';
|
||||
serial_code[0] = '\0';
|
||||
}
|
||||
|
||||
/* TODO: use strings from Detailed Timing Descriptors, if any */
|
||||
snprintf(name, sizeof(name), "%.3s 0x%X" PRIu16 "%s",
|
||||
edid_vendor_product->manufacturer,
|
||||
edid_vendor_product->product, serial);
|
||||
product = product_code;
|
||||
serial = serial_code;
|
||||
display_descs = di_edid_get_display_descriptors(info->edid);
|
||||
for (i = 0; display_descs[i] != NULL; i++) {
|
||||
const struct di_edid_display_descriptor *desc = display_descs[i];
|
||||
switch (di_edid_display_descriptor_get_tag(desc)) {
|
||||
case DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_SERIAL:
|
||||
serial = di_edid_display_descriptor_get_string(desc);
|
||||
break;
|
||||
case DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_NAME:
|
||||
product = di_edid_display_descriptor_get_string(desc);
|
||||
break;
|
||||
default:
|
||||
break; /* Ignore */
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "%.3s %s%s",
|
||||
edid_vendor_product->manufacturer, product, serial);
|
||||
|
||||
return strdup(name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue