/*******************************************************************************
*
*
* File:         hal_dsi_rx_ctrl.h
* Description:  hal mipi dsi rx path control 头文件
* Version:      V0.1
* Date:         2021-04-06
* Author:       lzy
 *******************************************************************************/
#ifndef __HAL_DSI_RX_CTRL_H__
#define __HAL_DSI_RX_CTRL_H__

/*******************************************************************************
* 1.Included files
*******************************************************************************/
#include "tau_dsi_datatype.h"
#include "tau_common.h"

/*******************************************************************************
* 2.Global constant and macro definitions using #define
*******************************************************************************/
#define RX_DCS_QUEUE_MAX_SIZE 20  /* DCS存储队列长度 */

/*******************************************************************************
* 3.Global structures, unions and enumerations using typedef
*******************************************************************************/
typedef struct hal_dcs_execute_entry_t hal_dcs_execute_entry_t;

typedef struct hal_dcs_packet_t hal_dcs_packet_t;

typedef struct hal_dsi_rx_ctrl_handle_t hal_dsi_rx_ctrl_handle_t;

/* DCS CMD 回调函数, 注册进cus_dcs_entry_table里, 匹配对应的DCS 后回调*/
typedef bool (*hal_dsi_rx_ctrl_dcs_execute)(hal_dsi_rx_ctrl_handle_t *rx_handle, hal_dcs_packet_t *dcs_packet);

/* AP 读cmd 回调, 需要快速回CMD 时可注册, 为NULL 时DSC 读指令与写指令经过parse后由cus_dcs_entry_table回调 */
typedef bool (*hal_dsi_rx_ctrl_read_entry)(uint8_t data_type, uint8_t dcs_cmd, uint8_t param);

/* AP PPS 更新回调,参数为PPS 以及从PPS 里解析出来的picture width/height, 用于分辨率切换, 不注册该接口时内部处理PPS */
typedef bool (*hal_dsi_rx_ctrl_pps_entry)(uint8_t *pps, uint8_t size, uint32_t pic_width, uint32_t pic_height);

/**
* @brief hal_rx_dbg_event_e select
*/
typedef enum hal_rx_dbg_event_e
{
    HAL_RX_DBG_FS   = 0,  /* Frame start */
    HAL_RX_DBG_EVENT_MAX
} hal_rx_dbg_event_e;

/* RX debug 回调函数,用于获取frame start 等功能debug */
typedef void (*hal_dsi_rx_ctrl_dbg_entry)(hal_rx_dbg_event_e event);

/**
* @brief  dsi rx ctrl handle struct
*/
typedef struct hal_dsi_rx_ctrl_handle_t
{
    dsi_base_trans_info_t            base_info;                 /* mipi video 转换基本信息 */
    dsi_color_code_e                 rx_color_mode;             /* 输入color mode */
    dsi_lane_nume_e                  rx_lanes;                  /* mipi data lane */
    dsi_video_mode_type_e            rx_nonburst_models;        /* transmission packet sequences */
    dsi_virtual_channel_e            rx_vc;                     /* virtual channel number */
    bool                             compress_en;               /* DSC 压缩标志 */
    uint32_t                         rx_hsclk_rate;             /* mipi 高速信号lane rate */
    uint8_t                          rx_dsc_pps[DSC_PPS_SIZE];  /* DSC 压缩PPS参数 */
    const hal_dcs_execute_entry_t    *cus_dcs_entry_table;      /* DCS处理函数列表 */
    hal_dsi_rx_ctrl_read_entry       rx_dcs_read_entry;         /* Host读指令数据函数,为NULL时由rx_dcs_queue注册cmd处理 */
    hal_dsi_rx_ctrl_pps_entry        pps_update_entry;          /* PPS Update 时回调函数,用于分辨率切换更新PPS,为NULL时内部处理 */
    bool                             used;                      /* handle使用标志位 */
    uint8_t                          pq_marginal;               /* picture quality,参数为hal_rx_pq_marginal_type_e */
    bool                             direct_mode;               /* video mode 直通模式,支持60hz同帧率且porch相等或者相近时使用 */
    hal_dsi_rx_ctrl_dbg_entry        rx_debug_cb;               /* rx debug 回调函数,目前为收到frame start之后回调，预留其他debug功能 */
    hal_err_handle_level_e           err_handler_level;         /* RX接收错误的时候对模块做reset等级, 等级越高reset模块越多 */
    bool                             draw_mode;                 /* 画点模式,仅debug使用 */
#if defined(ISP_568) || defined(ISP_368)
    uint8_t                          rx_strength;               /* 用于调节RX信号强度，仅适用于开启内阻校准模式，档位0~7，默认3 */
    hight_performan_mode_e           hight_performan_mode;      /* 高性能模式等级,参考hight_performan_mode_e */
    bool                             pu_optimize;               /* 用于优化PU显示效果，默认为false;true:优化PU显示显示效果,高功耗;false:普通PU模式,低功耗 */
#endif
    bool                             video_auto_sync;           /* Video mode 自动同步开关 */
    uint8_t                          rx_debug_status;           /* rx debug status用于debug表示rx的状态 */
} hal_dsi_rx_ctrl_handle_t;

