hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * Copyright 2015 Rockchip Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#ifndef __MPP_RGA_H__
#define __MPP_RGA_H__
 
/* NOTE: RGA support sync mode and async mode. We use sync mode only.  */
#define RGA_BLIT_SYNC       0x5017
#define RGA_BLIT_ASYNC      0x5018
#define RGA_FLUSH           0x5019
#define RGA_GET_RESULT      0x501a
 
typedef enum RgaFormat_e {
    RGA_FMT_RGBA_8888       = 0x0,
    RGA_FMT_RGBX_8888       = 0x1,
    RGA_FMT_RGB_888         = 0x2,
    RGA_FMT_BGRA_8888       = 0x3,
    RGA_FMT_RGB_565         = 0x4,
    RGA_FMT_RGBA_5551       = 0x5,
    RGA_FMT_RGBA_4444       = 0x6,
    RGA_FMT_BGR_888         = 0x7,
 
    RGA_FMT_YCbCr_422_SP    = 0x8,
    RGA_FMT_YCbCr_422_P     = 0x9,
    RGA_FMT_YCbCr_420_SP    = 0xa,
    RGA_FMT_YCbCr_420_P     = 0xb,
 
    RGA_FMT_YCrCb_422_SP    = 0xc,
    RGA_FMT_YCrCb_422_P     = 0xd,
    RGA_FMT_YCrCb_420_SP    = 0xe,
    RGA_FMT_YCrCb_420_P     = 0xf,
 
    RGA_FMT_BPP1            = 0x10,
    RGA_FMT_BPP2            = 0x11,
    RGA_FMT_BPP4            = 0x12,
    RGA_FMT_BPP8            = 0x13,
    RGA_FMT_BUTT,
} RgaFormat;
 
typedef struct RgaImg_t {
    RK_ULONG    yrgb_addr;       /* yrgb    addr         */
    RK_ULONG    uv_addr;         /* cb/cr   addr         */
    RK_ULONG    v_addr;          /* cr      addr         */
    RK_U32      format;          // definition by RgaFormat
 
    RK_U16      act_w;           // width
    RK_U16      act_h;           // height
    RK_U16      x_offset;        // offset from left
    RK_U16      y_offset;        // offset from top
 
    RK_U16      vir_w;           // horizontal stride
    RK_U16      vir_h;           // vertical stride
 
    RK_U16      endian_mode;     // for BPP
    RK_U16      alpha_swap;
} RgaImg;
 
typedef struct RgaRect_t {
    RK_U16      xmin;
    RK_U16      xmax;
    RK_U16      ymin;
    RK_U16      ymax;
} RgaRect;
 
typedef struct RgaPoint_t {
    RK_U16      x;
    RK_U16      y;
} RgaPoint;
 
typedef struct RgaColorFill_t {
    RK_S16      gr_x_a;
    RK_S16      gr_y_a;
    RK_S16      gr_x_b;
    RK_S16      gr_y_b;
    RK_S16      gr_x_g;
    RK_S16      gr_y_g;
    RK_S16      gr_x_r;
    RK_S16      gr_y_r;
} RgaColorFill;
 
typedef struct RgaLineDraw_t {
    RgaPoint    start_point;
    RgaPoint    end_point;
    RK_U32      color;
    RK_U32      flag;
    RK_U32      line_width;
} RgaLineDraw;
 
typedef struct RgaFading_t {
    RK_U8       b;
    RK_U8       g;
    RK_U8       r;
    RK_U8       res;
} RgaFading;
 
typedef struct RgaMmu_t {
    RK_U8       mmu_en;
    RK_ULONG    base_addr;
    RK_U32      mmu_flag;
} RgaMmu;
 
// structure for userspace / kernel communication
typedef struct RgaRequest_t {
    RK_U8       render_mode;
 
    RgaImg      src;
    RgaImg      dst;
    RgaImg      pat;
 
    RK_ULONG    rop_mask_addr;      /* rop4 mask addr */
    RK_ULONG    LUT_addr;           /* LUT addr */
 
    RgaRect     clip;               /* dst clip window default value is dst_vir */
    /* value from [0, w-1] / [0, h-1]*/
 
    RK_S32      sina;               /* dst angle  default value 0  16.16 scan from table */
    RK_S32      cosa;               /* dst angle  default value 0  16.16 scan from table */
 
    /* alpha rop process flag           */
    /* ([0] = 1 alpha_rop_enable)       */
    /* ([1] = 1 rop enable)             */
    /* ([2] = 1 fading_enable)          */
    /* ([3] = 1 PD_enable)              */
    /* ([4] = 1 alpha cal_mode_sel)     */
    /* ([5] = 1 dither_enable)          */
    /* ([6] = 1 gradient fill mode sel) */
    /* ([7] = 1 AA_enable)              */
    RK_U16      alpha_rop_flag;
    RK_U8       scale_mode;         /* 0 nearst / 1 bilnear / 2 bicubic */
 
    RK_U32      color_key_max;      /* color key max */
    RK_U32      color_key_min;      /* color key min */
 
    RK_U32      fg_color;           /* foreground color */
    RK_U32      bg_color;           /* background color */
 
    RgaColorFill gr_color;          /* color fill use gradient */
 
    RgaLineDraw line_draw_info;
 
    RgaFading   fading;
 
    RK_U8       PD_mode;            /* porter duff alpha mode sel */
    RK_U8       alpha_global_value; /* global alpha value */
    RK_U16      rop_code;           /* rop2/3/4 code  scan from rop code table*/
    RK_U8       bsfilter_flag;      /* [2] 0 blur 1 sharp / [1:0] filter_type*/
    RK_U8       palette_mode;       /* (enum) color palatte  0/1bpp, 1/2bpp 2/4bpp 3/8bpp */
    RK_U8       yuv2rgb_mode;       /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709  */
    RK_U8       endian_mode;
 
    /* (enum) rotate mode  */
    /* 0x0,     no rotate  */
    /* 0x1,     rotate     */
    /* 0x2,     x_mirror   */
    /* 0x3,     y_mirror   */
    RK_U8       rotate_mode;
 
    RK_U8       color_fill_mode;    /* 0 solid color / 1 patten color */
 
    RgaMmu      mmu_info;           /* mmu information */
 
    /* ([0~1] alpha mode)       */
    /* ([2~3] rop   mode)       */
    /* ([4]   zero  mode en)    */
    /* ([5]   dst   alpha mode) */
    RK_U8       alpha_rop_mode;
    RK_U8       src_trans_mode;
    RK_U8       CMD_fin_int_enable;
 
    /* completion is reported through a callback */
    void (*complete)(int retval);
} RgaReq;
 
#endif // __MPP_RGA_H__