-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libgpiod allows for checking and setting different GPIO pins in the device, if kernel is new enough and GPIO_CDEV is enabled in the kernel config.
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
TERMUX_PKG_HOMEPAGE=https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git | ||
TERMUX_PKG_DESCRIPTION="C library and tools for interacting with the GPIO character device. Requires kernel v4.6 or higher" | ||
TERMUX_PKG_LICENSE="LGPL-2.1" | ||
TERMUX_PKG_MAINTAINER="@termux" | ||
TERMUX_PKG_VERSION=2.2 | ||
TERMUX_PKG_SRCURL="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-${TERMUX_PKG_VERSION}.tar.gz" | ||
TERMUX_PKG_SHA256=ae35329db7027c740e90c883baf27c26311f0614e6a7b115771b28188b992aec | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" | ||
--enable-tools=yes | ||
ac_cv_func_versionsort=yes | ||
" | ||
|
||
termux_step_pre_configure() { | ||
autoreconf -vfi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TERMUX_SUBPKG_DESCRIPTION="Tools for interacting with Linux GPIO character device" | ||
TERMUX_SUBPKG_INCLUDE=" | ||
bin/* | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- ./tools/tools-common.c~ 2024-10-22 08:57:17.000000000 +0000 | ||
+++ ./tools/tools-common.c 2024-12-24 10:09:30.231824790 +0000 | ||
@@ -476,6 +476,42 @@ | ||
return 1; | ||
} | ||
|
||
+int strverscmp(const char *l0, const char *r0) | ||
+{ | ||
+ const unsigned char *l = (const void *)l0; | ||
+ const unsigned char *r = (const void *)r0; | ||
+ size_t i, dp, j; | ||
+ int z = 1; | ||
+ | ||
+ /* Find maximal matching prefix and track its maximal digit | ||
+ * suffix and whether those digits are all zeros. */ | ||
+ for (dp=i=0; l[i]==r[i]; i++) { | ||
+ int c = l[i]; | ||
+ if (!c) return 0; | ||
+ if (!isdigit(c)) dp=i+1, z=1; | ||
+ else if (c!='0') z=0; | ||
+ } | ||
+ | ||
+ if (l[dp]!='0' && r[dp]!='0') { | ||
+ /* If we're not looking at a digit sequence that began | ||
+ * with a zero, longest digit string is greater. */ | ||
+ for (j=i; isdigit(l[j]); j++) | ||
+ if (!isdigit(r[j])) return 1; | ||
+ if (isdigit(r[j])) return -1; | ||
+ } else if (z && dp<i && (isdigit(l[i]) || isdigit(r[i]))) { | ||
+ /* Otherwise, if common prefix of digit sequence is | ||
+ * all zeros, digits order less than non-digits. */ | ||
+ return (unsigned char)(l[i]-'0') - (unsigned char)(r[i]-'0'); | ||
+ } | ||
+ | ||
+ return l[i] - r[i]; | ||
+} | ||
+ | ||
+static int versionsort(const struct dirent **a, const struct dirent **b) | ||
+{ | ||
+ return strverscmp((*a)->d_name, (*b)->d_name); | ||
+} | ||
+ | ||
int all_chip_paths(char ***paths_ptr) | ||
{ | ||
int i, j, num_chips, ret = 0; |