/**
* @brief  DCS command execute entry
*/
typedef struct hal_dcs_execute_entry_t
{
    uint32_t dcs_command;                      /* DCS command */
    hal_dsi_rx_ctrl_dcs_execute execute_func;  /* command 对应处理函数 */
    bool immediately_func;                     /* 执行机制:true-在中断里立即执行,false-加入DCS队列异步执行 */
} hal_dcs_execute_entry_t;

/**
* @brief  存储 DCS packet 结构体
*/
typedef struct hal_dcs_packet_t
{
    uint32_t data_type;                        /* data type */
    uint32_t dcs_command;                      /* dcs command */
    uint32_t param_length;                     /* dcs param length */
    uint8_t *packet_param;                     /* dcs param */
    const hal_dcs_execute_entry_t *dcs_execute_entry;  /* dcs packet 处理函数入口*/
} hal_dcs_packet_t;

/**
* @brief dcs command filter select
*/
typedef enum
{
    HAL_RX_DCS_FILTER_0 = 0,
    HAL_RX_DCS_FILTER_1 = 1,
    HAL_RX_DCS_FILTER_2 = 2,
    HAL_RX_DCS_FILTER_3 = 3,
    HAL_RX_DCS_FILTER_4 = 4,
    HAL_RX_DCS_FILTER_5 = 5,
    HAL_RX_DCS_FILTER_6 = 6,
    HAL_RX_DCS_FILTER_7 = 7,
    HAL_RX_DCS_FILTER_MAX
} hal_rx_dcs_filter_sel_e;

/**
* @brief  pentile source color format
*/
typedef enum
{
    PENTILE_SRC_FORMAT_RGB           = 0x0,
    PENTILE_SRC_FORMAT_BGR           = 0x1,
    PENTILE_SRC_FORMAT_RGBG_BGRG     = 0x8,
    PENTILE_SRC_FORMAT_GBGR_GRGB     = 0x9,
    PENTILE_SRC_FORMAT_BGRG_RGBG     = 0xA,
    PENTILE_SRC_FORMAT_GRGB_GBGR     = 0xB,
    PENTILE_SRC_FORMAT_RGBG_RGBG     = 0xC,
    PENTILE_SRC_FORMAT_GBGR_GBGR     = 0xD,
    PENTILE_SRC_FORMAT_BGRG_BGRG     = 0xE,
    PENTILE_SRC_FORMAT_GRGB_GRGB     = 0xF,
    PENTILE_SRC_FORMAT_MAX
} pentile_src_format_e;

/**
* @brief pential G0 G1 swap mode
*/
typedef enum
{
    PENTILE_G0G1  = 0,
    PENTILE_G1G0  = 1
} pentile_g_swap_e;

/**
* @brief pential R B swap mode
*/
typedef enum
{
    PENTILE_RGBG_BGRG  = 0,
    PENTILE_GGRB_RBGG  = 1,
    PENTILE_GGBR_BRGG  = 3
} pentile_rb_swap_e;

/**
* @brief TE 信号产生模式
*/
typedef enum
{
    TE_HW_MODE          = 0,   /* TE由硬件产生,频率与输出帧率一致 */
    TE_USER_MODE        = 1,   /* 底层不产生TE, 由hal_dsi_rx_ctrl_gen_a_tear_signal 接口产生 */
    TE_SOFT_60HZ_MODE   = 2,   /* 底层软件产生同步60Hz TE   */
    TE_SOFT_90HZ_MODE   = 4,   /* 底层软件产生同步90Hz TE  */
    TE_SOFT_120HZ_MODE  = 5,   /* 底层软件产生同步120Hz TE   */
    TE_HW_MAX
} te_mode_e;

