diff --git a/boards/espressif/esp32s3_eye/esp32s3_eye_procpu.yaml b/boards/espressif/esp32s3_eye/esp32s3_eye_procpu.yaml index adddce2e59e7ea..089082c42e505c 100644 --- a/boards/espressif/esp32s3_eye/esp32s3_eye_procpu.yaml +++ b/boards/espressif/esp32s3_eye/esp32s3_eye_procpu.yaml @@ -16,6 +16,7 @@ supported: - pwm - dma - input + - video testing: ignore_tags: - net diff --git a/drivers/video/video_esp32_dvp.c b/drivers/video/video_esp32_dvp.c index 54a480e5424d09..d11a209fed211f 100644 --- a/drivers/video/video_esp32_dvp.c +++ b/drivers/video/video_esp32_dvp.c @@ -89,7 +89,6 @@ void video_esp32_dma_rx_done(const struct device *dev, void *user_data, uint32_t int status) { struct video_esp32_data *data = user_data; - int ret = 0; if (status == DMA_STATUS_BLOCK) { LOG_DBG("received block"); @@ -278,7 +277,6 @@ static int video_esp32_set_fmt(const struct device *dev, enum video_endpoint_id static int video_esp32_enqueue(const struct device *dev, enum video_endpoint_id ep, struct video_buffer *vbuf) { - const struct video_esp32_config *cfg = dev->config; struct video_esp32_data *data = dev->data; if (ep != VIDEO_EP_OUT) { diff --git a/samples/drivers/video/capture/Kconfig b/samples/drivers/video/capture/Kconfig new file mode 100644 index 00000000000000..5ec77c553e198e --- /dev/null +++ b/samples/drivers/video/capture/Kconfig @@ -0,0 +1,27 @@ +# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +mainmenu "Video capture sample application" + +menu "Video capture configuration" + +config VIDEO_FRAME_HEIGHT + int "Height of the video frame" + default 0 + help + Height of the video frame. If set to 0, the default height is used. + +config VIDEO_FRAME_WIDTH + int "Width of the video frame" + default 0 + help + Width of the video frame. If set to 0, the default width is used. + +config VIDEO_PIXEL_FORMAT + string "Pixel format of the video frame" + help + Pixel format of the video frame. If not set, the default pixel format is used. + +endmenu + +source "Kconfig.zephyr" diff --git a/samples/drivers/video/capture/boards/esp32s3_eye_procpu.conf b/samples/drivers/video/capture/boards/esp32s3_eye_procpu.conf new file mode 100644 index 00000000000000..76321800fa069a --- /dev/null +++ b/samples/drivers/video/capture/boards/esp32s3_eye_procpu.conf @@ -0,0 +1,11 @@ +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=40000 +CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=3 +CONFIG_ESP_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_VIDEO_BUFFER_POOL_ALIGN=32 +CONFIG_DMA_ESP32_MAX_DESCRIPTOR_NUM=64 +CONFIG_VIDEO_BUFFER_USE_SHARED_MULTI_HEAP=y +CONFIG_VIDEO_BUFFER_SMH_ATTRIBUTE=2 +CONFIG_VIDEO_FRAME_HEIGHT=240 +CONFIG_VIDEO_FRAME_WIDTH=240 +CONFIG_VIDEO_PIXEL_FORMAT="RGBP" diff --git a/samples/drivers/video/capture/sample.yaml b/samples/drivers/video/capture/sample.yaml index 6d3724b106ff39..79b65494bad55a 100644 --- a/samples/drivers/video/capture/sample.yaml +++ b/samples/drivers/video/capture/sample.yaml @@ -24,6 +24,7 @@ tests: - mimxrt1064_evk - mimxrt1170_evk/mimxrt1176/cm7 - mm_swiftio + - esp32s3_eye/esp32s3/procpu depends_on: video integration_platforms: - mimxrt1064_evk diff --git a/samples/drivers/video/capture/src/main.c b/samples/drivers/video/capture/src/main.c index 9eed2a3924fb27..d2d64b84dd408d 100644 --- a/samples/drivers/video/capture/src/main.c +++ b/samples/drivers/video/capture/src/main.c @@ -22,18 +22,13 @@ static inline int display_setup(const struct device *const display_dev, const ui struct display_capabilities capabilities; int ret = 0; - if (!device_is_ready(display_dev)) { - LOG_ERR("Device %s not found", display_dev->name); - return -ENODEV; - } - - printk("\nDisplay device: %s\n", display_dev->name); + LOG_INF("Display device: %s", display_dev->name); display_get_capabilities(display_dev, &capabilities); - printk("- Capabilities:\n"); - printk(" x_resolution = %u, y_resolution = %u, supported_pixel_formats = %u\n" - " current_pixel_format = %u, current_orientation = %u\n\n", + LOG_INF("- Capabilities:"); + LOG_INF(" x_resolution = %u, y_resolution = %u, supported_pixel_formats = %u" + " current_pixel_format = %u, current_orientation = %u", capabilities.x_resolution, capabilities.y_resolution, capabilities.supported_pixel_formats, capabilities.current_pixel_format, capabilities.current_orientation); @@ -41,7 +36,7 @@ static inline int display_setup(const struct device *const display_dev, const ui /* Set display pixel format to match the one in use by the camera */ switch (pixfmt) { case VIDEO_PIX_FMT_RGB565: - ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_BGR_565); + ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_RGB_565); break; case VIDEO_PIX_FMT_XRGB32: ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_ARGB_8888); @@ -101,7 +96,7 @@ int main(void) } #endif - printk("Video device: %s\n", video_dev->name); + LOG_INF("Video device: %s", video_dev->name); /* Get capabilities */ if (video_get_caps(video_dev, VIDEO_EP_OUT, &caps)) { @@ -109,11 +104,11 @@ int main(void) return 0; } - printk("- Capabilities:\n"); + LOG_INF("- Capabilities:"); while (caps.format_caps[i].pixelformat) { const struct video_format_cap *fcap = &caps.format_caps[i]; /* fourcc to string */ - printk(" %c%c%c%c width [%u; %u; %u] height [%u; %u; %u]\n", + LOG_INF(" %c%c%c%c width [%u; %u; %u] height [%u; %u; %u]", (char)fcap->pixelformat, (char)(fcap->pixelformat >> 8), (char)(fcap->pixelformat >> 16), (char)(fcap->pixelformat >> 24), fcap->width_min, fcap->width_max, fcap->width_step, fcap->height_min, @@ -127,23 +122,43 @@ int main(void) return 0; } - printk("- Default format: %c%c%c%c %ux%u\n", (char)fmt.pixelformat, +#if CONFIG_VIDEO_FRAME_HEIGHT + fmt.height = CONFIG_VIDEO_FRAME_HEIGHT; +#endif + +#if CONFIG_VIDEO_FRAME_WIDTH + fmt.width = CONFIG_VIDEO_FRAME_WIDTH; + fmt.pitch = fmt.width * 2; +#endif + + if (strcmp(CONFIG_VIDEO_PIXEL_FORMAT, "")) { + fmt.pixelformat = + video_fourcc(CONFIG_VIDEO_PIXEL_FORMAT[0], CONFIG_VIDEO_PIXEL_FORMAT[1], + CONFIG_VIDEO_PIXEL_FORMAT[2], CONFIG_VIDEO_PIXEL_FORMAT[3]); + } + + LOG_INF("- Video format: %c%c%c%c %ux%u", (char)fmt.pixelformat, (char)(fmt.pixelformat >> 8), (char)(fmt.pixelformat >> 16), (char)(fmt.pixelformat >> 24), fmt.width, fmt.height); + if (video_set_format(video_dev, VIDEO_EP_OUT, &fmt)) { + LOG_ERR("Unable to set format"); + return 0; + } + if (!video_get_frmival(video_dev, VIDEO_EP_OUT, &frmival)) { - printk("- Default frame rate : %f fps\n", + LOG_INF("- Default frame rate : %f fps", 1.0 * frmival.denominator / frmival.numerator); } - printk("- Supported frame intervals for the default format:\n"); + LOG_INF("- Supported frame intervals for the default format:"); 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); + LOG_INF(" %u/%u ", fie.discrete.numerator, fie.discrete.denominator); } else { - printk(" [min = %u/%u; max = %u/%u; step = %u/%u]\n", + LOG_INF(" [min = %u/%u; max = %u/%u; step = %u/%u]", fie.stepwise.min.numerator, fie.stepwise.min.denominator, fie.stepwise.max.numerator, fie.stepwise.max.denominator, fie.stepwise.step.numerator, fie.stepwise.step.denominator); @@ -190,7 +205,7 @@ int main(void) return 0; } - printk("Capture started\n"); + LOG_INF("Capture started"); /* Grab video frames */ while (1) { @@ -200,7 +215,7 @@ int main(void) return 0; } - printk("Got frame %u! size: %u; timestamp %u ms\n", frame++, vbuf->bytesused, + LOG_DBG("Got frame %u! size: %u; timestamp %u ms", frame++, vbuf->bytesused, vbuf->timestamp); #if DT_HAS_CHOSEN(zephyr_display)