1614 lines
56 KiB
1614 lines
56 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2020. All rights reserved.
|
|
* Description: Define the API of display manager client
|
|
* Author: Hisilicon
|
|
* Created: 2019-12-02
|
|
*/
|
|
#include "DisplayClient.h"
|
|
#include <sys/socket.h>
|
|
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
#include <arpa/inet.h>
|
|
#include <netinet/in.h>
|
|
#include <securec.h>
|
|
#include <utils/Log.h>
|
|
#include <utils/threads.h>
|
|
#include <hwbinder/Parcel.h>
|
|
#include <vendor/huanglong/hardware/hwdisplay/1.0/IHwdisplay.h>
|
|
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::IHwdisplay;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngAttachedInterface;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngInterfaceEnable;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngInterface;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngGetDisplayStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngGetOutputStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngVRRAttr;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngQmsAttr;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngAllmAttr;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispAllmMode;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngCvbsStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngHdmiStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngPanelStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispmngDisplayinfo;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplayMngCapabilities;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplayAvailableMode;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplayMode;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::AspectRatio;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplayScreenOffset;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::VirtualScreenWH;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::HdcpCapability;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DispHdcpStatus;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::IDispmngCallback;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplaymngCallbackData;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::HDCPKey;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::HDCPSrm;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::HdmiCfg;
|
|
using vendor::huanglong::hardware::hwdisplay::V1_0::DisplayLuminance;
|
|
|
|
using ::android::hardware::hidl_string;
|
|
using ::android::hardware::hidl_vec;
|
|
using ::android::sp;
|
|
using ::android::hardware::Void;
|
|
using android::hardware::Parcel;
|
|
#undef LOG_TAG
|
|
#define LOG_TAG "dispClient"
|
|
namespace android {
|
|
using EVT_CALLBACK_PFN_T = void (*)(uapi_svr_dispmng_event event,
|
|
void *msg, unsigned int msglen, void *privData);
|
|
using EVT_CALLBACK_S = struct {
|
|
EVT_CALLBACK_PFN_T pcallback;
|
|
};
|
|
|
|
static sp<android::DisplayClientListener> g_evtListenerCallback = nullptr;
|
|
static EVT_CALLBACK_S g_callBackArray[UAPI_SVR_DISPMNG_EVENT_MAX] = {{nullptr}};
|
|
|
|
static void IapiToIntf(const uapi_svr_dispmng_interface_group &iapi, DispmngAttachedInterface &intf)
|
|
{
|
|
intf.intf.resize(intf.number);
|
|
for (uint32_t i = 0; i < intf.number; i++) {
|
|
intf.intf[i].intf_type = iapi.intf[i].intf_type;
|
|
switch (iapi.intf[i].intf_type) {
|
|
case UAPI_SVR_DISPMNG_INTERFACE_HDMITX:
|
|
intf.intf[i].intf_id = iapi.intf[i].intf.hdmitx_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_CVBS:
|
|
intf.intf[i].intf_id = iapi.intf[i].intf.cvbs_dac;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_PANEL:
|
|
intf.intf[i].intf_id = iapi.intf[i].intf.panel_id;
|
|
break;
|
|
default:
|
|
ALOGE("Unknown interface type");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
static void IntfToIapi(const DispmngAttachedInterface &intf, uapi_svr_dispmng_interface_group &iapi)
|
|
{
|
|
for (uint32_t i = 0; i < intf.number; i++) {
|
|
iapi.intf[i].intf_type = (uapi_svr_dispmng_interface_type)intf.intf[i].intf_type;
|
|
switch (iapi.intf[i].intf_type) {
|
|
case UAPI_SVR_DISPMNG_INTERFACE_CVBS:
|
|
iapi.intf[i].intf.cvbs_dac = intf.intf[i].intf_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_HDMITX:
|
|
iapi.intf[i].intf.hdmitx_id = (uapi_svr_dispmng_hdmitx_id)intf.intf[i].intf_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_PANEL:
|
|
iapi.intf[i].intf.panel_id = (uapi_svr_dispmng_panel_id)intf.intf[i].intf_id;
|
|
break;
|
|
default:
|
|
ALOGE("Unknown interface type");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
int DisplayClient::masterId = UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER;
|
|
DisplayClient::DisplayClient()
|
|
{
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
masterId = mHal->GetDispId(UAPI_SVR_DISPMNG_DISPLAY_INDEX_0);
|
|
if (masterId < 0) {
|
|
masterId = UAPI_SVR_DISPMNG_DISPLAY_ID_MASTER;
|
|
}
|
|
}
|
|
}
|
|
|
|
int DisplayClient::SetBrightness(int brightness) const
|
|
{
|
|
return SetBrightness(masterId, brightness);
|
|
}
|
|
|
|
int DisplayClient::GetBrightness(void) const
|
|
{
|
|
return GetBrightness(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetContrast(int contrast) const
|
|
{
|
|
return SetContrast(masterId, contrast);
|
|
}
|
|
|
|
int DisplayClient::GetContrast(void) const
|
|
{
|
|
return GetContrast(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetSaturation(int saturation) const
|
|
{
|
|
return SetSaturation(masterId, saturation);
|
|
}
|
|
|
|
int DisplayClient::GetSaturation(void) const
|
|
{
|
|
return GetSaturation(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetHuePlus(int huePlus) const
|
|
{
|
|
return SetHue(masterId, huePlus);
|
|
}
|
|
|
|
int DisplayClient::GetHuePlus(void) const
|
|
{
|
|
return GetHue(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetAspectRatio(int displayid, int ratio) const
|
|
{
|
|
uapi_video_aspect_info mratio = {};
|
|
mratio.ratio = (uapi_video_aspect_ratio)ratio;
|
|
|
|
return SetAspectRatio(displayid, mratio);
|
|
}
|
|
|
|
int DisplayClient::SetAspectRatio(int ratio) const
|
|
{
|
|
return SetAspectRatio(masterId, ratio);
|
|
}
|
|
|
|
int DisplayClient::GetAspectRatio(int displayid) const
|
|
{
|
|
uapi_video_aspect_info ar = {};
|
|
|
|
int ret = GetAspectRatio(displayid, ar);
|
|
if (ret == 0) {
|
|
return ar.ratio;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetAspectRatio() const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetAspectRatio(masterId, [&ret](const AspectRatio &ar) {
|
|
ret = ar.aspect_rato;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetAspectCvrs(int cvrs) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetAspectCvrs(cvrs);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetAspectCvrs() const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetAspectCvrs();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::AttachIntf() const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->AttachIntf(masterId);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::DetachIntf() const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->DetachIntf(masterId);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetVirtScreen(int displayid, int outFmt) const
|
|
{
|
|
unsigned width = 0;
|
|
unsigned height = 0;
|
|
if (outFmt == static_cast<int>(DISPMNG_UI::DISPMNG_UI_720_P)) {
|
|
width = static_cast<unsigned int>(DISPMNG_UI::WIDTH_720_P);
|
|
height = static_cast<unsigned int>(DISPMNG_UI::HEIGHT_720_P);
|
|
} else if (outFmt == static_cast<int>(DISPMNG_UI::DISPMNG_UI_1080_P)) {
|
|
width = static_cast<unsigned int>(DISPMNG_UI::WIDTH_1080_P);
|
|
height = static_cast<unsigned int>(DISPMNG_UI::HEIGHT_1080_P);
|
|
} else if (outFmt == static_cast<int>(DISPMNG_UI::DISPMNG_UI_2160_P)) {
|
|
width = static_cast<unsigned int>(DISPMNG_UI::WIDTH_2160_P);
|
|
height = static_cast<unsigned int>(DISPMNG_UI::HEIGHT_2160_P);
|
|
} else {
|
|
return -1;
|
|
}
|
|
|
|
return SetVirtualScreen(displayid, width, height);
|
|
}
|
|
int DisplayClient::SetVirtScreen(int outFmt) const
|
|
{
|
|
return SetVirtScreen(masterId, outFmt);
|
|
}
|
|
|
|
int DisplayClient::GetVirtScreen(int displayid) const
|
|
{
|
|
unsigned int width = 0;
|
|
unsigned int height = 0;
|
|
int ret = GetVirtualScreen(displayid, width, height);
|
|
if (ret == 0) {
|
|
if (width == static_cast<unsigned int>(DISPMNG_UI::WIDTH_720_P) &&
|
|
height == static_cast<unsigned int>(DISPMNG_UI::HEIGHT_720_P)) {
|
|
return static_cast<int>(DISPMNG_UI::DISPMNG_UI_720_P);
|
|
} else if (width == static_cast<unsigned int>(DISPMNG_UI::WIDTH_1080_P) &&
|
|
height == static_cast<unsigned int>(DISPMNG_UI::HEIGHT_1080_P)) {
|
|
return static_cast<int>(DISPMNG_UI::DISPMNG_UI_1080_P);
|
|
} else if (width == static_cast<unsigned int>(DISPMNG_UI::WIDTH_2160_P) &&
|
|
height == static_cast<unsigned int>(DISPMNG_UI::HEIGHT_2160_P)) {
|
|
return static_cast<int>(DISPMNG_UI::DISPMNG_UI_2160_P);
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetVirtScreen() const
|
|
{
|
|
return GetVirtScreen(masterId);
|
|
}
|
|
|
|
int DisplayClient::GetVirtScreenSize(int displayid, unsigned &width, unsigned &height) const
|
|
{
|
|
return GetVirtualScreen(displayid, width, height);
|
|
}
|
|
|
|
int DisplayClient::GetVirtScreenSize(unsigned &width, unsigned &height) const
|
|
{
|
|
return GetVirtScreenSize(masterId, width, height);
|
|
}
|
|
|
|
int DisplayClient::SetOutputEnable(int port, int enable) const
|
|
{
|
|
return SetOutputEnable(masterId, port, enable);
|
|
}
|
|
|
|
int DisplayClient::SetOutputEnable(int displayid, int port, int enable) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetOutputEnable(displayid, port, enable);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetOutputEnable(int port) const
|
|
{
|
|
return GetOutputEnable(masterId, port);
|
|
}
|
|
|
|
|
|
int DisplayClient::GetOutputEnable(int displayid, int port) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetOutputEnable(displayid, port);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHDRType() const
|
|
{
|
|
return GetHDRType(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetHDRType(int type) const
|
|
{
|
|
return SetHDRType(masterId, type);
|
|
}
|
|
|
|
int DisplayClient::SetHDMIStart() const
|
|
{
|
|
return SetHDMIStart(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetHDMIStart(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetHDMIStart(displayid);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetHDMIStop() const
|
|
{
|
|
return SetHDMIStop(masterId);
|
|
}
|
|
|
|
int DisplayClient::SetHDMIStop(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetHDMIStop(displayid);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::ReadHDCPKey(int keyid, uapi_svr_dispmng_hdcp_key &key) const
|
|
{
|
|
int ret = -1;
|
|
if (key.data == nullptr) {
|
|
return ret;
|
|
}
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->ReadHDCPKey(keyid, [&key, &ret](const HDCPKey &hdcpkey) {
|
|
auto length = hdcpkey.key.size();
|
|
key.key_version = (uapi_svr_dispmng_hdcp_key_version)hdcpkey.key_version;
|
|
key.length = static_cast<int>(length);
|
|
errno_t err = memcpy_s(key.data, key.length, hdcpkey.key.data(), length);
|
|
if (err != EOK) {
|
|
ALOGE("%s:%d memcpy_s fail, err = %d\n", __func__, __LINE__, err);
|
|
return;
|
|
}
|
|
ret = 0;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::WriteHDCPKey(int keyid, uapi_svr_dispmng_hdcp_key &key) const
|
|
{
|
|
int ret = -1;
|
|
if (key.data == nullptr) {
|
|
return ret;
|
|
}
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
HDCPKey hdcpkey = {};
|
|
hdcpkey.key_version = key.key_version;
|
|
hdcpkey.key.setToExternal(key.data, key.length);
|
|
ret = mHal->WriteHDCPKey(keyid, hdcpkey);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::LoadHDCPKey(int displayid, uapi_svr_dispmng_hdcp_key &key) const
|
|
{
|
|
int ret = -1;
|
|
if (key.data == nullptr) {
|
|
return ret;
|
|
}
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
if (key.length <= 0) {
|
|
return -1;
|
|
}
|
|
HDCPKey hdcpkey = {};
|
|
hdcpkey.key_version = key.key_version;
|
|
hdcpkey.key.setToExternal(key.data, key.length);
|
|
ret = mHal->LoadHDCPKey(displayid, hdcpkey);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::LoadHDCPSrm(int displayid, const uapi_svr_dispmng_hdcp_srm &srm) const
|
|
{
|
|
int ret = -1;
|
|
if (srm.data == nullptr) {
|
|
return ret;
|
|
}
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
if (srm.length <= 0) {
|
|
return -1;
|
|
}
|
|
HDCPSrm hdcpsrm = {};
|
|
hdcpsrm.srm.setToExternal(srm.data, srm.length);
|
|
ret = mHal->LoadHDCPSrm(displayid, hdcpsrm);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDispCount() const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetDispCount();
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDispId(int index) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetDispId(index);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetAttachInterface(int displayid, const uapi_svr_dispmng_interface_group &attach) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngAttachedInterface intf;
|
|
intf.number = attach.number;
|
|
if (attach.number <= 0) {
|
|
return -1;
|
|
}
|
|
|
|
IapiToIntf(attach, intf);
|
|
ret = mHal->SetAttachInterface(displayid, intf);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetAttachedInterface(int displayid, uapi_svr_dispmng_interface_group &attach) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetAttachedInterface(displayid, [&attach, &ret](const DispmngAttachedInterface &infRet) {
|
|
attach.number = infRet.number;
|
|
if (attach.number <= 0) {
|
|
ret = -1;
|
|
} else {
|
|
IntfToIapi(infRet, attach);
|
|
ret = 0;
|
|
}
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayWindowNumber(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetDisplayWindowNumber(displayid);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::DetachInterface(int displayid, const uapi_svr_dispmng_interface_group &detach) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngAttachedInterface intf;
|
|
intf.number = detach.number;
|
|
if (detach.number <= 0) {
|
|
return -1;
|
|
}
|
|
|
|
IapiToIntf(detach, intf);
|
|
ret = mHal->DetachInterface(displayid, intf);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetInterfaceEnable(int displayid, const uapi_svr_dispmng_interface_enable &intfEnable) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngInterfaceEnable curIntfEnable;
|
|
curIntfEnable.number = intfEnable.number;
|
|
if (intfEnable.number <= 0) {
|
|
return -1;
|
|
}
|
|
curIntfEnable.intf.resize(curIntfEnable.number);
|
|
curIntfEnable.enable.resize(curIntfEnable.number);
|
|
for (uint32_t i = 0; i < curIntfEnable.number; i++) {
|
|
curIntfEnable.intf[i].intf_type = intfEnable.intf[i].intf_type;
|
|
switch (intfEnable.intf[i].intf_type) {
|
|
case UAPI_SVR_DISPMNG_INTERFACE_CVBS:
|
|
curIntfEnable.intf[i].intf_id = intfEnable.intf[i].intf.cvbs_dac;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_HDMITX:
|
|
curIntfEnable.intf[i].intf_id = intfEnable.intf[i].intf.hdmitx_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_PANEL:
|
|
curIntfEnable.intf[i].intf_id = intfEnable.intf[i].intf.panel_id;
|
|
break;
|
|
default:
|
|
ALOGE("Unknown interface type");
|
|
break;
|
|
}
|
|
curIntfEnable.enable[i] = intfEnable.enable[i];
|
|
}
|
|
ret = mHal->SetInterfaceEnable(displayid, curIntfEnable);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetInterfaceEnable(int displayid, uapi_svr_dispmng_interface_enable &intfEnable) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetInterfaceEnable(displayid, [&intfEnable, &ret](const DispmngInterfaceEnable &data) {
|
|
intfEnable.number = data.number;
|
|
if (intfEnable.number <= 0) {
|
|
ret = -1;
|
|
return;
|
|
}
|
|
|
|
for (uint32_t i = 0; i < data.number; i++) {
|
|
intfEnable.intf[i].intf_type = (uapi_svr_dispmng_interface_type)data.intf[i].intf_type;
|
|
switch (intfEnable.intf[i].intf_type) {
|
|
case UAPI_SVR_DISPMNG_INTERFACE_CVBS:
|
|
intfEnable.intf[i].intf.cvbs_dac = data.intf[i].intf_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_HDMITX:
|
|
intfEnable.intf[i].intf.hdmitx_id = (uapi_svr_dispmng_hdmitx_id)data.intf[i].intf_id;
|
|
break;
|
|
case UAPI_SVR_DISPMNG_INTERFACE_PANEL:
|
|
intfEnable.intf[i].intf.panel_id = \
|
|
(uapi_svr_dispmng_panel_id)data.intf[i].intf_id;
|
|
break;
|
|
default:
|
|
ALOGE("Unknown interface type");
|
|
break;
|
|
}
|
|
intfEnable.enable[i] = (td_bool)data.enable[i];
|
|
}
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetOutputStatus(int displayid, uapi_svr_disp_output_status &status) const
|
|
{
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetOutputStatus(displayid, [&status](const DispmngGetOutputStatus &st) {
|
|
status.refresh_rate = st.refresh_rate;
|
|
status.actual_out_hdr_type = (uapi_svr_disp_hdr_type)st.hdr_type;
|
|
status.actual_out_colorpace = (uapi_svr_disp_color_space)st.color_space;
|
|
});
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int DisplayClient::SetQmsAttr(int displayid, const uapi_svr_disp_qms_attr &attr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngQmsAttr qmsAttr;
|
|
qmsAttr.dst_rate = attr.dst_rate;
|
|
ret = mHal->SetQmsAttr(displayid, qmsAttr);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetQmsAttr(int displayid, uapi_svr_disp_qms_attr &attr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetQmsAttr(displayid, [&attr, &ret](const DispmngQmsAttr &qmsAttr) {
|
|
attr.dst_rate = qmsAttr.dst_rate;
|
|
ret = 0;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetAllmAttr(int displayid, const uapi_svr_disp_allm_attr &attr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngAllmAttr allmAttr;
|
|
ret = memset_s(&allmAttr, sizeof(allmAttr), 0, sizeof(allmAttr));
|
|
if (ret != EOK) {
|
|
ALOGE("data initialization failure");
|
|
return -1;
|
|
}
|
|
allmAttr.mode = (DispAllmMode)attr.mode;
|
|
ret = mHal->SetAllmAttr(displayid, allmAttr);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetAllmAttr(int displayid, uapi_svr_disp_allm_attr &attr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetAllmAttr(displayid, [&attr, &ret](const DispmngAllmAttr &allmAttr) {
|
|
attr.mode = (uapi_svr_disp_allm_mode)allmAttr.mode;
|
|
ret = 0;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetQmsEnable(int displayid, bool enable) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetQmsEnable(displayid, enable);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
bool DisplayClient::GetQmsEnable(int displayid) const
|
|
{
|
|
bool ret = false;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetQmsEnable(displayid);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetVrrEnable(int displayid, bool enable) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetVrrEnable(displayid, enable);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
bool DisplayClient::GetVrrEnable(int displayid) const
|
|
{
|
|
bool ret = false;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetVrrEnable(displayid);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetVRRAttr(int displayid, uapi_svr_disp_vrr_attr &vrr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetVRRAttr(displayid, [&vrr, &ret](const DispmngVRRAttr &attr) {
|
|
vrr.vrr_min = attr.vrr_min;
|
|
vrr.vrr_max = attr.vrr_max;
|
|
ret = 0;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetVRRAttr(int displayid, const uapi_svr_disp_vrr_attr &vrr) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DispmngVRRAttr attr;
|
|
ret = memset_s(&attr, sizeof(attr), 0, sizeof(attr));
|
|
if (ret != EOK) {
|
|
ALOGE("data initialization failure");
|
|
return -1;
|
|
}
|
|
attr.vrr_min = vrr.vrr_min;
|
|
attr.vrr_min = vrr.vrr_min;
|
|
ret = mHal->SetVRRAttr(displayid, attr);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
int DisplayClient::GetDisplayStatus(int displayid, uapi_svr_dispmng_display_status &status) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayStatus(displayid, [&status, &ret](const DispmngGetDisplayStatus &st) {
|
|
status.number = st.number;
|
|
if (status.number <= 0) {
|
|
ret = -1;
|
|
return;
|
|
}
|
|
size_t i = 0;
|
|
for (i = 0; i < st.hdmi.size(); i++) {
|
|
status.intf[i].intf_type = UAPI_SVR_DISPMNG_INTERFACE_HDMITX;
|
|
status.intf[i].intf.hdmi.hdmitx_id = (uapi_svr_dispmng_hdmitx_id)st.hdmi[i].hdmitx_id;
|
|
status.intf[i].intf.hdmi.conn_status = \
|
|
(uapi_svr_dispmng_hdmitx_connect_status)st.hdmi[i].conn_status;
|
|
status.intf[i].intf.hdmi.rsen_status = \
|
|
(uapi_svr_dispmng_hdmitx_rsen_status)st.hdmi[i].rsen_status;
|
|
status.intf[i].intf.hdmi.enabled = (td_bool)st.hdmi[i].enabled;
|
|
}
|
|
|
|
size_t j = 0;
|
|
for (j = 0; j < st.cvbs.size(); j++) {
|
|
status.intf[i + j].intf_type = UAPI_SVR_DISPMNG_INTERFACE_CVBS;
|
|
status.intf[i + j].intf.cvbs.dac = st.cvbs[j].dac;
|
|
status.intf[i + j].intf.cvbs.connected = (td_bool)st.cvbs[j].connected;
|
|
status.intf[i + j].intf.cvbs.cgms = (td_bool)st.cvbs[j].cgms;
|
|
status.intf[i + j].intf.cvbs.macrovision = (uapi_svr_dispmng_macrovision)st.cvbs[j].macrovision;
|
|
}
|
|
|
|
size_t k = 0;
|
|
for (k = 0; k < st.panel.size(); k++) {
|
|
status.intf[i + j + k].intf_type = UAPI_SVR_DISPMNG_INTERFACE_PANEL;
|
|
status.intf[i + j + k].intf.panel.panel_id = (uapi_svr_dispmng_panel_id)st.panel[k].panel_id;
|
|
status.intf[i + j + k].intf.panel.power_on = (td_bool)st.panel[k].power_on;
|
|
status.intf[i + j + k].intf.panel.dynamic_backlight_enabled = \
|
|
(td_bool)st.panel[k].dynamic_backlight_enabled;
|
|
status.intf[i + j + k].intf.panel.backlight_level = st.panel[k].backlight_level;
|
|
}
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayInfo(int displayid, uapi_svr_dispmng_sink_info &info) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayInfo(displayid, [&info](const DispmngDisplayinfo &infoRet) {
|
|
errno_t err = memcpy_s(info.mfrs_name, MANUFACTURERS_NAME_LEN,
|
|
infoRet.mfrs_name.c_str(), infoRet.mfrs_name.size() + 1);
|
|
if (err != EOK) {
|
|
ALOGE("%s:%d memcpy_s fail, err = %d\n", __func__, __LINE__, err);
|
|
return;
|
|
}
|
|
info.product_code = infoRet.product_code;
|
|
info.serial_number = infoRet.serial_number;
|
|
info.week = infoRet.week;
|
|
info.year = infoRet.year;
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void PackDolbyVision(uapi_svr_dispmng_display_capability &capa,
|
|
const DisplayMngCapabilities &data)
|
|
{
|
|
capa.dolby_vision.support_v0 = (td_bool)data.dolby_vision.support_v0;
|
|
capa.dolby_vision.support_v1 = (td_bool)data.dolby_vision.support_v1;
|
|
capa.dolby_vision.support_v2 = (td_bool)data.dolby_vision.support_v2;
|
|
|
|
capa.dolby_vision.v0.yuv422_12bit = (td_bool)data.dolby_vision.v0.yuv422_12bit;
|
|
capa.dolby_vision.v0.support_2160p60 = (td_bool)data.dolby_vision.v0.support_2160p60;
|
|
capa.dolby_vision.v0.global_dimming = (td_bool)data.dolby_vision.v0.global_dimming;
|
|
capa.dolby_vision.v0.white_x = data.dolby_vision.v0.white_x;
|
|
capa.dolby_vision.v0.white_y = data.dolby_vision.v0.white_y;
|
|
capa.dolby_vision.v0.dm_major_version = data.dolby_vision.v0.dm_major_version;
|
|
capa.dolby_vision.v0.dm_minor_version = data.dolby_vision.v0.dm_minor_version;
|
|
capa.dolby_vision.v0.red_x = data.dolby_vision.v0.red_x;
|
|
capa.dolby_vision.v0.red_y = data.dolby_vision.v0.red_y;
|
|
capa.dolby_vision.v0.green_x = data.dolby_vision.v0.green_x;
|
|
capa.dolby_vision.v0.green_y = data.dolby_vision.v0.green_y;
|
|
capa.dolby_vision.v0.blue_x = data.dolby_vision.v0.blue_x;
|
|
capa.dolby_vision.v0.blue_y = data.dolby_vision.v0.blue_y;
|
|
|
|
capa.dolby_vision.v1.yuv422_12bit = (td_bool)data.dolby_vision.v1.yuv422_12bit;
|
|
capa.dolby_vision.v1.support_2160p60 = (td_bool)data.dolby_vision.v1.support_2160p60;
|
|
capa.dolby_vision.v1.global_dimming = (td_bool)data.dolby_vision.v1.global_dimming;
|
|
capa.dolby_vision.v1.colorimetry = (td_bool)data.dolby_vision.v1.colorimetry;
|
|
capa.dolby_vision.v1.dm_version = data.dolby_vision.v1.dm_version;
|
|
capa.dolby_vision.v1.low_latency = data.dolby_vision.v1.low_latency;
|
|
capa.dolby_vision.v1.min_luminance = data.dolby_vision.v1.min_luminance;
|
|
capa.dolby_vision.v1.max_luminance = data.dolby_vision.v1.max_luminance;
|
|
capa.dolby_vision.v1.red_x = data.dolby_vision.v1.red_x;
|
|
capa.dolby_vision.v1.red_y = data.dolby_vision.v1.red_y;
|
|
capa.dolby_vision.v1.green_x = data.dolby_vision.v1.green_x;
|
|
capa.dolby_vision.v1.green_y = data.dolby_vision.v1.green_y;
|
|
capa.dolby_vision.v1.blue_x = data.dolby_vision.v1.blue_x;
|
|
capa.dolby_vision.v1.blue_y = data.dolby_vision.v1.blue_y;
|
|
|
|
capa.dolby_vision.v2.yuv422_12bit = (td_bool)data.dolby_vision.v2.yuv422_12bit;
|
|
capa.dolby_vision.v2.back_light_contol = (td_bool)data.dolby_vision.v2.back_light_contol;
|
|
capa.dolby_vision.v2.global_dimming = (td_bool)data.dolby_vision.v2.global_dimming;
|
|
capa.dolby_vision.v2.dm_version = data.dolby_vision.v2.dm_version;
|
|
capa.dolby_vision.v2.backlt_min_luma = data.dolby_vision.v2.backlt_min_luma;
|
|
capa.dolby_vision.v2.interface = data.dolby_vision.v2.intface;
|
|
capa.dolby_vision.v2.yuv444_rgb444_10b12b = data.dolby_vision.v2.yuv444_rgb444_10b12b;
|
|
capa.dolby_vision.v2.min_pq_v2 = data.dolby_vision.v2.min_pq_v2;
|
|
capa.dolby_vision.v2.max_pq_v2 = data.dolby_vision.v2.max_pq_v2;
|
|
capa.dolby_vision.v2.red_x = data.dolby_vision.v2.red_x;
|
|
capa.dolby_vision.v2.red_y = data.dolby_vision.v2.red_y;
|
|
capa.dolby_vision.v2.green_x = data.dolby_vision.v2.green_x;
|
|
capa.dolby_vision.v2.green_y = data.dolby_vision.v2.green_y;
|
|
capa.dolby_vision.v2.blue_x = data.dolby_vision.v2.blue_x;
|
|
capa.dolby_vision.v2.blue_y = data.dolby_vision.v2.blue_y;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayCapabilities(int displayid, uapi_svr_dispmng_display_capability &capa) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayCapabilities(displayid, [&capa](const DisplayMngCapabilities &data) {
|
|
for (int i = 0; i < UAPI_SVR_DISPMNG_COLORIMETRY_MAX; i++) {
|
|
capa.colorimetry.colorimetry[i] = (td_bool)data.colorimetry.colorimetry[i];
|
|
}
|
|
/* dolby_vision */
|
|
PackDolbyVision(capa, data);
|
|
/* hdr */
|
|
capa.hdr.eotf.eotf_sdr = (td_bool)data.hdr.eotf.eotf_sdr;
|
|
capa.hdr.eotf.eotf_hdr = (td_bool)data.hdr.eotf.eotf_hdr;
|
|
capa.hdr.eotf.eotf_smpte_st2084 = (td_bool)data.hdr.eotf.eotf_smpte_st2084;
|
|
capa.hdr.eotf.eotf_hlg = (td_bool)data.hdr.eotf.eotf_hlg;
|
|
|
|
capa.hdr.static_metadata.static_type_1 = (td_bool)data.hdr.static_metadata.static_type_1;
|
|
capa.hdr.static_metadata.max_lum_cv = data.hdr.static_metadata.max_lum_cv;
|
|
capa.hdr.static_metadata.aver_lum_cv = data.hdr.static_metadata.aver_lum_cv;
|
|
capa.hdr.static_metadata.min_lum_cv = data.hdr.static_metadata.min_lum_cv;
|
|
|
|
capa.hdr.dynamic_metadata.dynamic_type_1_support = \
|
|
(td_bool)data.hdr.dynamic_metadata.dynamic_type_1_support;
|
|
capa.hdr.dynamic_metadata.dynamic_type_1_version = data.hdr.dynamic_metadata.dynamic_type_1_version;
|
|
capa.hdr.dynamic_metadata.dynamic_type_2_support = \
|
|
(td_bool)data.hdr.dynamic_metadata.dynamic_type_2_support;
|
|
capa.hdr.dynamic_metadata.dynamic_type_2_version = data.hdr.dynamic_metadata.dynamic_type_2_version;
|
|
capa.hdr.dynamic_metadata.dynamic_type_3_support = \
|
|
(td_bool)data.hdr.dynamic_metadata.dynamic_type_3_support;
|
|
capa.hdr.dynamic_metadata.dynamic_type_4_support = \
|
|
(td_bool)data.hdr.dynamic_metadata.dynamic_type_4_support;
|
|
capa.hdr.dynamic_metadata.dynamic_type_4_version = data.hdr.dynamic_metadata.dynamic_type_4_version;
|
|
/* latency */
|
|
capa.latency.latency_present = (td_bool)data.latency.latency_present;
|
|
capa.latency.pvideo_latency = data.latency.pvideo_latency;
|
|
capa.latency.paudio_latency = data.latency.paudio_latency;
|
|
capa.latency.ivideo_latency = data.latency.ivideo_latency;
|
|
capa.latency.iaudio_latency = data.latency.iaudio_latency;
|
|
/* vrr */
|
|
capa.vrr.support = (td_bool)data.vrr.support;
|
|
capa.vrr.fva = (td_bool)data.vrr.fva;
|
|
capa.vrr.cnm_vrr = (td_bool)data.vrr.cnm_vrr;
|
|
capa.vrr.cinema_vrr = (td_bool)data.vrr.cinema_vrr;
|
|
capa.vrr.fapa_start_locat = (td_bool)data.vrr.fapa_start_locat;
|
|
capa.vrr.m_delta = (td_bool)data.vrr.m_delta;
|
|
capa.vrr.allm = (td_bool)data.vrr.allm;
|
|
capa.vrr.vrr_min = data.vrr.vrr_min;
|
|
capa.vrr.vrr_max = data.vrr.vrr_max;
|
|
});
|
|
ret = 0;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void FillDisplayMode(uapi_svr_dispmng_display_mode &mode, const DisplayMode &data)
|
|
{
|
|
mode.vic = data.vic;
|
|
if (data.name.c_str() == nullptr) {
|
|
ALOGE("Invalid input parameter: nullptr \n");
|
|
return;
|
|
}
|
|
errno_t err = memcpy_s(mode.name, MAX_DISPLAY_MODE_NAME_LEN,
|
|
data.name.c_str(), data.name.size() + 1);
|
|
if (err != EOK) {
|
|
ALOGE("%s:%d memcpy_s fail, err = %d\n", __func__, __LINE__, err);
|
|
return;
|
|
}
|
|
mode.progressive = (td_bool)data.progressive;
|
|
mode.format = data.format;
|
|
mode.width = data.width;
|
|
mode.height = data.height;
|
|
mode.field_rate = data.field_rate;
|
|
mode.pixel_format = (uapi_svr_dispmng_pixel_format)data.pixel_format;
|
|
mode.bit_depth = (uapi_svr_dispmng_pixel_bit_depth)data.bit_depth;
|
|
}
|
|
|
|
static void PackDisplayModes(uapi_svr_dispmng_display_available_mode &modes, const DisplayAvailableMode &data)
|
|
{
|
|
FillDisplayMode(modes.native_mode, data.native_mode);
|
|
FillDisplayMode(modes.max_mode, data.max_mode);
|
|
modes.number = data.number;
|
|
for (unsigned int i = 0; i < data.number && i < MAX_DISPLAY_MODE_NUMBER; i++) {
|
|
FillDisplayMode(modes.mode[i], data.mode[i]);
|
|
}
|
|
}
|
|
|
|
int DisplayClient::GetDisplaySupportedModeList(int displayid, uapi_svr_dispmng_display_available_mode &modes) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplaySupportedModeList(displayid, [&modes](const DisplayAvailableMode &data) {
|
|
PackDisplayModes(modes, data);
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayAllModeList(int displayid, uapi_svr_dispmng_display_available_mode &modes) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayAllModeList(displayid, [&modes](const DisplayAvailableMode &data) {
|
|
PackDisplayModes(modes, data);
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayMode(int displayid, uapi_svr_dispmng_display_mode &mode) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayMode(displayid, [&mode](const DisplayMode &data) {
|
|
FillDisplayMode(mode, data);
|
|
});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetDisplayMode(int displayid, const uapi_svr_dispmng_display_mode &mode) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DisplayMode data;
|
|
data.vic = mode.vic;
|
|
std::string str(mode.name, mode.name + sizeof(mode.name) / sizeof(mode.name[0]));
|
|
data.name = str.c_str();
|
|
data.progressive = mode.progressive;
|
|
data.format = mode.format;
|
|
data.width = mode.width;
|
|
data.height = mode.height;
|
|
data.field_rate = mode.field_rate;
|
|
data.pixel_format = mode.pixel_format;
|
|
data.bit_depth = mode.bit_depth;
|
|
ret = mHal->SetDisplayMode(displayid, data);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetSceneMode(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetSceneMode(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetSceneMode(int displayid, int mode) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetSceneMode(displayid, mode);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetBrightness(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetBrightness(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetBrightness(int displayid, int brightness) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetBrightness(displayid, brightness);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetContrast(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetContrast(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetContrast(int displayid, int contrast) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetContrast(displayid, contrast);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHue(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetHue(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetHue(int displayid, int hue) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetHue(displayid, hue);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetSaturation(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetSaturation(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetSaturation(int displayid, int saturation) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetSaturation(displayid, saturation);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetBacklight(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetBacklight(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetBacklight(int displayid, int backlight) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetBacklight(displayid, backlight);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetAspectRatio(int displayid, uapi_video_aspect_info &ratio) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetAspectRatio(displayid, [&ratio, &ret](const AspectRatio &ar) {
|
|
if (ar.aspect_rato < 0) {
|
|
ret = -1;
|
|
} else {
|
|
ratio.ratio = (uapi_video_aspect_ratio)ar.aspect_rato;
|
|
ratio.width = ar.user_width;
|
|
ratio.height = ar.user_height;
|
|
}
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetAspectRatio(int displayid, const uapi_video_aspect_info &ratio) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
AspectRatio ar;
|
|
ret = memset_s(&ar, sizeof(ar), 0, sizeof(ar));
|
|
if (ret != EOK) {
|
|
ALOGE("ar initialization failure");
|
|
return -1;
|
|
}
|
|
ar.aspect_rato = ratio.ratio;
|
|
ar.user_width = ratio.width;
|
|
ar.user_height = ratio.height;
|
|
ret = mHal->SetAspectRatio(displayid, ar);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetScreenOffset(int displayid, uapi_svr_dispmng_screen_offset &offset) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetScreenOffset(displayid, [&offset](const DisplayScreenOffset &offsetRet) {
|
|
offset.left = offsetRet.left;
|
|
offset.right = offsetRet.right;
|
|
offset.top = offsetRet.top;
|
|
offset.bottom = offsetRet.bottom;
|
|
});
|
|
ret = 0;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetScreenOffset(int displayid, const uapi_svr_dispmng_screen_offset &offset) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DisplayScreenOffset mOffset;
|
|
ret = memset_s(&mOffset, sizeof(mOffset), 0, sizeof(mOffset));
|
|
if (ret != EOK) {
|
|
ALOGE("mOffset initialization failure");
|
|
return -1;
|
|
}
|
|
mOffset.left = offset.left;
|
|
mOffset.right = offset.right;
|
|
mOffset.top = offset.top;
|
|
mOffset.bottom = offset.bottom;
|
|
ret = mHal->SetScreenOffset(displayid, mOffset);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetVirtualScreen(int displayid, unsigned int &width, unsigned int &height) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetVirtualScreen(displayid, [&width, &height](const VirtualScreenWH &wh) {
|
|
width = wh.width;
|
|
height = wh.height;
|
|
});
|
|
ret = 0;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetVirtualScreen(int displayid, unsigned int width, unsigned int height) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
VirtualScreenWH wh = {width, height};
|
|
ret = mHal->SetVirtualScreen(displayid, wh);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHDRType(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetHdrType(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetHDRType(int displayid, int type) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetHdrType(displayid, type);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool DisplayClient::GetHdrMatchContent(int displayid) const
|
|
{
|
|
bool ret = false;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetHdrMatchContent(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetHdrMatchContent(int displayid, bool match) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetHdrMatchContent(displayid, match);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::UILayerChanged(int displayid, uapi_svr_dispmng_layer &layer, int len) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->UILayerChanged(displayid,
|
|
hidl_vec<uint8_t>(reinterpret_cast<uint8_t *>(&layer), reinterpret_cast<uint8_t *>(&layer + 1)), len);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHdcpCapability(int displayid, uapi_svr_dispmng_hdcp_capability &capa) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetHdcpCapability(displayid, [&capa](const HdcpCapability &data) {
|
|
capa.support14 = (td_bool)data.support14;
|
|
capa.support2x = (td_bool)data.support2x;
|
|
});
|
|
ret = 0;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHdcpStatus(int displayid, uapi_svr_dispmng_hdcp_status &status) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetHdcpStatus(displayid, [&status, &ret](const DispHdcpStatus &data) {
|
|
if (data.mode < 0) {
|
|
ret = -1;
|
|
} else {
|
|
status.auth_start = (td_bool)data.auth_start;
|
|
status.auth_success = (td_bool)data.auth_success;
|
|
status.reauth_times = data.reauth_times;
|
|
status.mode = (uapi_svr_dispmng_hdcp_mode)data.mode;
|
|
status.err_code = (uapi_svr_dispmng_hdcp_error)data.err_code;
|
|
}
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetEnableHdcp(int displayid, uapi_svr_dispmng_hdcp_mode mode) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetEnableHdcp(displayid, mode);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetDisableHdcp(int displayid) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->SetDisableHdcp(displayid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetFormatFromVic(int vic) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetFormatFromVic(vic);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetVicFormFormat(int fmt) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
ret = mHal->GetVicFromFormat(fmt);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetHdmiCfgInfo(int hdmitxid, uapi_pdm_hdmi_config_info &info) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetHdmiCfgInfo(hdmitxid, [&info, &ret](const HdmiCfg &hdmicfg) {
|
|
if (hdmicfg.cec_mode < 0) {
|
|
ret = -1;
|
|
} else {
|
|
info.hdcp_enable = hdmicfg.hdcp_enable;
|
|
info.hdcp_mode = hdmicfg.hdcp_mode;
|
|
info.cec_enable = hdmicfg.cec_enable;
|
|
info.cec_mode = (uapi_cec_device_type)hdmicfg.cec_mode;
|
|
}
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetHdmiCfgInfo(int hdmitxid, const uapi_pdm_hdmi_config_info &info) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
HdmiCfg hdmicfg = {};
|
|
hdmicfg.hdcp_enable = info.hdcp_enable;
|
|
hdmicfg.hdcp_mode = info.hdcp_mode;
|
|
hdmicfg.cec_enable = info.cec_enable;
|
|
hdmicfg.cec_mode = info.cec_mode;
|
|
ret = mHal->SetHdmiCfgInfo(hdmitxid, hdmicfg);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::GetDisplayLuminance(int displayid, uapi_svr_dispmng_display_luminance &luminance) const
|
|
{
|
|
int ret = 0;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
mHal->GetDisplayLuminance(displayid, [&luminance](const DisplayLuminance &displayLuminance) {
|
|
luminance.min_luminance = displayLuminance.min_luminance;
|
|
luminance.max_luminance = displayLuminance.max_luminance;
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::SetDisplayLuminance(int displayid, const uapi_svr_dispmng_display_luminance &luminance) const
|
|
{
|
|
int ret = -1;
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
DisplayLuminance displayLuminance = {};
|
|
displayLuminance.min_luminance = luminance.min_luminance;
|
|
displayLuminance.max_luminance = luminance.max_luminance;
|
|
ret = mHal->SetDisplayLuminance(displayid, displayLuminance);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
class DisplayClientListener : public vendor::huanglong::hardware::hwdisplay::V1_0::IDispmngCallback {
|
|
public:
|
|
DisplayClientListener() noexcept {}
|
|
~DisplayClientListener() override {}
|
|
::android::hardware::Return<void> OnDispmngCallback(const DisplaymngCallbackData &data) override
|
|
{
|
|
if (data.event_id < UAPI_SVR_DISPMNG_EVENT_NONE || data.event_id >= UAPI_SVR_DISPMNG_EVENT_MAX) {
|
|
return Void();
|
|
}
|
|
if (g_callBackArray[data.event_id].pcallback != nullptr) {
|
|
EVT_CALLBACK_PFN_T pfnCallbackReal = g_callBackArray[data.event_id].pcallback;
|
|
|
|
if (data.event_id >= UAPI_SVR_DISPMNG_EVENT_HOTPLUG_IN &&
|
|
data.event_id <= UAPI_SVR_DISPMNG_EVENT_LINK_TRAIN_FAIL) {
|
|
uapi_svr_dispmng_event_hdmitx_event hdmi = {};
|
|
hdmi.display_id = (uapi_svr_dispmng_display_id)data.hdmi.display_id;
|
|
hdmi.hdmitx_id = (uapi_svr_dispmng_hdmitx_id)data.hdmi.hdmitx_id;
|
|
|
|
pfnCallbackReal((uapi_svr_dispmng_event)data.event_id, &hdmi,
|
|
sizeof(uapi_svr_dispmng_event_hdmitx_event), nullptr);
|
|
} else if (data.event_id == UAPI_SVR_DISPMNG_EVENT_MODE_CHANGED) {
|
|
uapi_svr_dispmng_event_mode_changed mode = {};
|
|
mode.display_id = (uapi_svr_dispmng_display_id)data.mode.display_id;
|
|
FillDisplayMode(mode.old_mode, data.mode.old_mode);
|
|
FillDisplayMode(mode.new_mode, data.mode.new_mode);
|
|
|
|
pfnCallbackReal(UAPI_SVR_DISPMNG_EVENT_MODE_CHANGED, &mode,
|
|
sizeof(uapi_svr_dispmng_event_mode_changed), nullptr);
|
|
} else if (data.event_id == UAPI_SVR_DISPMNG_EVENT_HDR_CHANGED) {
|
|
uapi_svr_dispmng_event_hdr_changed hdr = {};
|
|
hdr.display_id = (uapi_svr_dispmng_display_id)data.hdr_type.display_id;
|
|
hdr.old_hdr = (uapi_svr_dispmng_hdr_type)data.hdr_type.old_hdr;
|
|
hdr.new_hdr = (uapi_svr_dispmng_hdr_type)data.hdr_type.new_hdr;
|
|
|
|
pfnCallbackReal(UAPI_SVR_DISPMNG_EVENT_HDR_CHANGED, &hdr,
|
|
sizeof(uapi_svr_dispmng_event_hdr_changed), nullptr);
|
|
}
|
|
}
|
|
return Void();
|
|
}
|
|
};
|
|
|
|
int DisplayClient::RegisterCallback(int eventid, uapi_svr_dispmng_callback_func cb) const
|
|
{
|
|
if (cb == nullptr) {
|
|
return -1;
|
|
}
|
|
if (eventid >= UAPI_SVR_DISPMNG_EVENT_MAX || eventid < UAPI_SVR_DISPMNG_EVENT_NONE) {
|
|
return -1;
|
|
}
|
|
|
|
int ret = -1;
|
|
if (g_callBackArray[eventid].pcallback == nullptr) {
|
|
g_callBackArray[eventid].pcallback = cb;
|
|
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
if (g_evtListenerCallback == nullptr) {
|
|
g_evtListenerCallback = new DisplayClientListener();
|
|
}
|
|
ret = mHal->RegisterCallback(eventid, g_evtListenerCallback);
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int DisplayClient::UnRegisterCallback(int eventid) const
|
|
{
|
|
if (eventid >= UAPI_SVR_DISPMNG_EVENT_MAX || eventid < UAPI_SVR_DISPMNG_EVENT_NONE) {
|
|
return -1;
|
|
}
|
|
|
|
int ret = -1;
|
|
if (g_callBackArray[eventid].pcallback != nullptr) {
|
|
g_callBackArray[eventid].pcallback = nullptr;
|
|
|
|
sp<IHwdisplay> mHal = nullptr;
|
|
mHal = IHwdisplay::getService();
|
|
if (mHal != nullptr) {
|
|
if (g_evtListenerCallback != nullptr) {
|
|
sp<IDispmngCallback> callback = g_evtListenerCallback;
|
|
ret = mHal->UnRegisterCallback(eventid, callback);
|
|
}
|
|
}
|
|
|
|
int i = 0;
|
|
for (i = 0; i < UAPI_SVR_DISPMNG_EVENT_MAX; i++) {
|
|
if (g_callBackArray[i].pcallback != nullptr) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (i == UAPI_SVR_DISPMNG_EVENT_MAX) {
|
|
g_evtListenerCallback.clear();
|
|
g_evtListenerCallback = nullptr;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
}; // end namespace
|