summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-17 01:21:09 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-17 01:21:09 +0000
commitf3b51d7a4748fe62cb6b8c06fe35950522b3948a (patch)
tree972235c555b82d23bd826a02d64e821352248e4d
parent6d98f62745fa3b4296ee749df7aadf18e278966f (diff)
parentf1de980659b0ad327efef954a98cfc616c805d77 (diff)
Snap for 10338099 from f1de980659b0ad327efef954a98cfc616c805d77 to udc-release
Change-Id: I9dc7f953edaf953681b8a72f0bc21d0f9f5f4069
-rw-r--r--libhwc2.1/histogram_mediator.cpp2
-rw-r--r--libhwc2.1/histogram_mediator.h28
-rw-r--r--libhwc2.1/pixel-display.cpp29
3 files changed, 53 insertions, 6 deletions
diff --git a/libhwc2.1/histogram_mediator.cpp b/libhwc2.1/histogram_mediator.cpp
index d1fba54..f23feec 100644
--- a/libhwc2.1/histogram_mediator.cpp
+++ b/libhwc2.1/histogram_mediator.cpp
@@ -60,7 +60,7 @@ histogram::HistogramErrorCode histogram::HistogramMediator::requestHist() {
std::unique_lock<std::mutex> lk(mIDLHistogram->mDataCollectingMutex);
if (moduleDisplayInterface->setHistogramControl(
hidl_histogram_control_t::HISTOGRAM_CONTROL_REQUEST) != NO_ERROR) {
- return histogram::HistogramErrorCode::ENABLE_HIST_ERROR;
+ return histogram::HistogramErrorCode::ENABLE_HIST_ERROR;
}
mIDLHistogram->mHistReq_pending = true;
}
diff --git a/libhwc2.1/histogram_mediator.h b/libhwc2.1/histogram_mediator.h
index fa81e0b..54d28c9 100644
--- a/libhwc2.1/histogram_mediator.h
+++ b/libhwc2.1/histogram_mediator.h
@@ -73,10 +73,38 @@ public:
bool mHistReq_pending = false;
std::mutex mDataCollectingMutex; // for data collecting operations
};
+
+ struct HistogramConfig {
+ RoiRect mRoi;
+ Weight mWeights;
+ HistogramPos mPos;
+
+ HistogramConfig() {}
+
+ HistogramConfig(const RoiRect &roi, const Weight &weights, const HistogramPos &pos) {
+ mRoi = roi;
+ mWeights = weights;
+ mPos = pos;
+ }
+
+ bool operator!=(const HistogramConfig &rhs) {
+ return mRoi != rhs.mRoi || mWeights != rhs.mWeights || mPos != rhs.mPos;
+ }
+
+ HistogramConfig &operator=(const HistogramConfig &rhs) {
+ mRoi = rhs.mRoi;
+ mWeights = rhs.mWeights;
+ mPos = rhs.mPos;
+ return *this;
+ }
+ };
+
uint32_t getFrameCount();
void setSampleFrameCounter(int32_t id) { mSampledFrameCounter = id; }
uint32_t getSampleFrameCounter() { return mSampledFrameCounter; }
bool histRequested() { return mIDLHistogram->mHistReq_pending; }
+ std::mutex mConfigMutex;
+ HistogramConfig mConfig GUARDED_BY(mConfigMutex);
private:
int calculateThreshold(const RoiRect &roi);
diff --git a/libhwc2.1/pixel-display.cpp b/libhwc2.1/pixel-display.cpp
index fec7309..366945a 100644
--- a/libhwc2.1/pixel-display.cpp
+++ b/libhwc2.1/pixel-display.cpp
@@ -201,17 +201,36 @@ ndk::ScopedAStatus Display::setRefreshRateThrottle(int delayMs, int *_aidl_retur
bool Display::runMediator(const RoiRect &roi, const Weight &weight, const HistogramPos &pos,
std::vector<char16_t> *histogrambuffer) {
- if (mMediator.setRoiWeightThreshold(roi, weight, pos) != HistogramErrorCode::NONE) {
- ALOGE("histogram error, SET_ROI_WEIGHT_THRESHOLD ERROR\n");
- return false;
+ bool isConfigChanged;
+ histogram::HistogramMediator::HistogramConfig pendingConfig(roi, weight, pos);
+
+ {
+ std::unique_lock<std::mutex> lk(mMediator.mConfigMutex);
+ isConfigChanged = mMediator.mConfig != pendingConfig;
+
+ if (isConfigChanged &&
+ mMediator.setRoiWeightThreshold(roi, weight, pos) != HistogramErrorCode::NONE) {
+ ALOGE("histogram error, SET_ROI_WEIGHT_THRESHOLD ERROR\n");
+ return false;
+ }
+
+ mMediator.mConfig = pendingConfig;
}
+
if (!mMediator.histRequested() &&
mMediator.requestHist() == HistogramErrorCode::ENABLE_HIST_ERROR) {
ALOGE("histogram error, ENABLE_HIST ERROR\n");
}
- if (mMediator.getFrameCount() != mMediator.getSampleFrameCounter()) {
- mDisplay->mDevice->onRefresh(mDisplay->mDisplayId); // DRM not busy & sampled frame changed
+
+ /*
+ * DPU driver maintains always-on histogram engine state with up to date histogram data.
+ * Therefore we don't have explicitly to trigger onRefresh in case histogram configuration
+ * does not change.
+ */
+ if (isConfigChanged) {
+ mDisplay->mDevice->onRefresh(mDisplay->mDisplayId);
}
+
if (mMediator.collectRoiLuma(histogrambuffer) != HistogramErrorCode::NONE) {
ALOGE("histogram error, COLLECT_ROI_LUMA ERROR\n");
return false;