176 lines
6.4 KiB
C++
176 lines
6.4 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.
|
|
*/
|
|
|
|
#ifndef BINDER_SERVER_H
|
|
#define BINDER_SERVER_H
|
|
|
|
#include <binder/Binder.h>
|
|
#include <binder/Parcel.h>
|
|
#include <unordered_set>
|
|
|
|
#include "MesonVideoCompositor.h"
|
|
#include "info.h"
|
|
|
|
#include "vsc_func.h"
|
|
|
|
using namespace android;
|
|
|
|
typedef struct pairDisplayLayer {
|
|
int32_t displayId;
|
|
int32_t layerId;
|
|
} pairDisplayLayert;
|
|
|
|
class BinderServer : public BBinder {
|
|
public:
|
|
BinderServer();
|
|
void run(std::shared_ptr<BinderServer> server);
|
|
void setMesonCompositor(std::shared_ptr<mesonVideoCompositor>& c);
|
|
void broadcastEvent(uint32_t id, VscEventType event);
|
|
|
|
private:
|
|
class compositorClient {
|
|
public:
|
|
compositorClient(std::shared_ptr<mesonVideoCompositor> cp)
|
|
: mCp(cp) { }
|
|
|
|
~compositorClient() {
|
|
if (mCp.get()) {
|
|
for (auto it = mInfos.begin(); it != mInfos.end(); it++) {
|
|
int scaler_id = it->second.layerId & 0x7;
|
|
int index = it->second.layerId >> 3;
|
|
mCp->disconnectScaler(it->second.displayId, scaler_id, index);
|
|
}
|
|
}
|
|
}
|
|
|
|
void addDisplay(int32_t displayId, int32_t layerId) {
|
|
std::string key = std::to_string(10 * layerId + displayId);
|
|
pairDisplayLayert info = {
|
|
.displayId = displayId,
|
|
.layerId = layerId
|
|
};
|
|
|
|
mInfos.emplace(key, info);
|
|
}
|
|
|
|
void removeDisplay(int32_t displayId, int32_t layerId) {
|
|
std::string key = std::to_string(10 * layerId + displayId);
|
|
mInfos.erase(key);
|
|
}
|
|
|
|
private:
|
|
std::shared_ptr<mesonVideoCompositor> mCp;
|
|
std::map<std::string, pairDisplayLayert> mInfos;
|
|
};
|
|
|
|
class ServiceDeathRecipient;
|
|
|
|
typedef std::pair<std::shared_ptr<compositorClient>, sp<ServiceDeathRecipient>> clientInfo;
|
|
class ServerCallback {
|
|
public:
|
|
ServerCallback() { }
|
|
|
|
int registerCallback(const Parcel& data, Parcel* reply);
|
|
int createLayer(const Parcel& data, Parcel* reply);
|
|
int destroyLayer(const Parcel& data, Parcel* reply);
|
|
int setTunnelId(const Parcel& data, Parcel* reply);
|
|
int setLayerIndex(const Parcel& data, Parcel* reply);
|
|
int setLayerZorder(const Parcel& data, Parcel* reply);
|
|
int setSourceCrop(const Parcel& data, Parcel* reply);
|
|
int setDisplayFrame(const Parcel& data, Parcel* reply);
|
|
int getDelayLatency(const Parcel& data, Parcel* reply);
|
|
int setToMainPlane(const Parcel& data, Parcel* reply);
|
|
int getUiSize(const Parcel& data, Parcel* reply);
|
|
|
|
int connectVideoScaler(const Parcel& data, Parcel* reply);
|
|
int disconnectVideoScaler(const Parcel& data, Parcel* reply);
|
|
|
|
int getHdrType(const Parcel& data, Parcel* reply);
|
|
int setHdrType(const Parcel& data, Parcel* reply);
|
|
int getFreeze(const Parcel& data, Parcel* reply);
|
|
int setFreeze(const Parcel& data, Parcel* reply);
|
|
int getFreezeFrameBuffer(const Parcel& data, Parcel* reply);
|
|
int setFreezeFrameBuffer(const Parcel& data, Parcel* reply);
|
|
int getBgColor(const Parcel& data, Parcel* reply);
|
|
int setBgColor(const Parcel& data, Parcel* reply);
|
|
int getHdmitxConnection(const Parcel& data, Parcel* reply);
|
|
int getHdmitxHdrType(const Parcel& data, Parcel* reply);
|
|
int getHdmitxHdcpVersion(const Parcel& data, Parcel* reply);
|
|
int getHdmitxHdrPolicy(const Parcel& data, Parcel* reply);
|
|
int setHdmitxHdrPolicy(const Parcel& data, Parcel* reply);
|
|
int setHdmitxAvMute(const Parcel& data, Parcel* reply);
|
|
int setHdmitxHdcpAuth(const Parcel& data, Parcel* reply);
|
|
int getHdmitxHdcpStatus(const Parcel& data, Parcel* reply);
|
|
|
|
int getWinRegion(const Parcel& data, Parcel* reply);
|
|
int setOriginalResolution(const Parcel& data, Parcel* reply);
|
|
int getZorder(const Parcel& data, Parcel* reply);
|
|
int setZorder(const Parcel& data, Parcel* reply);
|
|
int getWinProp(const Parcel& data, Parcel* reply);
|
|
int setWinProp(const Parcel& data, Parcel* reply);
|
|
int getConnectInfo(const Parcel& data, Parcel* reply);
|
|
int setConnectInfo(const Parcel& data, Parcel* reply);
|
|
int setAspectratio(const Parcel& data, Parcel* reply);
|
|
int getHdmitxTiming(const Parcel& data, Parcel* reply);
|
|
int setHdmitxTiming(const Parcel& data, Parcel* reply);
|
|
int getHdmitxColor(const Parcel& data, Parcel* reply);
|
|
int setHdmitxColor(const Parcel& data, Parcel* reply);
|
|
int getHdmitxRawEdid(const Parcel& data, Parcel* reply);
|
|
int setOrbitWindow(const Parcel& data, Parcel* reply);
|
|
int setOrbitMove(const Parcel& data, Parcel* reply);
|
|
|
|
VSC_SERVER_FUNC_H_LIST();
|
|
|
|
int receiveLeaseFd(const Parcel& data, Parcel* reply);
|
|
|
|
void setMesonCompositor(std::shared_ptr<mesonVideoCompositor>& c);
|
|
void removeClient(int clientId);
|
|
void broadcastEvent(uint32_t id, VscEventType event);
|
|
|
|
private:
|
|
std::shared_ptr<mesonVideoCompositor> mMesonCompositor;
|
|
std::map<int, clientInfo> mClients;
|
|
std::map<int, sp<IBinder>> mBinders;
|
|
std::map<int, std::unordered_set<int>> mScalerId;
|
|
|
|
std::mutex mMutex;
|
|
};
|
|
|
|
class ServiceDeathRecipient : public IBinder::DeathRecipient {
|
|
public:
|
|
ServiceDeathRecipient(ServerCallback *callbck, int id)
|
|
: mCb(callbck),
|
|
mClientId(id) { }
|
|
virtual void binderDied(const wp<IBinder>& who);
|
|
|
|
private:
|
|
ServerCallback *mCb;
|
|
int mClientId;
|
|
};
|
|
|
|
virtual status_t onTransact(uint32_t code,
|
|
const Parcel& data, Parcel* reply,
|
|
uint32_t flags = 0);
|
|
typedef int (ServerCallback::*func)(const Parcel&, Parcel*);
|
|
|
|
private:
|
|
std::shared_ptr<ServerCallback> mSCallback;
|
|
std::map<uint32_t, func> mServerFunc;
|
|
};
|
|
|
|
#endif
|