feat(rgb_lcd): support convert rgb2rgb

This commit is contained in:
Chen Jichang
2026-08-31 16:17:22 +08:00
parent 5967653bdd
commit 0658f7bd1a
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" {
@@ -293,14 +296,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;
}
@@ -349,6 +351,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
*
@@ -358,6 +382,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) {
@@ -381,6 +408,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) {
@@ -404,6 +434,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:
@@ -487,9 +520,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();
}