1# RGA FAQ 2 3File No.:RK-PC-YF-404 4 5Release Version: V1.1.2 6 7Release Date: 2023-06-28 8 9Security Level: □Top-Secret □Secret □Internal ■Public 10 11**DISCLAIMER** 12 13THIS 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 15**Trademark Statement** 16 17"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 19**All rights reserved. ©2022. Rockchip Electronics Co., Ltd.** 20 21Beyond 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 23Rockchip Electronics Co., Ltd. 24 25No.18 Building, A District, No.89, software Boulevard Fuzhou, Fujian,PRC 26 27Website: [www.rock-chips.com](http://www.rock-chips.com) 28 29Customer service Tel: +86-4007-700-590 30 31Customer service Fax: +86-591-83951833 32 33Customer service e-Mail: [fae@rock-chips.com](mailto:fae@rock-chips.com) 34 35--- 36 37**Intended Audience** 38 39This document (this guide) is mainly intended for: 40 41- Technical support engineers 42- Software development engineers 43 44**Revision History** 45 46| **Date** | **Version** | **Author** | **Description** | 47| ---------- | -------- | -------- | ------------ | 48| 2021/06/28 | 1.0.0 | Yu Qiaowei | Initial version. | 49| 2022/12/21 | 1.1.0 | Yu Qiaowei | Add multi_rga driver related cases. | 50| 2023/02/09 | 1.1.1 | Yu Qiaowei | Format document. | 51| 2023/06/28 | 1.1.2 | Yu Qiaowei | Supplementary Q&A | 52 53--- 54 55**Contents** 56 57[TOC] 58 59--- 60 61## Overview 62 63For 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 65 66 67--- 68 69## Version Description 70 71### Hardware Version 72 73RGA 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 75 76 77### Software Version 78 79The 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 81#### librga 82 83The API version number consists of major, minor, revision and build. The four levels of version number correspond to different levels of function update. 84 85- version query 86 87 The more common query methods are as follows: 88 89 ``` 90 strings librga.so |grep rga_api |grep version 91 ``` 92 93- update version 94 95 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 97 - github: 98 99 https://github.com/airockchip/librga 100 101 - Baidu Cloud: 102 103 104 https://eyun.baidu.com/s/3jJ9Aiz0 105 106 107 108- RGA Driver 109 110 111The 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 113- version query 114 115 Different chip platforms have different opening paths for debug nodes. Usually, there are two paths as follows. 116 117 ``` 118 cat /sys/kernel/debug/rkrga/driver_version 119 cat /proc/rkrga/driver_version 120 ``` 121 122- update version 123 124 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 126 - Baidu Cloud: 127 128 https://eyun.baidu.com/s/3dGhufEL 129 130 131 132#### Version Correspondence 133 134When 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 136| librga版本 | 对应驱动 | 硬件支持 | 137| ------------- | ------------------------------------------------------------ | ---------------- | 138| no version | Driver in SDK | RGA1、RGA2 | 139| 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| > 1.4.0 | RGA multicore Device Driver(v1.2.0 and above) | RGA2、RGA3 | 141| > 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 143Usually 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 145https://eyun.baidu.com/s/3i6sbsDR 146 147- update-to-MULTI_RGA 148 149 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 151- MUTIL_RGA 152 153 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 155- RGA2 156 157 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 159- RGA1 160 161 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 163 164 165--- 166 167## Debugging instructions 168 169### HAL Logs 170 171#### Log Switch 172 173- Android 174 175 Android supports using Android Property to configure whether librga enables HAL log printing: 176 177 - enable log print: 178 179 ``` 180 setprop vendor.rga.log 1 181 logcat -s librga 182 ``` 183 184 - set log level: 185 186 The log level is divided into full print (0), DEFAULT (1), DEBUG (3), INFO (4), WRANING (5), ERROR (6). 187 188 ``` 189 setprop vendor.rga.log_level 6 190 ``` 191 192 193 194- Linux 195 196 The Linux supports enabling/disabling HAL log printing by setting environment variables (librga 1.9.0 and above): 197 198 - enable log print: 199 200 ``` 201 export ROCKCHIP_RGA_LOG=1 202 ``` 203 204 - set log level: 205 206 The log level is divided into full print (0), DEFAULT (1), DEBUG (3), INFO (4), WRANING (5), ERROR (6). 207 208 ``` 209 export ROCKCHIP_RGA_LOG_LEVEL=6 210 ``` 211 212 213 214#### Log Description 215 216- Init Log 217 218When 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 220```C++ 221E rockchiprga: rga_api version 1.9.0_[0] 222``` 223 224When the driver version does not match the librga version, it will print the corresponding error log. 225 226> 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 228```shell 229librga fail to get driver version! Compatibility mode will be enabled. 230 23129 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``` 233 234> 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 236``` 237Invalid parameters: invaild GraphicBuffer, can not get fd and virtual address, 238``` 239 240 241 242- running log 243 244```C++ 245D librga : <<<<-------- print rgaLog -------->>>> //The parameters passed to librga are printed as follows. 246D librga : src->hnd = 0x0 , dst->hnd = 0x0 , src1->hnd = 0x0 //The handle passed in by the three channels (src、src1、dst). 247D librga : src: Fd = 00 , phyAddr = 0x0 , virAddr = 0xb400007431ed6040 //Parameters passed in src channel, representing DMA_FD, physical address and virtual address respectively. 248D librga : dst: Fd = 00 , phyAddr = 0x0 , virAddr = 0xb400007431b4f040 //Parameters passed in dst channel, representing DMA_FD, physical address, and virtual address respectively. 249D 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. 250D 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. 251E librga : blend = 0 , perpixelAlpha = 1 //Blending mode and whether the image format includes an Alpha value. 252D librga : scaleMode = 0 , stretch = 0; //scale mode (RGA1). 253E librga : rgaVersion = 3.200000 , ditherEn =0 //Hardware version, Y4 Dither enabled. 254D librga : srcMmuFlag = 1 , dstMmuFlag = 1 , rotateMode = 0 //MMU enable flag, rotation mode. 255D librga : <<<<-------- rgaReg -------->>>> //Parameters configuration of the driver are printed as follows. 256E librga : render_mode=0 rotate_mode=0 //RGA rendering mode, rotation mode. 257E 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. 258E 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. 259E 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//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. 261E librga : ROP:[0,0,0],LUT[0] //ROP and LUT configuration. 262E librga : color:[0,0,0,0,0] //Colorkey configuration(max color, min color), color-filling configuration (foreground color, background color, color-filling). 263E librga : MMU:[1,0,80000521] //MMU configuration. 264E librga : mode[0,0,0,0] //Palette、csc、colorkey configuration. 265E librga : Full CSC : en[0] //Full csc enabled flag. 266E librga : gr_color_x [0, 0, 0] // Color-filling configuration, corresponding the value of R, G, B. 267``` 268 269 270 271### Driver Debug Node 272 273#### Log Switch 274 275- Debugging Node Address 276 277The configurations of different SDK kernels are different. Generally, the debugging node of RGA exists in one or both of the following two directories: 278 279- Use a kernel with the CONFIG_ROCKCHIP_RGA_DEBUG_FS compile option enabled by default. 280 281``` 282/sys/kernel/debug 283``` 284 285- Use a kernel with the ROCKCHIP_RGA_PROC_FS compile option enabled. 286 287``` 288/proc 289``` 290 291In 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 293 294 295#### Debug node name 296 297The 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 299| driver name | node path | 300| -------------------------------- | ---------- | 301| RGA Device Driver | rga_debug | 302| RGA2 Device Driver(no version) | rga2_debug | 303| RGA2 Device Driver(v2.1.0) | rkrga | 304| RGA multicore Device Driver | rkrga | 305 306 307 308#### Debug node function 309 310##### Overview 311 312- rga_debug/rga2_debug 313 314The rga_debug/rga2_debug nodes only support the running log enable/disable. 315 316- rkrga 317 318This 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 320 321 322##### Running Log 323 324###### Log Switch 325 326- Debug node name 327 328| driver name | node path | 329| ------------------------------- | --------------- | 330| RGA Device Driver | rga_debug/rga | 331| RGA2 Device Driver(no vesion) | rga2_debug/rga2 | 332| RGA2 Device Driver(v2.1.0) | rkrga/debug | 333| RGA multicore Device Driver | rkrga/debug | 334 335- Debugging Description 336 337The switching methods of debugging logs of different driver versions are the same, and they all operate on rga/rga2/debug nodes. 338 339Taking RGA multicore Device Driver as an example, you can get the corresponding function description through the cat node in the corresponding directory: 340 341```shell 342/# cd /sys/kerne/debug/rkrga/ 343/# cat debug 344REG [DIS] 345MSG [DIS] 346TIME [DIS] 347INT [DIS] 348CHECK [DIS] 349STOP [DIS] 350 351help: 352 'echo reg > debug' to enable/disable register log printing. 353 'echo msg > debug' to enable/disable message log printing. 354 'echo time > debug' to enable/disable time log printing. 355 'echo int > debug' to enable/disable interruppt log printing. 356 'echo check > debug' to enable/disable check mode. 357 'echo stop > debug' to enable/disable stop using hardware 358``` 359 360> 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> 362> 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> 364> 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> 366> 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> 368> 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> 370> 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> 372> 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 374- Switch Debugging Node 375 376The 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 378> Take RGA multicore Device Driver as an example, open the running log 'msg': 379 380```shell 381/# cd /sys/kernel/debug/rkrga/ 382/# cat debug 383REG [DIS] 384MSG [DIS] 385TIME [DIS] 386INT [DIS] 387CHECK [DIS] 388STOP [DIS] 389 390help: 391 'echo reg > debug' to enable/disable register log printing. 392 'echo msg > debug' to enable/disable message log printing. 393 'echo time > debug' to enable/disable time log printing. 394 'echo int > debug' to enable/disable interruppt log printing. 395 'echo check > debug' to enable/disable check mode. 396 'echo stop > debug' to enable/disable stop using hardware 397/# echo msg > debug 398/# cat debug 399REG [DIS] 400MSG [EN] 401TIME [DIS] 402INT [DIS] 403CHECK [DIS] 404STOP [DIS] 405 406help: 407 'echo reg > debug' to enable/disable register log printing. 408 'echo msg > debug' to enable/disable message log printing. 409 'echo time > debug' to enable/disable time log printing. 410 'echo int > debug' to enable/disable interruppt log printing. 411 'echo check > debug' to enable/disable check mode. 412 'echo stop > debug' to enable/disable stop using hardware 413/# echo msg > debug 414/# cat debug 415REG [DIS] 416MSG [DIS] 417TIME [DIS] 418INT [DIS] 419CHECK [DIS] 420STOP [DIS] 421 422help: 423 'echo reg > debug' to enable/disable register log printing. 424 'echo msg > debug' to enable/disable message log printing. 425 'echo time > debug' to enable/disable time log printing. 426 'echo int > debug' to enable/disable interruppt log printing. 427 'echo check > debug' to enable/disable check mode. 428 'echo stop > debug' to enable/disable stop using hardware 429``` 430 431> log printing: 432 433```shell 434/# echo reg > /sys/kerne/debug/rkrga/debug 435/# 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[ 4802.344683] rga2: open rga2 reg! 437/# echo reg > /sys/kernel/debug/rga2_debug/rga2 438/# dmesg -c 439[ 5096.412419] rga2: close rga2 reg! 440``` 441 442 443 444###### Log Description 445 446For 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 448- msg mode 449 450 - RGA Device Driver、RGA2 Device Driver 451 452 ``` 453 rga2: open rga2 test MSG! //Open 'msg' log printing. 454 rga2: cmd is RGA2_GET_VERSION //Get version number, which queries hardware version the first time each process calls librga. 455 rga2: cmd is RGA_BLIT_SYNC //Current working mode. 456 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 rga2: src : y=0 uv=b4000072cc8bc040 v=b4000072cc99d040 aw=1280 ah=720 vw=1280 vh=720 xoff=0 yoff=0 format=RGBA8888 458 //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 rga2: dst : y=0 uv=b4000072cc535040 v=b4000072cc616040 aw=1280 ah=720 vw=1280 vh=720 xoff=0 yoff=0 format=RGBA8888 460 //Parameters of dst channel of image data. 461 rga2: mmu : src=01 src1=00 dst=01 els=00 //MMU enabled flag,0 for close,1 for open. 462 rga2: alpha : flag 0 mode0=0 mode1=0 //Configuration of blending. 463 rga2: blend mode is no blend //Blend mode. 464 rga2: yuv2rgb mode is 0 //Csc mode. 465 rga2: *** rga2_blit_sync proc *** 466 ``` 467 468 - RGA multicore Device Driver 469 470 - Memory Manager Log 471 472 ``` 473 rga: import buffer info: 474 rga_common: external: memory = 0xb400007458406000, type = virt_addr 475 //memory:memory value,type:memory type 476 rga_common: memory param: w = 1280, h = 720, f = RGBA8888(0x0), size = 0 477 //w/h/f:Describe the memory size in the form of image canvas, size: memory size 478 rga_dma_buf: iova_align size = 3686400 479 ``` 480 481 - Job Request Log 482 483 ``` 484 rga: Blit mode: request id = 192732 //running mode and request id 485 rga_debugger: render_mode = 0, bitblit_mode=0, rotate_mode = 0 486 //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 rga_debugger: src: y = 19 uv = 0 v = e1000 aw = 1280 ah = 720 vw = 1280 vh = 720 488 //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 rga_debugger: src: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1 490 //, 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 rga_debugger: dst: y=1a uv=0 v=e1000 aw=1280 ah=720 vw=1280 vh=720 492 //Parameters of dst channel of image data. 493 rga_debugger: dst: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1 494 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 rga_debugger: alpha: rop_mode = 0 //alpha/ROP mode enable/disable. 496 rga_debugger: yuv2rgb mode is 0 //CSC mode config 497 rga_debugger: set core = 0, priority = 0, in_fence_fd = -1 498 //set_core:user mode specified core,priority:user mode specified priority,in_fence_fd:acquire_fence fd passed by user mode. 499 ``` 500 501 - Hardware Matching Log 502 503 ``` 504 rga_policy: start policy on core = 1 505 rga_policy: start policy on core = 2 506 rga_policy: start policy on core = 4 //Iterate over all core support cases. 507 rga_policy: RGA2 only support under 4G memory! //Corresponding to the log of the reason why the core does not support. 508 rga_policy: optional_cores = 3 //The current request can match the hardware core collection. 509 rga_policy: assign core: 1 //The hardware core identifier bound after matching. 510 ``` 511 512 - Hardware Configuration Log 513 514 ``` 515 rga3_reg: render_mode:bitblt, bitblit_mode=0, rotate_mode:0 516 rga3_reg: win0: y = ffc70000 uv = ffd51000 v = ffd89400 src_w = 1280 src_h = 720 517 rga3_reg: win0: vw = 1280 vh = 720 xoff = 0 yoff = 0 format = RGBA8888 518 rga3_reg: win0: dst_w = 1280, dst_h = 720, rd_mode = 0 519 rga3_reg: win0: rot_mode = 1, en = 1, compact = 1, endian = 0 520 rga3_reg: wr: y = ff8e0000 uv = ff9c1000 v = ff9f9400 vw = 1280 vh = 720 521 rga3_reg: wr: ovlp_xoff = 0 ovlp_yoff = 0 format = RGBA8888 rdmode = 0 522 rga3_reg: mmu: win0 = 00 win1 = 00 wr = 00 523 rga3_reg: alpha: flag 0 mode0=0 mode1=a0a 524 rga3_reg: blend mode is no blend 525 rga3_reg: yuv2rgb mode is 0 526 ``` 527 528- ‘reg’ mode 529 530```c++ 531rga2: open rga2 reg! //Open 'reg' log printing. 532rga2: CMD_REG //Configuration of command register. 533rga2: 00000000 00000000 00000040 000e1040 534rga2: 00119440 00000000 00000500 02cf04ff 535rga2: 00000000 00000000 00000000 00000000 536rga2: 00000000 00000000 00000000 00000040 537rga2: 000e1040 00119440 00000500 02cf04ff 538rga2: 00000000 00000000 0000ff00 ffffffff 539rga2: 00000007 00000000 00000000 00000101 540rga2: 07a80000 00000000 07a800e4 00000000 541rga2: CSC_REG //Configuration of full csc register. 542rga2: 00000000 00000000 00000000 00000000 543rga2: 00000000 00000000 00000000 00000000 544rga2: 00000000 00000000 00000000 00000000 545rga2: CMD_READ_BACK_REG //Read back of full command register. 546rga2: 00000000 00000000 00000040 000e1040 547rga2: 00119440 00000000 00000500 02cf04ff 548rga2: 00000000 00000000 00000000 00000000 549rga2: 00000000 00000000 00000000 00000040 550rga2: 000e1040 00119440 00000500 02cf04ff 551rga2: 00000000 00000000 0000ff00 ffffffff 552rga2: 00000007 00000000 00000000 00000101 553rga2: 07a80000 00000000 07a800e4 00000000 554rga2: CSC_READ_BACK_REG //Read back of full csc register. 555rga2: 00000000 00000000 00000000 00000000 556rga2: 00000000 00000000 00000000 00000000 557rga2: 00000000 00000000 00000000 00000000 558``` 559 560- ‘time’ mode 561 562 - rga2 563 564 ``` 565 rga2: sync one cmd end time 2414 //Print the RGA. hardware time of the work,in us. 566 ``` 567 568 - multi 569 570 ``` 571 rga3_reg: set cmd use time = 196 //Time elapsed from start processing request to configuration register. 572 rga_job: hw use time = 554 //Time-consuming from hardware startup to hardware interrupt return. 573 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 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 ``` 576 577 578 579##### Version Information Query 580 581Use the following commands to query the current driver name and driver version: 582 583``` 584/# cat driver_version 585RGA multicore Device Driver: v1.2.23 586``` 587 588 589 590##### Load Query 591 592Use the following command to query the RGA load status: 593 594``` 595/# cat load 596num of scheduler = 3 //The number of hardware cores currently equipped. 597================= load ================== 598scheduler[0]: rga3_core0 599 load = 0% //Core load ratio. 600----------------------------------- 601scheduler[1]: rga3_core1 602 load = 0% 603----------------------------------- 604scheduler[2]: rga2 605 load = 0% 606----------------------------------- 607``` 608 609 610 611##### Memory Manager Query 612 613Use the following command to query the memory status in the memory manager: 614 615``` 616/# cat mm_session 617rga_mm dump: 618buffer count = 3 //The number of buffers saved in the memory manager 619=============================================================== 620handle = 34 refcount = 1 mm_flag = 0x2 tgid = 3210 621virtual address: 622 va = 0xb400007286e1c000, pages = 0x00000000ae081f65, size = 3686400 623 iova = 0xffc70000, offset = 0x0, sgt = 0x00000000cc976f9e, size = 3686400, map_core = 0x1 624 //memory information 625--------------------------------------------------------------- 626handle = 35 refcount = 1 mm_flag = 0x2 tgid = 3210 627virtual address: 628 va = 0xb400007286a95000, pages = 0x000000002f083efc, size = 3686400 629 iova = 0xff8e0000, offset = 0x0, sgt = 0x0000000062bb1297, size = 3686400, map_core = 0x1 630--------------------------------------------------------------- 631handle = 36 refcount = 1 mm_flag = 0x2 tgid = 3210 632virtual address: 633 va = 0xb40000728670e000, pages = 0x00000000785fef63, size = 3686400 634 iova = 0xff550000, offset = 0x0, sgt = 0x00000000cdd7688d, size = 3686400, map_core = 0x1 635--------------------------------------------------------------- 636``` 637 638 639 640##### Job Request Query 641 642Use the following command in Job manager to request the status of the job: 643 644``` 645/# cat request_manager 646rga internal request dump: 647request count = 1 //The number of job requests in the job manager. 648=============================================================== 649------------------ request: 200073 ------------------ 650 set cmd num: 1, finish job: 0, failed job: 0, flags = 0x0, ref = 2 651 //Job request completion status. 652 cmd dump: //Job request information. 653 rotate_mode = 0 654 src: y = 25 uv = 0 v = e1000 aw = 1280 ah = 720 vw = 1280 vh = 720 655 src: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1 656 dst: y=26 uv=0 v=e1000 aw=1280 ah=720 vw=1280 vh=720 657 dst: xoff = 0, yoff = 0, format = 0x0, rd_mode = 1 658 mmu: mmu_flag=0 en=0 659 alpha: rop_mode = 0 660 yuv2rgb mode is 0 661 set core = 0, priority = 0, in_fence_fd = -1 662``` 663 664 665 666##### Hardware Information Query 667 668Use the following command to query the current hardware information: 669 670``` 671/# cat hardware 672=================================== 673rga3_core0, core 1: version: 3.0.76831 //Parameters such as the hardware version equipped with the core and supported function options. 674input range: 68x2 ~ 8176x8176 675output range: 68x2 ~ 8128x8128 676scale limit: 1/8 ~ 8 677byte_stride_align: 16 678max_byte_stride: 32768 679csc: RGB2YUV 0xf YUV2RGB 0xf 680feature: 0x4 681mmu: RK_IOMMU 682----------------------------------- 683rga3_core1, core 2: version: 3.0.76831 684input range: 68x2 ~ 8176x8176 685output range: 68x2 ~ 8128x8128 686scale limit: 1/8 ~ 8 687byte_stride_align: 16 688max_byte_stride: 32768 689csc: RGB2YUV 0xf YUV2RGB 0xf 690feature: 0x4 691mmu: RK_IOMMU 692----------------------------------- 693rga2, core 4: version: 3.2.63318 694input range: 2x2 ~ 8192x8192 695output range: 2x2 ~ 4096x4096 696scale limit: 1/16 ~ 16 697byte_stride_align: 4 698max_byte_stride: 32768 699csc: RGB2YUV 0x7 YUV2RGB 0x7 700feature: 0x5f 701mmu: RGA_MMU 702----------------------------------- 703``` 704 705 706 707##### dump running data 708 709Use 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 711- Set the dump data path, and when the dump operation data is enabled, it will be output to this folder. 712 713``` 714/# echo /data/rga_image > dump_path 715/# dmesg -c 716rga_debugger: dump path change to: /data/rga_image 717``` 718 719- Set the number of dump data frames. 720 721``` 722/# echo 1 > dump_image 723/# dmesg -c 724rga_debugger: dump image 1 725 726.... RGA running .... 727 728/# dmesg -c 729rga_debugger: dump image to: /data/rga_image/1_core1_src_plane0_virt_addr_w1280_h720_RGBA8888.bin 730rga_debugger: dump image to: /data/rga_image/1_core1_dst_plane0_virt_addr_w1280_h720_RGBA8888.bin 731 732/# ls /data/rga_image/ 7331_core1_dst_plane0_virt_addr_w1280_h720_RGBA8888.bin 1_core1_src_plane0_virt_addr_w1280_h720_RGBA8888.bin 734 //Input (src), output (dst) running image data 735``` 736 737 738 739--- 740 741## Q & A 742 743This 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 745### Performance Consulting 746 747**Q1.1**:How to evaluate RGA efficiency? 748 749**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 751 Time required for a single image copy = width × height / number of pixels that RGA can process per second 752 753 = width × height / (number of pixels that RGA can process per clock cycle × RGA frequency) 754 755 For example, the theoretical consuming time of copying an image of 1920 × 1080 size with RGA (frequency set at 300M) is: 756 757 RGA1 : 1920 × 1080 / (1 × 300000000) = 0.006912s 758 759 RGA2 : 1920 × 1080 / (2 × 300000000) = 0.003456s 760 761 RGA3 : 1920 × 1080 / (4 × 300000000) = 0.001728s 762 763 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 765 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 767 **Test Environment**: 768 769| Chip Platform | RK3566 | 770| -------- | ---------- | 771| System Platform | Android 11 | 772| RGA Frequency | 300 M | 773| CPU Frequency | 1.8 Ghz | 774| GPU Frequency | 800 M | 775| DDR Frequency | 1056 M | 776 777 **Test Data**: 778 779| Resolution | Memory type | Theoretical Time(us) | Actual Time(us) | 780| ----------- | ------------------------- | -------------- | -------------- | 781| 1280 × 720 | GraphicBuffer(cache) | 1,536 | 2,620 | 782| 1280 × 720 | GraphicBuffer(no cache) | 1,536 | 2,050 | 783| 1280 × 720 | Drm buffer(cache) | 1,536 | 2,190 | 784| 1280 × 720 | Physical address(Drm) | 1,536 | 2,000 | 785| 1920 × 1080 | GraphicBuffer(cache) | 3,456 | 5,500 | 786| 1920 × 1080 | GraphicBuffer(no cache) | 3,456 | 4,180 | 787| 1920 × 1080 | Drm buffer(cache) | 3,456 | 4,420 | 788| 1920 × 1080 | Physical address(Drm) | 3,456 | 4,100 | 789| 3840 × 2160 | GraphicBuffer(cache) | 13,824 | 21,500 | 790| 3840 × 2160 | GraphicBuffer(no cache) | 13,824 | 15,850 | 791| 3840 × 2160 | Drm buffer(cache) | 13,824 | 16,800 | 792| 3840 × 2160 | Physical address(Drm) | 13,824 | 15,600 | 793 794 795 796**Q1.2**:The theoretical formula only provides the evaluation method of copying, so how to evaluate other modes? 797 798**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 800 801 802**Q1.3**:Why does RGA perform poorly in certain scenarios, taking up to twice as long as running a demo? 803 804**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 806 807 808**Q1.4**:The efficiency of RGA cannot meet the needs of our products. Is there any way to improve it? 809 810**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 812- Set by command (temporarily modified, frequency restored upon device restart) 813 814> Query RGA Frequency 815 816```c++ 817cat /sys/kernel/debug/clk/clk_summary | grep rga //Query rga frequency. 818``` 819 820> Modify RGA Frequency 821 822```c++ 823echo 400000000 > /sys/kernel/debug/clk/aclk_rga/clk_rate //Modify 400000000 to the needed frequency. 824``` 825 826- Modify dts to modify RGA frequency(The frequency is still set after restart) 827 828> 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 830``` 831diff --git a/arch/arm/boot/dts/rk3288-android.dtsi b/arch/arm/boot/dts/rk3288-android.dtsi 832index 02938b0..10a1dc4 100644 833--- a/arch/arm/boot/dts/rk3288-android.dtsi 834+++ b/arch/arm/boot/dts/rk3288-android.dtsi 835@@ -450,6 +450,8 @@ 836 compatible = "rockchip,rga2"; 837 clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>; 838 clock-names = "aclk_rga", "hclk_rga", "clk_rga"; 839+ assigned-clocks = <&cru ACLK_RGA>, <&cru SCLK_RGA>; 840+ assigned-clock-rates = <300000000>, <300000000>; 841 dma-coherent; 842 }; 843``` 844 845 846 847**Q1.5**:Does the RGA support querying the current RGA hardware utilization (load) through commands or interfaces? 848 849**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 851 852 853**Q1.6**:Why are RGA calls in asynchronous mode slower than those in synchronous mode in some scenarios? 854 855**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 857 858 859**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 861**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 863 864 865**Q1.8**: When carrying 8G DDR, why is RGA efficiency worse than 4G? 866 867**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 869In 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 871> HAL Log: 872 873``` 874RgaBlit(1483) RGA_BLIT fail: Invalid argument 875Failed to call RockChipRga interface, please use 'dmesg' command to view driver error log. 876``` 877 878> Hardware Matching Log: 879 880``` 881rga_policy: invalid function policy //Indicates that there are invalid parameters, which means that no hardware can access the memory configured by the current request. 882rga_job: job assign failed //Failed to match hardware core 883rga_job: failed to get scheduler, rga_job_commit(403) 884rga_job: (pid:3524) job clean use time = 19 885rga_job: request[282567] task[0] job_commit failed. 886rga_job: rga request commit failed! 887rga: request[282567] submit failed! 888``` 889 890> Driver Running Log: 891 892``` 893rga_policy: start policy on core = 4 894[82116.782252] rga_policy: RGA2 only support under 4G memory! 895 //Indicates that the currently equipped RGA2 core only supports memory within 4G. 896[82116.782256] rga_policy: optional_cores = 0 897[82116.782258] rga_policy: invalid function policy 898[82116.782260] rga_policy: assign core: -1 899[82116.782262] rga_job: job assign failed 900``` 901 902Therefore, 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 904 **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_dma32_demo.cpp** 905 906 **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_graphicbuffer_demo.cpp** 907 908 909 910### Functions Consulting 911 912**Q2.1**:How do I know what version of RGA is available on my current chip platform and what functions are available? 913 914**A2.1**:See [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) - Overview for RGA version and support information. 915 916 Different systems have different source code paths. librga source code directory paths in different SDKS are as follows: 917 918 Android 7.0 and above SDK: 919 920 hardware/rockchip/librga 921 922 Android 7.0 and below SDK: 923 924 hardware/rk29/librga 925 926 Linux SDK: 927 928 external/linux-rga 929 930 931 932**Q2.2**:How to call RGA for hardware acceleration? Can there be a demo for reference? 933 934**A2.2**:1). For API call interface, see [《Rockchip_Developer_Guide_RGA_EN》](./Rockchip_Developer_Guide_RGA_EN.md) - API. 935 936 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 938 3). Common sample codes for common applications are in the samples directory: 939 940├── **allocator_demo**:Memory allocator related sample code<br/> 941├── **alpha_demo**:alpha blending, overlay related sample code<br/> 942├── **async_demo**:Asynchronous mode related sample code<br/> 943├── **config_demo**:Thread global configuration related sample code<br/> 944├── **copy_demo**:Image handling, copy related sample code<br/> 945├── **crop_demo**:image cropping and splicing related sample code<br/> 946├── **cvtcolor_demo**:Image format conversion, color space conversion related sample code<br/> 947├── **fill_demo**:image fill related sample code<br/> 948├── **mosaic_demo**:mosaic related sample code<br/> 949├── **padding_demo**:padding related sample code<br/> 950├── **resize_demo**:Image resize related sample code<br/> 951├── **rop_demo**:ROP related sample code<br/> 952└── **transform_demo**:Image process related sample code<br/> 953 954 955 956**Q2.3**:Support information of RGA? 957 958 **Q2.3.1**:What format is supported by RGA? 959 960 **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 962 **Q2.3.2**:What scaling ratio is supported by the RGA? 963 964 **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 966 **Q2.3.3**:What is the max resolution supported by RGA? 967 968 **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 970**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 972 973 974**Q2.4**:How does the new version of librga differ from the old one and how to tell? 975 976**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 978 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 980 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 982 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 984 985 986**Q2.5**:Does the RGA have alignment requirements? 987 988**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 990 991 992**Q2.6**:Can RGA support drawing more than one rectangular at a time, or performing multiple operations? How does RGA work? 993 994**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 996 997 998**Q2.7:*Does the fill function of RGA support YUV format? 999 1000**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 1002``` 1003commit 8c526a6bb9d0e43b293b885245bb53a3fa8ed7f9 1004Author: Yu Qiaowei <cerf.yu@rock-chips.com> 1005Date: Wed Dec 23 10:57:28 2020 +0800 1006 1007 Color fill supports YUV format as input source. 1008 1009 Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com> 1010 Change-Id: I0073c31d770da513f81b9b64e4c27fee2650f30b 1011``` 1012 1013 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 1015 1016 1017**Q2.8**:Does RGA support YUYV format? 1018 1019**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 1021``` 1022commit db278db815d147c0ff7a80faae0ea795ceffd341 1023Author: Yu Qiaowei <cerf.yu@rock-chips.com> 1024Date: Tue Nov 24 19:50:17 2020 +0800 1025 1026 Add support for Y4/YUV400/YUYV in imcheck(). 1027 1028 Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com> 1029 Change-Id: I3cfea7c8bb331b65b5bc741956da47924eeda6e1 1030``` 1031 1032 1033 1034**Q2.9**:Does RGA support scaling of grayscale input and output? 1035 1036**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 1038 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 1040 1041 1042**Q2.10**:Why does ROP code of RK3399 run on RV1126 without corresponding results? 1043 1044**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 1046 1047 1048**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 1050 Expectations: 1051 1052  1053 1054 Actual result: 1055 1056  1057 1058**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 1060 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 1062 The rga module source code update package can be obtained through Baidu Netdisk: https://eyun.baidu.com/s/3i6sbsDR 1063 1064 1065 1066**Q2.12**:How does RGA implement OSD overlay subtitle? 1067 1068 Expectations: 1069 1070  1071 1072**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 1074 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 1076 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 1078 Can view sample code: 1079 1080**<librga_souce_path>/samples/alpha_demo/src/rga_alpha_osd_demo.cpp\**** 1081 1082**<librga_souce_path>/samples/alpha_demo/src/rga_alpha_yuv_demo.cpp\**** 1083 1084 1085 1086**Q2.13**:Why brightness or numerical difference exists when RGA is called to implement YUV and RGB format conversion? 1087 1088**A2.13**:The reasons can be roughly divided into two kinds: 1089 1090 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 1092 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 1094 1095 1096**Q2.14**:How to configure the color space for format conversion in librga? 1097 1098**A2.14**:Both versions of librga support configuring the color space for format conversion. 1099 1100 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 1102 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 1104| Format Conversion | Color Space | Parameters | 1105| -------- | ------------------ | ------------------------ | 1106| YUV2RGB | BT.601-limit_range | yuvToRgbMode = 0x1 << 0; | 1107| YUV2RGB | BT.601-full_range | yuvToRgbMode = 0x2 << 0; | 1108| YUV2RGB | BT.709-limit_range | yuvToRgbMode = 0x3 << 0; | 1109| RGB2YUV | BT.601-limit_range | yuvToRgbMode = 0x2 << 4; | 1110| RGB2YUV | BT.601-full_range | yuvToRgbMode = 0x1 << 4; | 1111| RGB2YUV | BT.709-limit_range | yuvToRgbMode = 0x3 << 4; | 1112 1113 1114 1115**Q2.15**:Why does calling RGA to perform alpha overlay have no effect? 1116 1117**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 1119 1120 1121**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 1123 Foreground Image:(Black and white and rockchip alpha is 0x00) 1124 1125  1126 1127 Expectations: 1128 1129  1130 1131 Actual Results: 1132 1133  1134 1135 1136 1137**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 1139 1140 1141**Q2.17**:Can the IM2D API implement multiple functions in one RGA call? 1142 1143**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 1145 1146 1147**Q2.18**:When RGA is called to perform image rotation, the output image is stretched? 1148 1149 Expectations: 1150 1151  1152 1153 Actual Result: 1154 1155  1156 1157**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 1159 1160 1161**Q2.19**:RGB888 output scaling results show that the image is slanted and has black lines? 1162 1163 Input(1920 × 1080): 1164 1165  1166 1167 Output(1282 × 720): 1168 1169  1170 1171**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 1173 1174 1175**Q2.20**:What cause the error that in some system processes, the output of RGA is fuzzy? 1176 1177**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 1179 1180 1181**A2.21**:Small black or green stripes appear after calling RGA to process the image. What is the reason? 1182 1183  1184 1185**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 1187 1188 1189### HAL Error 1190 1191#### IM2D_API Error 1192 1193**Q3.1.1**: How to deal with the error of imcheck()? 1194 1195``` 1196check 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) 1197output support format : RGBA_8888 RGB_888 RGB_565 RGBA_4444 RGBA_5551 YUV420/YUV422 YUV420_10bit/YUV422_10bit YUYV420 YUYV422 YUV400/Y4 1198``` 1199 1200**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 1202 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 1204 1205 1206**Q3.1.2**:What is the error with the imstrError() error prompt that there are no specific parameters to print instructions? 1207 1208``` 1209Fatal error: Failed to call RockChipRga interface, please use 'dmesg' command to view driver error log. 1210``` 1211 1212**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 1214 1215 1216 1217#### RockchipRga API Error 1218 1219**Q3.2.1**:How to deal with the error “Try to use uninit rgaCtx=(nil)”? 1220 1221**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 1223 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 1225 1226 1227**Q3.2.2**:What causes the error“RgaBlit(1027) RGA_BLIT fail: ”、“RGA_COLORFILL(1027) RGA_BLIT fail: ”? 1228 1229**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 1231 **Q3.2.2.1**:“RgaBlit(1027) RGA_BLIT fail: Not a typewriter”? 1232 1233 **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 1235 1236 **Q3.2.2.2**:“RgaBlit(1349) RGA_BLIT fail: Bad file descriptor”? 1237 1238 **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 1240 1241 **Q3.2.2.3**:“RgaBlit(1360) RGA_BLIT fail: Bad address”? 1242 1243 **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 1245 **Q3.2.2.4**:“RgaBlit(1466) RGA BIIT fail: Invalid argument” 1246 1247 **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 1249 1250 1251**Q3.2.3**:What cause the log error “err ws[100,1280,1280]”、”Error srcRect“? 1252 1253**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 1255 After this error occurs, the following parameters are printed in logcat: 1256 1257```C++ 1258E librga : err ws[100,1280,1280] //Represent the width stride error. 1259E librga : [RgaBlit,731]Error srcRect //Represent the src channel error. 1260E rockchiprga: fd-vir-phy-hnd-format[0, 0xb400006eb6ea9040, 0x0, 0x0, 0] //Input address (fd, virtual address, physical address, handle) of corresponding src channel. 1261E 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. 1262E rockchiprga: f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1] //Represents the mode configuration in the call. 1263E rockchiprga: fd-vir-phy-hnd-format[0, 0xb400006eb2ea6040, 0x0, 0x0, 0] //Parameters of corresponding dst channel. 1264E rockchiprga: rect[0, 0, 1920, 1080, 1920, 1080, 1, 0] 1265E rockchiprga: f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1] 1266E rockchiprga: This output the user parameters when rga call blit fail //Error information. 1267``` 1268 1269 1270 1271### Kernel Errors 1272 1273**Q4.1**:What causes the error “RGA2 failed to get vma, result = 32769, pageCount = 65537”? 1274 1275**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 1277 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 1279 1280 1281**Q4.2**:What causes the error ”rga2_reg_init, [868] set mmu info error“? 1282 1283**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 1285 1286 1287**Q4.3**:Error “rga:dma_buf_get fail fd[328]“ usually refers to what exception occurs in the buffer? 1288 1289**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 1291 1292 1293**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 1295**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 1297 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 1299``` 1300(1) drm buffer application options add ROCKCHIP_BO_ALLOC_KMAP definition. 1301+ /* keep kmap for cma buffer or alloc kmap for other type memory */ 1302+ ROCKCHIP_BO_ALLOC_KMAP = 1 << 4, 1303(2) When applying for drm memory, add drm buffer option ROCKCHIP_BO_ALLOC_KMAP. 1304 struct drm_mode_create_dumb arg; 1305 ... 1306- arg.flags = ROCKCHIP_BO_CONTIG; 1307+ arg.flags = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_ALLOC_KMAP; //ROCKCHIP_BO_ALLOC_KMAP is valid only when used together with ROCKCHIP_BO_CONTIG. 1308 ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); 1309``` 1310 1311 And confirm whether the kernel contains the following submission, if not, please update SDK: 1312 1313``` 1314commit 1a81ee3e2d3726b9382ff2c48d08f4d837bc0143 1315Author: Sandy Huang <hjc@rock-chips.com> 1316Date: Mon May 10 16:52:04 2021 +0800 1317 1318 drm/rockchip: gem: add flag ROCKCHIP_BO_ALLOC_KMAP to assign kmap 1319 1320 RGA need to access CMA buffer at kernel space, so add this flag to keep kernel 1321 line mapping for RGA. 1322 1323 Change-Id: Ia59acee3c904a495792229a80c42f74ae34200e3 1324 Signed-off-by: Sandy Huang <hjc@rock-chips.com> 1325``` 1326 1327 1328 1329**Q4.5**: How to solve the "RGA_MMU unsupported Memory larger than 4G!" error? 1330 1331**A4.5**: This error usually corresponds to the HAL layer error: 1332 1333``` 1334RgaBlit(1483) RGA_BLIT fail: Invalid argument 1335Failed to call RockChipRga interface, please use 'dmesg' command to view driver error log. 1336``` 1337 1338This 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 1340When this error occurs, there are usually the following scenarios and corresponding solutions: 1341 13421. 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 1344 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 13462. 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 1348 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 1350 Common ways to allocate 4G memory can be viewed in the following sample code: 1351 1352 **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_dma32_demo.cpp** 1353 1354 **<librga_souce_path>/samples/allocator_demo/src/rga_allocator_graphicbuffer_demo.cpp** 1355 1356 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 13583. On chip platforms that only carry one RGA (such as RK3399, RK3568, and Rk3566 that only carry RGA2): 1359 1360 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 1362 1363 1364**Q4.6**: What is the cause of the "rga_policy: invalid function policy" and "rga_job: job assign failed" errors? 1365 1366**A4.6**: You can open the driver operation log to view the specific error reasons 1367 1368For example: 1369 1370``` 1371rga_policy: start policy on core = 4 1372rga_policy: RGA2 only support under 4G memory! //Indicates that the current RGA2 core only supports memory within 4G. 1373rga_policy: optional_cores = 0 1374rga_policy: invalid function policy 1375rga_policy: assign core: -1 1376rga_job: job assign failed 1377``` 1378 1379``` 1380rga_policy: start policy on core = 1 1381rga_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) 1382rga_policy: start policy on core = 2 1383rga_policy: core = 2, break on rga_check_dst //Corresponding to the log of reasons not supported by the core, same as above. 1384rga_policy: start policy on core = 4 1385rga_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 rga_policy: optional_cores = 0 1387rga_policy: invalid function policy 1388rga_policy: assign core: -1 // After traversing all cores, if there is no matching core, a matching failure error will be reported. 1389rga_job: job assign failed 1390``` 1391 1392In the above two cases, you can confirm the configured parameter information according to the corresponding logs, and make targeted modifications. 1393 1394 1395 1396**Q4.7**:What causes the error “rga:Rga err irq! INT[701],STATS[1]”? 1397 1398**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 1400 1401 1402**Q4.8**:What causes the error “rga: Rga sync pid 1001 wait 1 task done timeout”? 1403 1404**A4.8**:There are many reasons for the hardware timeout error. You can rectify the fault as follows: 1405 1406 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 1408 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 1410 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 1412 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 1414 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 1416 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 1418 1419 1420**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 1422**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 1424 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.