1 /* 2 * Copyright (C) 2019-2020 ARM Limited. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MALI_FOURCC_H_ 18 #define MALI_FOURCC_H_ 19 20 extern "C" 21 { 22 23 #include <drm_fourcc.h> 24 #include <stdint.h> 25 26 /* FOURCCs for formats that exist upstream, but may not be in the drm_fourcc.h header included above. 27 * 28 * Below we define DRM FOURCC formats that are upstreamed, but may not be in the drm_fourcc.h header that we include 29 * above, merely because that header is too old. As drm_fourcc.h is an external header that we cannot control, the best 30 * we can do is to define here the missing formats. 31 */ 32 #ifndef DRM_FORMAT_INVALID 33 #define DRM_FORMAT_INVALID 0 34 #endif 35 36 #ifndef DRM_FORMAT_P010 37 #define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') 38 #endif 39 40 #ifndef DRM_FORMAT_Y0L2 41 #define DRM_FORMAT_Y0L2 fourcc_code('Y', '0', 'L', '2') 42 #endif 43 44 #ifndef DRM_FORMAT_P210 45 #define DRM_FORMAT_P210 fourcc_code('P', '2', '1', '0') 46 #endif 47 48 #ifndef DRM_FORMAT_Y210 49 #define DRM_FORMAT_Y210 fourcc_code('Y', '2', '1', '0') 50 #endif 51 52 #ifndef DRM_FORMAT_Y410 53 #define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') 54 #endif 55 56 #ifndef DRM_FORMAT_YUV420_8BIT 57 #define DRM_FORMAT_YUV420_8BIT fourcc_code('Y', 'U', '0', '8') 58 #endif 59 60 #ifndef DRM_FORMAT_YUV420_10BIT 61 #define DRM_FORMAT_YUV420_10BIT fourcc_code('Y', 'U', '1', '0') 62 #endif 63 64 #ifndef DRM_FORMAT_ABGR16161616F 65 #define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') 66 #endif 67 68 #ifndef DRM_FORMAT_R16 69 #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') 70 #endif 71 72 /* ARM specific modifiers. */ 73 #ifndef DRM_FORMAT_MOD_VENDOR_ARM 74 #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 75 #endif 76 77 #ifndef fourcc_mod_code 78 #define fourcc_mod_code(vendor, val) \ 79 ((((uint64_t)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL)) 80 #endif 81 82 #ifndef DRM_FORMAT_MOD_ARM_AFBC 83 /* AFBC modifiers. */ 84 85 #define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) fourcc_mod_code(ARM, (__afbc_mode)) 86 /* AFBC superblock size. */ 87 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 88 #define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 ((uint64_t)0x1) 89 #endif 90 91 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 92 #define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 ((uint64_t)0x2) 93 #endif 94 95 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 96 #define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK ((uint64_t)0xf) 97 #endif 98 99 /* AFBC lossless transform. */ 100 #ifndef AFBC_FORMAT_MOD_YTR 101 #define AFBC_FORMAT_MOD_YTR (((uint64_t)1) << 4) 102 #endif 103 104 /* AFBC block-split. */ 105 #ifndef AFBC_FORMAT_MOD_SPLIT 106 #define AFBC_FORMAT_MOD_SPLIT (((uint64_t)1) << 5) 107 #endif 108 109 /* AFBC sparse layout. */ 110 #ifndef AFBC_FORMAT_MOD_SPARSE 111 #define AFBC_FORMAT_MOD_SPARSE (((uint64_t)1) << 6) 112 #endif 113 114 /* AFBC tiled layout. */ 115 #ifndef AFBC_FORMAT_MOD_TILED 116 #define AFBC_FORMAT_MOD_TILED (((uint64_t)1) << 8) 117 #endif 118 119 #endif /* DRM_FORMAT_MOD_ARM_AFBC */ 120 121 /* AFBC 1.3 block sizes. */ 122 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 123 #define AFBC_FORMAT_MOD_BLOCK_SIZE_64x4 ((uint64_t)0x3) 124 #endif 125 126 #ifndef AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 127 #define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4 ((uint64_t)0x4) 128 #endif 129 130 /* AFBC double-buffer. */ 131 #ifndef AFBC_FORMAT_MOD_DB 132 #define AFBC_FORMAT_MOD_DB (((uint64_t)1) << 10) 133 #endif 134 135 /* AFBC buffer content hints. */ 136 #ifndef AFBC_FORMAT_MOD_BCH 137 #define AFBC_FORMAT_MOD_BCH (((uint64_t)1) << 11) 138 #endif 139 140 } 141 142 #endif /* MALI_FOURCC_H_ */ 143