@@ -81,6 +81,23 @@ static int app_add_format(uint32_t pixfmt, uint32_t width, uint32_t height, bool
8181 return ret ;
8282}
8383
84+ struct video_resolution {
85+ uint16_t width ;
86+ uint16_t height ;
87+ };
88+
89+ static struct video_resolution video_common_fmts [] = {
90+ { .width = 160 , .height = 120 , }, /* QQVGA */
91+ { .width = 320 , .height = 240 , }, /* QVGA */
92+ { .width = 640 , .height = 480 , }, /* VGA */
93+ { .width = 854 , .height = 480 , }, /* WVGA */
94+ { .width = 800 , .height = 600 , }, /* SVGA */
95+ { .width = 1280 , .height = 720 , }, /* HD */
96+ { .width = 1280 , .height = 1024 , }, /* SXGA */
97+ { .width = 1920 , .height = 1080 , }, /* FHD */
98+ { .width = 3840 , .height = 2160 , }, /* UHD */
99+ };
100+
84101/* Submit to UVC only the formats expected to be working (enough memory for the size, etc.) */
85102static int app_add_filtered_formats (void )
86103{
@@ -89,6 +106,7 @@ static int app_add_filtered_formats(void)
89106
90107 for (int i = 0 ; video_caps .format_caps [i ].pixelformat != 0 ; i ++ ) {
91108 const struct video_format_cap * vcap = & video_caps .format_caps [i ];
109+ int count = 1 ;
92110
93111 ret = app_add_format (vcap -> pixelformat , vcap -> width_min , vcap -> height_min ,
94112 has_sup_fmts );
@@ -102,6 +120,39 @@ static int app_add_filtered_formats(void)
102120 if (ret != 0 ) {
103121 return ret ;
104122 }
123+
124+ count ++ ;
125+ }
126+
127+ if (vcap -> width_step == 0 && vcap -> height_step == 0 ) {
128+ continue ;
129+ }
130+
131+ /* RANGE Resolution processing */
132+ for (int j = 0 ; j < ARRAY_SIZE (video_common_fmts ); j ++ ) {
133+ if (count >= CONFIG_APP_VIDEO_MAX_RESOLUTIONS ) {
134+ break ;
135+ }
136+
137+ if (!IN_RANGE (video_common_fmts [j ].width ,
138+ vcap -> width_min , vcap -> width_max ) ||
139+ !IN_RANGE (video_common_fmts [j ].height ,
140+ vcap -> height_min , vcap -> height_max )) {
141+ continue ;
142+ }
143+
144+ if ((video_common_fmts [j ].width - vcap -> width_min ) % vcap -> width_step ||
145+ (video_common_fmts [j ].height - vcap -> height_min ) % vcap -> height_step ) {
146+ continue ;
147+ }
148+
149+ ret = app_add_format (vcap -> pixelformat , video_common_fmts [j ].width ,
150+ video_common_fmts [j ].height , has_sup_fmts );
151+ if (ret != 0 ) {
152+ return ret ;
153+ }
154+
155+ count ++ ;
105156 }
106157 }
107158
0 commit comments