@@ -76,19 +76,65 @@ static void app_add_format(uint32_t pixfmt, uint32_t width, uint32_t height, boo
7676	uvc_add_format (uvc_dev , & fmt );
7777}
7878
79+ struct  video_resolution  {
80+ 	uint16_t  width ;
81+ 	uint16_t  height ;
82+ };
83+ 
84+ static  struct  video_resolution  video_common_fmts [] =  {
85+ 	{ .width  =  160 ,		.height  =  120 ,	},	/* QQVGA */ 
86+ 	{ .width  =  320 ,		.height  =  240 ,	},	/* QVGA */ 
87+ 	{ .width  =  640 ,		.height  =  480 ,	},	/* VGA */ 
88+ 	{ .width  =  854 ,		.height  =  480 ,	},	/* WVGA */ 
89+ 	{ .width  =  800 ,		.height  =  600 ,	},	/* SVGA */ 
90+ 	{ .width  =  1280 ,	.height  =  720 ,	},	/* HD */ 
91+ 	{ .width  =  1280 ,	.height  =  1024 ,	},	/* SXGA */ 
92+ 	{ .width  =  1920 ,	.height  =  1080 ,	},	/* FHD */ 
93+ 	{ .width  =  3840 ,	.height  =  2160 ,	},	/* UHD */ 
94+ };
95+ 
7996/* Submit to UVC only the formats expected to be working (enough memory for the size, etc.) */ 
8097static  void  app_add_filtered_formats (void )
8198{
8299	const  bool  has_sup_fmts  =  app_has_supported_format ();
83100
84101	for  (int  i  =  0 ; video_caps .format_caps [i ].pixelformat  !=  0 ; i ++ ) {
85102		const  struct  video_format_cap  * vcap  =  & video_caps .format_caps [i ];
103+ 		int  count  =  1 ;
86104
87105		app_add_format (vcap -> pixelformat , vcap -> width_min , vcap -> height_min , has_sup_fmts );
88106
89107		if  (vcap -> width_min  !=  vcap -> width_max  ||  vcap -> height_min  !=  vcap -> height_max ) {
90108			app_add_format (vcap -> pixelformat , vcap -> width_max , vcap -> height_max ,
91109				       has_sup_fmts );
110+ 			count ++ ;
111+ 		}
112+ 
113+ 		if  (vcap -> width_step  ==  0  &&  vcap -> height_step  ==  0 ) {
114+ 			continue ;
115+ 		}
116+ 
117+ 		/* RANGE Resolution processing */ 
118+ 		for  (int  j  =  0 ; j  <  ARRAY_SIZE (video_common_fmts ); j ++ ) {
119+ 			if  (count  >= CONFIG_APP_VIDEO_MAX_RESOLUTIONS ) {
120+ 				break ;
121+ 			}
122+ 
123+ 			if  (!IN_RANGE (video_common_fmts [j ].width ,
124+ 				      vcap -> width_min , vcap -> width_max ) || 
125+ 			    !IN_RANGE (video_common_fmts [j ].height ,
126+ 				      vcap -> height_min , vcap -> height_max )) {
127+ 				continue ;
128+ 			}
129+ 
130+ 			if  ((video_common_fmts [j ].width  -  vcap -> width_min ) % vcap -> width_step  || 
131+ 			    (video_common_fmts [j ].height  -  vcap -> height_min ) % vcap -> height_step ) {
132+ 				continue ;
133+ 			}
134+ 
135+ 			app_add_format (vcap -> pixelformat , video_common_fmts [j ].width ,
136+ 				       video_common_fmts [j ].height , has_sup_fmts );
137+ 			count ++ ;
92138		}
93139	}
94140}
0 commit comments