1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3  */
4 
5 #ifndef _DPU_FORMATS_H
6 #define _DPU_FORMATS_H
7 
8 #include <drm/drm_fourcc.h>
9 #include "msm_gem.h"
10 #include "dpu_hw_mdss.h"
11 
12 /**
13  * dpu_get_dpu_format_ext() - Returns dpu format structure pointer.
14  * @format:          DRM FourCC Code
15  * @modifiers:       format modifier array from client, one per plane
16  */
17 const struct dpu_format *dpu_get_dpu_format_ext(
18 		const uint32_t format,
19 		const uint64_t modifier);
20 
21 #define dpu_get_dpu_format(f) dpu_get_dpu_format_ext(f, 0)
22 
23 /**
24  * dpu_get_msm_format - get an dpu_format by its msm_format base
25  *                     callback function registers with the msm_kms layer
26  * @kms:             kms driver
27  * @format:          DRM FourCC Code
28  * @modifiers:       data layout modifier
29  */
30 const struct msm_format *dpu_get_msm_format(
31 		struct msm_kms *kms,
32 		const uint32_t format,
33 		const uint64_t modifiers);
34 
35 /**
36  * dpu_format_check_modified_format - validate format and buffers for
37  *                   dpu non-standard, i.e. modified format
38  * @kms:             kms driver
39  * @msm_fmt:         pointer to the msm_fmt base pointer of an dpu_format
40  * @cmd:             fb_cmd2 structure user request
41  * @bos:             gem buffer object list
42  *
43  * Return: error code on failure, 0 on success
44  */
45 int dpu_format_check_modified_format(
46 		const struct msm_kms *kms,
47 		const struct msm_format *msm_fmt,
48 		const struct drm_mode_fb_cmd2 *cmd,
49 		struct drm_gem_object **bos);
50 
51 /**
52  * dpu_format_populate_layout - populate the given format layout based on
53  *                     mmu, fb, and format found in the fb
54  * @aspace:            address space pointer
55  * @fb:                framebuffer pointer
56  * @fmtl:              format layout structure to populate
57  *
58  * Return: error code on failure, -EAGAIN if success but the addresses
59  *         are the same as before or 0 if new addresses were populated
60  */
61 int dpu_format_populate_layout(
62 		struct msm_gem_address_space *aspace,
63 		struct drm_framebuffer *fb,
64 		struct dpu_hw_fmt_layout *fmtl);
65 
66 #endif /*_DPU_FORMATS_H */
67