Skip to content

Commit 60e95ab

Browse files
Kontra2Bymodlin
andauthored
Enabling Y12I mode for IR calibration stream (realsenseai#313)
Co-authored-by: Yogev Modlin <117653169+ymodlin@users.noreply.github.com>
1 parent 8386163 commit 60e95ab

7 files changed

Lines changed: 67 additions & 28 deletions

File tree

kernel/realsense/d4xx.c

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,9 @@ static const u16 ds5_framerates[] = {5, 30};
659659
#define DS5_FRAMERATE_DEFAULT_IDX 1
660660

661661
static const u16 ds5_framerate_30 = 30;
662-
663-
static const u16 ds5_framerate_15_30[] = {15, 30};
664-
665662
static const u16 ds5_framerate_25 = 25;
663+
static const u16 ds5_framerate_15_30[] = {15, 30};
666664
static const u16 ds5_framerate_15_25[] = {15, 25};
667-
668665
static const u16 ds5_depth_framerate_to_30[] = {5, 15, 30};
669666
static const u16 ds5_framerate_to_30[] = {5, 10, 15, 30};
670667
static const u16 ds5_framerate_to_60[] = {5, 15, 30, 60};
@@ -1005,6 +1002,15 @@ static const struct ds5_resolution d43x_calibration_sizes[] = {
10051002
},
10061003
};
10071004

1005+
static const struct ds5_resolution d45x_calibration_sizes[] = {
1006+
{
1007+
.width = 1280,
1008+
.height = 800,
1009+
.framerates = ds5_framerate_15_25,
1010+
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
1011+
},
1012+
};
1013+
10081014
static const struct ds5_resolution d46x_calibration_sizes[] = {
10091015
{
10101016
.width = 1600,
@@ -1129,13 +1135,33 @@ static const struct ds5_format ds5_y_formats_41x[] = {
11291135
.n_resolutions = ARRAY_SIZE(y8_41x_sizes),
11301136
.resolutions = y8_41x_sizes,
11311137
}, {
1132-
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
1133-
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */
1138+
.data_type = GMSL_CSI_DT_RGB_888, /* Y12I, 24-bit Calibration */
1139+
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24,
11341140
.n_resolutions = ARRAY_SIZE(d41x_calibration_sizes),
11351141
.resolutions = d41x_calibration_sizes,
11361142
},
11371143
};
11381144

1145+
static const struct ds5_format ds5_y_formats_45x[] = {
1146+
{
1147+
/* First format: default */
1148+
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
1149+
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
1150+
.n_resolutions = ARRAY_SIZE(y8_sizes),
1151+
.resolutions = y8_sizes,
1152+
}, {
1153+
.data_type = GMSL_CSI_DT_YUV422_8, /* Y8I */
1154+
.mbus_code = MEDIA_BUS_FMT_VYUY8_1X16,
1155+
.n_resolutions = ARRAY_SIZE(y8_sizes),
1156+
.resolutions = y8_sizes,
1157+
}, {
1158+
.data_type = GMSL_CSI_DT_RGB_888, /* Y12I, 24-bit Calibration */
1159+
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24,
1160+
.n_resolutions = ARRAY_SIZE(d45x_calibration_sizes),
1161+
.resolutions = d45x_calibration_sizes,
1162+
},
1163+
};
1164+
11391165
static const struct ds5_format ds5_41x_rgb_format = {
11401166
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
11411167
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
@@ -1713,9 +1739,7 @@ static int ds5_configure(struct ds5 *state)
17131739
#ifdef CONFIG_VIDEO_D4XX_SERDES
17141740
data_type1 = sensor->config.format->data_type;
17151741
data_type2 = state->is_imu ? 0x00 : md_fmt;
1716-
/* do not have metadata for y12i */
1717-
if (state->is_y8 && data_type1 == GMSL_CSI_DT_RGB_888)
1718-
data_type2 = 0;
1742+
17191743
vc_id = state->g_ctx.dst_vc;
17201744

17211745
ret = ds5_setup_pipeline(state, data_type1, data_type2, sensor->pipe_id,
@@ -4817,6 +4841,10 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
48174841
sensor->formats = ds5_y_formats_41x;
48184842
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_41x);
48194843
break;
4844+
case DS5_DEVICE_TYPE_D45X:
4845+
sensor->formats = ds5_y_formats_45x;
4846+
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_45x);
4847+
break;
48204848
default:
48214849
sensor->formats = state->variant->formats;
48224850
sensor->n_formats = state->variant->n_formats;
@@ -5897,4 +5925,4 @@ MODULE_AUTHOR("Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,\n\
58975925
Shikun Ding <shikun.ding@intel.com>,\n\
58985926
Dmitry Perchanov <dmitry.perchanov@intel.com>");
58995927
MODULE_LICENSE("GPL v2");
5900-
MODULE_VERSION("1.0.1.31");
5928+
MODULE_VERSION("1.0.1.32");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/drivers/media/platform/tegra/camera/vi/vi5_fops.c b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
2+
index 7d07ccd7..c64dcc38 100644
3+
--- a/drivers/media/platform/tegra/camera/vi/vi5_fops.c
4+
+++ b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
5+
@@ -612,7 +612,8 @@ static void vi5_capture_dequeue(struct tegra_channel *chan,
6+
trace_tegra_channel_capture_frame("sof", &ts);
7+
vb->vb2_buf.timestamp = descr->status.sof_timestamp;
8+
9+
- if (frame_err)
10+
+ /* TODO: Remove the branch or process the error for Y12I only */
11+
+ if (false && frame_err)
12+
buf->vb2_state = VB2_BUF_STATE_ERROR;
13+
else
14+
buf->vb2_state = VB2_BUF_STATE_DONE;
15+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../6.0/0003-Fix-y12i-calibration-stream.patch
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../6.0/0003-Fix-y12i-calibration-stream.patch

test/test_metadata/build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ set -x
44

55
rm -rf test_metadata test_metadata.o
66

7-
gcc test_metadata.c framesextract.c -o test_metadata
8-
9-
./test_metadata "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
7+
gcc -g -O0 test_metadata.c framesextract.c -o test_metadata

test/test_metadata/test_metadata

-25.7 KB
Binary file not shown.

test/test_metadata/test_metadata.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void requestBuffers(int fd, uint32_t type, uint32_t memory, uint32_t count)
218218
}
219219
}
220220

221-
void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index, uint32_t size)
221+
void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index)
222222
{
223223
struct v4l2_buffer v4l2Buffer;
224224
memset(&v4l2Buffer, 0, sizeof(v4l2Buffer));
@@ -229,7 +229,7 @@ void* queryMapQueueBuf(int fd, uint32_t type, uint32_t memory, uint8_t index, ui
229229
if (ret)
230230
return NULL;
231231
void* buffer = mmap(NULL,
232-
size,
232+
v4l2Buffer.length,
233233
PROT_READ | PROT_WRITE,
234234
MAP_SHARED,
235235
fd,
@@ -295,13 +295,11 @@ int main(int argc, char** argv) {
295295
depthBuffers[i] = queryMapQueueBuf(video_fd,
296296
V4L2_BUF_TYPE_VIDEO_CAPTURE,
297297
V4L2_MEMORY_MMAP,
298-
i,
299-
2 * width * height);
298+
i);
300299
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
301300
V4L2_BUF_TYPE_META_CAPTURE,
302301
V4L2_MEMORY_MMAP,
303-
i,
304-
4096);
302+
i);
305303
}
306304

