@@ -22,26 +22,21 @@ static inline int display_setup(const struct device *const display_dev, const ui
22
22
struct display_capabilities capabilities ;
23
23
int ret = 0 ;
24
24
25
- if (!device_is_ready (display_dev )) {
26
- LOG_ERR ("Device %s not found" , display_dev -> name );
27
- return - ENODEV ;
28
- }
29
-
30
- printk ("\nDisplay device: %s\n" , display_dev -> name );
25
+ LOG_INF ("Display device: %s" , display_dev -> name );
31
26
32
27
display_get_capabilities (display_dev , & capabilities );
33
28
34
- printk ("- Capabilities:\n " );
35
- printk (" x_resolution = %u, y_resolution = %u, supported_pixel_formats = %u\n "
36
- " current_pixel_format = %u, current_orientation = %u\n\n " ,
29
+ LOG_INF ("- Capabilities:" );
30
+ LOG_INF (" x_resolution = %u, y_resolution = %u, supported_pixel_formats = %u"
31
+ " current_pixel_format = %u, current_orientation = %u" ,
37
32
capabilities .x_resolution , capabilities .y_resolution ,
38
33
capabilities .supported_pixel_formats , capabilities .current_pixel_format ,
39
34
capabilities .current_orientation );
40
35
41
36
/* Set display pixel format to match the one in use by the camera */
42
37
switch (pixfmt ) {
43
38
case VIDEO_PIX_FMT_RGB565 :
44
- ret = display_set_pixel_format (display_dev , PIXEL_FORMAT_BGR_565 );
39
+ ret = display_set_pixel_format (display_dev , PIXEL_FORMAT_RGB_565 );
45
40
break ;
46
41
case VIDEO_PIX_FMT_XRGB32 :
47
42
ret = display_set_pixel_format (display_dev , PIXEL_FORMAT_ARGB_8888 );
@@ -101,19 +96,19 @@ int main(void)
101
96
}
102
97
#endif
103
98
104
- printk ("Video device: %s\n " , video_dev -> name );
99
+ LOG_INF ("Video device: %s" , video_dev -> name );
105
100
106
101
/* Get capabilities */
107
102
if (video_get_caps (video_dev , VIDEO_EP_OUT , & caps )) {
108
103
LOG_ERR ("Unable to retrieve video capabilities" );
109
104
return 0 ;
110
105
}
111
106
112
- printk ("- Capabilities:\n " );
107
+ LOG_INF ("- Capabilities:" );
113
108
while (caps .format_caps [i ].pixelformat ) {
114
109
const struct video_format_cap * fcap = & caps .format_caps [i ];
115
110
/* fourcc to string */
116
- printk (" %c%c%c%c width [%u; %u; %u] height [%u; %u; %u]\n " ,
111
+ LOG_INF (" %c%c%c%c width [%u; %u; %u] height [%u; %u; %u]" ,
117
112
(char )fcap -> pixelformat , (char )(fcap -> pixelformat >> 8 ),
118
113
(char )(fcap -> pixelformat >> 16 ), (char )(fcap -> pixelformat >> 24 ),
119
114
fcap -> width_min , fcap -> width_max , fcap -> width_step , fcap -> height_min ,
@@ -127,23 +122,43 @@ int main(void)
127
122
return 0 ;
128
123
}
129
124
130
- printk ("- Default format: %c%c%c%c %ux%u\n" , (char )fmt .pixelformat ,
125
+ #if CONFIG_VIDEO_FRAME_HEIGHT
126
+ fmt .height = CONFIG_VIDEO_FRAME_HEIGHT ;
127
+ #endif
128
+
129
+ #if CONFIG_VIDEO_FRAME_WIDTH
130
+ fmt .width = CONFIG_VIDEO_FRAME_WIDTH ;
131
+ fmt .pitch = fmt .width * 2 ;
132
+ #endif
133
+
134
+ if (strcmp (CONFIG_VIDEO_PIXEL_FORMAT , "" )) {
135
+ fmt .pixelformat =
136
+ video_fourcc (CONFIG_VIDEO_PIXEL_FORMAT [0 ], CONFIG_VIDEO_PIXEL_FORMAT [1 ],
137
+ CONFIG_VIDEO_PIXEL_FORMAT [2 ], CONFIG_VIDEO_PIXEL_FORMAT [3 ]);
138
+ }
139
+
140
+ LOG_INF ("- Video format: %c%c%c%c %ux%u" , (char )fmt .pixelformat ,
131
141
(char )(fmt .pixelformat >> 8 ), (char )(fmt .pixelformat >> 16 ),
132
142
(char )(fmt .pixelformat >> 24 ), fmt .width , fmt .height );
133
143
144
+ if (video_set_format (video_dev , VIDEO_EP_OUT , & fmt )) {
145
+ LOG_ERR ("Unable to set format" );
146
+ return 0 ;
147
+ }
148
+
134
149
if (!video_get_frmival (video_dev , VIDEO_EP_OUT , & frmival )) {
135
- printk ("- Default frame rate : %f fps\n " ,
150
+ LOG_INF ("- Default frame rate : %f fps" ,
136
151
1.0 * frmival .denominator / frmival .numerator );
137
152
}
138
153
139
- printk ("- Supported frame intervals for the default format:\n " );
154
+ LOG_INF ("- Supported frame intervals for the default format:" );
140
155
memset (& fie , 0 , sizeof (fie ));
141
156
fie .format = & fmt ;
142
157
while (video_enum_frmival (video_dev , VIDEO_EP_OUT , & fie ) == 0 ) {
143
158
if (fie .type == VIDEO_FRMIVAL_TYPE_DISCRETE ) {
144
- printk (" %u/%u " , fie .discrete .numerator , fie .discrete .denominator );
159
+ LOG_INF (" %u/%u " , fie .discrete .numerator , fie .discrete .denominator );
145
160
} else {
146
- printk (" [min = %u/%u; max = %u/%u; step = %u/%u]\n " ,
161
+ LOG_INF (" [min = %u/%u; max = %u/%u; step = %u/%u]" ,
147
162
fie .stepwise .min .numerator , fie .stepwise .min .denominator ,
148
163
fie .stepwise .max .numerator , fie .stepwise .max .denominator ,
149
164
fie .stepwise .step .numerator , fie .stepwise .step .denominator );
@@ -190,7 +205,7 @@ int main(void)
190
205
return 0 ;
191
206
}
192
207
193
- printk ("Capture started\n " );
208
+ LOG_INF ("Capture started" );
194
209
195
210
/* Grab video frames */
196
211
while (1 ) {
@@ -200,7 +215,7 @@ int main(void)
200
215
return 0 ;
201
216
}
202
217
203
- printk ("Got frame %u! size: %u; timestamp %u ms\n " , frame ++ , vbuf -> bytesused ,
218
+ LOG_DBG ("Got frame %u! size: %u; timestamp %u ms" , frame ++ , vbuf -> bytesused ,
204
219
vbuf -> timestamp );
205
220
206
221
#if DT_HAS_CHOSEN (zephyr_display )
0 commit comments