Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adlp metadata #11822

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/99-realsense-d4xx-mipi-dfu.rules
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SUBSYSTEM=="d4xx-class",KERNEL=="d4xx-dfu[0-9]*", GROUP="video", MODE="0660"
SUBSYSTEM=="d4xx-class",KERNEL=="d4xx-dfu*", GROUP="video", MODE="0660"

2 changes: 0 additions & 2 deletions scripts/rs-enum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ for camera in $mux_list; do
fi
create_dfu_dev=1 # will create DFU device link for camera
# metadata link
# skip all metadata nodes for now
continue
# skip IR metadata node for now.
[[ ${camera_names["${sens}"]} == 'ir' ]] && continue
# skip IMU metadata node.
Expand Down
8 changes: 4 additions & 4 deletions scripts/rs_ipu6_d457_bind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ media-ctl -v -l "\"Intel IPU6 ${csi2}\":1 -> \"Intel IPU6 ${csi2_be_soc}\":0[1]"
media-ctl -v -l "\"DS5 mux ${mux}\":0 -> \"Intel IPU6 ${csi2}\":0[1]" 1>/dev/null

media-ctl -v -l "\"D4XX depth ${mux}\":0 -> \"DS5 mux ${mux}\":1[1]" 1>/dev/null
# video streaming node
# DEPTH video streaming node
media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":1 -> \"Intel IPU6 ${be_soc_cap} 0\":0[5]" 1>/dev/null
# metadata node
#media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":2 -> \"Intel IPU6 ${be_soc_cap} 1\":0[5]" 1>/dev/null
# DEPTH metadata node
media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":2 -> \"Intel IPU6 ${be_soc_cap} 1\":0[5]" 1>/dev/null

media-ctl -v -l "\"D4XX rgb ${mux}\":0 -> \"DS5 mux ${mux}\":2[1]" 1>/dev/null
# RGB link
media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":3 -> \"Intel IPU6 ${be_soc_cap} 2\":0[5]" 1>/dev/null
# RGB metadata node
#media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":4 -> \"Intel IPU6 ${be_soc_cap} 3\":0[5]" 1>/dev/null
media-ctl -v -l "\"Intel IPU6 ${csi2_be_soc}\":4 -> \"Intel IPU6 ${be_soc_cap} 3\":0[5]" 1>/dev/null

# IR link
media-ctl -v -l "\"D4XX motion detection ${mux}\":0 -> \"DS5 mux ${mux}\":3[1]" 1>/dev/null
Expand Down
33 changes: 30 additions & 3 deletions src/linux/backend-v4l2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,8 @@ namespace librealsense

info.mi = vs.compare("imu") ? 0 : 4;
info.unique_id += "-" + std::to_string(i);
info.uvc_capabilities &= ~(V4L2_CAP_META_CAPTURE); // clean caps
mipi_rs_enum_nodes.emplace_back(info, video_path);

// Get metadata node
// Check if file on video_md_path is exists
vfd = open(video_md_path.c_str(), O_RDONLY | O_NONBLOCK);
Expand Down Expand Up @@ -2201,7 +2201,8 @@ namespace librealsense

void v4l_uvc_meta_device::streamon() const
{
if (_md_fd != -1)
bool jetson_platform = is_platform_jetson();
if ((_md_fd != -1) && jetson_platform)
{
// D457 development - added for mipi device, for IR because no metadata there
// Metadata stream shall be configured first to allow sync with video node
Expand All @@ -2211,6 +2212,12 @@ namespace librealsense
// Invoke UVC streaming request
v4l_uvc_device::streamon();

// Metadata stream configured last for IPU6 and it will be in sync with video node
if ((_md_fd != -1) && !jetson_platform)
{
stream_ctl_on(_md_fd, _md_type);
}

}

void v4l_uvc_meta_device::streamoff() const
Expand Down Expand Up @@ -2337,10 +2344,30 @@ namespace librealsense
throw linux_backend_exception("ioctl(VIDIOC_G_FMT): " + _md_name + " node is not metadata capture");

bool success = false;

for (const uint32_t& request : { V4L2_META_FMT_D4XX, V4L2_META_FMT_UVC})
{
// Configure metadata format - try d4xx, then fallback to currently retrieve UVC default header of 12 bytes
memcpy(fmt.fmt.raw_data,&request,sizeof(request));
memcpy(fmt.fmt.raw_data, &request, sizeof(request));
// use only for IPU6?
if ((_dev.cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) && !is_platform_jetson())
{
/* Sakari patch for videodev2.h. This structure will be within kernel > 6.4 */
struct v4l2_meta_format {
Copy link
Contributor Author

@dmipx dmipx May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. @Nir-Az
this is union with 200 bytes so we don't care about some integers appended.

struct v4l2_format {
	__u32	 type;
	union {
		struct v4l2_pix_format		pix;     /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
		struct v4l2_pix_format_mplane	pix_mp;  /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
		struct v4l2_window		win;     /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
		struct v4l2_vbi_format		vbi;     /* V4L2_BUF_TYPE_VBI_CAPTURE */
		struct v4l2_sliced_vbi_format	sliced;  /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
		struct v4l2_sdr_format		sdr;     /* V4L2_BUF_TYPE_SDR_CAPTURE */
		struct v4l2_meta_format		meta;    /* V4L2_BUF_TYPE_META_CAPTURE */
		__u8	raw_data[200];                   /* user-defined */
	} fmt;
};

uint32_t dataformat;
uint32_t buffersize;
uint32_t width;
uint32_t height;
uint32_t bytesperline;
} meta;
// copy fmt from g_fmt ioctl
memcpy(&meta, fmt.fmt.raw_data, sizeof(meta));
// set fmt width, d4xx metadata is only one line
meta.dataformat = request;
meta.width = profile.width;
meta.height = 1;
memcpy(fmt.fmt.raw_data, &meta, sizeof(meta));
}

if(xioctl(_md_fd, VIDIOC_S_FMT, &fmt) >= 0)
{
Expand Down