Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions dts/bindings/video/st,stm32-jpeg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2025 STMicroelectronics.
#
# SPDX-License-Identifier: Apache-2.0
#

description: |
STM32 JPEG Codec.
The STM32 JPEG codec can decode JPEG compressed frames
and encode uncompressed frames to the JPEG format.
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'm not familiar with video conventions: Is it worth specifying that this is an HW accelerator ie that we're not talking about a SW Codec ?

compatible: "st,stm32-jpeg"

include: [base.yaml, reset-device.yaml]

properties:
reg:
required: true

clocks:
required: true

interrupts:
required: true

resets:
required: true
45 changes: 21 additions & 24 deletions samples/drivers/video/tcpserversink/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ int configure_encoder(void)
}

/* Get capabilities */
caps.type = VIDEO_BUF_TYPE_OUTPUT;
caps.type = VIDEO_BUF_TYPE_INPUT;
if (video_get_caps(encoder_dev, &caps)) {
LOG_ERR("Unable to retrieve video capabilities");
return -1;
}

LOG_INF("- Encoder output capabilities:");
LOG_INF("- Encoder input capabilities:");
i = 0;
while (caps.format_caps[i].pixelformat) {
const struct video_format_cap *fcap = &caps.format_caps[i];
Expand All @@ -68,13 +68,13 @@ int configure_encoder(void)
i++;
}

caps.type = VIDEO_BUF_TYPE_INPUT;
caps.type = VIDEO_BUF_TYPE_OUTPUT;
if (video_get_caps(encoder_dev, &caps)) {
LOG_ERR("Unable to retrieve video capabilities");
return -1;
}

LOG_INF("- Encoder input capabilities:");
LOG_INF("- Encoder output capabilities:");
i = 0;
while (caps.format_caps[i].pixelformat) {
const struct video_format_cap *fcap = &caps.format_caps[i];
Expand All @@ -86,14 +86,16 @@ int configure_encoder(void)
}

/* Get default/native format */
fmt.type = VIDEO_BUF_TYPE_OUTPUT;
fmt.type = VIDEO_BUF_TYPE_INPUT;
if (video_get_format(encoder_dev, &fmt)) {
LOG_ERR("Unable to retrieve video format");
return -1;
}

LOG_INF("Video encoder device detected, format: %s %ux%u",
VIDEO_FOURCC_TO_STR(fmt.pixelformat), fmt.width, fmt.height);
/* Set input format */
if (strcmp(CONFIG_VIDEO_PIXEL_FORMAT, "")) {
fmt.pixelformat = VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_PIXEL_FORMAT);
}

#if CONFIG_VIDEO_FRAME_HEIGHT
fmt.height = CONFIG_VIDEO_FRAME_HEIGHT;
Expand All @@ -103,20 +105,29 @@ int configure_encoder(void)
fmt.width = CONFIG_VIDEO_FRAME_WIDTH;
#endif

fmt.type = VIDEO_BUF_TYPE_INPUT;
if (video_set_format(encoder_dev, &fmt)) {
LOG_ERR("Unable to set input format");
return -1;
}

LOG_INF("- Video encoder input format: %s %ux%u", VIDEO_FOURCC_TO_STR(fmt.pixelformat),
fmt.width, fmt.height);

/* Set output format */
if (strcmp(CONFIG_VIDEO_ENCODED_PIXEL_FORMAT, "")) {
fmt.pixelformat = VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_ENCODED_PIXEL_FORMAT);
}

LOG_INF("- Video encoder output format: %s %ux%u", VIDEO_FOURCC_TO_STR(fmt.pixelformat),
fmt.width, fmt.height);

fmt.type = VIDEO_BUF_TYPE_OUTPUT;
if (video_set_format(encoder_dev, &fmt)) {
LOG_ERR("Unable to set format");
return -1;
}

LOG_INF("- Video encoder output format: %s %ux%u", VIDEO_FOURCC_TO_STR(fmt.pixelformat),
fmt.width, fmt.height);

/* Alloc output buffer */
size = fmt.size;
if (size == 0) {
Expand All @@ -133,20 +144,6 @@ int configure_encoder(void)
buffer->type = VIDEO_BUF_TYPE_OUTPUT;
video_enqueue(encoder_dev, buffer);

/* Set input format */
if (strcmp(CONFIG_VIDEO_PIXEL_FORMAT, "")) {
fmt.pixelformat = VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_PIXEL_FORMAT);
}

LOG_INF("- Video encoder input format: %s %ux%u", VIDEO_FOURCC_TO_STR(fmt.pixelformat),
fmt.width, fmt.height);

fmt.type = VIDEO_BUF_TYPE_INPUT;
if (video_set_format(encoder_dev, &fmt)) {
LOG_ERR("Unable to set input format");
return -1;
}

/* Start video encoder */
if (video_stream_start(encoder_dev, VIDEO_BUF_TYPE_INPUT)) {
LOG_ERR("Unable to start video encoder (input)");
Expand Down