Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
0004  * Author: James.Qian.Wang <james.qian.wang@arm.com>
0005  *
0006  */
0007 
0008 #ifndef _KOMEDA_FORMAT_CAPS_H_
0009 #define _KOMEDA_FORMAT_CAPS_H_
0010 
0011 #include <linux/types.h>
0012 #include <uapi/drm/drm_fourcc.h>
0013 #include <drm/drm_fourcc.h>
0014 
0015 #define AFBC(x)     DRM_FORMAT_MOD_ARM_AFBC(x)
0016 
0017 /* afbc layerout */
0018 #define AFBC_16x16(x)   AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | (x))
0019 #define AFBC_32x8(x)    AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | (x))
0020 
0021 /* afbc features */
0022 #define _YTR        AFBC_FORMAT_MOD_YTR
0023 #define _SPLIT      AFBC_FORMAT_MOD_SPLIT
0024 #define _SPARSE     AFBC_FORMAT_MOD_SPARSE
0025 #define _CBR        AFBC_FORMAT_MOD_CBR
0026 #define _TILED      AFBC_FORMAT_MOD_TILED
0027 #define _SC     AFBC_FORMAT_MOD_SC
0028 
0029 /* layer_type */
0030 #define KOMEDA_FMT_RICH_LAYER       BIT(0)
0031 #define KOMEDA_FMT_SIMPLE_LAYER     BIT(1)
0032 #define KOMEDA_FMT_WB_LAYER     BIT(2)
0033 
0034 #define AFBC_TH_LAYOUT_ALIGNMENT    8
0035 #define AFBC_HEADER_SIZE        16
0036 #define AFBC_SUPERBLK_ALIGNMENT     128
0037 #define AFBC_SUPERBLK_PIXELS        256
0038 #define AFBC_BODY_START_ALIGNMENT   1024
0039 #define AFBC_TH_BODY_START_ALIGNMENT    4096
0040 
0041 /**
0042  * struct komeda_format_caps
0043  *
0044  * komeda_format_caps is for describing ARM display specific features and
0045  * limitations for a specific format, and format_caps will be linked into
0046  * &komeda_framebuffer like a extension of &drm_format_info.
0047  *
0048  * NOTE: one fourcc may has two different format_caps items for fourcc and
0049  * fourcc+modifier
0050  *
0051  * @hw_id: hw format id, hw specific value.
0052  * @fourcc: drm fourcc format.
0053  * @supported_layer_types: indicate which layer supports this format
0054  * @supported_rots: allowed rotations for this format
0055  * @supported_afbc_layouts: supported afbc layerout
0056  * @supported_afbc_features: supported afbc features
0057  */
0058 struct komeda_format_caps {
0059     u32 hw_id;
0060     u32 fourcc;
0061     u32 supported_layer_types;
0062     u32 supported_rots;
0063     u32 supported_afbc_layouts;
0064     u64 supported_afbc_features;
0065 };
0066 
0067 /**
0068  * struct komeda_format_caps_table - format_caps mananger
0069  *
0070  * @n_formats: the size of format_caps list.
0071  * @format_caps: format_caps list.
0072  * @format_mod_supported: Optional. Some HW may have special requirements or
0073  * limitations which can not be described by format_caps, this func supply HW
0074  * the ability to do the further HW specific check.
0075  */
0076 struct komeda_format_caps_table {
0077     u32 n_formats;
0078     const struct komeda_format_caps *format_caps;
0079     bool (*format_mod_supported)(const struct komeda_format_caps *caps,
0080                      u32 layer_type, u64 modifier, u32 rot);
0081 };
0082 
0083 extern u64 komeda_supported_modifiers[];
0084 
0085 const struct komeda_format_caps *
0086 komeda_get_format_caps(struct komeda_format_caps_table *table,
0087                u32 fourcc, u64 modifier);
0088 
0089 u32 komeda_get_afbc_format_bpp(const struct drm_format_info *info,
0090                    u64 modifier);
0091 
0092 u32 *komeda_get_layer_fourcc_list(struct komeda_format_caps_table *table,
0093                   u32 layer_type, u32 *n_fmts);
0094 
0095 void komeda_put_fourcc_list(u32 *fourcc_list);
0096 
0097 bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
0098                  u32 layer_type, u32 fourcc, u64 modifier,
0099                  u32 rot);
0100 
0101 #endif