[PATCH v14 27/41] compositor-drm: Extract drm_fb_addfb into a helper
Pekka Paalanen
ppaalanen at gmail.com
Fri Jan 26 09:50:10 UTC 2018
On Wed, 20 Dec 2017 12:26:44 +0000
Daniel Stone <daniels at collabora.com> wrote:
> We currently do the same thing in two places, and will soon have a
> third.
>
> Signed-off-by: Daniel Stone <daniels at 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.paalanen at collabora.co.uk>
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180126/8188633b/attachment.sig>
More information about the wayland-devel
mailing list