Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
39 changes: 35 additions & 4 deletions kernel/realsense/d4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,15 @@ static const struct ds5_resolution d46x_calibration_sizes[] = {
},
};

static const struct ds5_resolution ds5_calibration_sizes[] = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why ds5 and not d45x_calibration_size?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will be fixed with next commit

{
.width = 1280,
.height = 800,
.framerates = ds5_framerate_15_25,
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
},
};

static const struct ds5_resolution ds5_size_imu[] = {
{
.width = 32,
Expand Down Expand Up @@ -1136,6 +1145,26 @@ static const struct ds5_format ds5_y_formats_41x[] = {
},
};

static const struct ds5_format ds5_y_formats_45x[] = {
{
/* First format: default */
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
.n_resolutions = ARRAY_SIZE(y8_sizes),
.resolutions = y8_sizes,
}, {
.data_type = GMSL_CSI_DT_YUV422_8, /* Y8I */
.mbus_code = MEDIA_BUS_FMT_VYUY8_1X16,
.n_resolutions = ARRAY_SIZE(y8_sizes),
.resolutions = y8_sizes,
}, {
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove the comment FIXME

@Kontra2B Kontra2B Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Shall I change the previous line comment to Y12I as well?

.n_resolutions = ARRAY_SIZE(ds5_calibration_sizes),
.resolutions = ds5_calibration_sizes,
},
};

static const struct ds5_format ds5_41x_rgb_format = {
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
Expand Down Expand Up @@ -1713,9 +1742,7 @@ static int ds5_configure(struct ds5 *state)
#ifdef CONFIG_VIDEO_D4XX_SERDES
data_type1 = sensor->config.format->data_type;
data_type2 = state->is_imu ? 0x00 : md_fmt;
/* do not have metadata for y12i */
if (state->is_y8 && data_type1 == GMSL_CSI_DT_RGB_888)
data_type2 = 0;

vc_id = state->g_ctx.dst_vc;

ret = ds5_setup_pipeline(state, data_type1, data_type2, sensor->pipe_id,
Expand Down Expand Up @@ -4817,6 +4844,10 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
sensor->formats = ds5_y_formats_41x;
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_41x);
break;
case DS5_DEVICE_TYPE_D45X:
sensor->formats = ds5_y_formats_45x;
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_45x);
break;
default:
sensor->formats = state->variant->formats;
sensor->n_formats = state->variant->n_formats;
Expand Down Expand Up @@ -5897,4 +5928,4 @@ MODULE_AUTHOR("Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,\n\
Shikun Ding <shikun.ding@intel.com>,\n\
Dmitry Perchanov <dmitry.perchanov@intel.com>");
MODULE_LICENSE("GPL v2");
MODULE_VERSION("1.0.1.31");
MODULE_VERSION("1.0.1.32");
14 changes: 14 additions & 0 deletions nvidia-oot/6.0/0003-Fix-y12i-calibration-stream.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/drivers/media/platform/tegra/camera/vi/vi5_fops.c b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
index 7d07ccd7..c64dcc38 100644
--- a/drivers/media/platform/tegra/camera/vi/vi5_fops.c
+++ b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
@@ -612,7 +612,7 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
trace_tegra_channel_capture_frame("sof", &ts);
vb->vb2_buf.timestamp = descr->status.sof_timestamp;

- if (frame_err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add here a TODO comment for the future to remove this "false"

+ if (false && frame_err)
Comment on lines +10 to +11

Copilot AI Dec 4, 2025

Copy link

Choose a reason for hiding this comment

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

Using if (false && frame_err) to disable error checking is a temporary workaround that leaves dead code. Consider either processing Y12I errors specifically as suggested in the TODO, or documenting why error checking must be disabled for Y12I format.

Suggested change
+ /* TODO: Remove the branch or process the error for Y12I only */
+ if (false && frame_err)
+ /*
+ * Error checking is disabled for Y12I format due to known issues with
+ * error reporting for this format. For other formats, process errors normally.
+ * See issue tracker #<insert-issue-number-if-any> for details.
+ */
+ if (frame_err && chan->fmtinfo->fourcc != V4L2_PIX_FMT_Y12I)

Copilot uses AI. Check for mistakes.
buf->vb2_state = VB2_BUF_STATE_ERROR;
else
buf->vb2_state = VB2_BUF_STATE_DONE;

1 change: 1 addition & 0 deletions nvidia-oot/6.1/0003-Fix-y12i-calibration-stream.patch
1 change: 1 addition & 0 deletions nvidia-oot/6.2/0003-Fix-y12i-calibration-stream.patch
4 changes: 1 addition & 3 deletions test/test_metadata/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ set -x

rm -rf test_metadata test_metadata.o

gcc test_metadata.c framesextract.c -o test_metadata

./test_metadata "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
gcc -g -O0 test_metadata.c framesextract.c -o test_metadata
Binary file removed test/test_metadata/test_metadata
Binary file not shown.
26 changes: 11 additions & 15 deletions test/test_metadata/test_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void requestBuffers(int fd, uint32_t type, uint32_t memory, uint32_t count)
}
}

