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 uint32_t hwc_layer_color = (uint32_t)color.r << 24 |
873 (uint32_t)color.g << 16 |
874 (uint32_t)color.b << 8 | (uint32_t)color.a;
875 hwc_layer_.SetSolidColor(hwc_layer_color);
877 sf_type_ = HWC2::Composition::Client;
879 return HWC2::Error::None;
882 HWC2::Error IAHWC2::Hwc2Layer::SetLayerCompositionType(int32_t type) {
883 sf_type_ = static_cast<HWC2::Composition>(type);
884 if (sf_type_ == HWC2::Composition::Cursor) {
885 hwc_layer_.MarkAsCursorLayer();
888 return HWC2::Error::None;
891 HWC2::Error IAHWC2::Hwc2Layer::SetLayerDataspace(int32_t dataspace) {
893 dataspace_ = static_cast<android_dataspace_t>(dataspace);
894 return HWC2::Error::None;
897 HWC2::Error IAHWC2::Hwc2Layer::SetLayerDisplayFrame(hwc_rect_t frame) {
899 hwc_layer_.SetDisplayFrame(
900 hwcomposer::HwcRect<int>(frame.left, frame.top, frame.right,
902 x_translation_, y_translation_);
903 return HWC2::Error::None;
906 HWC2::Error IAHWC2::Hwc2Layer::SetLayerPlaneAlpha(float alpha) {
908 hwc_layer_.SetAlpha(static_cast<uint8_t>(255.0f * alpha + 0.5f));
909 return HWC2::Error::None;
912 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSidebandStream(
913 const native_handle_t *stream) {
915 // TODO: We don't support sideband
916 return unsupported(__func__, stream);
919 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSourceCrop(hwc_frect_t crop) {
921 hwc_layer_.SetSourceCrop(
922 hwcomposer::HwcRect<float>(crop.left, crop.top, crop.right, crop.bottom));
923 return HWC2::Error::None;
926 HWC2::Error IAHWC2::Hwc2Layer::SetLayerSurfaceDamage(hwc_region_t damage) {
927 uint32_t num_rects = damage.numRects;
928 hwcomposer::HwcRegion hwc_region;
930 for (size_t rect = 0; rect < num_rects; ++rect) {
931 hwc_region.emplace_back(damage.rects[rect].left, damage.rects[rect].top,
932 damage.rects[rect].right,
933 damage.rects[rect].bottom);
936 hwc_layer_.SetSurfaceDamage(hwc_region);
938 return HWC2::Error::None;
941 HWC2::Error IAHWC2::Hwc2Layer::SetLayerTransform(int32_t transform) {
943 // 270* and 180* cannot be combined with flips. More specifically, they
944 // already contain both horizontal and vertical flips, so those fields are
945 // redundant in this case. 90* rotation can be combined with either horizontal
946 // flip or vertical flip, so treat it differently
948 if (transform == HWC_TRANSFORM_ROT_270) {
949 temp = hwcomposer::HWCTransform::kTransform270;
950 } else if (transform == HWC_TRANSFORM_ROT_180) {
951 temp = hwcomposer::HWCTransform::kTransform180;
953 if (transform & HWC_TRANSFORM_FLIP_H)
954 temp |= hwcomposer::HWCTransform::kReflectX;
955 if (transform & HWC_TRANSFORM_FLIP_V)
956 temp |= hwcomposer::HWCTransform::kReflectY;
957 if (transform & HWC_TRANSFORM_ROT_90)
958 temp |= hwcomposer::HWCTransform::kTransform90;
960 hwc_layer_.SetTransform(temp);
961 return HWC2::Error::None;
964 HWC2::Error IAHWC2::Hwc2Layer::SetLayerVisibleRegion(hwc_region_t visible) {
965 uint32_t num_rects = visible.numRects;
966 hwcomposer::HwcRegion hwc_region;
968 for (size_t rect = 0; rect < num_rects; ++rect) {
969 hwc_region.emplace_back(visible.rects[rect].left, visible.rects[rect].top,
970 visible.rects[rect].right,
971 visible.rects[rect].bottom);
974 hwc_layer_.SetVisibleRegion(hwc_region);
975 return HWC2::Error::None;
978 HWC2::Error IAHWC2::Hwc2Layer::SetLayerZOrder(uint32_t order) {
981 hwc_layer_.SetLayerZOrder(order);
982 return HWC2::Error::None;
986 int IAHWC2::HookDevClose(hw_device_t * /*dev*/) {
987 unsupported(__func__);
992 void IAHWC2::HookDevGetCapabilities(hwc2_device_t * /*dev*/,
994 int32_t * /*out_capabilities*/) {
1000 hwc2_function_pointer_t IAHWC2::HookDevGetFunction(struct hwc2_device * /*dev*/,
1001 int32_t descriptor) {
1002 supported(__func__);
1003 auto func = static_cast<HWC2::FunctionDescriptor>(descriptor);
1006 case HWC2::FunctionDescriptor::CreateVirtualDisplay:
1007 return ToHook<HWC2_PFN_CREATE_VIRTUAL_DISPLAY>(
1008 DeviceHook<int32_t, decltype(&IAHWC2::CreateVirtualDisplay),
1009 &IAHWC2::CreateVirtualDisplay, uint32_t, uint32_t,
1010 int32_t *, hwc2_display_t *>);
1011 case HWC2::FunctionDescriptor::DestroyVirtualDisplay:
1012 return ToHook<HWC2_PFN_DESTROY_VIRTUAL_DISPLAY>(
1013 DeviceHook<int32_t, decltype(&IAHWC2::DestroyVirtualDisplay),
1014 &IAHWC2::DestroyVirtualDisplay, hwc2_display_t>);
1015 case HWC2::FunctionDescriptor::Dump:
1016 return ToHook<HWC2_PFN_DUMP>(DeviceHook<
1017 void, decltype(&IAHWC2::Dump), &IAHWC2::Dump, uint32_t *, char *>);
1018 case HWC2::FunctionDescriptor::GetMaxVirtualDisplayCount:
1019 return ToHook<HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT>(
1020 DeviceHook<uint32_t, decltype(&IAHWC2::GetMaxVirtualDisplayCount),
1021 &IAHWC2::GetMaxVirtualDisplayCount>);
1022 case HWC2::FunctionDescriptor::RegisterCallback:
1023 return ToHook<HWC2_PFN_REGISTER_CALLBACK>(
1024 DeviceHook<int32_t, decltype(&IAHWC2::RegisterCallback),
1025 &IAHWC2::RegisterCallback, int32_t, hwc2_callback_data_t,
1026 hwc2_function_pointer_t>);
1028 // Display functions
1029 case HWC2::FunctionDescriptor::AcceptDisplayChanges:
1030 return ToHook<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>(
1031 DisplayHook<decltype(&HwcDisplay::AcceptDisplayChanges),
1032 &HwcDisplay::AcceptDisplayChanges>);
1033 case HWC2::FunctionDescriptor::CreateLayer:
1034 return ToHook<HWC2_PFN_CREATE_LAYER>(
1035 DisplayHook<decltype(&HwcDisplay::CreateLayer),
1036 &HwcDisplay::CreateLayer, hwc2_layer_t *>);
1037 case HWC2::FunctionDescriptor::DestroyLayer:
1038 return ToHook<HWC2_PFN_DESTROY_LAYER>(
1039 DisplayHook<decltype(&HwcDisplay::DestroyLayer),
1040 &HwcDisplay::DestroyLayer, hwc2_layer_t>);
1041 case HWC2::FunctionDescriptor::GetActiveConfig:
1042 return ToHook<HWC2_PFN_GET_ACTIVE_CONFIG>(
1043 DisplayHook<decltype(&HwcDisplay::GetActiveConfig),
1044 &HwcDisplay::GetActiveConfig, hwc2_config_t *>);
1045 case HWC2::FunctionDescriptor::GetChangedCompositionTypes:
1046 return ToHook<HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES>(
1047 DisplayHook<decltype(&HwcDisplay::GetChangedCompositionTypes),
1048 &HwcDisplay::GetChangedCompositionTypes, uint32_t *,
1049 hwc2_layer_t *, int32_t *>);
1050 case HWC2::FunctionDescriptor::GetClientTargetSupport:
1051 return ToHook<HWC2_PFN_GET_CLIENT_TARGET_SUPPORT>(
1052 DisplayHook<decltype(&HwcDisplay::GetClientTargetSupport),
1053 &HwcDisplay::GetClientTargetSupport, uint32_t, uint32_t,
1055 case HWC2::FunctionDescriptor::GetColorModes:
1056 return ToHook<HWC2_PFN_GET_COLOR_MODES>(
1057 DisplayHook<decltype(&HwcDisplay::GetColorModes),
1058 &HwcDisplay::GetColorModes, uint32_t *, int32_t *>);
1059 case HWC2::FunctionDescriptor::GetDisplayAttribute:
1060 return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>(DisplayHook<
1061 decltype(&HwcDisplay::GetDisplayAttribute),
1062 &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t, int32_t *>);
1063 case HWC2::FunctionDescriptor::GetDisplayConfigs:
1064 return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>(DisplayHook<
1065 decltype(&HwcDisplay::GetDisplayConfigs),
1066 &HwcDisplay::GetDisplayConfigs, uint32_t *, hwc2_config_t *>);
1067 case HWC2::FunctionDescriptor::GetDisplayName:
1068 return ToHook<HWC2_PFN_GET_DISPLAY_NAME>(
1069 DisplayHook<decltype(&HwcDisplay::GetDisplayName),
1070 &HwcDisplay::GetDisplayName, uint32_t *, char *>);
1071 case HWC2::FunctionDescriptor::GetDisplayRequests:
1072 return ToHook<HWC2_PFN_GET_DISPLAY_REQUESTS>(
1073 DisplayHook<decltype(&HwcDisplay::GetDisplayRequests),
1074 &HwcDisplay::GetDisplayRequests, int32_t *, uint32_t *,
1075 hwc2_layer_t *, int32_t *>);
1076 case HWC2::FunctionDescriptor::GetDisplayType:
1077 return ToHook<HWC2_PFN_GET_DISPLAY_TYPE>(
1078 DisplayHook<decltype(&HwcDisplay::GetDisplayType),
1079 &HwcDisplay::GetDisplayType, int32_t *>);
1080 case HWC2::FunctionDescriptor::GetDozeSupport:
1081 return ToHook<HWC2_PFN_GET_DOZE_SUPPORT>(
1082 DisplayHook<decltype(&HwcDisplay::GetDozeSupport),
1083 &HwcDisplay::GetDozeSupport, int32_t *>);
1084 case HWC2::FunctionDescriptor::GetHdrCapabilities:
1085 return ToHook<HWC2_PFN_GET_HDR_CAPABILITIES>(
1086 DisplayHook<decltype(&HwcDisplay::GetHdrCapabilities),
1087 &HwcDisplay::GetHdrCapabilities, uint32_t *, int32_t *,
1088 float *, float *, float *>);
1089 case HWC2::FunctionDescriptor::GetReleaseFences:
1090 return ToHook<HWC2_PFN_GET_RELEASE_FENCES>(
1091 DisplayHook<decltype(&HwcDisplay::GetReleaseFences),
1092 &HwcDisplay::GetReleaseFences, uint32_t *, hwc2_layer_t *,
1094 case HWC2::FunctionDescriptor::PresentDisplay:
1095 return ToHook<HWC2_PFN_PRESENT_DISPLAY>(
1096 DisplayHook<decltype(&HwcDisplay::PresentDisplay),
1097 &HwcDisplay::PresentDisplay, int32_t *>);
1098 case HWC2::FunctionDescriptor::SetActiveConfig:
1099 return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG>(
1100 DisplayHook<decltype(&HwcDisplay::SetActiveConfig),
1101 &HwcDisplay::SetActiveConfig, hwc2_config_t>);
1102 case HWC2::FunctionDescriptor::SetClientTarget:
1103 return ToHook<HWC2_PFN_SET_CLIENT_TARGET>(DisplayHook<
1104 decltype(&HwcDisplay::SetClientTarget), &HwcDisplay::SetClientTarget,
1105 buffer_handle_t, int32_t, int32_t, hwc_region_t>);
1106 case HWC2::FunctionDescriptor::SetColorMode:
1107 return ToHook<HWC2_PFN_SET_COLOR_MODE>(
1108 DisplayHook<decltype(&HwcDisplay::SetColorMode),
1109 &HwcDisplay::SetColorMode, int32_t>);
1110 case HWC2::FunctionDescriptor::SetColorTransform:
1111 return ToHook<HWC2_PFN_SET_COLOR_TRANSFORM>(
1112 DisplayHook<decltype(&HwcDisplay::SetColorTransform),
1113 &HwcDisplay::SetColorTransform, const float *, int32_t>);
1114 case HWC2::FunctionDescriptor::SetOutputBuffer:
1115 return ToHook<HWC2_PFN_SET_OUTPUT_BUFFER>(
1116 DisplayHook<decltype(&HwcDisplay::SetOutputBuffer),
1117 &HwcDisplay::SetOutputBuffer, buffer_handle_t, int32_t>);
1118 case HWC2::FunctionDescriptor::SetPowerMode:
1119 return ToHook<HWC2_PFN_SET_POWER_MODE>(
1120 DisplayHook<decltype(&HwcDisplay::SetPowerMode),
1121 &HwcDisplay::SetPowerMode, int32_t>);
1122 case HWC2::FunctionDescriptor::SetVsyncEnabled:
1123 return ToHook<HWC2_PFN_SET_VSYNC_ENABLED>(
1124 DisplayHook<decltype(&HwcDisplay::SetVsyncEnabled),
1125 &HwcDisplay::SetVsyncEnabled, int32_t>);
1126 case HWC2::FunctionDescriptor::ValidateDisplay:
1127 return ToHook<HWC2_PFN_VALIDATE_DISPLAY>(
1128 DisplayHook<decltype(&HwcDisplay::ValidateDisplay),
1129 &HwcDisplay::ValidateDisplay, uint32_t *, uint32_t *>);
1132 case HWC2::FunctionDescriptor::SetCursorPosition:
1133 return ToHook<HWC2_PFN_SET_CURSOR_POSITION>(
1134 LayerHook<decltype(&Hwc2Layer::SetCursorPosition),
1135 &Hwc2Layer::SetCursorPosition, int32_t, int32_t>);
1136 case HWC2::FunctionDescriptor::SetLayerBlendMode:
1137 return ToHook<HWC2_PFN_SET_LAYER_BLEND_MODE>(
1138 LayerHook<decltype(&Hwc2Layer::SetLayerBlendMode),
1139 &Hwc2Layer::SetLayerBlendMode, int32_t>);
1140 case HWC2::FunctionDescriptor::SetLayerBuffer:
1141 return ToHook<HWC2_PFN_SET_LAYER_BUFFER>(
1142 LayerHook<decltype(&Hwc2Layer::SetLayerBuffer),
1143 &Hwc2Layer::SetLayerBuffer, buffer_handle_t, int32_t>);
1144 case HWC2::FunctionDescriptor::SetLayerColor:
1145 return ToHook<HWC2_PFN_SET_LAYER_COLOR>(
1146 LayerHook<decltype(&Hwc2Layer::SetLayerColor),
1147 &Hwc2Layer::SetLayerColor, hwc_color_t>);
1148 case HWC2::FunctionDescriptor::SetLayerCompositionType:
1149 return ToHook<HWC2_PFN_SET_LAYER_COMPOSITION_TYPE>(
1150 LayerHook<decltype(&Hwc2Layer::SetLayerCompositionType),
1151 &Hwc2Layer::SetLayerCompositionType, int32_t>);
1152 case HWC2::FunctionDescriptor::SetLayerDataspace:
1153 return ToHook<HWC2_PFN_SET_LAYER_DATASPACE>(
1154 LayerHook<decltype(&Hwc2Layer::SetLayerDataspace),
1155 &Hwc2Layer::SetLayerDataspace, int32_t>);
1156 case HWC2::FunctionDescriptor::SetLayerDisplayFrame:
1157 return ToHook<HWC2_PFN_SET_LAYER_DISPLAY_FRAME>(
1158 LayerHook<decltype(&Hwc2Layer::SetLayerDisplayFrame),
1159 &Hwc2Layer::SetLayerDisplayFrame, hwc_rect_t>);
1160 case HWC2::FunctionDescriptor::SetLayerPlaneAlpha:
1161 return ToHook<HWC2_PFN_SET_LAYER_PLANE_ALPHA>(
1162 LayerHook<decltype(&Hwc2Layer::SetLayerPlaneAlpha),
1163 &Hwc2Layer::SetLayerPlaneAlpha, float>);
1164 case HWC2::FunctionDescriptor::SetLayerSidebandStream:
1165 return ToHook<HWC2_PFN_SET_LAYER_SIDEBAND_STREAM>(LayerHook<
1166 decltype(&Hwc2Layer::SetLayerSidebandStream),
1167 &Hwc2Layer::SetLayerSidebandStream, const native_handle_t *>);
1168 case HWC2::FunctionDescriptor::SetLayerSourceCrop:
1169 return ToHook<HWC2_PFN_SET_LAYER_SOURCE_CROP>(
1170 LayerHook<decltype(&Hwc2Layer::SetLayerSourceCrop),
1171 &Hwc2Layer::SetLayerSourceCrop, hwc_frect_t>);
1172 case HWC2::FunctionDescriptor::SetLayerSurfaceDamage:
1173 return ToHook<HWC2_PFN_SET_LAYER_SURFACE_DAMAGE>(
1174 LayerHook<decltype(&Hwc2Layer::SetLayerSurfaceDamage),
1175 &Hwc2Layer::SetLayerSurfaceDamage, hwc_region_t>);
1176 case HWC2::FunctionDescriptor::SetLayerTransform:
1177 return ToHook<HWC2_PFN_SET_LAYER_TRANSFORM>(
1178 LayerHook<decltype(&Hwc2Layer::SetLayerTransform),
1179 &Hwc2Layer::SetLayerTransform, int32_t>);
1180 case HWC2::FunctionDescriptor::SetLayerVisibleRegion:
1181 return ToHook<HWC2_PFN_SET_LAYER_VISIBLE_REGION>(
1182 LayerHook<decltype(&Hwc2Layer::SetLayerVisibleRegion),
1183 &Hwc2Layer::SetLayerVisibleRegion, hwc_region_t>);
1184 case HWC2::FunctionDescriptor::SetLayerZOrder:
1185 return ToHook<HWC2_PFN_SET_LAYER_Z_ORDER>(
1186 LayerHook<decltype(&Hwc2Layer::SetLayerZOrder),
1187 &Hwc2Layer::SetLayerZOrder, uint32_t>);
1188 case HWC2::FunctionDescriptor::Invalid:
1195 int IAHWC2::HookDevOpen(const struct hw_module_t *module, const char *name,
1196 struct hw_device_t **dev) {
1197 supported(__func__);
1198 if (strcmp(name, HWC_HARDWARE_COMPOSER)) {
1199 ALOGE("Invalid module name- %s", name);
1203 std::unique_ptr<IAHWC2> ctx(new IAHWC2());
1205 ALOGE("Failed to allocate IAHWC2");
1209 HWC2::Error err = ctx->Init();
1210 if (err != HWC2::Error::None) {
1211 ALOGE("Failed to initialize IAHWC2 err=%d\n", err);
1215 ctx->common.module = const_cast<hw_module_t *>(module);
1216 *dev = &ctx->common;
1221 hwcomposer::NativeDisplay *IAHWC2::GetExtendedDisplay(uint32_t dispIndex) {
1222 return extended_displays_.at(dispIndex)->GetDisplay();
1225 hwcomposer::NativeDisplay *IAHWC2::GetPrimaryDisplay() {
1226 return primary_display_.GetDisplay();
1229 hwcomposer::NativeDisplay *IAHWC2::HwcDisplay::GetDisplay() {
1233 void IAHWC2::EnableHDCPSessionForDisplay(uint32_t connector,
1234 EHwcsContentType content_type) {
1235 HWCContentType type = kCONTENT_TYPE0;
1236 if (content_type == HWCS_CP_CONTENT_TYPE1) {
1237 type = kCONTENT_TYPE1;
1240 device_.EnableHDCPSessionForDisplay(connector, type);
1243 void IAHWC2::EnableHDCPSessionForAllDisplays(EHwcsContentType content_type) {
1244 HWCContentType type = kCONTENT_TYPE0;
1245 if (content_type == HWCS_CP_CONTENT_TYPE1) {
1246 type = kCONTENT_TYPE1;
1248 device_.EnableHDCPSessionForAllDisplays(type);
1251 void IAHWC2::DisableHDCPSessionForDisplay(uint32_t connector) {
1252 device_.DisableHDCPSessionForDisplay(connector);
1255 void IAHWC2::DisableHDCPSessionForAllDisplays() {
1256 device_.DisableHDCPSessionForAllDisplays();
1259 void IAHWC2::SetPAVPSessionStatus(bool enabled, uint32_t papv_session_id,
1260 uint32_t pavp_instance_id) {
1261 device_.SetPAVPSessionStatus(enabled, papv_session_id, pavp_instance_id);
1264 void IAHWC2::SetHDCPSRMForAllDisplays(const int8_t *SRM, uint32_t SRMLength) {
1266 ETRACE("Error:HDCP Set NULL SRM");
1269 device_.SetHDCPSRMForAllDisplays(SRM, SRMLength);
1272 uint32_t IAHWC2::GetDisplayIDFromConnectorID(const uint32_t connector_id) {
1273 return device_.GetDisplayIDFromConnectorID(connector_id);
1276 void IAHWC2::SetHDCPSRMForDisplay(uint32_t connector, const int8_t *SRM,
1277 uint32_t SRMLength) {
1279 ETRACE("Error:HDCP Set NULL SRM");
1282 device_.SetHDCPSRMForDisplay(connector, SRM, SRMLength);
1285 } // namespace android
1287 static struct hw_module_methods_t hwc2_module_methods = {
1288 .open = android::IAHWC2::HookDevOpen,
1291 hw_module_t HAL_MODULE_INFO_SYM = {
1292 .tag = HARDWARE_MODULE_TAG,
1293 .module_api_version = HARDWARE_MODULE_API_VERSION(2, 0),
1294 .id = HWC_HARDWARE_MODULE_ID,
1295 .name = "IA-Hardware-Composer",
1296 .author = "The Android Open Source Project",
1297 .methods = &hwc2_module_methods,