xref: /OK3568_Linux_fs/external/linux-rga/docs/Rockchip_FAQ_RGA_EN.md (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# RGA FAQ
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunFile No.:RK-PC-YF-404
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunRelease Version: V1.1.2
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunRelease Date: 2023-06-28
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunSecurity Level: □Top-Secret   □Secret   □Internal   ■Public
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun**DISCLAIMER**
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunTHIS DOCUMENT IS PROVIDED “AS IS”. ROCKCHIP ELECTRONICS CO., LTD.(“ROCKCHIP”)DOES NOT PROVIDE ANY WARRANTY OF ANY KIND, EXPRESSED, IMPLIED OR OTHERWISE, WITH RESPECT TO THE ACCURACY, RELIABILITY, COMPLETENESS,MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY REPRESENTATION, INFORMATION AND CONTENT IN THIS DOCUMENT. THIS DOCUMENT IS FOR REFERENCE ONLY. THIS DOCUMENT MAY BE UPDATED OR CHANGED WITHOUT ANY NOTICE AT ANY TIME DUE TO THE UPGRADES OF THE PRODUCT OR ANY OTHER REASONS.
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun**Trademark Statement**
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun"Rockchip", "瑞芯微", "瑞芯" shall be Rockchip’s registered trademarks and owned by Rockchip. All the other trademarks or registered trademarks mentioned in this document shall be owned by their respective owners.
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun**All rights reserved. ©2022. Rockchip Electronics Co., Ltd.**
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunBeyond the scope of fair use, neither any entity nor individual shall extract, copy, or distribute this document in any form in whole or in part without the written approval of Rockchip.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunRockchip Electronics Co., Ltd.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunNo.18 Building, A District, No.89, software Boulevard Fuzhou, Fujian,PRC
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunWebsite:     [www.rock-chips.com](http://www.rock-chips.com)
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunCustomer service Tel:  +86-4007-700-590
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunCustomer service Fax:  +86-591-83951833
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunCustomer service e-Mail:  [fae@rock-chips.com](mailto:fae@rock-chips.com)
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun---
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun**Intended Audience**
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunThis document (this guide) is mainly intended for:
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun- Technical support engineers
42*4882a593Smuzhiyun- Software development engineers
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun**Revision History**
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun| **Date**   | **Version** | **Author** | **Description** |
47*4882a593Smuzhiyun| ---------- | -------- | -------- | ------------ |
48*4882a593Smuzhiyun| 2021/06/28 | 1.0.0    | Yu Qiaowei | Initial version.     |
49*4882a593Smuzhiyun| 2022/12/21 | 1.1.0 | Yu Qiaowei | Add multi_rga driver related cases. |
50*4882a593Smuzhiyun| 2023/02/09 | 1.1.1 | Yu Qiaowei | Format document. |
51*4882a593Smuzhiyun| 2023/06/28 | 1.1.2 | Yu Qiaowei | Supplementary Q&A |
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun---
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun**Contents**
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun[TOC]
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun---
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun## Overview
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunFor RGA driver and user-mode API librga, this document summarizes some common problems occurred when RGA hardware is called on RK platform to realize graph drawing acceleration with OSD (On Screen Display) and GUI (Graphics User Interface).
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun---
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun## Version Description
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun### Hardware Version
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunRGA hardware consists of three versions: RGA1, RGA2, and RGA3. See section Introducions in [Rockchip_Developer_Guide_RGA_EN](./Rockchip_Developer_Guide_RGA_EN.md) for detailed platform information, supported functions, and restrictions.
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun### Software Version
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunThe following only provides common version query methods. For details, please refer to [Rockchip_Developer_Guide_RGA_EN](./Rockchip_Developer_Guide_RGA_EN.md) —— Release Notes chapter.
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun#### librga
82*4882a593Smuzhiyun
83*4882a593SmuzhiyunThe API version number consists of major, minor, revision and build. The four levels of version number correspond to different levels of function update.
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun- version query
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun  The more common query methods are as follows:
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun  ```
90*4882a593Smuzhiyun  strings librga.so |grep rga_api |grep version
91*4882a593Smuzhiyun  ```
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun- update version
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun  When it is found that the version does not meet the requirements, you can obtain the source code or precompiled library files in the following ways.
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun  - github:
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun    https://github.com/airockchip/librga
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun  - Baidu Cloud:
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun
104*4882a593Smuzhiyunhttps://eyun.baidu.com/s/3jJ9Aiz0
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun- RGA Driver
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunThe driver version number consists of major, minor, revision and build. The four levels of version number correspond to different levels of function update. Usually HAL library and driver is matching in released SDK, version verification is done within librga, developers do not need to consider about version. If the following error occurs when librga is updated separately, you need to update the driver to the corresponding version.
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun- version query
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun  Different chip platforms have different opening paths for debug nodes. Usually, there are two paths as follows.
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun  ```
118*4882a593Smuzhiyun  cat /sys/kernel/debug/rkrga/driver_version
119*4882a593Smuzhiyun  cat /proc/rkrga/driver_version
120*4882a593Smuzhiyun  ```
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun- update version
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun  When it is found that the version does not meet the requirements, you can obtain the source code or precompiled library files in the following ways.
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun  - Baidu Cloud:
127*4882a593Smuzhiyun
128*4882a593Smuzhiyunhttps://eyun.baidu.com/s/3dGhufEL
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun#### Version Correspondence
133*4882a593Smuzhiyun
134*4882a593SmuzhiyunWhen using RGA, you need to confirm that the current operating environment can work normally. The following table shows the correspondence between commonly used librga and driver versions.
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun| librga版本    | 对应驱动                                                     | 硬件支持         |
137*4882a593Smuzhiyun| ------------- | ------------------------------------------------------------ | ---------------- |
138*4882a593Smuzhiyun| no version    | Driver in SDK                                                | RGA1、RGA2       |
139*4882a593Smuzhiyun| 1.0.0 ~ 1.3.2 | RGA Device Driver(kernel - 4.4 and above)<br/>RGA2 Device Driver(no version or v2.1.0) | RGA1、RGA2       |
140*4882a593Smuzhiyun| > 1.4.0       | RGA multicore Device Driver(v1.2.0 and above)              | RGA2、RGA3       |
141*4882a593Smuzhiyun| > 1.9.0       | RGA Device Driver(kernel-4.4 and above)<br/>RGA2 Device Driver(no version or v2.1.0)<br/>RGA multicore Device Driver(v1.2.0 and above) | RGA1、RGA2、RGA3 |
142*4882a593Smuzhiyun
143*4882a593SmuzhiyunUsually the released SDK version matches, but because some applications depend on the higher version librga.so, you can use the following Baidu Cloud link to obtain the RGA module code update package:
144*4882a593Smuzhiyun
145*4882a593Smuzhiyunhttps://eyun.baidu.com/s/3i6sbsDR
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun- update-to-MULTI_RGA
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun​		When the original driver is RGA Device Driver or RGA2 Device Driver, use this update package to update the driver to RGA multicore Device Driver and update the matching version of librga.
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun- MUTIL_RGA
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun  When the original driver is RGA multicore Device Driver, use this update package to update the driver version and update the matching version of librga.
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun- RGA2
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun  When the original driver is RGA2 Device Driver, use this update package to update the driver version and update the matching version of librga.
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun- RGA1
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun  When the original driver is RGA Device Driver, use this update package to update the driver version and update the matching version of librga.
162*4882a593Smuzhiyun
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun---
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun## Debugging instructions
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun### HAL Logs
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun#### Log Switch
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun- Android
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun  Android supports using Android Property to configure whether librga enables HAL log printing:
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun  - enable log print:
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun  ```
180*4882a593Smuzhiyun  setprop vendor.rga.log 1
181*4882a593Smuzhiyun  logcat -s librga
182*4882a593Smuzhiyun  ```
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun  - set log level:
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun    The log level is divided into full print (0), DEFAULT (1), DEBUG (3), INFO (4), WRANING (5), ERROR (6).
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun  ```
189*4882a593Smuzhiyun  setprop vendor.rga.log_level 6
190*4882a593Smuzhiyun  ```
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun
194*4882a593Smuzhiyun- Linux
195*4882a593Smuzhiyun
196*4882a593Smuzhiyun  The Linux supports enabling/disabling HAL log printing by setting environment variables (librga 1.9.0 and above):
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun  - enable log print:
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun  ```
201*4882a593Smuzhiyun  export ROCKCHIP_RGA_LOG=1
202*4882a593Smuzhiyun  ```
203*4882a593Smuzhiyun
204*4882a593Smuzhiyun  - set log level:
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun    The log level is divided into full print (0), DEFAULT (1), DEBUG (3), INFO (4), WRANING (5), ERROR (6).
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun  ```
209*4882a593Smuzhiyun  export ROCKCHIP_RGA_LOG_LEVEL=6
210*4882a593Smuzhiyun  ```
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun#### Log Description
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun- Init Log
217*4882a593Smuzhiyun
218*4882a593SmuzhiyunWhen each process calls librga for the first time, it initializes a singleton of librga and prints information such as the current API version number.
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun```C++
221*4882a593SmuzhiyunE rockchiprga: rga_api version 1.9.0_[0]
222*4882a593Smuzhiyun```
223*4882a593Smuzhiyun
224*4882a593SmuzhiyunWhen the driver version does not match the librga version, it will print the corresponding error log.
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun> When the driver version is lower, the compatibility mode will be started, and the following log will be printed when the singleton is initialized. At this time, you can consider updating the driver to the version indicated by the log, or you can continue to run in compatibility mode.
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun```shell
229*4882a593Smuzhiyunlibrga fail to get driver version! Compatibility mode will be enabled.
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun29 im2d_rga_impl rga_version_below_minimun_range_user_driver(310): The driver may be compatible, but it is best to update the driver to version 1.2.4. You can try to update the SDK or update the <SDK>/kernel/drivers/video/rockchip/rga3 directory individually. current version: librga 1.8.5, driver .
232*4882a593Smuzhiyun```
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun> When the librga version is low, some errors related to Invalid parameters will be returned through imStrError(), which indicates that the current librga version is too low and the librga version needs to be updated.
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun```
237*4882a593SmuzhiyunInvalid parameters: invaild GraphicBuffer, can not get fd and virtual address,
238*4882a593Smuzhiyun```
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun- running log
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun```C++
245*4882a593SmuzhiyunD librga  : <<<<-------- print rgaLog -------->>>>								//The parameters passed to librga are printed as follows.
246*4882a593SmuzhiyunD librga  : src->hnd = 0x0 , dst->hnd = 0x0 , src1->hnd = 0x0					//The handle passed in by the three channels (src、src1、dst).
247*4882a593SmuzhiyunD librga  : src: Fd = 00 , phyAddr = 0x0 , virAddr = 0xb400007431ed6040			//Parameters passed in src channel, representing DMA_FD, physical address and virtual address respectively.
248*4882a593SmuzhiyunD librga  : dst: Fd = 00 , phyAddr = 0x0 , virAddr = 0xb400007431b4f040			//Parameters passed in dst channel, representing DMA_FD, physical address, and virtual address respectively.
249*4882a593SmuzhiyunD librga  : src: Fd = -01 , buf = 0xb400007431ed6040, mmuFlag = 1, mmuType = 0	//The src channel configures the value for the type of memory passed and whether or not MMU is enabled, where the HAL selects the virtual address to pass into the driver.
250*4882a593SmuzhiyunD librga  : dst: Fd = -01 , buf = 0xb400007431b4f040, mmuFlag = 1, mmuType = 0	//The dst channel configures the value for the type of memory passed and whether or not MMU is enabled, where HAL selects the virtual address to pass in the driver.
251*4882a593SmuzhiyunE librga  : blend = 0 , perpixelAlpha = 1										//Blending mode and whether the image format includes an Alpha value.
252*4882a593SmuzhiyunD librga  : scaleMode = 0 , stretch = 0;										//scale mode (RGA1).
253*4882a593SmuzhiyunE librga  : rgaVersion = 3.200000  , ditherEn =0								//Hardware version, Y4 Dither enabled.
254*4882a593SmuzhiyunD librga  : srcMmuFlag = 1 , dstMmuFlag = 1 , rotateMode = 0					//MMU enable flag, rotation mode.
255*4882a593SmuzhiyunD librga  : <<<<-------- rgaReg -------->>>>									//Parameters configuration of the driver are printed as follows.
256*4882a593SmuzhiyunE librga  : render_mode=0 rotate_mode=0											//RGA rendering mode, rotation mode.
257*4882a593SmuzhiyunE librga  : src:[0,b400007431ed6040,b400007431fb7040],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0	//Memory, image parameters, format information of src channel.
258*4882a593SmuzhiyunE librga  : dst:[0,b400007431b4f040,b400007431c30040],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0	//Memory, image parameters, format information of dst channel.
259*4882a593SmuzhiyunE librga  : pat:[0,0,0],x-y[0,0],w-h[0,0],vw-vh[0,0],f=0						//Memory, image parameters, format information of pat/src1 channel. This channel is not used in current mode, therefore the parameters are set to 0.
260*4882a593Smuzhiyun//The following are some of the parameters that developers usually don't have to care about, which is to configure for librga different modes of the driver.
261*4882a593SmuzhiyunE librga  : ROP:[0,0,0],LUT[0]													//ROP and LUT configuration.
262*4882a593SmuzhiyunE librga  : color:[0,0,0,0,0]													//Colorkey configuration(max color, min color), color-filling configuration (foreground color, background color, color-filling).
263*4882a593SmuzhiyunE librga  : MMU:[1,0,80000521]													//MMU configuration.
264*4882a593SmuzhiyunE librga  : mode[0,0,0,0]														//Palette、csc、colorkey configuration.
265*4882a593SmuzhiyunE librga  : Full CSC : en[0]													//Full csc enabled flag.
266*4882a593SmuzhiyunE librga  : gr_color_x [0, 0, 0]												// Color-filling configuration, corresponding the value of R, G, B.
267*4882a593Smuzhiyun```
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun
270*4882a593Smuzhiyun
271*4882a593Smuzhiyun### Driver Debug Node
272*4882a593Smuzhiyun
273*4882a593Smuzhiyun#### Log Switch
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun- Debugging Node Address
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunThe configurations of different SDK kernels are different. Generally, the debugging node of RGA exists in one or both of the following two directories:
278*4882a593Smuzhiyun
279*4882a593Smuzhiyun- Use a kernel with the CONFIG_ROCKCHIP_RGA_DEBUG_FS compile option enabled by default.
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun```
282*4882a593Smuzhiyun/sys/kernel/debug
283*4882a593Smuzhiyun```
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun- Use a kernel with the ROCKCHIP_RGA_PROC_FS compile option enabled.
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun```
288*4882a593Smuzhiyun/proc
289*4882a593Smuzhiyun```
290*4882a593Smuzhiyun
291*4882a593SmuzhiyunIn addition to enabling by default, you can also modify the kernel compilation options according to your own project requirements to implement a custom RGA debug node path.
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun#### Debug node name
296*4882a593Smuzhiyun
297*4882a593SmuzhiyunThe name of the debug node on different drivers is different, and it will be unified as rkrga in subsequent updated drivers, and the name of rgax_debug has been deprecated.
298*4882a593Smuzhiyun
299*4882a593Smuzhiyun| driver name                      | node path  |
300*4882a593Smuzhiyun| -------------------------------- | ---------- |
301*4882a593Smuzhiyun| RGA Device Driver                | rga_debug  |
302*4882a593Smuzhiyun| RGA2 Device Driver(no version) | rga2_debug |
303*4882a593Smuzhiyun| RGA2 Device Driver(v2.1.0)     | rkrga      |
304*4882a593Smuzhiyun| RGA multicore Device Driver      | rkrga      |
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun#### Debug node function
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun##### Overview
311*4882a593Smuzhiyun
312*4882a593Smuzhiyun- rga_debug/rga2_debug
313*4882a593Smuzhiyun
314*4882a593SmuzhiyunThe rga_debug/rga2_debug nodes only support the running log enable/disable.
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun- rkrga
317*4882a593Smuzhiyun
318*4882a593SmuzhiyunThis version of the debugging node supports functions such as enabling/disabling the running log, load query, version query, hardware information query, and memory/task manager status query.
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun##### Running Log
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun###### Log Switch
325*4882a593Smuzhiyun
326*4882a593Smuzhiyun- Debug node name
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun| driver name                     | node path       |
329*4882a593Smuzhiyun| ------------------------------- | --------------- |
330*4882a593Smuzhiyun| RGA Device Driver               | rga_debug/rga   |
331*4882a593Smuzhiyun| RGA2 Device Driver(no vesion) | rga2_debug/rga2 |
332*4882a593Smuzhiyun| RGA2 Device Driver(v2.1.0)    | rkrga/debug     |
333*4882a593Smuzhiyun| RGA multicore Device Driver     | rkrga/debug     |
334*4882a593Smuzhiyun
335*4882a593Smuzhiyun- Debugging Description
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunThe switching methods of debugging logs of different driver versions are the same, and they all operate on rga/rga2/debug nodes.
338*4882a593Smuzhiyun
339*4882a593SmuzhiyunTaking RGA multicore Device Driver as an example, you can get the corresponding function description through the cat node in the corresponding directory:
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun```shell
342*4882a593Smuzhiyun/# cd /sys/kerne/debug/rkrga/
343*4882a593Smuzhiyun/# cat debug
344*4882a593SmuzhiyunREG [DIS]
345*4882a593SmuzhiyunMSG [DIS]
346*4882a593SmuzhiyunTIME [DIS]
347*4882a593SmuzhiyunINT [DIS]
348*4882a593SmuzhiyunCHECK [DIS]
349*4882a593SmuzhiyunSTOP [DIS]
350*4882a593Smuzhiyun
351*4882a593Smuzhiyunhelp:
352*4882a593Smuzhiyun 'echo reg > debug' to enable/disable register log printing.
353*4882a593Smuzhiyun 'echo msg > debug' to enable/disable message log printing.
354*4882a593Smuzhiyun 'echo time > debug' to enable/disable time log printing.
355*4882a593Smuzhiyun 'echo int > debug' to enable/disable interruppt log printing.
356*4882a593Smuzhiyun 'echo check > debug' to enable/disable check mode.
357*4882a593Smuzhiyun 'echo stop > debug' to enable/disable stop using hardware
358*4882a593Smuzhiyun```
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun> echo reg > debug:This command switches the printing of RGA register configuration information. When it is opened, the configuration of RGA register is printed.
361*4882a593Smuzhiyun>
362*4882a593Smuzhiyun> echo msg> debug:This command switches the printing of RGA register upper-layer configuration information. When it is opened, The parameters passed by the upper-level call to the RGA driver will be printed out.
363*4882a593Smuzhiyun>
364*4882a593Smuzhiyun> echo time> debug:This command switches the printing of RGA time information. When it is opened, the time taken for each rga call is printed.
365*4882a593Smuzhiyun>
366*4882a593Smuzhiyun> echo check> debug:This command switches the RGA internal test case. When it is opened, corresponding parameters are checked when RGA is working, mainly memory and alignment checks. If the following log is printed, the check is successful. If the memory exceeds the threshold, the kernel crashes. You can check whether there is a problem with src data or dst data through the print log before cash.
367*4882a593Smuzhiyun>
368*4882a593Smuzhiyun> echo stop> debug:This command switches the RGA working status. When it is opened, rga directly returns without working. A mode used in some special cases.
369*4882a593Smuzhiyun>
370*4882a593Smuzhiyun> echo int> debug:This command switches the printing of RGA register interrupt information. When it is opened, the current value of the interrupt register and state base will be printed after the RGA enters the interrupt.
371*4882a593Smuzhiyun>
372*4882a593Smuzhiyun> echo slt> debug:This command causes rga driver to perform an internal SLT case to test whether the RGA hardware is working well. If log “rga slt success !” is printed, it indicates that the function is working well.
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun- Switch Debugging Node
375*4882a593Smuzhiyun
376*4882a593SmuzhiyunThe opening and closing commands of log printing are the same. Each time you enter a command to switch the state (on/off), you can confirm the log through the cat debug node or the log information printed after entering the command ("open xxx" or "close xxx") Whether printing is turned on or off as expected.
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun> Take RGA multicore Device Driver as an example, open the running log 'msg':
379*4882a593Smuzhiyun
380*4882a593Smuzhiyun```shell
381*4882a593Smuzhiyun/# cd /sys/kernel/debug/rkrga/
382*4882a593Smuzhiyun/# cat debug
383*4882a593SmuzhiyunREG [DIS]
384*4882a593SmuzhiyunMSG [DIS]
385*4882a593SmuzhiyunTIME [DIS]
386*4882a593SmuzhiyunINT [DIS]
387*4882a593SmuzhiyunCHECK [DIS]
388*4882a593SmuzhiyunSTOP [DIS]
389*4882a593Smuzhiyun
390*4882a593Smuzhiyunhelp:
391*4882a593Smuzhiyun 'echo reg > debug' to enable/disable register log printing.
392*4882a593Smuzhiyun 'echo msg > debug' to enable/disable message log printing.
393*4882a593Smuzhiyun 'echo time > debug' to enable/disable time log printing.
394*4882a593Smuzhiyun 'echo int > debug' to enable/disable interruppt log printing.
395*4882a593Smuzhiyun 'echo check > debug' to enable/disable check mode.
396*4882a593Smuzhiyun 'echo stop > debug' to enable/disable stop using hardware
397*4882a593Smuzhiyun/# echo msg > debug
398*4882a593Smuzhiyun/# cat debug
399*4882a593SmuzhiyunREG [DIS]
400*4882a593SmuzhiyunMSG [EN]
401*4882a593SmuzhiyunTIME [DIS]
402*4882a593SmuzhiyunINT [DIS]
403*4882a593SmuzhiyunCHECK [DIS]
404*4882a593SmuzhiyunSTOP [DIS]
405*4882a593Smuzhiyun
406*4882a593Smuzhiyunhelp:
407*4882a593Smuzhiyun 'echo reg > debug' to enable/disable register log printing.
408*4882a593Smuzhiyun 'echo msg > debug' to enable/disable message log printing.
409*4882a593Smuzhiyun 'echo time > debug' to enable/disable time log printing.
410*4882a593Smuzhiyun 'echo int > debug' to enable/disable interruppt log printing.
411*4882a593Smuzhiyun 'echo check > debug' to enable/disable check mode.
412*4882a593Smuzhiyun 'echo stop > debug' to enable/disable stop using hardware
413*4882a593Smuzhiyun/# echo msg > debug
414*4882a593Smuzhiyun/# cat debug
415*4882a593SmuzhiyunREG [DIS]
416*4882a593SmuzhiyunMSG [DIS]
417*4882a593SmuzhiyunTIME [DIS]
418*4882a593SmuzhiyunINT [DIS]
419*4882a593SmuzhiyunCHECK [DIS]
420*4882a593SmuzhiyunSTOP [DIS]
421*4882a593Smuzhiyun
422*4882a593Smuzhiyunhelp:
423*4882a593Smuzhiyun 'echo reg > debug' to enable/disable register log printing.
424*4882a593Smuzhiyun 'echo msg > debug' to enable/disable message log printing.
425*4882a593Smuzhiyun 'echo time > debug' to enable/disable time log printing.
426*4882a593Smuzhiyun 'echo int > debug' to enable/disable interruppt log printing.
427*4882a593Smuzhiyun 'echo check > debug' to enable/disable check mode.
428*4882a593Smuzhiyun 'echo stop > debug' to enable/disable stop using hardware
429*4882a593Smuzhiyun```
430*4882a593Smuzhiyun
431*4882a593Smuzhiyun> log printing:
432*4882a593Smuzhiyun
433*4882a593Smuzhiyun```shell
434*4882a593Smuzhiyun/# echo reg > /sys/kerne/debug/rkrga/debug
435*4882a593Smuzhiyun/# dmesg -c						//For logs opened through nodes, the printing level is KERNEL_DEBUG. You need to run the dmesg command to view the corresponding logs on the serial port or adb.
436*4882a593Smuzhiyun[ 4802.344683] rga2: open rga2 reg!
437*4882a593Smuzhiyun/# echo reg > /sys/kernel/debug/rga2_debug/rga2
438*4882a593Smuzhiyun/# dmesg -c
439*4882a593Smuzhiyun[ 5096.412419] rga2: close rga2 reg!
440*4882a593Smuzhiyun```
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun###### Log Description
445*4882a593Smuzhiyun
446*4882a593SmuzhiyunFor RGA problem debugging, logs are needed to confirm work of RGA hardware. When HAL parameters are passed into the driver, the following logs describe the corresponding parameters. We usually use msg, reg or time mode for debugging.
447*4882a593Smuzhiyun
448*4882a593Smuzhiyun- msg mode
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun  - RGA Device Driver、RGA2 Device Driver
451*4882a593Smuzhiyun
452*4882a593Smuzhiyun  ```
453*4882a593Smuzhiyun  rga2: open rga2 test MSG!								//Open 'msg' log printing.
454*4882a593Smuzhiyun  rga2: cmd is RGA2_GET_VERSION							//Get version number, which queries hardware version the first time each process calls librga.
455*4882a593Smuzhiyun  rga2: cmd is RGA_BLIT_SYNC								//Current working mode.
456*4882a593Smuzhiyun  rga2: render_mode:bitblt,bitblit_mode=0,rotate_mode:0	//Render_mode: display calling interface, bitblit_mode: current blending mode(0:two-channel mode A+B->B, 1: three-channel mode A+B->C, rotate_mode: rotation angle.
457*4882a593Smuzhiyun  rga2: src : y=0 uv=b4000072cc8bc040 v=b4000072cc99d040 aw=1280 ah=720 vw=1280 vh=720 xoff=0 yoff=0 format=RGBA8888
458*4882a593Smuzhiyun  														//Parameters of src channel of image data y:fd, uv:virtual address, v:vw * vh + uv, aw and ah:actual width and height, the actual area of image. operation, vw、vh:virtual width and height, the size of image itself, xoff、yoff: offset in the x and y directions, format:image format.
459*4882a593Smuzhiyun  rga2: dst : y=0 uv=b4000072cc535040 v=b4000072cc616040 aw=1280 ah=720 vw=1280 vh=720 xoff=0 yoff=0 format=RGBA8888
460*4882a593Smuzhiyun  														//Parameters of dst channel of image data.
461*4882a593Smuzhiyun  rga2: mmu : src=01 src1=00 dst=01 els=00				//MMU enabled flag,0 for close,1 for open.
462*4882a593Smuzhiyun  rga2: alpha : flag 0 mode0=0 mode1=0					//Configuration of blending.
463*4882a593Smuzhiyun  rga2: blend mode is no blend							//Blend mode.
464*4882a593Smuzhiyun  rga2: yuv2rgb mode is 0									//Csc mode.
465*4882a593Smuzhiyun  rga2: *** rga2_blit_sync proc ***
466*4882a593Smuzhiyun  ```
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun  - RGA multicore Device Driver
469*4882a593Smuzhiyun
470*4882a593Smuzhiyun    - Memory Manager Log
471*4882a593Smuzhiyun
472*4882a593Smuzhiyun    ```
473*4882a593Smuzhiyun    rga: import buffer info:
474*4882a593Smuzhiyun    rga_common: external: memory = 0xb400007458406000, type = virt_addr
475*4882a593Smuzhiyun    													//memory:memory value,type:memory type
476*4882a593Smuzhiyun    rga_common: memory param: w = 1280, h = 720, f = RGBA8888(0x0), size = 0
477*4882a593Smuzhiyun    													//w/h/f:Describe the memory size in the form of image canvas, size: memory size
478*4882a593Smuzhiyun    rga_dma_buf: iova_align size = 3686400
479*4882a593Smuzhiyun    ```
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun    - Job Request Log
482*4882a593Smuzhiyun
483*4882a593Smuzhiyun    ```
484*4882a593Smuzhiyun    rga: Blit mode: request id = 192732					//running mode and request id
485*4882a593Smuzhiyun    rga_debugger: render_mode = 0, bitblit_mode=0, rotate_mode = 0
486*4882a593Smuzhiyun        												//render_modedisplay calling interface,bitblit_mode: current blending mode(0:two-channel mode A+B->B, 1: three-channel mode A+B->C, rotate_mode: rotation angle.
487*4882a593Smuzhiyun    rga_debugger: src: y = 19 uv = 0 v = e1000 aw = 1280 ah = 720 vw = 1280 vh = 720
488*4882a593Smuzhiyun        												//Parameters of src channel of image data y:fd, uv:virtual address, v:vw * vh + uv, aw and ah:actual width and height, the actual area of image. operation, vw、vh:virtual width and height, the size of image itself.
489*4882a593Smuzhiyun    rga_debugger: src: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1
490*4882a593Smuzhiyun        												//, xoff、yoff: offset in the x and y directions, format:image format, rd_mode:Current channel read/write data mode(1:raster,2:FBC,3:tile 16*16).
491*4882a593Smuzhiyun    rga_debugger: dst: y=1a uv=0 v=e1000 aw=1280 ah=720 vw=1280 vh=720
492*4882a593Smuzhiyun        												//Parameters of dst channel of image data.
493*4882a593Smuzhiyun    rga_debugger: dst: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1
494*4882a593Smuzhiyun    rga_debugger: mmu: mmu_flag=0 en=0					//MMU enabled flag,0 for close,1 for open.This configuration is disabled when called with rga_buffer_handle_t, and the driver chooses the optimal configuration.
495*4882a593Smuzhiyun    rga_debugger: alpha: rop_mode = 0					//alpha/ROP mode enable/disable.
496*4882a593Smuzhiyun    rga_debugger: yuv2rgb mode is 0						//CSC mode config
497*4882a593Smuzhiyun    rga_debugger: set core = 0, priority = 0, in_fence_fd = -1
498*4882a593Smuzhiyun        												//set_core:user mode specified core,priority:user mode specified priority,in_fence_fd:acquire_fence fd passed by user mode.
499*4882a593Smuzhiyun    ```
500*4882a593Smuzhiyun
501*4882a593Smuzhiyun    - Hardware Matching Log
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun    ```
504*4882a593Smuzhiyun    rga_policy: start policy on core = 1
505*4882a593Smuzhiyun    rga_policy: start policy on core = 2
506*4882a593Smuzhiyun    rga_policy: start policy on core = 4				//Iterate over all core support cases.
507*4882a593Smuzhiyun    rga_policy: RGA2 only support under 4G memory!		//Corresponding to the log of the reason why the core does not support.
508*4882a593Smuzhiyun    rga_policy: optional_cores = 3						//The current request can match the hardware core collection.
509*4882a593Smuzhiyun    rga_policy: assign core: 1							//The hardware core identifier bound after matching.
510*4882a593Smuzhiyun    ```
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun    - Hardware Configuration Log
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun    ```
515*4882a593Smuzhiyun    rga3_reg: render_mode:bitblt, bitblit_mode=0, rotate_mode:0
516*4882a593Smuzhiyun    rga3_reg: win0: y = ffc70000 uv = ffd51000 v = ffd89400 src_w = 1280 src_h = 720
517*4882a593Smuzhiyun    rga3_reg: win0: vw = 1280 vh = 720 xoff = 0 yoff = 0 format = RGBA8888
518*4882a593Smuzhiyun    rga3_reg: win0: dst_w = 1280, dst_h = 720, rd_mode = 0
519*4882a593Smuzhiyun    rga3_reg: win0: rot_mode = 1, en = 1, compact = 1, endian = 0
520*4882a593Smuzhiyun    rga3_reg: wr: y = ff8e0000 uv = ff9c1000 v = ff9f9400 vw = 1280 vh = 720
521*4882a593Smuzhiyun    rga3_reg: wr: ovlp_xoff = 0 ovlp_yoff = 0 format = RGBA8888 rdmode = 0
522*4882a593Smuzhiyun    rga3_reg: mmu: win0 = 00 win1 = 00 wr = 00
523*4882a593Smuzhiyun    rga3_reg: alpha: flag 0 mode0=0 mode1=a0a
524*4882a593Smuzhiyun    rga3_reg: blend mode is no blend
525*4882a593Smuzhiyun    rga3_reg: yuv2rgb mode is 0
526*4882a593Smuzhiyun    ```
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun- ‘reg’ mode
529*4882a593Smuzhiyun
530*4882a593Smuzhiyun```c++
531*4882a593Smuzhiyunrga2: open rga2 reg!									//Open 'reg' log printing.
532*4882a593Smuzhiyunrga2: CMD_REG											//Configuration of command register.
533*4882a593Smuzhiyunrga2: 00000000 00000000 00000040 000e1040
534*4882a593Smuzhiyunrga2: 00119440 00000000 00000500 02cf04ff
535*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
536*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000040
537*4882a593Smuzhiyunrga2: 000e1040 00119440 00000500 02cf04ff
538*4882a593Smuzhiyunrga2: 00000000 00000000 0000ff00 ffffffff
539*4882a593Smuzhiyunrga2: 00000007 00000000 00000000 00000101
540*4882a593Smuzhiyunrga2: 07a80000 00000000 07a800e4 00000000
541*4882a593Smuzhiyunrga2: CSC_REG											//Configuration of full csc register.
542*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
543*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
544*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
545*4882a593Smuzhiyunrga2: CMD_READ_BACK_REG									//Read back of full command register.
546*4882a593Smuzhiyunrga2: 00000000 00000000 00000040 000e1040
547*4882a593Smuzhiyunrga2: 00119440 00000000 00000500 02cf04ff
548*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
549*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000040
550*4882a593Smuzhiyunrga2: 000e1040 00119440 00000500 02cf04ff
551*4882a593Smuzhiyunrga2: 00000000 00000000 0000ff00 ffffffff
552*4882a593Smuzhiyunrga2: 00000007 00000000 00000000 00000101
553*4882a593Smuzhiyunrga2: 07a80000 00000000 07a800e4 00000000
554*4882a593Smuzhiyunrga2: CSC_READ_BACK_REG									//Read back of full csc register.
555*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
556*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
557*4882a593Smuzhiyunrga2: 00000000 00000000 00000000 00000000
558*4882a593Smuzhiyun```
559*4882a593Smuzhiyun
560*4882a593Smuzhiyun- ‘time’ mode
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun  - rga2
563*4882a593Smuzhiyun
564*4882a593Smuzhiyun  ```
565*4882a593Smuzhiyun  rga2: sync one cmd end time 2414					//Print the RGA. hardware time of the work,in us.
566*4882a593Smuzhiyun  ```
567*4882a593Smuzhiyun
568*4882a593Smuzhiyun  - multi
569*4882a593Smuzhiyun
570*4882a593Smuzhiyun  ```
571*4882a593Smuzhiyun  rga3_reg: set cmd use time = 196					//Time elapsed from start processing request to configuration register.
572*4882a593Smuzhiyun  rga_job: hw use time = 554							//Time-consuming from hardware startup to hardware interrupt return.
573*4882a593Smuzhiyun  rga_job: (pid:3197) job done use time = 751			//Time-consuming from the start of processing the request to the completion of the request.
574*4882a593Smuzhiyun  rga_job: (pid:3197) job clean use time = 933		//Time-consuming from the start of processing the request to the completion of the request resource processing.
575*4882a593Smuzhiyun  ```
576*4882a593Smuzhiyun
577*4882a593Smuzhiyun
578*4882a593Smuzhiyun
579*4882a593Smuzhiyun##### Version Information Query
580*4882a593Smuzhiyun
581*4882a593SmuzhiyunUse the following commands to query the current driver name and driver version:
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun```
584*4882a593Smuzhiyun/# cat driver_version
585*4882a593SmuzhiyunRGA multicore Device Driver: v1.2.23
586*4882a593Smuzhiyun```
587*4882a593Smuzhiyun
588*4882a593Smuzhiyun
589*4882a593Smuzhiyun
590*4882a593Smuzhiyun##### Load Query
591*4882a593Smuzhiyun
592*4882a593SmuzhiyunUse the following command to query the RGA load status:
593*4882a593Smuzhiyun
594*4882a593Smuzhiyun```
595*4882a593Smuzhiyun/# cat load
596*4882a593Smuzhiyunnum of scheduler = 3									//The number of hardware cores currently equipped.
597*4882a593Smuzhiyun================= load ==================
598*4882a593Smuzhiyunscheduler[0]: rga3_core0
599*4882a593Smuzhiyun         load = 0%										//Core load ratio.
600*4882a593Smuzhiyun-----------------------------------
601*4882a593Smuzhiyunscheduler[1]: rga3_core1
602*4882a593Smuzhiyun         load = 0%
603*4882a593Smuzhiyun-----------------------------------
604*4882a593Smuzhiyunscheduler[2]: rga2
605*4882a593Smuzhiyun         load = 0%
606*4882a593Smuzhiyun-----------------------------------
607*4882a593Smuzhiyun```
608*4882a593Smuzhiyun
609*4882a593Smuzhiyun
610*4882a593Smuzhiyun
611*4882a593Smuzhiyun##### Memory Manager Query
612*4882a593Smuzhiyun
613*4882a593SmuzhiyunUse the following command to query the memory status in the memory manager:
614*4882a593Smuzhiyun
615*4882a593Smuzhiyun```
616*4882a593Smuzhiyun/# cat mm_session
617*4882a593Smuzhiyunrga_mm dump:
618*4882a593Smuzhiyunbuffer count = 3										//The number of buffers saved in the memory manager
619*4882a593Smuzhiyun===============================================================
620*4882a593Smuzhiyunhandle = 34 refcount = 1 mm_flag = 0x2  tgid = 3210
621*4882a593Smuzhiyunvirtual address:
622*4882a593Smuzhiyun         va = 0xb400007286e1c000, pages = 0x00000000ae081f65, size = 3686400
623*4882a593Smuzhiyun         iova = 0xffc70000, offset = 0x0, sgt = 0x00000000cc976f9e, size = 3686400, map_core = 0x1
624*4882a593Smuzhiyun         												//memory information
625*4882a593Smuzhiyun---------------------------------------------------------------
626*4882a593Smuzhiyunhandle = 35 refcount = 1 mm_flag = 0x2  tgid = 3210
627*4882a593Smuzhiyunvirtual address:
628*4882a593Smuzhiyun         va = 0xb400007286a95000, pages = 0x000000002f083efc, size = 3686400
629*4882a593Smuzhiyun         iova = 0xff8e0000, offset = 0x0, sgt = 0x0000000062bb1297, size = 3686400, map_core = 0x1
630*4882a593Smuzhiyun---------------------------------------------------------------
631*4882a593Smuzhiyunhandle = 36 refcount = 1 mm_flag = 0x2  tgid = 3210
632*4882a593Smuzhiyunvirtual address:
633*4882a593Smuzhiyun         va = 0xb40000728670e000, pages = 0x00000000785fef63, size = 3686400
634*4882a593Smuzhiyun         iova = 0xff550000, offset = 0x0, sgt = 0x00000000cdd7688d, size = 3686400, map_core = 0x1
635*4882a593Smuzhiyun---------------------------------------------------------------
636*4882a593Smuzhiyun```
637*4882a593Smuzhiyun
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun
640*4882a593Smuzhiyun##### Job Request Query
641*4882a593Smuzhiyun
642*4882a593SmuzhiyunUse the following command in Job manager to request the status of the job:
643*4882a593Smuzhiyun
644*4882a593Smuzhiyun```
645*4882a593Smuzhiyun/# cat request_manager
646*4882a593Smuzhiyunrga internal request dump:
647*4882a593Smuzhiyunrequest count = 1										//The number of job requests in the job manager.
648*4882a593Smuzhiyun===============================================================
649*4882a593Smuzhiyun------------------ request: 200073 ------------------
650*4882a593Smuzhiyun         set cmd num: 1, finish job: 0, failed job: 0, flags = 0x0, ref = 2
651*4882a593Smuzhiyun         												//Job request completion status.
652*4882a593Smuzhiyun         cmd dump:										//Job request information.
653*4882a593Smuzhiyun                 rotate_mode = 0
654*4882a593Smuzhiyun                 src: y = 25 uv = 0 v = e1000 aw = 1280 ah = 720 vw = 1280 vh = 720
655*4882a593Smuzhiyun                 src: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1
656*4882a593Smuzhiyun                 dst: y=26 uv=0 v=e1000 aw=1280 ah=720 vw=1280 vh=720
657*4882a593Smuzhiyun                 dst: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1
658*4882a593Smuzhiyun                 mmu: mmu_flag=0 en=0
659*4882a593Smuzhiyun                 alpha: rop_mode = 0
660*4882a593Smuzhiyun                 yuv2rgb mode is 0
661*4882a593Smuzhiyun                 set core = 0, priority = 0, in_fence_fd = -1
662*4882a593Smuzhiyun```
663*4882a593Smuzhiyun
664*4882a593Smuzhiyun
665*4882a593Smuzhiyun
666*4882a593Smuzhiyun##### Hardware Information Query
667*4882a593Smuzhiyun
668*4882a593SmuzhiyunUse the following command to query the current hardware information:
669*4882a593Smuzhiyun
670*4882a593Smuzhiyun```
671*4882a593Smuzhiyun/# cat hardware
672*4882a593Smuzhiyun===================================
673*4882a593Smuzhiyunrga3_core0, core 1: version: 3.0.76831					//Parameters such as the hardware version equipped with the core and supported function options.
674*4882a593Smuzhiyuninput range: 68x2 ~ 8176x8176
675*4882a593Smuzhiyunoutput range: 68x2 ~ 8128x8128
676*4882a593Smuzhiyunscale limit: 1/8 ~ 8
677*4882a593Smuzhiyunbyte_stride_align: 16
678*4882a593Smuzhiyunmax_byte_stride: 32768
679*4882a593Smuzhiyuncsc: RGB2YUV 0xf YUV2RGB 0xf
680*4882a593Smuzhiyunfeature: 0x4
681*4882a593Smuzhiyunmmu: RK_IOMMU
682*4882a593Smuzhiyun-----------------------------------
683*4882a593Smuzhiyunrga3_core1, core 2: version: 3.0.76831
684*4882a593Smuzhiyuninput range: 68x2 ~ 8176x8176
685*4882a593Smuzhiyunoutput range: 68x2 ~ 8128x8128
686*4882a593Smuzhiyunscale limit: 1/8 ~ 8
687*4882a593Smuzhiyunbyte_stride_align: 16
688*4882a593Smuzhiyunmax_byte_stride: 32768
689*4882a593Smuzhiyuncsc: RGB2YUV 0xf YUV2RGB 0xf
690*4882a593Smuzhiyunfeature: 0x4
691*4882a593Smuzhiyunmmu: RK_IOMMU
692*4882a593Smuzhiyun-----------------------------------
693*4882a593Smuzhiyunrga2, core 4: version: 3.2.63318
694*4882a593Smuzhiyuninput range: 2x2 ~ 8192x8192
695*4882a593Smuzhiyunoutput range: 2x2 ~ 4096x4096
696*4882a593Smuzhiyunscale limit: 1/16 ~ 16
697*4882a593Smuzhiyunbyte_stride_align: 4
698*4882a593Smuzhiyunmax_byte_stride: 32768
699*4882a593Smuzhiyuncsc: RGB2YUV 0x7 YUV2RGB 0x7
700*4882a593Smuzhiyunfeature: 0x5f
701*4882a593Smuzhiyunmmu: RGA_MMU
702*4882a593Smuzhiyun-----------------------------------
703*4882a593Smuzhiyun```
704*4882a593Smuzhiyun
705*4882a593Smuzhiyun
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun##### dump running data
708*4882a593Smuzhiyun
709*4882a593SmuzhiyunUse the following command to dump the running data for debugging. You can write the next few frames of RGA data to the specified directory through the debugging node configuration. Without this node, it means that the current kernel does not support the kernel to write and write data.
710*4882a593Smuzhiyun
711*4882a593Smuzhiyun- Set the dump data path, and when the dump operation data is enabled, it will be output to this folder.
712*4882a593Smuzhiyun
713*4882a593Smuzhiyun```
714*4882a593Smuzhiyun/# echo /data/rga_image > dump_path
715*4882a593Smuzhiyun/# dmesg -c
716*4882a593Smuzhiyunrga_debugger: dump path change to: /data/rga_image
717*4882a593Smuzhiyun```
718*4882a593Smuzhiyun
719*4882a593Smuzhiyun- Set the number of dump data frames.
720*4882a593Smuzhiyun
721*4882a593Smuzhiyun```
722*4882a593Smuzhiyun/# echo 1 > dump_image
723*4882a593Smuzhiyun/# dmesg -c
724*4882a593Smuzhiyunrga_debugger: dump image 1
725*4882a593Smuzhiyun
726*4882a593Smuzhiyun.... RGA running ....
727*4882a593Smuzhiyun
728*4882a593Smuzhiyun/# dmesg -c
729*4882a593Smuzhiyunrga_debugger: dump image to: /data/rga_image/1_core1_src_plane0_virt_addr_w1280_h720_RGBA8888.bin
730*4882a593Smuzhiyunrga_debugger: dump image to: /data/rga_image/1_core1_dst_plane0_virt_addr_w1280_h720_RGBA8888.bin
731*4882a593Smuzhiyun
732*4882a593Smuzhiyun/# ls /data/rga_image/
733*4882a593Smuzhiyun1_core1_dst_plane0_virt_addr_w1280_h720_RGBA8888.bin  1_core1_src_plane0_virt_addr_w1280_h720_RGBA8888.bin
734*4882a593Smuzhiyun														//Input (src), output (dst) running image data
735*4882a593Smuzhiyun```
736*4882a593Smuzhiyun
737*4882a593Smuzhiyun
738*4882a593Smuzhiyun
739*4882a593Smuzhiyun---
740*4882a593Smuzhiyun
741*4882a593Smuzhiyun## Q & A
742*4882a593Smuzhiyun
743*4882a593SmuzhiyunThis section introduces common questions about RGA in the form of Q&A. If the problem is not in this section, please sort out the relevant log and preliminary analysis information and submit it to the redmine platform for the engineer who maintains the RGA module to handle it.
744*4882a593Smuzhiyun
745*4882a593Smuzhiyun### Performance Consulting
746*4882a593Smuzhiyun
747*4882a593Smuzhiyun**Q1.1**:How to evaluate RGA efficiency?
748*4882a593Smuzhiyun
749*4882a593Smuzhiyun**A1.1**: When RGA performs copying, the following formula can be used to calculate the theoretical time (this function only supports data copy evaluation):
750*4882a593Smuzhiyun
751*4882a593Smuzhiyun​			Time required for a single image copy = width × height / number of pixels that RGA can process per second
752*4882a593Smuzhiyun
753*4882a593Smuzhiyun​											= width × height / (number of pixels that RGA can process per clock cycle × RGA frequency)
754*4882a593Smuzhiyun
755*4882a593Smuzhiyun​			For example, the theoretical consuming time of copying an image of 1920 × 1080 size with RGA (frequency set at 300M) is:
756*4882a593Smuzhiyun
757*4882a593Smuzhiyun​						RGA1 : 1920 × 1080 / (1 × 300000000) = 0.006912s
758*4882a593Smuzhiyun
759*4882a593Smuzhiyun​						RGA2 : 1920 × 1080 / (2 × 300000000) = 0.003456s
760*4882a593Smuzhiyun
761*4882a593Smuzhiyun​						RGA3 : 1920 × 1080 / (4 × 300000000) = 0.001728s
762*4882a593Smuzhiyun
763*4882a593Smuzhiyun​			The actual consuming time depends on the type of memory used. The efficiency of different memory types from high to low is physical address > dma_fd > virtual address.
764*4882a593Smuzhiyun
765*4882a593Smuzhiyun​			When the system is in no load, the actual time consuming of physical address is about 1.1-1.2 times of the theoretical time consuming, the actual time consuming of dma_fd is about 1.3-1.5 times of the theoretical time consuming, and the actual time consuming of virtual address is about 1.8-2.1 times of the theoretical time consuming, and is greatly affected by CPU. In general, we recommend developers to use dma_fd as the memory type passed in, which achieves great balance between accessibility and efficiency. Virtual addresses are only used as a simple and easy-to-use memory type when learning about RGA. The following table shows the actual test data of different RGA frequencies when the system is in no load on RK3566.
766*4882a593Smuzhiyun
767*4882a593Smuzhiyun​			**Test Environment**:
768*4882a593Smuzhiyun
769*4882a593Smuzhiyun| Chip Platform | RK3566     |
770*4882a593Smuzhiyun| -------- | ---------- |
771*4882a593Smuzhiyun| System Platform | Android 11 |
772*4882a593Smuzhiyun| RGA Frequency  | 300 M      |
773*4882a593Smuzhiyun| CPU Frequency  | 1.8 Ghz    |
774*4882a593Smuzhiyun| GPU Frequency  | 800 M      |
775*4882a593Smuzhiyun| DDR Frequency  | 1056 M     |
776*4882a593Smuzhiyun
777*4882a593Smuzhiyun​			**Test Data**:
778*4882a593Smuzhiyun
779*4882a593Smuzhiyun| Resolution      | Memory type                  | Theoretical Time(us) | Actual Time(us) |
780*4882a593Smuzhiyun| ----------- | ------------------------- | -------------- | -------------- |
781*4882a593Smuzhiyun| 1280 × 720  | GraphicBuffer(cache)    | 1,536          | 2,620          |
782*4882a593Smuzhiyun| 1280 × 720  | GraphicBuffer(no cache) | 1,536          | 2,050          |
783*4882a593Smuzhiyun| 1280 × 720  | Drm buffer(cache)       | 1,536          | 2,190          |
784*4882a593Smuzhiyun| 1280 × 720  | Physical address(Drm)   | 1,536          | 2,000          |
785*4882a593Smuzhiyun| 1920 × 1080 | GraphicBuffer(cache)    | 3,456          | 5,500          |
786*4882a593Smuzhiyun| 1920 × 1080 | GraphicBuffer(no cache) | 3,456          | 4,180          |
787*4882a593Smuzhiyun| 1920 × 1080 | Drm buffer(cache)       | 3,456          | 4,420          |
788*4882a593Smuzhiyun| 1920 × 1080 | Physical address(Drm)   | 3,456          | 4,100          |
789*4882a593Smuzhiyun| 3840 × 2160 | GraphicBuffer(cache)    | 13,824         | 21,500         |
790*4882a593Smuzhiyun| 3840 × 2160 | GraphicBuffer(no cache) | 13,824         | 15,850         |
791*4882a593Smuzhiyun| 3840 × 2160 | Drm buffer(cache)       | 13,824         | 16,800         |
792*4882a593Smuzhiyun| 3840 × 2160 | Physical address(Drm)   | 13,824         | 15,600         |
793*4882a593Smuzhiyun
794*4882a593Smuzhiyun
795*4882a593Smuzhiyun
796*4882a593Smuzhiyun**Q1.2**:The theoretical formula only provides the evaluation method of copying, so how to evaluate other modes?
797*4882a593Smuzhiyun
798*4882a593Smuzhiyun**A1.2**:Currently only the formula of copying is available for evaluating use. Other modes, such as scaling and cropping, can be evaluated by taking two images of larger resolution into the copy formula to calculate the time consumption, which usually fluctuates up and down according to the size of scaling and cropping. The time consumption of the mode with no change in resolution such as blending is about 1.1-1.2 times that of the copy mode. Because of the DDR bandwidth effect in actual scenarios, it is recommended that the actual test data in the target scenario prevail in the actual evaluation.
799*4882a593Smuzhiyun
800*4882a593Smuzhiyun
801*4882a593Smuzhiyun
802*4882a593Smuzhiyun**Q1.3**:Why does RGA perform poorly in certain scenarios, taking up to twice as long as running a demo?
803*4882a593Smuzhiyun
804*4882a593Smuzhiyun**A1.3**:The bus priority of RGA in the current RK platform is the lowest. When bandwidth resources are tight, for example, in the ISP running multiplex scenario, RGA cannot read and write data in DDR timely due to bandwidth resource shortage, resulting in a large delay and performance deterioration of RGA.
805*4882a593Smuzhiyun
806*4882a593Smuzhiyun
807*4882a593Smuzhiyun
808*4882a593Smuzhiyun**Q1.4**:The efficiency of RGA cannot meet the needs of our products. Is there any way to improve it?
809*4882a593Smuzhiyun
810*4882a593Smuzhiyun**A1.4**:The RGA frequency of the factory firmware of some chips is not the highest frequency. For example, the RGA frequency of chips such as 3399 and 1126 can be up to 400M. The RGA frequency can be improved in the following two ways:
811*4882a593Smuzhiyun
812*4882a593Smuzhiyun- Set by command (temporarily modified, frequency restored upon device restart)
813*4882a593Smuzhiyun
814*4882a593Smuzhiyun> Query RGA Frequency
815*4882a593Smuzhiyun
816*4882a593Smuzhiyun```c++
817*4882a593Smuzhiyuncat /sys/kernel/debug/clk/clk_summary | grep rga  				//Query rga frequency.
818*4882a593Smuzhiyun```
819*4882a593Smuzhiyun
820*4882a593Smuzhiyun> Modify RGA Frequency
821*4882a593Smuzhiyun
822*4882a593Smuzhiyun```c++
823*4882a593Smuzhiyunecho 400000000 > /sys/kernel/debug/clk/aclk_rga/clk_rate		//Modify 400000000 to the needed frequency.
824*4882a593Smuzhiyun```
825*4882a593Smuzhiyun
826*4882a593Smuzhiyun- Modify dts to modify RGA frequency(The frequency is still set after restart)
827*4882a593Smuzhiyun
828*4882a593Smuzhiyun> The following example shows how to change RGA frequency in dts of RK3288. Users can change RGA frequency in the corresponding dts of other platforms.
829*4882a593Smuzhiyun
830*4882a593Smuzhiyun```
831*4882a593Smuzhiyundiff --git a/arch/arm/boot/dts/rk3288-android.dtsi b/arch/arm/boot/dts/rk3288-android.dtsi
832*4882a593Smuzhiyunindex 02938b0..10a1dc4 100644
833*4882a593Smuzhiyun--- a/arch/arm/boot/dts/rk3288-android.dtsi
834*4882a593Smuzhiyun+++ b/arch/arm/boot/dts/rk3288-android.dtsi
835*4882a593Smuzhiyun@@ -450,6 +450,8 @@
836*4882a593Smuzhiyun        compatible = "rockchip,rga2";
837*4882a593Smuzhiyun        clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>;
838*4882a593Smuzhiyun        clock-names = "aclk_rga", "hclk_rga", "clk_rga";
839*4882a593Smuzhiyun+       assigned-clocks = <&cru ACLK_RGA>, <&cru SCLK_RGA>;
840*4882a593Smuzhiyun+       assigned-clock-rates = <300000000>, <300000000>;
841*4882a593Smuzhiyun        dma-coherent;
842*4882a593Smuzhiyun };
843*4882a593Smuzhiyun```
844*4882a593Smuzhiyun
845*4882a593Smuzhiyun
846*4882a593Smuzhiyun
847*4882a593Smuzhiyun**Q1.5**:Does the RGA support querying the current RGA hardware utilization (load) through commands or interfaces?
848*4882a593Smuzhiyun
849*4882a593Smuzhiyun**A1.5**:RGA multicore Device Driver supports viewing hardware load, for details, please refer to **Debugging Instructions——Driver Debugging Node——Debugging Node Function——Load Query**
850*4882a593Smuzhiyun
851*4882a593Smuzhiyun
852*4882a593Smuzhiyun
853*4882a593Smuzhiyun**Q1.6**:Why are RGA calls in asynchronous mode slower than those in synchronous mode in some scenarios?
854*4882a593Smuzhiyun
855*4882a593Smuzhiyun**A1.6**:RGA Device Driver, RGA2 Device Driver Since the identifier of the asynchronous mode of librga is an open device node, and a process of librga in singleton mode will only open one fd, so imsync() waits for all asynchronous modes of the process to run Will not return until finished. The RGA multicore Device Driver introduces a fence mechanism, so it is for real-time processing of a single request, and there will be no such problem.
856*4882a593Smuzhiyun
857*4882a593Smuzhiyun
858*4882a593Smuzhiyun
859*4882a593Smuzhiyun**Q1.7**:The time cousuming when using virtual address to call RGA for copying is higher than memcpy, is there a way to optimize?
860*4882a593Smuzhiyun
861*4882a593Smuzhiyun**A1.7**:In general, we do not recommend using virtual addresses to call RGA, because the efficiency of using a virtual address to call RGA in a scenario with a high CPU load will be greatly reduced. This is because the part of the virtual address to physical address page table in the RGA driver is calculated by the CPU, and the virtual address itself is converted to a physical address. The process of address page table itself is very time-consuming; in addition, the virtual address usually does not have a user-mode interface synchronization cache, so the driver will force the virtual address to synchronize the cache every frame. Therefore, it is generally recommended to call librga using a physical address or dma_fd.
862*4882a593Smuzhiyun
863*4882a593Smuzhiyun
864*4882a593Smuzhiyun
865*4882a593Smuzhiyun**Q1.8**: When carrying 8G DDR, why is RGA efficiency worse than 4G?
866*4882a593Smuzhiyun
867*4882a593Smuzhiyun**A1.8**:Since the current RGA1/RGA2 MMU only supports a maximum of 32 bits of physical address, therefore, with devices equipped with DDR of 4G or more, when a buffer with memory greater than 4G is passed to RGA, the RGA driver copies the data from the memory with the highest address to the memory reserved by swiotlb through the DMA interface and returns the corresponding address for RGA to read and write. After the work is finished, the result is copied to the previous high target address through dma, so the CPU involvement was increased, leading to a serious increase in the working time of the librga. If only RGA2/RGA1 is configured and the DDR of the device is greater than 4 GB, you are advised to use less than 4 GB memory when calling RGA to ensure RGA efficiency.
868*4882a593Smuzhiyun
869*4882a593SmuzhiyunIn the RGA Multicore Device Driver, the swiotlb mechanism will be disabled for access-restricted memory, and the caller will be notified directly to apply for a reasonable memory re-call by displaying the failure of the call to ensure the efficiency of RGA. Usually accompanied by the following logs:
870*4882a593Smuzhiyun
871*4882a593Smuzhiyun> HAL Log:
872*4882a593Smuzhiyun
873*4882a593Smuzhiyun```
874*4882a593SmuzhiyunRgaBlit(1483) RGA_BLIT fail: Invalid argument
875*4882a593SmuzhiyunFailed to call RockChipRga interface, please use 'dmesg' command to view driver error log.
876*4882a593Smuzhiyun```
877*4882a593Smuzhiyun
878*4882a593Smuzhiyun> Hardware Matching Log:
879*4882a593Smuzhiyun
880*4882a593Smuzhiyun```
881*4882a593Smuzhiyunrga_policy: invalid function policy							//Indicates that there are invalid parameters, which means that no hardware can access the memory configured by the current request.
882*4882a593Smuzhiyunrga_job: job assign failed									//Failed to match hardware core
883*4882a593Smuzhiyunrga_job: failed to get scheduler, rga_job_commit(403)
884*4882a593Smuzhiyunrga_job: (pid:3524) job clean use time = 19
885*4882a593Smuzhiyunrga_job: request[282567] task[0] job_commit failed.
886*4882a593Smuzhiyunrga_job: rga request commit failed!
887*4882a593Smuzhiyunrga: request[282567] submit failed!
888*4882a593Smuzhiyun```
889*4882a593Smuzhiyun
890*4882a593Smuzhiyun> Driver Running Log:
891*4882a593Smuzhiyun
892*4882a593Smuzhiyun```
893*4882a593Smuzhiyunrga_policy: start policy on core = 4
894*4882a593Smuzhiyun[82116.782252] rga_policy: RGA2 only support under 4G memory!
895*4882a593Smuzhiyun															//Indicates that the currently equipped RGA2 core only supports memory within 4G.
896*4882a593Smuzhiyun[82116.782256] rga_policy: optional_cores = 0
897*4882a593Smuzhiyun[82116.782258] rga_policy: invalid function policy
898*4882a593Smuzhiyun[82116.782260] rga_policy: assign core: -1
899*4882a593Smuzhiyun[82116.782262] rga_job: job assign failed
900*4882a593Smuzhiyun```
901*4882a593Smuzhiyun
902*4882a593SmuzhiyunTherefore, for this scenario, it is recommended to apply for memory within 4G to call librga. The common way to allocate 4G memory can be viewed in the following sample code:
903*4882a593Smuzhiyun
904*4882a593Smuzhiyun **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_dma32_demo.cpp**
905*4882a593Smuzhiyun
906*4882a593Smuzhiyun **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_graphicbuffer_demo.cpp**
907*4882a593Smuzhiyun
908*4882a593Smuzhiyun
909*4882a593Smuzhiyun
910*4882a593Smuzhiyun### Functions Consulting
911*4882a593Smuzhiyun
912*4882a593Smuzhiyun**Q2.1**:How do I know what version of RGA is available on my current chip platform and what functions are available?
913*4882a593Smuzhiyun
914*4882a593Smuzhiyun**A2.1**:See [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) - Overview for RGA version and support information.
915*4882a593Smuzhiyun
916*4882a593Smuzhiyun​			Different systems have different source code paths. librga source code directory paths in different SDKS are as follows:
917*4882a593Smuzhiyun
918*4882a593Smuzhiyun​			Android 7.0 and above SDK:
919*4882a593Smuzhiyun
920*4882a593Smuzhiyunhardware/rockchip/librga
921*4882a593Smuzhiyun
922*4882a593Smuzhiyun​			Android 7.0 and below SDK:
923*4882a593Smuzhiyun
924*4882a593Smuzhiyunhardware/rk29/librga
925*4882a593Smuzhiyun
926*4882a593Smuzhiyun​			Linux SDK:
927*4882a593Smuzhiyun
928*4882a593Smuzhiyunexternal/linux-rga
929*4882a593Smuzhiyun
930*4882a593Smuzhiyun
931*4882a593Smuzhiyun
932*4882a593Smuzhiyun**Q2.2**:How to call RGA for hardware acceleration? Can there be a demo for reference?
933*4882a593Smuzhiyun
934*4882a593Smuzhiyun**A2.2**:1). For API call interface, see [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) - API.
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun​			2). Demo is located in sample/rga_im2d_demo. The demo internally implements most RGA API and implements corresponding RGA functions through command. It can also be used as a tool to test whether RGA works properly in some scenarios. It is recommended that developers who are learning about RGA for the first time run the demo and get the results to understand the actual functions of RGA, modify parameters in the demo to implement corresponding functions according to their own needs, and finally try to call RGA API in their own projects.
937*4882a593Smuzhiyun
938*4882a593Smuzhiyun​			3). Common sample codes for common applications are in the samples directory:
939*4882a593Smuzhiyun
940*4882a593Smuzhiyun├── **allocator_demo**:Memory allocator related sample code<br/>
941*4882a593Smuzhiyun├── **alpha_demo**:alpha blending, overlay related sample code<br/>
942*4882a593Smuzhiyun├── **async_demo**:Asynchronous mode related sample code<br/>
943*4882a593Smuzhiyun├── **config_demo**:Thread global configuration related sample code<br/>
944*4882a593Smuzhiyun├── **copy_demo**:Image handling, copy related sample code<br/>
945*4882a593Smuzhiyun├── **crop_demo**:image cropping and splicing related sample code<br/>
946*4882a593Smuzhiyun├── **cvtcolor_demo**:Image format conversion, color space conversion related sample code<br/>
947*4882a593Smuzhiyun├── **fill_demo**:image fill related sample code<br/>
948*4882a593Smuzhiyun├── **mosaic_demo**:mosaic related sample code<br/>
949*4882a593Smuzhiyun├── **padding_demo**:padding related sample code<br/>
950*4882a593Smuzhiyun├── **resize_demo**:Image resize related sample code<br/>
951*4882a593Smuzhiyun├── **rop_demo**:ROP related sample code<br/>
952*4882a593Smuzhiyun└── **transform_demo**:Image process related sample code<br/>
953*4882a593Smuzhiyun
954*4882a593Smuzhiyun
955*4882a593Smuzhiyun
956*4882a593Smuzhiyun**Q2.3**:Support information of RGA?
957*4882a593Smuzhiyun
958*4882a593Smuzhiyun​			**Q2.3.1**:What format is supported by RGA?
959*4882a593Smuzhiyun
960*4882a593Smuzhiyun​			**A2.3.1**:For detailed support information, see  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) - Overview -  Image Format Supported to check the format support information of RGA for the corresponding chip version.  Users can also call **querystring(RGA_INPUT_FORMAT | RGA_OUTPUT_FORMAT);** to query the supported input and output formats of current hardware.
961*4882a593Smuzhiyun
962*4882a593Smuzhiyun​			**Q2.3.2**:What scaling ratio is supported by the RGA?
963*4882a593Smuzhiyun
964*4882a593Smuzhiyun​			**A2.3.2**:For detailed support information, see   [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - Overview - Design Index to query scaling ratio supported by RGA for the corresponding chip version. Users can also call **querystring(RGA_SCALE_LIMIT);** to query the scaling ratio supported by current hardware.
965*4882a593Smuzhiyun
966*4882a593Smuzhiyun​			**Q2.3.3**:What is the max resolution supported by RGA?
967*4882a593Smuzhiyun
968*4882a593Smuzhiyun​			**A2.3.3**:For detailed support information, see  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - Overview - Design Index to query the max input and output resolution supported by RGA for the corresponding chip version. Users can also call **querystring(RGA_MAX_INPUT | RGA_MAX_OUTPUT);** to query the max input/output resolution supported by current hardware.
969*4882a593Smuzhiyun
970*4882a593Smuzhiyun**A2.3**:In general, if you have any questions about RGA support, please refer to [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md), which provides detailed instructions on RGA support information.
971*4882a593Smuzhiyun
972*4882a593Smuzhiyun
973*4882a593Smuzhiyun
974*4882a593Smuzhiyun**Q2.4**:How does the new version of librga differ from the old one and how to tell?
975*4882a593Smuzhiyun
976*4882a593Smuzhiyun**A2.4**:Among all the released SDKs of the current RK platform, the old version of librga that cannot obtain the version number is mainly distributed, and the new version of librga that supports querying the version number.
977*4882a593Smuzhiyun
978*4882a593Smuzhiyun​			The support and maintenance of the no version librga has been stopped. The main feature is that the SDK released before November 2020 is loaded with the old version librga. Some chip platforms, such as RK3399 Linux SDK released before June 2021 (V2.5 and below), are also with the old version librga. This version of librga cannot perfectly fit newer drivers and may have color deviation, abnormal format and other problems, so it is not recommended to use it together. When using a newer kernel, users are recommended to update the new version librga, and when using a newer version librga , kernel should be updated to match.
979*4882a593Smuzhiyun
980*4882a593Smuzhiyun​			The support query version of librga is currently the main version of support and maintenance, the main feature is to add **im2d_api** directory under source directory. This version integrates with the old version librga, and introduces a simple and easy to use IM2D API, also called IM2D librga. The new version librga supports not only the new IM2D API, but also RockchipRga and C_XXX interfaces of older version. For details about API, see [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md). This version adds the software management version number, which can be queried through **querystring(RGA_VERSION);**.
981*4882a593Smuzhiyun
982*4882a593Smuzhiyun​			Generally, for librga support information of old and new version, it is recommended to update the overall SDK to avoid dependency problems. It is strongly not recommended to use the new version librga with old driver or the old version librga with new kernel. It may cause obvious errors in certain scenario.
983*4882a593Smuzhiyun
984*4882a593Smuzhiyun
985*4882a593Smuzhiyun
986*4882a593Smuzhiyun**Q2.5**:Does the RGA have alignment requirements?
987*4882a593Smuzhiyun
988*4882a593Smuzhiyun**A2.5**:Different formats have different alignment requirements,the RGA hardware itself fetches the data of each line of the image in a word aligned manner,that is 4 bytes/32 bits. For example, the RGBA format itself has a single pixel storage size of 32 bit (4 × 8bit), so there is no alignment requirement. RGB565 format storage size is 16 bit (5bit + 6bit + 5bit), so it needs 2 alignment; RGB888 format storage size is 24 bit (3 × 8bit), so the format needs 4 alignment to meet the 32bit fetching requirement of RGA hardware; YUV format storage is relatively special, its own alignment requirement needs 2 alignment, Y channel single pixel storage size is 8bit, so YUV format needs 4 alignment to meet the 32bit fetching requirement of RGA hardware. UV channel according to 420/422 to determine the storage size of each four pixels, so the YUV format Y channel needs 4 alignment to meet the RGA hardware fetching requirements, then the YUV format needs 4 alignment; other unmentioned format alignment requirements are similar in principle. Note that the alignment in the question refers to the alignment requirements of width stride, the actual width and height of YUV format itself, offset due to the characteristics of the format itself is also required 2 alignment. See the [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) , "Overview" - "Image Format Alignment Instructions" for specific alignment restrictions.
989*4882a593Smuzhiyun
990*4882a593Smuzhiyun
991*4882a593Smuzhiyun
992*4882a593Smuzhiyun**Q2.6**:Can RGA support drawing more than one rectangular at a time, or performing multiple operations? How does RGA work?
993*4882a593Smuzhiyun
994*4882a593Smuzhiyun**A2.6**:RGA can only work sequentially on hardware, that is, one configured task ends and the next configured begins. Therefore, instead of drawing multiple rectangular at a time, async mode can be used to configure the work of RGA to the underlying driver. RGA will store the work in a work queue managed by driver and complete them in sequence. When the upper layer needs to process the buffer, it calls **imsync()** to determine if the RGA hardware has completed its work.
995*4882a593Smuzhiyun
996*4882a593Smuzhiyun
997*4882a593Smuzhiyun
998*4882a593Smuzhiyun**Q2.7:*Does the fill function of RGA support YUV format?
999*4882a593Smuzhiyun
1000*4882a593Smuzhiyun**A2.7**:Older versions librga do not support YUV format. Only newer versions librga with the following submission support this format. If there is no such submission please try to update the SDK to the latest version.
1001*4882a593Smuzhiyun
1002*4882a593Smuzhiyun```
1003*4882a593Smuzhiyuncommit 8c526a6bb9d0e43b293b885245bb53a3fa8ed7f9
1004*4882a593SmuzhiyunAuthor: Yu Qiaowei <cerf.yu@rock-chips.com>
1005*4882a593SmuzhiyunDate:   Wed Dec 23 10:57:28 2020 +0800
1006*4882a593Smuzhiyun
1007*4882a593Smuzhiyun    Color fill supports YUV format as input source.
1008*4882a593Smuzhiyun
1009*4882a593Smuzhiyun    Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com>
1010*4882a593Smuzhiyun    Change-Id: I0073c31d770da513f81b9b64e4c27fee2650f30b
1011*4882a593Smuzhiyun```
1012*4882a593Smuzhiyun
1013*4882a593Smuzhiyun​			This function is the same as the RGB color fill API, which fills the color by configuring  RGB value of the color, except that the output can be set to YUV format.
1014*4882a593Smuzhiyun
1015*4882a593Smuzhiyun
1016*4882a593Smuzhiyun
1017*4882a593Smuzhiyun**Q2.8**:Does RGA support YUYV format?
1018*4882a593Smuzhiyun
1019*4882a593Smuzhiyun**A2.8**:Older version librga (librga in the SDK released before October 2020) do not support YUYV format, only newer versions librga (with ** im2d_API ** in the source directory) with the following submission support this format. If there is no such submission, please try to update the SDK to the latest version.
1020*4882a593Smuzhiyun
1021*4882a593Smuzhiyun```
1022*4882a593Smuzhiyuncommit db278db815d147c0ff7a80faae0ea795ceffd341
1023*4882a593SmuzhiyunAuthor: Yu Qiaowei <cerf.yu@rock-chips.com>
1024*4882a593SmuzhiyunDate:   Tue Nov 24 19:50:17 2020 +0800
1025*4882a593Smuzhiyun
1026*4882a593Smuzhiyun    Add support for Y4/YUV400/YUYV in imcheck().
1027*4882a593Smuzhiyun
1028*4882a593Smuzhiyun    Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com>
1029*4882a593Smuzhiyun    Change-Id: I3cfea7c8bb331b65b5bc741956da47924eeda6e1
1030*4882a593Smuzhiyun```
1031*4882a593Smuzhiyun
1032*4882a593Smuzhiyun
1033*4882a593Smuzhiyun
1034*4882a593Smuzhiyun**Q2.9**:Does RGA support scaling of grayscale input and output?
1035*4882a593Smuzhiyun
1036*4882a593Smuzhiyun**A2.9**:Older version librga (librga in the SDK released before October 2020) do not support this format, only newer version 1.2.2 of librga (with ** im2d_API ** in the source directory) supports grayscale input. If the librga version is lower than this, please try to update SDK to the latest version. Since the RGA hardware itself does not support grayscale format, the grayscale format used here is **RK_FORMAT_Y400**, which is represented as YUV format without UV channel. YUV with only Y channel is 256-order grayscale.
1037*4882a593Smuzhiyun
1038*4882a593Smuzhiyun​			Since it is in the YUV format, we need to pay attention to the problem of the color gamut here. When converting CSC to YUV format in librga, the default is BT.601 limit range, and the Y channel of the limit range is not 0~255, which involves CSC conversion (RGB to YUV) When the output is in Y400 format, you need to pay attention to configuring the full range flag when converting the color gamut space.
1039*4882a593Smuzhiyun
1040*4882a593Smuzhiyun
1041*4882a593Smuzhiyun
1042*4882a593Smuzhiyun**Q2.10**:Why does ROP code of RK3399 run on RV1126 without corresponding results?
1043*4882a593Smuzhiyun
1044*4882a593Smuzhiyun**A2.10**:Although RGA on both RK3399 and RV1126 is RGA2-ENHANCE, their sub versions are different, and ROP function has been cut out of RV1126. For detailed function support information, see  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  or call **querystring(RGA_FEATURE);** to query support  functions.
1045*4882a593Smuzhiyun
1046*4882a593Smuzhiyun
1047*4882a593Smuzhiyun
1048*4882a593Smuzhiyun**Q2.11**:What is the reason for serious color difference (too pink or too green) in RGB and YUV format conversion, while other functions of RGA are normal.
1049*4882a593Smuzhiyun
1050*4882a593Smuzhiyun​			Expectations:
1051*4882a593Smuzhiyun
1052*4882a593Smuzhiyun​			![image-20210708171527861](RGA_FAQ.assets/image-normal.png)
1053*4882a593Smuzhiyun
1054*4882a593Smuzhiyun​			Actual result:
1055*4882a593Smuzhiyun
1056*4882a593Smuzhiyun​			![image-20210708171608076](RGA_FAQ.assets/image-color-abnormal.png)
1057*4882a593Smuzhiyun
1058*4882a593Smuzhiyun**A2.11**:This is usually caused by a mismatch between librga and kernel. For detailed version description, see **A2.4**. The problem usually occurs after librga available on Github is used in SDK released before November 2020. Librga on Github is of new version, which does not match the older version RGA driver. Here, some configurations about color space have been changed, which causes the obvious color deviation.
1059*4882a593Smuzhiyun
1060*4882a593Smuzhiyun​			There are two solutions to this problem: one is to update the SDK or RGA driver and keep librga matching with the driver; the other is to use the librga provided with SDK if the functions only available in the new version librga are not needed.
1061*4882a593Smuzhiyun
1062*4882a593Smuzhiyun​			The rga module source code update package can be obtained through Baidu Netdisk: https://eyun.baidu.com/s/3i6sbsDR
1063*4882a593Smuzhiyun
1064*4882a593Smuzhiyun
1065*4882a593Smuzhiyun
1066*4882a593Smuzhiyun**Q2.12**:How does RGA implement OSD overlay subtitle?
1067*4882a593Smuzhiyun
1068*4882a593Smuzhiyun​			Expectations:
1069*4882a593Smuzhiyun
1070*4882a593Smuzhiyun​			![image-20210708171450243](RGA_FAQ.assets/image-blend.png)
1071*4882a593Smuzhiyun
1072*4882a593Smuzhiyun**A2.12**:If the output is in RGB format, **imblend()** can be used to implement this, usually select src over mode, and the src channel image is overlaid on the dst channel image. If the output is in YUV format, ** imcomposite ()** can be used to implement this, usually select dst over mode, the src1 channel image is overlaid on the src channel image, and then output to the dst channel.
1073*4882a593Smuzhiyun
1074*4882a593Smuzhiyun​			The blending principle of this function is **Porter-Duff blending model**. For details, see  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - API - Image Blending.
1075*4882a593Smuzhiyun
1076*4882a593Smuzhiyun​			The reason RGA requires different configurations for different output formats is that RGA2 has three image channels: src, src1/pat, and dst, in which src channel supports YUV2RGB conversion, src1/pat and dst channel only supports RGB2YUV conversion. The blending inside RGA needs to be performed in RGB format. Therefore, in order to ensure that RGB images are overlaid on YUV images, src must be used as the overlaid background image YUV. Src1 is used as the overlaid RGB foreground image, and the blended RGB image is finally converted into YUV format output by dst channel.
1077*4882a593Smuzhiyun
1078*4882a593Smuzhiyun​			Can view sample code:
1079*4882a593Smuzhiyun
1080*4882a593Smuzhiyun**<librga_souce_path>/samples/alpha_demo/src/rga_alpha_osd_demo.cpp\****
1081*4882a593Smuzhiyun
1082*4882a593Smuzhiyun**<librga_souce_path>/samples/alpha_demo/src/rga_alpha_yuv_demo.cpp\****
1083*4882a593Smuzhiyun
1084*4882a593Smuzhiyun
1085*4882a593Smuzhiyun
1086*4882a593Smuzhiyun**Q2.13**:Why brightness or numerical difference exists when RGA is called to implement YUV and RGB format conversion?
1087*4882a593Smuzhiyun
1088*4882a593Smuzhiyun**A2.13**:The reasons can be roughly divided into two kinds:
1089*4882a593Smuzhiyun
1090*4882a593Smuzhiyun​			1). When YUV and RGB interconversion configuration are the same, some pixel values will be slightly different (usually 1), which is caused by the formula accuracy difference when RGA hardware implements CSC function. The decimal accuracy of CSC formula of RGA1 and RGA2 is 8bit, and that of RGA3 is 10bit. In this case, the accuracy of some calculations will have ±1 error  when the results are rounded.
1091*4882a593Smuzhiyun
1092*4882a593Smuzhiyun​			2). When the CSC modes configured for RGB2YUV and YUV2RGB conversion are different, the default CSC modes of RGB2YUV and YUV2RGB in the new version librga is BT.601-limit _range. When the corresponding **color_space_mode** member variable is incorrectly configured, the different configurations of the color space will result in large changes in interconversion. In the old version  librga, RGB2YUV is BT.601-full_range by default, and YUV2RGB is BT.709-limit_range by default. Due to the different color space configuration of the two kinds of conversions, there are great changes in interconversion.
1093*4882a593Smuzhiyun
1094*4882a593Smuzhiyun
1095*4882a593Smuzhiyun
1096*4882a593Smuzhiyun**Q2.14**:How to configure the color space for format conversion in librga?
1097*4882a593Smuzhiyun
1098*4882a593Smuzhiyun**A2.14**:Both versions of librga support configuring the color space for format conversion.
1099*4882a593Smuzhiyun
1100*4882a593Smuzhiyun​			1). In the new version librga, see to the  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - API - Image Format Conversion, and focus on configuring the mode parameter.
1101*4882a593Smuzhiyun
1102*4882a593Smuzhiyun​			2). In the old version librga, you need to modify the source code of librga, that is, yuvToRgbMode value in Normal/NormaRga.cpp, the corresponding parameters are as follows:
1103*4882a593Smuzhiyun
1104*4882a593Smuzhiyun| Format Conversion | Color Space           | Parameters                     |
1105*4882a593Smuzhiyun| -------- | ------------------ | ------------------------ |
1106*4882a593Smuzhiyun| YUV2RGB  | BT.601-limit_range | yuvToRgbMode = 0x1 << 0; |
1107*4882a593Smuzhiyun| YUV2RGB  | BT.601-full_range  | yuvToRgbMode = 0x2 << 0; |
1108*4882a593Smuzhiyun| YUV2RGB  | BT.709-limit_range | yuvToRgbMode = 0x3 << 0; |
1109*4882a593Smuzhiyun| RGB2YUV  | BT.601-limit_range | yuvToRgbMode = 0x2 << 4; |
1110*4882a593Smuzhiyun| RGB2YUV  | BT.601-full_range  | yuvToRgbMode = 0x1 << 4; |
1111*4882a593Smuzhiyun| RGB2YUV  | BT.709-limit_range | yuvToRgbMode = 0x3 << 4; |
1112*4882a593Smuzhiyun
1113*4882a593Smuzhiyun
1114*4882a593Smuzhiyun
1115*4882a593Smuzhiyun**Q2.15**:Why does calling RGA to perform alpha overlay have no effect?
1116*4882a593Smuzhiyun
1117*4882a593Smuzhiyun**A2.15**:Check whether the alpha value of the two input images is both 0xFF. When the alpha value of the foreground image in the overlay is 0xFF, the result is that the foreground image directly overwrites the background image. The result looks like there is no effect, but in fact it is a correct result.
1118*4882a593Smuzhiyun
1119*4882a593Smuzhiyun
1120*4882a593Smuzhiyun
1121*4882a593Smuzhiyun**Q2.16**:Call RGA to perform alpha overlay. The alpha value of the foreground image is 0x0. Why is the result not completely transparent?
1122*4882a593Smuzhiyun
1123*4882a593Smuzhiyun​			Foreground Image:(Black and white and rockchip alpha is 0x00)
1124*4882a593Smuzhiyun
1125*4882a593Smuzhiyun​			![image-20210708173625438](RGA_FAQ.assets/image-alpha-0x0.png)
1126*4882a593Smuzhiyun
1127*4882a593Smuzhiyun​			Expectations:
1128*4882a593Smuzhiyun
1129*4882a593Smuzhiyun​			![image-20210708173737882](RGA_FAQ.assets/image-alpha-normal.png)
1130*4882a593Smuzhiyun
1131*4882a593Smuzhiyun​			Actual Results:
1132*4882a593Smuzhiyun
1133*4882a593Smuzhiyun​			![image-20210708173808977](RGA_FAQ.assets/image-alpha-abnormal.png)
1134*4882a593Smuzhiyun
1135*4882a593Smuzhiyun
1136*4882a593Smuzhiyun
1137*4882a593Smuzhiyun**A2.16**:In normal configuration mode, default color value has been pre-multiplied by the corresponding alpha value, while the color value of the original image read directly has not been pre-multiplied by alpha value, so we need to add an extra flag bit when calling imblend to indicate that the color value of the image processed does not need to be pre-multiplied by alpha value. For details of calling method, see  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - API - Image Blending.
1138*4882a593Smuzhiyun
1139*4882a593Smuzhiyun
1140*4882a593Smuzhiyun
1141*4882a593Smuzhiyun**Q2.17**:Can the IM2D API implement multiple functions in one RGA call?
1142*4882a593Smuzhiyun
1143*4882a593Smuzhiyun**A2.17**:Yes, please refer to  [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md)  - API - Image process, and refer to the implementation of other IM2D API to understand the use of **improcess()**.
1144*4882a593Smuzhiyun
1145*4882a593Smuzhiyun
1146*4882a593Smuzhiyun
1147*4882a593Smuzhiyun**Q2.18**:When RGA is called to perform image rotation, the output image is stretched?
1148*4882a593Smuzhiyun
1149*4882a593Smuzhiyun​			Expectations:
1150*4882a593Smuzhiyun
1151*4882a593Smuzhiyun​			![image-20210708174014165](RGA_FAQ.assets/image-rotate-90-normal.png)
1152*4882a593Smuzhiyun
1153*4882a593Smuzhiyun​			Actual Result:
1154*4882a593Smuzhiyun
1155*4882a593Smuzhiyun​			![image-20210708174113366](RGA_FAQ.assets/image-rotate-90-abnormal.png)
1156*4882a593Smuzhiyun
1157*4882a593Smuzhiyun**A2.18**:When rotating 90° or 270°, if users do not want RGA to perform scaling, users should exchange the width and height of the image. Otherwise, the RGA driver defaults to the behavior of rotation + scaling, and the result is the effect of stretching.
1158*4882a593Smuzhiyun
1159*4882a593Smuzhiyun
1160*4882a593Smuzhiyun
1161*4882a593Smuzhiyun**Q2.19**:RGB888 output scaling results show that the image is slanted and has black lines?
1162*4882a593Smuzhiyun
1163*4882a593Smuzhiyun​			Input(1920 × 1080):
1164*4882a593Smuzhiyun
1165*4882a593Smuzhiyun​			![image-20210708171527861](RGA_FAQ.assets/image-normal.png)
1166*4882a593Smuzhiyun
1167*4882a593Smuzhiyun​			Output(1282 × 720):
1168*4882a593Smuzhiyun
1169*4882a593Smuzhiyun​			![image-20210708174334975](RGA_FAQ.assets/image-resize-abnormal.png)
1170*4882a593Smuzhiyun
1171*4882a593Smuzhiyun**A2.19**:This problem is caused by alignment requirement, virtual width of RGB888 format needs 4 alignment, please check the configured image parameters. For alignment requirement, see **Q2.5**.
1172*4882a593Smuzhiyun
1173*4882a593Smuzhiyun
1174*4882a593Smuzhiyun
1175*4882a593Smuzhiyun**Q2.20**:What cause the error that in some system processes, the output of RGA is fuzzy?
1176*4882a593Smuzhiyun
1177*4882a593Smuzhiyun**A2.20**:Usually RGA exception does not cause the phenomenon of fuzzy screen, when this problem occurs, users need to figure out whether the problem is RGA problem. In some system processes, users need to confirm whether the RGA input data is abnormal, you can call **fwrite()** to write  memory data to file. before calling RGA, and check whether the source data is normal. If you're not familiar with how to write files, see the implementation of the **output_buf_data_to_file()** function in the **core/ rgautils.cpp ** directory.
1178*4882a593Smuzhiyun
1179*4882a593Smuzhiyun
1180*4882a593Smuzhiyun
1181*4882a593Smuzhiyun**A2.21**:Small black or green stripes appear after calling RGA to process the image. What is the reason?
1182*4882a593Smuzhiyun
1183*4882a593Smuzhiyun​			![image-cache-abnormal](RGA_FAQ.assets/image-cache-abnormal.png)
1184*4882a593Smuzhiyun
1185*4882a593Smuzhiyun**Q2.21**:This is caused by the buffer enabling the cache when using a call that is not a virtual address, and the cache is not synchronized before and after the CPU operation. If you don't know how to synchronize the cache, you can refer to the usage in samples/allocator_demo/src/rga_allocator_dma_cache_demo.cpp.
1186*4882a593Smuzhiyun
1187*4882a593Smuzhiyun
1188*4882a593Smuzhiyun
1189*4882a593Smuzhiyun### HAL Error
1190*4882a593Smuzhiyun
1191*4882a593Smuzhiyun#### IM2D_API Error
1192*4882a593Smuzhiyun
1193*4882a593Smuzhiyun**Q3.1.1**: How to deal with the error of imcheck()?
1194*4882a593Smuzhiyun
1195*4882a593Smuzhiyun```
1196*4882a593Smuzhiyuncheck error! Invalid parameters: dst, Error yuv not align to 2, rect[x,y,w,h] = [0, 0, 1281, 720], wstride = 1281, hstride = 720, format = 0xa00(nv12)
1197*4882a593Smuzhiyunoutput support format : RGBA_8888 RGB_888 RGB_565 RGBA_4444 RGBA_5551 YUV420/YUV422 YUV420_10bit/YUV422_10bit YUYV420 YUYV422 YUV400/Y4
1198*4882a593Smuzhiyun```
1199*4882a593Smuzhiyun
1200*4882a593Smuzhiyun**A3.1.1**:The imcheck() API serves as the verification API to call librga, which determines whether the parameters of the data structure to be passed to librga are correct, whether the function is supported, whether the hardware restrictions are triggered, etc. You can pass the error value of imcheck() as an argument to **IMStrError()** and the string returned is a detailed error message. which can be used to confirm which conditions were triggered or which parameters were wrong.
1201*4882a593Smuzhiyun
1202*4882a593Smuzhiyun​			The error in this problem is caused by the alignment limitation of YUV format. Here, the width 1281 of the image is not 2 aligned, so the verification fails.
1203*4882a593Smuzhiyun
1204*4882a593Smuzhiyun
1205*4882a593Smuzhiyun
1206*4882a593Smuzhiyun**Q3.1.2**:What is the error with the imstrError() error prompt that there are no specific parameters to print instructions?
1207*4882a593Smuzhiyun
1208*4882a593Smuzhiyun```
1209*4882a593SmuzhiyunFatal error: Failed to call RockChipRga interface, please use 'dmesg' command to view driver error log.
1210*4882a593Smuzhiyun```
1211*4882a593Smuzhiyun
1212*4882a593Smuzhiyun**A3.1.2**:It means that the configuration has passed the im2d api verification and has been configured on the back-level driver. You can check the error report of the driver through dmesg.
1213*4882a593Smuzhiyun
1214*4882a593Smuzhiyun
1215*4882a593Smuzhiyun
1216*4882a593Smuzhiyun
1217*4882a593Smuzhiyun#### RockchipRga API Error
1218*4882a593Smuzhiyun
1219*4882a593Smuzhiyun**Q3.2.1**:How to deal with the error “Try to use uninit rgaCtx=(nil)”?
1220*4882a593Smuzhiyun
1221*4882a593Smuzhiyun**A3.2.1**:1). The error is caused by the fact that called API finds that librga module has not been initialized and returns an error. In the current version, the error is usually caused by some older code still uses  RgaInit/RgaDeInit/c_RkRgaInit/c_RkRgaDeInit interface to manage the initialization of RGA module, and when the singleton mode used by the current version of API is abnormal DeInit, the error will occur. Users just need to remove the Init/DeInit related calls in the code.
1222*4882a593Smuzhiyun
1223*4882a593Smuzhiyun​				2). This error will also be reported when the driver fails to probe successfully, or the access to the driver device node (/dev/rga) is restricted.
1224*4882a593Smuzhiyun
1225*4882a593Smuzhiyun
1226*4882a593Smuzhiyun
1227*4882a593Smuzhiyun**Q3.2.2**:What causes the error“RgaBlit(1027) RGA_BLIT fail: ”、“RGA_COLORFILL(1027) RGA_BLIT fail: ”?
1228*4882a593Smuzhiyun
1229*4882a593Smuzhiyun**A3.2.2**:If the header error occurs, it means that the current RGA task returns after the driver fails to run. For the specific reason, you need to check the driver log through dmesg.
1230*4882a593Smuzhiyun
1231*4882a593Smuzhiyun​				**Q3.2.2.1**:“RgaBlit(1027) RGA_BLIT fail: Not a typewriter”?
1232*4882a593Smuzhiyun
1233*4882a593Smuzhiyun​				**A3.2.2.1**:This error is usually caused by parameter errors. You are advised to check the scaling factor, whether virtual width is smaller than the sum of actual width and the offset in the corresponding direction, and whether the alignment meets requirements. It is recommended that new developed projects use IM2D API, which has a more comprehensive error detection mechanism, and is convenient for developers.
1234*4882a593Smuzhiyun
1235*4882a593Smuzhiyun
1236*4882a593Smuzhiyun​				**Q3.2.2.2**:“RgaBlit(1349) RGA_BLIT fail: Bad file descriptor”?
1237*4882a593Smuzhiyun
1238*4882a593Smuzhiyun​				**A3.2.2.2**:This error is an ioctl error, indicating that the current fd passed to device node is invalid. Please try to update librga or confirm whether the RGA initialization process has been modified.
1239*4882a593Smuzhiyun
1240*4882a593Smuzhiyun
1241*4882a593Smuzhiyun​				**Q3.2.2.3**:“RgaBlit(1360) RGA_BLIT fail: Bad address”?
1242*4882a593Smuzhiyun
1243*4882a593Smuzhiyun​				**A3.2.2.3**:The error is usually caused by a problem with the memory address of the src/src1/dst channel passed into the kernel (commonly out-of-bouns).See "Log Obtaining and Description" - "Driver Debug Node" in this document to open driver logging and locate the faulty memory.
1244*4882a593Smuzhiyun
1245*4882a593Smuzhiyun​				**Q3.2.2.4**:“RgaBlit(1466) RGA BIIT fail: Invalid argument”
1246*4882a593Smuzhiyun
1247*4882a593Smuzhiyun​				**A3.2.2.4**:This error is an invalid parameter error reported when the incoming parameters do not meet the core function and restriction requirements of the current chip. It is recommended to check whether the currently configured task parameters meet the requirements of the current chip equipped with the RGA core.
1248*4882a593Smuzhiyun
1249*4882a593Smuzhiyun
1250*4882a593Smuzhiyun
1251*4882a593Smuzhiyun**Q3.2.3**:What cause the log error “err ws[100,1280,1280]”、”Error srcRect“?
1252*4882a593Smuzhiyun
1253*4882a593Smuzhiyun**A3.2.3**:The error is an obvious parameter error. “err ws” represents width stride parameter error. The parameters in the following "[]" are [X_offeset, width, width_stride] respectively.Here, because the sum of offset in X direction and width of the actual operation area is larger than the width stride, librga thinks there is a problem with the width stride and returns an error. Change the width stride to 1380 or  width to 1180.
1254*4882a593Smuzhiyun
1255*4882a593Smuzhiyun​			After this error occurs, the following parameters are printed in logcat:
1256*4882a593Smuzhiyun
1257*4882a593Smuzhiyun```C++
1258*4882a593SmuzhiyunE librga  : err ws[100,1280,1280]											//Represent the width stride error.
1259*4882a593SmuzhiyunE librga  : [RgaBlit,731]Error srcRect										//Represent the src channel error.
1260*4882a593SmuzhiyunE rockchiprga: fd-vir-phy-hnd-format[0, 0xb400006eb6ea9040, 0x0, 0x0, 0]	//Input address (fd, virtual address, physical address, handle) of  corresponding src channel.
1261*4882a593SmuzhiyunE rockchiprga: rect[100, 0, 1280, 720, 1280, 720, 1, 0]						//Image parameters of corresponding src channel are: X direction offset, Y direction offset, width of the actual operation area, height of the actual operation area, image width (virtual width), image height (virtual height), image format, size ( parameters currently not used) respectively.
1262*4882a593SmuzhiyunE rockchiprga: f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]		//Represents the mode configuration in the call.
1263*4882a593SmuzhiyunE rockchiprga: fd-vir-phy-hnd-format[0, 0xb400006eb2ea6040, 0x0, 0x0, 0]	//Parameters of corresponding dst channel.
1264*4882a593SmuzhiyunE rockchiprga: rect[0, 0, 1920, 1080, 1920, 1080, 1, 0]
1265*4882a593SmuzhiyunE rockchiprga: f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
1266*4882a593SmuzhiyunE rockchiprga: This output the user parameters when rga call blit fail		//Error information.
1267*4882a593Smuzhiyun```
1268*4882a593Smuzhiyun
1269*4882a593Smuzhiyun
1270*4882a593Smuzhiyun
1271*4882a593Smuzhiyun### Kernel Errors
1272*4882a593Smuzhiyun
1273*4882a593Smuzhiyun**Q4.1**:What causes the error “RGA2 failed to get vma, result = 32769, pageCount = 65537”?
1274*4882a593Smuzhiyun
1275*4882a593Smuzhiyun**A4.1**:This error is usually caused by the fact that the actual memory size of virtual address is smaller than the memory size needed (that is, the memory needed for the image of current channel calculated according to parameters of image) when the RGA is called using the virtual address. Just check the size of the buffer. In some scenarios where the application and the call are not performed together, users can memset the size of image  before calling RGA, to confirm whether the problem is caused by insufficient memory size.
1276*4882a593Smuzhiyun
1277*4882a593Smuzhiyun​			Usually by “rga2 map src0 memory failed”, the channel with memory problems can be confirmed, as shown in this case, the src channel triggered this error due to the actual application of buffer size only half the size of required for the image.
1278*4882a593Smuzhiyun
1279*4882a593Smuzhiyun
1280*4882a593Smuzhiyun
1281*4882a593Smuzhiyun**Q4.2**:What causes the error ”rga2_reg_init, [868] set mmu info error“?
1282*4882a593Smuzhiyun
1283*4882a593Smuzhiyun**A4.2**:This error represents a fd or virtual address conversion to physical address page table error, usually due to the size of the applied memory, the same as Q4.1.
1284*4882a593Smuzhiyun
1285*4882a593Smuzhiyun
1286*4882a593Smuzhiyun
1287*4882a593Smuzhiyun**Q4.3**:Error “rga:dma_buf_get fail fd[328]“ usually refers to what exception occurs in the buffer?
1288*4882a593Smuzhiyun
1289*4882a593Smuzhiyun**Q4.3**:This error is reported when the kernel passes through the interface of dma. It is recommended to check the process of applying for fd and verify that fd is available outside librga before using it to call RGA.
1290*4882a593Smuzhiyun
1291*4882a593Smuzhiyun
1292*4882a593Smuzhiyun
1293*4882a593Smuzhiyun**Q4.4**:What cause the error “RGA2 failed to get pte, result = -14, pageCount = 112”、”rga2_reg_init, [868] set mmu info error“? After checking accroding to **Q4.1** 、**Q4.2**, the error remains the same. In this case, the physical address allocated by DRM is used. The memset passed to RGA through virtual address mapped by MMAP is correct.
1294*4882a593Smuzhiyun
1295*4882a593Smuzhiyun**A4.4**:This problem is caused by the allocator DRM itself. The DRM itself judges that the user mode obtains the physical address, the kernel mode usually does not need the virtual address, so the corresponding kmap will be released when allocating buffer. Releasing kmap will not affect the virtual address mapping and use in the user mode. However, when the virtual address in user mode of this buffer was passed into the RGA driver and the driver perform conversion query of the physical address page table, the kernel crashes because kmap of the buffer has been released, or the corresponding page table entry can not be queried, or the wrong address is accessed.
1296*4882a593Smuzhiyun
1297*4882a593Smuzhiyun​			For this scenario, DRM provides an interface flag bit for users to figure out whether the user mode wants DRM to release kmap, that is, whether to pass the mapped virtual address to kernel:
1298*4882a593Smuzhiyun
1299*4882a593Smuzhiyun```
1300*4882a593Smuzhiyun(1) drm buffer application options add ROCKCHIP_BO_ALLOC_KMAP definition.
1301*4882a593Smuzhiyun+	/* keep kmap for cma buffer or alloc kmap for other type memory */
1302*4882a593Smuzhiyun+   ROCKCHIP_BO_ALLOC_KMAP  = 1 << 4,
1303*4882a593Smuzhiyun(2) When applying for drm memory, add drm buffer option ROCKCHIP_BO_ALLOC_KMAP.
1304*4882a593Smuzhiyun	struct drm_mode_create_dumb arg;
1305*4882a593Smuzhiyun	...
1306*4882a593Smuzhiyun-	arg.flags = ROCKCHIP_BO_CONTIG;
1307*4882a593Smuzhiyun+	arg.flags = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_ALLOC_KMAP;	//ROCKCHIP_BO_ALLOC_KMAP is valid only when used together with ROCKCHIP_BO_CONTIG.
1308*4882a593Smuzhiyun	ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
1309*4882a593Smuzhiyun```
1310*4882a593Smuzhiyun
1311*4882a593Smuzhiyun​			And confirm whether the kernel contains the following submission, if not, please update SDK:
1312*4882a593Smuzhiyun
1313*4882a593Smuzhiyun```
1314*4882a593Smuzhiyuncommit 1a81ee3e2d3726b9382ff2c48d08f4d837bc0143
1315*4882a593SmuzhiyunAuthor: Sandy Huang <hjc@rock-chips.com>
1316*4882a593SmuzhiyunDate:   Mon May 10 16:52:04 2021 +0800
1317*4882a593Smuzhiyun
1318*4882a593Smuzhiyun    drm/rockchip: gem: add flag ROCKCHIP_BO_ALLOC_KMAP to assign kmap
1319*4882a593Smuzhiyun
1320*4882a593Smuzhiyun    RGA need to access CMA buffer at kernel space, so add this flag to keep kernel
1321*4882a593Smuzhiyun    line mapping for RGA.
1322*4882a593Smuzhiyun
1323*4882a593Smuzhiyun    Change-Id: Ia59acee3c904a495792229a80c42f74ae34200e3
1324*4882a593Smuzhiyun    Signed-off-by: Sandy Huang <hjc@rock-chips.com>
1325*4882a593Smuzhiyun```
1326*4882a593Smuzhiyun
1327*4882a593Smuzhiyun
1328*4882a593Smuzhiyun
1329*4882a593Smuzhiyun**Q4.5**: How to solve the "RGA_MMU unsupported Memory larger than 4G!" error?
1330*4882a593Smuzhiyun
1331*4882a593Smuzhiyun**A4.5**: This error usually corresponds to the HAL layer error:
1332*4882a593Smuzhiyun
1333*4882a593Smuzhiyun```
1334*4882a593SmuzhiyunRgaBlit(1483) RGA_BLIT fail: Invalid argument
1335*4882a593SmuzhiyunFailed to call RockChipRga interface, please use 'dmesg' command to view driver error log.
1336*4882a593Smuzhiyun```
1337*4882a593Smuzhiyun
1338*4882a593SmuzhiyunThis error indicates that the memory configured for the currently configured image task cannot meet the memory requirements of the currently matched hardware core. Since the IOMMU of different hardware versions of RGA has different requirements for the number of memory bits, when the allocated memory exceeds the limit of the corresponding hardware , this error will appear. For details on the restrictions of different hardware versions of RGA, please refer to the overview in [《Rockchip_Developer_Guide_RGA_CN》](./Rockchip_Developer_Guide_RGA_CN.md) - Design Indicators section.
1339*4882a593Smuzhiyun
1340*4882a593SmuzhiyunWhen this error occurs, there are usually the following scenarios and corresponding solutions:
1341*4882a593Smuzhiyun
1342*4882a593Smuzhiyun1. On a chip platform equipped with multiple RGAs (for example, RK3588 is equipped with 2 RGA3 cores and 1 RGA2 core), when the importbuffer_xx interface is not used to obtain the handle, but the wrapbuffer_xx interface is used to call the im2d api directly:
1343*4882a593Smuzhiyun
1344*4882a593Smuzhiyun    Since importbuffer_xx is not used to map the external memory to the RGA driver memory in advance, it is impossible to know in advance whether the memory does not meet the limit of the corresponding core in the actual task matching. Therefore, this error may occur in high-load scenarios. It is recommended to use importbuffer_xx to advance the external The memory is imported into the RGA driver to avoid this problem.
1345*4882a593Smuzhiyun
1346*4882a593Smuzhiyun2. On a chip platform equipped with multiple RGAs (for example, RK3588 is equipped with 2 RGA3 cores and 1 RGA2 core), the importbuffer_xx interface is used to obtain the handle, but the problem still exists:
1347*4882a593Smuzhiyun
1348*4882a593Smuzhiyun    You can check the parameters of the configured image task to confirm whether the function or format supported only by the RGA2 core (the core with restricted memory access) is configured. Taking RK3588 as an example, the color fill function and the YUV422/420 planar format are both RGA2 cores Unique functions and formats, so in this scenario, memory within 4G must be allocated to call RGA.
1349*4882a593Smuzhiyun
1350*4882a593Smuzhiyun    Common ways to allocate 4G memory can be viewed in the following sample code:
1351*4882a593Smuzhiyun
1352*4882a593Smuzhiyun     **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_dma32_demo.cpp**
1353*4882a593Smuzhiyun
1354*4882a593Smuzhiyun     **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_graphicbuffer_demo.cpp**
1355*4882a593Smuzhiyun
1356*4882a593Smuzhiyun    If you use other allocators, such as mpp_buffer, v4l2_buffer, drm_buffer, etc., please check whether the corresponding allocator supports the limited allocation of memory space within 4G, and apply for the memory required by the composite RGA hardware according to the corresponding method.
1357*4882a593Smuzhiyun
1358*4882a593Smuzhiyun3. On chip platforms that only carry one RGA (such as RK3399, RK3568, and Rk3566 that only carry RGA2):
1359*4882a593Smuzhiyun
1360*4882a593Smuzhiyun    When the chip platform is only equipped with a core with limited memory access, you must apply for memory that meets the memory requirements of the core when calling RGA. The solution is the same as scenario 2 above.
1361*4882a593Smuzhiyun
1362*4882a593Smuzhiyun
1363*4882a593Smuzhiyun
1364*4882a593Smuzhiyun**Q4.6**: What is the cause of the "rga_policy: invalid function policy" and "rga_job: job assign failed" errors?
1365*4882a593Smuzhiyun
1366*4882a593Smuzhiyun**A4.6**: You can open the driver operation log to view the specific error reasons
1367*4882a593Smuzhiyun
1368*4882a593SmuzhiyunFor example:
1369*4882a593Smuzhiyun
1370*4882a593Smuzhiyun```
1371*4882a593Smuzhiyunrga_policy: start policy on core = 4
1372*4882a593Smuzhiyunrga_policy: RGA2 only support under 4G memory! //Indicates that the current RGA2 core only supports memory within 4G.
1373*4882a593Smuzhiyunrga_policy: optional_cores = 0
1374*4882a593Smuzhiyunrga_policy: invalid function policy
1375*4882a593Smuzhiyunrga_policy: assign core: -1
1376*4882a593Smuzhiyunrga_job: job assign failed
1377*4882a593Smuzhiyun```
1378*4882a593Smuzhiyun
1379*4882a593Smuzhiyun```
1380*4882a593Smuzhiyunrga_policy: start policy on core = 1
1381*4882a593Smuzhiyunrga_policy: core = 1, break on rga_check_dst //Corresponding to the core unsupported reason log, here is the image parameter of the dst channel does not meet the current core requirements (you can check the document to confirm the core support, here core 0x1, 0x2 are RGA3 core, 0x4 is RGA2 core)
1382*4882a593Smuzhiyunrga_policy: start policy on core = 2
1383*4882a593Smuzhiyunrga_policy: core = 2, break on rga_check_dst //Corresponding to the log of reasons not supported by the core, same as above.
1384*4882a593Smuzhiyunrga_policy: start policy on core = 4
1385*4882a593Smuzhiyunrga_policy: RGA2 only support under 4G memory! //Corresponding to the reason log that the core does not support, it indicates that the reason for the current mismatch is that the core does not support memory other than 4G memory space.
1386*4882a593Smuzhiyun  rga_policy: optional_cores = 0
1387*4882a593Smuzhiyunrga_policy: invalid function policy
1388*4882a593Smuzhiyunrga_policy: assign core: -1 // After traversing all cores, if there is no matching core, a matching failure error will be reported.
1389*4882a593Smuzhiyunrga_job: job assign failed
1390*4882a593Smuzhiyun```
1391*4882a593Smuzhiyun
1392*4882a593SmuzhiyunIn the above two cases, you can confirm the configured parameter information according to the corresponding logs, and make targeted modifications.
1393*4882a593Smuzhiyun
1394*4882a593Smuzhiyun
1395*4882a593Smuzhiyun
1396*4882a593Smuzhiyun**Q4.7**:What causes the error “rga:Rga err irq! INT[701],STATS[1]”?
1397*4882a593Smuzhiyun
1398*4882a593Smuzhiyun**A4.7**:This problem usually occurs when an exception occurs during RGA hardware execution. There are many reasons for the exception, such as memory out-of-bounds and abnormal configuration. If this problem occurs, you are advised to check whether the memory passed in is out of bounds.
1399*4882a593Smuzhiyun
1400*4882a593Smuzhiyun
1401*4882a593Smuzhiyun
1402*4882a593Smuzhiyun**Q4.8**:What causes the error “rga: Rga sync pid 1001 wait 1 task done timeout”?
1403*4882a593Smuzhiyun
1404*4882a593Smuzhiyun**A4.8**:There are many reasons for the hardware timeout error. You can rectify the fault as follows:
1405*4882a593Smuzhiyun
1406*4882a593Smuzhiyun​			1). Check the overall process and ensure that no other modules or applications are locking or abnormally occupying the buffer. If the same buffer is abnormally occupied by other modules, RGA cannot read and write data properly. If the work cannot be completed within 200ms, the driver returns with exception and report the error message.
1407*4882a593Smuzhiyun
1408*4882a593Smuzhiyun​			2). Check the DDR bandwidth and utilization of current system. Because the bus priority of RGA is low, when the DDR load is full, if RGA is not completed within 200ms, the driver returns with exception and report the error message.
1409*4882a593Smuzhiyun
1410*4882a593Smuzhiyun​			3). Check whether other IP modules, such as ISP and vpu, have reported an error before the RGA timeout error occurs. If the hardware on the same bus is faulty, the RGA may fail to work properly. If the work cannot be completed within 200ms, the driver returns with exception and report the error message.
1411*4882a593Smuzhiyun
1412*4882a593Smuzhiyun​			4). Check current RGA frequency (see RGA frequency related operations in **Q1.4**). In some scenarios, the module on the same bus may lower the frequency thus affect RGA frequency. RGA frequency decrease will lead to the overall performance decline, if the work cannot be completed within 200ms, the driver returns with exception and report the error message.
1413*4882a593Smuzhiyun
1414*4882a593Smuzhiyun​			5). RGA of some chips is overclocked to a higher frequency, at which case RGA frequency rises but the voltage does not, leading to the overall performance of RGA decreases significantly and the work cannot be completed within the specified threshold. As a result,the driver returns with exception and report the error message. In this scenario, developers are advised to change the RGA frequency to proper frequency.  Overclocking will affect the stability and service life of the overall chip, so this behavior is strongly not recommended.
1415*4882a593Smuzhiyun
1416*4882a593Smuzhiyun​			6). If no error is found in any of the above scenarios, try to write the data in the target memory to file after an RGA timeout error is reported, and check whether part of the data is written to RGA. If some data is written to RGA, reconfirm scenarios 1 to 5. This is obviously caused by insufficient RGA performance. If no data is written to the target memory by RGA, collect corresponding log information and related experiments, and contact RGA maintenance engineers.
1417*4882a593Smuzhiyun
1418*4882a593Smuzhiyun
1419*4882a593Smuzhiyun
1420*4882a593Smuzhiyun**Q4.9**:When a timeout error occurs, it is accompanied by the "rga_job: hardware has finished, but the software has timeout!" log. What is the reason?
1421*4882a593Smuzhiyun
1422*4882a593Smuzhiyun**A4.9**:When this log appears, it means that the CPU core responsible for interrupts in the current system environment has been preempted, causing the RGA driver to wait for the soft interrupt in the lower half after the hardware interrupt in the upper half ends. After the timeout threshold set by the driver is exceeded, the driver reports timeout error.
1423*4882a593Smuzhiyun
1424*4882a593Smuzhiyun​			This kind of situation is common when there is a real-time process in the application layer that preempts the CPU, causing the drive device to fail to work normally. It is not recommended to use real-time processes to forcibly preempt CPU resources. If this problem occurs, it can only be optimized from the CPU side to avoid the interruption of the CPU core. Preemption cannot execute softirqs of other device drivers.