backend-drm: explicitly pass device to initialization

The drm_device is initialized as a side effect of the (badly named)
drm_device_is_kms function. Explicitly pass the drm_device to be able to
initialize kms devices that are not the main drm device of the drm backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
dev
Michael Tretter 3 years ago committed by Daniel Stone
parent deebfd99e3
commit dfceb60274
  1. 15
      libweston/backend-drm/drm.c

@ -2734,9 +2734,9 @@ drm_device_changed(struct weston_compositor *compositor,
* sets b->drm.fd and b->drm.filename to the opened device. * sets b->drm.fd and b->drm.filename to the opened device.
*/ */
static bool static bool
drm_device_is_kms(struct drm_backend *b, struct udev_device *udev_device) drm_device_is_kms(struct drm_backend *b, struct drm_device *device,
struct udev_device *udev_device)
{ {
struct drm_device *device = b->drm;
struct weston_compositor *compositor = b->compositor; struct weston_compositor *compositor = b->compositor;
const char *filename = udev_device_get_devnode(udev_device); const char *filename = udev_device_get_devnode(udev_device);
const char *sysnum = udev_device_get_sysnum(udev_device); const char *sysnum = udev_device_get_sysnum(udev_device);
@ -2847,7 +2847,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
/* Make sure this device is actually capable of modesetting; /* Make sure this device is actually capable of modesetting;
* if this call succeeds, device->drm.{fd,filename} will be set, * if this call succeeds, device->drm.{fd,filename} will be set,
* and any old values freed. */ * and any old values freed. */
if (!drm_device_is_kms(b, dev)) { if (!drm_device_is_kms(b, b->drm, dev)) {
udev_device_unref(dev); udev_device_unref(dev);
continue; continue;
} }
@ -2877,9 +2877,9 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
} }
static struct udev_device * static struct udev_device *
open_specific_drm_device(struct drm_backend *b, const char *name) open_specific_drm_device(struct drm_backend *b, struct drm_device *device,
const char *name)
{ {
struct drm_device *device = b->drm;
struct udev_device *udev_device; struct udev_device *udev_device;
udev_device = udev_device_new_from_subsystem_sysname(b->udev, "drm", name); udev_device = udev_device_new_from_subsystem_sysname(b->udev, "drm", name);
@ -2888,7 +2888,7 @@ open_specific_drm_device(struct drm_backend *b, const char *name)
return NULL; return NULL;
} }
if (!drm_device_is_kms(b, udev_device)) { if (!drm_device_is_kms(b, device, udev_device)) {
udev_device_unref(udev_device); udev_device_unref(udev_device);
weston_log("ERROR: DRM device '%s' is not a KMS device.\n", name); weston_log("ERROR: DRM device '%s' is not a KMS device.\n", name);
return NULL; return NULL;
@ -3109,7 +3109,8 @@ drm_backend_create(struct weston_compositor *compositor,
wl_signal_add(&compositor->session_signal, &b->session_listener); wl_signal_add(&compositor->session_signal, &b->session_listener);
if (config->specific_device) if (config->specific_device)
drm_device = open_specific_drm_device(b, config->specific_device); drm_device = open_specific_drm_device(b, device,
config->specific_device);
else else
drm_device = find_primary_gpu(b, seat_id); drm_device = find_primary_gpu(b, seat_id);
if (drm_device == NULL) { if (drm_device == NULL) {

Loading…
Cancel
Save