Edit online

数据结构说明

28 Nov 2024
Read time: 12 minute(s)

本节段介绍了多个结构体和枚举类型的代码示例,用于描述和管理显示框架缓冲区 (Framebuffer) 的配置,包括矩形区域、点坐标、大小、像素格式、缓冲区属性、图层数据、颜色键、Alpha 混合、CCM(Color Correction Matrix)、Gamma 校正以及屏幕信息。

mpp_types.h

路径:bsp/artinchip/include/uapi/mpp_types.h

  • struct mpp_rect
    struct mpp_rect {
        int x;
        int y;
        int width;
        int height;
    };
  • struct mpp_point
    struct mpp_point {
        int x;
        int y;
    };
  • struct mpp_size
    struct mpp_size {
        int width;
        int height;
    };
  • enum mpp_pixel_format
    enum mpp_pixel_format {
        MPP_FMT_ARGB_8888            = 0x00,
        MPP_FMT_ABGR_8888            = 0x01,
        MPP_FMT_RGBA_8888            = 0x02,
        MPP_FMT_BGRA_8888            = 0x03,
        MPP_FMT_XRGB_8888            = 0x04,
        MPP_FMT_XBGR_8888            = 0x05,
        MPP_FMT_RGBX_8888            = 0x06,
        MPP_FMT_BGRX_8888            = 0x07,
        MPP_FMT_RGB_888              = 0x08,
        MPP_FMT_BGR_888              = 0x09,
        MPP_FMT_ARGB_1555            = 0x0a,
        MPP_FMT_ABGR_1555            = 0x0b,
        MPP_FMT_RGBA_5551            = 0x0c,
        MPP_FMT_BGRA_5551            = 0x0d,
        MPP_FMT_RGB_565              = 0x0e,
        MPP_FMT_BGR_565              = 0x0f,
        MPP_FMT_ARGB_4444            = 0x10,
        MPP_FMT_ABGR_4444            = 0x11,
        MPP_FMT_RGBA_4444            = 0x12,
        MPP_FMT_BGRA_4444            = 0x13,
    
        MPP_FMT_YUV420P              = 0x20,
        MPP_FMT_NV12                 = 0x21,
        MPP_FMT_NV21                 = 0x22,
        MPP_FMT_YUV422P              = 0x23,
        MPP_FMT_NV16                 = 0x24,
        MPP_FMT_NV61                 = 0x25,
        MPP_FMT_YUYV                 = 0x26,
        MPP_FMT_YVYU                 = 0x27,
        MPP_FMT_UYVY                 = 0x28,
        MPP_FMT_VYUY                 = 0x29,
        MPP_FMT_YUV400               = 0x2a,
        MPP_FMT_YUV444P              = 0x2b,
    
        MPP_FMT_YUV420_64x32_TILE    = 0x30,
        MPP_FMT_YUV420_128x16_TILE   = 0x31,
        MPP_FMT_YUV422_64x32_TILE    = 0x32,
        MPP_FMT_YUV422_128x16_TILE   = 0x33,
        MPP_FMT_MAX,
    };

artinchip_fb.h

