diff options
-rw-r--r-- | gralloc/gr_buf_mgr.cpp | 4 | ||||
-rw-r--r-- | gralloc/gr_priv_handle.h | 12 | ||||
-rw-r--r-- | sdm/libs/core/display_base.cpp | 1 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display.cpp | 4 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_session.cpp | 2 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_session_services.cpp | 8 |
6 files changed, 21 insertions, 10 deletions
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp index 985dd3ef..48675ad3 100644 --- a/gralloc/gr_buf_mgr.cpp +++ b/gralloc/gr_buf_mgr.cpp @@ -101,6 +101,10 @@ void BufferManager::RegisterHandleLocked(const private_handle_t *hnd, int ion_ha } Error BufferManager::ImportHandleLocked(private_handle_t *hnd) { + if (private_handle_t::validate(hnd) != 0) { + ALOGE("ImportHandleLocked: Invalid handle: %p", hnd); + return Error::BAD_BUFFER; + } ALOGD_IF(DEBUG, "Importing handle:%p id: %" PRIu64, hnd, hnd->id); int ion_handle = allocator_->ImportBuffer(hnd->fd); if (ion_handle < 0) { diff --git a/gralloc/gr_priv_handle.h b/gralloc/gr_priv_handle.h index 752a8774..cbfc8676 100644 --- a/gralloc/gr_priv_handle.h +++ b/gralloc/gr_priv_handle.h @@ -132,12 +132,14 @@ struct private_handle_t : public native_handle_t { static int validate(const native_handle *h) { auto *hnd = static_cast<const private_handle_t *>(h); if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() || - h->numFds != kNumFds || hnd->magic != kMagic) { - ALOGE( - "Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) " - "magic(%c%c%c%c/%c%c%c%c)", + h->numFds != kNumFds) { + ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) ", h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(), - h ? h->numFds : -1, kNumFds, + h ? h->numFds : -1, kNumFds); + return -EINVAL; + } + if (hnd->magic != kMagic) { + ALOGE("magic(%c%c%c%c/%c%c%c%c)", hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?', hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?', hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?', diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp index 1d3a027a..917c07b5 100644 --- a/sdm/libs/core/display_base.cpp +++ b/sdm/libs/core/display_base.cpp @@ -1299,6 +1299,7 @@ void DisplayBase::CommitLayerParams(LayerStack *layer_stack) { hw_layer.input_buffer.size = sdm_layer->input_buffer.size; hw_layer.input_buffer.acquire_fence_fd = sdm_layer->input_buffer.acquire_fence_fd; hw_layer.input_buffer.handle_id = sdm_layer->input_buffer.handle_id; + hw_layer.input_buffer.buffer_id = sdm_layer->input_buffer.buffer_id; } return; diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp index 96b2e7b3..b5e2a5a5 100644 --- a/sdm/libs/hwc2/hwc_display.cpp +++ b/sdm/libs/hwc2/hwc_display.cpp @@ -1790,11 +1790,15 @@ int HWCDisplay::SetDisplayStatus(DisplayStatus display_status) { switch (display_status) { case kDisplayStatusResume: display_paused_ = false; + status = INT32(SetPowerMode(HWC2::PowerMode::On)); + break; case kDisplayStatusOnline: status = INT32(SetPowerMode(HWC2::PowerMode::On)); break; case kDisplayStatusPause: display_paused_ = true; + status = INT32(SetPowerMode(HWC2::PowerMode::Off)); + break; case kDisplayStatusOffline: status = INT32(SetPowerMode(HWC2::PowerMode::Off)); break; diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 76b681f8..6109ee08 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -1059,7 +1059,7 @@ HWC2::Error HWCSession::CreateVirtualDisplayObject(uint32_t width, uint32_t heig height, format, &hwc_display_[HWC_DISPLAY_VIRTUAL]); // TODO(user): validate width and height support if (status) { - return HWC2::Error::Unsupported; + return HWC2::Error::NoResources; } } diff --git a/sdm/libs/hwc2/hwc_session_services.cpp b/sdm/libs/hwc2/hwc_session_services.cpp index 519346f0..90ed00b4 100644 --- a/sdm/libs/hwc2/hwc_session_services.cpp +++ b/sdm/libs/hwc2/hwc_session_services.cpp @@ -524,8 +524,8 @@ Return<int32_t> HWCSession::controlIdlePowerCollapse(bool enable, bool synchrono if (!idle_pc_ref_cnt_) { HWC2::Error err = hwc_display_[HWC_DISPLAY_PRIMARY]->ControlIdlePowerCollapse(enable, synchronous); - if (err != HWC2::Error::None) { - return -EINVAL; + if (err == HWC2::Error::Unsupported) { + return 0; } Refresh(HWC_DISPLAY_PRIMARY); int32_t error = locker_[HWC_DISPLAY_PRIMARY].WaitFinite(kCommitDoneTimeoutMs); @@ -540,8 +540,8 @@ Return<int32_t> HWCSession::controlIdlePowerCollapse(bool enable, bool synchrono if (!(idle_pc_ref_cnt_ - 1)) { HWC2::Error err = hwc_display_[HWC_DISPLAY_PRIMARY]->ControlIdlePowerCollapse(enable, synchronous); - if (err != HWC2::Error::None) { - return -EINVAL; + if (err == HWC2::Error::Unsupported) { + return 0; } DLOGI("Idle PC enabled!!"); } |