Sharing meta-data between DMA-BUF exporter and importer

Thierry Reding thierry.reding at gmail.com
Wed Jun 4 08:07:01 PDT 2014


Hi,

I've recently added support for Tegra K1 to kmscube[0]. The changes add
support for sharing buffers using DMA-BUF. On Tegra K1 the buffers are
shared between the GK20A GPU (Nouveau) for rendering and Tegra DRM for
display.

One of the commits[1] adds a Tegra-specific hook that sets the tiling
parameters of the imported buffer. I've discussed this a bit with Rob on
IRC and he asked me to raise the issue with a broader audience. Weston
is eventually going to need something along the same lines. One idea was
to implement something like that in gbm, though for it to be useful in
the general case I think it would need to be based on a data structure
that's hardware agnostic. The process how this would work is that the
application could do something like this:

	/*
	 * This should be able to represent all known tiling modes that
	 * could possibly be set on a buffer object and is just an
	 * example of how this could look like. There are possibly many
	 * different and better ways to do this.
	 */
	struct gbm_bo_tiling {
		enum gbo_bo_tiling_mode mode;

		union {
			...
		};
	};

	struct gbm_device *gpu, *display;
	struct gbm_bo_tiling tiling;

	/* get tiling parameters from importer */
	err = gbm_bo_get_tiling(gpu, bo, &tiling);
	if (err < 0) {
		...
	}

	fd = gbm_bo_export(gpu, bo);
	if (err < 0) {
		/* can't export DMA-BUF */
		...
	}

	/* import bo */
	bo = gbm_bo_import(display, GBM_BO_IMPORT_DMA_BUF, (void *)fd, ...);
	if (!bo) {
		/* can't import DMA-BUF */
		...
	}

	err = gbm_bo_set_tiling(display, bo, &tiling);
	if (err < 0) {
		/* tiling parameters not compatible with importer */
		...
	}

I guess optionally there could be some sort of negotiation between
importer and exporter about what tiling parameters they support, but
that can possibly be built on top of the above.

I'm adding Christian Gmeiner since I'm told he'll be likely needing
something similar for his work on etnaviv and it would be good to get a
second opinion on this.

Thierry

[0]: https://gitorious.org/thierryreding/kmscube
[1]: https://gitorious.org/thierryreding/kmscube/commit/b4d79d5c4e27b6d37234a137bdefc6ff517d6ea4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140604/b8d933b2/attachment.sig>


More information about the wayland-devel mailing list