feat(dsi): can use gray8 image as input

This commit is contained in:
morris
2025-09-12 18:20:14 +08:00
parent eedbd9f8e3
commit 42be8c8dbf
8 changed files with 99 additions and 13 deletions

View File

@@ -31,6 +31,7 @@ repos:
.*.pb-c.c|
.*.yuv|
.*.rgb|
.*.gray|
.*COPYING.*|
docs/sphinx-known-warnings\.txt
)$

View File

@@ -9,6 +9,8 @@ project(mipi_dsi_lcd_panel_test)
target_add_binary_data(mipi_dsi_lcd_panel_test.elf "resources/pictures/hello.yuv" BINARY)
target_add_binary_data(mipi_dsi_lcd_panel_test.elf "resources/pictures/world.yuv" BINARY)
target_add_binary_data(mipi_dsi_lcd_panel_test.elf "resources/pictures/hello.gray" BINARY)
target_add_binary_data(mipi_dsi_lcd_panel_test.elf "resources/pictures/world.gray" BINARY)
idf_build_get_property(elf EXECUTABLE)
if(CONFIG_COMPILER_DUMP_RTL_FILES)

View File

@@ -88,7 +88,7 @@ TEST_CASE("MIPI DSI Pattern Generator (EK79007)", "[mipi_dsi]")
#define TEST_IMG_SIZE (100 * 100 * sizeof(uint16_t))
TEST_CASE("MIPI DSI draw bitmap (EK79007)", "[mipi_dsi]")
TEST_CASE("MIPI DSI draw RGB bitmap (EK79007)", "[mipi_dsi]")
{
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
esp_lcd_panel_io_handle_t mipi_dbi_io;
@@ -162,7 +162,7 @@ TEST_CASE("MIPI DSI draw bitmap (EK79007)", "[mipi_dsi]")
test_bsp_disable_dsi_phy_power();
}
TEST_CASE("MIPI DSI with multiple frame buffers (EK79007)", "[mipi_dsi]")
TEST_CASE("MIPI DSI use multiple frame buffers (EK79007)", "[mipi_dsi]")
{
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
esp_lcd_panel_io_handle_t mipi_dbi_io;
@@ -241,7 +241,7 @@ TEST_CASE("MIPI DSI with multiple frame buffers (EK79007)", "[mipi_dsi]")
test_bsp_disable_dsi_phy_power();
}
TEST_CASE("MIPI DSI draw YUV422 (EK79007)", "[mipi_dsi]")
TEST_CASE("MIPI DSI draw YUV422 image (EK79007)", "[mipi_dsi]")
{
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
esp_lcd_panel_io_handle_t mipi_dbi_io;
@@ -249,9 +249,6 @@ TEST_CASE("MIPI DSI draw YUV422 (EK79007)", "[mipi_dsi]")
test_bsp_enable_dsi_phy_power();
uint8_t *img = malloc(TEST_IMG_SIZE);
TEST_ASSERT_NOT_NULL(img);
esp_lcd_dsi_bus_config_t bus_config = {
.bus_id = 0,
.num_data_lanes = 2,
@@ -285,10 +282,6 @@ TEST_CASE("MIPI DSI draw YUV422 (EK79007)", "[mipi_dsi]")
.vsync_pulse_width = MIPI_DSI_LCD_VSYNC,
.vsync_front_porch = MIPI_DSI_LCD_VFP,
},
.flags = {
.use_dma2d = true,
}
};
ek79007_vendor_config_t vendor_config = {
.mipi_config = {
@@ -333,7 +326,84 @@ TEST_CASE("MIPI DSI draw YUV422 (EK79007)", "[mipi_dsi]")
TEST_ESP_OK(esp_lcd_panel_del(mipi_dpi_panel));
TEST_ESP_OK(esp_lcd_panel_io_del(mipi_dbi_io));
TEST_ESP_OK(esp_lcd_del_dsi_bus(mipi_dsi_bus));
free(img);
test_bsp_disable_dsi_phy_power();
}
TEST_CASE("MIPI DSI draw Gray8 image (EK79007)", "[mipi_dsi]")
{
esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
esp_lcd_panel_io_handle_t mipi_dbi_io;
esp_lcd_panel_handle_t mipi_dpi_panel;
test_bsp_enable_dsi_phy_power();
esp_lcd_dsi_bus_config_t bus_config = {
.bus_id = 0,
.num_data_lanes = 2,
.lane_bit_rate_mbps = 1000, // 1000 Mbps
};
TEST_ESP_OK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));
esp_lcd_dbi_io_config_t dbi_config = {
.virtual_channel = 0,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
};
TEST_ESP_OK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io));
esp_lcd_dpi_panel_config_t dpi_config = {
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
.dpi_clock_freq_mhz = MIPI_DSI_DPI_CLK_MHZ,
.virtual_channel = 0,
// Gray8 -> RGB888
.in_color_format = LCD_COLOR_FMT_GRAY8,
.out_color_format = LCD_COLOR_FMT_RGB888,
.video_timing = {
.h_size = MIPI_DSI_LCD_H_RES,
.v_size = MIPI_DSI_LCD_V_RES,
.hsync_back_porch = MIPI_DSI_LCD_HBP,
.hsync_pulse_width = MIPI_DSI_LCD_HSYNC,
.hsync_front_porch = MIPI_DSI_LCD_HFP,
.vsync_back_porch = MIPI_DSI_LCD_VBP,
.vsync_pulse_width = MIPI_DSI_LCD_VSYNC,
.vsync_front_porch = MIPI_DSI_LCD_VFP,
},
};
ek79007_vendor_config_t vendor_config = {
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
},
};
esp_lcd_panel_dev_config_t lcd_dev_config = {
.reset_gpio_num = -1,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = 24,
.vendor_config = &vendor_config,
};
TEST_ESP_OK(esp_lcd_new_panel_ek79007(mipi_dbi_io, &lcd_dev_config, &mipi_dpi_panel));
TEST_ESP_OK(esp_lcd_panel_reset(mipi_dpi_panel));
TEST_ESP_OK(esp_lcd_panel_init(mipi_dpi_panel));
// YUV images are embedded in the firmware binary
extern const uint8_t image_hello_gray_start[] asm("_binary_hello_gray_start");
extern const uint8_t image_world_gray_start[] asm("_binary_world_gray_start");
printf("Draw Gray8 images\r\n");
for (int i = 0; i < 4; i++) {
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(mipi_dpi_panel, 0, 0, 320, 320, image_hello_gray_start));
vTaskDelay(pdMS_TO_TICKS(1000));
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(mipi_dpi_panel, 0, 0, 320, 320, image_world_gray_start));
vTaskDelay(pdMS_TO_TICKS(1000));
}
TEST_ESP_OK(esp_lcd_panel_del(mipi_dpi_panel));
TEST_ESP_OK(esp_lcd_panel_io_del(mipi_dbi_io));
TEST_ESP_OK(esp_lcd_del_dsi_bus(mipi_dsi_bus));
test_bsp_disable_dsi_phy_power();
}

