mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 07:00:09 +01:00
backend-drm: Refactor drm_backend_update_connectors
This splits drm_backend_update_connectors into drm_backend_update_connector and a post destroy phase/function. There's no functional change, but this allows to pass drm_backend_update_connector() on its own as we'll need that. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
parent
b6f890d249
commit
aa04d9d4ad
1 changed files with 61 additions and 37 deletions
|
|
@ -3606,31 +3606,19 @@ resources_has_connector(drmModeRes *resources, uint32_t connector_id)
|
|||
}
|
||||
|
||||
static void
|
||||
drm_backend_update_connectors(struct drm_device *device,
|
||||
struct udev_device *drm_device)
|
||||
drm_backend_update_connector(struct drm_device *device,
|
||||
struct udev_device *drm_device,
|
||||
uint32_t connector_id)
|
||||
{
|
||||
struct drm_backend *b = device->backend;
|
||||
drmModeRes *resources;
|
||||
drmModeConnector *conn;
|
||||
struct weston_head *base, *base_next;
|
||||
struct drm_head *head;
|
||||
struct drm_writeback *writeback, *writeback_next;
|
||||
uint32_t connector_id;
|
||||
int i, ret;
|
||||
|
||||
resources = drmModeGetResources(device->drm.fd);
|
||||
if (!resources) {
|
||||
weston_log("drmModeGetResources failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* collect new connectors that have appeared, e.g. MST */
|
||||
for (i = 0; i < resources->count_connectors; i++) {
|
||||
connector_id = resources->connectors[i];
|
||||
struct drm_writeback *writeback;
|
||||
int ret;
|
||||
|
||||
conn = drmModeGetConnector(device->drm.fd, connector_id);
|
||||
if (!conn)
|
||||
continue;
|
||||
return;
|
||||
|
||||
head = drm_head_find_by_connector(b, device, connector_id);
|
||||
writeback = drm_writeback_find_by_connector(device, connector_id);
|
||||
|
|
@ -3641,8 +3629,9 @@ drm_backend_update_connectors(struct drm_device *device,
|
|||
|
||||
if (head) {
|
||||
ret = drm_head_update_info(head, conn);
|
||||
if (head->base.device_changed)
|
||||
if (head->base.device_changed) {
|
||||
drm_head_log_info(head, "updated");
|
||||
}
|
||||
} else if (writeback) {
|
||||
ret = drm_writeback_update_info(writeback, conn);
|
||||
} else {
|
||||
|
|
@ -3651,7 +3640,20 @@ drm_backend_update_connectors(struct drm_device *device,
|
|||
|
||||
if (ret < 0)
|
||||
drmModeFreeConnector(conn);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
drm_backend_update_connectors_post_destroy(struct drm_device *device,
|
||||
drmModeRes *resources)
|
||||
{
|
||||
struct drm_backend *b = device->backend;
|
||||
struct weston_head *base, *base_next;
|
||||
struct drm_head *head;
|
||||
struct drm_writeback *writeback, *writeback_next;
|
||||
uint32_t connector_id;
|
||||
|
||||
if (!resources)
|
||||
return;
|
||||
|
||||
/* Destroy head objects of connectors (except writeback connectors) that
|
||||
* have disappeared. */
|
||||
|
|
@ -3686,6 +3688,28 @@ drm_backend_update_connectors(struct drm_device *device,
|
|||
connector_id);
|
||||
drm_writeback_destroy(writeback);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
drm_backend_update_connectors(struct drm_device *device,
|
||||
struct udev_device *drm_device)
|
||||
{
|
||||
drmModeRes *resources;
|
||||
int i;
|
||||
|
||||
/* collect new connectors that have appeared, e.g. MST */
|
||||
resources = drmModeGetResources(device->drm.fd);
|
||||
if (!resources) {
|
||||
weston_log("drmModeGetResources failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < resources->count_connectors; i++) {
|
||||
uint32_t connector_id = resources->connectors[i];
|
||||
drm_backend_update_connector(device, drm_device, connector_id);
|
||||
}
|
||||
|
||||
drm_backend_update_connectors_post_destroy(device, resources);
|
||||
|
||||
drmModeFreeResources(resources);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue