Github messages for voidlinux
 help / color / mirror / Atom feed
* Re: [PR PATCH] [Updated] New package: librga-4.0.0_1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23273@inbox.vuxu.org>
@ 2020-08-28 23:17 ` valadaa48
  0 siblings, 0 replies; only message in thread
From: valadaa48 @ 2020-08-28 23:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

There is an updated pull request by valadaa48 against master on the void-packages repository

https://github.com/valadaa48/void-packages librga
https://github.com/void-linux/void-packages/pull/23273

New package: librga-4.0.0_1
This provides userland access to the Rockchip Graphics Acceleration unit used on some odroid devices. This chip provides hardware accelerated raster operations such as scaling and rotation.

A patch file from https://github.com/void-linux/void-packages/pull/23273.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-librga-23273.patch --]
[-- Type: text/x-diff, Size: 9713 bytes --]

From b8f9184c441b5914b03da6ba717bebd93d23cd64 Mon Sep 17 00:00:00 2001
From: valadaa48 <valadaa48@gmx.com>
Date: Sat, 27 Jun 2020 15:14:16 -0400
Subject: [PATCH] New package: librga-4.0.0_1

---
 common/shlibs                     |   1 +
 srcpkgs/librga-devel              |   1 +
 srcpkgs/librga/files/50-rga.rules |   1 +
 srcpkgs/librga/patches/opt.patch  | 207 ++++++++++++++++++++++++++++++
 srcpkgs/librga/template           |  36 ++++++
 5 files changed, 246 insertions(+)
 create mode 120000 srcpkgs/librga-devel
 create mode 100644 srcpkgs/librga/files/50-rga.rules
 create mode 100644 srcpkgs/librga/patches/opt.patch
 create mode 100644 srcpkgs/librga/template

diff --git a/common/shlibs b/common/shlibs
index 4ee9b8a8e32..73f94052d09 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3981,3 +3981,4 @@ libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libtdjson.so.1.6.0 libtd-1.6.0_1
 libJudy.so.1 judy-1.0.5_1
+librga.so librga-4.0.0_1
diff --git a/srcpkgs/librga-devel b/srcpkgs/librga-devel
new file mode 120000
index 00000000000..0409dc3afcc
--- /dev/null
+++ b/srcpkgs/librga-devel
@@ -0,0 +1 @@
+librga
\ No newline at end of file
diff --git a/srcpkgs/librga/files/50-rga.rules b/srcpkgs/librga/files/50-rga.rules
new file mode 100644
index 00000000000..4d1a077b135
--- /dev/null
+++ b/srcpkgs/librga/files/50-rga.rules
@@ -0,0 +1 @@
+KERNEL=="rga", GROUP="video", MODE="0660"
diff --git a/srcpkgs/librga/patches/opt.patch b/srcpkgs/librga/patches/opt.patch
new file mode 100644
index 00000000000..a191b085814
--- /dev/null
+++ b/srcpkgs/librga/patches/opt.patch
@@ -0,0 +1,207 @@
+diff --git a/Makefile b/Makefile
+index 6266b2e..ff19a51 100644
+--- a/Makefile
++++ b/Makefile
+@@ -12,7 +12,7 @@
+ all:
+ 
+ # Some important on-off settings. You can not be too careful about them.
+-DEBUG       	:= y
++DEBUG :=
+ # Flag of generate a dynamic lib or a static lib: y means yes. If the target is a excutable file, it should be blank!
+ GEN_LIBS    	:= y
+ # Flag of generate a dynamic lib: y means yes. It should be blank unless you want to generate a dynamic lib!
+diff --git a/RockchipRga.cpp b/RockchipRga.cpp
+index 23bc22d..b244060 100644
+--- a/RockchipRga.cpp
++++ b/RockchipRga.cpp
+@@ -34,7 +34,6 @@
+ #include "xf86drm.h"
+ #endif
+ 
+-
+ // ---------------------------------------------------------------------------
+ 
+ RockchipRga::RockchipRga():
+@@ -137,12 +136,12 @@ int RockchipRga::RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int b
+     bo_info->fd = -1;
+     bo_info->handle = 0;
+     drm_fd = open(card, flag);
+-    if (drm_fd < 0) {
++    if (unlikely(drm_fd < 0)) {
+         fprintf(stderr, "Fail to open %s: %m\n", card);
+         return -errno;
+     }
+     ret = RkRgaAllocBuffer(drm_fd, bo_info, width, height, bpp);
+-    if (ret) {
++    if (likely(ret)) {
+         close(drm_fd);
+         return ret;
+     }
+@@ -160,10 +159,10 @@ int RockchipRga::RkRgaGetMmap(bo_t *bo_info)
+     memset(&arg, 0, sizeof(arg));
+     arg.handle = bo_info->handle;
+     ret = drmIoctl(bo_info->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+-    if (ret)
++    if (likely(ret))
+         return ret;
+     map = mmap64(0, bo_info->size, PROT_READ | PROT_WRITE, MAP_SHARED, bo_info->fd, arg.offset);
+-    if (map == MAP_FAILED)
++    if (unlikely(map == MAP_FAILED))
+        return -EINVAL;
+     bo_info->ptr = map;
+     return 0;
+@@ -205,7 +204,7 @@ int RockchipRga::RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ {
+     int ret = 0;
+     ret = RgaBlit(src, dst, src1);
+-    if (ret) {
++    if (unlikely(ret)) {
+         RkRgaLogOutUserPara(src);
+         RkRgaLogOutUserPara(dst);
+         RkRgaLogOutUserPara(src1);
+diff --git a/RockchipRga.h b/RockchipRga.h
+index 98cfff6..d6554af 100644
+--- a/RockchipRga.h
++++ b/RockchipRga.h
+@@ -31,6 +31,11 @@
+ 
+ #include "RockchipRgaMacro.h"
+ 
++#define likely(x)       __builtin_expect((x),1)
++#define unlikely(x)     __builtin_expect((x),0)
++
++
++
+ //////////////////////////////////////////////////////////////////////////////////
+ 
+ // -------------------------------------------------------------------------------
+diff --git a/normal/NormalRga.cpp b/normal/NormalRga.cpp
+index 0585527..4c75f4b 100644
+--- a/normal/NormalRga.cpp
++++ b/normal/NormalRga.cpp
+@@ -16,6 +16,10 @@
+ #include <sys/ioctl.h> 
+ //#include <cutils/properties.h>
+ 
++#define likely(x)       __builtin_expect((x),1)
++#define unlikely(x)     __builtin_expect((x),0)
++
++
+ volatile int32_t refCount = 0;
+ struct rgaContext *rgaCtx = NULL;
+ 
+@@ -169,7 +173,7 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 	void *src1Buf = NULL;
+ 	RECT_t clip;
+ 
+-	if (!ctx) {
++	if (unlikely(!ctx)) {
+ 		DEBUG("Try to use uninit rgaCtx=%p \n",ctx);
+ 		return -ENODEV;
+ 	}
+@@ -182,12 +186,12 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 	blend = 0;
+ 	yuvToRgbMode = 0;
+     
+-	if (!src && !dst && !src1) {
++	if (unlikely(!src && !dst && !src1)) {
+ 		DEBUG("src = %p, dst = %p, src1 = %p \n", src, dst, src1);
+ 		return -EINVAL;
+ 	}
+ 
+-	if (!src && !dst) {
++	if (unlikely(!src && !dst)) {
+ 		DEBUG("src = %p, dst = %p \n", src, dst);
+ 		return -EINVAL;
+ 	}
+@@ -253,12 +257,12 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 	//else if (src && src->hnd)
+ 		//ret = RkRgaGetHandleMapAddress(src->hnd, &srcBuf);
+ 
+-	if (srcFd == -1 && !srcBuf) {
++	if (unlikely(srcFd == -1 && !srcBuf)) {
+ 		DEBUG("%d:src has not fd and address for render \n", __LINE__);
+ 		return ret;
+ 	}
+ 
+-	if (srcFd == 0 && !srcBuf) {
++	if (unlikely(srcFd == 0 && !srcBuf)) {
+ 		DEBUG("srcFd is zero, now driver not support \n");
+ 		return -EINVAL;
+ 	}
+@@ -278,12 +282,12 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 	//else if (dst && dst->hnd)
+ 		//ret = RkRgaGetHandleMapAddress(dst->hnd, &dstBuf);
+     
+-	if (dst && dstFd == -1 && !dstBuf) {
++	if (unlikely(dst && dstFd == -1 && !dstBuf)) {
+ 		DEBUG("%d:dst has not fd and address for render \n", __LINE__);
+ 		return ret;
+ 	}
+ 
+-	if (dst && dstFd == 0 && !dstBuf) {
++	if (unlikely(dst && dstFd == 0 && !dstBuf)) {
+ 		DEBUG("dstFd is zero, now driver not support \n");
+ 		return -EINVAL;
+ 	}
+@@ -339,7 +343,7 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 
+ 	if (src) {
+ 		ret = checkRectForRga(relSrcRect);
+-		if (ret) {
++		if (unlikely(ret)) {
+ 			DEBUG("[%s,%d]Error srcRect \n", __func__, __LINE__);
+ 			return ret;
+ 		}
+@@ -347,7 +351,7 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 
+ 	if (dst) {
+ 		ret = checkRectForRga(relDstRect);
+-		if (ret) {
++		if (unlikely(ret)) {
+ 			DEBUG("[%s,%d]Error dstRect \n", __func__, __LINE__);
+ 			return ret;
+ 		}
+@@ -360,16 +364,16 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+ 			hScale = (float)relSrcRect.width / relDstRect.height;
+ 			vScale = (float)relSrcRect.height / relDstRect.width;
+ 		}
+-		if (hScale < 1/16 || hScale > 16 || vScale < 1/16 || vScale > 16) {
++		if (unlikely(hScale < 1/16 || hScale > 16 || vScale < 1/16 || vScale > 16)) {
+ 			DEBUG("Error scale[%f,%f] line %d \n", hScale, vScale, __LINE__);
+ 			return -EINVAL;
+ 		}
+-		if (ctx->mVersion < 2.0 && (hScale < 1/8 ||
+-					hScale > 8 || vScale < 1/8 || vScale > 8)) {
++		if (unlikely(ctx->mVersion < 2.0 && (hScale < 1/8 ||
++					hScale > 8 || vScale < 1/8 || vScale > 8))) {
+ 			DEBUG("Error scale[%f,%f] line %d \n", hScale, vScale, __LINE__);
+ 			return -EINVAL;
+ 		}
+-		if (ctx->mVersion <= 1.003 && (hScale < 1/2 || vScale < 1/2)) {
++		if (unlikely(ctx->mVersion <= 1.003 && (hScale < 1/2 || vScale < 1/2))) {
+ 			DEBUG("e scale[%f,%f] ver[%f] \n", hScale, vScale, ctx->mVersion);
+ 			return -EINVAL;
+ 		}
+@@ -686,7 +690,7 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1)
+     DEBUG("<<<<-------- rgaReg -------->>>>\n");
+ 	NormalRgaLogOutRgaReq(rgaReg);
+ 
+-	if(ioctl(ctx->rgaFd, RGA_BLIT_SYNC, &rgaReg)) {
++	if(unlikely(ioctl(ctx->rgaFd, RGA_BLIT_SYNC, &rgaReg))) {
+ 		DEBUG(" %s(%d) RGA_BLIT fail: %s \n",__FUNCTION__, __LINE__,strerror(errno));
+ 	}
+ 	return 0;
+diff --git a/normal/NormalRgaContext.h b/normal/NormalRgaContext.h
+index 458d470..6792795 100644
+--- a/normal/NormalRgaContext.h
++++ b/normal/NormalRgaContext.h
+@@ -17,6 +17,7 @@
+ #define __DEBUG 0
+ #if __DEBUG
+ #define DEBUG(format, ...)  printf(format, ##__VA_ARGS__)
++#error dont want debug
+ #else
+ #define DEBUG(format, ...)
+ #endif
diff --git a/srcpkgs/librga/template b/srcpkgs/librga/template
new file mode 100644
index 00000000000..6b438c044a7
--- /dev/null
+++ b/srcpkgs/librga/template
@@ -0,0 +1,36 @@
+# Template file for 'librga'
+pkgname=librga
+version=4.0.0
+revision=1
+_gitrev=87737c0b4425e2372086385de7fe9c54b9dbbace
+archs="aarch64 armv7*"
+wrksrc="linux-rga-${_gitrev}"
+build_style=gnu-makefile
+short_desc="Rockchip RGA rotation and scaling library"
+maintainer="valadaa48 <valadaa48@gmx.com>"
+license="GPL-2.0-or-later"
+homepage="https://github.com/rockchip-linux"
+distfiles="https://github.com/rockchip-linux/linux-rga/archive/${_gitrev}.tar.gz"
+checksum=48da521e4989bd4c511bb9c7bb99d2e447e1d14e621541555628c8afb2d8032a
+patch_args="-Np1"
+shlib_provides="librga.so"
+
+do_build() {
+	make PROJECT_DIR=.
+}
+
+do_install() {
+	vinstall lib/librga.so 755 usr/lib
+	vinstall ${FILESDIR}/50-rga.rules 644 usr/lib/udev/rules.d
+}
+
+librga-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vinstall drmrga.h 644 usr/include/rga
+		vinstall RgaApi.h 644 usr/include/rga
+		vinstall rga.h 644 usr/include/rga
+		vinstall RockchipRgaMacro.h 644 usr/include/rga
+	}
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-28 23:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23273@inbox.vuxu.org>
2020-08-28 23:17 ` [PR PATCH] [Updated] New package: librga-4.0.0_1 valadaa48

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).