Edit online

数据结构设计

28 Nov 2024
Read time: 10 minute(s)

uapi/video/artinchip_video.h

  • struct aic_rect
    struct aic_rect {
        int x;
        int y;
        int width;
        int height;
    };
  • struct aic_point
    struct aic_point {
        int x;
        int y;
    };
  • struct aic_size
    struct aic_size {
        int width;
        int height;
    };
  • enum aic_pixel_format
    enum aic_pixel_format {
        AIC_FMT_ARGB_8888            = 0x00,
        AIC_FMT_ABGR_8888            = 0x01,
        AIC_FMT_RGBA_8888            = 0x02,
        AIC_FMT_BGRA_8888            = 0x03,
        AIC_FMT_XRGB_8888            = 0x04,
        AIC_FMT_XBGR_8888            = 0x05,
        AIC_FMT_RGBX_8888            = 0x06,
        AIC_FMT_BGRX_8888            = 0x07,
        AIC_FMT_RGB_888              = 0x08,
        AIC_FMT_BGR_888              = 0x09,
        AIC_FMT_ARGB_1555            = 0x0a,
        AIC_FMT_ABGR_1555            = 0x0b,
        AIC_FMT_RGBA_5551            = 0x0c,
        AIC_FMT_BGRA_5551            = 0x0d,
        AIC_FMT_RGB_565              = 0x0e,
        AIC_FMT_BGR_565              = 0x0f,
        AIC_FMT_ARGB_4444            = 0x10,
        AIC_FMT_ABGR_4444            = 0x11,
        AIC_FMT_RGBA_4444            = 0x12,
        AIC_FMT_BGRA_4444            = 0x13,
    
        AIC_FMT_YUV420P              = 0x20,
        AIC_FMT_NV12                 = 0x21,
        AIC_FMT_NV21                 = 0x22,
        AIC_FMT_YUV422P              = 0x23,
        AIC_FMT_NV16                 = 0x24,
        AIC_FMT_NV61                 = 0x25,
        AIC_FMT_YUYV                 = 0x26,
        AIC_FMT_YVYU                 = 0x27,
        AIC_FMT_UYVY                 = 0x28,
        AIC_FMT_VYUY                 = 0x29,
        AIC_FMT_YUV400               = 0x2a,
        AIC_FMT_YUV444P              = 0x2b,
    
        AIC_FMT_YUV420_64x32_TILE    = 0x30,
        AIC_FMT_YUV420_128x16_TILE   = 0x31,
        AIC_FMT_YUV422_64x32_TILE    = 0x32,
        AIC_FMT_YUV422_128x16_TILE   = 0x33,
        AIC_FMT_MAX,
    };

uapi/video/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_dmabuf_fd
    /**
     * Transfer dma-buf fd from userspace to the importers in kernel.
     *
     * @fd: the actual fd, requested by mmap() in userspace
     * @phy_addr: the physical address of the actual fd
     *
     */
    struct aicfb_dmabuf_fd {
        int fd;
        unsigned int phy_addr;
    };
  • ioctl 命令
    #define IOC_TYPE_FB       'F'
    
    #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, 0x26, struct aicfb_ck_config)
    
    /** update layer color key config */
    #define AICFB_UPDATE_CK_CONFIG  _IOW(IOC_TYPE_FB, 0x27, struct aicfb_ck_config)
    
    /** get screen size */
    #define AICFB_GET_SCREEN_SIZE  _IOR(IOC_TYPE_FB, 0x40, struct aic_size)
    
    /** get layer config data which the standard framebuffer is used
     * call this API to get which layer the standard framebuffer is used.
     */
    #define AICFB_GET_FB_LAYER_CONFIG  _IOR(IOC_TYPE_FB, 0x41, \
                        struct aicfb_layer_data)
    
    #define AICFB_GET_DMABUF _IOW(IOC_TYPE_FB, 0x50, struct aicfb_dmabuf_fd)
    #define AICFB_PUT_DMABUF _IOW(IOC_TYPE_FB, 0x51, struct aicfb_dmabuf_fd)
    
    /** export a dma_buf fd, associates /dev/fb0 */
    #define AICFB_TO_DMABUF_FD _IOW(IOC_TYPE_FB, 0x52, struct aicfb_dmabuf_fd)