Home | History | Annotate | Line # | Download | only in lib
      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 
     37 typedef uint32_t mali_pixel_format;
     38 
     39 struct panfrost_format {
     40         mali_pixel_format hw;
     41         unsigned bind;
     42 };
     43 
     44 struct 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 
     52 extern const struct pan_blendable_format panfrost_blendable_formats_v6[PIPE_FORMAT_COUNT];
     53 extern const struct pan_blendable_format panfrost_blendable_formats_v7[PIPE_FORMAT_COUNT];
     54 extern const struct panfrost_format panfrost_pipe_format_v6[PIPE_FORMAT_COUNT];
     55 extern const struct panfrost_format panfrost_pipe_format_v7[PIPE_FORMAT_COUNT];
     56 
     57 /* Helpers to construct swizzles */
     58 
     59 #define PAN_V6_SWIZZLE(R, G, B, A) ( \
     60         ((MALI_CHANNEL_ ## R) << 0) | \
     61         ((MALI_CHANNEL_ ## G) << 3) | \
     62         ((MALI_CHANNEL_ ## B) << 6) | \
     63         ((MALI_CHANNEL_ ## A) << 9))
     64 
     65 static inline unsigned
     66 panfrost_get_default_swizzle(unsigned components)
     67 {
     68         switch (components) {
     69         case 1:
     70                 return PAN_V6_SWIZZLE(R, 0, 0, 1);
     71         case 2:
     72                 return PAN_V6_SWIZZLE(R, G, 0, 1);
     73         case 3:
     74                 return PAN_V6_SWIZZLE(R, G, B, 1);
     75         case 4:
     76                 return PAN_V6_SWIZZLE(R, G, B, A);
     77         default:
     78                 unreachable("Invalid number of components");
     79         }
     80 }
     81 
     82 #endif
     83