diff options
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp | 8 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h | 4 | ||||
-rw-r--r-- | libhwjpeg/Android.bp | 1 | ||||
-rw-r--r-- | libhwjpeg/AppMarkerWriter.cpp | 2 | ||||
-rw-r--r-- | libhwjpeg/AppMarkerWriter.h | 2 | ||||
-rw-r--r-- | libhwjpeg/ExynosJpegEncoder.cpp | 9 | ||||
-rw-r--r-- | libhwjpeg/FileLock.cpp | 13 | ||||
-rw-r--r-- | libhwjpeg/hwjpeg-v4l2.cpp | 11 | ||||
-rw-r--r-- | libhwjpeg/include/ExynosJpegApi.h | 5 | ||||
-rw-r--r-- | libhwjpeg/include/FileLock.h | 16 | ||||
-rw-r--r-- | libhwjpeg/include/exynos-hwjpeg.h | 11 |
11 files changed, 78 insertions, 4 deletions
diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp index 7f565e4..6a2be7d 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.cpp @@ -431,7 +431,8 @@ int32_t ExynosDisplayDrmInterface::getDefaultModeId(int32_t *modeId) { return NO_ERROR; } -ExynosDisplayDrmInterface::ExynosDisplayDrmInterface(ExynosDisplay *exynosDisplay) +ExynosDisplayDrmInterface::ExynosDisplayDrmInterface(ExynosDisplay *exynosDisplay): + mMonitorDescription{0} { mType = INTERFACE_TYPE_DRM; init(exynosDisplay); @@ -2423,6 +2424,11 @@ int32_t ExynosDisplayDrmInterface::getDisplayFakeEdid(uint8_t &outPort, uint32_t edid_buf[59] = height & 0xff; edid_buf[61] = (height >> 4) & 0xf0; + if (mMonitorDescription[0] != 0) { + /* Descriptor block 3 starts at address 90, data offset is 5 bytes */ + memcpy(&edid_buf[95], mMonitorDescription.data(), mMonitorDescription.size()); + } + unsigned int sum = std::accumulate(edid_buf.begin(), edid_buf.end() - 1, 0); edid_buf[127] = (0x100 - (sum & 0xFF)) & 0xFF; if (outData) { diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h index d3e9e66..bf5c9aa 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h @@ -37,6 +37,9 @@ /* Max plane number of buffer object */ #define HWC_DRM_BO_MAX_PLANES 4 +/* Monitor Descriptor data is 13 bytes in VESA EDID Standard */ +#define MONITOR_DESCRIPTOR_DATA_LENGTH 13 + #ifndef HWC_FORCE_PANIC_PATH #define HWC_FORCE_PANIC_PATH "/d/dpu/panic" #endif @@ -492,6 +495,7 @@ class ExynosDisplayDrmInterface : DrmReadbackInfo mReadbackInfo; FramebufferManager mFBManager; + std::array<uint8_t, MONITOR_DESCRIPTOR_DATA_LENGTH> mMonitorDescription; private: int32_t getDisplayFakeEdid(uint8_t &outPort, uint32_t &outDataSize, uint8_t *outData); diff --git a/libhwjpeg/Android.bp b/libhwjpeg/Android.bp index b7dd526..86dc84d 100644 --- a/libhwjpeg/Android.bp +++ b/libhwjpeg/Android.bp @@ -10,6 +10,7 @@ cc_library_shared { "AppMarkerWriter.cpp", "ExynosJpegEncoder.cpp", "ExynosJpegEncoderForCamera.cpp", + "FileLock.cpp", "hwjpeg-base.cpp", "hwjpeg-v4l2.cpp", "libhwjpeg-exynos.cpp", diff --git a/libhwjpeg/AppMarkerWriter.cpp b/libhwjpeg/AppMarkerWriter.cpp index b764025..f9eb12b 100644 --- a/libhwjpeg/AppMarkerWriter.cpp +++ b/libhwjpeg/AppMarkerWriter.cpp @@ -260,7 +260,7 @@ void CAppMarkerWriter::PrepareAppWriter(char *base, exif_attribute_t *exif, m_pExtra = extra; // |<- m_szApp1 ->|<- m_szMaxThumbSize ->|<-m_szAppX->| - // |<----- size of total APP1 and APP4 segments ----->|<-APP11->|<-- main image + // |<----- size of total APP1 and APPX segments ----->|<-APP11->|<-- main image // m_pAppBase m_pThumbBase | | return // | | | | || // v v | | v| diff --git a/libhwjpeg/AppMarkerWriter.h b/libhwjpeg/AppMarkerWriter.h index 9531339..a25d9c0 100644 --- a/libhwjpeg/AppMarkerWriter.h +++ b/libhwjpeg/AppMarkerWriter.h @@ -37,7 +37,7 @@ #define IFD_FIELD_SIZE (IFD_TAG_SIZE + IFD_TYPE_SIZE + IFD_COUNT_SIZE + IFD_VALOFF_SIZE) -#define EXTRA_APPMARKER_MIN 4 +#define EXTRA_APPMARKER_MIN 2 #define EXTRA_APPMARKER_LIMIT 10 #define MAX_GPS_PROCESSINGMETHOD_SIZE 108 diff --git a/libhwjpeg/ExynosJpegEncoder.cpp b/libhwjpeg/ExynosJpegEncoder.cpp index f25d9b4..d833ca7 100644 --- a/libhwjpeg/ExynosJpegEncoder.cpp +++ b/libhwjpeg/ExynosJpegEncoder.cpp @@ -19,6 +19,15 @@ #include <linux/videodev2.h> #include "hwjpeg-internal.h" + +int ExynosJpegEncoder::lock() { + return m_hwjpeg.lock(); +} + +int ExynosJpegEncoder::unlock() { + return m_hwjpeg.unlock(); +} + int ExynosJpegEncoder::setJpegConfig(void *pConfig) { ExynosJpegEncoder *that = reinterpret_cast<ExynosJpegEncoder *>(pConfig); diff --git a/libhwjpeg/FileLock.cpp b/libhwjpeg/FileLock.cpp new file mode 100644 index 0000000..6e8ecbd --- /dev/null +++ b/libhwjpeg/FileLock.cpp @@ -0,0 +1,13 @@ +#include "FileLock.h" + +#include <bits/lockf.h> + +FileLock::FileLock(int fd) : fd_(fd) {} + +int FileLock::lock() { + return lockf(fd_, F_LOCK, 0); +} + +int FileLock::unlock() { + return lockf(fd_, F_ULOCK, 0); +} diff --git a/libhwjpeg/hwjpeg-v4l2.cpp b/libhwjpeg/hwjpeg-v4l2.cpp index b822e24..c364554 100644 --- a/libhwjpeg/hwjpeg-v4l2.cpp +++ b/libhwjpeg/hwjpeg-v4l2.cpp @@ -22,7 +22,8 @@ #include "hwjpeg-internal.h" #include "log/log_main.h" -CHWJpegV4L2Compressor::CHWJpegV4L2Compressor() : CHWJpegCompressor("/dev/video12") { +CHWJpegV4L2Compressor::CHWJpegV4L2Compressor() + : CHWJpegCompressor("/dev/video12"), file_lock_(FileLock(GetDeviceFD())) { memset(&m_v4l2Format, 0, sizeof(m_v4l2Format)); memset(&m_v4l2SrcBuffer, 0, sizeof(m_v4l2SrcBuffer)); memset(&m_v4l2DstBuffer, 0, sizeof(m_v4l2DstBuffer)); @@ -69,6 +70,14 @@ CHWJpegV4L2Compressor::~CHWJpegV4L2Compressor() { ALOGD("CHWJpegV4L2Compressor Destroyed: %p, FD %d", this, GetDeviceFD()); } +int CHWJpegV4L2Compressor::lock() { + return file_lock_.lock(); +} + +int CHWJpegV4L2Compressor::unlock() { + return file_lock_.unlock(); +} + bool CHWJpegV4L2Compressor::SetChromaSampFactor(unsigned int horizontal, unsigned int vertical) { __s32 value; switch ((horizontal << 4) | vertical) { diff --git a/libhwjpeg/include/ExynosJpegApi.h b/libhwjpeg/include/ExynosJpegApi.h index 6addf51..dcf06b3 100644 --- a/libhwjpeg/include/ExynosJpegApi.h +++ b/libhwjpeg/include/ExynosJpegApi.h @@ -114,6 +114,11 @@ public: } virtual ~ExynosJpegEncoder() { destroy(); } + // Acquire exclusive lock to V4L2 device. This is a blocking call. + int lock(); + // Release exclusive lock to V4L2 device. + int unlock(); + // Return 0 on success, -1 on error int flagCreate() { return m_hwjpeg.Okay() ? 0 : -1; } virtual int create(void) { return flagCreate(); } diff --git a/libhwjpeg/include/FileLock.h b/libhwjpeg/include/FileLock.h new file mode 100644 index 0000000..b308aa7 --- /dev/null +++ b/libhwjpeg/include/FileLock.h @@ -0,0 +1,16 @@ +#include "android-base/thread_annotations.h" + +// Encapsulates advisory file lock for a given field descriptor +class CAPABILITY("mutex") FileLock { +public: + FileLock(int fd); + ~FileLock() = default; + + // Acquires advisory file lock. This will block. + int lock() ACQUIRE(); + // Releases advisory file lock. + int unlock() RELEASE(); + +private: + int fd_; +};
\ No newline at end of file diff --git a/libhwjpeg/include/exynos-hwjpeg.h b/libhwjpeg/include/exynos-hwjpeg.h index 3d3d7e5..45114b5 100644 --- a/libhwjpeg/include/exynos-hwjpeg.h +++ b/libhwjpeg/include/exynos-hwjpeg.h @@ -26,6 +26,9 @@ #error VIDEO_MAX_PLANES should not be smaller than 6 #endif +#include "FileLock.h" +#include "android-base/thread_annotations.h" + // Exynos JPEG specific device capabilities // Defined in the driver. Not in videodev2.h #define V4L2_CAP_EXYNOS_JPEG_DECOMPRESSION 0x0100 @@ -581,6 +584,8 @@ class CHWJpegV4L2Compressor : public CHWJpegCompressor, private CHWJpegFlagManag bool m_bEnableHWFC; + FileLock file_lock_; + bool IsB2BCompression() { return (TO_SEC_IMG_SIZE(m_v4l2Format.fmt.pix_mp.width) + TO_SEC_IMG_SIZE(m_v4l2Format.fmt.pix_mp.height)) != 0; @@ -601,6 +606,12 @@ public: CHWJpegV4L2Compressor(); virtual ~CHWJpegV4L2Compressor(); + // Acquires exclusive lock to V4L2 device. This must be called before starting image + // configuration. This is a blocking call. + int lock(); + // Releases exclusive lock to V4L2 device. This should be called after encoding is complete. + int unlock(); + unsigned int GetHWDelay() { return m_uiHWDelay; } // SetChromaSampFactor can be called during streaming |