Skip to content

Commit 3a04b6d

Browse files
Nikolai-Lymodlin
authored andcommitted
Refactor framerate definitions and resolution entries for D40x removing 5 FPS
1 parent 4a274ac commit 3a04b6d

1 file changed

Lines changed: 47 additions & 87 deletions

File tree

kernel/realsense/d4xx.c

Lines changed: 47 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,6 @@ static const u16 ds5_framerates[] = {5, 30};
677677

678678
static const u16 ds5_framerate_30 = 30;
679679
static const u16 ds5_framerate_25 = 25;
680-
static const u16 ds5_framerate_15_30[] = {15, 30};
681-
static const u16 ds5_framerate_15_25[] = {15, 25};
682680
static const u16 ds5_depth_framerate_to_30[] = {5, 15, 30};
683681
static const u16 ds5_framerate_to_30[] = {5, 10, 15, 30};
684682
static const u16 ds5_framerate_to_60[] = {5, 15, 30, 60};
@@ -688,47 +686,42 @@ static const u16 ds5_41x_framerate_to_30[] = {6, 15, 30};
688686
static const u16 ds5_41x_framerate_to_60_no_15[] = {6, 30, 60};
689687
static const u16 ds5_41x_framerate_to_60[] = {6, 15, 30, 60};
690688
static const u16 ds5_41x_framerate_to_90[] = {6, 15, 30, 60, 90};
691-
static const u16 ds5_framerate_100[] = {100};
692-
static const u16 ds5_framerate_90[] = {90};
689+
static const u16 ds5_framerate_15_25[] = {15, 25};
690+
static const u16 ds5_framerate_15_30[] = {15, 30};
691+
static const u16 ds5_framerate_15_60[] = {15, 30, 60};
692+
static const u16 ds5_framerate_15_90[] = {15, 30, 60, 90};
693693
static const u16 ds5_imu_framerates[] = {50, 100, 200, 400};
694+
static const u16 ds5_framerate_90[] = {90};
695+
static const u16 ds5_framerate_100[] = {100};
696+
697+
/* Helper macro to define resolution entries concisely. */
698+
#define DS5_RES(w, h, fr) \
699+
{ .width = (w), .height = (h), .framerates = (fr), .n_framerates = ARRAY_SIZE(fr) },
700+
701+
#define D401_COMMON_RES \
702+
DS5_RES(1280, 720, ds5_framerate_15_30)\
703+
DS5_RES(848, 480, ds5_framerate_15_60)\
704+
DS5_RES(640, 480, ds5_framerate_15_60)\
705+
DS5_RES(640, 360, ds5_framerate_15_90)\
706+
DS5_RES(480, 270, ds5_framerate_15_90)\
707+
DS5_RES(424, 240, ds5_framerate_15_90)\
694708

695709
static const struct ds5_resolution d40x_depth_sizes[] = {
696-
{
697-
.width = 1280,
698-
.height = 720,
699-
.framerates = ds5_depth_framerate_to_30,
700-
.n_framerates = ARRAY_SIZE(ds5_depth_framerate_to_30),
701-
}, {
702-
.width = 848,
703-
.height = 480,
704-
.framerates = ds5_framerate_to_90,
705-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
706-
}, {
707-
.width = 640,
708-
.height = 480,
709-
.framerates = ds5_framerate_to_90,
710-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
711-
}, {
712-
.width = 640,
713-
.height = 360,
714-
.framerates = ds5_framerate_to_90,
715-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
716-
}, {
717-
.width = 480,
718-
.height = 270,
719-
.framerates = ds5_framerate_to_90,
720-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
721-
}, {
722-
.width = 424,
723-
.height = 240,
724-
.framerates = ds5_framerate_to_90,
725-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
726-
}, {
727-
.width = 256,
728-
.height = 144,
729-
.framerates = ds5_framerate_90,
730-
.n_framerates = ARRAY_SIZE(ds5_framerate_90),
731-
},
710+
D401_COMMON_RES
711+
DS5_RES(256, 144, ds5_framerate_15_90)
712+
};
713+
714+
static const struct ds5_resolution d40x_y8_sizes[] = {
715+
D401_COMMON_RES
716+
};
717+
718+
static const struct ds5_resolution d40x_rgb_sizes[] = {
719+
DS5_RES(1280, 800, ds5_framerate_15_30)
720+
D401_COMMON_RES
721+
};
722+
723+
static const struct ds5_resolution d40x_calibration_sizes[] = {
724+
DS5_RES(1288, 808, ds5_framerate_15_25)
732725
};
733726

