1/* 2 * Copyright (C) 2008 VMware, Inc. 3 * Copyright (C) 2014 Broadcom 4 * Copyright (C) 2018-2019 Alyssa Rosenzweig 5 * Copyright (C) 2019-2020 Collabora, Ltd. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the next 15 * paragraph) shall be included in all copies or substantial portions of the 16 * Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 * SOFTWARE. 25 * 26 */ 27 28#ifndef __PAN_FORMAT_H 29#define __PAN_FORMAT_H 30 31#include "genxml/gen_macros.h" 32 33#include "util/format/u_format.h" 34 35/* Formats */ 36 37typedef uint32_t mali_pixel_format; 38 39struct panfrost_format { 40 mali_pixel_format hw; 41 unsigned bind; 42}; 43 44struct pan_blendable_format { 45 /* enum mali_color_buffer_internal_format */ uint16_t internal; 46 /* enum mali_mfbd_color_format */ uint16_t writeback; 47 48 /* Indexed by the dithered? flag. So _PU first, then _AU */ 49 mali_pixel_format bifrost[2]; 50}; 51 52extern const struct pan_blendable_format panfrost_blendable_formats_v6[PIPE_FORMAT_COUNT]; 53extern const struct pan_blendable_format panfrost_blendable_formats_v7[PIPE_FORMAT_COUNT]; 54extern const struct pan_blendable_format panfrost_blendable_formats_v9[PIPE_FORMAT_COUNT]; 55extern const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT]; 56extern const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT]; 57extern const struct panfrost_format panfrost_pipe_format_v9[PIPE_FORMAT_COUNT]; 58 59/* Helpers to construct swizzles */ 60 61#define PAN_V6_SWIZZLE(R, G, B, A) ( \ 62 ((MALI_CHANNEL_ ## R) << 0) | \ 63 ((MALI_CHANNEL_ ## G) << 3) | \ 64 ((MALI_CHANNEL_ ## B) << 6) | \ 65 ((MALI_CHANNEL_ ## A) << 9)) 66 67static inline unsigned 68panfrost_get_default_swizzle(unsigned components) 69{ 70 switch (components) { 71 case 1: 72 return PAN_V6_SWIZZLE(R, 0, 0, 1); 73 case 2: 74 return PAN_V6_SWIZZLE(R, G, 0, 1); 75 case 3: 76 return PAN_V6_SWIZZLE(R, G, B, 1); 77 case 4: 78 return PAN_V6_SWIZZLE(R, G, B, A); 79 default: 80 unreachable("Invalid number of components"); 81 } 82} 83 84#endif 85