Skip to content
Merged
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
227 changes: 223 additions & 4 deletions kernel/realsense/d4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#define DS5_FW_VERSION 0x030C
#define DS5_FW_BUILD 0x030E
#define DS5_DEVICE_TYPE 0x0310
#define DS5_DEVICE_TYPE_D41X 7
#define DS5_DEVICE_TYPE_D45X 6
#define DS5_DEVICE_TYPE_D43X 5
#define DS5_DEVICE_TYPE_D46X 4
Expand Down Expand Up @@ -662,15 +663,65 @@ static const u16 ds5_framerate_30 = 30;
static const u16 ds5_framerate_15_30[] = {15, 30};

static const u16 ds5_framerate_25 = 25;
static const u16 ds5_framerate_15_25[] = {15, 25};

static const u16 ds5_depth_framerate_to_30[] = {5, 15, 30};
static const u16 ds5_framerate_to_30[] = {5, 10, 15, 30};
static const u16 ds5_framerate_to_60[] = {5, 15, 30, 60};
static const u16 ds5_framerate_to_90[] = {5, 15, 30, 60, 90};
static const u16 ds5_41x_depth_framerate_to_30[] = {6, 15, 30};
static const u16 ds5_41x_framerate_to_30[] = {6, 15, 30};
static const u16 ds5_41x_framerate_to_60_no_15[] = {6, 30, 60};
static const u16 ds5_41x_framerate_to_60[] = {6, 15, 30, 60};
static const u16 ds5_41x_framerate_to_90[] = {6, 15, 30, 60, 90};
static const u16 ds5_framerate_100[] = {100};
static const u16 ds5_framerate_90[] = {90};
static const u16 ds5_imu_framerates[] = {50, 100, 200, 400};

static const struct ds5_resolution d41x_depth_sizes[] = {
{
.width = 1280,
.height = 720,
.framerates = ds5_41x_depth_framerate_to_30,
.n_framerates = ARRAY_SIZE(ds5_41x_depth_framerate_to_30),
}, {
.width = 848,
.height = 480,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 848,
.height = 100,
.framerates = ds5_framerate_100,
.n_framerates = ARRAY_SIZE(ds5_framerate_100),
}, {
.width = 640,
.height = 480,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 640,
.height = 360,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 480,
.height = 270,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 424,
.height = 240,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 256,
.height = 144,
.framerates = ds5_framerate_90,
.n_framerates = ARRAY_SIZE(ds5_framerate_90),

Copilot AI Aug 11, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent framerate array usage. All other entries in d41x_depth_sizes use ds5_framerate_to_90 but this entry uses ds5_framerate_90. This should likely be ds5_framerate_to_90 for consistency, unless there's a specific reason for this 256x144 resolution to only support 90fps.

Suggested change
.n_framerates = ARRAY_SIZE(ds5_framerate_90),
.framerates = ds5_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),

Copilot uses AI. Check for mistakes.
},
};

static const struct ds5_resolution d43x_depth_sizes[] = {
{
.width = 1280,
Expand Down Expand Up @@ -763,6 +814,104 @@ static const struct ds5_resolution y8_sizes[] = {
}
};

static const struct ds5_resolution y8_41x_sizes[] = {
{
.width = 1920,
.height = 1080,
.framerates = ds5_framerate_15_25,
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
}, {
.width = 1280,
.height = 720,
.framerates = ds5_41x_depth_framerate_to_30,
.n_framerates = ARRAY_SIZE(ds5_41x_depth_framerate_to_30),
}, {
.width = 960,
.height = 540,
.framerates = ds5_framerate_15_25,
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
}, {
.width = 848,
.height = 480,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 848,
.height = 100,
.framerates = ds5_framerate_100,
.n_framerates = ARRAY_SIZE(ds5_framerate_100),
}, {
.width = 640,
.height = 480,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 640,
.height = 360,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 480,
.height = 270,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}, {
.width = 424,
.height = 240,
.framerates = ds5_41x_framerate_to_90,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
}
};

static const struct ds5_resolution ds5_41x_rgb_sizes[] = {
{
.width = 1920,
.height = 1080,
.framerates = ds5_41x_framerate_to_30,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_30),
}, {
.width = 1280,
.height = 720,
.framerates = ds5_41x_framerate_to_30,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_30),
}, {
.width = 960,
.height = 540,
.framerates = ds5_41x_framerate_to_60,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
}, {
.width = 848,
.height = 480,
.framerates = ds5_41x_framerate_to_60,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
}, {
.width = 640,
.height = 480,
.framerates = ds5_41x_framerate_to_60,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
}, {
.width = 640,
.height = 360,
.framerates = ds5_41x_framerate_to_60,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
}, {
.width = 424,
.height = 240,
.framerates = ds5_41x_framerate_to_60,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
}, {
.width = 320,
.height = 240,
.framerates = ds5_41x_framerate_to_60_no_15,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60_no_15),
}, {
.width = 320,
.height = 180,
.framerates = ds5_41x_framerate_to_60_no_15,
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60_no_15),
},
};

