diff --git a/services/config/config_defs.h b/services/config/config_defs.h index 7bf66a60..d9ec9866 100644 --- a/services/config/config_defs.h +++ b/services/config/config_defs.h @@ -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 */, diff --git a/services/config/src/client_impl.cpp b/services/config/src/client_impl.cpp index 34184fb5..a2bb2234 100644 --- a/services/config/src/client_impl.cpp +++ b/services/config/src/client_impl.cpp @@ -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(&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(data); + *supported = *output; + } + + return error; +} + void ClientCallback::ParseNotifyCWBBufferDone(const ByteStream &input_params, const HandleStream &input_handles) { const int *error; diff --git a/services/config/src/client_impl.h b/services/config/src/client_impl.h index 3ad23cbc..bd5ae0eb 100644 --- a/services/config/src/client_impl.h +++ b/services/config/src/client_impl.h @@ -30,6 +30,8 @@ #ifndef __CLIENT_IMPL_H__ #define __CLIENT_IMPL_H__ +#define VALIDATE_CONFIG_SWITCH 1 + #include #include #include @@ -122,6 +124,7 @@ class ClientImpl : public ClientInterface { std::vector *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 display_config_ = nullptr; diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp index 9181a811..2a8feff7 100644 --- a/services/config/src/device_impl.cpp +++ b/services/config/src/device_impl.cpp @@ -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(data); + + int32_t error = intf_->IsSupportedConfigSwitch(supported_modes_data->disp_id, + supported_modes_data->mode, &supported); + output_params.setToExternal(reinterpret_cast(&supported), sizeof(bool)); + _hidl_cb(error, output_params, {}); +} + Return 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 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; diff --git a/services/config/src/device_impl.h b/services/config/src/device_impl.h index 14e349ca..0fbd4811 100644 --- a/services/config/src/device_impl.h +++ b/services/config/src/device_impl.h @@ -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; diff --git a/services/config/src/opcode_types.h b/services/config/src/opcode_types.h index fee79fac..a31e314c 100644 --- a/services/config/src/opcode_types.h +++ b/services/config/src/opcode_types.h @@ -80,6 +80,7 @@ enum OpCode { kGetSupportedDisplayRefreshRates = 44, kIsRCSupported = 45, kControlIdleStatusCallback = 46, + kIsSupportedConfigSwitch = 47, kDestroy = 0xFFFF, // Destroy sequence execution };