samples: drivers: video: update video samples for min/max line count

Update video samples to use min/max line count capabilities when
allocating video buffers.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2024-10-04 12:03:30 -05:00 committed by Anas Nashif
parent ec6ffc8b33
commit 2fb259833f
3 changed files with 21 additions and 1 deletions

View File

@ -182,7 +182,11 @@ int main(void)
#endif
/* Size to allocate for each buffer */
bsize = fmt.pitch * fmt.height;
if (caps.min_line_count == LINE_COUNT_HEIGHT) {
bsize = fmt.pitch * fmt.height;
} else {
bsize = fmt.pitch * caps.min_line_count;
}
/* Alloc video buffers and enqueue for capture */
for (i = 0; i < ARRAY_SIZE(buffers); i++) {

View File

@ -88,6 +88,10 @@ int main(void)
(char)(fmt.pixelformat >> 16), (char)(fmt.pixelformat >> 24), fmt.width, fmt.height,
fmt.pitch);
if (caps.min_line_count != LINE_COUNT_HEIGHT) {
LOG_ERR("Partial framebuffers not supported by this sample");
return 0;
}
/* Size to allocate for each buffer */
bsize = fmt.pitch * fmt.height;

View File

@ -41,6 +41,7 @@ int main(void)
struct video_buffer *buffers[2], *vbuf;
int i, ret, sock, client;
struct video_format fmt;
struct video_caps caps;
#if DT_HAS_CHOSEN(zephyr_camera)
const struct device *const video = DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));
@ -81,6 +82,12 @@ int main(void)
return 0;
}
/* Get capabilities */
if (video_get_caps(video, VIDEO_EP_OUT, &caps)) {
LOG_ERR("Unable to retrieve video capabilities");
return 0;
}
/* Get default/native format */
if (video_get_format(video, VIDEO_EP_OUT, &fmt)) {
LOG_ERR("Unable to retrieve video format");
@ -91,6 +98,11 @@ int main(void)
(char)(fmt.pixelformat >> 8), (char)(fmt.pixelformat >> 16),
(char)(fmt.pixelformat >> 24), fmt.width, fmt.height);
if (caps.min_line_count != LINE_COUNT_HEIGHT) {
LOG_ERR("Partial framebuffers not supported by this sample");
return 0;
}
/* Alloc Buffers */
for (i = 0; i < ARRAY_SIZE(buffers); i++) {
buffers[i] = video_buffer_alloc(fmt.pitch * fmt.height);