diff --git a/config/linux/ipu6/sensors/isx031.xml b/config/linux/ipu6/sensors/isx031.xml new file mode 100644 index 00000000..333fd9d1 --- /dev/null +++ b/config/linux/ipu6/sensors/isx031.xml @@ -0,0 +1,545 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/linux/ipu6ep/libcamhal_profile.xml b/config/linux/ipu6ep/libcamhal_profile.xml index 3bc4ff67..f167d84f 100644 --- a/config/linux/ipu6ep/libcamhal_profile.xml +++ b/config/linux/ipu6ep/libcamhal_profile.xml @@ -21,6 +21,6 @@ + isx031,imx390,ar0234,external_source,ar0234_usb,lt6911uxc,lt6911uxe"/> diff --git a/config/linux/ipu6ep/sensors/isx031.xml b/config/linux/ipu6ep/sensors/isx031.xml new file mode 100644 index 00000000..333fd9d1 --- /dev/null +++ b/config/linux/ipu6ep/sensors/isx031.xml @@ -0,0 +1,545 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/linux/ipu6epmtl/sensors/isx031.xml b/config/linux/ipu6epmtl/sensors/isx031.xml new file mode 100644 index 00000000..333fd9d1 --- /dev/null +++ b/config/linux/ipu6epmtl/sensors/isx031.xml @@ -0,0 +1,545 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/v4l2/v4l2_device.h b/modules/v4l2/v4l2_device.h index 87d087ef..94375cdd 100644 --- a/modules/v4l2/v4l2_device.h +++ b/modules/v4l2/v4l2_device.h @@ -351,6 +351,7 @@ class CROS_CAMERA_EXPORT V4L2VideoNode final : public V4L2Device { // V4L2 memory type. enum v4l2_memory GetMemoryType(); + int GetDeviceCaps(); // This method get the buffer type of video device. // // Returns: @@ -467,6 +468,7 @@ class CROS_CAMERA_EXPORT V4L2VideoNode final : public V4L2Device { bool is_buffer_cached_; + int device_caps; enum v4l2_buf_type buffer_type_; enum v4l2_memory memory_type_; diff --git a/modules/v4l2/v4l2_video_node.cc b/modules/v4l2/v4l2_video_node.cc index 1d5f6c83..8c9a913d 100644 --- a/modules/v4l2/v4l2_video_node.cc +++ b/modules/v4l2/v4l2_video_node.cc @@ -392,6 +392,7 @@ V4L2VideoNode::V4L2VideoNode(const std::string& name) buffer_type_(V4L2_BUF_TYPE_VIDEO_CAPTURE), memory_type_(V4L2_MEMORY_USERPTR) { LOG1("@%s", __func__); + device_caps = 0; } V4L2VideoNode::~V4L2VideoNode() { @@ -426,14 +427,14 @@ int V4L2VideoNode::Open(int flags) { {V4L2_CAP_VIDEO_OUTPUT_MPLANE, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE}, {V4L2_CAP_META_CAPTURE, V4L2_BUF_TYPE_META_CAPTURE}, {V4L2_CAP_META_OUTPUT, V4L2_BUF_TYPE_META_OUTPUT}}; + size_t i = 0; for (; i < ARRAY_SIZE(buffer_type_mapper); i++) { if (cap.capabilities & buffer_type_mapper[i].first) { - buffer_type_ = buffer_type_mapper[i].second; - break; + device_caps |= buffer_type_mapper[i].first; } } - if (i == ARRAY_SIZE(buffer_type_mapper)) { + if (device_caps == 0) { V4L2Device::Close(); LOGE("%s: ARRAY_SIZE error.", __func__); return -EINVAL; @@ -462,6 +463,12 @@ enum v4l2_memory V4L2VideoNode::GetMemoryType() { return memory_type_; } +int V4L2VideoNode::GetDeviceCaps() { + LOG1("@%s", __func__); + + return device_caps; +} + enum v4l2_buf_type V4L2VideoNode::GetBufferType() { LOG1("@%s", __func__); @@ -530,7 +537,7 @@ int V4L2VideoNode::SetFormat(const V4L2Format& format) { } V4L2Format fmt(format); - fmt.SetType(buffer_type_); + buffer_type_ = static_cast(fmt.Type()); if (V4L2_TYPE_IS_META(buffer_type_)) { fmt.SetSizeImage(0, 0); diff --git a/src/core/CameraBuffer.cpp b/src/core/CameraBuffer.cpp index 17266e38..421f1ab6 100644 --- a/src/core/CameraBuffer.cpp +++ b/src/core/CameraBuffer.cpp @@ -37,13 +37,12 @@ namespace icamera { CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, - int format) + int format, v4l2_buf_type v4l2BufType) : mNumPlanes(1), mAllocatedMemory(false), mU(nullptr), mBufferUsage(usage), mSettingSequence(-1) { - v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; int num_plane = 1; LOG2("%s: construct buffer with usage:%d, memory:%d, size:%d, format:%d, index:%d", @@ -62,28 +61,21 @@ CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, i case BUFFER_USAGE_GENERAL: if (PlatformData::isIsysEnabled(cameraId) && PlatformData::isCSIFrontEndCapture(cameraId)) { - type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; num_plane = CameraUtils::getNumOfPlanes(format); - } else { - type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; } break; - case BUFFER_USAGE_PSYS_STATS: - type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - break; case BUFFER_USAGE_MIPI_CAPTURE: case BUFFER_USAGE_METADATA: - type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; num_plane = CameraUtils::getNumOfPlanes(format); break; default: - LOGE("Not supported Usage"); + break; } CLEAR(mMmapAddrs); CLEAR(mDmaFd); - initBuffer(memory, type, size, index, num_plane); + initBuffer(memory, v4l2BufType, size, index, num_plane); } CameraBuffer::~CameraBuffer() { @@ -104,7 +96,6 @@ void CameraBuffer::initBuffer(int memType, v4l2_buf_type bufType, uint32_t size, if (!V4L2_TYPE_IS_MULTIPLANAR(bufType)) { mV.SetOffset(0, 0); mV.SetLength(size, 0); - LOGE("SINGLE PLANE!"); } else { mV.SetLength(num_plane, 0); mNumPlanes = num_plane; diff --git a/src/core/CameraBuffer.h b/src/core/CameraBuffer.h index 0e65750c..e5fc4443 100644 --- a/src/core/CameraBuffer.h +++ b/src/core/CameraBuffer.h @@ -54,7 +54,8 @@ class CameraBuffer { int srcWidth = -1, int srcHeight = -1); public: - CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, int format = -1); + CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, int format = -1, + v4l2_buf_type v4l2BufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); virtual ~CameraBuffer(); public: diff --git a/src/core/CameraStream.cpp b/src/core/CameraStream.cpp index c3d2897f..e98e8aff 100644 --- a/src/core/CameraStream.cpp +++ b/src/core/CameraStream.cpp @@ -98,10 +98,12 @@ shared_ptr CameraStream::userBufferToCameraBuffer(camera_buffer_t* } if (!camBuffer) { // Not found in the pool, so create a new CameraBuffer for it. + v4l2_buf_type v4l2BufType = PlatformData::getV4L2BufType(mCameraId); ubuffer->index = mUserBuffersPool.size(); camBuffer = std::make_shared(mCameraId, BUFFER_USAGE_GENERAL, ubuffer->s.memType, - ubuffer->s.size, ubuffer->index, ubuffer->s.format); + ubuffer->s.size, ubuffer->index, ubuffer->s.format, + v4l2BufType); CheckAndLogError(!camBuffer, nullptr, "@%s: fail to alloc CameraBuffer", __func__); mUserBuffersPool.push_back(camBuffer); } diff --git a/src/core/CsiMetaDevice.cpp b/src/core/CsiMetaDevice.cpp index 007fbbfa..25fb9f64 100644 --- a/src/core/CsiMetaDevice.cpp +++ b/src/core/CsiMetaDevice.cpp @@ -377,7 +377,16 @@ int CsiMetaDevice::setFormat() { struct v4l2_format v4l2fmt; CLEAR(v4l2fmt); +#ifdef CAL_BUILD v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; +#else + int dev_caps = mCsiMetaDevice->GetDeviceCaps(); + if (dev_caps & V4L2_CAP_META_CAPTURE) { + v4l2fmt.type = V4L2_BUF_TYPE_META_CAPTURE; + } else { + v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + } +#endif v4l2fmt.fmt.pix_mp.width = mEmbeddedMetaData.width; v4l2fmt.fmt.pix_mp.height = mEmbeddedMetaData.height; v4l2fmt.fmt.pix_mp.num_planes = mEmbeddedMetaData.planesNum; diff --git a/src/core/DeviceBase.cpp b/src/core/DeviceBase.cpp index 7c14b203..800fdd4a 100644 --- a/src/core/DeviceBase.cpp +++ b/src/core/DeviceBase.cpp @@ -59,6 +59,9 @@ DeviceBase::DeviceBase(int cameraId, VideoNodeType nodeType, VideoNodeDirection nodeType); mDevice = new V4L2VideoNode(devName); +#ifdef LINUX_BUILD + mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; +#endif } DeviceBase::~DeviceBase() { @@ -74,7 +77,24 @@ int DeviceBase::openDevice() { SyncManager::getInstance()->updateSyncCamNum(); // FRAME_SYNC_E +#ifdef LINUX_BUILD + int ret = mDevice->Open(O_RDWR); + if (ret) + return ret; + + int dev_caps = mDevice->GetDeviceCaps(); + if (dev_caps & V4L2_CAP_VIDEO_CAPTURE) { + mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; + } else { + mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + } + + PlatformData::setV4L2BufType(mCameraId, mBufType); + + return OK; +#else return mDevice->Open(O_RDWR); +#endif } void DeviceBase::closeDevice() { @@ -139,6 +159,10 @@ int DeviceBase::queueBuffer(int64_t sequence) { mBufferQueuing = true; } +#ifdef LINUX_BUILD + buffer->getV4L2Buffer().SetType(mBufType); + +#endif int ret = onQueueBuffer(sequence, buffer); if (ret == OK) { ret = mDevice->PutFrame(&buffer->getV4L2Buffer()); @@ -324,7 +348,11 @@ int MainDevice::createBufferPool(const stream_t& config) { v4l2fmt.fmt.pix.sizeimage = 0; } +#ifdef LINUX_BUILD + v4l2fmt.type = mBufType; +#else v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +#endif V4L2Format tmpbuf{v4l2fmt}; int ret = mDevice->SetFormat(tmpbuf); CheckAndLogError(ret != OK, ret, "set v4l2 format failed ret=%d", ret); @@ -428,7 +456,11 @@ int DolCaptureDevice::createBufferPool(const stream_t& config) { v4l2fmt.fmt.pix.sizeimage = 0; v4l2fmt.fmt.pix_mp.field = 0; +#ifdef LINUX_BUILD + v4l2fmt.type = mBufType; +#else v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +#endif V4L2Format tmpbuf{v4l2fmt}; int ret = mDevice->SetFormat(tmpbuf); CheckAndLogError(ret != OK, ret, "set DOL v4l2 format failed ret=%d", ret); diff --git a/src/core/DeviceBase.h b/src/core/DeviceBase.h index 94774254..95d60ce6 100644 --- a/src/core/DeviceBase.h +++ b/src/core/DeviceBase.h @@ -152,6 +152,9 @@ class DeviceBase : public EventSource { uint32_t mMaxBufferNumber; bool mBufferQueuing; +#ifdef LINUX_BUILD + v4l2_buf_type mBufType; +#endif private: DISALLOW_COPY_AND_ASSIGN(DeviceBase); diff --git a/src/platformdata/PlatformData.cpp b/src/platformdata/PlatformData.cpp index 357b9b76..1cb6705b 100644 --- a/src/platformdata/PlatformData.cpp +++ b/src/platformdata/PlatformData.cpp @@ -1996,6 +1996,14 @@ int64_t PlatformData::getReqWaitTimeout(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mReqWaitTimeout; } +v4l2_buf_type PlatformData::getV4L2BufType(int cameraId) { + return getInstance()->mStaticCfg.mCameras[cameraId].mV4l2BufType; +} + +void PlatformData::setV4L2BufType(int cameraId, v4l2_buf_type v4l2BufType) { + getInstance()->mStaticCfg.mCameras[cameraId].mV4l2BufType = v4l2BufType; +} + // LEVEL0_ICBM_S bool PlatformData::isGPUICBMEnabled() { return getInstance()->mStaticCfg.mCommonConfig.isGPUICBMEnabled; diff --git a/src/platformdata/PlatformData.h b/src/platformdata/PlatformData.h index ebb0f0df..e04c21cc 100644 --- a/src/platformdata/PlatformData.h +++ b/src/platformdata/PlatformData.h @@ -213,7 +213,8 @@ class PlatformData { mDisableBLCAGainLow(-1), mDisableBLCAGainHigh(-1), mResetLinkRoute(true), - mReqWaitTimeout(0) {} + mReqWaitTimeout(0), + mV4l2BufType(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {} std::vector mMediaCtlConfs; @@ -365,6 +366,7 @@ class PlatformData { bool mResetLinkRoute; /* mReqWaitTimeout is used to override dqbuf timeout (ns) */ int64_t mReqWaitTimeout; + v4l2_buf_type mV4l2BufType; }; /** @@ -1835,6 +1837,22 @@ class PlatformData { */ static int64_t getReqWaitTimeout(int cameraId); + /** + * Get V4L2 buffer type + * + * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] + * \return V4L2 buffer type + */ + static v4l2_buf_type getV4L2BufType(int cameraId); + + /** + * Set V4L2 buffer type + * + * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] + * \param v4l2BufType:V4L2 buffer type + */ + static void setV4L2BufType(int cameraId, v4l2_buf_type v4l2BufType); + // LEVEL0_ICBM_S /** * Check GPU ICBM is enabled or not