compositor-drm: Rename drm_sprite to drm_plane
We make the differentiation where planes are an abstract framebuffer with a position within a CRTC/output, and sprites are special cases of planes that are neither the primary (base/framebuffer) nor cursor plane. drm_sprite, OTOH, contains nothing that's actually specific to sprites, and we end up duplicating a lot of code to deal with them, especially when we come to use an entirely plane-based interface with atomic modesetting. Rename drm_sprite to drm_plane, to reflect that it's actually generic. No functional changes. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> [Pekka: dropped the removal of an unrelated comment] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
205c0a018c
commit
08d4edf20d
+106
-95
@@ -162,6 +162,50 @@ struct drm_edid {
|
|||||||
char serial_number[13];
|
char serial_number[13];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A plane represents one buffer, positioned within a CRTC, and stacked
|
||||||
|
* relative to other planes on the same CRTC.
|
||||||
|
*
|
||||||
|
* Each CRTC has a 'primary plane', which use used to display the classic
|
||||||
|
* framebuffer contents, as accessed through the legacy drmModeSetCrtc
|
||||||
|
* call (which combines setting the CRTC's actual physical mode, and the
|
||||||
|
* properties of the primary plane).
|
||||||
|
*
|
||||||
|
* The cursor plane also has its own alternate legacy API.
|
||||||
|
*
|
||||||
|
* Other planes are used opportunistically to display content we do not
|
||||||
|
* wish to blit into the primary plane. These non-primary/cursor planes
|
||||||
|
* are referred to as 'sprites'.
|
||||||
|
*/
|
||||||
|
struct drm_plane {
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
struct weston_plane base;
|
||||||
|
|
||||||
|
struct drm_output *output;
|
||||||
|
struct drm_backend *backend;
|
||||||
|
|
||||||
|
uint32_t possible_crtcs;
|
||||||
|
uint32_t plane_id;
|
||||||
|
uint32_t count_formats;
|
||||||
|
|
||||||
|
/* The last framebuffer submitted to the kernel for this plane. */
|
||||||
|
struct drm_fb *fb_current;
|
||||||
|
/* The previously-submitted framebuffer, where the hardware has not
|
||||||
|
* yet acknowledged display of fb_current. */
|
||||||
|
struct drm_fb *fb_last;
|
||||||
|
/* Framebuffer we are going to submit to the kernel when the current
|
||||||
|
* repaint is flushed. */
|
||||||
|
struct drm_fb *fb_pending;
|
||||||
|
|
||||||
|
int32_t src_x, src_y;
|
||||||
|
uint32_t src_w, src_h;
|
||||||
|
uint32_t dest_x, dest_y;
|
||||||
|
uint32_t dest_w, dest_h;
|
||||||
|
|
||||||
|
uint32_t formats[];
|
||||||
|
};
|
||||||
|
|
||||||
struct drm_output {
|
struct drm_output {
|
||||||
struct weston_output base;
|
struct weston_output base;
|
||||||
drmModeConnector *connector;
|
drmModeConnector *connector;
|
||||||
@@ -211,39 +255,6 @@ struct drm_output {
|
|||||||
struct wl_event_source *pageflip_timer;
|
struct wl_event_source *pageflip_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* An output has a primary display plane plus zero or more sprites for
|
|
||||||
* blending display contents.
|
|
||||||
*/
|
|
||||||
struct drm_sprite {
|
|
||||||
struct wl_list link;
|
|
||||||
|
|
||||||
struct weston_plane plane;
|
|
||||||
|
|
||||||
struct drm_output *output;
|
|
||||||
struct drm_backend *backend;
|
|
||||||
|
|
||||||
uint32_t possible_crtcs;
|
|
||||||
uint32_t plane_id;
|
|
||||||
uint32_t count_formats;
|
|
||||||
|
|
||||||
/* The last framebuffer submitted to the kernel for this plane. */
|
|
||||||
struct drm_fb *fb_current;
|
|
||||||
/* The previously-submitted framebuffer, where the hardware has not
|
|
||||||
* yet acknowledged display of fb_current. */
|
|
||||||
struct drm_fb *fb_last;
|
|
||||||
/* Framebuffer we are going to submit to the kernel when the current
|
|
||||||
* repaint is flushed. */
|
|
||||||
struct drm_fb *fb_pending;
|
|
||||||
|
|
||||||
int32_t src_x, src_y;
|
|
||||||
uint32_t src_w, src_h;
|
|
||||||
uint32_t dest_x, dest_y;
|
|
||||||
uint32_t dest_w, dest_h;
|
|
||||||
|
|
||||||
uint32_t formats[];
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct gl_renderer_interface *gl_renderer;
|
static struct gl_renderer_interface *gl_renderer;
|
||||||
|
|
||||||
static const char default_seat[] = "seat0";
|
static const char default_seat[] = "seat0";
|
||||||
@@ -306,9 +317,9 @@ static void
|
|||||||
drm_output_update_msc(struct drm_output *output, unsigned int seq);
|
drm_output_update_msc(struct drm_output *output, unsigned int seq);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
drm_sprite_crtc_supported(struct drm_output *output, struct drm_sprite *sprite)
|
drm_plane_crtc_supported(struct drm_output *output, struct drm_plane *plane)
|
||||||
{
|
{
|
||||||
return !!(sprite->possible_crtcs & (1 << output->pipe));
|
return !!(plane->possible_crtcs & (1 << output->pipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct drm_output *
|
static struct drm_output *
|
||||||
@@ -845,7 +856,7 @@ drm_output_repaint(struct weston_output *output_base,
|
|||||||
struct drm_output *output = to_drm_output(output_base);
|
struct drm_output *output = to_drm_output(output_base);
|
||||||
struct drm_backend *backend =
|
struct drm_backend *backend =
|
||||||
to_drm_backend(output->base.compositor);
|
to_drm_backend(output->base.compositor);
|
||||||
struct drm_sprite *s;
|
struct drm_plane *s;
|
||||||
struct drm_mode *mode;
|
struct drm_mode *mode;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@@ -905,7 +916,7 @@ drm_output_repaint(struct weston_output *output_base,
|
|||||||
/* XXX: Set output much earlier, so we don't attempt to place
|
/* XXX: Set output much earlier, so we don't attempt to place
|
||||||
* planes on entirely the wrong output. */
|
* planes on entirely the wrong output. */
|
||||||
if ((!s->fb_current && !s->fb_pending) ||
|
if ((!s->fb_current && !s->fb_pending) ||
|
||||||
!drm_sprite_crtc_supported(output, s))
|
!drm_plane_crtc_supported(output, s))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (s->fb_pending && !backend->sprites_hidden)
|
if (s->fb_pending && !backend->sprites_hidden)
|
||||||
@@ -1048,7 +1059,7 @@ static void
|
|||||||
vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
|
vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct drm_sprite *s = (struct drm_sprite *)data;
|
struct drm_plane *s = (struct drm_plane *)data;
|
||||||
struct drm_output *output = s->output;
|
struct drm_output *output = s->output;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
|
uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
|
||||||
@@ -1115,7 +1126,7 @@ page_flip_handler(int fd, unsigned int frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
drm_output_check_sprite_format(struct drm_sprite *s,
|
drm_output_check_plane_format(struct drm_plane *p,
|
||||||
struct weston_view *ev, struct gbm_bo *bo)
|
struct weston_view *ev, struct gbm_bo *bo)
|
||||||
{
|
{
|
||||||
uint32_t i, format;
|
uint32_t i, format;
|
||||||
@@ -1136,8 +1147,8 @@ drm_output_check_sprite_format(struct drm_sprite *s,
|
|||||||
pixman_region32_fini(&r);
|
pixman_region32_fini(&r);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < s->count_formats; i++)
|
for (i = 0; i < p->count_formats; i++)
|
||||||
if (s->formats[i] == format)
|
if (p->formats[i] == format)
|
||||||
return format;
|
return format;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1151,7 +1162,7 @@ drm_output_prepare_overlay_view(struct drm_output *output,
|
|||||||
struct drm_backend *b = to_drm_backend(ec);
|
struct drm_backend *b = to_drm_backend(ec);
|
||||||
struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
|
struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
|
||||||
struct wl_resource *buffer_resource;
|
struct wl_resource *buffer_resource;
|
||||||
struct drm_sprite *s;
|
struct drm_plane *p;
|
||||||
struct linux_dmabuf_buffer *dmabuf;
|
struct linux_dmabuf_buffer *dmabuf;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
@@ -1187,11 +1198,11 @@ drm_output_prepare_overlay_view(struct drm_output *output,
|
|||||||
if (ev->alpha != 1.0f)
|
if (ev->alpha != 1.0f)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wl_list_for_each(s, &b->sprite_list, link) {
|
wl_list_for_each(p, &b->sprite_list, link) {
|
||||||
if (!drm_sprite_crtc_supported(output, s))
|
if (!drm_plane_crtc_supported(output, p))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!s->fb_pending) {
|
if (!p->fb_pending) {
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1244,23 +1255,23 @@ drm_output_prepare_overlay_view(struct drm_output *output,
|
|||||||
if (!bo)
|
if (!bo)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
format = drm_output_check_sprite_format(s, ev, bo);
|
format = drm_output_check_plane_format(p, ev, bo);
|
||||||
if (format == 0) {
|
if (format == 0) {
|
||||||
gbm_bo_destroy(bo);
|
gbm_bo_destroy(bo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->fb_pending = drm_fb_get_from_bo(bo, b, format, BUFFER_CLIENT);
|
p->fb_pending = drm_fb_get_from_bo(bo, b, format, BUFFER_CLIENT);
|
||||||
if (!s->fb_pending) {
|
if (!p->fb_pending) {
|
||||||
gbm_bo_destroy(bo);
|
gbm_bo_destroy(bo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_fb_set_buffer(s->fb_pending, ev->surface->buffer_ref.buffer);
|
drm_fb_set_buffer(p->fb_pending, ev->surface->buffer_ref.buffer);
|
||||||
|
|
||||||
box = pixman_region32_extents(&ev->transform.boundingbox);
|
box = pixman_region32_extents(&ev->transform.boundingbox);
|
||||||
s->plane.x = box->x1;
|
p->base.x = box->x1;
|
||||||
s->plane.y = box->y1;
|
p->base.y = box->y1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the source & dest rects properly based on actual
|
* Calculate the source & dest rects properly based on actual
|
||||||
@@ -1277,10 +1288,10 @@ drm_output_prepare_overlay_view(struct drm_output *output,
|
|||||||
output->base.transform,
|
output->base.transform,
|
||||||
output->base.current_scale,
|
output->base.current_scale,
|
||||||
*box);
|
*box);
|
||||||
s->dest_x = tbox.x1;
|
p->dest_x = tbox.x1;
|
||||||
s->dest_y = tbox.y1;
|
p->dest_y = tbox.y1;
|
||||||
s->dest_w = tbox.x2 - tbox.x1;
|
p->dest_w = tbox.x2 - tbox.x1;
|
||||||
s->dest_h = tbox.y2 - tbox.y1;
|
p->dest_h = tbox.y2 - tbox.y1;
|
||||||
pixman_region32_fini(&dest_rect);
|
pixman_region32_fini(&dest_rect);
|
||||||
|
|
||||||
pixman_region32_init(&src_rect);
|
pixman_region32_init(&src_rect);
|
||||||
@@ -1317,13 +1328,13 @@ drm_output_prepare_overlay_view(struct drm_output *output,
|
|||||||
viewport->buffer.scale,
|
viewport->buffer.scale,
|
||||||
tbox);
|
tbox);
|
||||||
|
|
||||||
s->src_x = tbox.x1 << 8;
|
p->src_x = tbox.x1 << 8;
|
||||||
s->src_y = tbox.y1 << 8;
|
p->src_y = tbox.y1 << 8;
|
||||||
s->src_w = (tbox.x2 - tbox.x1) << 8;
|
p->src_w = (tbox.x2 - tbox.x1) << 8;
|
||||||
s->src_h = (tbox.y2 - tbox.y1) << 8;
|
p->src_h = (tbox.y2 - tbox.y1) << 8;
|
||||||
pixman_region32_fini(&src_rect);
|
pixman_region32_fini(&src_rect);
|
||||||
|
|
||||||
return &s->plane;
|
return &p->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct weston_plane *
|
static struct weston_plane *
|
||||||
@@ -2832,71 +2843,71 @@ err:
|
|||||||
static void
|
static void
|
||||||
create_sprites(struct drm_backend *b)
|
create_sprites(struct drm_backend *b)
|
||||||
{
|
{
|
||||||
struct drm_sprite *sprite;
|
struct drm_plane *plane;
|
||||||
drmModePlaneRes *plane_res;
|
drmModePlaneRes *kplane_res;
|
||||||
drmModePlane *plane;
|
drmModePlane *kplane;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
plane_res = drmModeGetPlaneResources(b->drm.fd);
|
kplane_res = drmModeGetPlaneResources(b->drm.fd);
|
||||||
if (!plane_res) {
|
if (!kplane_res) {
|
||||||
weston_log("failed to get plane resources: %s\n",
|
weston_log("failed to get plane resources: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < plane_res->count_planes; i++) {
|
for (i = 0; i < kplane_res->count_planes; i++) {
|
||||||
plane = drmModeGetPlane(b->drm.fd, plane_res->planes[i]);
|
kplane = drmModeGetPlane(b->drm.fd, kplane_res->planes[i]);
|
||||||
if (!plane)
|
if (!kplane)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprite = zalloc(sizeof(*sprite) + ((sizeof(uint32_t)) *
|
plane = zalloc(sizeof(*plane) + ((sizeof(uint32_t)) *
|
||||||
plane->count_formats));
|
kplane->count_formats));
|
||||||
if (!sprite) {
|
if (!plane) {
|
||||||
weston_log("%s: out of memory\n",
|
weston_log("%s: out of memory\n",
|
||||||
__func__);
|
__func__);
|
||||||
drmModeFreePlane(plane);
|
drmModeFreePlane(kplane);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprite->possible_crtcs = plane->possible_crtcs;
|
plane->possible_crtcs = kplane->possible_crtcs;
|
||||||
sprite->plane_id = plane->plane_id;
|
plane->plane_id = kplane->plane_id;
|
||||||
sprite->fb_last = NULL;
|
plane->fb_last = NULL;
|
||||||
sprite->fb_current = NULL;
|
plane->fb_current = NULL;
|
||||||
sprite->fb_pending = NULL;
|
plane->fb_pending = NULL;
|
||||||
sprite->backend = b;
|
plane->backend = b;
|
||||||
sprite->count_formats = plane->count_formats;
|
plane->count_formats = kplane->count_formats;
|
||||||
memcpy(sprite->formats, plane->formats,
|
memcpy(plane->formats, kplane->formats,
|
||||||
plane->count_formats * sizeof(plane->formats[0]));
|
kplane->count_formats * sizeof(kplane->formats[0]));
|
||||||
drmModeFreePlane(plane);
|
drmModeFreePlane(kplane);
|
||||||
weston_plane_init(&sprite->plane, b->compositor, 0, 0);
|
weston_plane_init(&plane->base, b->compositor, 0, 0);
|
||||||
weston_compositor_stack_plane(b->compositor, &sprite->plane,
|
weston_compositor_stack_plane(b->compositor, &plane->base,
|
||||||
&b->compositor->primary_plane);
|
&b->compositor->primary_plane);
|
||||||
|
|
||||||
wl_list_insert(&b->sprite_list, &sprite->link);
|
wl_list_insert(&b->sprite_list, &plane->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
drmModeFreePlaneResources(plane_res);
|
drmModeFreePlaneResources(kplane_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_sprites(struct drm_backend *backend)
|
destroy_sprites(struct drm_backend *backend)
|
||||||
{
|
{
|
||||||
struct drm_sprite *sprite, *next;
|
struct drm_plane *plane, *next;
|
||||||
struct drm_output *output;
|
struct drm_output *output;
|
||||||
|
|
||||||
output = container_of(backend->compositor->output_list.next,
|
output = container_of(backend->compositor->output_list.next,
|
||||||
struct drm_output, base.link);
|
struct drm_output, base.link);
|
||||||
|
|
||||||
wl_list_for_each_safe(sprite, next, &backend->sprite_list, link) {
|
wl_list_for_each_safe(plane, next, &backend->sprite_list, link) {
|
||||||
drmModeSetPlane(backend->drm.fd,
|
drmModeSetPlane(backend->drm.fd,
|
||||||
sprite->plane_id,
|
plane->plane_id,
|
||||||
output->crtc_id, 0, 0,
|
output->crtc_id, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0);
|
0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
assert(!sprite->fb_last);
|
assert(!plane->fb_last);
|
||||||
assert(!sprite->fb_pending);
|
assert(!plane->fb_pending);
|
||||||
drm_fb_unref(sprite->fb_current);
|
drm_fb_unref(plane->fb_current);
|
||||||
weston_plane_release(&sprite->plane);
|
weston_plane_release(&plane->base);
|
||||||
free(sprite);
|
free(plane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3102,7 +3113,7 @@ session_notify(struct wl_listener *listener, void *data)
|
|||||||
{
|
{
|
||||||
struct weston_compositor *compositor = data;
|
struct weston_compositor *compositor = data;
|
||||||
struct drm_backend *b = to_drm_backend(compositor);
|
struct drm_backend *b = to_drm_backend(compositor);
|
||||||
struct drm_sprite *sprite;
|
struct drm_plane *sprite;
|
||||||
struct drm_output *output;
|
struct drm_output *output;
|
||||||
|
|
||||||
if (compositor->session_active) {
|
if (compositor->session_active) {
|
||||||
|
|||||||
Reference in New Issue
Block a user