@@ -83,20 +83,62 @@ static void app_add_format(uint32_t pixfmt, uint16_t width, uint16_t height, boo
83
83
uvc_add_format (uvc_dev , & fmt );
84
84
}
85
85
86
+ struct video_resolution {
87
+ uint16_t width ;
88
+ uint16_t height ;
89
+ };
90
+
91
+ static struct video_resolution video_common_fmts [] = {
92
+ { .width = 3840 , .height = 2160 , }, /* UHD */
93
+ { .width = 1920 , .height = 1080 , }, /* FHD */
94
+ { .width = 1280 , .height = 1024 , }, /* SXGA */
95
+ { .width = 1280 , .height = 720 , }, /* HD */
96
+ { .width = 800 , .height = 600 , }, /* SVGA */
97
+ { .width = 854 , .height = 480 , }, /* WVGA */
98
+ { .width = 640 , .height = 480 , }, /* VGA */
99
+ { .width = 320 , .height = 240 , }, /* QVGA */
100
+ { .width = 160 , .height = 120 , }, /* QQVGA */
101
+ };
102
+
86
103
/* Submit to UVC only the formats expected to be working (enough memory for the size, etc.) */
87
104
static void app_add_filtered_formats (void )
88
105
{
89
106
const bool has_std_fmts = app_has_standard_formats ();
90
107
91
108
for (int i = 0 ; video_caps .format_caps [i ].pixelformat != 0 ; i ++ ) {
92
109
const struct video_format_cap * vcap = & video_caps .format_caps [i ];
110
+ int range_count = 0 ;
93
111
94
112
app_add_format (vcap -> pixelformat , vcap -> width_min , vcap -> height_min , has_std_fmts );
95
113
96
114
if (vcap -> width_min != vcap -> width_max || vcap -> height_min != vcap -> height_max ) {
97
115
app_add_format (vcap -> pixelformat , vcap -> width_max , vcap -> height_max ,
98
116
has_std_fmts );
99
117
}
118
+
119
+ if (vcap -> width_step == 0 && vcap -> height_step == 0 ) {
120
+ continue ;
121
+ }
122
+
123
+ /* RANGE Resolution processing */
124
+ for (int j = 0 ; j < ARRAY_SIZE (video_common_fmts ); j ++ ) {
125
+ if (range_count >= CONFIG_VIDEO_MAX_RANGE_RESOLUTIONS ) {
126
+ break ;
127
+ }
128
+ if (!IN_RANGE (video_common_fmts [j ].width ,
129
+ vcap -> width_min , vcap -> width_max ) ||
130
+ !IN_RANGE (video_common_fmts [j ].height ,
131
+ vcap -> height_min , vcap -> height_max )) {
132
+ continue ;
133
+ }
134
+ if ((video_common_fmts [j ].width - vcap -> width_min ) % vcap -> width_step ||
135
+ (video_common_fmts [j ].height - vcap -> height_min ) % vcap -> height_step ) {
136
+ continue ;
137
+ }
138
+
139
+ app_add_format (vcap -> pixelformat , video_common_fmts [j ].width ,
140
+ video_common_fmts [j ].height , has_std_fmts );
141
+ }
100
142
}
101
143
}
102
144
0 commit comments