rockchip: make camera be aware of display orientation

Signed-off-by: hmz007 <hmz007@gmail.com>
master
hmz007 8 months ago
parent 684713d7e7
commit 8a784c53fb

@ -49,6 +49,6 @@
<!-- image size larger than the last entry will not be supported--> <!-- image size larger than the last entry will not be supported-->
</FpsList> </FpsList>
<!-- orientation --> <!-- orientation -->
<Orientation degree="0"/> <!-- <Orientation degree="0"/> -->
</Device> </Device>
</ExternalCamera> </ExternalCamera>

@ -49,6 +49,6 @@
<!-- image size larger than the last entry will not be supported--> <!-- image size larger than the last entry will not be supported-->
</FpsList> </FpsList>
<!-- orientation --> <!-- orientation -->
<Orientation degree="0"/> <!-- <Orientation degree="0"/> -->
</Device> </Device>
</ExternalCamera> </ExternalCamera>

@ -758,8 +758,14 @@ void PlatformData::getCameraInfo(int cameraId, struct camera_info * info)
appendTags(staticMeta,ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS,RK_CONTROL_AIQ_SATURATION); appendTags(staticMeta,ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS,RK_CONTROL_AIQ_SATURATION);
appendTags(staticMeta,ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,RK_CONTROL_AIQ_SATURATION); appendTags(staticMeta,ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,RK_CONTROL_AIQ_SATURATION);
} }
info->static_camera_characteristics = staticMeta.getAndLock(); int degree = property_get_int32("vendor.hwc.orient.main", 0);
staticMeta.unlock( info->static_camera_characteristics); if (info->orientation == 0 && degree == 270) {
info->orientation = degree;
staticMeta.update(ANDROID_SENSOR_ORIENTATION, &info->orientation, 1);
ALOGD("camera %d orientation updated to %d\n", cameraId, info->orientation);
}
info->static_camera_characteristics = staticMeta.getAndLock();
staticMeta.unlock( info->static_camera_characteristics);
#else #else
info->static_camera_characteristics = getStaticMetadata(cameraId); info->static_camera_characteristics = getStaticMetadata(cameraId);
#endif #endif

@ -26,6 +26,7 @@
#include <algorithm> #include <algorithm>
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <cutils/properties.h>
#define HAVE_JPEG // required for libyuv.h to export MJPEG decode APIs #define HAVE_JPEG // required for libyuv.h to export MJPEG decode APIs
#include <libyuv.h> #include <libyuv.h>
@ -164,6 +165,12 @@ ExternalCameraConfig ExternalCameraConfig::loadFromCfg(const char* cfgPath) {
XMLElement* orientation = deviceCfg->FirstChildElement("Orientation"); XMLElement* orientation = deviceCfg->FirstChildElement("Orientation");
if (orientation == nullptr) { if (orientation == nullptr) {
ALOGI("%s: no sensor orientation specified", __FUNCTION__); ALOGI("%s: no sensor orientation specified", __FUNCTION__);
ret.orientation = property_get_int32("vendor.hwc.orient.main", -1);
if (ret.orientation < 0) {
// Simple delay to wait vendor property ready
usleep(1000*100);
ret.orientation = property_get_int32("vendor.hwc.orient.main", kDefaultOrientation);
}
} else { } else {
ret.orientation = orientation->IntAttribute("degree", /*Default*/ kDefaultOrientation); ret.orientation = orientation->IntAttribute("degree", /*Default*/ kDefaultOrientation);
} }

@ -26,6 +26,7 @@
#include <algorithm> #include <algorithm>
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <cutils/properties.h>
#define HAVE_JPEG // required for libyuv.h to export MJPEG decode APIs #define HAVE_JPEG // required for libyuv.h to export MJPEG decode APIs
#include <libyuv.h> #include <libyuv.h>
@ -164,6 +165,12 @@ HdmiConfig HdmiConfig::loadFromCfg(const char* cfgPath) {
XMLElement* orientation = deviceCfg->FirstChildElement("Orientation"); XMLElement* orientation = deviceCfg->FirstChildElement("Orientation");
if (orientation == nullptr) { if (orientation == nullptr) {
ALOGI("%s: no sensor orientation specified", __FUNCTION__); ALOGI("%s: no sensor orientation specified", __FUNCTION__);
ret.orientation = property_get_int32("vendor.hwc.orient.main", -1);
if (ret.orientation < 0) {
// Simple delay to wait vendor property ready
usleep(1000*100);
ret.orientation = property_get_int32("vendor.hwc.orient.main", kDefaultOrientation);
}
} else { } else {
ret.orientation = orientation->IntAttribute("degree", /*Default*/ kDefaultOrientation); ret.orientation = orientation->IntAttribute("degree", /*Default*/ kDefaultOrientation);
} }

@ -1437,6 +1437,10 @@ HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
} }
} }
// set display orientation for camera
if (handle_ == HWC_DISPLAY_PRIMARY && ctx_.rel_xres < ctx_.rel_yres)
property_set(PROPERTY_TYPE ".hwc.orient.main", "270");
const std::vector<int> vrr_mode = connector_->vrr_modes(); const std::vector<int> vrr_mode = connector_->vrr_modes();
if(bVrrDisplay_ && vrr_mode.size() > 1){ if(bVrrDisplay_ && vrr_mode.size() > 1){
if (!configs) { if (!configs) {

Loading…
Cancel
Save