307305
int ret = ioctl(md_fd, VIDIOC_STREAMON, &mdType);
@@ -356,13 +354,11 @@ int main(int argc, char** argv) {
356354
depthBuffers[i] = queryMapQueueBuf(video_fd,
357355
V4L2_BUF_TYPE_VIDEO_CAPTURE,
358356
V4L2_MEMORY_MMAP,
359-
i,
360-
2 * width * height);
357+
i);
361358
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
362359
V4L2_BUF_TYPE_META_CAPTURE,
363360
V4L2_MEMORY_MMAP,
364-
i,
365-
4096);
361+
i);
366362
}
367363

368364
int ret = ioctl(md_fd, VIDIOC_STREAMON, &mdType);
@@ -406,7 +402,9 @@ int main(int argc, char** argv) {
406402
fprintf(stderr, "Error opening Ir video devices\n");
407403
return 1;
408404
}
409-
setFmt(video_fd, V4L2_PIX_FMT_GREY, width, height);
405+
uint32_t format = V4L2_PIX_FMT_GREY;
406+
if (stream_repeat % 2) format = V4L2_PIX_FMT_Y12I;
407+
setFmt(video_fd, format, width, height);
410408
setFPS(video_fd, fps);
411409
requestBuffers(video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_MEMORY_MMAP, SIZE_METADATA_BUFFERS);
412410
requestBuffers(md_fd, V4L2_BUF_TYPE_META_CAPTURE, V4L2_MEMORY_MMAP, SIZE_METADATA_BUFFERS);
@@ -416,13 +414,11 @@ int main(int argc, char** argv) {
416414
depthBuffers[i] = queryMapQueueBuf(video_fd,
417415
V4L2_BUF_TYPE_VIDEO_CAPTURE,
418416
V4L2_MEMORY_MMAP,
419-
i,
420-
width * height);
417+
i);
421418
metaDataBuffers[i] = queryMapQueueBuf(md_fd,
422419
V4L2_BUF_TYPE_META_CAPTURE,
423420
V4L2_MEMORY_MMAP,
424-
i,
425-
4096);
421+
i);
426422
}
427423

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

0 commit comments

Comments
 (0)