mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
backend/drm: fetch EDID manufacturer from udev_hwdb
Maintaining our internal table up-to-date is tedious: one needs to manually go through the PnP ID registry [1] and check whether we're missing any entry. udev_hwdb already has an API to fetch a manufacturer name from its PnP ID. Use that instead. [1]: https://uefi.org/pnp_id_list
This commit is contained in:
parent
fa9b61004b
commit
e646d882cf
5 changed files with 67 additions and 81 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <libudev.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -58,6 +59,7 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
|
||||
finish_drm_resources(drm);
|
||||
|
||||
udev_hwdb_unref(drm->hwdb);
|
||||
free(drm->name);
|
||||
wlr_session_close_file(drm->session, drm->dev);
|
||||
wl_event_source_remove(drm->drm_event);
|
||||
|
|
@ -172,6 +174,23 @@ static void handle_parent_destroy(struct wl_listener *listener, void *data) {
|
|||
backend_destroy(&drm->backend);
|
||||
}
|
||||
|
||||
static struct udev_hwdb *create_udev_hwdb(void) {
|
||||
struct udev *udev = udev_new();
|
||||
if (!udev) {
|
||||
wlr_log(WLR_ERROR, "udev_new failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct udev_hwdb *hwdb = udev_hwdb_new(udev);
|
||||
udev_unref(udev);
|
||||
if (!hwdb) {
|
||||
wlr_log(WLR_ERROR, "udev_hwdb_new failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return hwdb;
|
||||
}
|
||||
|
||||
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
||||
struct wlr_session *session, struct wlr_device *dev,
|
||||
struct wlr_backend *parent) {
|
||||
|
|
@ -226,6 +245,12 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
|||
drm->session_active.notify = handle_session_active;
|
||||
wl_signal_add(&session->events.active, &drm->session_active);
|
||||
|
||||
drm->hwdb = create_udev_hwdb();
|
||||
if (!drm->hwdb) {
|
||||
wlr_log(WLR_INFO, "Failed to load udev_hwdb, "
|
||||
"falling back to PnP IDs instead of manufacturer names");
|
||||
}
|
||||
|
||||
if (!check_drm_features(drm)) {
|
||||
goto error_event;
|
||||
}
|
||||
|
|
@ -275,6 +300,7 @@ error_mgpu_renderer:
|
|||
error_resources:
|
||||
finish_drm_resources(drm);
|
||||
error_event:
|
||||
udev_hwdb_unref(drm->hwdb);
|
||||
wl_list_remove(&drm->session_active.link);
|
||||
wl_event_source_remove(drm->drm_event);
|
||||
error_fd:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue