mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-20 02:38:07 +02:00
loader: allow DRI_PRIME=vendor_id:device_id syntax
This syntax allows to select a specific GPU without depending on the pci bus information. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17298>
This commit is contained in:
parent
6d50e4cdc1
commit
4005ba3ed4
1 changed files with 17 additions and 3 deletions
|
|
@ -328,6 +328,8 @@ int loader_get_user_preferred_fd(int default_fd, bool *different_device)
|
|||
char *default_tag, *prime = NULL;
|
||||
drmDevicePtr devices[MAX_DRM_DEVICES];
|
||||
int i, num_devices, fd = -1;
|
||||
bool prime_is_vid_did;
|
||||
uint16_t vendor_id, device_id;
|
||||
|
||||
if (dri_prime)
|
||||
prime = strdup(dri_prime);
|
||||
|
|
@ -339,6 +341,8 @@ int loader_get_user_preferred_fd(int default_fd, bool *different_device)
|
|||
if (prime == NULL) {
|
||||
*different_device = false;
|
||||
return default_fd;
|
||||
} else {
|
||||
prime_is_vid_did = sscanf(prime, "%hx:%hx", &vendor_id, &device_id) == 2;
|
||||
}
|
||||
|
||||
default_tag = drm_get_id_path_tag_for_fd(default_fd);
|
||||
|
|
@ -353,17 +357,27 @@ int loader_get_user_preferred_fd(int default_fd, bool *different_device)
|
|||
if (!(devices[i]->available_nodes & 1 << DRM_NODE_RENDER))
|
||||
continue;
|
||||
|
||||
/* two formats of DRI_PRIME are supported:
|
||||
/* three formats of DRI_PRIME are supported:
|
||||
* "1": choose any other card than the card used by default.
|
||||
* id_path_tag: (for example "pci-0000_02_00_0") choose the card
|
||||
* with this id_path_tag.
|
||||
* vendor_id:device_id
|
||||
*/
|
||||
if (!strcmp(prime,"1")) {
|
||||
if (drm_device_matches_tag(devices[i], default_tag))
|
||||
continue;
|
||||
} else {
|
||||
if (!drm_device_matches_tag(devices[i], prime))
|
||||
continue;
|
||||
if (prime_is_vid_did && devices[i]->bustype == DRM_BUS_PCI &&
|
||||
devices[i]->deviceinfo.pci->vendor_id == vendor_id &&
|
||||
devices[i]->deviceinfo.pci->device_id == device_id) {
|
||||
/* Update prime for the "different_device"
|
||||
* determination below. */
|
||||
free(prime);
|
||||
prime = drm_construct_id_path_tag(devices[i]);
|
||||
} else {
|
||||
if (!drm_device_matches_tag(devices[i], prime))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fd = loader_open_device(devices[i]->nodes[DRM_NODE_RENDER]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue