1 #ifndef __DRM_GEM_FB_HELPER_H__
2 #define __DRM_GEM_FB_HELPER_H__
3 
4 #include <linux/dma-buf.h>
5 #include <linux/dma-buf-map.h>
6 
7 #include <drm/drm_fourcc.h>
8 
9 struct drm_afbc_framebuffer;
10 struct drm_device;
11 struct drm_fb_helper_surface_size;
12 struct drm_file;
13 struct drm_framebuffer;
14 struct drm_framebuffer_funcs;
15 struct drm_gem_object;
16 struct drm_mode_fb_cmd2;
17 
18 #define AFBC_VENDOR_AND_TYPE_MASK	GENMASK_ULL(63, 52)
19 
20 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
21 					  unsigned int plane);
22 void drm_gem_fb_destroy(struct drm_framebuffer *fb);
23 int drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
24 			     unsigned int *handle);
25 
26 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
27 			       struct drm_framebuffer *fb,
28 			       struct drm_file *file,
29 			       const struct drm_mode_fb_cmd2 *mode_cmd,
30 			       const struct drm_framebuffer_funcs *funcs);
31 struct drm_framebuffer *
32 drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
33 			     const struct drm_mode_fb_cmd2 *mode_cmd,
34 			     const struct drm_framebuffer_funcs *funcs);
35 struct drm_framebuffer *
36 drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
37 		  const struct drm_mode_fb_cmd2 *mode_cmd);
38 struct drm_framebuffer *
39 drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
40 			     const struct drm_mode_fb_cmd2 *mode_cmd);
41 
42 int drm_gem_fb_vmap(struct drm_framebuffer *fb,
43 		    struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],
44 		    struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]);
45 void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
46 		       struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]);
47 int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
48 void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
49 
50 #define drm_is_afbc(modifier) \
51 	(((modifier) & AFBC_VENDOR_AND_TYPE_MASK) == DRM_FORMAT_MOD_ARM_AFBC(0))
52 
53 int drm_gem_fb_afbc_init(struct drm_device *dev,
54 			 const struct drm_mode_fb_cmd2 *mode_cmd,
55 			 struct drm_afbc_framebuffer *afbc_fb);
56 
57 #endif
58