aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/gen_pnpids.sh
blob: 80e5542d73acab084bcfab5fe0e87abd24f9668a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh -eu
#
# usage: gen_pnpids.sh < pnp.ids > pnpids.c

gen_pnps()
{
	while read -r id vendor; do
		[ "${#id}" = 3 ] || exit 1

		printf "\tcase PNP_ID('%c', '%c', '%c'): return \"%s\";\n" \
			"$id" "${id#?}" "${id#??}" "$vendor"
	done
}

cat << EOF
#include <stdint.h>
#include <stddef.h>
#include "backend/drm/util.h"
#define PNP_ID(a, b, c) ((a & 0x1f) << 10) | ((b & 0x1f) << 5) | (c & 0x1f)
const char *get_pnp_manufacturer(uint16_t code) {
	switch (code) {
$(gen_pnps)
	}
	return NULL;
}
#undef PNP_ID
EOF