Skip to content

Commit

Permalink
samples: video: capture: Get and enumerate frame rate
Browse files Browse the repository at this point in the history
Add code to get the current frame rate and enumerate all supported frame
rates (frame intervals) of the current format.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
  • Loading branch information
ngphibang authored and mmahadevan108 committed Sep 24, 2024
1 parent 16fc8f8 commit 41034d0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions samples/drivers/video/capture/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ int main(void)
struct video_buffer *buffers[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX], *vbuf;
struct video_format fmt;
struct video_caps caps;
struct video_frmival frmival;
struct video_frmival_enum fie;
unsigned int frame = 0;
size_t bsize;
int i = 0;
Expand Down Expand Up @@ -129,6 +131,26 @@ int main(void)
(char)(fmt.pixelformat >> 8), (char)(fmt.pixelformat >> 16),
(char)(fmt.pixelformat >> 24), fmt.width, fmt.height);

if (!video_get_frmival(video_dev, VIDEO_EP_OUT, &frmival)) {
printk("- Default frame rate : %f fps\n",
1.0 * frmival.denominator / frmival.numerator);
}

printk("- Supported frame intervals for the default format:\n");
memset(&fie, 0, sizeof(fie));
fie.format = &fmt;
while (video_enum_frmival(video_dev, VIDEO_EP_OUT, &fie) == 0) {
if (fie.type == VIDEO_FRMIVAL_TYPE_DISCRETE) {
printk(" %u/%u ", fie.discrete.numerator, fie.discrete.denominator);
} else {
printk(" [min = %u/%u; max = %u/%u; step = %u/%u]\n",
fie.stepwise.min.numerator, fie.stepwise.min.denominator,
fie.stepwise.max.numerator, fie.stepwise.max.denominator,
fie.stepwise.step.numerator, fie.stepwise.step.denominator);
}
fie.index++;
}

#if DT_HAS_CHOSEN(zephyr_display)
const struct device *const display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));

Expand Down

0 comments on commit 41034d0

Please sign in to comment.