• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
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 #include <cstring>
18 
19 #include <log/log.h>
20 
21 #include <exynos_format.h> // hardware/smasung_slsi/exynos/include
22 #include <mali_gralloc_formats.h>
23 
24 static uint32_t all_fimg2d_gs101_formats[] = {
25     HAL_PIXEL_FORMAT_RGBA_8888,
26     HAL_PIXEL_FORMAT_BGRA_8888,
27     HAL_PIXEL_FORMAT_RGBA_1010102,
28     HAL_PIXEL_FORMAT_RGBX_8888,
29     HAL_PIXEL_FORMAT_RGB_888,
30     HAL_PIXEL_FORMAT_RGB_565,
31     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P,
32     HAL_PIXEL_FORMAT_YCrCb_420_SP,                  // NV21 (YVU420 semi-planar)
33     HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M,         // NV21 on multi-buffer
34     HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_FULL,    // NV21 on multi-buffer
35     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP,           // NV12 (YUV420 semi-planar)
36     HAL_PIXEL_FORMAT_GOOGLE_NV12_SP,                // NV12 (YUV420 semi-planar)
37     MALI_GRALLOC_FORMAT_INTERNAL_YUV420_8BIT_I,     // NV12 AFBC
38     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN,          // NV12 with MFC alignment constraints
39     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M,
40     // NV12M with MFC alignment constraints on multi-buffer
41     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_PRIV,
42     // NV12M with MFC alignment constraints on multi-buffer
43     HAL_PIXEL_FORMAT_YCbCr_422_SP,                  // YUV422 2P (YUV422 semi-planar)
44     HAL_PIXEL_FORMAT_YCBCR_P010,
45     HAL_PIXEL_FORMAT_GOOGLE_NV12_SP_10B,
46     MALI_GRALLOC_FORMAT_INTERNAL_YUV420_10BIT_I,
47     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_SPN,
48     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_M,
49     MALI_GRALLOC_FORMAT_INTERNAL_P010,
50     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC,
51     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_SBWC,
52     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC,
53     HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_10B_SBWC,
54     HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_SBWC,
55     HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_10B_SBWC,
56 };
57 
58 static int all_hwc_gs101_dataspaces[] = {
59     HAL_DATASPACE_STANDARD_BT709,
60     HAL_DATASPACE_STANDARD_BT709 | HAL_DATASPACE_RANGE_FULL,
61     HAL_DATASPACE_STANDARD_BT709 | HAL_DATASPACE_RANGE_LIMITED,
62     HAL_DATASPACE_STANDARD_BT2020,
63     HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_RANGE_FULL,
64     HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_RANGE_LIMITED,
65     HAL_DATASPACE_STANDARD_BT601_625,
66     HAL_DATASPACE_STANDARD_BT601_625 | HAL_DATASPACE_RANGE_FULL,
67     HAL_DATASPACE_STANDARD_BT601_625 | HAL_DATASPACE_RANGE_LIMITED,
68     HAL_DATASPACE_STANDARD_BT601_525,
69     HAL_DATASPACE_STANDARD_BT601_525 | HAL_DATASPACE_RANGE_FULL,
70     HAL_DATASPACE_STANDARD_BT601_525 | HAL_DATASPACE_RANGE_LIMITED,
71     HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED,
72     HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED | HAL_DATASPACE_RANGE_FULL,
73     HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED | HAL_DATASPACE_RANGE_LIMITED,
74     HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED,
75     HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED | HAL_DATASPACE_RANGE_FULL,
76     HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED | HAL_DATASPACE_RANGE_LIMITED,
77     HAL_DATASPACE_STANDARD_DCI_P3,
78     HAL_DATASPACE_STANDARD_DCI_P3 | HAL_DATASPACE_RANGE_FULL,
79     HAL_DATASPACE_STANDARD_DCI_P3 | HAL_DATASPACE_RANGE_LIMITED,
80     HAL_DATASPACE_STANDARD_FILM,
81     HAL_DATASPACE_STANDARD_FILM | HAL_DATASPACE_RANGE_FULL,
82     HAL_DATASPACE_STANDARD_FILM | HAL_DATASPACE_RANGE_LIMITED,
83     // 0 should be treated as BT709 Limited range
84     0,
85     HAL_DATASPACE_RANGE_FULL,
86     HAL_DATASPACE_RANGE_LIMITED,
87     // Deprecated legacy dataspace definitions
88     HAL_DATASPACE_SRGB,
89     HAL_DATASPACE_JFIF,
90     HAL_DATASPACE_BT601_525,
91     HAL_DATASPACE_BT601_625,
92     HAL_DATASPACE_BT709,
93 };
94 
95 const static stHW2DCapability __capability_g2d_gs101 = {
96     .max_upsampling_num = {8, 8},
97     .max_downsampling_factor = {4, 4},
98     .max_upsizing_num = {8, 8},
99     .max_downsizing_factor = {4, 4},
100     .min_src_dimension = {1, 1},
101     .max_src_dimension = {8192, 8192},
102     .min_dst_dimension = {1, 1},
103     .max_dst_dimension = {8192, 8192},
104     .min_pix_align = {1, 1},
105     .rescaling_count = 0,
106     .compositing_mode = HW2DCapability::BLEND_NONE | HW2DCapability::BLEND_SRC_COPY
107 	                 | HW2DCapability::BLEND_SRC_OVER,
108     .transform_type = HW2DCapability::TRANSFORM_ALL,
109     .auxiliary_feature = HW2DCapability::FEATURE_PLANE_ALPHA | HW2DCapability::FEATURE_UORDER_WRITE
110                          | HW2DCapability::FEATURE_AFBC_ENCODE | HW2DCapability::FEATURE_AFBC_DECODE
111                          | HW2DCapability::FEATURE_SOLIDCOLOR,
112     .num_formats = ARRSIZE(all_fimg2d_gs101_formats),
113     .num_dataspaces = ARRSIZE(all_hwc_gs101_dataspaces),
114     .max_layers = 4,
115     .pixformats = all_fimg2d_gs101_formats,
116     .dataspaces = all_hwc_gs101_dataspaces,
117     .base_align = 1,
118 };
119 
120 static const HW2DCapability capability_fimg2d_gs101(__capability_g2d_gs101);
121 
createAcrylicCompositorG2D(const char * spec)122 inline Acrylic *createAcrylicCompositorG2D(const char *spec)
123 {
124     Acrylic *compositor = nullptr;
125 
126     if (strcmp(spec, "fimg2d_gs101") == 0) {
127         compositor = new AcrylicCompositorG2D(capability_fimg2d_gs101, /*halfmt_to_g2dfmt*/ true);
128     }
129     return compositor;
130 }
131