summaryrefslogtreecommitdiff
path: root/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp')
-rw-r--r--libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp139
1 files changed, 139 insertions, 0 deletions
diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp
index df71cfb..bfe8eaa 100644
--- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp
+++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp
@@ -85,6 +85,9 @@ int32_t ExynosDisplayDrmInterfaceModule::initDrmDevice(DrmDevice *drmDevice)
initOldDppBlobs(drmDevice);
if (mDrmCrtc->force_bpc_property().id())
parseBpcEnums(mDrmCrtc->force_bpc_property());
+
+ mOldHistoBlobs.init(drmDevice);
+
return ret;
}
@@ -786,6 +789,142 @@ const std::string ExynosDisplayDrmInterfaceModule::GetPanelInfo(const std::strin
return info;
}
+/* For Histogram */
+int32_t ExynosDisplayDrmInterfaceModule::createHistoRoiBlob(uint32_t &blobId) {
+ struct histogram_roi histo_roi;
+
+ histo_roi.start_x = mHistogramInfo->getHistogramROI().start_x;
+ histo_roi.start_y = mHistogramInfo->getHistogramROI().start_y;
+ histo_roi.hsize = mHistogramInfo->getHistogramROI().hsize;
+ histo_roi.vsize = mHistogramInfo->getHistogramROI().vsize;
+
+ int ret = mDrmDevice->CreatePropertyBlob(&histo_roi, sizeof(histo_roi), &blobId);
+ if (ret) {
+ HWC_LOGE(mExynosDisplay, "Failed to create histogram roi blob %d", ret);
+ return ret;
+ }
+
+ return NO_ERROR;
+}
+
+int32_t ExynosDisplayDrmInterfaceModule::createHistoWeightsBlob(uint32_t &blobId) {
+ struct histogram_weights histo_weights;
+
+ histo_weights.weight_r = mHistogramInfo->getHistogramWeights().weight_r;
+ histo_weights.weight_g = mHistogramInfo->getHistogramWeights().weight_g;
+ histo_weights.weight_b = mHistogramInfo->getHistogramWeights().weight_b;
+
+ int ret = mDrmDevice->CreatePropertyBlob(&histo_weights, sizeof(histo_weights), &blobId);
+ if (ret) {
+ HWC_LOGE(mExynosDisplay, "Failed to create histogram weights blob %d", ret);
+ return ret;
+ }
+
+ return NO_ERROR;
+}
+
+int32_t ExynosDisplayDrmInterfaceModule::setDisplayHistoBlob(
+ const DrmProperty &prop, const uint32_t type,
+ ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq) {
+ if (!prop.id()) return NO_ERROR;
+
+ int32_t ret = NO_ERROR;
+ uint32_t blobId = 0;
+
+ switch (type) {
+ case HistoBlobs::ROI:
+ ret = createHistoRoiBlob(blobId);
+ break;
+ case HistoBlobs::WEIGHTS:
+ ret = createHistoWeightsBlob(blobId);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ if (ret != NO_ERROR) {
+ HWC_LOGE(mExynosDisplay, "%s: Failed to create blob", __func__);
+ return ret;
+ }
+
+ /* Skip setting when previous and current setting is same with 0 */
+ if ((blobId == 0) && (mOldHistoBlobs.getBlob(type) == 0)) return ret;
+
+ if ((ret = drmReq.atomicAddProperty(mDrmCrtc->id(), prop, blobId)) < 0) {
+ HWC_LOGE(mExynosDisplay, "%s: Failed to add property", __func__);
+ return ret;
+ }
+ mOldHistoBlobs.addBlob(type, blobId);
+
+ return ret;
+}
+
+int32_t ExynosDisplayDrmInterfaceModule::setDisplayHistogramSetting(
+ ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq) {
+ if ((mHistogramInfoRegistered == false) || (isPrimary() == false)) return NO_ERROR;
+
+ int ret = NO_ERROR;
+
+ if ((ret = setDisplayHistoBlob(mDrmCrtc->histogram_roi_property(),
+ static_cast<uint32_t>(HistoBlobs::ROI), drmReq) != NO_ERROR)) {
+ HWC_LOGE(mExynosDisplay, "%s: Failed to set Histo_ROI blob", __func__);
+ return ret;
+ }
+ if ((ret = setDisplayHistoBlob(mDrmCrtc->histogram_weights_property(),
+ static_cast<uint32_t>(HistoBlobs::WEIGHTS),
+ drmReq) != NO_ERROR)) {
+ HWC_LOGE(mExynosDisplay, "%s: Failed to set Histo_Weights blob", __func__);
+ return ret;
+ }
+
+ const DrmProperty &prop_histo_threshold = mDrmCrtc->histogram_threshold_property();
+ if (prop_histo_threshold.id()) {
+ if ((ret = drmReq.atomicAddProperty(mDrmCrtc->id(), prop_histo_threshold,
+ (uint64_t)(mHistogramInfo->getHistogramThreshold()),
+ true)) < 0) {
+ HWC_LOGE(mExynosDisplay, "%s: Failed to set histogram thereshold property", __func__);
+ return ret;
+ }
+ }
+
+ return NO_ERROR;
+}
+
+int32_t ExynosDisplayDrmInterfaceModule::setHistogramControl(int32_t control) {
+ if ((mHistogramInfoRegistered == false) || (isPrimary() == false)) return NO_ERROR;
+
+ int ret = NO_ERROR;
+ uint32_t crtc_id = mDrmCrtc->id();
+
+ if (control == HISTOGRAM_CONTROL_REQUEST) {
+ ret = mDrmDevice->CallVendorIoctl(DRM_IOCTL_EXYNOS_HISTOGRAM_REQUEST, (void *)&crtc_id);
+ ALOGD("Histogram Requested");
+ } else if (control == HISTOGRAM_CONTROL_CANCEL) {
+ ret = mDrmDevice->CallVendorIoctl(DRM_IOCTL_EXYNOS_HISTOGRAM_CANCEL, (void *)&crtc_id);
+ ALOGD("Histogram Canceled");
+ }
+
+ return ret;
+}
+
+int32_t ExynosDisplayDrmInterfaceModule::setHistogramData(void *bin) {
+ if (!bin) return -EINVAL;
+
+ /*
+ * There are two handling methods.
+ * For ContentSampling in HWC_2.3 API, histogram bin needs to be accumulated.
+ * For Histogram HIDL, histogram bin need to be sent to HIDL block.
+ */
+ if (mHistogramInfo->getHistogramType() == HistogramInfo::Histogram_Type::HISTOGRAM_HIDL) {
+ static_cast<HIDLHistogram *>(mHistogramInfo.get())->CallbackHistogram(bin);
+ } else {
+ /*
+ * ContentSampling in HWC2.3 API is not supported
+ */
+ }
+
+ return NO_ERROR;
+}
+
//////////////////////////////////////////////////// ExynosPrimaryDisplayDrmInterfaceModule //////////////////////////////////////////////////////////////////
ExynosPrimaryDisplayDrmInterfaceModule::ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay)
: ExynosDisplayDrmInterfaceModule(exynosDisplay)