On Wed, 20 Dec 2017 12:26:44 +0000 Daniel Stone <dani...@collabora.com> wrote:
> We currently do the same thing in two places, and will soon have a > third. > > Signed-off-by: Daniel Stone <dani...@collabora.com> > --- > libweston/compositor-drm.c | 93 > ++++++++++++++++++++++++---------------------- > 1 file changed, 48 insertions(+), 45 deletions(-) > > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c > index e6b5efba0..09fa10f5f 100644 > --- a/libweston/compositor-drm.c > +++ b/libweston/compositor-drm.c > @@ -288,7 +288,10 @@ struct drm_fb { > > int refcnt; > > - uint32_t fb_id, stride, handle, size; > + uint32_t fb_id, size; > + uint32_t handles[4]; > + uint32_t strides[4]; > + uint32_t offsets[4]; > const struct pixel_format_info *format; > int width, height; > int fd; > @@ -821,7 +824,7 @@ drm_fb_destroy_dumb(struct drm_fb *fb) > munmap(fb->map, fb->size); > > memset(&destroy_arg, 0, sizeof(destroy_arg)); > - destroy_arg.handle = fb->handle; > + destroy_arg.handle = fb->handles[0]; > drmIoctl(fb->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg); > > drm_fb_destroy(fb); > @@ -837,6 +840,32 @@ drm_fb_destroy_gbm(struct gbm_bo *bo, void *data) > drm_fb_destroy(fb); > } > > +static int > +drm_fb_addfb(struct drm_fb *fb) > +{ > + int ret; > + > + ret = drmModeAddFB2(fb->fd, fb->width, fb->height, fb->format->format, > + fb->handles, fb->strides, fb->offsets, &fb->fb_id, > + 0); > + if (ret == 0) > + return 0; > + > + /* Legacy AddFB can't always infer the format from depth/bpp alone, so > + * check if our format is one of the lucky ones. */ > + if (!fb->format->depth || !fb->format->bpp) > + return ret; > + > + /* Cannot fall back to AddFB for multi-planar formats either. */ > + if (fb->handles[1] || fb->handles[2] || fb->handles[3]) > + return ret; > + > + ret = drmModeAddFB(fb->fd, fb->width, fb->height, > + fb->format->depth, fb->format->bpp, > + fb->strides[0], fb->handles[0], &fb->fb_id); > + return ret; > +} > + Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Thanks, pq
pgpbrYOJ2CYDh.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel