File: generate-hwdb.c

package info (click to toggle)
switcheroo-control 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 316 kB
  • sloc: ansic: 939; python: 435; xml: 200; makefile: 28; sh: 1
file content (62 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

/*
 * This tool generates updated hwdb data for Intel GPUs, so we
 * get the same name in udev as we do in Mesa.
 */

#include <locale.h>
#include <glib.h>

typedef struct {
	int vid;
	int pid;
	const char *name;
} pci_id;

/* Intel drivers */
#define CHIPSET(w, x, y, z) { 0x8086, w, z },
pci_id i965_pci_ids[] = {
#include "/home/hadess/Projects/jhbuild/mesa/include/pci_ids/i965_pci_ids.h"
	{ },
};
#undef CHIPSET
#define CHIPSET(x, y, z) { 0x8086, x, z },
pci_id i915_pci_ids[] = {
#include "/home/hadess/Projects/jhbuild/mesa/include/pci_ids/i915_pci_ids.h"
	{},
};

static void
print_table (pci_id *table)
{
	guint i;

	for (i = 0; table[i].vid != 0; i++) {
		const char *name;

		name = table[i].name;
		g_print ("pci:v%08Xd%08X*\n", table[i].vid, table[i].pid);

		/* Quirk */
		if (g_str_equal ("Mobile IntelĀ® GM45 Express Chipset", name))
			name = "Intel(R) Mobile GM45 Express Chipset";

		if (!g_str_has_prefix (name, "Intel(R) "))
			g_error ("Unhandled name %s", name);
		g_print (" SWITCHEROO_CONTROL_VENDOR_NAME=Intel(R)\n");
		g_print (" SWITCHEROO_CONTROL_PRODUCT_NAME=%s\n", name + strlen ("Intel(R) "));
		g_print ("\n");
	}
}

int main (int argc, char **argv)
{
	setlocale (LC_ALL, "");

	g_print ("# Generated by a helper script in switcheroo-control\n");
	g_print ("# See https://gitlab.freedesktop.org/hadess/switcheroo-control/\n\n");

	print_table (i965_pci_ids);
	print_table (i915_pci_ids);
	return 0;
}