/**
* @brief pq_marginal_type select
*/
typedef enum
{
    PQ_TYPE_0 = 0x0,
    PQ_TYPE_1 = 0x1,
    PQ_TYPE_2 = 0x3,
    PQ_TYPE_3 = 0x2,
    PQ_TYPE_4 = 0xA,
    PQ_TYPE_5 = 0xE,
    PQ_TYPE_6 = 0xC,
    PQ_TYPE_7 = 0x1A,
    PQ_TYPE_8 = 0x18,
    PQ_TYPE_MAX
} hal_rx_pq_marginal_type_e;

/**
* @brief 设置RX CLK
*/
typedef enum
{
    RX_CLK_100M   = 0,
    RX_CLK_150M   = 1,
    RX_CLK_200M   = 2,
    RX_CLK_300M   = 3,
    RX_CLK_MAX
} hal_rx_clk_e;


/*******************************************************************************
* 4.Global variable extern declarations
*******************************************************************************/

/*******************************************************************************
* 5.Global function prototypes
*******************************************************************************/

/**
* @brief  创建dsi rx ctrl handle (释放时需调用hal_dsi_rx_ctrl_release_handle)
* @param  none
* @retval dsi rx handle
*/
hal_dsi_rx_ctrl_handle_t *hal_dsi_rx_ctrl_create_handle(void);

/**
* @brief  释放dsi rx ctrl handle
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_release_handle(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  设置rx ctrl handle 里的 PPS 参数
* @param  rx_ctrl_handle: dsi rx handle
* @param  pps: pps 参数
* @param  pps_size: pps 参数长度
* @retval true/false
*/
bool hal_dsi_rx_ctrl_pre_init_pps(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t pps[], uint32_t pps_size);

/**
* @brief  初始化dsi rx 模块
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_init(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  dsi rx 模块去初始化
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_deinit(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  启动dsi rx
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_start(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  重新配置dsi rx参数并恢复状态 (debug使用, 重新配置rx_ctrl_handle参数后调用该接口重启)
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_restart(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  停止dsi rx
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_stop(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  手动设置RX clk,一般RX CLK 由底层自动计算,用于特殊video mode场景出现FIFO FULL情况调试使用
* @param  rxbr_clk: rx clk, 需要大于hs_lane_rate/8
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_rx_clk(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_rx_clk_e rxbr_clk);

/**
* @brief  发送 MIPI HOST的读响应 CMD
* @param  rx_ctrl_handle: dsi rx handle
* @param  data_type: data type
* @param  vc:        virtual channel
* @param  cmd_count: ack command 的长度
* @param  ...      : 需要发送的command(数量与cmd_count 配置一致)
* @retval true/false
*/
bool hal_dsi_rx_ctrl_send_ack_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, dsi_ack_data_type_e data_type, dsi_virtual_channel_e vc, uint8_t cmd_count, ...);

/**
* @brief  使用数组方式回复短包,与hal_dsi_rx_ctrl_send_ack_cmd功能一致
* @param  rx_ctrl_handle: dsi rx handle
* @param  data_size: 数组长度,固定为4
* @param  data: 回复cmd数据,数据排列有严格规定:
* data[0]:DI(data type)
* data[1]:data 0
* data[2]:data 1
* data[3]:内部pkt type,短包固定为0
* @retval true/false
*/
bool hal_dsi_rx_ctrl_ack_short_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t data_size, uint8_t data[]);

/**
* @brief  使用数组方式回复长包,与hal_dsi_rx_ctrl_send_ack_cmd功能一致
* @param  rx_ctrl_handle: dsi rx handle
* @param  data_size: 数组长度,为Word Count + header长度 (header固定为4)
* @param  data: 回复cmd数据,数据排列有严格规定:
* data[0]:DI(data type)
* data[1]:wc 0 (Word Count 低八位)
* data[2]:wc 1 (Word Count 高八位)
* data[3]:内部pkt type,长包固定为1
* data[N]:长包数据
* @retval true/false
*/
bool hal_dsi_rx_ctrl_ack_long_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t data_size, uint8_t data[]);

