1 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #ifndef _DPU_FORMATS_H
14 #define _DPU_FORMATS_H
16 #include <drm/drm_fourcc.h>
18 #include "dpu_hw_mdss.h"
21 * dpu_get_dpu_format_ext() - Returns dpu format structure pointer.
22 * @format: DRM FourCC Code
23 * @modifiers: format modifier array from client, one per plane
25 const struct dpu_format *dpu_get_dpu_format_ext(
26 const uint32_t format,
27 const uint64_t modifier);
29 #define dpu_get_dpu_format(f) dpu_get_dpu_format_ext(f, 0)
32 * dpu_get_msm_format - get an dpu_format by its msm_format base
33 * callback function registers with the msm_kms layer
35 * @format: DRM FourCC Code
36 * @modifiers: data layout modifier
38 const struct msm_format *dpu_get_msm_format(
40 const uint32_t format,
41 const uint64_t modifiers);
44 * dpu_populate_formats - populate the given array with fourcc codes supported
45 * @format_list: pointer to list of possible formats
46 * @pixel_formats: array to populate with fourcc codes
47 * @pixel_modifiers: array to populate with drm modifiers, can be NULL
48 * @pixel_formats_max: length of pixel formats array
49 * Return: number of elements populated
51 uint32_t dpu_populate_formats(
52 const struct dpu_format_extended *format_list,
53 uint32_t *pixel_formats,
54 uint64_t *pixel_modifiers,
55 uint32_t pixel_formats_max);
58 * dpu_format_check_modified_format - validate format and buffers for
59 * dpu non-standard, i.e. modified format
61 * @msm_fmt: pointer to the msm_fmt base pointer of an dpu_format
62 * @cmd: fb_cmd2 structure user request
63 * @bos: gem buffer object list
65 * Return: error code on failure, 0 on success
67 int dpu_format_check_modified_format(
68 const struct msm_kms *kms,
69 const struct msm_format *msm_fmt,
70 const struct drm_mode_fb_cmd2 *cmd,
71 struct drm_gem_object **bos);
74 * dpu_format_populate_layout - populate the given format layout based on
75 * mmu, fb, and format found in the fb
76 * @aspace: address space pointer
77 * @fb: framebuffer pointer
78 * @fmtl: format layout structure to populate
80 * Return: error code on failure, -EAGAIN if success but the addresses
81 * are the same as before or 0 if new addresses were populated
83 int dpu_format_populate_layout(
84 struct msm_gem_address_space *aspace,
85 struct drm_framebuffer *fb,
86 struct dpu_hw_fmt_layout *fmtl);
88 #endif /*_DPU_FORMATS_H */