1 /* 2 * Copyright (C) 2018-2019 ARM Limited. All rights reserved. 3 * 4 * Copyright (C) 2008 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef FORMAT_INFO_H_ 20 #define FORMAT_INFO_H_ 21 22 #include "exynos_format.h" 23 #include "mali_gralloc_buffer.h" 24 25 /* Base format unsupported */ 26 #define F_NONE 0 27 /* Base format supports uncompressed */ 28 #define F_LIN ((uint8_t)1 << 0) 29 /* Base format supports AFBC */ 30 #define F_AFBC ((uint8_t)1 << 1) 31 /* Base format supports AFBC with different swizzle */ 32 #define F_AFBC_SWIZ ((uint8_t)1 << 2) 33 34 typedef struct 35 { 36 uint16_t width; 37 uint16_t height; 38 } rect_t; 39 40 41 /* 42 * Pixel format information. 43 * 44 * These properties are used by gralloc for buffer allocation. 45 * Each format is uniquely identified with 'id'. 46 */ 47 typedef struct 48 { 49 uint32_t id; /* Format ID. */ 50 uint8_t npln; /* Number of planes. */ 51 uint8_t ncmp; /* Number of components. */ 52 uint8_t bps; /* Bits per sample (primary/largest). */ 53 uint8_t bpp_afbc[MAX_PLANES]; /* Bits per pixel (AFBC), without implicit padding. 'X' in RGBX is still included. */ 54 uint8_t bpp[MAX_PLANES]; /* Bits per pixel (linear/uncompressed), including any implicit sample padding defined by format (e.g. 10-bit Y210 padded to 16-bits). 55 * NOTE: bpp[n] and/or (bpp[n] * align_w_cpu) must be multiples of 8. */ 56 uint8_t hsub; /* Horizontal sub-sampling (YUV formats). Pixel rounding in width (all formats). Must be a power of 2. */ 57 uint8_t vsub; /* Vertical sub-sampling (YUV formats). Pixel rounding in height (all formats). Must be a power of 2. */ 58 uint8_t align_w; /* Alignment of width (per plane, in pixels). Must be a power of 2. NOTE: where 'is_yuv == true', this must be a multiple of 'hsub'. */ 59 uint8_t align_h; /* Alignment of height (per plane, in pixels). Must be a power of 2. NOTE: where 'is_yuv == true', this must be a multiple of 'vsub'. */ 60 uint8_t align_w_cpu; /* Alignment of width for CPU access (per plane, in pixels). ALIGN_W_CPU_DEFAULT: 1. Must be a power of 2. */ 61 uint16_t tile_size; /* Tile size (in pixels), assumed square. Uncompressed only. */ 62 bool has_alpha; /* Alpha channel present. */ 63 bool is_rgb; /* RGB format. */ 64 bool is_yuv; /* YUV format. */ 65 bool afbc; /* AFBC supported (per specification and by gralloc). IP support not considered. */ 66 bool linear; /* Linear/uncompressed supported. */ 67 bool yuv_transform; /* Supports AFBC YUV transform: 3+ channel RGB (strict R-G-B-? order) with less than 12-bit per sample. */ 68 bool flex; /* Linear version of format can be represented as flex. */ 69 bool planes_contiguous; /* True if all planes in format are contiguous in memory. Has no effect on non-planar formats */ 70 const char *name; /* Human-readable name. */ 71 } format_info_t; 72 73 typedef struct 74 { 75 uint32_t id; /* Format ID. */ 76 uint8_t cpu_wr; /* CPU producer. */ 77 uint8_t cpu_rd; /* CPU consumer. */ 78 uint8_t gpu_wr; /* GPU producer. */ 79 uint8_t gpu_rd; /* GPU consumer. */ 80 uint8_t dpu_wr; /* DPU producer. */ 81 uint8_t dpu_rd; /* DPU consumer. */ 82 uint8_t dpu_aeu_wr; /* DPU AEU producer. */ 83 uint8_t vpu_wr; /* VPU producer. */ 84 uint8_t vpu_rd; /* VPU consumer. */ 85 86 } format_ip_support_t; 87 88 89 extern const format_info_t formats[]; 90 extern const format_ip_support_t formats_ip_support[]; 91 extern const size_t num_formats; 92 extern const size_t num_ip_formats; 93 94 extern int32_t get_format_index(const uint32_t base_format); 95 extern int32_t get_ip_format_index(const uint32_t base_format); 96 extern uint32_t get_internal_format(const uint32_t base_format, const bool map_to_internal); 97 extern bool sanitize_formats(void); 98 99 extern const char *format_name(const uint32_t base_format); 100 101 #endif 102