xref: /linux/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h (revision db5d28c0bfe566908719bec8e25443aabecbb802)
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_find_format - validate if the pixel format is supported
14  * @format:		dpu format
15  * @supported_formats:	supported formats by dpu HW
16  * @num_formatss:	total number of formats
17  *
18  * Return: false if not valid format, true on success
19  */
dpu_find_format(u32 format,const u32 * supported_formats,size_t num_formats)20 static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
21 					size_t num_formats)
22 {
23 	int i;
24 
25 	for (i = 0; i < num_formats; i++) {
26 		/* check for valid formats supported */
27 		if (format == supported_formats[i])
28 			return true;
29 	}
30 
31 	return false;
32 }
33 
34 /**
35  * dpu_format_check_modified_format - validate format and buffers for
36  *                   dpu non-standard, i.e. modified format
37  * @kms:             kms driver
38  * @msm_fmt:         pointer to the msm_fmt base pointer of an msm_format
39  * @cmd:             fb_cmd2 structure user request
40  * @bos:             gem buffer object list
41  *
42  * Return: error code on failure, 0 on success
43  */
44 int dpu_format_check_modified_format(
45 		const struct msm_kms *kms,
46 		const struct msm_format *msm_fmt,
47 		const struct drm_mode_fb_cmd2 *cmd,
48 		struct drm_gem_object **bos);
49 
50 /**
51  * dpu_format_populate_layout - populate the given format layout based on
52  *                     mmu, fb, and format found in the fb
53  * @aspace:            address space pointer
54  * @fb:                framebuffer pointer
55  * @fmtl:              format layout structure to populate
56  *
57  * Return: error code on failure, -EAGAIN if success but the addresses
58  *         are the same as before or 0 if new addresses were populated
59  */
60 int dpu_format_populate_layout(
61 		struct msm_gem_address_space *aspace,
62 		struct drm_framebuffer *fb,
63 		struct dpu_hw_fmt_layout *fmtl);
64 
65 #endif /*_DPU_FORMATS_H */
66