Skip to content

Commit 35c4ab3

Browse files
authored
Add D41x support (#266)
* Add D41x support * Bump module version * Fix D41x resolutions
1 parent 48e39e0 commit 35c4ab3

File tree

1 file changed

+223
-4
lines changed

1 file changed

+223
-4
lines changed

kernel/realsense/d4xx.c

Lines changed: 223 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#define DS5_FW_VERSION 0x030C
6666
#define DS5_FW_BUILD 0x030E
6767
#define DS5_DEVICE_TYPE 0x0310
68+
#define DS5_DEVICE_TYPE_D41X 7
6869
#define DS5_DEVICE_TYPE_D45X 6
6970
#define DS5_DEVICE_TYPE_D43X 5
7071
#define DS5_DEVICE_TYPE_D46X 4
@@ -662,15 +663,65 @@ static const u16 ds5_framerate_30 = 30;
662663
static const u16 ds5_framerate_15_30[] = {15, 30};
663664

664665
static const u16 ds5_framerate_25 = 25;
666+
static const u16 ds5_framerate_15_25[] = {15, 25};
665667

666668
static const u16 ds5_depth_framerate_to_30[] = {5, 15, 30};
667669
static const u16 ds5_framerate_to_30[] = {5, 10, 15, 30};
668670
static const u16 ds5_framerate_to_60[] = {5, 15, 30, 60};
669671
static const u16 ds5_framerate_to_90[] = {5, 15, 30, 60, 90};
672+
static const u16 ds5_41x_depth_framerate_to_30[] = {6, 15, 30};
673+
static const u16 ds5_41x_framerate_to_30[] = {6, 15, 30};
674+
static const u16 ds5_41x_framerate_to_60_no_15[] = {6, 30, 60};
675+
static const u16 ds5_41x_framerate_to_60[] = {6, 15, 30, 60};
676+
static const u16 ds5_41x_framerate_to_90[] = {6, 15, 30, 60, 90};
670677
static const u16 ds5_framerate_100[] = {100};
671678
static const u16 ds5_framerate_90[] = {90};
672679
static const u16 ds5_imu_framerates[] = {50, 100, 200, 400};
673680

681+
static const struct ds5_resolution d41x_depth_sizes[] = {
682+
{
683+
.width = 1280,
684+
.height = 720,
685+
.framerates = ds5_41x_depth_framerate_to_30,
686+
.n_framerates = ARRAY_SIZE(ds5_41x_depth_framerate_to_30),
687+
}, {
688+
.width = 848,
689+
.height = 480,
690+
.framerates = ds5_41x_framerate_to_90,
691+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
692+
}, {
693+
.width = 848,
694+
.height = 100,
695+
.framerates = ds5_framerate_100,
696+
.n_framerates = ARRAY_SIZE(ds5_framerate_100),
697+
}, {
698+
.width = 640,
699+
.height = 480,
700+
.framerates = ds5_41x_framerate_to_90,
701+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
702+
}, {
703+
.width = 640,
704+
.height = 360,
705+
.framerates = ds5_41x_framerate_to_90,
706+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
707+
}, {
708+
.width = 480,
709+
.height = 270,
710+
.framerates = ds5_41x_framerate_to_90,
711+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
712+
}, {
713+
.width = 424,
714+
.height = 240,
715+
.framerates = ds5_41x_framerate_to_90,
716+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
717+
}, {
718+
.width = 256,
719+
.height = 144,
720+
.framerates = ds5_framerate_90,
721+
.n_framerates = ARRAY_SIZE(ds5_framerate_90),
722+
},
723+
};
724+
674725
static const struct ds5_resolution d43x_depth_sizes[] = {
675726
{
676727
.width = 1280,
@@ -763,6 +814,104 @@ static const struct ds5_resolution y8_sizes[] = {
763814
}
764815
};
765816

817+
static const struct ds5_resolution y8_41x_sizes[] = {
818+
{
819+
.width = 1920,
820+
.height = 1080,
821+
.framerates = ds5_framerate_15_25,
822+
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
823+
}, {
824+
.width = 1280,
825+
.height = 720,
826+
.framerates = ds5_41x_depth_framerate_to_30,
827+
.n_framerates = ARRAY_SIZE(ds5_41x_depth_framerate_to_30),
828+
}, {
829+
.width = 960,
830+
.height = 540,
831+
.framerates = ds5_framerate_15_25,
832+
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
833+
}, {
834+
.width = 848,
835+
.height = 480,
836+
.framerates = ds5_41x_framerate_to_90,
837+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
838+
}, {
839+
.width = 848,
840+
.height = 100,
841+
.framerates = ds5_framerate_100,
842+
.n_framerates = ARRAY_SIZE(ds5_framerate_100),
843+
}, {
844+
.width = 640,
845+
.height = 480,
846+
.framerates = ds5_41x_framerate_to_90,
847+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
848+
}, {
849+
.width = 640,
850+
.height = 360,
851+
.framerates = ds5_41x_framerate_to_90,
852+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
853+
}, {
854+
.width = 480,
855+
.height = 270,
856+
.framerates = ds5_41x_framerate_to_90,
857+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
858+
}, {
859+
.width = 424,
860+
.height = 240,
861+
.framerates = ds5_41x_framerate_to_90,
862+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_90),
863+
}
864+
};
865+
866+
static const struct ds5_resolution ds5_41x_rgb_sizes[] = {
867+
{
868+
.width = 1920,
869+
.height = 1080,
870+
.framerates = ds5_41x_framerate_to_30,
871+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_30),
872+
}, {
873+
.width = 1280,
874+
.height = 720,
875+
.framerates = ds5_41x_framerate_to_30,
876+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_30),
877+
}, {
878+
.width = 960,
879+
.height = 540,
880+
.framerates = ds5_41x_framerate_to_60,
881+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
882+
}, {
883+
.width = 848,
884+
.height = 480,
885+
.framerates = ds5_41x_framerate_to_60,
886+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
887+
}, {
888+
.width = 640,
889+
.height = 480,
890+
.framerates = ds5_41x_framerate_to_60,
891+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
892+
}, {
893+
.width = 640,
894+
.height = 360,
895+
.framerates = ds5_41x_framerate_to_60,
896+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
897+
}, {
898+
.width = 424,
899+
.height = 240,
900+
.framerates = ds5_41x_framerate_to_60,
901+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60),
902+
}, {
903+
.width = 320,
904+
.height = 240,
905+
.framerates = ds5_41x_framerate_to_60_no_15,
906+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60_no_15),
907+
}, {
908+
.width = 320,
909+
.height = 180,
910+
.framerates = ds5_41x_framerate_to_60_no_15,
911+
.n_framerates = ARRAY_SIZE(ds5_41x_framerate_to_60_no_15),
912+
},
913+
};
914+
766915
static const struct ds5_resolution ds5_rlt_rgb_sizes[] = {
767916
{
768917
.width = 1280,
@@ -838,6 +987,15 @@ static const struct ds5_resolution ds5_size_w10 = {
838987
.n_framerates = 1,
839988
};
840989

990+
static const struct ds5_resolution d41x_calibration_sizes[] = {
991+
{
992+
.width = 1920,
993+
.height = 1080,
994+
.framerates = ds5_framerate_15_25,
995+
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
996+
},
997+
};
998+
841999
static const struct ds5_resolution d43x_calibration_sizes[] = {
8421000
{
8431001
.width = 1280,
@@ -875,6 +1033,26 @@ static const struct ds5_resolution ds5_size_imu_extended[] = {
8751033
},
8761034
};
8771035

1036+
static const struct ds5_format ds5_depth_formats_d41x[] = {
1037+
{
1038+
// TODO: 0x31 is replaced with 0x1e since it caused low FPS in Jetson.
1039+
.data_type = GMSL_CSI_DT_YUV422_8, /* Z16 */
1040+
.mbus_code = MEDIA_BUS_FMT_UYVY8_1X16,
1041+
.n_resolutions = ARRAY_SIZE(d41x_depth_sizes),
1042+
.resolutions = d41x_depth_sizes,
1043+
}, {
1044+
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
1045+
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
1046+
.n_resolutions = ARRAY_SIZE(d41x_depth_sizes),
1047+
.resolutions = d41x_depth_sizes,
1048+
}, {
1049+
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
1050+
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */
1051+
.n_resolutions = ARRAY_SIZE(d41x_calibration_sizes),
1052+
.resolutions = d41x_calibration_sizes,
1053+
},
1054+
};
1055+
8781056
static const struct ds5_format ds5_depth_formats_d43x[] = {
8791057
{
8801058
// TODO: 0x31 is replaced with 0x1e since it caused low FPS in Jetson.
@@ -938,6 +1116,33 @@ static const struct ds5_format ds5_y_formats_ds5u[] = {
9381116
},
9391117
};
9401118

1119+
static const struct ds5_format ds5_y_formats_41x[] = {
1120+
{
1121+
/* First format: default */
1122+
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
1123+
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
1124+
.n_resolutions = ARRAY_SIZE(y8_41x_sizes),
1125+
.resolutions = y8_41x_sizes,
1126+
}, {
1127+
.data_type = GMSL_CSI_DT_YUV422_8, /* Y8I */
1128+
.mbus_code = MEDIA_BUS_FMT_VYUY8_1X16,
1129+
.n_resolutions = ARRAY_SIZE(y8_41x_sizes),
1130+
.resolutions = y8_41x_sizes,
1131+
}, {
1132+
.data_type = GMSL_CSI_DT_RGB_888, /* 24-bit Calibration */
1133+
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24, /* FIXME */
1134+
.n_resolutions = ARRAY_SIZE(d41x_calibration_sizes),
1135+
.resolutions = d41x_calibration_sizes,
1136+
},
1137+
};
1138+
1139+
static const struct ds5_format ds5_41x_rgb_format = {
1140+
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
1141+
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
1142+
.n_resolutions = ARRAY_SIZE(ds5_41x_rgb_sizes),
1143+
.resolutions = ds5_41x_rgb_sizes,
1144+
};
1145+
9411146
static const struct ds5_format ds5_rlt_rgb_format = {
9421147
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
9431148
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
@@ -4590,6 +4795,9 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
45904795

45914796
sensor = &state->depth.sensor;
45924797
switch (dev_type) {
4798+
case DS5_DEVICE_TYPE_D41X:
4799+
sensor->formats = ds5_depth_formats_d41x;
4800+
break;
45934801
case DS5_DEVICE_TYPE_D43X:
45944802
case DS5_DEVICE_TYPE_D45X:
45954803
sensor->formats = ds5_depth_formats_d43x;
@@ -4604,8 +4812,15 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
46044812
sensor->mux_pad = DS5_MUX_PAD_DEPTH;
46054813

46064814
sensor = &state->ir.sensor;
4607-
sensor->formats = state->variant->formats;
4608-
sensor->n_formats = state->variant->n_formats;
4815+
switch (dev_type) {
4816+
case DS5_DEVICE_TYPE_D41X:
4817+
sensor->formats = ds5_y_formats_41x;
4818+
sensor->n_formats = ARRAY_SIZE(ds5_y_formats_41x);
4819+
break;
4820+
default:
4821+
sensor->formats = state->variant->formats;
4822+
sensor->n_formats = state->variant->n_formats;
4823+
}
46094824
sensor->mux_pad = DS5_MUX_PAD_IR;
46104825

46114826
sensor = &state->rgb.sensor;
@@ -4615,6 +4830,10 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
46154830
sensor->formats = &ds5_onsemi_rgb_format;
46164831
sensor->n_formats = DS5_ONSEMI_RGB_N_FORMATS;
46174832
break;
4833+
case DS5_DEVICE_TYPE_D41X:
4834+
sensor->formats = &ds5_41x_rgb_format;
4835+
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
4836+
break;
46184837
case DS5_DEVICE_TYPE_D45X:
46194838
sensor->formats = &ds5_rlt_rgb_format;
46204839
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
@@ -5440,7 +5659,7 @@ static int ds5_probe(struct i2c_client *c, const struct i2c_device_id *id)
54405659
mutex_init(&state->lock);
54415660

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

54455664
state->variant = ds5_variants + id->driver_data;
54465665
#ifdef CONFIG_OF
@@ -5678,4 +5897,4 @@ MODULE_AUTHOR("Guennadi Liakhovetski <[email protected]>,\n\
56785897
Shikun Ding <[email protected]>");
56795898
MODULE_AUTHOR("Dmitry Perchanov <[email protected]>");
56805899
MODULE_LICENSE("GPL v2");
5681-
MODULE_VERSION("1.0.1.28");
5900+
MODULE_VERSION("1.0.1.29");

0 commit comments

Comments
 (0)