/**
* @brief  异步处理DSC接口,执行cus_dcs_entry_table里对应DCS immediately_func为false的函数
* @param  rx_ctrl_handle: dsi rx handle
* @retval true - 正常处理1个DSC , false - 无DSC 处理
*/
bool hal_dsi_rx_ctrl_dsc_async_handler(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  使用硬件filter丢弃不需要处理的CMD,避免MCU资源被无效CMD占用
* @param  rx_ctrl_handle: dsi rx handle
* @param  filter_number: filter 编号(0-7)
* @param  cmd_start: 需要丢弃command code起始位
* @param  cmd_end: 需要丢弃command code终止位
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_hw_cmd_filter(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle,
                                       hal_rx_dcs_filter_sel_e filter_number,
                                       uint32_t cmd_start, uint32_t cmd_end);

/**
* @brief  配置输入输出同步行数,用于调整图像撕裂问题
* @param  rx_ctrl_handle: dsi rx handle
* @param  line_num:  同步行号,范围1 ~ input height
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_cus_sync_line(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t line_num);

/**
* @brief  使用内置pattern代替mipi输入(用于测试)
* @param  rx_ctrl_handle: dsi rx handle
* @param  pg_orient: pattern 方向(0:Vertical mode ; 1:Horizontal mode)
* @param  enable: 开启/关闭pattern
* @retval true/false
*/
bool hal_dsi_rx_ctrl_enable_test_pattern(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t pg_orient, bool enable);

/**
* @brief  设置TE信号特征
* @param  rx_ctrl_handle: dsi rx handle
* @param  inverse_poly: tear信号极性
* @param  te_width: tear信号宽度(0-1023)
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_te_waveform(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool inverse_poly, uint32_t te_width);

/**
* @brief  客制化scld filter配置,用于图像质量调节
* @param  rx_ctrl_handle: dsi rx handle
* @param  scld_filter_h: 水平方向filter
* @param  scld_filter_v: 垂直方向filter
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_cus_scld_filter(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t scld_filter_h[32][2], uint32_t scld_filter_v[32][2]);

/**
* @brief  获取AP 配置 BTA回复数据最大size
* @param  rx_ctrl_handle: dsi rx handle
* @retval 返回数据大小
*/
uint32_t hal_dsi_rx_ctrl_get_max_ret_size(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  获取AP Compression Mode Command配置,默认为0,谨慎使用
* @param  rx_ctrl_handle: dsi rx handle
* @retval AP 配置compressen_en
*/
bool hal_dsi_rx_ctrl_get_compressen_en(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  生成一个TE信号
* @param  rx_ctrl_handle: dsi rx handle
* @retval none
*/
bool hal_dsi_rx_ctrl_gen_a_tear_signal(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  输入分辨率切换接口
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_toggle_resolution(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  启动高性能模式,通常为debug使用
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_hight_performan_mode(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  配置TE信号为软件模式
* @param  rx_ctrl_handle: dsi rx handle
* @retval none
*/
bool hal_dsi_rx_ctrl_set_sw_tear_mode(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  配置TE信号为硬件模式
* @param  rx_ctrl_handle: dsi rx handle
* @retval none
*/
bool hal_dsi_rx_ctrl_set_hw_tear_mode(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/**
* @brief  配置 pentile格式
* @param  rx_ctrl_handle: dsi rx handle
* @param  src_format: pentile format
* @param  g_swap: swap G0 G1
* @param  rb_swap: swap R B
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_pentile_format(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, pentile_src_format_e src_format, pentile_g_swap_e g_swap, pentile_rb_swap_e rb_swap);

/**
* @brief  配置 RX escape clk
* @param  rx_ctrl_handle: dsi rx handle
* @param  esc_clk: escape clk 单位Hz,10000000时回CMD为10Mhz
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_cus_esc_clk(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t esc_clk);

/**
* @brief  自动计算并配置硬件filter
* @param  rx_ctrl_handle: dsi rx handle
* @param  enable: 启动/关闭 硬件filter
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_auto_hw_filter(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool enable);

/*
* @brief  配置DCS cmd 透传模式, Tx init 之后生效
* @param  enable/disable
* @retval true/false
*/
bool hal_dsi_rx_ctrl_set_dcs_direct_mode(bool enable);

/*
* @brief  输入帧率修改(针对video mode)
* @param  rx_ctrl_handle: dsi rx handle
* @param  frame_rate：frame rate
*/
bool hal_dsi_rx_ctrl_toggle_input_frame_rate(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, dsi_video_frame_rate_e frame_rate);

/**
* @brief  配置TE模式扩展接口
* @param  line_num:  同步行号,范围1 ~ input height
建议从最大开始配置,step为100逐步减小,直到完全不出现撕裂
* @param  te_mode: 产生 te 模式,建议使用HW mode
* @retval none
*/
bool hal_dsi_rx_ctrl_set_tear_mode_ex(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t line_num, te_mode_e te_mode);

/**
* @brief  输入分辨率切换扩展接口
* @param  rx_ctrl_handle: dsi rx handle
* @retval true/false
*/
bool hal_dsi_rx_ctrl_toggle_resolution_ex(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);

/*
* @brief  注册写命令的回调函数,用于特殊命令序列时写命令的处理.
          可配合hal_dsi_rx_ctrl_set_auto_hw_filter关闭hw filter用于获取所有软件CMD
* @param  rx_ctrl_handle: dsi rx handle
* @param  写命令处理函数
* @retval none
*/
void hal_dsi_rx_ctrl_register_write_cmd_entry(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_dsi_rx_ctrl_dcs_execute execute_func);


#if !defined(ISP_568) && !defined(ISP_368)
    /* ISP_518/ISP_308 接口 */
    /**
    * @brief  客制化 Channel Gain 配置,用于图像质量调节
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  gain_r: channel gain coefficient for R
    * @param  gain_g: channel gain coefficient for G
    * @param  gain_b: channel gain coefficient for B
    * @retval true/false
    */
    bool hal_dsi_rx_ctrl_set_cus_pq_gain(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, int r_gain, int g_gain, int b_gain);

    /**
    * @brief  客制化enhance for luma参数配置,用于图像质量调节
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  enhl_str: Enhance Str
    * @param  enhl_edgeslope: Enhance Edge Slope
    * @retval none
    */
    bool hal_dsi_rx_ctrl_set_cus_pq_enh_lum(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t enhl_str, uint32_t enhl_edgeslope);

    /**
    * @brief  客制化false color remove for chroma参数配置,用于图像质量调节
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  desatstr: 饱和度调整参数 范围:0-4095
    * @param  desatslope: 饱和度调整斜率 范围:0-4095
    * @retval none
    */
    bool hal_dsi_rx_ctrl_set_cus_pq_enh_chr(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t desatstr, uint32_t desatslope);

    /**
    * @brief  客制化false color remove for chroma参数配置2,用于图像质量调节
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  desatmode: 饱和度调整模式 0-降低饱和度 1-提升饱和度
    * @param  fc_final_alpha: 饱和度调整参数 范围:0 - 255
    * @param  edge_med_slope: 饱和度调整参数 范围:0 - 4095
    * @retval none
    */
    bool hal_dsi_rx_ctrl_set_cus_pq_enh_chr2(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t desatmode, uint32_t fc_final_alpha, uint32_t edge_med_slope);

#else
    /* ISP_568/ISP_368 接口 */
    /**
    * @brief  裁剪输入video多余部分，用于部分机型比如mipi输入是900x1792,实际有效部分为828x1792,可用于裁剪右边跟下边
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  crop_width: 需要裁剪的列数
    * @param  crop_height: 需要裁剪的行数
    * @retval true/false
    */
    bool hal_dsi_rx_ctrl_crop_video(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t crop_width, uint32_t crop_height);

    /*
    * @brief  初始化画点模式,全屏赋值
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  red_data: 像素点R分量
    * @param  green_data: 像素点G分量
    * @param  blue_data: 像素点B分量
    * @retval none
    */
    void hal_dsi_rx_ctrl_draw_mode_init(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t red_data, uint8_t green_data, uint8_t blue_data);

    /*
    * @brief  配置像素颜色
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  x: 像素点的x 坐标
    * @param  y: 像素点的y 坐标
    * @param  red_data: 像素点R分量
    * @param  green_data: 像素点G分量
    * @param  blue_data: 像素点B分量
    * @retval none
    */
    void hal_dsi_rx_ctrl_set_pixel_data(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, int x, int y, uint8_t red_data, uint8_t green_data, uint8_t blue_data);

    /*
    * @brief  填充颜色矩形
    * @param  rx_ctrl_handle: dsi rx handle
    * @param  x1,y1: 矩形起始点
    * @param  x2,y2: 矩形终点
    * @param  red_data: 像素点R分量
    * @param  green_data: 像素点G分量
    * @param  blue_data: 像素点B分量
    * @retval none
    */
    void hal_dsi_rx_ctrl_set_rect_pixel_data(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, int x1, int x2, int y1, int y2, uint8_t red_data, uint8_t green_data, uint8_t blue_data);
#endif

#endif //__HAL_DSI_RX_CTRL_H__
