Skip to content

Commit

Permalink
Multiple MTL, RPL, ADL releases.
Browse files Browse the repository at this point in the history
Signed-off-by: zouxiaoh <[email protected]>
  • Loading branch information
zouxiaoh committed Aug 8, 2024
1 parent f62c663 commit 6cea480
Show file tree
Hide file tree
Showing 14 changed files with 1,728 additions and 20 deletions.
545 changes: 545 additions & 0 deletions config/linux/ipu6/sensors/isx031.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/linux/ipu6ep/libcamhal_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<!-- The value format of availableSensors is "sensor name"-wf/uf-"CSI port ID" -->
<availableSensors value="ov13b10-wf-2,ov13b10-uf-1,ov8856-wf-2,ov8856-uf-1,ov01a10-uf-1,ov01a10-uf-2,ov02c10-uf-1,ov02c10-uf-2,
ov2740-uf-1,hm2170-uf-1,hm2170-uf-2,hi556-uf-1,ov01a1s-uf-1,ov08a10-uf-1,
imx390,ar0234,external_source,ar0234_usb,lt6911uxc,lt6911uxe"/>
isx031,imx390,ar0234,external_source,ar0234_usb,lt6911uxc,lt6911uxe"/>
</Common>
</CameraSettings>
545 changes: 545 additions & 0 deletions config/linux/ipu6ep/sensors/isx031.xml

Large diffs are not rendered by default.

545 changes: 545 additions & 0 deletions config/linux/ipu6epmtl/sensors/isx031.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions modules/v4l2/v4l2_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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_;
Expand Down
15 changes: 11 additions & 4 deletions modules/v4l2/v4l2_video_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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__);

Expand Down Expand Up @@ -530,7 +537,7 @@ int V4L2VideoNode::SetFormat(const V4L2Format& format) {
}

V4L2Format fmt(format);
fmt.SetType(buffer_type_);
buffer_type_ = static_cast<enum v4l2_buf_type>(fmt.Type());

if (V4L2_TYPE_IS_META(buffer_type_)) {
fmt.SetSizeImage(0, 0);
Expand Down
15 changes: 3 additions & 12 deletions src/core/CameraBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<id%d>%s: construct buffer with usage:%d, memory:%d, size:%d, format:%d, index:%d",
Expand All @@ -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() {
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/core/CameraBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/core/CameraStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ shared_ptr<CameraBuffer> 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<CameraBuffer>(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);
}
Expand Down
9 changes: 9 additions & 0 deletions src/core/CsiMetaDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions src/core/DeviceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/core/DeviceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/platformdata/PlatformData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 19 additions & 1 deletion src/platformdata/PlatformData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MediaCtlConf> mMediaCtlConfs;

Expand Down Expand Up @@ -365,6 +366,7 @@ class PlatformData {
bool mResetLinkRoute;
/* mReqWaitTimeout is used to override dqbuf timeout (ns) */
int64_t mReqWaitTimeout;
v4l2_buf_type mV4l2BufType;
};

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6cea480

Please sign in to comment.