summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ding <aaronding@google.com>2021-05-20 22:23:31 +0800
committerAaron Ding <aaronding@google.com>2021-05-20 22:23:31 +0800
commitc5d087e8ff50ce78732312942326a3cb465b237c (patch)
treed413dcb76a199422c69f58e3c224457f4673f7a9
parent661880a301be9e7edd901a5721c73dec9975d865 (diff)
downloadgs201-c5d087e8ff50ce78732312942326a3cb465b237c.tar.gz
add libacryl_plugin library support
Bug: 186836335 Change-Id: I14ebd21de7c14807c65ffe1e87b34657371efda6
-rw-r--r--Android.bp18
-rw-r--r--include/gs101/displaycolor/displaycolor_gs101.h302
-rw-r--r--libacryl_plugins/Android.bp21
-rw-r--r--libacryl_plugins/libacryl_hdr_plugin.cpp237
4 files changed, 578 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..a874d56
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,18 @@
+soong_namespace {
+ imports: ["hardware/google/gchips", "hardware/google/graphics/common"]
+}
+
+package {
+ default_applicable_licenses: ["hardware_google_graphics_gs201_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "hardware_google_graphics_gs201_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ ],
+ // large-scale-change unable to identify any license_text files
+}
diff --git a/include/gs101/displaycolor/displaycolor_gs101.h b/include/gs101/displaycolor/displaycolor_gs101.h
new file mode 100644
index 0000000..b2ef7f9
--- /dev/null
+++ b/include/gs101/displaycolor/displaycolor_gs101.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DISPLAYCOLOR_GS101_H_
+#define DISPLAYCOLOR_GS101_H_
+
+#include <array>
+#include <functional>
+#include <memory>
+
+#include <displaycolor/displaycolor.h>
+
+namespace displaycolor {
+
+/// An interface for accessing GS101 color management data.
+class IDisplayColorGS101 : public IDisplayColorGeneric {
+ private:
+ /// Register data for matrices in DPP and DQE.
+ template <typename T, size_t kDimensions>
+ struct MatrixData {
+ /**
+ * DQE0_GAMMA_MATRIX_COEFF0..4[GAMMA_MATRIX_COEFF_xx]
+ * DQE0_LINEAR_MATRIX_COEFF0..4[LINEAR_MATRIX_COEFF_xx]
+ * DPP_HDR_LSI_L#_GM_COEF0..8[COEF], #(0..5)
+ */
+ std::array<T, kDimensions * kDimensions> coeffs{};
+
+ /**
+ * DQE0_GAMMA_MATRIX_OFFSET0..1[GAMMA_MATRIX_COEFF_n]
+ * DQE0_LINEAR_MATRIX_OFFSET0..1[LINEAR_MATRIX_COEFF_n]
+ * DPP_HDR_LSI_L#_GM_OFFS0..2[OFFS], #(0..5)
+ */
+ std::array<T, kDimensions> offsets{};
+ };
+
+ public:
+ /**
+ * @brief Interface for accessing data for DPP stages.
+ *
+ * Note that the data returned by this interface is applicable to both DPP
+ * in DPU and the HDR blocks in G2D. These two IPs' register specs are
+ * identical, with one caveat: While all G2D layers support display tone
+ * mapping (DTM) for HDR10+, only DPP layers L1/L3/L5 support this stage.
+ */
+ struct IDpp {
+ private:
+ /// Register data for transfer function LUTs in DPP)
+ template <typename XT, typename YT, size_t N>
+ struct TransferFunctionData {
+ /**
+ * DPP_HDR_LSI_L#_EOTF_POSX0~64[POSXn], #(0..5), n(0..1)
+ * DPP_HDR_LSI_L#_OETF_POSX0~16[POSXn], #(0..5), n(0..1)
+ * DPP_HDR_LSI_L#_TM_POSX0~16[POSXn], #(1, 3, 5), n(0..1)
+ */
+ std::array<XT, N> posx;
+ /**
+ * DPP_HDR_LSI_L#_EOTF_POSY0~128[POSY0], #(0..5)
+ * DPP_HDR_LSI_L#_OETF_POSY0~16[POSYn] #(0..5), n(0..1)
+ * DPP_HDR_LSI_L#_TM_POSY0~32[POSY0], #(1, 3, 5)
+ */
+ std::array<YT, N> posy;
+ };
+
+ struct EotfConfigType {
+ using XContainer = uint16_t;
+ using YContainer = uint32_t;
+ static constexpr size_t kLutLen = 129;
+
+ TransferFunctionData<XContainer, YContainer, kLutLen> tf_data;
+ };
+
+ struct GmConfigType {
+ using Container = uint32_t;
+ static constexpr size_t kDimensions = 3;
+
+ MatrixData<Container, kDimensions> matrix_data;
+ };
+
+ struct DtmConfigType {
+ using XContainer = uint16_t;
+ using YContainer = uint32_t;
+ static constexpr size_t kLutLen = 33;
+
+ TransferFunctionData<XContainer, YContainer, kLutLen> tf_data;
+ uint16_t coeff_r; // DPP_HDR_LSI_L#_TM_COEF[COEFR] #(1, 3, 5)
+ uint16_t coeff_g; // DPP_HDR_LSI_L#_TM_COEF[COEFG] #(1, 3, 5)
+ uint16_t coeff_b; // DPP_HDR_LSI_L#_TM_COEF[COEFB] #(1, 3, 5)
+ uint16_t rng_x_min; // DPP_HDR_LSI_L#_TM_RNGX[MINX] #(1, 3, 5)
+ uint16_t rng_x_max; // DPP_HDR_LSI_L#_TM_RNGX[MAXX] #(1, 3, 5)
+ uint16_t rng_y_min; // DPP_HDR_LSI_L#_TM_RNGY[MINY] #(1, 3, 5)
+ uint16_t rng_y_max; // DPP_HDR_LSI_L#_TM_RNGY[MAXY] #(1, 3, 5)
+ };
+
+ struct OetfConfigType {
+ using XContainer = uint32_t;
+ using YContainer = uint16_t;
+ static constexpr size_t kLutLen = 33;
+
+ TransferFunctionData<XContainer, YContainer, kLutLen> tf_data;
+ };
+
+ public:
+ /// Register data for the EOTF LUT in DPP.
+ using EotfData = DisplayStage<EotfConfigType>;
+
+ /// Register data for the gamut mapping (GM) matrix in DPP.
+ using GmData = DisplayStage<GmConfigType>;
+
+ /**
+ * @brief Register data for the DTM stage in DPP.
+ *
+ * Note that this data is only applicable to DPP in layers L1/L3/L5 and
+ * G2D layers. Other DPPs do not support DTM. DTM data will be provided
+ * for any layer whose DisplayScene::LayerColorData contains HDR dynamic
+ * metadata. It is the caller's (typically HWComposer) responsibility to
+ * validate layers and HW capabilities correctly, before calling this
+ * API.
+ */
+ using DtmData = DisplayStage<DtmConfigType>;
+
+ /// Register data for the OETF LUT in DPP.
+ using OetfData = DisplayStage<OetfConfigType>;
+
+ /// Get data for the EOTF LUT.
+ virtual const EotfData& EotfLut() const = 0;
+
+ /// Get data for the gamut mapping (GM) matrix.
+ virtual const GmData& Gm() const = 0;
+
+ /**
+ * @brief Get data for the DTM LUT. Only used for HDR10+, and only
+ * applicable to DPPs that support this functionality.
+ */
+ virtual const DtmData& Dtm() const = 0;
+
+ /// Get data for the OETF LUT.
+ virtual const OetfData& OetfLut() const = 0;
+
+ virtual ~IDpp() {}
+ };
+
+ /// Interface for accessing data for DQE stages.
+ struct IDqe {
+ private:
+ /// 32-bit DQE dither register, same definition as in uapi
+ struct DitherConfigType {
+ uint8_t en : 1;
+ uint8_t mode : 1;
+ uint8_t frame_con : 1;
+ uint8_t frame_offset : 2;
+ uint8_t table_sel_r : 1;
+ uint8_t table_sel_g : 1;
+ uint8_t table_sel_b : 1;
+ uint32_t reserved : 24;
+ };
+
+ struct DqeControlConfigType {
+ /// DQE force 10bpc mode
+ bool force_10bpc = false;
+
+ /// flag to use cgc_dither
+ bool cgc_dither_override = false;
+ /// CGC dither register value
+ union {
+ DitherConfigType cgc_dither_reg = {};
+ uint8_t cgc_dither; // only lowest 8 bit is used
+ };
+
+ /// flag to use disp_dither
+ bool disp_dither_override = false;
+ /// Display dither register value
+ union {
+ DitherConfigType disp_dither_reg = {};
+ uint8_t disp_dither; // only lowest 8 bit is used
+ };
+ };
+
+ struct DqeMatrixConfigType {
+ using Container = uint16_t;
+ static constexpr size_t kDimensions = 3;
+
+ struct MatrixData<Container, kDimensions> matrix_data;
+ };
+
+ struct DegammaConfigType {
+ using Container = uint16_t;
+ static constexpr size_t kLutLen = 65;
+
+ std::array<Container, kLutLen> values;
+ };
+
+ struct CgcConfigType {
+ using Container = uint32_t;
+ static constexpr size_t kChannelLutLen = 2457;
+
+ /// DQE0_CGC_LUT_R_N{0-2456} (8 bit: 0~2047, 10 bit: 0~8191)
+ std::array<Container, kChannelLutLen> r_values{};
+ /// DQE0_CGC_LUT_G_N{0-2456} (8 bit: 0~2047, 10 bit: 0~8191)
+ std::array<Container, kChannelLutLen> g_values{};
+ /// DQE0_CGC_LUT_B_N{0-2456} (8 bit: 0~2047, 10 bit: 0~8191)
+ std::array<Container, kChannelLutLen> b_values{};
+ };
+
+ struct RegammaConfigType {
+ using Container = uint16_t;
+ static constexpr size_t kChannelLutLen = 65;
+
+ /// REGAMMA LUT_R_{00-64} (8 bit: 0~1024, 10 bit: 0~4096)
+ std::array<Container, kChannelLutLen> r_values{};
+ /// REGAMMA LUT_G_{00-64} (8 bit: 0~1024, 10 bit: 0~4096)
+ std::array<Container, kChannelLutLen> g_values{};
+ /// REGAMMA LUT_B_{00-64} (8 bit: 0~1024, 10 bit: 0~4096)
+ std::array<Container, kChannelLutLen> b_values{};
+ };
+
+ public:
+ /// DQE control data
+ using DqeControlData = DisplayStage<DqeControlConfigType>;
+
+ /// Register data for the gamma and linear matrices in DQE.
+ using DqeMatrixData = DisplayStage<DqeMatrixConfigType>;
+
+ /// Register data for the degamma LUT in DQE.
+ using DegammaLutData = DisplayStage<DegammaConfigType>;
+
+ /// Register data for CGC.
+ using CgcData = DisplayStage<CgcConfigType>;
+
+ /// Register data for the regamma LUT.
+ using RegammaLutData = DisplayStage<RegammaConfigType>;
+
+ /// Get DQE control data
+ virtual const DqeControlData& DqeControl() const = 0;
+
+ /// Get data for the gamma-space matrix.
+ virtual const DqeMatrixData& GammaMatrix() const = 0;
+
+ /// Get data for the 1D de-gamma LUT (EOTF).
+ virtual const DegammaLutData& DegammaLut() const = 0;
+
+ /// Get data for the linear-space matrix.
+ virtual const DqeMatrixData& LinearMatrix() const = 0;
+
+ /// Get data for the Color Gamut Conversion stage (3D LUT).
+ virtual const CgcData& Cgc() const = 0;
+
+ /// Get data for the 3x1D re-gamma LUTa (OETF).
+ virtual const RegammaLutData& RegammaLut() const = 0;
+
+ virtual ~IDqe() {}
+ };
+
+ /// Interface for accessing particular display color data
+ struct IDisplayPipelineData {
+ /**
+ * @brief Get handles to Display Pre-Processor (DPP) data accessors.
+ *
+ * The order of the returned DPP handles match the order of the
+ * LayerColorData provided as part of struct DisplayScene and
+ * IDisplayColorGeneric::Update().
+ */
+ virtual std::vector<std::reference_wrapper<const IDpp>> Dpp() const = 0;
+
+ /// Get a handle to Display Quality Enhancer (DQE) data accessors.
+ virtual const IDqe& Dqe() const = 0;
+
+ /// Get a handle to panel data accessors
+ virtual const IPanel& Panel() const = 0;
+
+ virtual ~IDisplayPipelineData() {}
+ };
+
+ /// Get pipeline color data for specified display type
+ virtual const IDisplayPipelineData* GetPipelineData(
+ DisplayType display) const = 0;
+
+ virtual ~IDisplayColorGS101() {}
+};
+
+extern "C" {
+
+/// Get the GS101 instance.
+IDisplayColorGS101* GetDisplayColorGS101(size_t display_num);
+
+}
+
+} // namespace displaycolor
+
+#endif // DISPLAYCOLOR_GS101_H_
diff --git a/libacryl_plugins/Android.bp b/libacryl_plugins/Android.bp
new file mode 100644
index 0000000..118163b
--- /dev/null
+++ b/libacryl_plugins/Android.bp
@@ -0,0 +1,21 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_google_graphics_gs201_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_google_graphics_gs201_license"],
+}
+
+cc_library {
+ name: "libacryl_hdr_plugin",
+ proprietary: true,
+ include_dirs: [
+ "hardware/google/graphics/gs201/include",
+ "hardware/google/graphics/common/include"
+ ],
+ srcs: ["libacryl_hdr_plugin.cpp"],
+ shared_libs: ["liblog", "android.hardware.graphics.common@1.2"],
+ header_libs: ["google_libacryl_hdrplugin_headers", "libsystem_headers"],
+ cflags: ["-Werror"],
+}
diff --git a/libacryl_plugins/libacryl_hdr_plugin.cpp b/libacryl_plugins/libacryl_hdr_plugin.cpp
new file mode 100644
index 0000000..0861c71
--- /dev/null
+++ b/libacryl_plugins/libacryl_hdr_plugin.cpp
@@ -0,0 +1,237 @@
+/*
+ * libacryl_plugins/libacryl_hdr_plugin.cpp
+ *
+ * Copyright 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <cassert>
+#include <array>
+
+#include <gs101/displaycolor/displaycolor_gs101.h>
+#include <hardware/exynos/g2d_hdr_plugin.h>
+
+#define HDR_BASE 0x3000
+#define HDR_SFR_LEN 0x800
+
+#define HDR_COM_CTRL 0x3004 // [0] HDR enable
+static const uint32_t VAL_HDR_CTRL_ENABLE = 1;
+
+#define HDR_MOD_CTRL_NUM 1 // [0] oetf enable, [1] eotf enable [2] gm enable [5] tm enable
+#define HDR_OETF_POSX_NUM 17 // two 16-bit from LSB
+#define HDR_OETF_POSY_NUM 17 // two 10-bit from LSB
+#define HDR_EOTF_POSX_NUM 65 // two 10-bit from LSB
+#define HDR_EOTF_POSY_NUM 129 // one 16-bit
+#define HDR_GM_COEF_NUM 9 // one 19-bit
+#define HDR_GM_OFF_NUM 3 // one 17-bit
+#define HDR_TM_COEF_NUM 1 // three 10-bit from LSB (R, G, B)
+#define HDR_TM_RNGX_NUM 1 // two 16-bit from LSB (min:max)
+#define HDR_TM_RNGY_NUM 1 // two 9-bit from LSB (min:max)
+#define HDR_TM_POSX_NUM 17 // two 16-bit from LSB
+#define HDR_TM_POSY_NUM 33 // one 27-bit from LSB
+
+#define HDR_MOD_CTRL_OFFSET (0x8)
+static const uint32_t HDR_ENABLE_OETF = 1 << 0;
+static const uint32_t HDR_ENABLE_EOTF = 1 << 1;
+static const uint32_t HDR_ENABLE_GM = 1 << 2;
+static const uint32_t HDR_ENABLE_DTM = 1 << 5;
+
+#define HDR_OETF_POSX_OFFSET (HDR_MOD_CTRL_OFFSET + 4 * HDR_MOD_CTRL_NUM )
+#define HDR_OETF_POSY_OFFSET (HDR_OETF_POSX_OFFSET + 4 * HDR_OETF_POSX_NUM)
+#define HDR_EOTF_POSX_OFFSET (HDR_OETF_POSY_OFFSET + 4 * HDR_OETF_POSY_NUM)
+#define HDR_EOTF_POSY_OFFSET (HDR_EOTF_POSX_OFFSET + 4 * HDR_EOTF_POSX_NUM)
+#define HDR_GM_COEF_OFFSET (HDR_EOTF_POSY_OFFSET + 4 * HDR_EOTF_POSY_NUM)
+#define HDR_GM_OFF_OFFSET (HDR_GM_COEF_OFFSET + 4 * HDR_GM_COEF_NUM )
+#define HDR_TM_COEF_OFFSET (HDR_GM_OFF_OFFSET + 4 * HDR_GM_OFF_NUM )
+#define HDR_TM_RNGX_OFFSET (HDR_TM_COEF_OFFSET + 4 * HDR_TM_COEF_NUM )
+#define HDR_TM_RNGY_OFFSET (HDR_TM_RNGX_OFFSET + 4 * HDR_TM_RNGX_NUM )
+#define HDR_TM_POSX_OFFSET (HDR_TM_RNGY_OFFSET + 4 * HDR_TM_RNGY_NUM )
+#define HDR_TM_POSY_OFFSET (HDR_TM_POSX_OFFSET + 4 * HDR_TM_POSX_NUM )
+
+#define HDR_LAYER_BASE(layer) (HDR_BASE + HDR_SFR_LEN * (layer))
+
+#define HDR_MOD_CTRL(layer) (HDR_LAYER_BASE(layer) + HDR_MOD_CTRL_OFFSET )
+#define HDR_OETF_POSX(layer) (HDR_LAYER_BASE(layer) + HDR_OETF_POSX_OFFSET)
+#define HDR_OETF_POSY(layer) (HDR_LAYER_BASE(layer) + HDR_OETF_POSY_OFFSET)
+#define HDR_EOTF_POSX(layer) (HDR_LAYER_BASE(layer) + HDR_EOTF_POSX_OFFSET)
+#define HDR_EOTF_POSY(layer) (HDR_LAYER_BASE(layer) + HDR_EOTF_POSY_OFFSET)
+#define HDR_GM_COEF(layer) (HDR_LAYER_BASE(layer) + HDR_GM_COEF_OFFSET )
+#define HDR_GM_OFF(layer) (HDR_LAYER_BASE(layer) + HDR_GM_OFF_OFFSET )
+#define HDR_TM_COEF(layer) (HDR_LAYER_BASE(layer) + HDR_TM_COEF_OFFSET )
+#define HDR_TM_RNGX(layer) (HDR_LAYER_BASE(layer) + HDR_TM_RNGX_OFFSET )
+#define HDR_TM_RNGY(layer) (HDR_LAYER_BASE(layer) + HDR_TM_RNGY_OFFSET )
+#define HDR_TM_POSX(layer) (HDR_LAYER_BASE(layer) + HDR_TM_POSX_OFFSET )
+#define HDR_TM_POSY(layer) (HDR_LAYER_BASE(layer) + HDR_TM_POSY_OFFSET )
+
+#define G2D_LAYER_HDRMODE(i) (0x290 + (i) * 0x100)
+
+#define MAX_LAYER_COUNT 4
+#define HDR_LAYER_SFR_COUNT (\
+ HDR_MOD_CTRL_NUM + HDR_OETF_POSX_NUM + HDR_OETF_POSY_NUM + \
+ HDR_EOTF_POSX_NUM + HDR_EOTF_POSY_NUM + HDR_GM_COEF_NUM + \
+ HDR_GM_OFF_NUM + HDR_TM_COEF_NUM + HDR_TM_RNGX_NUM + \
+ HDR_TM_RNGY_NUM + HDR_TM_POSX_NUM + HDR_TM_POSY_NUM\
+ )
+
+static const size_t NUM_HDR_COEFFICIENTS = HDR_LAYER_SFR_COUNT * MAX_LAYER_COUNT + 1; // HDR SFR COUNT x LAYER COUNT + COM_CTRL
+static const size_t NUM_HDR_MODE_REGS = MAX_LAYER_COUNT;
+
+class G2DHdrCommandWriter: public IG2DHdr10CommandWriter {
+ std::bitset<MAX_LAYER_COUNT> mLayerAlphaMap;
+ std::array<displaycolor::IDisplayColorGS101::IDpp *, MAX_LAYER_COUNT> mLayerData{};
+
+public:
+ struct CommandList {
+ std::array<g2d_reg, NUM_HDR_COEFFICIENTS> commands; // (294 * 4 + 1) * 8 bytes
+ std::array<g2d_reg, NUM_HDR_MODE_REGS> layer_hdr_modes; // 4 * 8 bytes
+ g2d_commandlist cmdlist{};
+
+ CommandList() {
+ cmdlist.commands = commands.data();
+ cmdlist.layer_hdr_mode = layer_hdr_modes.data();
+ }
+
+ ~CommandList() { }
+
+ void reset() {
+ cmdlist.command_count = 0;
+ cmdlist.layer_count = 0;
+ }
+
+ g2d_commandlist *get() { return &cmdlist; }
+
+ uint32_t set_and_get_next_offset(uint32_t offset, uint32_t value) {
+ commands[cmdlist.command_count].offset = offset;
+ commands[cmdlist.command_count].value = value;
+ cmdlist.command_count++;
+ return offset + sizeof(value);
+ }
+
+ void updateLayer(std::size_t layer, bool alpha_premultiplied, uint32_t modectl) {
+ auto &hdr_mode = layer_hdr_modes[cmdlist.layer_count++];
+
+ hdr_mode.offset = G2D_LAYER_HDRMODE(layer);
+ hdr_mode.value = layer;
+ // The premultiplied alpha should be demultiplied before HDR conversion.
+ if (alpha_premultiplied)
+ hdr_mode.value |= G2D_LAYER_HDRMODE_DEMULT_ALPHA;
+
+ set_and_get_next_offset(HDR_MOD_CTRL(layer), modectl);
+ }
+
+ template <typename containerT>
+ void updateDouble(const containerT &container, uint32_t offset) {
+ for (std::size_t n = 0; n < container.size(); n += 2)
+ offset = set_and_get_next_offset(offset, container[n] | container[n + 1] << 16);
+ if ((container.size() % 2) == 1)
+ set_and_get_next_offset(offset, container.back());
+ }
+
+ template <typename containerT>
+ void updateSingle(const containerT &container, uint32_t offset) {
+ for (auto item : container)
+ offset = set_and_get_next_offset(offset, item);
+ }
+
+ void updateTmCoef(const displaycolor::IDisplayColorGS101::IDpp::DtmData::ConfigType &config, uint32_t offset) {
+ offset = set_and_get_next_offset(offset, config.coeff_r | (config.coeff_g << 10) | (config.coeff_b << 20));
+ offset = set_and_get_next_offset(offset, config.rng_x_min | (config.rng_x_max << 16));
+ set_and_get_next_offset(offset, config.rng_y_min | (config.rng_y_max << 16));
+ }
+
+ void updateHdr() {
+ if (cmdlist.command_count > 0)
+ set_and_get_next_offset(HDR_COM_CTRL, VAL_HDR_CTRL_ENABLE);
+ }
+ } mCmdList;
+
+ G2DHdrCommandWriter() { }
+ virtual ~G2DHdrCommandWriter() { }
+
+ virtual bool setLayerStaticMetadata(int __unused index, int __unused dataspace,
+ unsigned int __unused min_luminance, unsigned int __unused max_luminance) override {
+ return true;
+ }
+
+ virtual bool setLayerImageInfo(int index, unsigned int __unused pixfmt, bool alpha_premult) override {
+ if (alpha_premult)
+ mLayerAlphaMap.set(index);
+ return true;
+ }
+
+ virtual bool setTargetInfo(int __unused dataspace, void * __unused data) override {
+ return true;
+ }
+
+ virtual bool setLayerOpaqueData(int index, void *data, size_t __unused len) override {
+ mLayerData[index] = reinterpret_cast<displaycolor::IDisplayColorGS101::IDpp *>(data);
+ return true;
+ }
+
+ virtual struct g2d_commandlist *getCommands() override {
+ mCmdList.reset();
+
+ unsigned int i = 0;
+ for (auto layer : mLayerData) {
+ if (layer) {
+ uint32_t modectl = 0;
+
+ if (layer->EotfLut().enable && layer->EotfLut().config != nullptr) {
+ mCmdList.updateDouble(layer->EotfLut().config->tf_data.posx, HDR_EOTF_POSX(i));
+ mCmdList.updateSingle(layer->EotfLut().config->tf_data.posy, HDR_EOTF_POSY(i));
+ modectl |= HDR_ENABLE_EOTF;
+ }
+
+ if (layer->Gm().enable && layer->Gm().config != nullptr) {
+ mCmdList.updateSingle(layer->Gm().config->matrix_data.coeffs, HDR_GM_COEF(i));
+ mCmdList.updateSingle(layer->Gm().config->matrix_data.offsets, HDR_GM_OFF(i));
+ modectl |= HDR_ENABLE_GM;
+ }
+
+ if (layer->Dtm().enable && layer->Dtm().config != nullptr) {
+ mCmdList.updateTmCoef(*layer->Dtm().config, HDR_TM_COEF(i));
+ mCmdList.updateDouble(layer->Dtm().config->tf_data.posx, HDR_TM_POSX(i));
+ mCmdList.updateSingle(layer->Dtm().config->tf_data.posy, HDR_TM_POSY(i));
+ modectl |= HDR_ENABLE_DTM;
+ }
+
+ if (layer->OetfLut().enable && layer->OetfLut().config != nullptr) {
+ mCmdList.updateDouble(layer->OetfLut().config->tf_data.posx, HDR_OETF_POSX(i));
+ mCmdList.updateDouble(layer->OetfLut().config->tf_data.posy, HDR_OETF_POSY(i));
+ modectl |= HDR_ENABLE_OETF;
+ }
+
+ mCmdList.updateLayer(i, mLayerAlphaMap[0], modectl);
+ }
+
+ mLayerAlphaMap >>= 1;
+ i++;
+ }
+
+ mCmdList.updateHdr();
+
+ // initialize for the next layer metadata configuration
+ mLayerAlphaMap.reset();
+ mLayerData.fill(nullptr);
+
+ return mCmdList.get();
+ }
+
+ virtual void putCommands(struct g2d_commandlist __unused *commands) override {
+ assert(commands == &mCommandList);
+ }
+};
+
+IG2DHdr10CommandWriter *IG2DHdr10CommandWriter::createInstance() {
+ return new G2DHdrCommandWriter();
+}