路径: bsp/artinchip/include/uapi/artinchip_fb.h

  • struct aicfb_layer_num
    /**
     * struct aicfb_layer_num - aicfb layer number
     * @vi_num: number of video layers
     * @ui_num: number of UI layers
     *
     *  total_layer_num = vi_num + ui_num
     *
     *  layer id range: [0, total_layer_num - 1]
     */
    struct aicfb_layer_num {
        unsigned int vi_num;
        unsigned int ui_num;
    };
  • struct aicfb_layer_capability
    /**
     * struct aicfb_layer_capability - aicfb layer capability
     * @layer_id: the layer id
     * @layer_type: the layer type
     *  0: UI layer
     *  1: Video layer
     * @max_width:  the max pixels per line
     * @max_height: the max lines
     * @cap_flags:  flags of layer capability
     */
    struct aicfb_layer_capability {
        unsigned int layer_id;
        unsigned int layer_type;
        unsigned int max_width;
        unsigned int max_height;
        unsigned int cap_flags;
    };
  • struct aicfb_buffer
    /**
     * struct aicfb_buffer - aicfb frame buffer
     * @phy_addr[3]: address of frame buffer
     *  single addr for interleaved fomart with 1 plane,
     *  double addr for semi-planar fomart with 2 planes,
     *  triple addr for planar format with 3 planes
     * @size: width and height of aicfb_buffer
     * @stride[3]: stride for all planes
     * @crop_en: corp disable/enable ctrl
     *  0: disable crop the buffer
     *  1: enable crop the buffer
     * @crop: crop info
     * @format: color format
     * @buf_flags: aicfb buffer flags
     */
    struct aicfb_buffer {
        unsigned int            phy_addr[AICFB_PLANE_NUM];
        unsigned int            dmabuf_fd[AICFB_PLANE_NUM];
        unsigned int            stride[AICFB_PLANE_NUM];
        struct aic_size         size;
        unsigned int            crop_en;
        struct aic_rect         crop;
        enum aic_pixel_format   format;
        unsigned int            buf_flags;
    };
  • struct aicfb_layer_data
    /**
     * struct aicfb_layer_data - aicfb layer data
     * @enable
     *  0: disable the layer
     *  1: enable the layer
     * @layer_id: the layer id
     *
     * @rect_id: the rectanglular window id of the layer
     *  only used by layers with multi-rectangular windows
     *  for example: if the layer has 4 rectangular windows,
     *  rect_id can be 0,1,2 or 3 for different windows
     *
     * @scale_size:  scaling size
     *  if the layer can be scaled. the scaling size can be different
     *  from the input buffer. the input buffer can be original aicfb_buffer
     *  or crop aicfb_buffer, otherwise, the scaling size will be ignore
     *
     * @pos: left-top x/y coordinate of the screen in pixels
     * @buf: frame buffer
     */
    struct aicfb_layer_data {
        unsigned int enable;
        unsigned int layer_id;
        unsigned int rect_id;
        struct aic_size scale_size;
        struct aic_point pos;
        struct aicfb_buffer buf;
    };
  • struct aicfb_config_lists
    /**
     * struct aicfb_config_lists - aicfb config lists
     * @num: the total number of layer data config lists
     * @layers[]: the array of aicfb_layer_data lists
     */
    struct aicfb_config_lists {
        unsigned int num;
        struct aicfb_layer_data layers[];
    };
  • struct aicfb_alpha_config
    /**
     * struct aicfb_alpha_config - aicfb layer alpha blending config
     *
     * @layer_id: the layer id
     *
     * @enable
     *  0: disable alpha
     *  1: enable alpha
     *
     * @mode: alpha mode
     *  0: pixel alpha mode
     *  1: global alpha mode
     *  2: mixder alpha mode(alpha = pixel alpha * global alpha / 255)
     *
     * @value: global alpha value (0~255)
     *  used by global alpha mode and mixer alpha mode
     *
     */
    struct aicfb_alpha_config {
        unsigned int layer_id;
        unsigned int enable;
        unsigned int mode;
        unsigned int value;
    };
  • struct aicfb_ck_config
    /**
     * struct aicfb_ck_config - aicfb layer color key blending config
     *
     * @layer_id: the layer id
     *
     * @ck_enable
     *  0: disable color key
     *  1: enable color key
     *
     *
     * @ck_value: color key rgb value to match the layer pixels
     *  bit[31:24]: reserved
     *  bit[23:16]: R value
     *  bit[15:8]: G value
     *  bit[7:0]: B value
     *
     */
    struct aicfb_ck_config {
        unsigned int layer_id;
        unsigned int enable;
        unsigned int value;
    };
  • struct aicfb_disp_prop
    /*
     * struct aicfb_disp_prop - aicfb display property
     *
     * @bright: bright in percent, range [0, 100], 50 means no effect
     * @contrast: contrast in percent, range [0, 100], 50 means no effect
     * @saturation: saturation in percent, range [0, 100], 50 means no effect
     * @hue: hue in percent, range [0, 100], 50 means no effect
     */
    struct aicfb_disp_prop {
        unsigned int bright;
        unsigned int contrast;
        unsigned int saturation;
        unsigned int hue;
    };
  • struct aicfb_ccm_config
    struct aicfb_ccm_config {
        unsigned int enable;
        int ccm_table[12];
    };
  • struct aicfb_gamma_config
    enum gamma_lut {
        GAMMA_RED,
        GAMMA_GREEN,
        GAMMA_BLUE,
    };
    
    struct aicfb_gamma_config {
        unsigned int enable;
        unsigned int gamma_lut[3][16];
    };
  • struct aicfb_screeninfo
    /*
     * struct aicfb_screeninfo - aicfb screen info
     *
     * @format: color format
     * @bits_per_pixel: bits per pixel
     * @stride: stride of screen
     * @width: screen width in pixels
     * @height: screen height in pixels
     * @framebuffer: start of frame buffer mem
     * @smem_len: length of frame buffer mem
     */
    struct aicfb_screeninfo {
        enum mpp_pixel_format format;
        unsigned int bits_per_pixel;
        unsigned int stride;
    
        unsigned int width;
        unsigned int height;
    
        unsigned char *framebuffer;
        unsigned int smem_len;
    };
  • ioctl 命令
    #define AICFB_WAIT_FOR_VSYNC  _IOW(IOC_TYPE_FB, 0x20, unsigned int)
    
    /** get layer number */
    #define AICFB_GET_LAYER_NUM  _IOR(IOC_TYPE_FB, 0x21, struct aicfb_layer_num)
    
    /** get layer capability */
    #define AICFB_GET_LAYER_CAPABILITY  _IOWR(IOC_TYPE_FB, 0x22,\
                        struct aicfb_layer_capability)
    
    /** get layer config data */
    #define AICFB_GET_LAYER_CONFIG  _IOWR(IOC_TYPE_FB, 0x23, \
                        struct aicfb_layer_data)
    
    /** update layer config data */
    #define AICFB_UPDATE_LAYER_CONFIG  _IOW(IOC_TYPE_FB, 0x24, \
                        struct aicfb_layer_data)
    
    /** update layer config data lists */
    #define AICFB_UPDATE_LAYER_CONFIG_LISTS  _IOW(IOC_TYPE_FB, 0x25, \
                            struct aicfb_config_lists)
    
    /** get layer alpha blendig config */
    #define AICFB_GET_ALPHA_CONFIG  _IOWR(IOC_TYPE_FB, 0x26, \
                        struct aicfb_alpha_config)
    
    /** update layer alpha blendig config */
    #define AICFB_UPDATE_ALPHA_CONFIG  _IOW(IOC_TYPE_FB, 0x27, \
                        struct aicfb_alpha_config)
    
    /** get layer color key config */
    #define AICFB_GET_CK_CONFIG  _IOWR(IOC_TYPE_FB, 0x28, struct aicfb_ck_config)
    
    /** update layer color key config */
    #define AICFB_UPDATE_CK_CONFIG  _IOW(IOC_TYPE_FB, 0x29, struct aicfb_ck_config)
    
    /** pan display */
    #define AICFB_PAN_DISPLAY  _IOR(IOC_TYPE_FB, 0x43, unsigned int)
    
    /** set display property */
    #define AICFB_SET_DISP_PROP _IOW(IOC_TYPE_FB, 0x60, struct aicfb_disp_prop)
    
    /** get display property */
    #define AICFB_GET_DISP_PROP _IOR(IOC_TYPE_FB, 0x61, struct aicfb_disp_prop)
    
    /** update ccm config */
    #define AICFB_UPDATE_CCM_CONFIG _IOR(IOC_TYPE_FB, 0x65, struct aicfb_ccm_config)
    
    /** get ccm config */
    #define AICFB_GET_CCM_CONFIG _IOR(IOC_TYPE_FB, 0x66, struct aicfb_ccm_config)
    
    /** update gamma config */
    #define AICFB_UPDATE_GAMMA_CONFIG _IOR(IOC_TYPE_FB, 0x67, struct aicfb_gamma_config)
    
    /** get gamma config */
    #define AICFB_GET_GAMMA_CONFIG _IOR(IOC_TYPE_FB, 0x68, struct aicfb_gamma_config)
    
    /* get screen info */
    #define AICFB_GET_SCREENINFO _IOR(IOC_TYPE_FB, 0x62, struct aicfb_screeninfo)
    
    /* enable aic fb, calls panel enable callback */
    #define AICFB_POWERON   _IOR(IOC_TYPE_FB, 0x63, unsigned int)
    
    /* disable aic fb, calls panel disable callback */
    #define AICFB_POWEROFF   _IOR(IOC_TYPE_FB, 0x64, unsigned int)