info: add di_info_get_device_tag()
This is a new iteration of !115 (closed). More things are baked into the string:
- Model and serial codes are always baked in, because some EDIDs have identical strings but different codes (wlroots/wlroots#3913).
- Manufacture year + week, because I found ~410 cases in linuxhw/EDID where this helped.
- Unspecified ASCII string, because I found ~400 cases in linuxhw/EDID where this helped.
Small script to find duplicates in linuxhw/EDID
import os
import subprocess
tags = {}
for root, dirs, files in os.walk('../linuxhw-EDID/Digital'):
for name in files:
path = root + '/' + name
with open(path) as f:
raw = f.read()
raw = raw.replace('edid-decode (hex):', '')
raw = raw.split('---', 2)[0]
raw = raw.replace(' ', '').replace('\n', '')
try:
blob = bytes.fromhex(raw)
except ValueError:
print('MALFORMED: ' + path)
continue
result = subprocess.run(['build/test/di-edid-print'], input=blob, capture_output=True)
if result.returncode != 0:
print('ERROR: ' + path)
print(result.stderr.decode('utf-8'))
else:
tag = None
for l in result.stdout.decode('utf-8').split('\n'):
if l.startswith('device tag:'):
tag = l.split(':', 2)[1].strip()
assert(tag != None)
matches = tags.get(tag, [])
matches.append(path)
tags[tag] = matches
ndupes = 0
for tag in tags:
matches = tags[tag]
if len(matches) > 1:
ndupes += 1
print(tag, matches)
print('Number of duplicates:', ndupes)
cc @pq @Zamundaaa
Edited by Simon Ser