1 /* 2 * Copyright (C) Texas Instruments Incorporated - http://www.ti.com/ 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 #pragma once 18 19 #include <string> 20 21 #include <cstdint> 22 23 #include <drm/drm_fourcc.h> 24 #include <linux/types.h> 25 26 #include "hal_public.h" 27 HAL_FMT(uint32_t format)28static inline std::string HAL_FMT(uint32_t format) 29 { 30 switch (format) { 31 case HAL_PIXEL_FORMAT_TI_NV12: return "NV12"; 32 case HAL_PIXEL_FORMAT_TI_NV12_1D: return "NV12"; 33 case HAL_PIXEL_FORMAT_YV12: return "YV12"; 34 case HAL_PIXEL_FORMAT_BGRX_8888: return "xRGB32"; 35 case HAL_PIXEL_FORMAT_RGBX_8888: return "xBGR32"; 36 case HAL_PIXEL_FORMAT_BGRA_8888: return "ARGB32"; 37 case HAL_PIXEL_FORMAT_RGBA_8888: return "ABGR32"; 38 case HAL_PIXEL_FORMAT_RGB_565: return "RGB565"; 39 default: return "??"; 40 } 41 } 42 DRM_FMT(uint32_t format)43static inline std::string DRM_FMT(uint32_t format) 44 { 45 switch (format) { 46 case DRM_FORMAT_NV12: return "NV12"; 47 case DRM_FORMAT_XRGB8888: return "xRGB32"; 48 case DRM_FORMAT_ARGB8888: return "ARGB32"; 49 case DRM_FORMAT_RGB565: return "RGB565"; 50 default: return "??"; 51 } 52 } 53 54 bool is_valid_format(uint32_t format); 55 bool is_rgb_format(uint32_t format); 56 bool is_bgr_format(uint32_t format); 57 bool is_nv12_format(uint32_t format); 58 bool is_opaque_format(uint32_t format); 59 uint32_t get_format_bpp(uint32_t format); 60 uint32_t convert_hal_to_dss_format(uint32_t format, bool blended); 61 uint32_t convert_hal_to_drm_format(uint32_t hal_format, bool blended); 62 uint32_t convert_hal_to_ocd_format(uint32_t hal_format); 63 uint32_t get_stride_from_format(uint32_t format, uint32_t width); 64