diff --git a/services/config/config_defs.h b/services/config/config_defs.h index 4f4ef92a..0009ac83 100644 --- a/services/config/config_defs.h +++ b/services/config/config_defs.h @@ -296,6 +296,8 @@ class ConfigInterface { virtual int ControlQsyncCallback(bool enable) DEFAULT_RET virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type) DEFAULT_RET virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id) DEFAULT_RET + virtual int GetSupportedDisplayRefreshRates( + DisplayType dpy, std::vector *supported_refresh_rates) DEFAULT_RET // deprecated APIs virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET diff --git a/services/config/src/client_impl.cpp b/services/config/src/client_impl.cpp index d3c3075b..9790f213 100644 --- a/services/config/src/client_impl.cpp +++ b/services/config/src/client_impl.cpp @@ -865,6 +865,32 @@ int ClientImpl::GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id) { return error; } +int ClientImpl::GetSupportedDisplayRefreshRates(DisplayType dpy, + std::vector *supported_refresh_rates) { + ByteStream input_params; + input_params.setToExternal(reinterpret_cast(&dpy), sizeof(DisplayType)); + ByteStream output_params; + int error = 0; + auto hidl_cb = [&error, &output_params](int32_t err, ByteStream params, HandleStream handles) { + error = err; + output_params = params; + }; + + display_config_->perform(client_handle_, kGetSupportedDisplayRefreshRates, input_params, {}, + hidl_cb); + + if (!error) { + const uint8_t *data = output_params.data(); + const uint32_t *refresh_rates_data = reinterpret_cast(data); + int num_refresh_rates = static_cast(output_params.size() / sizeof(uint32_t)); + for (int i = 0; i < num_refresh_rates; i++) { + supported_refresh_rates->push_back(refresh_rates_data[i]); + } + } + + 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 677fedfc..737ea19d 100644 --- a/services/config/src/client_impl.h +++ b/services/config/src/client_impl.h @@ -116,6 +116,8 @@ class ClientImpl : public ClientInterface { virtual int ControlQsyncCallback(bool enable); virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type); virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id); + virtual int GetSupportedDisplayRefreshRates(DisplayType dpy, + std::vector *supported_refresh_rates); private: android::sp display_config_ = nullptr; diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp index a6304cc1..74801947 100644 --- a/services/config/src/device_impl.cpp +++ b/services/config/src/device_impl.cpp @@ -736,6 +736,25 @@ void DeviceImpl::DeviceClientContext::ParseGetDisplayHwId(const ByteStream &inpu _hidl_cb(error, output_params, {}); } +void DeviceImpl::DeviceClientContext::ParseGetSupportedDisplayRefreshRates( + const ByteStream &input_params, perform_cb _hidl_cb) { + ByteStream output_params; + std::vector refresh_rates; + + const uint8_t *data = input_params.data(); + const DisplayType *dpy = reinterpret_cast(data); + int32_t error = intf_->GetSupportedDisplayRefreshRates(*dpy, &refresh_rates); + + uint32_t *refresh_rates_data = + reinterpret_cast(malloc(sizeof(uint32_t) * refresh_rates.size())); + for (int i = 0; i < refresh_rates.size(); i++) { + refresh_rates_data[i] = refresh_rates[i]; + } + output_params.setToExternal(reinterpret_cast(refresh_rates_data), + sizeof(uint32_t) * refresh_rates.size()); + _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) { @@ -889,6 +908,9 @@ Return DeviceImpl::perform(uint64_t client_handle, uint32_t op_code, case kGetDisplayHwId: client->ParseGetDisplayHwId(input_params, _hidl_cb); break; + case kGetSupportedDisplayRefreshRates: + client->ParseGetSupportedDisplayRefreshRates(input_params, _hidl_cb); + break; default: break; } diff --git a/services/config/src/device_impl.h b/services/config/src/device_impl.h index 85a31c55..a116f301 100644 --- a/services/config/src/device_impl.h +++ b/services/config/src/device_impl.h @@ -118,6 +118,7 @@ class DeviceImpl : public IDisplayConfig, public android::hardware::hidl_death_r perform_cb _hidl_cb); void ParseSendTUIEvent(const ByteStream &input_params, perform_cb _hidl_cb); void ParseGetDisplayHwId(const ByteStream &input_params, perform_cb _hidl_cb); + void ParseGetSupportedDisplayRefreshRates(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 6e0c5b72..6386cae9 100644 --- a/services/config/src/opcode_types.h +++ b/services/config/src/opcode_types.h @@ -77,6 +77,7 @@ enum OpCode { kControlQsyncCallback = 41, kSendTUIEvent = 42, kGetDisplayHwId = 43, + kGetSupportedDisplayRefreshRates = 44, kDestroy = 0xFFFF, // Destroy sequence execution };