2 * Copyright (C) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
20 #include "utils_android.h"
24 #include <android/log.h>
25 #include <cutils/properties.h>
26 #include <hardware/hardware.h>
27 #include <hardware/hwcomposer2.h>
28 #include <system/graphics.h>
30 #include <gpudevice.h>
32 #include <nativedisplay.h>
33 #include "mosaicdisplay.h"
42 class IAVsyncCallback : public hwcomposer::VsyncCallback {
44 IAVsyncCallback(hwc2_callback_data_t data, hwc2_function_pointer_t hook)
45 : data_(data), hook_(hook) {
48 void Callback(uint32_t display, int64_t timestamp) {
50 auto hook = reinterpret_cast<HWC2_PFN_VSYNC>(hook_);
51 hook(data_, display, timestamp);
56 hwc2_callback_data_t data_;
57 hwc2_function_pointer_t hook_;
60 class IARefreshCallback : public hwcomposer::RefreshCallback {
62 IARefreshCallback(hwc2_callback_data_t data, hwc2_function_pointer_t hook)
63 : data_(data), hook_(hook) {
66 void Callback(uint32_t display) {
68 auto hook = reinterpret_cast<HWC2_PFN_REFRESH>(hook_);
74 hwc2_callback_data_t data_;
75 hwc2_function_pointer_t hook_;
78 class IAHotPlugEventCallback : public hwcomposer::HotPlugCallback {
80 IAHotPlugEventCallback(hwc2_callback_data_t data,
81 hwc2_function_pointer_t hook,
82 IAHWC2::HwcDisplay *display)
83 : data_(data), hook_(hook), display_(display) {
86 void Callback(uint32_t display, bool connected) {
88 // SF expects primary display to be always
89 // connected. Let's notify it first time and ignore
90 // any followup status changes.
99 auto hook = reinterpret_cast<HWC2_PFN_HOTPLUG>(hook_);
100 int32_t status = static_cast<int32_t>(HWC2::Connection::Connected);
102 status = static_cast<int32_t>(HWC2::Connection::Disconnected);
106 "IAHotPlugEventCallback called displayid: %d status: %d \n", display,
109 hook(data_, display, status);
111 // FIXME: SurfaceFlinger doesn't seem to reset layers correctly
112 // when display is connected/disconnected. We force it here.
113 // Remove this workaround once fixed correctly in SurfaceFlinger.
114 if (!connected && display > 0) {
115 display_->FreeAllLayers();
120 hwc2_callback_data_t data_;
121 hwc2_function_pointer_t hook_;
122 IAHWC2::HwcDisplay *display_;
123 bool notified_ = false;
127 common.tag = HARDWARE_DEVICE_TAG;
128 common.version = HWC_DEVICE_API_VERSION_2_0;
129 common.close = HookDevClose;
130 getCapabilities = HookDevGetCapabilities;
131 getFunction = HookDevGetFunction;
134 HWC2::Error IAHWC2::Init() {
135 char value[PROPERTY_VALUE_MAX];
136 property_get("board.disable.explicit.sync", value, "0");
137 disable_explicit_sync_ = atoi(value);
138 if (disable_explicit_sync_)
139 ALOGI("EXPLICIT SYNC support is disabled");
141 ALOGI("EXPLICIT SYNC support is enabled");
143 property_get("board.hwc.scaling.mode", value, "2");
144 scaling_mode_ = atoi(value);
145 switch (scaling_mode_) {
147 ALOGI("HWC Scaling Mode Fast");
150 ALOGI("HWC Scaling Mode High Quality");
153 ALOGI("Unsupport HWC Scaling Mode");
157 if (!device_.Initialize()) {
158 ALOGE("Can't initialize drm object.");
159 return HWC2::Error::NoResources;
162 const std::vector<NativeDisplay *> &displays = device_.GetAllDisplays();
163 NativeDisplay *primary_display = displays.at(0);
164 uint32_t external_display_id = 1;
165 primary_display_.Init(primary_display, 0, disable_explicit_sync_,
167 size_t size = displays.size();
169 for (size_t i = 0; i < size; ++i) {
170 hwcomposer::NativeDisplay *display = displays.at(i);
171 if (display == primary_display)
174 std::unique_ptr<HwcDisplay> temp(new HwcDisplay());
175 temp->Init(display, external_display_id, disable_explicit_sync_,
177 extended_displays_.emplace_back(std::move(temp));
178 external_display_id++;
180 // Let's not confuse things with Virtual Display.
181 if (external_display_id == HWC_DISPLAY_VIRTUAL)
182 external_display_id = HWC_DISPLAY_VIRTUAL + 1;
185 // Start the hwc service
186 hwcService_.Start(*this);
188 return HWC2::Error::None;
191 template <typename... Args>
192 static inline HWC2::Error unsupported(char const *func, Args... /*args*/) {
193 ALOGV("Unsupported function: %s", func);
194 return HWC2::Error::Unsupported;
197 static inline void supported(char const *func) {
198 ALOGV("supported function: %s", func);
201 HWC2::Error IAHWC2::CreateVirtualDisplay(uint32_t width, uint32_t height,
203 hwc2_display_t *display) {
204 *display = (hwc2_display_t)(virtual_display_index_ + HWC_DISPLAY_VIRTUAL +
206 std::unique_ptr<HwcDisplay> temp(new HwcDisplay());
207 temp->InitVirtualDisplay(device_.CreateVirtualDisplay(virtual_display_index_),
208 width, height, virtual_display_index_,
209 disable_explicit_sync_);
210 virtual_displays_.emplace_back(std::move(temp));
211 virtual_display_index_++;
213 if (*format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
214 // fallback to RGBA_8888, align with framework requirement
215 *format = HAL_PIXEL_FORMAT_RGBA_8888;
218 return HWC2::Error::None;
221 HWC2::Error IAHWC2::DestroyVirtualDisplay(hwc2_display_t display) {
222 if (display < (hwc2_display_t)(HWC_DISPLAY_VIRTUAL + VDS_OFFSET)) {
223 ALOGE("Not Virtual Display Type in DestroyVirtualDisplay");
224 return HWC2::Error::BadDisplay;
227 device_.DestroyVirtualDisplay(display - HWC_DISPLAY_VIRTUAL - VDS_OFFSET);
228 virtual_displays_.at(display - HWC_DISPLAY_VIRTUAL - VDS_OFFSET)
231 return HWC2::Error::None;
234 void IAHWC2::Dump(uint32_t *size, char *buffer) {
235 // TODO: Implement dump
236 unsupported(__func__, size, buffer);
239 uint32_t IAHWC2::GetMaxVirtualDisplayCount() {
243 HWC2::Error IAHWC2::RegisterCallback(int32_t descriptor,
244 hwc2_callback_data_t data,
245 hwc2_function_pointer_t function) {
247 auto callback = static_cast<HWC2::Callback>(descriptor);
248 size_t size = extended_displays_.size();
249 HWC2::Error error = HWC2::Error::None;
252 case HWC2::Callback::Hotplug: {
253 primary_display_.RegisterHotPlugCallback(data, function);
254 for (size_t i = 0; i < size; ++i) {
255 IAHWC2::HwcDisplay *display = extended_displays_.at(i).get();
256 display->RegisterHotPlugCallback(data, function);
261 case HWC2::Callback::Vsync: {
262 primary_display_.RegisterVsyncCallback(data, function);
263 for (size_t i = 0; i < size; ++i) {
264 IAHWC2::HwcDisplay *display = extended_displays_.at(i).get();
265 display->RegisterVsyncCallback(data, function);
270 case HWC2::Callback::Refresh: {
271 primary_display_.RegisterRefreshCallback(data, function);
272 for (size_t i = 0; i < size; ++i) {
273 IAHWC2::HwcDisplay *display = extended_displays_.at(i).get();
274 display->RegisterRefreshCallback(data, function);
280 error = HWC2::Error::BadParameter;
286 IAHWC2::HwcDisplay::HwcDisplay()
289 type_(HWC2::DisplayType::Invalid),
291 check_validate_display_(false),
292 disable_explicit_sync_(false),
293 enable_nested_display_compose_(false),
298 // This function will be called only for Virtual Display Init
299 HWC2::Error IAHWC2::HwcDisplay::InitVirtualDisplay(
300 hwcomposer::NativeDisplay *display, uint32_t width, uint32_t height,
301 uint32_t display_index, bool disable_explicit_sync) {
304 type_ = HWC2::DisplayType::Virtual;
305 handle_ = display_index + HWC_DISPLAY_VIRTUAL + VDS_OFFSET;
306 display_->InitVirtualDisplay(width, height);
307 disable_explicit_sync_ = disable_explicit_sync;
308 display_->SetExplicitSyncSupport(disable_explicit_sync_);
309 return HWC2::Error::None;
312 HWC2::Error IAHWC2::HwcDisplay::Init(hwcomposer::NativeDisplay *display,
314 bool disable_explicit_sync,
315 uint32_t scaling_mode) {
318 type_ = HWC2::DisplayType::Physical;
319 handle_ = display_index;
321 disable_explicit_sync_ = disable_explicit_sync;
322 scaling_mode_ = scaling_mode;
323 display_->SetExplicitSyncSupport(disable_explicit_sync_);
324 display_->SetVideoScalingMode(scaling_mode_);
326 if (!display_->IsConnected()) {
327 return HWC2::Error::None;
329 // Fetch the number of modes from the display
330 uint32_t num_configs;
331 HWC2::Error err = GetDisplayConfigs(&num_configs, NULL);
332 if (err != HWC2::Error::None || !num_configs)
335 // Grab the first mode, we'll choose this as the active mode
336 hwc2_config_t default_config;
338 err = GetDisplayConfigs(&num_configs, &default_config);
339 if (err != HWC2::Error::None)
342 display_->InitializeLayerHashGenerator(32);
344 return SetActiveConfig(default_config);
347 HWC2::Error IAHWC2::HwcDisplay::RegisterVsyncCallback(
348 hwc2_callback_data_t data, hwc2_function_pointer_t func) {
350 auto callback = std::make_shared<IAVsyncCallback>(data, func);
351 int ret = display_->RegisterVsyncCallback(std::move(callback),
352 static_cast<int>(handle_));
354 ALOGE("Failed to register callback d=%" PRIu64 " ret=%d", handle_, ret);
355 return HWC2::Error::BadDisplay;
357 return HWC2::Error::None;
360 HWC2::Error IAHWC2::HwcDisplay::RegisterRefreshCallback(
361 hwc2_callback_data_t data, hwc2_function_pointer_t func) {
363 auto callback = std::make_shared<IARefreshCallback>(data, func);
364 display_->RegisterRefreshCallback(std::move(callback),
365 static_cast<int>(handle_));
366 return HWC2::Error::None;
369 HWC2::Error IAHWC2::HwcDisplay::RegisterHotPlugCallback(
370 hwc2_callback_data_t data, hwc2_function_pointer_t func) {
372 auto callback = std::make_shared<IAHotPlugEventCallback>(data, func, this);
373 display_->RegisterHotPlugCallback(std::move(callback),
374 static_cast<int>(handle_));
375 return HWC2::Error::None;
378 HWC2::Error IAHWC2::HwcDisplay::AcceptDisplayChanges() {
380 if (!check_validate_display_) {
381 ALOGV("AcceptChanges failed, not validated");
382 return HWC2::Error::NotValidated;
385 for (std::pair<const hwc2_layer_t, IAHWC2::Hwc2Layer> &l : layers_)
386 l.second.accept_type_change();
388 // reset the value to false
389 check_validate_display_ = false;
390 return HWC2::Error::None;
393 HWC2::Error IAHWC2::HwcDisplay::CreateLayer(hwc2_layer_t *layer) {
395 uint64_t id = display_->AcquireId();
396 layers_.emplace(static_cast<hwc2_layer_t>(id), IAHWC2::Hwc2Layer());
397 layers_.at(id).XTranslateCoordinates(display_->GetXTranslation());
398 layers_.at(id).YTranslateCoordinates(display_->GetYTranslation());
399 *layer = static_cast<hwc2_layer_t>(id);
400 return HWC2::Error::None;
403 HWC2::Error IAHWC2::HwcDisplay::DestroyLayer(hwc2_layer_t layer) {
406 return HWC2::Error::None;
408 if (layers_.erase(layer))
409 display_->ReleaseId(layer);
411 return HWC2::Error::None;
414 void IAHWC2::HwcDisplay::FreeAllLayers() {
418 display_->ResetLayerHashGenerator();
419 std::map<hwc2_layer_t, Hwc2Layer>().swap(layers_);
422 HWC2::Error IAHWC2::HwcDisplay::GetActiveConfig(hwc2_config_t *config) {
424 IHOTPLUGEVENTTRACE("GetActiveConfig called for Display: %p \n", display_);
426 if (!display_->GetActiveConfig(config))
427 return HWC2::Error::BadConfig;
429 return HWC2::Error::None;
432 HWC2::Error IAHWC2::HwcDisplay::GetChangedCompositionTypes(
433 uint32_t *num_elements, hwc2_layer_t *layers, int32_t *types) {
435 uint32_t num_changes = 0;
436 for (std::pair<const hwc2_layer_t, IAHWC2::Hwc2Layer> &l : layers_) {
437 if (l.second.type_changed()) {
438 if (layers && num_changes < *num_elements)
439 layers[num_changes] = l.first;
440 if (types && num_changes < *num_elements)
441 types[num_changes] = static_cast<int32_t>(l.second.validated_type());
445 if (!layers && !types)
446 *num_elements = num_changes;
447 return HWC2::Error::None;
450 HWC2::Error IAHWC2::HwcDisplay::GetClientTargetSupport(uint32_t width,
454 if (width != display_->Width() || height != display_->Height()) {
455 return HWC2::Error::Unsupported;
458 if (format == HAL_PIXEL_FORMAT_RGBA_8888 &&
459 (dataspace == HAL_DATASPACE_UNKNOWN ||
460 dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED)) {
461 return HWC2::Error::None;
463 // Convert HAL to fourcc-based DRM formats
464 uint32_t drm_format = GetDrmFormatFromHALFormat(format);
465 if (display_->CheckPlaneFormat(drm_format) &&
466 (dataspace == HAL_DATASPACE_UNKNOWN ||
467 dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED))
468 return HWC2::Error::None;
471 return HWC2::Error::Unsupported;
474 HWC2::Error IAHWC2::HwcDisplay::GetColorModes(uint32_t *num_modes,
481 *modes = HAL_COLOR_MODE_NATIVE;
483 return HWC2::Error::None;
486 HWC2::Error IAHWC2::HwcDisplay::GetDisplayAttribute(hwc2_config_t config,
487 int32_t attribute_in,
490 auto attribute = static_cast<HWC2::Attribute>(attribute_in);
492 case HWC2::Attribute::Width:
493 display_->GetDisplayAttribute(
494 config, hwcomposer::HWCDisplayAttribute::kWidth, value);
496 case HWC2::Attribute::Height:
497 display_->GetDisplayAttribute(
498 config, hwcomposer::HWCDisplayAttribute::kHeight, value);
500 case HWC2::Attribute::VsyncPeriod:
502 display_->GetDisplayAttribute(
503 config, hwcomposer::HWCDisplayAttribute::kRefreshRate, value);
505 case HWC2::Attribute::DpiX:
506 // Dots per 1000 inches
507 display_->GetDisplayAttribute(
508 config, hwcomposer::HWCDisplayAttribute::kDpiX, value);
510 case HWC2::Attribute::DpiY:
511 // Dots per 1000 inches
512 display_->GetDisplayAttribute(
513 config, hwcomposer::HWCDisplayAttribute::kDpiY, value);
517 return HWC2::Error::BadConfig;
519 return HWC2::Error::None;
522 HWC2::Error IAHWC2::HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
523 hwc2_config_t *configs) {
525 if (!display_->GetDisplayConfigs(num_configs, configs))
526 return HWC2::Error::BadDisplay;
528 return HWC2::Error::None;
531 HWC2::Error IAHWC2::HwcDisplay::GetDisplayName(uint32_t *size, char *name) {
533 if (!display_->GetDisplayName(size, name))
534 return HWC2::Error::BadDisplay;
536 return HWC2::Error::None;
539 HWC2::Error IAHWC2::HwcDisplay::GetDisplayRequests(int32_t *display_requests,
540 uint32_t *num_elements,
541 hwc2_layer_t *layers,
542 int32_t *layer_requests) {
544 // TODO: I think virtual display should request
545 // HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT here
546 unsupported(__func__, display_requests, num_elements, layers, layer_requests);
548 return HWC2::Error::None;
551 HWC2::Error IAHWC2::HwcDisplay::GetDisplayType(int32_t *type) {
553 *type = static_cast<int32_t>(type_);
554 return HWC2::Error::None;
557 HWC2::Error IAHWC2::HwcDisplay::GetDozeSupport(int32_t *support) {
560 return HWC2::Error::None;
563 HWC2::Error IAHWC2::HwcDisplay::GetHdrCapabilities(
564 uint32_t *num_types, int32_t * /*types*/, float * /*max_luminance*/,
565 float * /*max_average_luminance*/, float * /*min_luminance*/) {
568 return HWC2::Error::None;
571 HWC2::Error IAHWC2::HwcDisplay::GetReleaseFences(uint32_t *num_elements,
572 hwc2_layer_t *layers,
575 if (layers == NULL || fences == NULL) {
576 *num_elements = layers_.size();
577 return HWC2::Error::None;
580 uint32_t num_layers = 0;
581 for (std::pair<const hwc2_layer_t, IAHWC2::Hwc2Layer> &l : layers_) {
583 if (num_layers > *num_elements) {
584 ALOGW("Overflow num_elements %d/%d", num_layers, *num_elements);
585 return HWC2::Error::None;
588 layers[num_layers - 1] = l.first;
589 fences[num_layers - 1] = l.second.GetLayer()->GetReleaseFence();
592 *num_elements = num_layers;
593 return HWC2::Error::None;
596 HWC2::Error IAHWC2::HwcDisplay::PresentDisplay(int32_t *retire_fence) {
598 // order the layers by z-order
599 bool use_client_layer = false;
600 uint32_t client_z_order = 0;
601 bool use_cursor_layer = false;
602 uint32_t cursor_z_order = 0;
603 IAHWC2::Hwc2Layer *cursor_layer;
605 std::map<uint32_t, IAHWC2::Hwc2Layer *> z_map;
607 // if the power mode is doze suspend then its the hint that the drawing
608 // into the display has suspended and remain in the low power state and
609 // continue displaying the current state and stop applying display
610 // update from the client
611 if (display_->PowerMode() == HWC2_POWER_MODE_DOZE_SUSPEND)
612 return HWC2::Error::None;
613 for (std::pair<const hwc2_layer_t, IAHWC2::Hwc2Layer> &l : layers_) {
614 if (l.second.IsCursorLayer()) {
615 use_cursor_layer = true;
616 cursor_layer = &l.second;
617 cursor_z_order = l.second.z_order();
621 if ((l.second.validated_type() != HWC2::Composition::SolidColor) &&
622 (l.second.GetLayer()->GetNativeHandle() == NULL)) {
624 "HWC don't support layer without buffer if not in type SolidColor");
628 switch (l.second.validated_type()) {
629 case HWC2::Composition::Device:
630 case HWC2::Composition::SolidColor:
631 z_map.emplace(std::make_pair(l.second.z_order(), &l.second));
633 case HWC2::Composition::Client:
634 // Place it at the z_order of the highest client layer
635 use_client_layer = true;
636 client_z_order = std::max(client_z_order, l.second.z_order());
642 if (use_client_layer && client_layer_.GetLayer() &&
643 client_layer_.GetLayer()->GetNativeHandle() &&
644 client_layer_.GetLayer()->GetNativeHandle()->handle_) {
645 z_map.emplace(std::make_pair(client_z_order, &client_layer_));
648 // Place the cursor at the highest z-order
649 if (use_cursor_layer) {
651 if (z_map.rbegin()->second->z_order() > cursor_z_order)
652 cursor_z_order = z_map.rbegin()->second->z_order() + 1;
653 else if (client_z_order > cursor_z_order)
654 cursor_z_order = client_z_order + 1;
656 z_map.emplace(std::make_pair(cursor_z_order, cursor_layer));
659 std::vector<hwcomposer::HwcLayer *> layers;
660 // now that they're ordered by z, add them to the composition
661 for (std::pair<const uint32_t, IAHWC2::Hwc2Layer *> &l : z_map) {
662 layers.emplace_back(l.second->GetLayer());
666 return HWC2::Error::None;
668 IHOTPLUGEVENTTRACE("PhysicalDisplay called for Display: %p \n", display_);
670 bool success = display_->Present(layers, retire_fence);
672 ALOGE("Failed to set layers in the composition");
673 return HWC2::Error::BadLayer;
678 return HWC2::Error::None;
681 HWC2::Error IAHWC2::HwcDisplay::SetActiveConfig(hwc2_config_t config) {
683 if (!display_->SetActiveConfig(config)) {
684 ALOGE("Could not find active mode for %d", config);
685 return HWC2::Error::BadConfig;
688 // Setup the client layer's dimensions
689 hwc_rect_t display_frame = {.left = 0,
691 .right = static_cast<int>(display_->Width()),
692 .bottom = static_cast<int>(display_->Height())};
693 client_layer_.SetLayerDisplayFrame(display_frame);
694 hwc_frect_t source_crop = {.left = 0.0f,
696 .right = display_->Width() + 0.0f,
697 .bottom = display_->Height() + 0.0f};
698 client_layer_.SetLayerSourceCrop(source_crop);
700 return HWC2::Error::None;
703 HWC2::Error IAHWC2::HwcDisplay::SetClientTarget(buffer_handle_t target,
704 int32_t acquire_fence,
706 hwc_region_t damage) {
708 client_layer_.set_buffer(target);
709 client_layer_.set_acquire_fence(acquire_fence);
710 client_layer_.SetLayerDataspace(dataspace);
711 client_layer_.SetLayerSurfaceDamage(damage);
713 return HWC2::Error::None;
716 HWC2::Error IAHWC2::HwcDisplay::SetColorMode(int32_t mode) {
718 // TODO: Use the parameter mode to set the color mode for the display to be
721 return HWC2::Error::None;
724 HWC2::Error IAHWC2::HwcDisplay::SetColorTransform(const float *matrix,
727 // TODO: Force client composition if we get this
729 if (hint != HAL_COLOR_TRANSFORM_IDENTITY &&
730 hint != HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX &&
731 hint != HAL_COLOR_TRANSFORM_VALUE_INVERSE &&
732 hint != HAL_COLOR_TRANSFORM_GRAYSCALE &&
733 hint != HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA &&
734 hint != HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA &&
735 hint != HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA)
736 return HWC2::Error::BadParameter;
738 display_->SetColorTransform(matrix, (HWCColorTransform)hint);
740 return HWC2::Error::None;
743 HWC2::Error IAHWC2::HwcDisplay::SetOutputBuffer(buffer_handle_t buffer,
744 int32_t release_fence) {
747 struct gralloc_handle *temp = new struct gralloc_handle();
748 temp->handle_ = buffer;
749 display_->SetOutputBuffer(temp, release_fence);
750 return HWC2::Error::None;
753 HWC2::Error IAHWC2::HwcDisplay::SetPowerMode(int32_t mode_in) {
755 uint32_t power_mode = 0;
756 auto mode = static_cast<HWC2::PowerMode>(mode_in);
758 case HWC2::PowerMode::Off:
759 power_mode = HWC2_POWER_MODE_OFF;
761 case HWC2::PowerMode::Doze:
762 power_mode = HWC2_POWER_MODE_DOZE;
764 case HWC2::PowerMode::DozeSuspend:
765 power_mode = HWC2_POWER_MODE_DOZE_SUSPEND;
767 case HWC2::PowerMode::On:
768 power_mode = HWC2_POWER_MODE_ON;
771 ALOGI("Power mode %d is unsupported\n", mode);
772 return HWC2::Error::BadParameter;
775 display_->SetPowerMode(power_mode);
777 return HWC2::Error::None;
780 HWC2::Error IAHWC2::HwcDisplay::SetVsyncEnabled(int32_t enabled) {
783 case HWC2_VSYNC_ENABLE:
784 display_->VSyncControl(true);
786 case HWC2_VSYNC_DISABLE:
787 display_->VSyncControl(false);
790 ALOGE("SetVsyncEnabled called with invalid parameter");
791 return HWC2::Error::BadParameter;
793 return HWC2::Error::None;
796 HWC2::Error IAHWC2::HwcDisplay::ValidateDisplay(uint32_t *num_types,
797 uint32_t *num_requests) {
801 for (std::pair<const hwc2_layer_t, IAHWC2::Hwc2Layer> &l : layers_) {
802 IAHWC2::Hwc2Layer &layer = l.second;
804 switch (layer.sf_type()) {
805 case HWC2::Composition::Sideband:
806 layer.set_validated_type(HWC2::Composition::Client);
809 case HWC2::Composition::Cursor:
810 layer.set_validated_type(HWC2::Composition::Device);
814 if (disable_explicit_sync_ ||
815 display_->PowerMode() == HWC2_POWER_MODE_DOZE_SUSPEND) {
816 layer.set_validated_type(HWC2::Composition::Client);
818 layer.set_validated_type(layer.sf_type());
824 check_validate_display_ = true;
825 return HWC2::Error::None;
828 HWC2::Error IAHWC2::Hwc2Layer::SetCursorPosition(int32_t /*x*/, int32_t /*y*/) {
830 return HWC2::Error::None;
833 HWC2::Error IAHWC2::Hwc2Layer::SetLayerBlendMode(int32_t mode) {
835 switch (static_cast<HWC2::BlendMode>(mode)) {
836 case HWC2::BlendMode::None:
837 hwc_layer_.SetBlending(hwcomposer::HWCBlending::kBlendingNone);
839 case HWC2::BlendMode::Premultiplied:
840 hwc_layer_.SetBlending(hwcomposer::HWCBlending::kBlendingPremult);
842 case HWC2::BlendMode::Coverage:
843 hwc_layer_.SetBlending(hwcomposer::HWCBlending::kBlendingCoverage);
846 ALOGE("Unknown blending mode b=%d", mode);
847 hwc_layer_.SetBlending(hwcomposer::HWCBlending::kBlendingNone);
850 return HWC2::Error::None;
853 HWC2::Error IAHWC2::Hwc2Layer::SetLayerBuffer(buffer_handle_t buffer,
854 int32_t acquire_fence) {
857 // The buffer and acquire_fence are handled elsewhere
858 if (sf_type_ == HWC2::Composition::Client ||
859 sf_type_ == HWC2::Composition::Sideband)
860 return HWC2::Error::None;
862 native_handle_.handle_ = buffer;
863 hwc_layer_.SetNativeHandle(&native_handle_);
864 if (acquire_fence > 0)
865 hwc_layer_.SetAcquireFence(acquire_fence);
866 return HWC2::Error::None;
869 HWC2::Error IAHWC2::Hwc2Layer::SetLayerColor(hwc_color_t color) {
870 if (sf_type_ == HWC2::Composition::SolidColor) {
871 hwc_layer_.SetLayerCompositionType(hwcomposer::Composition_SolidColor);
872 hwc_layer_.SetSolidColor(color);
874 sf_type_ = HWC2::Composition::Client;
876 return HWC2::Error::None;
879 HWC2::Error IAHWC2::Hwc2Layer::SetLayerCompositionType(int32_t type) {
880 sf_type_ = static_cast<HWC2::Composition>(type);
881 if (sf_type_ == HWC2::Composition::Cursor) {
882 hwc_layer_.MarkAsCursorLayer();
885 return HWC2::Error::None;
888 HWC2::Error IAHWC2::Hwc2Layer::SetLayerDataspace(int32_t dataspace) {
890 dataspace_ = static_cast<android_dataspace_t>(dataspace);
891 return HWC2::Error::None;
894 HWC2::Error IAHWC2::Hwc2Layer::SetLayerDisplayFrame(hwc_rect_t frame) {
896 hwc_layer_.SetDisplayFrame(
897 hwcomposer::HwcRect<int>(frame.left, frame.top, frame.right,
899 x_translation_, y_translation_);
900 return HWC2::Error::None;
903 HWC2::Error IAHWC2::Hwc2Layer::SetLayerPlaneAlpha(float alpha) {
905 hwc_layer_.SetAlpha(static_cast<uint8_t>(255.0f * alpha + 0.5f));
906 return HWC2::Error::None;
909 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSidebandStream(
910 const native_handle_t *stream) {
912 // TODO: We don't support sideband
913 return unsupported(__func__, stream);
916 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSourceCrop(hwc_frect_t crop) {
918 hwc_layer_.SetSourceCrop(
919 hwcomposer::HwcRect<float>(crop.left, crop.top, crop.right, crop.bottom));
920 return HWC2::Error::None;
923 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSurfaceDamage(hwc_region_t damage) {
924 uint32_t num_rects = damage.numRects;
925 hwcomposer::HwcRegion hwc_region;
927 for (size_t rect = 0; rect < num_rects; ++rect) {
928 hwc_region.emplace_back(damage.rects[rect].left, damage.rects[rect].top,
929 damage.rects[rect].right,
930 damage.rects[rect].bottom);
933 hwc_layer_.SetSurfaceDamage(hwc_region);
935 return HWC2::Error::None;
938 HWC2::Error IAHWC2::Hwc2Layer::SetLayerTransform(int32_t transform) {
940 // 270* and 180* cannot be combined with flips. More specifically, they
941 // already contain both horizontal and vertical flips, so those fields are
942 // redundant in this case. 90* rotation can be combined with either horizontal
943 // flip or vertical flip, so treat it differently
945 if (transform == HWC_TRANSFORM_ROT_270) {
946 temp = hwcomposer::HWCTransform::kTransform270;
947 } else if (transform == HWC_TRANSFORM_ROT_180) {
948 temp = hwcomposer::HWCTransform::kTransform180;
950 if (transform & HWC_TRANSFORM_FLIP_H)
951 temp |= hwcomposer::HWCTransform::kReflectX;
952 if (transform & HWC_TRANSFORM_FLIP_V)
953 temp |= hwcomposer::HWCTransform::kReflectY;
954 if (transform & HWC_TRANSFORM_ROT_90)
955 temp |= hwcomposer::HWCTransform::kTransform90;
957 hwc_layer_.SetTransform(temp);
958 return HWC2::Error::None;
961 HWC2::Error IAHWC2::Hwc2Layer::SetLayerVisibleRegion(hwc_region_t visible) {
962 uint32_t num_rects = visible.numRects;
963 hwcomposer::HwcRegion hwc_region;
965 for (size_t rect = 0; rect < num_rects; ++rect) {
966 hwc_region.emplace_back(visible.rects[rect].left, visible.rects[rect].top,
967 visible.rects[rect].right,
968 visible.rects[rect].bottom);
971 hwc_layer_.SetVisibleRegion(hwc_region);
972 return HWC2::Error::None;
975 HWC2::Error IAHWC2::Hwc2Layer::SetLayerZOrder(uint32_t order) {
978 hwc_layer_.SetLayerZOrder(order);
979 return HWC2::Error::None;
983 int IAHWC2::HookDevClose(hw_device_t * /*dev*/) {
984 unsupported(__func__);
989 void IAHWC2::HookDevGetCapabilities(hwc2_device_t * /*dev*/,
991 int32_t * /*out_capabilities*/) {
997 hwc2_function_pointer_t IAHWC2::HookDevGetFunction(struct hwc2_device * /*dev*/,
998 int32_t descriptor) {
1000 auto func = static_cast<HWC2::FunctionDescriptor>(descriptor);
1003 case HWC2::FunctionDescriptor::CreateVirtualDisplay:
1004 return ToHook<HWC2_PFN_CREATE_VIRTUAL_DISPLAY>(
1005 DeviceHook<int32_t, decltype(&IAHWC2::CreateVirtualDisplay),
1006 &IAHWC2::CreateVirtualDisplay, uint32_t, uint32_t,
1007 int32_t *, hwc2_display_t *>);
1008 case HWC2::FunctionDescriptor::DestroyVirtualDisplay:
1009 return ToHook<HWC2_PFN_DESTROY_VIRTUAL_DISPLAY>(
1010 DeviceHook<int32_t, decltype(&IAHWC2::DestroyVirtualDisplay),
1011 &IAHWC2::DestroyVirtualDisplay, hwc2_display_t>);
1012 case HWC2::FunctionDescriptor::Dump:
1013 return ToHook<HWC2_PFN_DUMP>(DeviceHook<
1014 void, decltype(&IAHWC2::Dump), &IAHWC2::Dump, uint32_t *, char *>);
1015 case HWC2::FunctionDescriptor::GetMaxVirtualDisplayCount:
1016 return ToHook<HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT>(
1017 DeviceHook<uint32_t, decltype(&IAHWC2::GetMaxVirtualDisplayCount),
1018 &IAHWC2::GetMaxVirtualDisplayCount>);
1019 case HWC2::FunctionDescriptor::RegisterCallback:
1020 return ToHook<HWC2_PFN_REGISTER_CALLBACK>(
1021 DeviceHook<int32_t, decltype(&IAHWC2::RegisterCallback),
1022 &IAHWC2::RegisterCallback, int32_t, hwc2_callback_data_t,
1023 hwc2_function_pointer_t>);
1025 // Display functions
1026 case HWC2::FunctionDescriptor::AcceptDisplayChanges:
1027 return ToHook<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>(
1028 DisplayHook<decltype(&HwcDisplay::AcceptDisplayChanges),
1029 &HwcDisplay::AcceptDisplayChanges>);
1030 case HWC2::FunctionDescriptor::CreateLayer:
1031 return ToHook<HWC2_PFN_CREATE_LAYER>(
1032 DisplayHook<decltype(&HwcDisplay::CreateLayer),
1033 &HwcDisplay::CreateLayer, hwc2_layer_t *>);
1034 case HWC2::FunctionDescriptor::DestroyLayer:
1035 return ToHook<HWC2_PFN_DESTROY_LAYER>(
1036 DisplayHook<decltype(&HwcDisplay::DestroyLayer),
1037 &HwcDisplay::DestroyLayer, hwc2_layer_t>);
1038 case HWC2::FunctionDescriptor::GetActiveConfig:
1039 return ToHook<HWC2_PFN_GET_ACTIVE_CONFIG>(
1040 DisplayHook<decltype(&HwcDisplay::GetActiveConfig),
1041 &HwcDisplay::GetActiveConfig, hwc2_config_t *>);
1042 case HWC2::FunctionDescriptor::GetChangedCompositionTypes:
1043 return ToHook<HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES>(
1044 DisplayHook<decltype(&HwcDisplay::GetChangedCompositionTypes),
1045 &HwcDisplay::GetChangedCompositionTypes, uint32_t *,
1046 hwc2_layer_t *, int32_t *>);
1047 case HWC2::FunctionDescriptor::GetClientTargetSupport:
1048 return ToHook<HWC2_PFN_GET_CLIENT_TARGET_SUPPORT>(
1049 DisplayHook<decltype(&HwcDisplay::GetClientTargetSupport),
1050 &HwcDisplay::GetClientTargetSupport, uint32_t, uint32_t,
1052 case HWC2::FunctionDescriptor::GetColorModes:
1053 return ToHook<HWC2_PFN_GET_COLOR_MODES>(
1054 DisplayHook<decltype(&HwcDisplay::GetColorModes),
1055 &HwcDisplay::GetColorModes, uint32_t *, int32_t *>);
1056 case HWC2::FunctionDescriptor::GetDisplayAttribute:
1057 return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>(DisplayHook<
1058 decltype(&HwcDisplay::GetDisplayAttribute),
1059 &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t, int32_t *>);
1060 case HWC2::FunctionDescriptor::GetDisplayConfigs:
1061 return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>(DisplayHook<
1062 decltype(&HwcDisplay::GetDisplayConfigs),
1063 &HwcDisplay::GetDisplayConfigs, uint32_t *, hwc2_config_t *>);
1064 case HWC2::FunctionDescriptor::GetDisplayName:
1065 return ToHook<HWC2_PFN_GET_DISPLAY_NAME>(
1066 DisplayHook<decltype(&HwcDisplay::GetDisplayName),
1067 &HwcDisplay::GetDisplayName, uint32_t *, char *>);
1068 case HWC2::FunctionDescriptor::GetDisplayRequests:
1069 return ToHook<HWC2_PFN_GET_DISPLAY_REQUESTS>(
1070 DisplayHook<decltype(&HwcDisplay::GetDisplayRequests),
1071 &HwcDisplay::GetDisplayRequests, int32_t *, uint32_t *,
1072 hwc2_layer_t *, int32_t *>);
1073 case HWC2::FunctionDescriptor::GetDisplayType:
1074 return ToHook<HWC2_PFN_GET_DISPLAY_TYPE>(
1075 DisplayHook<decltype(&HwcDisplay::GetDisplayType),
1076 &HwcDisplay::GetDisplayType, int32_t *>);
1077 case HWC2::FunctionDescriptor::GetDozeSupport:
1078 return ToHook<HWC2_PFN_GET_DOZE_SUPPORT>(
1079 DisplayHook<decltype(&HwcDisplay::GetDozeSupport),
1080 &HwcDisplay::GetDozeSupport, int32_t *>);
1081 case HWC2::FunctionDescriptor::GetHdrCapabilities:
1082 return ToHook<HWC2_PFN_GET_HDR_CAPABILITIES>(
1083 DisplayHook<decltype(&HwcDisplay::GetHdrCapabilities),
1084 &HwcDisplay::GetHdrCapabilities, uint32_t *, int32_t *,
1085 float *, float *, float *>);
1086 case HWC2::FunctionDescriptor::GetReleaseFences:
1087 return ToHook<HWC2_PFN_GET_RELEASE_FENCES>(
1088 DisplayHook<decltype(&HwcDisplay::GetReleaseFences),
1089 &HwcDisplay::GetReleaseFences, uint32_t *, hwc2_layer_t *,
1091 case HWC2::FunctionDescriptor::PresentDisplay:
1092 return ToHook<HWC2_PFN_PRESENT_DISPLAY>(
1093 DisplayHook<decltype(&HwcDisplay::PresentDisplay),
1094 &HwcDisplay::PresentDisplay, int32_t *>);
1095 case HWC2::FunctionDescriptor::SetActiveConfig:
1096 return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG>(
1097 DisplayHook<decltype(&HwcDisplay::SetActiveConfig),
1098 &HwcDisplay::SetActiveConfig, hwc2_config_t>);
1099 case HWC2::FunctionDescriptor::SetClientTarget:
1100 return ToHook<HWC2_PFN_SET_CLIENT_TARGET>(DisplayHook<
1101 decltype(&HwcDisplay::SetClientTarget), &HwcDisplay::SetClientTarget,
1102 buffer_handle_t, int32_t, int32_t, hwc_region_t>);
1103 case HWC2::FunctionDescriptor::SetColorMode:
1104 return ToHook<HWC2_PFN_SET_COLOR_MODE>(
1105 DisplayHook<decltype(&HwcDisplay::SetColorMode),
1106 &HwcDisplay::SetColorMode, int32_t>);
1107 case HWC2::FunctionDescriptor::SetColorTransform:
1108 return ToHook<HWC2_PFN_SET_COLOR_TRANSFORM>(
1109 DisplayHook<decltype(&HwcDisplay::SetColorTransform),
1110 &HwcDisplay::SetColorTransform, const float *, int32_t>);
1111 case HWC2::FunctionDescriptor::SetOutputBuffer:
1112 return ToHook<HWC2_PFN_SET_OUTPUT_BUFFER>(
1113 DisplayHook<decltype(&HwcDisplay::SetOutputBuffer),
1114 &HwcDisplay::SetOutputBuffer, buffer_handle_t, int32_t>);
1115 case HWC2::FunctionDescriptor::SetPowerMode:
1116 return ToHook<HWC2_PFN_SET_POWER_MODE>(
1117 DisplayHook<decltype(&HwcDisplay::SetPowerMode),
1118 &HwcDisplay::SetPowerMode, int32_t>);
1119 case HWC2::FunctionDescriptor::SetVsyncEnabled:
1120 return ToHook<HWC2_PFN_SET_VSYNC_ENABLED>(
1121 DisplayHook<decltype(&HwcDisplay::SetVsyncEnabled),
1122 &HwcDisplay::SetVsyncEnabled, int32_t>);
1123 case HWC2::FunctionDescriptor::ValidateDisplay:
1124 return ToHook<HWC2_PFN_VALIDATE_DISPLAY>(
1125 DisplayHook<decltype(&HwcDisplay::ValidateDisplay),
1126 &HwcDisplay::ValidateDisplay, uint32_t *, uint32_t *>);
1129 case HWC2::FunctionDescriptor::SetCursorPosition:
1130 return ToHook<HWC2_PFN_SET_CURSOR_POSITION>(
1131 LayerHook<decltype(&Hwc2Layer::SetCursorPosition),
1132 &Hwc2Layer::SetCursorPosition, int32_t, int32_t>);
1133 case HWC2::FunctionDescriptor::SetLayerBlendMode:
1134 return ToHook<HWC2_PFN_SET_LAYER_BLEND_MODE>(
1135 LayerHook<decltype(&Hwc2Layer::SetLayerBlendMode),
1136 &Hwc2Layer::SetLayerBlendMode, int32_t>);
1137 case HWC2::FunctionDescriptor::SetLayerBuffer:
1138 return ToHook<HWC2_PFN_SET_LAYER_BUFFER>(
1139 LayerHook<decltype(&Hwc2Layer::SetLayerBuffer),
1140 &Hwc2Layer::SetLayerBuffer, buffer_handle_t, int32_t>);
1141 case HWC2::FunctionDescriptor::SetLayerColor:
1142 return ToHook<HWC2_PFN_SET_LAYER_COLOR>(
1143 LayerHook<decltype(&Hwc2Layer::SetLayerColor),
1144 &Hwc2Layer::SetLayerColor, hwc_color_t>);
1145 case HWC2::FunctionDescriptor::SetLayerCompositionType:
1146 return ToHook<HWC2_PFN_SET_LAYER_COMPOSITION_TYPE>(
1147 LayerHook<decltype(&Hwc2Layer::SetLayerCompositionType),
1148 &Hwc2Layer::SetLayerCompositionType, int32_t>);
1149 case HWC2::FunctionDescriptor::SetLayerDataspace:
1150 return ToHook<HWC2_PFN_SET_LAYER_DATASPACE>(
1151 LayerHook<decltype(&Hwc2Layer::SetLayerDataspace),
1152 &Hwc2Layer::SetLayerDataspace, int32_t>);
1153 case HWC2::FunctionDescriptor::SetLayerDisplayFrame:
1154 return ToHook<HWC2_PFN_SET_LAYER_DISPLAY_FRAME>(
1155 LayerHook<decltype(&Hwc2Layer::SetLayerDisplayFrame),
1156 &Hwc2Layer::SetLayerDisplayFrame, hwc_rect_t>);
1157 case HWC2::FunctionDescriptor::SetLayerPlaneAlpha:
1158 return ToHook<HWC2_PFN_SET_LAYER_PLANE_ALPHA>(
1159 LayerHook<decltype(&Hwc2Layer::SetLayerPlaneAlpha),
1160 &Hwc2Layer::SetLayerPlaneAlpha, float>);
1161 case HWC2::FunctionDescriptor::SetLayerSidebandStream:
1162 return ToHook<HWC2_PFN_SET_LAYER_SIDEBAND_STREAM>(LayerHook<
1163 decltype(&Hwc2Layer::SetLayerSidebandStream),
1164 &Hwc2Layer::SetLayerSidebandStream, const native_handle_t *>);
1165 case HWC2::FunctionDescriptor::SetLayerSourceCrop:
1166 return ToHook<HWC2_PFN_SET_LAYER_SOURCE_CROP>(
1167 LayerHook<decltype(&Hwc2Layer::SetLayerSourceCrop),
1168 &Hwc2Layer::SetLayerSourceCrop, hwc_frect_t>);
1169 case HWC2::FunctionDescriptor::SetLayerSurfaceDamage:
1170 return ToHook<HWC2_PFN_SET_LAYER_SURFACE_DAMAGE>(
1171 LayerHook<decltype(&Hwc2Layer::SetLayerSurfaceDamage),
1172 &Hwc2Layer::SetLayerSurfaceDamage, hwc_region_t>);
1173 case HWC2::FunctionDescriptor::SetLayerTransform:
1174 return ToHook<HWC2_PFN_SET_LAYER_TRANSFORM>(
1175 LayerHook<decltype(&Hwc2Layer::SetLayerTransform),
1176 &Hwc2Layer::SetLayerTransform, int32_t>);
1177 case HWC2::FunctionDescriptor::SetLayerVisibleRegion:
1178 return ToHook<HWC2_PFN_SET_LAYER_VISIBLE_REGION>(
1179 LayerHook<decltype(&Hwc2Layer::SetLayerVisibleRegion),
1180 &Hwc2Layer::SetLayerVisibleRegion, hwc_region_t>);
1181 case HWC2::FunctionDescriptor::SetLayerZOrder:
1182 return ToHook<HWC2_PFN_SET_LAYER_Z_ORDER>(
1183 LayerHook<decltype(&Hwc2Layer::SetLayerZOrder),
1184 &Hwc2Layer::SetLayerZOrder, uint32_t>);
1185 case HWC2::FunctionDescriptor::Invalid:
1192 int IAHWC2::HookDevOpen(const struct hw_module_t *module, const char *name,
1193 struct hw_device_t **dev) {
1194 supported(__func__);
1195 if (strcmp(name, HWC_HARDWARE_COMPOSER)) {
1196 ALOGE("Invalid module name- %s", name);
1200 std::unique_ptr<IAHWC2> ctx(new IAHWC2());
1202 ALOGE("Failed to allocate IAHWC2");
1206 HWC2::Error err = ctx->Init();
1207 if (err != HWC2::Error::None) {
1208 ALOGE("Failed to initialize IAHWC2 err=%d\n", err);
1212 ctx->common.module = const_cast<hw_module_t *>(module);
1213 *dev = &ctx->common;
1218 hwcomposer::NativeDisplay *IAHWC2::GetExtendedDisplay(uint32_t dispIndex) {
1219 return extended_displays_.at(dispIndex)->GetDisplay();
1222 hwcomposer::NativeDisplay *IAHWC2::GetPrimaryDisplay() {
1223 return primary_display_.GetDisplay();
1226 hwcomposer::NativeDisplay *IAHWC2::HwcDisplay::GetDisplay() {
1230 void IAHWC2::EnableHDCPSessionForDisplay(uint32_t connector,
1231 EHwcsContentType content_type) {
1232 HWCContentType type = kCONTENT_TYPE0;
1233 if (content_type == HWCS_CP_CONTENT_TYPE1) {
1234 type = kCONTENT_TYPE1;
1237 device_.EnableHDCPSessionForDisplay(connector, type);
1240 void IAHWC2::EnableHDCPSessionForAllDisplays(EHwcsContentType content_type) {
1241 HWCContentType type = kCONTENT_TYPE0;
1242 if (content_type == HWCS_CP_CONTENT_TYPE1) {
1243 type = kCONTENT_TYPE1;
1245 device_.EnableHDCPSessionForAllDisplays(type);
1248 void IAHWC2::DisableHDCPSessionForDisplay(uint32_t connector) {
1249 device_.DisableHDCPSessionForDisplay(connector);
1252 void IAHWC2::DisableHDCPSessionForAllDisplays() {
1253 device_.DisableHDCPSessionForAllDisplays();
1256 void IAHWC2::SetPAVPSessionStatus(bool enabled, uint32_t papv_session_id,
1257 uint32_t pavp_instance_id) {
1258 device_.SetPAVPSessionStatus(enabled, papv_session_id, pavp_instance_id);
1261 void IAHWC2::SetHDCPSRMForAllDisplays(const int8_t *SRM, uint32_t SRMLength) {
1263 ETRACE("Error:HDCP Set NULL SRM");
1266 device_.SetHDCPSRMForAllDisplays(SRM, SRMLength);
1269 uint32_t IAHWC2::GetDisplayIDFromConnectorID(const uint32_t connector_id) {
1270 return device_.GetDisplayIDFromConnectorID(connector_id);
1273 void IAHWC2::SetHDCPSRMForDisplay(uint32_t connector, const int8_t *SRM,
1274 uint32_t SRMLength) {
1276 ETRACE("Error:HDCP Set NULL SRM");
1279 device_.SetHDCPSRMForDisplay(connector, SRM, SRMLength);
1282 } // namespace android
1284 static struct hw_module_methods_t hwc2_module_methods = {
1285 .open = android::IAHWC2::HookDevOpen,
1288 hw_module_t HAL_MODULE_INFO_SYM = {
1289 .tag = HARDWARE_MODULE_TAG,
1290 .module_api_version = HARDWARE_MODULE_API_VERSION(2, 0),
1291 .id = HWC_HARDWARE_MODULE_ID,
1292 .name = "IA-Hardware-Composer",
1293 .author = "The Android Open Source Project",
1294 .methods = &hwc2_module_methods,