1 /* SPDX-License-Identifier: GPL-2.0 */
3 * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
4 * Author: James.Qian.Wang <james.qian.wang@arm.com>
8 #ifndef _KOMEDA_FORMAT_CAPS_H_
9 #define _KOMEDA_FORMAT_CAPS_H_
11 #include <linux/types.h>
12 #include <uapi/drm/drm_fourcc.h>
13 #include <drm/drm_fourcc.h>
15 #define AFBC(x) DRM_FORMAT_MOD_ARM_AFBC(x)
18 #define AFBC_16x16(x) AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | (x))
19 #define AFBC_32x8(x) AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | (x))
22 #define _YTR AFBC_FORMAT_MOD_YTR
23 #define _SPLIT AFBC_FORMAT_MOD_SPLIT
24 #define _SPARSE AFBC_FORMAT_MOD_SPARSE
25 #define _CBR AFBC_FORMAT_MOD_CBR
26 #define _TILED AFBC_FORMAT_MOD_TILED
27 #define _SC AFBC_FORMAT_MOD_SC
30 #define KOMEDA_FMT_RICH_LAYER BIT(0)
31 #define KOMEDA_FMT_SIMPLE_LAYER BIT(1)
32 #define KOMEDA_FMT_WB_LAYER BIT(2)
34 #define AFBC_TH_LAYOUT_ALIGNMENT 8
35 #define AFBC_HEADER_SIZE 16
36 #define AFBC_SUPERBLK_ALIGNMENT 128
37 #define AFBC_SUPERBLK_PIXELS 256
38 #define AFBC_BODY_START_ALIGNMENT 1024
39 #define AFBC_TH_BODY_START_ALIGNMENT 4096
42 * struct komeda_format_caps
44 * komeda_format_caps is for describing ARM display specific features and
45 * limitations for a specific format, and format_caps will be linked into
46 * &komeda_framebuffer like a extension of &drm_format_info.
48 * NOTE: one fourcc may has two different format_caps items for fourcc and
51 * @hw_id: hw format id, hw specific value.
52 * @fourcc: drm fourcc format.
53 * @supported_layer_types: indicate which layer supports this format
54 * @supported_rots: allowed rotations for this format
55 * @supported_afbc_layouts: supported afbc layerout
56 * @supported_afbc_features: supported afbc features
58 struct komeda_format_caps
{
61 u32 supported_layer_types
;
63 u32 supported_afbc_layouts
;
64 u64 supported_afbc_features
;
68 * struct komeda_format_caps_table - format_caps mananger
70 * @n_formats: the size of format_caps list.
71 * @format_caps: format_caps list.
72 * @format_mod_supported: Optional. Some HW may have special requirements or
73 * limitations which can not be described by format_caps, this func supply HW
74 * the ability to do the further HW specific check.
76 struct komeda_format_caps_table
{
78 const struct komeda_format_caps
*format_caps
;
79 bool (*format_mod_supported
)(const struct komeda_format_caps
*caps
,
80 u32 layer_type
, u64 modifier
, u32 rot
);
83 extern u64 komeda_supported_modifiers
[];
85 static inline const char *komeda_get_format_name(u32 fourcc
, u64 modifier
)
87 struct drm_format_name_buf buf
;
90 snprintf(name
, sizeof(name
), "%s with modifier: 0x%llx.",
91 drm_get_format_name(fourcc
, &buf
), modifier
);
96 const struct komeda_format_caps
*
97 komeda_get_format_caps(struct komeda_format_caps_table
*table
,
98 u32 fourcc
, u64 modifier
);
100 u32
komeda_get_afbc_format_bpp(const struct drm_format_info
*info
,
103 u32
*komeda_get_layer_fourcc_list(struct komeda_format_caps_table
*table
,
104 u32 layer_type
, u32
*n_fmts
);
106 void komeda_put_fourcc_list(u32
*fourcc_list
);
108 bool komeda_format_mod_supported(struct komeda_format_caps_table
*table
,
109 u32 layer_type
, u32 fourcc
, u64 modifier
,