View File

@@ -1,7 +1,7 @@
# How to generate the YUV image from the PNG image
# How to get a YUV image from a PNG image
```bash
ffmpeg -i hello.png -pix_fmt yuyv422 hello.yuv
ffmpeg -i hello.png -pix_fmt yuyv422 -f rawvideo hello.yuv
```
## Supported YUV422 packing order
@@ -11,3 +11,9 @@ ffmpeg -i hello.png -pix_fmt yuyv422 hello.yuv
| yuyv422 | 3 | 16 | 8-8-8 |
| yvyu422 | 3 | 16 | 8-8-8 |
| uyvy422 | 3 | 16 | 8-8-8 |
# How to get a gray8 raw image from a PNG image
```bash
ffmpeg -i hello.png -vf format=gray -pix_fmt gray -f rawvideo hello.gray
```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -361,6 +361,10 @@ static inline void mipi_dsi_brg_ll_set_input_color_format(dsi_brg_dev_t *dev, lc
dev->pixel_type.raw_type = 9;
dev->pixel_type.data_in_type = 1;
break;
case LCD_COLOR_FMT_GRAY8:
dev->pixel_type.raw_type = 12;
dev->pixel_type.data_in_type = 0;
break;
default:
abort();
}

View File

@@ -56,6 +56,7 @@ typedef enum {
LCD_COLOR_FMT_RGB666 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB666), ///< RGB666
LCD_COLOR_FMT_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), ///< RGB888
LCD_COLOR_FMT_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), ///< YUV422
LCD_COLOR_FMT_GRAY8 = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), ///< 8-bit gray scale
} lcd_color_format_t;
/**