feat(rgb_lcd): support convert rgb2rgb

This commit is contained in:
Chen Jichang
2026-08-13 17:27:43 +08:00
parent 8c007f0e03
commit df71a43db5
6 changed files with 234 additions and 28 deletions
@@ -22,6 +22,9 @@
#define LCD_LL_RGB_PANEL_NUM 1
#define LCD_LL_I80_BUS_WIDTH 24
#define LCD_LL_I80_BUS_NUM 1
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
#define LCD_LL_SUPPORT_RGB2RGB_CONV 1
#endif
#ifdef __cplusplus
extern "C" {
@@ -295,14 +298,13 @@ static inline void lcd_ll_enable_color_convert(lcd_cam_dev_t *dev, bool en)
}
/**
* @brief Set convert data line width
* @brief Set convert input data line width for YUV<->RGB conversion
*
* @param dev LCD register base address
* @param width data line width
*/
static inline void lcd_ll_set_convert_data_width(lcd_cam_dev_t *dev, uint32_t width)
static inline void lcd_ll_set_yuv_convert_input_data_width(lcd_cam_dev_t *dev, uint32_t width)
{
HAL_ASSERT(width == 8 || width == 16);
dev->lcd_rgb_yuv.lcd_conv_mode_8bits_on = (width == 8) ? 1 : 0;
}
@@ -351,6 +353,28 @@ static inline void lcd_ll_set_yuv_convert_std(lcd_cam_dev_t *dev, lcd_yuv_conv_s
}
}
#if LCD_LL_SUPPORT(RGB2RGB_CONV)
/**
* @brief Set the converter mode: RGB to RGB
*
* @param dev LCD register base address
* @param in_color_format Input color format
* @param out_color_format Output color format
*/
static inline void lcd_ll_set_rgb2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 0;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
if (in_color_format == LCD_COLOR_FMT_RGB888 && out_color_format == LCD_COLOR_FMT_RGB565) {
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 0;
} else if (in_color_format == LCD_COLOR_FMT_RGB565 && out_color_format == LCD_COLOR_FMT_RGB888) {
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 1;
} else {
abort();
}
}
#endif // LCD_LL_SUPPORT(RGB2RGB_CONV)
/**
* @brief Set the converter mode: RGB to YUV
*
@@ -360,6 +384,9 @@ static inline void lcd_ll_set_yuv_convert_std(lcd_cam_dev_t *dev, lcd_yuv_conv_s
*/
static inline void lcd_ll_set_rgb2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
#if LCD_LL_SUPPORT(RGB2RGB_CONV)
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
#endif
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 1;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
switch (out_color_format) {
@@ -383,6 +410,9 @@ static inline void lcd_ll_set_rgb2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color
*/
static inline void lcd_ll_set_yuv2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
#if LCD_LL_SUPPORT(RGB2RGB_CONV)
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
#endif
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 0;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
switch (in_color_format) {
@@ -406,6 +436,9 @@ static inline void lcd_ll_set_yuv2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color
*/
static inline void lcd_ll_set_yuv2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
#if LCD_LL_SUPPORT(RGB2RGB_CONV)
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
#endif
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 1;
switch (in_color_format) {
case LCD_COLOR_FMT_YUV422_UYVY:
@@ -489,9 +522,6 @@ static inline void lcd_ll_set_dma_read_stride(lcd_cam_dev_t *dev, uint32_t strid
case 24:
dev->lcd_user.lcd_byte_mode = 2;
break;
case 32:
dev->lcd_user.lcd_byte_mode = 3;
break;
default:
abort();
}
@@ -267,12 +267,12 @@ static inline void lcd_ll_enable_color_convert(lcd_cam_dev_t *dev, bool en)
}
/**
* @brief Set convert data line width
* @brief Set convert input data line width for YUV<->RGB conversion
*
* @param dev LCD register base address
* @param width data line width (8 or 16)
*/
static inline void lcd_ll_set_convert_data_width(lcd_cam_dev_t *dev, uint32_t width)
static inline void lcd_ll_set_yuv_convert_input_data_width(lcd_cam_dev_t *dev, uint32_t width)
{
HAL_ASSERT(width == 8 || width == 16);
dev->lcd_rgb_yuv.lcd_conv_mode_8bits_on = (width == 8) ? 1 : 0;
@@ -24,6 +24,7 @@
#define LCD_LL_I80_BUS_NUM 1
#define LCD_LL_SUPPORT_IOMUX 1
#define LCD_LL_SUPPORT_RGB2RGB_CONV 1
#ifdef __cplusplus
extern "C" {
@@ -333,17 +334,17 @@ static inline void lcd_ll_set_pixel_clock_prescale(lcd_cam_dev_t *dev, uint32_t
static inline void lcd_ll_enable_color_convert(lcd_cam_dev_t *dev, bool en)
{
dev->lcd_rgb_yuv.lcd_conv_enable = en;
dev->lcd_rgb_yuv.lcd_conv_mem_clk_en = !en;
}
/**
* @brief Set convert data line width
* @brief Set convert input data line width for YUV<->RGB conversion
*
* @param dev LCD register base address
* @param width data line width
*/
static inline void lcd_ll_set_convert_data_width(lcd_cam_dev_t *dev, uint32_t width)
static inline void lcd_ll_set_yuv_convert_input_data_width(lcd_cam_dev_t *dev, uint32_t width)
{
HAL_ASSERT(width == 8 || width == 16);
dev->lcd_rgb_yuv.lcd_conv_mode_8bits_on = (width == 8) ? 1 : 0;
}
@@ -392,6 +393,26 @@ static inline void lcd_ll_set_yuv_convert_std(lcd_cam_dev_t *dev, lcd_yuv_conv_s
}
}
/**
* @brief Set the converter mode: RGB to RGB
*
* @param dev LCD register base address
* @param in_color_format Input color format
* @param out_color_format Output color format
*/
static inline void lcd_ll_set_rgb2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 0;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
if (in_color_format == LCD_COLOR_FMT_RGB888 && out_color_format == LCD_COLOR_FMT_RGB565) {
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 0;
} else if (in_color_format == LCD_COLOR_FMT_RGB565 && out_color_format == LCD_COLOR_FMT_RGB888) {
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 1;
} else {
abort();
}
}
/**
* @brief Set the converter mode: RGB to YUV
*
@@ -402,6 +423,7 @@ static inline void lcd_ll_set_yuv_convert_std(lcd_cam_dev_t *dev, lcd_yuv_conv_s
static inline void lcd_ll_set_rgb2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
(void)in_color_format;
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 1;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
switch (out_color_format) {
@@ -426,6 +448,7 @@ static inline void lcd_ll_set_rgb2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color
static inline void lcd_ll_set_yuv2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
(void)out_color_format;
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 0;
dev->lcd_rgb_yuv.lcd_conv_yuv2yuv_mode = 3;
switch (in_color_format) {
@@ -449,6 +472,7 @@ static inline void lcd_ll_set_yuv2rgb_convert_mode(lcd_cam_dev_t *dev, lcd_color
*/
static inline void lcd_ll_set_yuv2yuv_convert_mode(lcd_cam_dev_t *dev, lcd_color_format_t in_color_format, lcd_color_format_t out_color_format)
{
dev->lcd_rgb_yuv.lcd_conv_rgb2rgb_mode = 2;
dev->lcd_rgb_yuv.lcd_conv_trans_mode = 1;
switch (in_color_format) {
case LCD_COLOR_FMT_YUV422_UYVY:
@@ -532,9 +556,6 @@ static inline void lcd_ll_set_dma_read_stride(lcd_cam_dev_t *dev, uint32_t strid
case 24:
dev->lcd_user.lcd_byte_mode = 2;
break;
case 32:
dev->lcd_user.lcd_byte_mode = 3;
break;
default:
abort();
}