void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index, uint32_t size)
void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index)
{
struct v4l2_buffer v4l2Buffer;
memset(&v4l2Buffer, 0, sizeof(v4l2Buffer));
Expand All @@ -229,7 +229,7 @@ void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index, ui
if (ret)
return NULL;
void* buffer = mmap(NULL,
size,
v4l2Buffer.length,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
Expand Down Expand Up @@ -295,13 +295,11 @@ int main(int argc, char** argv) {
depthBuffers[i] = queryMapQueueBuf(video_fd,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_MEMORY_MMAP,
i,
2 * width * height);
i);
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
V4L2_BUF_TYPE_META_CAPTURE,
V4L2_MEMORY_MMAP,
i,
4096);
i);
}

int ret = ioctl(md_fd, VIDIOC_STREAMON, &mdType);
Expand Down Expand Up @@ -356,13 +354,11 @@ int main(int argc, char** argv) {
depthBuffers[i] = queryMapQueueBuf(video_fd,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_MEMORY_MMAP,
i,
2 * width * height);
i);
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
V4L2_BUF_TYPE_META_CAPTURE,
V4L2_MEMORY_MMAP,
i,
4096);
i);
}

int ret = ioctl(md_fd, VIDIOC_STREAMON, &mdType);
Expand Down Expand Up @@ -406,7 +402,9 @@ int main(int argc, char** argv) {
fprintf(stderr, "Error opening Ir video devices\n");
return 1;
}

Copilot AI Dec 4, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The variable stream_repeat is used here but not visible in the diff context. Consider adding a comment explaining that the format alternates with each iteration to make the intent clearer for future maintainers.

Suggested change
}
}
// Alternate the IR stream format with each iteration:
// If stream_repeat is odd, use V4L2_PIX_FMT_Y12I; if even, use V4L2_PIX_FMT_GREY.

Copilot uses AI. Check for mistakes.
setFmt(video_fd, V4L2_PIX_FMT_GREY, width, height);
uint32_t format = V4L2_PIX_FMT_GREY;
if (stream_repeat % 2) format = V4L2_PIX_FMT_Y12I;
setFmt(video_fd, format, width, height);
setFPS(video_fd, fps);
requestBuffers(video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_MEMORY_MMAP, SIZE_METADATA_BUFFERS);
requestBuffers(md_fd, V4L2_BUF_TYPE_META_CAPTURE, V4L2_MEMORY_MMAP, SIZE_METADATA_BUFFERS);
Expand All @@ -416,13 +414,11 @@ int main(int argc, char** argv) {
depthBuffers[i] = queryMapQueueBuf(video_fd,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_MEMORY_MMAP,
i,
width * height);
i);
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
V4L2_BUF_TYPE_META_CAPTURE,
V4L2_MEMORY_MMAP,
i,
4096);
i);
}

int ret = ioctl(md_fd, VIDIOC_STREAMON, &mdType);
Expand Down