883 lines
27 KiB
C++
883 lines
27 KiB
C++
/*
|
|
* Copyright (C) 2024 Amlogic Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "BinderServer.h"
|
|
#include <binder/IPCThreadState.h>
|
|
#include <binder/ProcessState.h>
|
|
#include <binder/IServiceManager.h>
|
|
|
|
#include "binderInfo.h"
|
|
#include "DispAdptLog.h"
|
|
#include "binder_api.h"
|
|
|
|
#include "vsc_func.h"
|
|
|
|
BinderServer::BinderServer()
|
|
{
|
|
mSCallback = std::make_shared<ServerCallback>();
|
|
mServerFunc.emplace(CMD_SEND_CLIENT, &ServerCallback::registerCallback);
|
|
mServerFunc.emplace(CMD_CONNECT_VIDEO_SCALER, &ServerCallback::connectVideoScaler);
|
|
mServerFunc.emplace(CMD_DISCONNECT_VIDEO_SCALER, &ServerCallback::disconnectVideoScaler);
|
|
mServerFunc.emplace(CMD_GET_HDR_TYPE, &ServerCallback::getHdrType);
|
|
mServerFunc.emplace(CMD_SET_HDR_TYPE, &ServerCallback::setHdrType);
|
|
mServerFunc.emplace(CMD_GET_FREEZE, &ServerCallback::getFreeze);
|
|
mServerFunc.emplace(CMD_SET_FREEZE, &ServerCallback::setFreeze);
|
|
mServerFunc.emplace(CMD_GET_FREEZE_FRAMEBUFFER, &ServerCallback::getFreezeFrameBuffer);
|
|
mServerFunc.emplace(CMD_SET_FREEZE_FRAMEBUFFER, &ServerCallback::setFreezeFrameBuffer);
|
|
mServerFunc.emplace(CMD_GET_BG_COLOR, &ServerCallback::getBgColor);
|
|
mServerFunc.emplace(CMD_SET_BG_COLOR, &ServerCallback::setBgColor);
|
|
mServerFunc.emplace(CMD_GET_HDMI_CONNECTION, &ServerCallback::getHdmitxConnection);
|
|
mServerFunc.emplace(CMD_GET_HDMITX_HDR, &ServerCallback::getHdmitxHdrType);
|
|
mServerFunc.emplace(CMD_GET_HDMITX_HDCP_VERSION, &ServerCallback::getHdmitxHdcpVersion);
|
|
mServerFunc.emplace(CMD_GET_HDMITX_HDR_POLICY, &ServerCallback::getHdmitxHdrPolicy);
|
|
mServerFunc.emplace(CMD_SET_HDMITX_HDR_POLICY, &ServerCallback::setHdmitxHdrPolicy);
|
|
mServerFunc.emplace(CMD_SET_HDMITX_AV_MUTE, &ServerCallback::setHdmitxAvMute);
|
|
mServerFunc.emplace(CMD_SET_HDMITX_HDCP_AUTH, &ServerCallback::setHdmitxHdcpAuth);
|
|
mServerFunc.emplace(CMD_GET_HDMITX_HDCP_STATUS, &ServerCallback::getHdmitxHdcpStatus);
|
|
|
|
mServerFunc.emplace(CMD_GET_WIN_REGION, &ServerCallback::getWinRegion);
|
|
mServerFunc.emplace(CMD_SET_WIN_REGION, &ServerCallback::setOriginalResolution);
|
|
mServerFunc.emplace(CMD_GET_ZORDER, &ServerCallback::getZorder);
|
|
mServerFunc.emplace(CMD_SET_ZORDER, &ServerCallback::setZorder);
|
|
mServerFunc.emplace(CMD_GET_WIN_PROP, &ServerCallback::getWinProp);
|
|
mServerFunc.emplace(CMD_SET_WIN_PROP, &ServerCallback::setWinProp);
|
|
mServerFunc.emplace(CMD_GET_CONNECT_INFO, &ServerCallback::getConnectInfo);
|
|
mServerFunc.emplace(CMD_SET_CONNECT_INFO, &ServerCallback::setConnectInfo);
|
|
mServerFunc.emplace(CMD_SET_ASPECTRATIO, &ServerCallback::setAspectratio);
|
|
mServerFunc.emplace(CMD_GET_HDMI_TIMING, &ServerCallback::getHdmitxTiming);
|
|
mServerFunc.emplace(CMD_SET_HDMI_TIMING, &ServerCallback::setHdmitxTiming);
|
|
mServerFunc.emplace(CMD_GET_HDMI_COLOR, &ServerCallback::getHdmitxColor);
|
|
mServerFunc.emplace(CMD_SET_HDMI_COLOR, &ServerCallback::setHdmitxColor);
|
|
mServerFunc.emplace(CMD_GET_HDMI_EDID, &ServerCallback::getHdmitxRawEdid);
|
|
mServerFunc.emplace(CMD_SET_ORBIT_WINDOW, &ServerCallback::setOrbitWindow);
|
|
mServerFunc.emplace(CMD_SET_ORBIT_MOVE, &ServerCallback::setOrbitMove);
|
|
|
|
VSC_SERVER_FUNC_MAP_LIST();
|
|
|
|
mServerFunc.emplace(CMD_TRANSFER_LEASE_FD, &ServerCallback::receiveLeaseFd);
|
|
}
|
|
|
|
void BinderServer::ServiceDeathRecipient::binderDied(const wp<IBinder>& who)
|
|
{
|
|
if (mCb != NULL)
|
|
mCb->removeClient(mClientId);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::registerCallback(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
std::lock_guard<std::mutex> lock(mMutex);
|
|
int index = data.readInt32();
|
|
int scaler_id = data.readInt32();
|
|
sp<IBinder> binder = data.readStrongBinder();
|
|
|
|
int client_id = (index << 3) | scaler_id;
|
|
sp<ServiceDeathRecipient> deathRecip = new ServiceDeathRecipient(this, client_id);
|
|
std::shared_ptr<compositorClient> client = std::make_shared<compositorClient>(mMesonCompositor);
|
|
|
|
if (binder != NULL)
|
|
binder->linkToDeath(deathRecip);
|
|
|
|
mClients.emplace(client_id, std::make_pair(client, deathRecip));
|
|
mBinders.emplace(client_id, binder);
|
|
|
|
auto scaler = mScalerId.find(scaler_id);
|
|
if (scaler != mScalerId.end()) {
|
|
scaler->second.emplace(client_id);
|
|
} else {
|
|
std::unordered_set<int> item;
|
|
item.emplace(client_id);
|
|
mScalerId.emplace(scaler_id, item);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::connectVideoScaler(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int index = data.readInt32();
|
|
int client_id = (index << 3) | scalerId;
|
|
|
|
auto client = mClients.find(client_id);
|
|
if (client != mClients.end()) {
|
|
auto info = client->second;
|
|
auto [cc, deathRecipient] = info;
|
|
if (cc.get())
|
|
cc->addDisplay(displayId, client_id);
|
|
}
|
|
|
|
mMesonCompositor->connectScaler(displayId, scalerId);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::disconnectVideoScaler(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int index = data.readInt32();
|
|
int client_id = (index << 3) | scalerId;
|
|
|
|
auto client = mClients.find(client_id);
|
|
if (client != mClients.end()) {
|
|
auto info = client->second;
|
|
auto [cc, deathRecipient] = info;
|
|
if (cc.get())
|
|
cc->removeDisplay(displayId, client_id);
|
|
}
|
|
|
|
removeClient(client_id);
|
|
|
|
mMesonCompositor->disconnectScaler(displayId, scalerId, index);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::createLayer(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int32_t id = 0;
|
|
int ret;
|
|
int callingPid = IPCThreadState::self()->getCallingPid();
|
|
|
|
ret = mMesonCompositor->createLayer(displayId, &id);
|
|
if (!ret) {
|
|
auto client = mClients.find(callingPid);
|
|
if (client != mClients.end()) {
|
|
auto info = client->second;
|
|
auto [cc, deathRecipient] = info;
|
|
if (cc.get())
|
|
cc->addDisplay(displayId, id);
|
|
}
|
|
}
|
|
reply->writeInt32(id);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::destroyLayer(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
int callingPid = IPCThreadState::self()->getCallingPid();
|
|
auto client = mClients.find(callingPid);
|
|
|
|
if (client != mClients.end()) {
|
|
auto info = client->second;
|
|
auto [cc, deathRecipient] = info;
|
|
if (cc.get())
|
|
cc->removeDisplay(displayId, layerId);
|
|
}
|
|
|
|
return mMesonCompositor->destroyLayer(displayId, layerId);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setTunnelId(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
int tunnelId = data.readInt32();
|
|
|
|
return mMesonCompositor->setTunnelId(displayId, layerId, tunnelId);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setLayerIndex(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
int index = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerIndex(displayId, layerId, index);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setLayerZorder(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
int zorder = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerZorder(displayId, layerId, zorder);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setSourceCrop(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
struct rect crop = { 0 };
|
|
|
|
crop.x = data.readInt32();
|
|
crop.y = data.readInt32();
|
|
crop.w = data.readInt32();
|
|
crop.h = data.readInt32();
|
|
|
|
return mMesonCompositor->setSourceCrop(displayId, layerId, crop);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setDisplayFrame(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
struct rect frame = { 0 };
|
|
|
|
frame.x = data.readInt32();
|
|
frame.y = data.readInt32();
|
|
frame.w = data.readInt32();
|
|
frame.h = data.readInt32();
|
|
|
|
return mMesonCompositor->setDisplayFrame(displayId, layerId, frame);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getDelayLatency(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int layerId = data.readInt32();
|
|
int latency;
|
|
|
|
latency = mMesonCompositor->getDelayLatency(displayId, layerId);
|
|
reply->writeInt32(latency);
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setToMainPlane(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
|
|
return mMesonCompositor->setToMainPlane(displayId);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getUiSize(const Parcel& data, Parcel* reply)
|
|
{
|
|
int32_t displayId = data.readInt32();
|
|
int32_t width = 0;
|
|
int32_t height = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getUiSize(displayId, &width, &height);
|
|
if (!ret && reply != NULL) {
|
|
reply->writeInt32(width);
|
|
reply->writeInt32(height);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdrType(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int value = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHDR(displayId, &value);
|
|
reply->writeInt32(value);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdrType(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int hdrValue = data.readInt32();
|
|
|
|
return mMesonCompositor->setHDR(displayId, hdrValue);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getFreeze(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int freeze = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getLayerFreeze(displayId, scalerId, &freeze);
|
|
|
|
reply->writeInt32(freeze);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setFreeze(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int freeze = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerFreeze(displayId, scalerId, freeze);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getFreezeFrameBuffer(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int freeze = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getLayerFreezeFrameBuffer(displayId, scalerId, &freeze);
|
|
|
|
reply->writeInt32(freeze);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setFreezeFrameBuffer(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int freeze = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerFreezeFrameBuffer(displayId, scalerId, freeze);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getBgColor(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int color = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getBgColor(displayId, &color);
|
|
|
|
reply->writeInt32(color);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setBgColor(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int color = data.readInt32();
|
|
|
|
return mMesonCompositor->setBgColor(displayId, scalerId, color);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxConnection(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int state = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxConnection(displayId, state);
|
|
reply->writeInt32(state);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxHdrType(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int value = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxHdrType(displayId, value);
|
|
reply->writeInt32(value);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxHdcpVersion(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int value = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxHdcpVersion(displayId, value);
|
|
reply->writeInt32(value);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxHdrPolicy(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int value = 0;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxHdrPolicy(displayId, value);
|
|
reply->writeInt32(value);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdmitxHdrPolicy(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int value = data.readInt32();
|
|
|
|
return mMesonCompositor->setHdmitxHdrPolicy(displayId, value);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdmitxAvMute(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
enum v4l2_ext_hdmitx_avmute value = (enum v4l2_ext_hdmitx_avmute)data.readInt32();
|
|
|
|
return mMesonCompositor->setHdmitxAvMute(displayId, value);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdmitxHdcpAuth(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
enum v4l2_ext_hdmitx_hdcp_auth value =
|
|
(enum v4l2_ext_hdmitx_hdcp_auth)data.readInt32();
|
|
|
|
return mMesonCompositor->setHdmitxHdcpAuth(displayId, value);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxHdcpStatus(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
enum v4l2_ext_hdmitx_hdcp_status value = V4L2_EXT_HDMITX_HDCP_STATUS_FAIL;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxHdcpStatus(displayId, value);
|
|
reply->writeInt32(value);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getWinRegion(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_win_region win = { 0 };
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getLayerWinRegion(displayId, scalerId, win);
|
|
|
|
reply->writeInt32(win.in.crop.x);
|
|
reply->writeInt32(win.in.crop.y);
|
|
reply->writeInt32(win.in.crop.w);
|
|
reply->writeInt32(win.in.crop.h);
|
|
reply->writeInt32(win.in.res.x);
|
|
reply->writeInt32(win.in.res.y);
|
|
reply->writeInt32(win.in.res.w);
|
|
reply->writeInt32(win.in.res.h);
|
|
reply->writeInt32(win.out.x);
|
|
reply->writeInt32(win.out.y);
|
|
reply->writeInt32(win.out.w);
|
|
reply->writeInt32(win.out.h);
|
|
reply->writeInt32(win.punch.x);
|
|
reply->writeInt32(win.punch.y);
|
|
reply->writeInt32(win.punch.w);
|
|
reply->writeInt32(win.punch.h);
|
|
reply->writeInt32(win.rotation);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setOriginalResolution(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
meson_rect_t originalRect = {
|
|
.left = data.readInt32(),
|
|
.top = data.readInt32(),
|
|
.right = data.readInt32(),
|
|
.bottom = data.readInt32() };
|
|
drm_rect_t sourceRect = {
|
|
.left = data.readInt32(),
|
|
.top = data.readInt32(),
|
|
.right = data.readInt32(),
|
|
.bottom = data.readInt32() };
|
|
meson_rect_t displayRect = {
|
|
.left = data.readInt32(),
|
|
.top = data.readInt32(),
|
|
.right = data.readInt32(),
|
|
.bottom = data.readInt32() };
|
|
meson_rect_t punch = {
|
|
.left = data.readInt32(),
|
|
.top = data.readInt32(),
|
|
.right = data.readInt32(),
|
|
.bottom = data.readInt32() };
|
|
int rotation = data.readInt32();
|
|
|
|
struct rect crop = {
|
|
.x = (uint32_t)sourceRect.left,
|
|
.y = (uint32_t)sourceRect.top,
|
|
.w = (uint32_t)(sourceRect.right - sourceRect.left),
|
|
.h = (uint32_t)(sourceRect.bottom - sourceRect.top) };
|
|
struct rect frame = {
|
|
.x = (uint32_t)displayRect.left,
|
|
.y = (uint32_t)displayRect.top,
|
|
.w = (uint32_t)(displayRect.right - displayRect.left),
|
|
.h = (uint32_t)(displayRect.bottom - displayRect.top) };
|
|
|
|
mMesonCompositor->setOriginalResolution(displayId, scalerId, originalRect, punch);
|
|
mMesonCompositor->setScalerSourceCrop(displayId, scalerId, crop);
|
|
mMesonCompositor->setScalerDisplayFrame(displayId, scalerId, frame);
|
|
mMesonCompositor->setScalerTransform(displayId, scalerId, rotation);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getZorder(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_zorder z = { 0 };
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getZorder(displayId, scalerId, z);
|
|
|
|
reply->writeInt32(z.zorder);
|
|
reply->writeInt32(z.alpha);
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setZorder(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int zorder = data.readInt32();
|
|
int alpha = data.readInt32();
|
|
|
|
mMesonCompositor->setZorder(displayId, scalerId, zorder, alpha);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getWinProp(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_win_prop prop;
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getWinProp(displayId, scalerId, prop);
|
|
|
|
reply->writeInt32(prop.win_mode);
|
|
reply->writeInt32(prop.mirror_mode);
|
|
reply->writeInt32(prop.mem_type);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setWinProp(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int dat = data.readInt32();
|
|
int displayId = dat & 0xf;
|
|
int scalerId = (dat >> 4) & 0xf;
|
|
int win_mode = (dat >> 16) & 0xf;
|
|
int mirror_mode = (dat >> 12) & 0xf;
|
|
int mem_type = (dat >> 8) & 0xf;
|
|
|
|
mMesonCompositor->setWinProp(displayId, scalerId, win_mode, mirror_mode, mem_type);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getConnectInfo(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_connect_info conInfo;
|
|
|
|
mMesonCompositor->getConnectInfo(displayId, scalerId, conInfo);
|
|
reply->writeInt32(conInfo.in.src);
|
|
reply->writeInt32(conInfo.in.index);
|
|
reply->writeInt32(conInfo.in.attr);
|
|
reply->writeInt32(conInfo.out);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setConnectInfo(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
int open_index = data.readInt32();
|
|
int src = data.readInt32();
|
|
int index = data.readInt32();
|
|
int attr = data.readInt32();
|
|
int out = data.readInt32();
|
|
|
|
mMesonCompositor->setConnectInfo(displayId, scalerId, src, index, attr, out, open_index);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setAspectratio(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_aspectratio_policy policy;
|
|
|
|
policy.out.x = data.readInt32();
|
|
policy.out.y = data.readInt32();
|
|
policy.out.w = data.readInt32();
|
|
policy.out.h = data.readInt32();
|
|
|
|
policy.system_policy.panel.x = data.readInt32();
|
|
policy.system_policy.panel.y = data.readInt32();
|
|
policy.system_policy.panel.w = data.readInt32();
|
|
policy.system_policy.panel.h = data.readInt32();
|
|
|
|
policy.system_policy.country_grp = data.readInt32();
|
|
policy.system_policy.content_type = data.readInt32();
|
|
policy.system_policy.source_index = data.readInt32();
|
|
|
|
policy.setting_policy.zoom_data.h_ratio = data.readInt32();
|
|
policy.setting_policy.zoom_data.v_ratio = data.readInt32();
|
|
policy.setting_policy.zoom_data.h_position = data.readInt32();
|
|
policy.setting_policy.zoom_data.v_position = data.readInt32();
|
|
|
|
policy.setting_policy.just_scan = data.readInt32();
|
|
policy.setting_policy.aspect_ratio = data.readInt32();
|
|
policy.setting_policy.rotate = data.readInt32();
|
|
policy.setting_policy.orbit_over_scan = data.readInt32();
|
|
policy.setting_policy.screen_position = data.readInt32();
|
|
policy.setting_policy.media_afd_property = data.readInt32();
|
|
policy.setting_policy.overscan_appropriate_flag = data.readInt32();
|
|
policy.setting_policy.scan_type = data.readInt32();
|
|
|
|
return mMesonCompositor->setAspectratio(displayId, scalerId, policy);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxTiming(const Parcel& data, Parcel* reply)
|
|
{
|
|
struct v4l2_ext_hdmitx_timing_info timing = { 0 };
|
|
int displayId = data.readInt32();
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmiTiming(displayId, timing);
|
|
reply->writeInt32(timing.width);
|
|
reply->writeInt32(timing.height);
|
|
reply->writeInt32(timing.framerate);
|
|
reply->writeInt32(timing.scan_type);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdmitxTiming(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
struct v4l2_ext_hdmitx_timing_info timing;
|
|
int displayId = data.readInt32();
|
|
|
|
timing.width = data.readInt32();
|
|
timing.height = data.readInt32();
|
|
timing.framerate = data.readInt32();
|
|
timing.scan_type = data.readInt32();
|
|
return mMesonCompositor->setHdmiTiming(displayId, timing);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxColor(const Parcel& data, Parcel* reply)
|
|
{
|
|
struct v4l2_ext_hdmitx_color_attr attr;
|
|
int displayId = data.readInt32();
|
|
int ret;
|
|
|
|
ret = mMesonCompositor->getHdmitxColor(displayId, attr);
|
|
reply->writeInt32(attr.pixel_encoding);
|
|
reply->writeInt32(attr.color_depth);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setHdmitxColor(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
struct v4l2_ext_hdmitx_color_attr attr;
|
|
int displayId = data.readInt32();
|
|
|
|
attr.pixel_encoding = (enum v4l2_ext_hdmitx_avi_csc)data.readInt32();
|
|
attr.color_depth = (enum v4l2_ext_hdmitx_color_depth)data.readInt32();
|
|
return mMesonCompositor->setHdmitxColor(displayId, attr);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::getHdmitxRawEdid(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int ret;
|
|
char *dat = NULL;
|
|
int len = 0;
|
|
|
|
ret = mMesonCompositor->getHdmitxRawEdid(displayId, &dat, len);
|
|
if (dat) {
|
|
reply->writeByteArray(len, (uint8_t *)dat);
|
|
free(dat);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setOrbitWindow(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_orbit_window win;
|
|
|
|
win.osd_input.x = data.readInt32();
|
|
win.osd_input.y = data.readInt32();
|
|
win.osd_input.w = data.readInt32();
|
|
win.osd_input.h = data.readInt32();
|
|
|
|
win.video_input.x = data.readInt32();
|
|
win.video_input.y = data.readInt32();
|
|
win.video_input.w = data.readInt32();
|
|
win.video_input.h = data.readInt32();
|
|
|
|
win.osd_output.x = data.readInt32();
|
|
win.osd_output.y = data.readInt32();
|
|
win.osd_output.w = data.readInt32();
|
|
win.osd_output.h = data.readInt32();
|
|
|
|
win.video_output.x = data.readInt32();
|
|
win.video_output.y = data.readInt32();
|
|
win.video_output.w = data.readInt32();
|
|
win.video_output.h = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerOrbitWindow(displayId, scalerId, win);
|
|
}
|
|
|
|
int BinderServer::ServerCallback::setOrbitMove(const Parcel& data, Parcel* reply)
|
|
{
|
|
(void)reply;
|
|
int displayId = data.readInt32();
|
|
int scalerId = data.readInt32();
|
|
struct v4l2_ext_vsc_orbit_move win;
|
|
|
|
win.osd_input.x = data.readInt32();
|
|
win.osd_input.y = data.readInt32();
|
|
win.osd_input.w = data.readInt32();
|
|
win.osd_input.h = data.readInt32();
|
|
|
|
win.video_input.x = data.readInt32();
|
|
win.video_input.y = data.readInt32();
|
|
win.video_input.w = data.readInt32();
|
|
win.video_input.h = data.readInt32();
|
|
|
|
win.osd_output.x = data.readInt32();
|
|
win.osd_output.y = data.readInt32();
|
|
win.osd_output.w = data.readInt32();
|
|
win.osd_output.h = data.readInt32();
|
|
|
|
win.video_output.x = data.readInt32();
|
|
win.video_output.y = data.readInt32();
|
|
win.video_output.w = data.readInt32();
|
|
win.video_output.h = data.readInt32();
|
|
|
|
return mMesonCompositor->setLayerOrbitMove(displayId, scalerId, win);
|
|
}
|
|
|
|
VSC_BINDER_SERVER_FUNC_LIST
|
|
|
|
int BinderServer::ServerCallback::receiveLeaseFd(const Parcel& data, Parcel* reply)
|
|
{
|
|
int displayId = data.readInt32();
|
|
int lease_fd = data.readFileDescriptor();
|
|
if (lease_fd < 0)
|
|
return -1;
|
|
|
|
if (mMesonCompositor.get())
|
|
return mMesonCompositor->setDrmLeaseFd(displayId, lease_fd);
|
|
return 0;
|
|
}
|
|
|
|
void BinderServer::ServerCallback::setMesonCompositor(std::shared_ptr<mesonVideoCompositor>& c)
|
|
{
|
|
mMesonCompositor = c;
|
|
}
|
|
|
|
void BinderServer::ServerCallback::removeClient(int clientId)
|
|
{
|
|
std::lock_guard<std::mutex> lock(mMutex);
|
|
int scaler_id = clientId & 0x7;
|
|
auto client = mClients.find(clientId);
|
|
if (client != mClients.end()) {
|
|
auto [cc, deathRecipient] = client->second;
|
|
|
|
if (cc.get()) cc.reset();
|
|
if (deathRecipient != NULL) deathRecipient.clear();
|
|
mClients.erase(client);
|
|
}
|
|
mBinders.erase(clientId);
|
|
|
|
auto scaler = mScalerId.find(scaler_id);
|
|
if (scaler != mScalerId.end())
|
|
scaler->second.erase(clientId);
|
|
}
|
|
|
|
void BinderServer::ServerCallback::broadcastEvent(uint32_t id, VscEventType event)
|
|
{
|
|
std::lock_guard<std::mutex> lock(mMutex);
|
|
if (mBinders.size() <= 0)
|
|
return;
|
|
|
|
auto scaler = mScalerId.find(id);
|
|
if (scaler == mScalerId.end())
|
|
return;
|
|
|
|
for (const auto& elem : scaler->second) {
|
|
auto cb = mBinders.find(elem);
|
|
if (cb != mBinders.end()) {
|
|
int ret = -1;
|
|
Parcel send, reply;
|
|
send.writeUint64(event.displayId);
|
|
send.writeInt32(event.scalerId);
|
|
send.writeUint32(event.eventId);
|
|
send.write((void *)event.data, sizeof(event.data));
|
|
ret = cb->second->transact(CMD_EVENT, send, &reply);
|
|
if (ret)
|
|
DISPLAY_LOGE("fail to send event to vsc: %d", reply.readInt32());
|
|
}
|
|
}
|
|
}
|
|
|
|
status_t BinderServer::onTransact(uint32_t code,
|
|
const Parcel& data, Parcel* reply,
|
|
uint32_t flags) {
|
|
auto cb = mServerFunc.find(code);
|
|
if (cb == mServerFunc.end())
|
|
return BBinder::onTransact(code, data, reply, flags);
|
|
|
|
return (mSCallback.get()->*(cb->second))(data, reply);
|
|
}
|
|
|
|
void BinderServer::setMesonCompositor(std::shared_ptr<mesonVideoCompositor>& c)
|
|
{
|
|
if (mSCallback.get())
|
|
mSCallback->setMesonCompositor(c);
|
|
}
|
|
|
|
void BinderServer::broadcastEvent(uint32_t id, VscEventType event)
|
|
{
|
|
mSCallback->broadcastEvent(id, event);
|
|
}
|
|
|
|
void BinderServer::run(std::shared_ptr<BinderServer> server)
|
|
{
|
|
sp<ProcessState> proc(ProcessState::self());
|
|
sp<IServiceManager> serviceManager = defaultServiceManager();
|
|
|
|
serviceManager->addService(String16("compositor-service"), server.get());
|
|
proc->startThreadPool();
|
|
IPCThreadState::self()->joinThreadPool();
|
|
}
|