162306a36Sopenharmony_ci#ifndef __DRM_GEM_FB_HELPER_H__
262306a36Sopenharmony_ci#define __DRM_GEM_FB_HELPER_H__
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#include <linux/dma-buf.h>
562306a36Sopenharmony_ci#include <linux/iosys-map.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistruct drm_afbc_framebuffer;
862306a36Sopenharmony_cistruct drm_device;
962306a36Sopenharmony_cistruct drm_fb_helper_surface_size;
1062306a36Sopenharmony_cistruct drm_file;
1162306a36Sopenharmony_cistruct drm_framebuffer;
1262306a36Sopenharmony_cistruct drm_framebuffer_funcs;
1362306a36Sopenharmony_cistruct drm_gem_object;
1462306a36Sopenharmony_cistruct drm_mode_fb_cmd2;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define AFBC_VENDOR_AND_TYPE_MASK	GENMASK_ULL(63, 52)
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistruct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
1962306a36Sopenharmony_ci					  unsigned int plane);
2062306a36Sopenharmony_civoid drm_gem_fb_destroy(struct drm_framebuffer *fb);
2162306a36Sopenharmony_ciint drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
2262306a36Sopenharmony_ci			     unsigned int *handle);
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciint drm_gem_fb_init_with_funcs(struct drm_device *dev,
2562306a36Sopenharmony_ci			       struct drm_framebuffer *fb,
2662306a36Sopenharmony_ci			       struct drm_file *file,
2762306a36Sopenharmony_ci			       const struct drm_mode_fb_cmd2 *mode_cmd,
2862306a36Sopenharmony_ci			       const struct drm_framebuffer_funcs *funcs);
2962306a36Sopenharmony_cistruct drm_framebuffer *
3062306a36Sopenharmony_cidrm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
3162306a36Sopenharmony_ci			     const struct drm_mode_fb_cmd2 *mode_cmd,
3262306a36Sopenharmony_ci			     const struct drm_framebuffer_funcs *funcs);
3362306a36Sopenharmony_cistruct drm_framebuffer *
3462306a36Sopenharmony_cidrm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
3562306a36Sopenharmony_ci		  const struct drm_mode_fb_cmd2 *mode_cmd);
3662306a36Sopenharmony_cistruct drm_framebuffer *
3762306a36Sopenharmony_cidrm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
3862306a36Sopenharmony_ci			     const struct drm_mode_fb_cmd2 *mode_cmd);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciint drm_gem_fb_vmap(struct drm_framebuffer *fb, struct iosys_map *map,
4162306a36Sopenharmony_ci		    struct iosys_map *data);
4262306a36Sopenharmony_civoid drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct iosys_map *map);
4362306a36Sopenharmony_ciint drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
4462306a36Sopenharmony_civoid drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define drm_is_afbc(modifier) \
4762306a36Sopenharmony_ci	(((modifier) & AFBC_VENDOR_AND_TYPE_MASK) == DRM_FORMAT_MOD_ARM_AFBC(0))
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciint drm_gem_fb_afbc_init(struct drm_device *dev,
5062306a36Sopenharmony_ci			 const struct drm_mode_fb_cmd2 *mode_cmd,
5162306a36Sopenharmony_ci			 struct drm_afbc_framebuffer *afbc_fb);
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#endif
54