display: Add API to support config switch validation
This change adds a new API which will be called by SF whenever it tries to switch the device's active config. Change-Id: Iea57e4939ca1c2693605c623b3133b9203ccfdd1 CRs-Fixed: 2777628
This commit is contained in:
@@ -233,6 +233,11 @@ struct TUIEventParams {
|
||||
TUIEventType tui_event_type = TUIEventType::kNone;
|
||||
};
|
||||
|
||||
struct SupportedModesParams {
|
||||
uint32_t disp_id = 0;
|
||||
uint32_t mode = 0;
|
||||
};
|
||||
|
||||
/* Callback Interface */
|
||||
class ConfigCallback {
|
||||
public:
|
||||
@@ -313,6 +318,8 @@ class ConfigInterface {
|
||||
/* supported_refresh_rates */) DEFAULT_RET
|
||||
virtual int IsRCSupported(uint32_t /* disp_id */, bool* /* supported */) DEFAULT_RET
|
||||
virtual int ControlIdleStatusCallback(bool /* enable */) DEFAULT_RET
|
||||
virtual int IsSupportedConfigSwitch(uint32_t /* disp_id */, uint32_t /* config */,
|
||||
bool* /* supported */) DEFAULT_RET
|
||||
|
||||
// deprecated APIs
|
||||
virtual int GetDebugProperty(const std::string /* prop_name */,
|
||||
|
||||
@@ -926,6 +926,32 @@ int ClientImpl::IsRCSupported(uint32_t disp_id, bool *supported) {
|
||||
return error;
|
||||
}
|
||||
|
||||
int ClientImpl::IsSupportedConfigSwitch(uint32_t disp_id, uint32_t config, bool *supported) {
|
||||
struct SupportedModesParams input = {disp_id, config};
|
||||
ByteStream input_params;
|
||||
ByteStream output_params;
|
||||
const bool *output;
|
||||
input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
|
||||
sizeof(struct SupportedModesParams));
|
||||
int error = 0;
|
||||
auto hidl_cb = [&error, &output_params] (int32_t err, ByteStream params, HandleStream handles) {
|
||||
error = err;
|
||||
output_params = params;
|
||||
};
|
||||
|
||||
if (display_config_) {
|
||||
display_config_->perform(client_handle_, kIsSupportedConfigSwitch, input_params, {}, hidl_cb);
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
const uint8_t *data = output_params.data();
|
||||
output = reinterpret_cast<const bool *>(data);
|
||||
*supported = *output;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void ClientCallback::ParseNotifyCWBBufferDone(const ByteStream &input_params,
|
||||
const HandleStream &input_handles) {
|
||||
const int *error;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef __CLIENT_IMPL_H__
|
||||
#define __CLIENT_IMPL_H__
|
||||
|
||||
#define VALIDATE_CONFIG_SWITCH 1
|
||||
|
||||
#include <vendor/display/config/2.0/IDisplayConfig.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <log/log.h>
|
||||
@@ -122,6 +124,7 @@ class ClientImpl : public ClientInterface {
|
||||
std::vector<uint32_t> *supported_refresh_rates);
|
||||
virtual int IsRCSupported(uint32_t disp_id, bool *supported);
|
||||
virtual int ControlIdleStatusCallback(bool enable);
|
||||
virtual int IsSupportedConfigSwitch(uint32_t disp_id, uint32_t config, bool *supported);
|
||||
|
||||
private:
|
||||
android::sp<IDisplayConfig> display_config_ = nullptr;
|
||||
|
||||
@@ -819,6 +819,25 @@ void DeviceImpl::DeviceClientContext::ParseIsRCSupported(const ByteStream &input
|
||||
_hidl_cb(error, output_params, {});
|
||||
}
|
||||
|
||||
void DeviceImpl::DeviceClientContext::ParseIsSupportedConfigSwitch(const ByteStream &input_params,
|
||||
perform_cb _hidl_cb) {
|
||||
if (!intf_) {
|
||||
_hidl_cb(-EINVAL, {}, {});
|
||||
return;
|
||||
}
|
||||
|
||||
const struct SupportedModesParams *supported_modes_data;
|
||||
const uint8_t *data = input_params.data();
|
||||
bool supported = false;
|
||||
ByteStream output_params;
|
||||
supported_modes_data = reinterpret_cast<const SupportedModesParams*>(data);
|
||||
|
||||
int32_t error = intf_->IsSupportedConfigSwitch(supported_modes_data->disp_id,
|
||||
supported_modes_data->mode, &supported);
|
||||
output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported), sizeof(bool));
|
||||
_hidl_cb(error, output_params, {});
|
||||
}
|
||||
|
||||
Return<void> DeviceImpl::perform(uint64_t client_handle, uint32_t op_code,
|
||||
const ByteStream &input_params, const HandleStream &input_handles,
|
||||
perform_cb _hidl_cb) {
|
||||
@@ -981,6 +1000,9 @@ Return<void> DeviceImpl::perform(uint64_t client_handle, uint32_t op_code,
|
||||
case kIsRCSupported:
|
||||
client->ParseIsRCSupported(input_params, _hidl_cb);
|
||||
break;
|
||||
case kIsSupportedConfigSwitch:
|
||||
client->ParseIsSupportedConfigSwitch(input_params, _hidl_cb);
|
||||
break;
|
||||
default:
|
||||
_hidl_cb(-EINVAL, {}, {});
|
||||
break;
|
||||
|
||||
@@ -123,6 +123,7 @@ class DeviceImpl : public IDisplayConfig, public android::hardware::hidl_death_r
|
||||
void ParseIsRCSupported(const ByteStream &input_params, perform_cb _hidl_cb);
|
||||
void ParseControlIdleStatusCallback(uint64_t client_handle, const ByteStream &input_params,
|
||||
perform_cb _hidl_cb);
|
||||
void ParseIsSupportedConfigSwitch(const ByteStream &input_params, perform_cb _hidl_cb);
|
||||
|
||||
private:
|
||||
ConfigInterface *intf_ = nullptr;
|
||||
|
||||
@@ -80,6 +80,7 @@ enum OpCode {
|
||||
kGetSupportedDisplayRefreshRates = 44,
|
||||
kIsRCSupported = 45,
|
||||
kControlIdleStatusCallback = 46,
|
||||
kIsSupportedConfigSwitch = 47,
|
||||
|
||||
kDestroy = 0xFFFF, // Destroy sequence execution
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user