Rev 4358 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4358 | Rev 4548 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | * Benjamin Franzke |
26 | * Benjamin Franzke |
27 | */ |
27 | */ |
Line 28... | Line 28... | ||
28 | 28 | ||
29 | #include |
29 | #include |
30 | #include |
- | |
31 | 30 | #include |
|
- | 31 | #include |
|
Line 32... | Line 32... | ||
32 | #include |
32 | #include |
33 | 33 | ||
34 | #include "gbm_driint.h" |
34 | #include "gbm_driint.h" |
Line 35... | Line 35... | ||
35 | #define DRIVER_MAP_DRI2_ONLY |
35 | #define DRIVER_MAP_DRI2_ONLY |
36 | #include "pci_ids/pci_id_driver_map.h" |
36 | #include "pci_ids/pci_id_driver_map.h" |
37 | 37 | ||
38 | char * |
38 | char * |
39 | dri_fd_get_driver_name(int fd) |
39 | dri_fd_get_driver_name(int fd) |
40 | { |
- | |
41 | struct udev *udev; |
40 | { |
42 | struct udev_device *device, *parent; |
- | |
43 | const char *pci_id; |
- | |
44 | char *driver = NULL; |
- | |
45 | int vendor_id, chip_id, i, j; |
- | |
46 | - | ||
47 | udev = udev_new(); |
41 | ioctl_t io; |
Line -... | Line 42... | ||
- | 42 | struct pci_device device; |
|
48 | device = _gbm_udev_device_new_from_fd(udev, fd); |
43 | char *driver = NULL; |
49 | if (device == NULL) |
44 | int i, j; |
50 | return NULL; |
45 | |
51 | 46 | io.handle = fd; |
|
52 | parent = udev_device_get_parent(device); |
47 | io.io_code = SRV_GET_PCI_INFO; |
Line 53... | Line -... | ||
53 | if (parent == NULL) { |
- | |
54 | fprintf(stderr, "gbm: could not get parent device"); |
48 | io.input = &device; |
55 | goto out; |
- | |
56 | } |
- | |
57 | 49 | io.inp_size = sizeof(device); |
|
58 | pci_id = udev_device_get_property_value(parent, "PCI_ID"); |
- | |
Line 59... | Line 50... | ||
59 | if (pci_id == NULL || |
50 | io.output = NULL; |
- | 51 | io.out_size = 0; |
|
60 | sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) { |
52 | |
61 | fprintf(stderr, "gbm: malformed or no PCI ID"); |
53 | if (call_service(&io)!=0) |
62 | goto out; |
54 | return NULL; |
- | 55 | ||
63 | } |
56 | for (i = 0; driver_map[i].driver; i++) |
64 | 57 | { |
|
65 | for (i = 0; driver_map[i].driver; i++) { |
58 | if (device.vendor_id != driver_map[i].vendor_id) |
66 | if (vendor_id != driver_map[i].vendor_id) |
59 | continue; |
67 | continue; |
60 | if (driver_map[i].num_chips_ids == -1) |
Line 68... | Line 61... | ||
68 | if (driver_map[i].num_chips_ids == -1) { |
61 | { |
69 | driver = strdup(driver_map[i].driver); |
62 | driver = strdup(driver_map[i].driver); |
- | 63 | printf("pci id for %d: %04x:%04x, driver %s\n", |
|
70 | _gbm_log("pci id for %d: %04x:%04x, driver %s", |
64 | fd, device.vendor_id, device.device_id, driver); |
71 | fd, vendor_id, chip_id, driver); |
65 | goto out; |
72 | goto out; |
66 | } |
73 | } |
67 | |
74 | 68 | for (j = 0; j < driver_map[i].num_chips_ids; j++) |
|
75 | for (j = 0; j < driver_map[i].num_chips_ids; j++) |
69 | if (driver_map[i].chip_ids[j] == device.device_id) |
Line 76... | Line 70... | ||
76 | if (driver_map[i].chip_ids[j] == chip_id) { |
70 | { |
77 | driver = strdup(driver_map[i].driver); |
- | |
78 | _gbm_log("pci id for %d: %04x:%04x, driver %s", |
- | |
Line 79... | Line 71... | ||
79 | fd, vendor_id, chip_id, driver); |
71 | driver = strdup(driver_map[i].driver); |
80 | goto out; |
72 | printf("pci id for %d: %04x:%04x, driver %s\n", |