summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/drm_gem_atomic_helper.c
blob: 4fb8acd28045b660c8d1f32eafce7bb404f996ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Public domain. */

#include <linux/kernel.h>

#include <drm/drm_plane.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_gem.h>
#include <linux/dma-resv.h>

int
drm_gem_plane_helper_prepare_fb(struct drm_plane *dp,
    struct drm_plane_state *dps)
{
	struct drm_gem_object *obj;
	struct dma_fence *f;
	int r;

	if (dps->fb != NULL) {
		obj = dps->fb->obj[0];
		if (obj == NULL)
			return -EINVAL;
		if (dps->fence) {
			printf("%s: explicit fence not handled\n", __func__);
			return -EINVAL;
		}
		r = dma_resv_get_singleton(obj->resv, DMA_RESV_USAGE_WRITE, &f);
		if (r)
			return r;
		dps->fence = f;
	}

	return 0;
}