1 /*
2 * Copyright Samsung Electronics Co.,LTD.
3 * Copyright (C) 2016 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #include <cstring>
19
20 #include <log/log.h>
21
22 #include <exynos_format.h> // hardware/smasung_slsi/exynos/include
23
24 #include "acrylic_internal.h"
25 #include "acrylic_g2d.h"
26
27 static uint32_t all_fimg2d_gs101_formats[] = {
28 HAL_PIXEL_FORMAT_RGBA_8888,
29 HAL_PIXEL_FORMAT_BGRA_8888,
30 HAL_PIXEL_FORMAT_RGBA_1010102,
31 HAL_PIXEL_FORMAT_RGBX_8888,
32 HAL_PIXEL_FORMAT_RGB_888,
33 HAL_PIXEL_FORMAT_RGB_565,
34 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P,
35 HAL_PIXEL_FORMAT_YCrCb_420_SP, // NV21 (YVU420 semi-planar)
36 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M, // NV21 on multi-buffer
37 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_FULL, // NV21 on multi-buffer
38 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP, // NV12 (YUV420 semi-planar)
39 HAL_PIXEL_FORMAT_GOOGLE_NV12_SP, // NV12 (YUV420 semi-planar)
40 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN, // NV12 with MFC alignment constraints
41 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M, // NV12M with MFC alignment constraints on multi-buffer
42 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_PRIV, // 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 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_M,
47 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC,
48 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_SBWC,
49 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC,
50 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_10B_SBWC,
51 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_SBWC,
52 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_10B_SBWC,
53 };
54
55 // The presence of the dataspace definitions are in the order
56 // of application's preference to reduce comparations.
57 static int all_hwc_dataspaces[] = {
58 HAL_DATASPACE_STANDARD_BT709,
59 HAL_DATASPACE_STANDARD_BT709 | HAL_DATASPACE_RANGE_FULL,
60 HAL_DATASPACE_STANDARD_BT709 | HAL_DATASPACE_RANGE_LIMITED,
61 HAL_DATASPACE_STANDARD_BT2020,
62 HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_RANGE_FULL,
63 HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_RANGE_LIMITED,
64 HAL_DATASPACE_STANDARD_BT601_625,
65 HAL_DATASPACE_STANDARD_BT601_625 | HAL_DATASPACE_RANGE_FULL,
66 HAL_DATASPACE_STANDARD_BT601_625 | HAL_DATASPACE_RANGE_LIMITED,
67 HAL_DATASPACE_STANDARD_BT601_525,
68 HAL_DATASPACE_STANDARD_BT601_525 | HAL_DATASPACE_RANGE_FULL,
69 HAL_DATASPACE_STANDARD_BT601_525 | HAL_DATASPACE_RANGE_LIMITED,
70 HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED,
71 HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED | HAL_DATASPACE_RANGE_FULL,
72 HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED | HAL_DATASPACE_RANGE_LIMITED,
73 HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED,
74 HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED | HAL_DATASPACE_RANGE_FULL,
75 HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED | HAL_DATASPACE_RANGE_LIMITED,
76 HAL_DATASPACE_STANDARD_DCI_P3,
77 HAL_DATASPACE_STANDARD_DCI_P3 | HAL_DATASPACE_RANGE_FULL,
78 HAL_DATASPACE_STANDARD_DCI_P3 | HAL_DATASPACE_RANGE_LIMITED,
79 HAL_DATASPACE_STANDARD_FILM,
80 HAL_DATASPACE_STANDARD_FILM | HAL_DATASPACE_RANGE_FULL,
81 HAL_DATASPACE_STANDARD_FILM | HAL_DATASPACE_RANGE_LIMITED,
82 // 0 should be treated as BT709 Limited range
83 0,
84 HAL_DATASPACE_RANGE_FULL,
85 HAL_DATASPACE_RANGE_LIMITED,
86 // Depricated legacy dataspace definitions
87 HAL_DATASPACE_SRGB,
88 HAL_DATASPACE_JFIF,
89 HAL_DATASPACE_BT601_525,
90 HAL_DATASPACE_BT601_625,
91 HAL_DATASPACE_BT709,
92 };
93
94 const static stHW2DCapability __capability_fimg2d_gs101 = {
95 .max_upsampling_num = {8, 8},
96 .max_downsampling_factor = {4, 4},
97 .max_upsizing_num = {8, 8},
98 .max_downsizing_factor = {4, 4},
99 .min_src_dimension = {1, 1},
100 .max_src_dimension = {8192, 8192},
101 .min_dst_dimension = {1, 1},
102 .max_dst_dimension = {8192, 8192},
103 .min_pix_align = {1, 1},
104 .rescaling_count = 0,
105 .compositing_mode = HW2DCapability::BLEND_NONE | HW2DCapability::BLEND_SRC_COPY | HW2DCapability::BLEND_SRC_OVER,
106 .transform_type = HW2DCapability::TRANSFORM_ALL,
107 .auxiliary_feature = HW2DCapability::FEATURE_PLANE_ALPHA | HW2DCapability::FEATURE_UORDER_WRITE
108 | HW2DCapability::FEATURE_AFBC_ENCODE | HW2DCapability::FEATURE_AFBC_DECODE
109 | HW2DCapability::FEATURE_SOLIDCOLOR,
110 .num_formats = ARRSIZE(all_fimg2d_gs101_formats),
111 .num_dataspaces = ARRSIZE(all_hwc_dataspaces),
112 .max_layers = 4,
113 .pixformats = all_fimg2d_gs101_formats,
114 .dataspaces = all_hwc_dataspaces,
115 .base_align = 1,
116 };
117
118 static const HW2DCapability capability_fimg2d_gs101(__capability_fimg2d_gs101);
119
createInstance(const char * spec)120 Acrylic *Acrylic::createInstance(const char *spec)
121 {
122 Acrylic *compositor = nullptr;
123
124 ALOGD_TEST("Creating a new Acrylic instance of '%s'", spec);
125
126 if (strcmp(spec, "fimg2d_gs101") == 0) {
127 compositor = new AcrylicCompositorG2D(capability_fimg2d_gs101, true);
128 } else {
129 ALOGE("Unknown HW2D compositor spec., %s", spec);
130 return nullptr;
131 }
132
133 ALOGE_IF(!compositor, "Failed to create HW2D compositor of '%s'", spec);
134
135 return compositor;
136 }
137
createCompositor()138 Acrylic *Acrylic::createCompositor()
139 {
140 return Acrylic::createInstance(LIBACRYL_DEFAULT_COMPOSITOR);
141 }
142
createScaler()143 Acrylic *Acrylic::createScaler()
144 {
145 return Acrylic::createInstance(LIBACRYL_DEFAULT_SCALER);
146 }
147
createBlter()148 Acrylic *Acrylic::createBlter()
149 {
150 return Acrylic::createInstance(LIBACRYL_DEFAULT_BLTER);
151 }
152
createAcrylic(const char * spec)153 Acrylic *AcrylicFactory::createAcrylic(const char *spec)
154 {
155 if (strcmp(spec, "default_compositor") == 0) {
156 spec = LIBACRYL_DEFAULT_COMPOSITOR;
157 } else if (strcmp(spec, "default_scaler") == 0) {
158 spec = LIBACRYL_DEFAULT_SCALER;
159 } else if (strcmp(spec, "default_blter") == 0) {
160 spec = LIBACRYL_DEFAULT_BLTER;
161 }
162
163 return Acrylic::createInstance(spec);
164 }
165