Rev 4358 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | /* |
2 | * Copyright © 2011 Intel Corporation |
||
3 | * |
||
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
5 | * copy of this software and associated documentation files (the "Software"), |
||
6 | * to deal in the Software without restriction, including without limitation |
||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
8 | * and/or sell copies of the Software, and to permit persons to whom the |
||
9 | * Software is furnished to do so, subject to the following conditions: |
||
10 | * |
||
11 | * The above copyright notice and this permission notice (including the next |
||
12 | * paragraph) shall be included in all copies or substantial portions of the |
||
13 | * Software. |
||
14 | * |
||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||
19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||
20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
22 | * DEALINGS IN THE SOFTWARE. |
||
23 | * |
||
24 | * Authors: |
||
25 | * Kristian Høgsberg |
||
26 | * Benjamin Franzke |
||
27 | */ |
||
28 | |||
29 | #include |
||
30 | #include |
||
4548 | Serge | 31 | #include |
32 | #include |
||
4358 | Serge | 33 | |
34 | #include "gbm_driint.h" |
||
35 | #define DRIVER_MAP_DRI2_ONLY |
||
36 | #include "pci_ids/pci_id_driver_map.h" |
||
37 | |||
38 | char * |
||
39 | dri_fd_get_driver_name(int fd) |
||
40 | { |
||
4548 | Serge | 41 | ioctl_t io; |
42 | struct pci_device device; |
||
4358 | Serge | 43 | char *driver = NULL; |
4548 | Serge | 44 | int i, j; |
4358 | Serge | 45 | |
4548 | Serge | 46 | io.handle = fd; |
47 | io.io_code = SRV_GET_PCI_INFO; |
||
48 | io.input = &device; |
||
49 | io.inp_size = sizeof(device); |
||
50 | io.output = NULL; |
||
51 | io.out_size = 0; |
||
52 | |||
53 | if (call_service(&io)!=0) |
||
4358 | Serge | 54 | return NULL; |
55 | |||
4548 | Serge | 56 | for (i = 0; driver_map[i].driver; i++) |
57 | { |
||
58 | if (device.vendor_id != driver_map[i].vendor_id) |
||
4358 | Serge | 59 | continue; |
4548 | Serge | 60 | if (driver_map[i].num_chips_ids == -1) |
61 | { |
||
4358 | Serge | 62 | driver = strdup(driver_map[i].driver); |
4548 | Serge | 63 | printf("pci id for %d: %04x:%04x, driver %s\n", |
64 | fd, device.vendor_id, device.device_id, driver); |
||
4358 | Serge | 65 | goto out; |
66 | } |
||
67 | |||
68 | for (j = 0; j < driver_map[i].num_chips_ids; j++) |
||
4548 | Serge | 69 | if (driver_map[i].chip_ids[j] == device.device_id) |
70 | { |
||
4358 | Serge | 71 | driver = strdup(driver_map[i].driver); |
4548 | Serge | 72 | printf("pci id for %d: %04x:%04x, driver %s\n", |
73 | fd, device.vendor_id, device.device_id, driver); |
||
4358 | Serge | 74 | goto out; |
75 | } |
||
76 | } |
||
77 | |||
78 | out: |
||
79 | |||
80 | return driver; |
||
81 | }> |