734727
static const struct ds5_resolution d41x_depth_sizes[] = {
@@ -867,40 +860,6 @@ static const struct ds5_resolution y8_sizes[] = {
867860
}
868861
};
869862

870-
static const struct ds5_resolution y8_40x_sizes[] = {
871-
{
872-
.width = 1280,
873-
.height = 720,
874-
.framerates = ds5_depth_framerate_to_30,
875-
.n_framerates = ARRAY_SIZE(ds5_depth_framerate_to_30),
876-
}, {
877-
.width = 848,
878-
.height = 480,
879-
.framerates = ds5_framerate_to_90,
880-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
881-
}, {
882-
.width = 640,
883-
.height = 480,
884-
.framerates = ds5_framerate_to_90,
885-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
886-
}, {
887-
.width = 640,
888-
.height = 360,
889-
.framerates = ds5_framerate_to_90,
890-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
891-
}, {
892-
.width = 480,
893-
.height = 270,
894-
.framerates = ds5_framerate_to_90,
895-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
896-
}, {
897-
.width = 424,
898-
.height = 240,
899-
.framerates = ds5_framerate_to_90,
900-
.n_framerates = ARRAY_SIZE(ds5_framerate_to_90),
901-
},
902-
};
903-
904863
static const struct ds5_resolution y8_41x_sizes[] = {
905864
{
906865
.width = 1920,
@@ -1074,15 +1033,6 @@ static const struct ds5_resolution ds5_size_w10 = {
10741033
.n_framerates = 1,
10751034
};
10761035

1077-
static const struct ds5_resolution d40x_calibration_sizes[] = {
1078-
{
1079-
.width = 1288,
1080-
.height = 808,
1081-
.framerates = ds5_framerate_15_25,
1082-
.n_framerates = ARRAY_SIZE(ds5_framerate_15_25),
1083-
},
1084-
};
1085-
10861036
static const struct ds5_resolution d41x_calibration_sizes[] = {
10871037
{
10881038
.width = 1920,
@@ -1246,13 +1196,13 @@ static const struct ds5_format ds5_y_formats_40x[] = {
12461196
/* First format: default */
12471197
.data_type = GMSL_CSI_DT_RAW_8, /* Y8 */
12481198
.mbus_code = MEDIA_BUS_FMT_Y8_1X8,
1249-
.n_resolutions = ARRAY_SIZE(y8_40x_sizes),
1250-
.resolutions = y8_40x_sizes,
1199+
.n_resolutions = ARRAY_SIZE(d40x_y8_sizes),
1200+
.resolutions = d40x_y8_sizes,
12511201
}, {
12521202
.data_type = GMSL_CSI_DT_YUV422_8, /* Y8I */
12531203
.mbus_code = MEDIA_BUS_FMT_VYUY8_1X16,
1254-
.n_resolutions = ARRAY_SIZE(y8_40x_sizes),
1255-
.resolutions = y8_40x_sizes,
1204+
.n_resolutions = ARRAY_SIZE(d40x_y8_sizes),
1205+
.resolutions = d40x_y8_sizes,
12561206
}, {
12571207
.data_type = GMSL_CSI_DT_RGB_888, /* Y12I, 24-bit Calibration */
12581208
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24,
@@ -1308,6 +1258,13 @@ static const struct ds5_format ds5_41x_rgb_format = {
13081258
.resolutions = ds5_41x_rgb_sizes,
13091259
};
13101260

1261+
static const struct ds5_format ds5_40x_rgb_format = {
1262+
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
1263+
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
1264+
.n_resolutions = ARRAY_SIZE(d40x_rgb_sizes),
1265+
.resolutions = d40x_rgb_sizes,
1266+
};
1267+
13111268
static const struct ds5_format ds5_rlt_rgb_format = {
13121269
.data_type = GMSL_CSI_DT_YUV422_8, /* UYVY */
13131270
.mbus_code = MEDIA_BUS_FMT_YUYV8_1X16,
@@ -4985,6 +4942,9 @@ static int ds5_fixed_configuration(struct i2c_client *client, struct ds5 *state)
49854942
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
49864943
break;
49874944
case DS5_DEVICE_TYPE_D40X:
4945+
sensor->formats = &ds5_40x_rgb_format;
4946+
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;
4947+
break;
49884948
case DS5_DEVICE_TYPE_D45X:
49894949
sensor->formats = &ds5_rlt_rgb_format;
49904950
sensor->n_formats = DS5_RLT_RGB_N_FORMATS;

0 commit comments

Comments
 (0)