/* * Copyright (c) 2019, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "drm_property.h" #include "drm_utils.h" namespace sde_drm { DRMProperty DRMPropertyManager::GetPropertyEnum(const std::string &name) const { if (name == "type") { return DRMProperty::TYPE; } if (name == "FB_ID") { return DRMProperty::FB_ID; } if (name == "rot_fb_id") { return DRMProperty::ROT_FB_ID; } if (name == "CRTC_ID") { return DRMProperty::CRTC_ID; } if (name == "CRTC_X") { return DRMProperty::CRTC_X; } if (name == "CRTC_Y") { return DRMProperty::CRTC_Y; } if (name == "CRTC_W") { return DRMProperty::CRTC_W; } if (name == "CRTC_H") { return DRMProperty::CRTC_H; } if (name == "SRC_X") { return DRMProperty::SRC_X; } if (name == "SRC_Y") { return DRMProperty::SRC_Y; } if (name == "SRC_W") { return DRMProperty::SRC_W; } if (name == "SRC_H") { return DRMProperty::SRC_H; } if (name == "zpos") { return DRMProperty::ZPOS; } if (name == "alpha") { return DRMProperty::ALPHA; } if (name == "excl_rect_v1") { return DRMProperty::EXCL_RECT; } if (name == "h_decimate") { return DRMProperty::H_DECIMATE; } if (name == "v_decimate") { return DRMProperty::V_DECIMATE; } if (name == "input_fence") { return DRMProperty::INPUT_FENCE; } if (name == "rotation") { return DRMProperty::ROTATION; } if (name == "blend_op") { return DRMProperty::BLEND_OP; } if (name == "src_config") { return DRMProperty::SRC_CONFIG; } if (name == "scaler_v1") { return DRMProperty::SCALER_V1; } if (name == "scaler_v2") { return DRMProperty::SCALER_V2; } if (name == "csc_v1") { return DRMProperty::CSC_V1; } if (name == "capabilities") { return DRMProperty::CAPABILITIES; } if (name == "mode_properties") { return DRMProperty::MODE_PROPERTIES; } if (name == "lut_ed") { return DRMProperty::LUT_ED; } if (name == "lut_cir") { return DRMProperty::LUT_CIR; } if (name == "lut_sep") { return DRMProperty::LUT_SEP; } if (name == "rot_caps_v1") { return DRMProperty::ROTATOR_CAPS_V1; } if (name == "true_inline_rot_rev") { return DRMProperty::TRUE_INLINE_ROT_REV; } if (name == "fb_translation_mode") { return DRMProperty::FB_TRANSLATION_MODE; } if (name == "ACTIVE") { return DRMProperty::ACTIVE; } if (name == "MODE_ID") { return DRMProperty::MODE_ID; } if (name == "output_fence_offset") { return DRMProperty::OUTPUT_FENCE_OFFSET; } if (name == "output_fence") { return DRMProperty::OUTPUT_FENCE; } if (name == "sde_drm_roi_v1") { return DRMProperty::ROI_V1; } if (name == "core_clk") { return DRMProperty::CORE_CLK; } if (name == "core_ab") { return DRMProperty::CORE_AB; } if (name == "core_ib") { return DRMProperty::CORE_IB; } if (name == "llcc_ab") { return DRMProperty::LLCC_AB; } if (name == "llcc_ib") { return DRMProperty::LLCC_IB; } if (name == "dram_ab") { return DRMProperty::DRAM_AB; } if (name == "dram_ib") { return DRMProperty::DRAM_IB; } if (name == "rot_prefill_bw") { return DRMProperty::ROT_PREFILL_BW; } if (name == "rot_clk") { return DRMProperty::ROT_CLK; } if (name == "security_level") { return DRMProperty::SECURITY_LEVEL; } if (name == "dim_layer_v1") { return DRMProperty::DIM_STAGES_V1; } if (name == "idle_time") { return DRMProperty::IDLE_TIME; } if (name == "RETIRE_FENCE") { return DRMProperty::RETIRE_FENCE; } if (name == "DST_X") { return DRMProperty::DST_X; } if (name == "DST_Y") { return DRMProperty::DST_Y; } if (name == "DST_W") { return DRMProperty::DST_W; } if (name == "DST_H") { return DRMProperty::DST_H; } if (name == "LP") { return DRMProperty::LP; } if (name == "dest_scaler") { return DRMProperty::DEST_SCALER; } if (name == "ds_lut_ed") { return DRMProperty::DS_LUT_ED; } if (name == "ds_lut_cir") { return DRMProperty::DS_LUT_CIR; } if (name == "ds_lut_sep") { return DRMProperty::DS_LUT_SEP; } if (name == "hdr_properties") { return DRMProperty::HDR_PROPERTIES; } if (name == "SDE_DSPP_GAMUT_V3") { return DRMProperty::SDE_DSPP_GAMUT_V3; } if (name == "SDE_DSPP_GAMUT_V4") { return DRMProperty::SDE_DSPP_GAMUT_V4; } if (name == "SDE_DSPP_GAMUT_V5") { return DRMProperty::SDE_DSPP_GAMUT_V5; } if (name == "SDE_DSPP_GC_V1") { return DRMProperty::SDE_DSPP_GC_V1; } if (name == "SDE_DSPP_GC_V2") { return DRMProperty::SDE_DSPP_GC_V2; } if (name == "SDE_DSPP_IGC_V2") { return DRMProperty::SDE_DSPP_IGC_V2; } if (name == "SDE_DSPP_IGC_V3") { return DRMProperty::SDE_DSPP_IGC_V3; } if (name == "SDE_DSPP_IGC_V4") { return DRMProperty::SDE_DSPP_IGC_V4; } if (name == "SDE_DSPP_PCC_V3") { return DRMProperty::SDE_DSPP_PCC_V3; } if (name == "SDE_DSPP_PCC_V4") { return DRMProperty::SDE_DSPP_PCC_V4; } if (name == "SDE_DSPP_PCC_V5") { return DRMProperty::SDE_DSPP_PCC_V5; } if (name == "SDE_DSPP_PA_HSIC_V1") { return DRMProperty::SDE_DSPP_PA_HSIC_V1; } if (name == "SDE_DSPP_PA_HSIC_V2") { return DRMProperty::SDE_DSPP_PA_HSIC_V2; } if (name == "SDE_DSPP_PA_SIXZONE_V1") { return DRMProperty::SDE_DSPP_PA_SIXZONE_V1; } if (name == "SDE_DSPP_PA_SIXZONE_V2") { return DRMProperty::SDE_DSPP_PA_SIXZONE_V2; } if (name == "SDE_DSPP_PA_MEMCOL_SKIN_V1") { return DRMProperty::SDE_DSPP_PA_MEMCOL_SKIN_V1; } if (name == "SDE_DSPP_PA_MEMCOL_SKIN_V2") { return DRMProperty::SDE_DSPP_PA_MEMCOL_SKIN_V2; } if (name == "SDE_DSPP_PA_MEMCOL_SKY_V1") { return DRMProperty::SDE_DSPP_PA_MEMCOL_SKY_V1; } if (name == "SDE_DSPP_PA_MEMCOL_SKY_V2") { return DRMProperty::SDE_DSPP_PA_MEMCOL_SKY_V2; } if (name == "SDE_DSPP_PA_MEMCOL_FOLIAGE_V1") { return DRMProperty::SDE_DSPP_PA_MEMCOL_FOLIAGE_V1; } if (name == "SDE_DSPP_PA_MEMCOL_FOLIAGE_V2") { return DRMProperty::SDE_DSPP_PA_MEMCOL_FOLIAGE_V2; } if (name == "SDE_DSPP_PA_MEMCOL_PROT_V1") { return DRMProperty::SDE_DSPP_PA_MEMCOL_PROT_V1; } if (name == "SDE_DSPP_PA_MEMCOL_PROT_V2") { return DRMProperty::SDE_DSPP_PA_MEMCOL_PROT_V2; } if (name == "autorefresh") { return DRMProperty::AUTOREFRESH; } if (name == "ext_hdr_properties") { return DRMProperty::EXT_HDR_PROPERTIES; } if (name == "hdr_metadata") { return DRMProperty::HDR_METADATA; } if (name == "multirect_mode") { return DRMProperty::MULTIRECT_MODE; } if (name == "SDE_DSPP_PA_DITHER_V1") { return DRMProperty::SDE_DSPP_PA_DITHER_V1; } if (name == "SDE_DSPP_PA_DITHER_V2") { return DRMProperty::SDE_DSPP_PA_DITHER_V2; } if (name == "SDE_PP_DITHER_V1") { return DRMProperty::SDE_PP_DITHER_V1; } if (name == "SDE_PP_DITHER_V2") { return DRMProperty::SDE_PP_DITHER_V2; } if (name == "inverse_pma") { return DRMProperty::INVERSE_PMA; } if (name == "csc_dma_v1") { return DRMProperty::CSC_DMA_V1; } if (name == "SDE_DGM_1D_LUT_IGC_V5") { return DRMProperty::SDE_DGM_1D_LUT_IGC_V5; } if (name == "SDE_DGM_1D_LUT_GC_V5") { return DRMProperty::SDE_DGM_1D_LUT_GC_V5; } if (name == "SDE_VIG_1D_LUT_IGC_V5") { return DRMProperty::SDE_VIG_1D_LUT_IGC_V5; } if (name == "SDE_VIG_3D_LUT_GAMUT_V5") { return DRMProperty::SDE_VIG_3D_LUT_GAMUT_V5; } if (name == "SDE_DSPP_AD_V4_MODE") { return DRMProperty::SDE_DSPP_AD4_MODE; } if (name == "SDE_DSPP_AD_V4_INIT") { return DRMProperty::SDE_DSPP_AD4_INIT; } if (name == "SDE_DSPP_AD_V4_CFG") { return DRMProperty::SDE_DSPP_AD4_CFG; } if (name == "SDE_DSPP_AD_V4_ASSERTIVENESS") { return DRMProperty::SDE_DSPP_AD4_ASSERTIVENESS; } if (name == "SDE_DSPP_AD_V4_STRENGTH") { return DRMProperty::SDE_DSPP_AD4_STRENGTH; } if (name == "SDE_DSPP_AD_V4_INPUT") { return DRMProperty::SDE_DSPP_AD4_INPUT; } if (name == "SDE_DSPP_AD_V4_BACKLIGHT") { return DRMProperty::SDE_DSPP_AD4_BACKLIGHT; } if (name == "SDE_DSPP_AD_V4_ROI") { return DRMProperty::SDE_DSPP_AD4_ROI; } if (name == "SDE_DSPP_HIST_CTRL_V1") { return DRMProperty::SDE_DSPP_ABA_HIST_CTRL; } if (name == "SDE_DSPP_HIST_IRQ_V1") { return DRMProperty::SDE_DSPP_ABA_HIST_IRQ; } if (name == "SDE_DSPP_VLUT_V1") { return DRMProperty::SDE_DSPP_ABA_LUT; } if (name == "bl_scale") { return DRMProperty::SDE_DSPP_BL_SCALE; } if (name == "sv_bl_scale") { return DRMProperty::SDE_DSPP_SV_BL_SCALE; } if (name == "capture_mode") { return DRMProperty::CAPTURE_MODE; } if (name == "qsync_mode") { return DRMProperty::QSYNC_MODE; } if (name == "idle_pc_state") { return DRMProperty::IDLE_PC_STATE; } if (name == "topology_control") { return DRMProperty::TOPOLOGY_CONTROL; } if (name == "EDID") { return DRMProperty::EDID; } if (name == "SDE_DSPP_LTM_V1") { return DRMProperty::SDE_LTM_VERSION; } if (name == "SDE_DSPP_LTM_INIT_V1") { return DRMProperty::SDE_LTM_INIT; } if (name == "SDE_DSPP_LTM_ROI_V1") { return DRMProperty::SDE_LTM_CFG; } if (name == "SDE_DSPP_LTM_HIST_THRESH_V1") { return DRMProperty::SDE_LTM_NOISE_THRESH; } if (name == "SDE_DSPP_LTM_HIST_CTRL_V1") { return DRMProperty::SDE_LTM_HIST_CTRL; } if (name == "SDE_DSPP_LTM_SET_BUF_V1") { return DRMProperty::SDE_LTM_BUFFER_CTRL; } if (name == "SDE_DSPP_LTM_QUEUE_BUF_V1") { return DRMProperty::SDE_LTM_QUEUE_BUFFER; } if (name == "SDE_DSPP_LTM_QUEUE_BUF2_V1") { return DRMProperty::SDE_LTM_QUEUE_BUFFER2; } if (name == "SDE_DSPP_LTM_QUEUE_BUF3_V1") { return DRMProperty::SDE_LTM_QUEUE_BUFFER3; } if (name == "SDE_DSPP_LTM_VLUT_V1") { return DRMProperty::SDE_LTM_VLUT; } if (name == "SDE_VIG_1D_LUT_IGC_V6") { return DRMProperty::SDE_VIG_1D_LUT_IGC_V6; } if (name == "SDE_VIG_3D_LUT_GAMUT_V6") { return DRMProperty::SDE_VIG_3D_LUT_GAMUT_V6; } if (name == "frame_trigger_mode") { return DRMProperty::FRAME_TRIGGER; } if (name == "Colorspace") { return DRMProperty::COLORSPACE; } if (name == "supported_colorspaces") { return DRMProperty::SUPPORTED_COLORSPACES; } if (name == "sspp_layout") { return DRMProperty::SDE_SSPP_LAYOUT; } return DRMProperty::INVALID; } #define __CLASS__ "DRMObject" DRMObject::DRMObject(DRMPropertyManager& pm) : property_manager_(pm) {} void DRMObject::AddProperty(DRMProperty prop, uint64_t value, bool force_dirty) { const uint32_t prop_id = property_manager_.GetPropertyId(prop); // bypass check if forced dirty or property is already dirty if (!force_dirty && dirty_values_.find(prop_id) == dirty_values_.end()) { auto it = property_values_.find(prop_id); // skip update if value hasn't changed if (it != property_values_.end() && it->second == value) { return; } } dirty_values_[prop_id] = value; } void DRMObject::RemoveProperty(DRMProperty prop) { const uint32_t prop_id = property_manager_.GetPropertyId(prop); dirty_values_.erase(prop_id); } size_t DRMObject::ApplyDirtyProperties(drmModeAtomicReq *req) { const uint32_t obj_id = GetObjectId(); for (const auto& it : dirty_values_) drmModeAtomicAddProperty(req, obj_id, it.first, it.second); return dirty_values_.size(); } void DRMObject::CommitProperties() { for (const auto& it : dirty_values_) property_values_[it.first] = it.second; DiscardDirtyProperties(); } void DRMObject::ClearProperties() { property_values_.clear(); DiscardDirtyProperties(); } } // namespace sde_drm