1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
4  * Author: James.Qian.Wang <james.qian.wang@arm.com>
5  *
6  */
7 #ifndef _KOMEDA_FRAMEBUFFER_H_
8 #define _KOMEDA_FRAMEBUFFER_H_
9 
10 #include <drm/drm_framebuffer.h>
11 #include "komeda_format_caps.h"
12 
13 /**
14  * struct komeda_fb - Entending drm_framebuffer with komeda attribute
15  */
16 struct komeda_fb {
17 	/** @base: &drm_framebuffer */
18 	struct drm_framebuffer base;
19 	/**
20 	 * @format_caps:
21 	 * extends drm_format_info for komeda specific information
22 	 */
23 	const struct komeda_format_caps *format_caps;
24 	/** @is_va: if smmu is enabled, it will be true */
25 	bool is_va;
26 	/** @aligned_w: aligned frame buffer width */
27 	u32 aligned_w;
28 	/** @aligned_h: aligned frame buffer height */
29 	u32 aligned_h;
30 	/** @afbc_size: minimum size of afbc */
31 	u32 afbc_size;
32 	/** @offset_payload: start of afbc body buffer */
33 	u32 offset_payload;
34 };
35 
36 #define to_kfb(dfb)	container_of(dfb, struct komeda_fb, base)
37 
38 struct drm_framebuffer *
39 komeda_fb_create(struct drm_device *dev, struct drm_file *file,
40 		const struct drm_mode_fb_cmd2 *mode_cmd);
41 int komeda_fb_check_src_coords(const struct komeda_fb *kfb,
42 			       u32 src_x, u32 src_y, u32 src_w, u32 src_h);
43 dma_addr_t
44 komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane);
45 bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
46 		u32 rot);
47 
48 #endif
49