/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2022. All rights reserved. * Description: Support hwdisplay hal adaptation interface * Author: Hisilicon * Created: 2022-12-28 */ #include "DisplayImpl.h" #include #include "uapi_pdm.h" #include "uapi_pmoc.h" #include "DisplayLog.h" #define PROPERTY_LEN PROP_VALUE_MAX namespace android { DisplayImpl *DisplayImpl::mDisplayImpl = nullptr; android::Mutex DisplayImpl::mLockInstance; td_s32 DisplayImpl::GetDispmngCount(td_s32 &count) const { td_s32 ret = uapi_svr_dispmng_get_display_count(&count); if (ret != TD_SUCCESS) { LOGE("get display count failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get display count %d", count); return ret; } td_s32 DisplayImpl::GetDispmngDispid(td_s32 index, td_s32 &dispid) const { uapi_svr_dispmng_display_id id = UAPI_SVR_DISPMNG_DISPLAY_ID_0; td_s32 ret = uapi_svr_dispmng_get_display_id((uapi_svr_dispmng_display_index)index, &id); if (ret != TD_SUCCESS) { LOGE("get display id failed, ret=%#x", ret); return TD_FAILURE; } dispid = id; LOGI("get display id:%d", dispid); return ret; } td_s32 DisplayImpl::DispmngAttachDispid(td_s32 dstid, td_s32 srcid) const { td_s32 ret = uapi_svr_dispmng_attach((uapi_svr_dispmng_display_id)dstid, (uapi_svr_dispmng_display_id)srcid); if (ret != TD_SUCCESS) { LOGE("attach display failed, ret=%#x", ret); return TD_FAILURE; } LOGI("attached display src:%d, dst:%d", srcid, dstid); return ret; } td_s32 DisplayImpl::DispmngDetachDispid(td_s32 dstid, td_s32 srcid) const { td_s32 ret = uapi_svr_dispmng_detach((uapi_svr_dispmng_display_id)dstid, (uapi_svr_dispmng_display_id)srcid); if (ret != TD_SUCCESS) { LOGE("detach display failed, ret=%#x", ret); return TD_FAILURE; } LOGI("detached display src:%d, dst:%d", srcid, dstid); return ret; } td_s32 DisplayImpl::SetBrightness(td_s32 dispid, td_u32 brightness) const { td_s32 ret = uapi_svr_dispmng_set_brightness((uapi_svr_dispmng_display_id)dispid, brightness); if (ret != TD_SUCCESS) { LOGE("set brightness failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set brightness dispid:%d, brightness:%d", dispid, brightness); return ret; } td_s32 DisplayImpl::GetBrightness(td_s32 dispid, td_u32 &brightness) const { td_s32 ret = uapi_svr_dispmng_get_brightness((uapi_svr_dispmng_display_id)dispid, &brightness); if (ret != TD_SUCCESS) { LOGE("get brightness failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get brightness dispid:%d, brightness:%d", dispid, brightness); return ret; } td_s32 DisplayImpl::GetContrast(td_s32 dispid, td_u32 &contrast) const { td_s32 ret = uapi_svr_dispmng_get_contrast((uapi_svr_dispmng_display_id)dispid, &contrast); if (ret != TD_SUCCESS) { LOGE("get GetContrast failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get GetContrast dispid:%d, contrast:%d", dispid, contrast); return ret; } td_s32 DisplayImpl::SetContrast(td_s32 dispid, td_u32 contrast) const { td_s32 ret = uapi_svr_dispmng_set_contrast((uapi_svr_dispmng_display_id)dispid, contrast); if (ret != TD_SUCCESS) { LOGE("set contrast failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set contrast dispid:%d, contrast:%d", dispid, contrast); return ret; } td_s32 DisplayImpl::GetHue(td_s32 dispid, td_u32 &hue) const { td_s32 ret = uapi_svr_dispmng_get_hue((uapi_svr_dispmng_display_id)dispid, &hue); if (ret != TD_SUCCESS) { LOGE("get hue failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get hue dispid:%d, hue:%d", dispid, hue); return ret; } td_s32 DisplayImpl::SetHue(td_s32 dispid, td_u32 hue) const { td_s32 ret = uapi_svr_dispmng_set_hue((uapi_svr_dispmng_display_id)dispid, hue); if (ret != TD_SUCCESS) { LOGE("set hue failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set hue dispid:%d, hue:%d", dispid, hue); return ret; } td_s32 DisplayImpl::GetSaturation(td_s32 dispid, td_u32 &saturation) const { td_s32 ret = uapi_svr_dispmng_get_saturation((uapi_svr_dispmng_display_id)dispid, &saturation); if (ret != TD_SUCCESS) { LOGE("get saturation failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get saturation dispid:%d, saturation:%d", dispid, saturation); return ret; } td_s32 DisplayImpl::SetSaturation(td_s32 dispid, td_u32 saturation) const { td_s32 ret = uapi_svr_dispmng_set_saturation((uapi_svr_dispmng_display_id)dispid, saturation); if (ret != TD_SUCCESS) { LOGE("set saturation failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set saturation dispid:%d, saturation:%d", dispid, saturation); return ret; } td_s32 DisplayImpl::GetBacklight(td_s32 dispid, td_u32 &backlight) const { td_s32 ret = uapi_svr_dispmng_get_panel_property((uapi_svr_dispmng_display_id)dispid, UAPI_SVR_DISPMNG_PROPERTY_PANEL_BACKLIGHT_LEVEL, &backlight); if (ret != TD_SUCCESS) { LOGE("get backlight failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get backlight dispid:%d, backlight:%d", dispid, backlight); return ret; } td_s32 DisplayImpl::SetBacklight(td_s32 dispid, td_u32 backlight) const { if (backlight > UI_MAX) { return TD_FAILURE; } td_s32 ret = uapi_svr_dispmng_set_panel_property((uapi_svr_dispmng_display_id)dispid, UAPI_SVR_DISPMNG_PROPERTY_PANEL_BACKLIGHT_LEVEL, &backlight); if (ret != TD_SUCCESS) { LOGE("set backlight failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set backlight dispid:%d, backlight:%d", dispid, backlight); return ret; } static td_s32 GetScreenOrientation(td_s32 id) { char buffer[PROPERTY_LEN] = {0}; uapi_svr_dispmng_display_id masterId = UAPI_SVR_DISPMNG_DISPLAY_ID_0; uapi_svr_dispmng_get_display_id(UAPI_SVR_DISPMNG_DISPLAY_INDEX_0, &masterId); if (id == (int)masterId) { property_get("persist.vendor.prop.screenorientation", buffer, "landscape"); } else { property_get("persist.vendor.prop.screenorientation.ext", buffer, "landscape"); } if (strncmp("upsideDown", buffer, strlen("upsideDown")) == 0) { return UAPI_VIDEO_ROTATION_270; } else if (strncmp("seascape", buffer, strlen("seascape")) == 0) { return UAPI_VIDEO_ROTATION_180; } else if (strncmp("portrait", buffer, strlen("portrait")) == 0) { return UAPI_VIDEO_ROTATION_90; } else { return UAPI_VIDEO_ROTATION_0; } } td_s32 DisplayImpl::GetScreenOffset(td_s32 dispid, CROP_RECT_S& offset) const { uapi_svr_dispmng_screen_offset tempoffset = {}; td_s32 ret = uapi_svr_dispmng_get_screen_offset((uapi_svr_dispmng_display_id)dispid, &tempoffset); if (ret == TD_SUCCESS) { td_s32 rotation = GetScreenOrientation((uapi_svr_dispmng_display_id)dispid); if (rotation == UAPI_VIDEO_ROTATION_0) { // landscape offset.u32LeftOffset = tempoffset.left; offset.u32TopOffset = tempoffset.top; offset.u32RightOffset = tempoffset.right; offset.u32BottomOffset = tempoffset.bottom; } else if (rotation == UAPI_VIDEO_ROTATION_90) { // portrait offset.u32LeftOffset = tempoffset.top; offset.u32TopOffset = tempoffset.right; offset.u32RightOffset = tempoffset.bottom; offset.u32BottomOffset = tempoffset.left; } else if (rotation == UAPI_VIDEO_ROTATION_180) { // seascape offset.u32LeftOffset = tempoffset.right; offset.u32TopOffset = tempoffset.bottom; offset.u32RightOffset = tempoffset.left; offset.u32BottomOffset = tempoffset.top; } else if (rotation == UAPI_VIDEO_ROTATION_270) { // upsideDown offset.u32LeftOffset = tempoffset.bottom; offset.u32TopOffset = tempoffset.left; offset.u32RightOffset = tempoffset.top; offset.u32BottomOffset = tempoffset.right; } } else { LOGI("get screen offset failed, ret:%#x", ret); } return ret; } td_s32 DisplayImpl::SetScreenOffset(td_s32 dispid, CROP_RECT_S offset) const { uapi_svr_dispmng_screen_offset tempoffset = {}; td_s32 rotation = GetScreenOrientation(dispid); if (rotation == UAPI_VIDEO_ROTATION_0) { // landscape tempoffset.left = offset.u32LeftOffset; tempoffset.top = offset.u32TopOffset; tempoffset.right = offset.u32RightOffset; tempoffset.bottom = offset.u32BottomOffset; } else if (rotation == UAPI_VIDEO_ROTATION_90) { // portrait tempoffset.left = offset.u32BottomOffset; tempoffset.top = offset.u32LeftOffset; tempoffset.right = offset.u32TopOffset; tempoffset.bottom = offset.u32RightOffset; } else if (rotation == UAPI_VIDEO_ROTATION_180) { // seascape tempoffset.left = offset.u32RightOffset; tempoffset.top = offset.u32BottomOffset; tempoffset.right = offset.u32LeftOffset; tempoffset.bottom = offset.u32TopOffset; } else if (rotation == UAPI_VIDEO_ROTATION_270) { // upsideDown tempoffset.left = offset.u32TopOffset; tempoffset.top = offset.u32RightOffset; tempoffset.right = offset.u32BottomOffset; tempoffset.bottom = offset.u32LeftOffset; } td_s32 ret = uapi_svr_dispmng_set_screen_offset((uapi_svr_dispmng_display_id)dispid, &tempoffset); if (ret != TD_SUCCESS) { LOGI("set screen offset failed, ret:%#x", ret); } return ret; } static int SetProp(std::string key, int saveValue) { char value[PROPERTY_LEN] = {0}; int ret = sprintf_s(value, sizeof(value), "%d", saveValue); if (ret < 0) { LOGE("sprintf_s Err--- %d", ret); return TD_FAILURE; } ret = property_set(key.data(), value); return ret; } td_s32 DisplayImpl::SetEnableHdcp(td_s32 dispid, DispHdcpMode mode) const { td_s32 ret = uapi_svr_dispmng_hdcp_enable((uapi_svr_dispmng_display_id)dispid, (uapi_svr_dispmng_hdcp_mode)mode); if (ret != TD_SUCCESS) { LOGE("set hdcp enable failed, ret=%#x", ret); return TD_FAILURE; } std::string props = ""; if (dispid == UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER) { props = "persist.vendor.display.hdcp.master"; } else if (dispid == UAPI_SVR_DISPMNG_DISPLAY_ID_SLAVE) { props = "persist.vendor.display.hdcp.slave"; } else { LOGW("persist hdcp enable failed, get UnExpected dispid, dispid:%d, mode:%d", dispid, mode); return ret; } SetProp(props, (int)mode); LOGI("set hdcp enable, dispid:%d, mode:%d", dispid, mode); return ret; } td_s32 DisplayImpl::SetDisableHdcp(td_s32 dispid) const { td_s32 ret = uapi_svr_dispmng_hdcp_disable((uapi_svr_dispmng_display_id)dispid); if (ret != TD_SUCCESS) { LOGE("set hdcp disable failed, ret=%#x", ret); return TD_FAILURE; } std::string props = ""; if (dispid == UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER) { props = "persist.vendor.display.hdcp.master"; } else if (dispid == UAPI_SVR_DISPMNG_DISPLAY_ID_SLAVE) { props = "persist.vendor.display.hdcp.slave"; } else { LOGW("persist hdcp enable failed, get UnExpected dispid, dispid:%d, mode:%d", dispid, mode); return ret; } SetProp(props, -1); LOGI("set hdcp disable, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetHdcpCapability(td_s32 dispid, DispHdcpCapability &cap) const { uapi_svr_dispmng_hdcp_capability hdcpCap = {}; td_s32 ret = uapi_svr_dispmng_hdcp_get_capability((uapi_svr_dispmng_display_id)dispid, &hdcpCap); if (ret != TD_SUCCESS) { LOGE("get hdcp capability failed, ret=%#x", ret); return TD_FAILURE; } cap.support14 = hdcpCap.support14; cap.support2x = hdcpCap.support2x; LOGI("get hdcp support, hdcp1.4:%d, hdcp2.x:%d", hdcpCap.support14, hdcpCap.support2x); return ret; } td_s32 DisplayImpl::GetHdcpStatus(td_s32 dispid, DispHdcpStatus &status) const { uapi_svr_dispmng_hdcp_status hdcpStatus = {}; td_s32 ret = uapi_svr_dispmng_hdcp_get_status((uapi_svr_dispmng_display_id)dispid, &hdcpStatus); if (ret != TD_SUCCESS) { LOGE("get hdcp status failed, ret=%#x", ret); return TD_FAILURE; } status.authStart = hdcpStatus.auth_start; status.authSuccess = hdcpStatus.auth_success; status.reauthTimes = hdcpStatus.reauth_times; status.mode = hdcpStatus.mode; status.errCode = hdcpStatus.err_code; LOGI("get hdcp status, authStart:%d, authSuccess:%d, reauthTimes:%d, mode:%d, errCode:%d", status.authStart, status.authSuccess, status.reauthTimes, status.mode, status.errCode); return ret; } td_s32 DisplayImpl::GetHdrType(td_s32 dispid, td_s32 &hdrType) const { uapi_svr_dispmng_hdr_type hdr = UAPI_SVR_DISPMNG_HDR_TYPE_MAX; td_s32 ret = uapi_svr_dispmng_get_hdr_type((uapi_svr_dispmng_display_id)dispid, &hdr); if (ret != TD_SUCCESS) { LOGE("get hdr type failed, ret=%#x", ret); return TD_FAILURE; } hdrType = hdr; LOGI("get hdr type, dispid:%d, hdrType:%d", dispid, hdr); return ret; } td_s32 DisplayImpl::SetHdrType(td_s32 dispid, td_s32 hdrType) const { td_s32 ret = uapi_svr_dispmng_set_hdr_type((uapi_svr_dispmng_display_id)dispid, (uapi_svr_dispmng_hdr_type)hdrType); if (ret != TD_SUCCESS) { LOGE("set hdr type failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set hdr type, dispid:%d, hdrType:%d", dispid, hdrType); return ret; } td_s32 DisplayImpl::GetVirtualScreenhw(td_s32 dispid, td_u32 &width, td_u32 &height) const { td_s32 ret = uapi_svr_dispmng_get_virtual_screen((uapi_svr_dispmng_display_id)dispid, &width, &height); if (ret != TD_SUCCESS) { LOGE("get vir screen failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get vir screen, width:%d, height:%d", width, height); return ret; } td_s32 DisplayImpl::SetVirtualScreenhw(td_s32 dispid, td_u32 width, td_u32 height) const { uapi_pdm_disp_param param = {}; td_s32 ret = uapi_pdm_get_disp_param((uapi_disp)dispid, ¶m); if (ret != TD_SUCCESS) { LOGE("get pdm disp param failed, ret=%#x", ret); ret = TD_FAILURE; } param.virt_screen_width = width; param.virt_screen_height = height; ret = uapi_pdm_update_disp_param((uapi_disp)dispid, ¶m); if (ret != TD_SUCCESS) { LOGE("update pdm disp param failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set vir screen, width:%d, height:%d", width, height); return ret; } td_s32 DisplayImpl::GetQmsEnable(td_s32 dispid, td_bool& enable) const { td_s32 ret = uapi_svr_dispmng_get_qms_enable((uapi_svr_dispmng_display_id)dispid, &enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x dispid=%d enable=%d\n", __func__, __LINE__, ret, dispid, enable); ret = TD_FAILURE; } return ret; } td_s32 DisplayImpl::SetQmsEnable(td_s32 dispid, td_bool enable) const { td_s32 ret = uapi_svr_dispmng_set_qms_enable((uapi_svr_dispmng_display_id)dispid, enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x dispid=%d enable=%d\n", __func__, __LINE__, ret, dispid, enable); ret = TD_FAILURE; } return ret; } td_s32 DisplayImpl::GetQmsAttr(td_s32 dispid, td_u32& qmsRate) const { uapi_svr_disp_qms_attr attr = {}; td_s32 ret = uapi_svr_dispmng_get_qms_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { ALOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); ret = TD_FAILURE; } else { qmsRate = attr.dst_rate; } return TD_SUCCESS; } td_s32 DisplayImpl::SetQmsAttr(td_s32 dispid, td_u32 qmsRate) const { uapi_svr_disp_qms_attr attr = {qmsRate}; td_s32 ret = uapi_svr_dispmng_set_qms_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); ret = TD_FAILURE; } return ret; } td_s32 DisplayImpl::GetVrrEnable(td_s32 dispid, td_bool &enable) const { td_s32 ret = uapi_svr_dispmng_get_vrr_enable((uapi_svr_dispmng_display_id)dispid, &enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x dispid=%d enable=%d\n", __func__, __LINE__, ret, dispid, *enable); ret = TD_FAILURE; } return ret; } td_s32 DisplayImpl::SetVrrEnable(td_s32 dispid, td_bool enable) const { LOGI("set vrr enable, dispid:%d, enable:%d", dispid, enable); td_s32 ret = uapi_svr_dispmng_set_vrr_enable((uapi_svr_dispmng_display_id)dispid, enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x dispid=%d enable=%d\n", __func__, __LINE__, ret, dispid, enable); ret = TD_FAILURE; } return ret; } td_s32 DisplayImpl::GetAllmAttr(td_s32 dispid, td_u32 &allmMode) const { uapi_svr_disp_allm_attr attr = {}; td_s32 ret = uapi_svr_dispmng_get_allm_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { ALOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); return TD_FAILURE; } allmMode = attr.mode; return TD_SUCCESS; } td_s32 DisplayImpl::SetAllmAttr(td_s32 dispid, td_u32 allmMode) const { LOGI("set allm attr, dispid:%d, mode:%d", dispid, allmMode); uapi_svr_disp_allm_attr attr = { (uapi_svr_disp_allm_mode)allmMode }; td_s32 ret = uapi_svr_dispmng_set_allm_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); return TD_FAILURE; } return TD_SUCCESS; } td_s32 DisplayImpl::GetOutputStatus(td_s32 dispid, DispOutputStatus &status) const { uapi_svr_disp_output_status data = {}; td_s32 ret = uapi_svr_dispmng_get_output_status((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { ALOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); return TD_FAILURE; } status.actualOutHdrType = data.actual_out_hdr_type; status.actualOutColorpace = data.actual_out_colorpace; status.refreshRate = data.refresh_rate; return TD_SUCCESS; } td_s32 DisplayImpl::GetDisplayStatus(td_s32 dispid, DisplayStatus &status) const { uapi_svr_dispmng_display_status data = {}; td_s32 ret = uapi_svr_dispmng_get_display_status((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display status failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&status, sizeof(DisplayStatus), &data, sizeof(uapi_svr_dispmng_display_status)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display status, dispid:%d, number:%d", dispid, data.number); return ret; } td_s32 DisplayImpl::GetDisplayInfo(td_s32 dispid, DispSinkInfo &info) const { uapi_svr_dispmng_sink_info data = {}; td_s32 ret = uapi_svr_dispmng_get_sink_info((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display info failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&info, sizeof(DispSinkInfo), &data, sizeof(uapi_svr_dispmng_sink_info)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display info, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetDisplayCapabilities(td_s32 dispid, DisplayCapability &cap) const { uapi_svr_dispmng_display_capability data = {}; td_s32 ret = uapi_svr_dispmng_get_display_capabilities((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display capability failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&cap, sizeof(DisplayCapability), &data, sizeof(uapi_svr_dispmng_display_capability)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display capability, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetDisplaySupportedModeList(td_s32 dispid, DisplayAvailableMode &mode) const { uapi_svr_dispmng_display_available_mode data = {}; td_s32 ret = uapi_svr_dispmng_get_supported_mode_list((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display sup mode list failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&mode, sizeof(DisplayAvailableMode), &data, sizeof(uapi_svr_dispmng_display_available_mode)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display sup mode list, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetDisplayAllModeList(td_s32 dispid, DisplayAvailableMode &mode) const { uapi_svr_dispmng_display_available_mode data = {}; td_s32 ret = uapi_svr_dispmng_get_all_mode_list((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display all mode list failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&mode, sizeof(DisplayAvailableMode), &data, sizeof(uapi_svr_dispmng_display_available_mode)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display all mode list, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetDisplayMode(td_s32 dispid, DisplayMode &mode) const { uapi_svr_dispmng_display_mode data = {}; td_s32 ret = uapi_svr_dispmng_get_display_mode((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("get display mode failed, ret=%#x", ret); return TD_FAILURE; } errno_t rc = memcpy_s(&mode, sizeof(DisplayMode), &data, sizeof(uapi_svr_dispmng_display_mode)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } LOGI("get display mode , dispid:%d", dispid); return ret; } td_s32 DisplayImpl::SetDisplayMode(td_s32 dispid, DisplayMode mode) const { uapi_svr_dispmng_display_mode data = {}; errno_t rc = memcpy_s(&data, sizeof(uapi_svr_dispmng_display_mode), &mode, sizeof(DisplayMode)); if (rc != EOK) { LOGE("memcpy_s_func failed rc = %d", rc); return TD_FAILURE; } td_s32 ret = uapi_svr_dispmng_set_display_mode((uapi_svr_dispmng_display_id)dispid, &data); if (ret != TD_SUCCESS) { LOGE("set display mode failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set display mode , dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetSceneMode(td_s32 dispid, td_s32 &sceneMode) const { uapi_svr_dispmng_scenario_mode mode = UAPI_SVR_DISPMNG_SCENARIO_MAX; td_s32 ret = uapi_svr_dispmng_get_scenario((uapi_svr_dispmng_display_id)dispid, &mode); if (ret != TD_SUCCESS) { LOGE("get scene mode failed, ret=%#x", ret); return TD_FAILURE; } sceneMode = mode; LOGI("get scene mode, dispid:%d, mode:%d", dispid, sceneMode); return ret; } td_s32 DisplayImpl::SetSceneMode(td_s32 dispid, td_s32 mode) const { td_s32 ret = uapi_svr_dispmng_set_scenario((uapi_svr_dispmng_display_id)dispid, (uapi_svr_dispmng_scenario_mode)mode); if (ret != TD_SUCCESS) { LOGE("set scene mode failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set scene mode, dispid:%d, mode:%d", dispid, mode); return ret; } td_s32 DisplayImpl::GetAspectRatio(td_s32 dispid, VideoAspectInfo &aspectInfo) const { uapi_video_aspect_info ratio = {}; td_s32 ret = uapi_svr_dispmng_get_device_aspect_ratio((uapi_svr_dispmng_display_id)dispid, &ratio); if (ret != TD_SUCCESS) { LOGE("get aspect ratio failed, ret=%#x", ret); return TD_FAILURE; } aspectInfo.ratio = ratio.ratio; aspectInfo.width = ratio.width; aspectInfo.height = ratio.height; LOGI("get aspect ratio, dispid:%d, ratio:%d, width, height", dispid, aspectInfo.ratio, aspectInfo.width, aspectInfo.width); return ret; } td_s32 DisplayImpl::SetAspectRatio(td_s32 dispid, VideoAspectInfo aspectInfo) const { uapi_video_aspect_info ratio = {}; ratio.ratio = (uapi_video_aspect_ratio)aspectInfo.ratio; ratio.width = aspectInfo.width; ratio.height = aspectInfo.height; td_s32 ret = uapi_svr_dispmng_set_device_aspect_ratio((uapi_svr_dispmng_display_id)dispid, &ratio); if (ret != TD_SUCCESS) { LOGE("set aspect ratio failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set aspect ratio, dispid:%d, ratio:%d, width, height", dispid, aspectInfo.ratio, aspectInfo.width, aspectInfo.width); return ret; } td_s32 DisplayImpl::GetHdrMatchContent(td_s32 dispid, td_bool &match) const { td_s32 ret = uapi_svr_dispmng_get_hdr_match_content((uapi_svr_dispmng_display_id)dispid, &match); if (ret != TD_SUCCESS) { LOGE("get hdr match failed, ret=%#x", ret); return TD_FAILURE; } LOGI("get hdr match, dispid:%d, match:%d", dispid, match); return ret; } td_s32 DisplayImpl::SetHdrMatchContent(td_s32 dispid, td_bool match) const { td_s32 ret = uapi_svr_dispmng_set_hdr_match_content((uapi_svr_dispmng_display_id)dispid, match); if (ret != TD_SUCCESS) { LOGE("set hdr match failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set hdr match, dispid:%d, match:%d", dispid, match); return ret; } td_s32 DisplayImpl::LoadHDCPKey(td_s32 dispid, DispHdcpKey key) const { uapi_svr_dispmng_hdcp_key hdcpKey = {}; hdcpKey.key_version = (uapi_svr_dispmng_hdcp_key_version)key.keyVersion; hdcpKey.data = key.data; hdcpKey.length = key.length; td_s32 ret = uapi_svr_dispmng_hdcp_load_key((uapi_svr_dispmng_display_id)dispid, &hdcpKey); if (ret != TD_SUCCESS) { LOGE("load hdcp key failed, ret=%#x", ret); return TD_FAILURE; } LOGI("load hdcp key, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::LoadHDCPSrm(td_s32 dispid, DispHdcpSrm srm) const { uapi_svr_dispmng_hdcp_srm hdcpSrm = {}; hdcpSrm.data = srm.data; hdcpSrm.length = srm.length; td_s32 ret = uapi_svr_dispmng_hdcp_set_srm((uapi_svr_dispmng_display_id)dispid, &hdcpSrm); if (ret != TD_SUCCESS) { LOGE("load hdcp srm failed, ret=%#x", ret); return TD_FAILURE; } LOGI("load hdcp srm, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::GetHdmiConfigInfo(td_s32 hdmitx, HdmiConfigInfo &info) const { uapi_pdm_config_info cfgInfo = {}; if (hdmitx >= 2 || hdmitx < 0) { /* max hdmi tx id is 2 */ LOGE("get hdmi cfg invalid param"); return TD_FAILURE; } td_s32 ret = uapi_pdm_get_cfg_info(&cfgInfo); if (ret != TD_SUCCESS) { LOGE("get pdm cfg info failed, ret=%#x", ret); return TD_FAILURE; } info.hdcpEnable = cfgInfo.hdmi_cfg_info[hdmitx].hdcp_enable; info.hdcpMode = cfgInfo.hdmi_cfg_info[hdmitx].hdcp_mode; info.cecEnable = cfgInfo.hdmi_cfg_info[hdmitx].cec_enable; info.cecMode = cfgInfo.hdmi_cfg_info[hdmitx].cec_mode; LOGI("get hdmi cfg info, hdmitx:%d, hdcpEnable:%d, hdcpMode:%d, cecEnable:%d, cecMode:%d", hdmitx, info.hdcpEnable, info.hdcpMode, info.cecEnable, info.cecMode); return ret; } td_s32 DisplayImpl::SetHdmiConfigInfo(td_s32 hdmitx, HdmiConfigInfo info) const { uapi_pdm_config_info cfgInfo = {}; if (hdmitx >= 2 || hdmitx < 0) { /* max hdmi tx id is 2 */ LOGE("set hdmi cfg invalid param"); return TD_FAILURE; } td_s32 ret = uapi_pdm_get_cfg_info(&cfgInfo); if (ret != TD_SUCCESS) { LOGE("get pdm cfg info failed, ret=%#x", ret); return TD_FAILURE; } cfgInfo.hdmi_cfg_info[hdmitx].hdcp_enable = info.hdcpEnable; cfgInfo.hdmi_cfg_info[hdmitx].hdcp_mode = info.hdcpMode; cfgInfo.hdmi_cfg_info[hdmitx].cec_enable = info.cecEnable; cfgInfo.hdmi_cfg_info[hdmitx].cec_mode = (uapi_cec_device_type)info.cecMode; ret = uapi_pdm_update_cfg_info(&cfgInfo); if (ret != TD_SUCCESS) { LOGE("update pdm cfg info failed, ret=%#x", ret); return TD_FAILURE; } LOGI("set hdmi cfg info, hdmitx:%d, hdcpEnable:%d, hdcpMode:%d, cecEnable:%d, cecMode:%d", hdmitx, info.hdcpEnable, info.hdcpMode, info.cecEnable, info.cecMode); return ret; } td_s32 DisplayImpl::GetHdmitxidByDispid(td_s32 dispid, td_u32 &hdmitx) const { uapi_svr_dispmng_interface_group intf = {}; hdmitx = UAPI_SVR_DISPMNG_HDMITX_ID_MAX; td_s32 ret = uapi_svr_dispmng_get_attached_interface((uapi_svr_dispmng_display_id)dispid, &intf); if (ret != TD_SUCCESS) { LOGE("get attach intf failed, ret=%#x", ret); return ret; } for (int i = 0; i < (td_s32)intf.number; i++) { if (intf.intf[i].intf_type == UAPI_SVR_DISPMNG_INTERFACE_HDMITX) { hdmitx = intf.intf[i].intf.hdmitx_id; } } LOGI("get hdmitx id, dispid:%d, txid:%d", dispid, hdmitx); return ret; } td_s32 DisplayImpl::GetDisplayConfig(td_s32 dispid, DisplayConfig &info) const { uapi_svr_dispmng_display_config cfgInfo = {}; td_s32 ret = uapi_svr_dispmng_get_display_config((uapi_svr_dispmng_display_id)dispid, &cfgInfo); if (ret != TD_SUCCESS) { LOGE("get disp cfg info failed, ret=%#x", ret); return TD_FAILURE; } info.index = cfgInfo.index; info.enable = cfgInfo.enable; info.attach = cfgInfo.attach; info.srcDisp = cfgInfo.src_disp; info.rType = cfgInfo.r_type; info.rAngle = cfgInfo.r_angle; info.hFlip = cfgInfo.h_flip; info.vFlip = cfgInfo.v_flip; info.touchId = cfgInfo.touch_id; info.panelIndex = cfgInfo.panel_index; LOGI("get disp cfg info, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::SetDisplayConfig(td_s32 dispid, DisplayConfig info) const { uapi_svr_dispmng_display_config cfgInfo = {}; cfgInfo.index = (uapi_svr_dispmng_display_index)info.index; cfgInfo.enable = info.enable; cfgInfo.attach = info.attach; cfgInfo.src_disp = (uapi_svr_dispmng_display_id)info.srcDisp; cfgInfo.r_type = (uapi_svr_dispmng_rotation_type)info.rType; cfgInfo.r_angle = (uapi_video_rotation)info.rAngle; cfgInfo.h_flip = info.hFlip; cfgInfo.v_flip = info.vFlip; cfgInfo.touch_id = (uapi_svr_dispmng_touchpad_id)info.touchId; cfgInfo.panel_index = info.panelIndex; td_s32 ret = uapi_svr_dispmng_set_display_config((uapi_svr_dispmng_display_id)dispid, &cfgInfo); if (ret != TD_SUCCESS) { LOGE("update pdm cfg info failed, ret=%#x", ret); return TD_FAILURE; } if (cfgInfo.index == UAPI_SVR_DISPMNG_DISPLAY_INDEX_0) { char disp[PROPERTY_LEN] = {0}; td_s32 spRet = sprintf_s(disp, sizeof(disp), "%d", dispid); if (spRet < 0) { LOGE("sprintf_s Err--- %d", spRet); return TD_FAILURE; } property_set("persist.vendor.display.master", disp); } LOGI("set disp cfg info, dispid:%d", dispid); return ret; } td_s32 DisplayImpl::SetHdmiConfig() const { LOGI("%s (%d)", __func__, __LINE__); HdmiConfigInfo info = {}; int count = 0; int id = -1; td_s32 ret = GetDispmngCount(count); if (ret != TD_SUCCESS) { LOGE("get_dispmng_count failure, ret = %#x\n", ret); return ret; } LOGI("hdmi_config_set %d\n", count); for (int i = 0; i < count && i < UAPI_SVR_DISPMNG_DISPLAY_INDEX_MAX; i++) { ret = GetDispmngDispid(i, id); td_u32 hdmitxId; GetHdmitxidByDispid(id, hdmitxId); ret = GetHdmiConfigInfo((uapi_hdmitx_id)hdmitxId, info); if (ret == TD_SUCCESS) { if (info.hdcpEnable != 0xFFFFFFFF && info.hdcpEnable != 0) { ret = SetEnableHdcp(id, (DispHdcpMode)info.hdcpMode); LOGI("set_enable_hdcp id=%d ret %d\n", id, ret); } } } return ret; } td_s32 DisplayImpl::GetVrrAttr(td_s32 dispid, DISPLAY_RANGE_S &range) const { uapi_svr_disp_vrr_attr attr = {}; td_s32 ret = uapi_svr_dispmng_get_vrr_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); return TD_FAILURE; } range.min = attr.vrr_min; range.max = attr.vrr_max; LOGI("get vrr attr, dispid:%d, min:%d, max:%d", dispid, attr.vrrMin, attr.vrr_max); return TD_SUCCESS; } td_s32 DisplayImpl::SetVrrAttr(td_s32 dispid, DISPLAY_RANGE_S range) const { LOGI("set vrr attr, dispid:%d, min:%d, max:%d", dispid, range.min, range.max); uapi_svr_disp_vrr_attr attr = {range.min, range.max}; td_s32 ret = uapi_svr_dispmng_set_vrr_attr((uapi_svr_dispmng_display_id)dispid, &attr); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); return TD_FAILURE; } return TD_SUCCESS; } td_s32 DisplayImpl::SetPQBypass(td_s32 enable) const { (void)enable; // Unused return TD_SUCCESS; } td_s32 DisplayImpl::GetPQBypass(td_u32 &enable) const { (void)enable; // Unused return TD_SUCCESS; } td_s32 DisplayImpl::SetAspectCvrs(int cvrs) const { return SetProp("persist.prop.video.cvrs", cvrs); } td_s32 DisplayImpl::GetAspectCvrs() const { char buffer[PROPERTY_LEN] = {0}; property_get("persist.prop.video.cvrs", buffer, "0"); int value = strtol(buffer, nullptr, 10); return value; } static int SetInterfaceEnable(int dispid, uapi_svr_dispmng_interface_enable *intfEnable) { td_s32 ret = uapi_svr_dispmng_set_intf_enable((uapi_svr_dispmng_display_id)dispid, intfEnable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); ret = TD_FAILURE; } return ret; } static int GetInterfaceEnable(int dispid, uapi_svr_dispmng_interface_enable *intfEnable) { td_s32 ret = uapi_svr_dispmng_get_intf_enable((uapi_svr_dispmng_display_id)dispid, intfEnable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x \n", __func__, __LINE__, ret); ret = TD_FAILURE; } return ret; } // enable: 0->disabled (close this port), 1->enabled (open this port) const td_s32 DisplayImpl::SetOutputEnable(int dispid, int port, td_bool enable) const { uapi_svr_dispmng_interface_enable intfEnable = {}; td_s32 ret = GetInterfaceEnable(dispid, &intfEnable); if (ret == TD_SUCCESS) { for (int i = 0; i < (int)intfEnable.number; i++) { if ((int)intfEnable.intf[i].intf_type == port) { intfEnable.enable[i] = enable; } } ret = SetInterfaceEnable(dispid, &intfEnable); } return ret; } // port: 0->HDMI, 0x0a->CVBS, 0x16->PANEL // Return: 0->disabled, 1->enabled td_s32 DisplayImpl::GetOutputEnable(int dispid, int port) const { uapi_svr_dispmng_interface_enable intfEnable = {}; td_s32 ret = GetInterfaceEnable(dispid, &intfEnable); if (ret == TD_SUCCESS) { for (int i = 0; i < (int)intfEnable.number; i++) { if ((int)intfEnable.intf[i].intf_type == port) { ret = intfEnable.enable[i]; break; } } } return ret; } td_s32 DisplayImpl::SetHdmiStart(td_s32 dispid) const { return SetOutputEnable(dispid, UAPI_SVR_DISPMNG_INTERFACE_HDMITX, TD_TRUE); } td_s32 DisplayImpl::SetHdmiStop(td_s32 dispid) const { return SetOutputEnable(dispid, UAPI_SVR_DISPMNG_INTERFACE_HDMITX, TD_FALSE); } td_s32 DisplayImpl::SetEnable3D(td_s32 dispid, td_bool enable) const { td_s32 ret = uapi_svr_dispmng_enable_3d((uapi_svr_dispmng_display_id)dispid, enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x\n", __func__, __LINE__, ret); return TD_FAILURE; } return TD_SUCCESS; } td_s32 DisplayImpl::GetEnable3D(td_s32 dispid, td_bool &enable) const { td_s32 ret = uapi_svr_dispmng_get_3d_enable((uapi_svr_dispmng_display_id)dispid, &enable); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x\n", __func__, __LINE__, ret); return TD_FAILURE; } return TD_SUCCESS; } static int SetIntfStatus(int dispid, td_bool enable) { uapi_svr_dispmng_interface_group attach = {}; td_s32 s32Ret = uapi_svr_dispmng_get_attached_interface((uapi_svr_dispmng_display_id)dispid, &attach); if (s32Ret != TD_SUCCESS) { ALOGE("uapi_svr_dispmng_get_attached_interface Err ret= 0x%x", s32Ret); return -1; } if (attach.number == 0) { ALOGE("attach.number Err--- %d", attach.number); return -1; } uapi_svr_dispmng_interface_enable intfEnable = {}; intfEnable.number = attach.number; for (int i = 0; i < (int)intfEnable.number; i++) { intfEnable.intf[i] = attach.intf[i]; intfEnable.enable[i] = enable; } s32Ret = uapi_svr_dispmng_set_intf_enable((uapi_svr_dispmng_display_id)dispid, &intfEnable); if (s32Ret != TD_SUCCESS) { ALOGE("uapi_svr_dispmng_set_intf_enable Err--- %d", s32Ret); return -1; } return s32Ret; } td_s32 DisplayImpl::AttachIntf(int dispid) const { td_bool enable = TD_TRUE; td_s32 s32Ret = SetIntfStatus(dispid, enable); return s32Ret; } td_s32 DisplayImpl::DetachIntf(int dispid) const { td_bool enable = TD_FALSE; td_s32 s32Ret = SetIntfStatus(dispid, enable); return s32Ret; } td_s32 DisplayImpl::GetDisplayWindowNumber(int dispid, uapi_win_handle_info *handleInfo) const { td_s32 ret = uapi_win_init(); if (ret != TD_SUCCESS) { LOGE("ERR :%s LINE %d | uapi_win_init Failed ret(%x)", __FUNCTION__, __LINE__, ret); ret = TD_FAILURE; } ret = uapi_win_get_handle_info((uapi_disp)dispid, handleInfo); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x dispid=%d \n", __func__, __LINE__, ret, dispid); ret = TD_FAILURE; } uapi_win_deinit(); return ret; } td_s32 DisplayImpl::GetFmtFromVic(int vic) const { td_u32 fmt = 0; td_s32 ret = uapi_svr_dispmng_get_format_from_vic(vic, &fmt); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x\n", __func__, __LINE__, ret); return TD_FAILURE; } return fmt; } td_s32 DisplayImpl::GetVicFromFmt(int fmt) const { td_u32 vic = 0; td_s32 ret = uapi_svr_dispmng_get_vic_from_format(fmt, &vic); if (ret != TD_SUCCESS) { LOGE("%s (%d) end return 0x%x\n", __func__, __LINE__, ret); return TD_FAILURE; } return vic; } td_s32 DisplayImpl::GetDisplayLuminance(int dispid, uapi_svr_dispmng_display_luminance& luminance) const { int ret = uapi_svr_dispmng_get_display_luminance((uapi_svr_dispmng_display_id)dispid, &luminance); if (ret != TD_SUCCESS) { LOGE("%s (%d) dispid=%d ret=0x%x\n", __func__, __LINE__, dispid, ret); return TD_FAILURE; } return ret; } td_s32 DisplayImpl::SetDisplayLuminance(int dispid, uapi_svr_dispmng_display_luminance& luminance) const { int ret = uapi_svr_dispmng_set_display_luminance((uapi_svr_dispmng_display_id)dispid, &luminance); if (ret != TD_SUCCESS) { LOGE("%s (%d) dispid=%d ret=0x%x\n", __func__, __LINE__, dispid, ret); return TD_FAILURE; } SetProp("persist.vendor.display.luminance", luminance.max_luminance); return ret; } static td_s32 SetDisplayRotation(int dispid) { uapi_svr_dispmng_display_config cfg = {}; int ret = uapi_svr_dispmng_get_display_config((uapi_svr_dispmng_display_id)dispid, &cfg); if (ret != TD_SUCCESS) { ALOGE("%s (%d) dispid=%d ret=0x%x\n", __func__, __LINE__, dispid, ret); return TD_FAILURE; } ALOGI("index %d enable %d attach %d srcDisp %d rType %d " "r_angle %d hFlip %d vFlip %d touchId %d panelIndex %d\n", cfg.index, cfg.enable, cfg.attach, cfg.src_disp, cfg.r_type, cfg.r_angle, cfg.h_flip, cfg.v_flip, cfg.touch_id, cfg.panel_index); const char *rotation[] = {"landscape", "portrait", "seascape", "upsideDown"}; char disp[PROPERTY_LEN] = {}; ret = sprintf_s(disp, sizeof(disp), "%d", dispid); if (ret < 0) { ALOGE("sprintf_s Err--- %d", ret); return TD_FAILURE; } if (cfg.r_type == UAPI_SVR_DISPMNG_ROTATION_SOFTWARE) { if (cfg.r_angle >= UAPI_VIDEO_ROTATION_0 && cfg.r_angle < UAPI_VIDEO_ROTATION_MAX) { if (cfg.index == UAPI_SVR_DISPMNG_DISPLAY_INDEX_0) { ret = property_set("persist.vendor.prop.screenorientation", rotation[cfg.r_angle]); property_set("persist.vendor.display.master", disp); } else { ret = property_set("persist.vendor.prop.screenorientation.ext", rotation[cfg.r_angle]); } } else { ALOGE("Unsupported rotation angle\n"); return TD_FAILURE; } } else { if (cfg.index == UAPI_SVR_DISPMNG_DISPLAY_INDEX_0) { property_set("persist.vendor.prop.screenorientation", "landscape"); property_set("persist.vendor.display.master", disp); } else { property_set("persist.vendor.prop.screenorientation.ext", "landscape"); } } return TD_SUCCESS; } td_s32 DisplayImpl::SetDisplayCount() const { LOGI("%s (%d)", __func__, __LINE__); int count = -1; int id = -1; td_s32 ret = GetDispmngCount(count); if (ret == TD_SUCCESS) { SetProp("vendor.display.count", count); for (int i = 0; i < count && i < UAPI_SVR_DISPMNG_DISPLAY_INDEX_MAX; i++) { ret = GetDispmngDispid(i, id); if (ret == TD_SUCCESS) { SetDisplayRotation(id); } } } // reset hdcp with Previous Settings int hdcpStatus = property_get_int32("persist.vendor.display.hdcp.master", -1); if (hdcpStatus == -1) { SetDisableHdcp(UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER); } else { SetEnableHdcp(UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER, (DispHdcpMode)hdcpStatus); } if (count > 1) { hdcpStatus = property_get_int32("persist.vendor.display.hdcp.slave", -1); if (hdcpStatus == -1) { SetDisableHdcp(UAPI_SVR_DISPMNG_DISPLAY_ID_SLAVE); } else { SetEnableHdcp(UAPI_SVR_DISPMNG_DISPLAY_ID_SLAVE, (DispHdcpMode)hdcpStatus); } } return ret; } td_s32 DisplayImpl::SetCuvaConfig() const { LOGI("%s (%d)", __func__, __LINE__); td_bool isMatch = TD_FALSE; const int defaultMasterDisplayId = 0; GetHdrMatchContent(defaultMasterDisplayId, isMatch); if (isMatch) { LOGI("current hdr type is auto"); return TD_SUCCESS; } td_s32 hdrType = UAPI_SVR_DISPMNG_HDR_TYPE_MAX; GetHdrType(defaultMasterDisplayId, hdrType); if (hdrType != UAPI_SVR_DISPMNG_HDR_TYPE_SDR && hdrType != UAPI_SVR_DISPMNG_HDR_TYPE_HDR10 && hdrType != UAPI_SVR_DISPMNG_HDR_TYPE_CUVA_MONITOR) { LOGI("hdr type is not sdr/hdr10/cuvaMonitor"); return TD_SUCCESS; } char value[PROPERTY_LEN] = {0}; property_get("persist.vendor.display.luminance", value, "0"); const int decimal = 10; int luminanceValue = strtol(value, nullptr, decimal); if (luminanceValue == 0) { LOGI("luminance value never set"); return TD_SUCCESS; } uapi_svr_dispmng_display_luminance displayLuminance = {}; GetDisplayLuminance(defaultMasterDisplayId, displayLuminance); displayLuminance.max_luminance = static_cast(luminanceValue); SetDisplayLuminance(defaultMasterDisplayId, displayLuminance); return TD_SUCCESS; } }