static const struct ds5_resolution ds5_rlt_rgb_sizes[] = {
{
.width = 1280,
Expand Down Expand Up @@ -838,6 +987,15 @@ static const struct ds5_resolution ds5_size_w10 = {
.n_framerates = 1,
};

static const struct ds5_resolution d41x_calibration_sizes[] = {
{
.width = 1920,
.height = 1080,
.framerates = ds5_framerate_15_25,
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
},
};

static const struct ds5_resolution d43x_calibration_sizes[] = {
{
.width = 1280,
Expand Down Expand Up @@ -875,6 +1033,26 @@ static const struct ds5_resolution ds5_size_imu_extended[] = {
},
};

static const struct ds5_format ds5_depth_formats_d41x[] = {
{
// TODO: 0x31 is replaced with 0x1e since it caused low FPS in Jetson.
.data_type = GMSL_CSI_DT_YUV422_8, /* Z16 */
.mbus_code = MEDIA_BUS_FMT_UYVY8_1X16,
.n_resolutions = ARRAY_SIZE(d41x_depth_sizes),
.resolutions = d41x_depth_sizes,
}, {
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
.n_resolutions = ARRAY_SIZE(d41x_depth_sizes),
.resolutions = d41x_depth_sizes,
}, {
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */
.n_resolutions = ARRAY_SIZE(d41x_calibration_sizes),
.resolutions = d41x_calibration_sizes,
},
};

static const struct ds5_format ds5_depth_formats_d43x[] = {
{
// TODO: 0x31 is replaced with 0x1e since it caused low FPS in Jetson.
Expand Down Expand Up @@ -938,6 +1116,33 @@ static const struct ds5_format ds5_y_formats_ds5u[] = {
},
};

static const struct ds5_format ds5_y_formats_41x[] = {
{
/* First format: default */
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
.n_resolutions = ARRAY_SIZE(y8_41x_sizes),
.resolutions = y8_41x_sizes,
}, {
.data_type = GMSL_CSI_DT_YUV422_8, /* Y8I */
.mbus_code = MEDIA_BUS_FMT_VYUY8_1X16,
.n_resolutions = ARRAY_SIZE(y8_41x_sizes),
.resolutions = y8_41x_sizes,
}, {
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */
.n_resolutions = ARRAY_SIZE(d41x_calibration_sizes),
.resolutions = d41x_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,
.n_resolutions = ARRAY_SIZE(ds5_41x_rgb_sizes),
.resolutions = ds5_41x_rgb_sizes,
};

static const struct ds5_format ds5_rlt_rgb_format = {
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
Expand Down Expand Up @@ -4590,6 +4795,9 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)

sensor = &state->depth.sensor;
switch (dev_type) {
case DS5_DEVICE_TYPE_D41X:
sensor->formats = ds5_depth_formats_d41x;
break;
case DS5_DEVICE_TYPE_D43X:
case DS5_DEVICE_TYPE_D45X:
sensor->formats = ds5_depth_formats_d43x;
Expand All @@ -4604,8 +4812,15 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
sensor->mux_pad = DS5_MUX_PAD_DEPTH;

sensor = &state->ir.sensor;
sensor->formats = state->variant->formats;
sensor->n_formats = state->variant->n_formats;
switch (dev_type) {
case DS5_DEVICE_TYPE_D41X:
sensor->formats = ds5_y_formats_41x;
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_41x);
break;
default:
sensor->formats = state->variant->formats;
sensor->n_formats = state->variant->n_formats;
}
sensor->mux_pad = DS5_MUX_PAD_IR;

sensor = &state->rgb.sensor;
Expand All @@ -4615,6 +4830,10 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
sensor->formats = &ds5_onsemi_rgb_format;
sensor->n_formats = DS5_ONSEMI_RGB_N_FORMATS;
break;
case DS5_DEVICE_TYPE_D41X:
sensor->formats = &ds5_41x_rgb_format;
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
break;
case DS5_DEVICE_TYPE_D45X:
sensor->formats = &ds5_rlt_rgb_format;
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
Expand Down Expand Up @@ -5440,7 +5659,7 @@ static int ds5_probe(struct i2c_client *c, const struct i2c_device_id *id)
mutex_init(&state->lock);

state->client = c;
dev_warn(&c->dev, "Probing driver for D45x\n");
dev_warn(&c->dev, "Probing driver for D4xx\n");

state->variant = ds5_variants + id->driver_data;
#ifdef CONFIG_OF
Expand Down Expand Up @@ -5678,4 +5897,4 @@ MODULE_AUTHOR("Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>,\n\
Shikun Ding <shikun.ding@intel.com>");
MODULE_AUTHOR("Dmitry Perchanov <dmitry.perchanov@intel.com>");
MODULE_LICENSE("GPL v2");
MODULE_VERSION("1.0.1.28");
MODULE_VERSION("1.0.1.29");