mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
rgb_lcd: support yuv converter
This commit is contained in:
@@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.16)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(rgb_lcd_panel_test)
|
||||
|
||||
target_add_binary_data(rgb_lcd_panel_test.elf "resources/pictures/hello.yuv" BINARY)
|
||||
target_add_binary_data(rgb_lcd_panel_test.elf "resources/pictures/world.yuv" BINARY)
|
||||
|
||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
|
@@ -1,6 +1,10 @@
|
||||
set(srcs "test_app_main.c"
|
||||
"test_rgb_panel.c")
|
||||
|
||||
if(CONFIG_SOC_LCD_SUPPORT_RGB_YUV_CONV)
|
||||
list(APPEND srcs "test_yuv_rgb_conv.c")
|
||||
endif()
|
||||
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
|
105
components/esp_lcd/test_apps/rgb_lcd/main/test_yuv_rgb_conv.c
Normal file
105
components/esp_lcd/test_apps/rgb_lcd/main/test_yuv_rgb_conv.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "unity.h"
|
||||
#include "esp_lcd_panel_rgb.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_random.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_attr.h"
|
||||
#include "spi_flash_mmap.h"
|
||||
#include "test_rgb_board.h"
|
||||
|
||||
#define TEST_IMG_SIZE (320 * 320 * sizeof(uint16_t))
|
||||
|
||||
// YUV images are embedded in the firmware binary
|
||||
extern const uint8_t image_hello_yuv_start[] asm("_binary_hello_yuv_start");
|
||||
extern const uint8_t image_hello_yuv_end[] asm("_binary_hello_yuv_end");
|
||||
extern const uint8_t image_world_yuv_start[] asm("_binary_world_yuv_start");
|
||||
extern const uint8_t image_world_yuv_end[] asm("_binary_world_yuv_end");
|
||||
|
||||
TEST_CASE("lcd_rgb_panel_yuv422_conversion", "[lcd]")
|
||||
{
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
esp_lcd_rgb_panel_config_t panel_config = {
|
||||
.data_width = 16,
|
||||
.psram_trans_align = 64,
|
||||
.bits_per_pixel = 16, // YUV422: 16bits per pixel
|
||||
.clk_src = LCD_CLK_SRC_DEFAULT,
|
||||
.disp_gpio_num = TEST_LCD_DISP_EN_GPIO,
|
||||
.pclk_gpio_num = TEST_LCD_PCLK_GPIO,
|
||||
.vsync_gpio_num = TEST_LCD_VSYNC_GPIO,
|
||||
.hsync_gpio_num = TEST_LCD_HSYNC_GPIO,
|
||||
.de_gpio_num = TEST_LCD_DE_GPIO,
|
||||
.data_gpio_nums = {
|
||||
TEST_LCD_DATA0_GPIO,
|
||||
TEST_LCD_DATA1_GPIO,
|
||||
TEST_LCD_DATA2_GPIO,
|
||||
TEST_LCD_DATA3_GPIO,
|
||||
TEST_LCD_DATA4_GPIO,
|
||||
TEST_LCD_DATA5_GPIO,
|
||||
TEST_LCD_DATA6_GPIO,
|
||||
TEST_LCD_DATA7_GPIO,
|
||||
TEST_LCD_DATA8_GPIO,
|
||||
TEST_LCD_DATA9_GPIO,
|
||||
TEST_LCD_DATA10_GPIO,
|
||||
TEST_LCD_DATA11_GPIO,
|
||||
TEST_LCD_DATA12_GPIO,
|
||||
TEST_LCD_DATA13_GPIO,
|
||||
TEST_LCD_DATA14_GPIO,
|
||||
TEST_LCD_DATA15_GPIO,
|
||||
},
|
||||
.timings = {
|
||||
.pclk_hz = TEST_LCD_PIXEL_CLOCK_HZ,
|
||||
.h_res = TEST_LCD_H_RES,
|
||||
.v_res = TEST_LCD_V_RES,
|
||||
.hsync_back_porch = 68,
|
||||
.hsync_front_porch = 20,
|
||||
.hsync_pulse_width = 5,
|
||||
.vsync_back_porch = 18,
|
||||
.vsync_front_porch = 4,
|
||||
.vsync_pulse_width = 1,
|
||||
},
|
||||
.flags.fb_in_psram = 1, // allocate frame buffer in PSRAM
|
||||
};
|
||||
|
||||
printf("Create RGB LCD panel\r\n");
|
||||
TEST_ESP_OK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
|
||||
TEST_ESP_OK(esp_lcd_panel_reset(panel_handle));
|
||||
|
||||
printf("Set YUV-RGB conversion profile\r\n");
|
||||
esp_lcd_yuv_conv_config_t conv_config = {
|
||||
.std = LCD_YUV_CONV_STD_BT601,
|
||||
.src = {
|
||||
.color_range = LCD_COLOR_RANGE_FULL,
|
||||
.color_space = LCD_COLOR_SPACE_RGB,
|
||||
},
|
||||
.dst = {
|
||||
.color_range = LCD_COLOR_RANGE_FULL,
|
||||
.color_space = LCD_COLOR_SPACE_RGB,
|
||||
},
|
||||
};
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, esp_lcd_rgb_panel_set_yuv_conversion(panel_handle, &conv_config));
|
||||
|
||||
conv_config.src.color_space = LCD_COLOR_SPACE_YUV;
|
||||
conv_config.src.yuv_sample = LCD_YUV_SAMPLE_422;
|
||||
TEST_ESP_OK(esp_lcd_rgb_panel_set_yuv_conversion(panel_handle, &conv_config));
|
||||
|
||||
TEST_ESP_OK(esp_lcd_panel_init(panel_handle));
|
||||
|
||||
printf("Draw YUV images\r\n");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, 320, 320, image_hello_yuv_start));
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, 320, 320, image_world_yuv_start));
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
|
||||
TEST_ESP_OK(esp_lcd_panel_del(panel_handle));
|
||||
}
|
5
components/esp_lcd/test_apps/rgb_lcd/resources/README.md
Normal file
5
components/esp_lcd/test_apps/rgb_lcd/resources/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# How to generate the YUV image from the PNG image
|
||||
|
||||
```bash
|
||||
ffmpeg -i hello.png -pix_fmt uyvy422 hello.yuv
|
||||
```
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user