Merge "DisplayConfig: Add support to notify idling."

This commit is contained in:
qctecmdr
2020-09-29 23:19:04 -07:00
committed by Gerrit - the friendly Code Review server
6 changed files with 64 additions and 0 deletions

View File

@@ -39,6 +39,7 @@
// implementation being present. When this ifdef gets enabled in this header, the
// client code will automatically get compiled.
#define DISPLAY_CONFIG_API_LEVEL_0
#define DISPLAY_CONFIG_API_LEVEL_1
namespace DisplayConfig {
@@ -237,6 +238,7 @@ class ConfigCallback {
public:
virtual void NotifyCWBBufferDone(int error, const native_handle_t *buffer) { }
virtual void NotifyQsyncChange(bool qsync_enabled, int refresh_rate, int qsync_refresh_rate) { }
virtual void NotifyIdleStatus(bool is_idle) { }
protected:
virtual ~ConfigCallback() { }
@@ -299,6 +301,7 @@ class ConfigInterface {
virtual int GetSupportedDisplayRefreshRates(
DisplayType dpy, std::vector<uint32_t> *supported_refresh_rates) DEFAULT_RET
virtual int IsRCSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
virtual int ControlIdleStatusCallback(bool enable) DEFAULT_RET
// deprecated APIs
virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET

View File

@@ -828,6 +828,19 @@ int ClientImpl::ControlQsyncCallback(bool enable) {
return error;
}
int ClientImpl::ControlIdleStatusCallback(bool enable) {
ByteStream input_params;
input_params.setToExternal(reinterpret_cast<uint8_t*>(&enable), sizeof(bool));
int32_t error = 0;
auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
error = err;
};
display_config_->perform(client_handle_, kControlIdleStatusCallback, input_params, {}, hidl_cb);
return error;
}
int ClientImpl::SendTUIEvent(DisplayType dpy, TUIEventType event_type) {
struct TUIEventParams input = {dpy, event_type};
ByteStream input_params;
@@ -940,6 +953,17 @@ void ClientCallback::ParseNotifyQsyncChange(const ByteStream &input_params) {
qsync_data->qsync_refresh_rate);
}
void ClientCallback::ParseNotifyIdleStatus(const ByteStream &input_params) {
const bool *is_idle;
if (callback_ == nullptr || input_params.size() == 0) {
return;
}
const uint8_t *data = input_params.data();
is_idle = reinterpret_cast<const bool*>(data);
callback_->NotifyIdleStatus(*is_idle);
}
Return<void> ClientCallback::perform(uint32_t op_code, const ByteStream &input_params,
const HandleStream &input_handles) {
switch (op_code) {
@@ -949,6 +973,9 @@ Return<void> ClientCallback::perform(uint32_t op_code, const ByteStream &input_p
case kControlQsyncCallback:
ParseNotifyQsyncChange(input_params);
break;
case kControlIdleStatusCallback:
ParseNotifyIdleStatus(input_params);
break;
default:
break;
}

View File

@@ -62,6 +62,7 @@ class ClientCallback: public IDisplayConfigCallback {
const HandleStream &input_handles);
void ParseNotifyCWBBufferDone(const ByteStream &input_params, const HandleStream &input_handles);
void ParseNotifyQsyncChange(const ByteStream &input_params);
void ParseNotifyIdleStatus(const ByteStream &input_params);
ConfigCallback *callback_ = nullptr;
};
@@ -120,6 +121,7 @@ class ClientImpl : public ClientInterface {
virtual int GetSupportedDisplayRefreshRates(DisplayType dpy,
std::vector<uint32_t> *supported_refresh_rates);
virtual int IsRCSupported(uint32_t disp_id, bool *supported);
virtual int ControlIdleStatusCallback(bool enable);
private:
android::sp<IDisplayConfig> display_config_ = nullptr;

View File

@@ -163,6 +163,18 @@ void DeviceImpl::DeviceClientContext::NotifyQsyncChange(bool qsync_enabled, int3
}
}
void DeviceImpl::DeviceClientContext::NotifyIdleStatus(bool is_idle) {
bool data = {is_idle};
ByteStream output_params;
output_params.setToExternal(reinterpret_cast<uint8_t*>(&data), sizeof(data));
auto status = callback_->perform(kControlIdleStatusCallback, output_params, {});
if (status.isDeadObject()) {
return;
}
}
void DeviceImpl::DeviceClientContext::ParseIsDisplayConnected(const ByteStream &input_params,
perform_cb _hidl_cb) {
const DisplayType *dpy;
@@ -716,6 +728,19 @@ void DeviceImpl::DeviceClientContext::ParseControlQsyncCallback(uint64_t client_
_hidl_cb(error, {}, {});
}
void DeviceImpl::DeviceClientContext::ParseControlIdleStatusCallback(uint64_t client_handle,
const ByteStream &input_params,
perform_cb _hidl_cb) {
const bool *enable;
const uint8_t *data = input_params.data();
enable = reinterpret_cast<const bool*>(data);
int32_t error = intf_->ControlIdleStatusCallback(*enable);
_hidl_cb(error, {}, {});
}
void DeviceImpl::DeviceClientContext::ParseSendTUIEvent(const ByteStream &input_params,
perform_cb _hidl_cb) {
const struct TUIEventParams *input_data =
@@ -938,6 +963,9 @@ Return<void> DeviceImpl::perform(uint64_t client_handle, uint32_t op_code,
case kControlQsyncCallback:
client->ParseControlQsyncCallback(client_handle, input_params, _hidl_cb);
break;
case kControlIdleStatusCallback:
client->ParseControlIdleStatusCallback(client_handle, input_params, _hidl_cb);
break;
case kSendTUIEvent:
client->ParseSendTUIEvent(input_params, _hidl_cb);
break;

View File

@@ -71,6 +71,7 @@ class DeviceImpl : public IDisplayConfig, public android::hardware::hidl_death_r
virtual void NotifyCWBBufferDone(int32_t error, const native_handle_t *buffer);
virtual void NotifyQsyncChange(bool qsync_enabled, int32_t refresh_rate,
int32_t qsync_refresh_rate);
virtual void NotifyIdleStatus(bool is_idle);
void ParseIsDisplayConnected(const ByteStream &input_params, perform_cb _hidl_cb);
void ParseSetDisplayStatus(const ByteStream &input_params, perform_cb _hidl_cb);
@@ -120,6 +121,8 @@ class DeviceImpl : public IDisplayConfig, public android::hardware::hidl_death_r
void ParseGetDisplayHwId(const ByteStream &input_params, perform_cb _hidl_cb);
void ParseGetSupportedDisplayRefreshRates(const ByteStream &input_params, perform_cb _hidl_cb);
void ParseIsRCSupported(const ByteStream &input_params, perform_cb _hidl_cb);
void ParseControlIdleStatusCallback(uint64_t client_handle, const ByteStream &input_params,
perform_cb _hidl_cb);
private:
ConfigInterface *intf_ = nullptr;

View File

@@ -79,6 +79,7 @@ enum OpCode {
kGetDisplayHwId = 43,
kGetSupportedDisplayRefreshRates = 44,
kIsRCSupported = 45,
kControlIdleStatusCallback = 46,
kDestroy = 0xFFFF, // Destroy sequence execution
};