[Mesa-dev] a suggestion of loader_get_driver_for_fd
Rob Clark
robdclark at gmail.com
Thu Jan 7 06:57:33 PST 2016
well, there are a lot of cases where mesa driver name != drm driver
name, for example. Or a single kernel driver maps to one of several
dri drivers. Etc, etc. So I'm not sure if fallback to kernel driver
name is so useful. But a patch sent to mesa-dev is a better idea, to
get feedback from more than just one person ;-)
BR,
-R
On Thu, Jan 7, 2016 at 3:03 AM, <VictorHe at zhaoxin.com> wrote:
> Dear robclark,
>
> Sorry to troble you,
>
> I try to integrate our dri driver to mesa glx3, but I see follow
> function was mainly hardcode check pci_id in driver_map;
>
> so I suggest it maybe give a chance to fallback drmGetVersion when no
> hardcoded pci_id match in driver_map but vender_id & chip_id was successful
> return from loader_get_pci_id_for_fd
>
>
>
>
>
> char *
>
> loader_get_driver_for_fd(int fd, unsigned driver_types)
>
> {
>
> int vendor_id, chip_id, i, j;
>
> char *driver = NULL;
>
>
>
> if (!driver_types)
>
> driver_types = _LOADER_GALLIUM | _LOADER_DRI;
>
>
>
> if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
>
>
>
> #ifndef __NOT_HAVE_DRM_H
>
> /* fallback to drmGetVersion(): */
>
> drmVersionPtr version = drmGetVersion(fd);
>
>
>
> if (!version) {
>
> log_(_LOADER_WARNING, "failed to get driver name for fd %d\n", fd);
>
> return NULL;
>
> }
>
>
>
> driver = strndup(version->name, version->name_len);
>
> log_(_LOADER_INFO, "using driver %s for %d\n", driver, fd);
>
>
>
> drmFreeVersion(version);
>
> #endif
>
>
>
> return driver;
>
> }
>
>
>
> for (i = 0; driver_map[i].driver; i++) {
>
> if (vendor_id != driver_map[i].vendor_id)
>
> continue;
>
>
>
> if (!(driver_types & driver_map[i].driver_types))
>
> continue;
>
>
>
> if (driver_map[i].predicate && !driver_map[i].predicate(fd))
>
> continue;
>
>
>
> if (driver_map[i].num_chips_ids == -1) {
>
> driver = strdup(driver_map[i].driver);
>
>
>
>
>
> Thanks very much.
>
> 本邮件仅针对指定的收件人发送并可能含有保密或专有内容。任何非指定收件人所为之查阅、转发或使用本信息是不被允许的。
> 如果您误收到本邮件,请立即告知发件人并删除本邮件及所有附件。谢谢!
> The information transmitted in this e-mail is intended only for the
> addressee and may contain confidential and/or privileged material. Any
> review, retransmission, dissemination or other use of this information by
> persons or entities other than the intended recipient is prohibited. If you
> received this e-mail in error, please notify the sender immediately, and
> delete this e-mail and any attachments. Thank you.
More information about the mesa-dev
mailing list