From 64fb5f85f6bdee2e7e9f80c84bca130be5bfa1e2 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 8 Oct 2025 01:04:34 +0400 Subject: [PATCH 1/2] [Jetson.GPIO] Update to 2.1.12 Closes: #14820 --- .../Jetson.GPIO/@tests/stubtest_allowlist.txt | 7 ++++-- stubs/Jetson.GPIO/Jetson/GPIO/constants.pyi | 22 ++++++++++++++++ stubs/Jetson.GPIO/Jetson/GPIO/gpio.pyi | 23 ++--------------- stubs/Jetson.GPIO/Jetson/GPIO/gpio_cdev.pyi | 11 ++++++++ .../Jetson.GPIO/Jetson/GPIO/gpio_pin_data.pyi | 25 ++++++++++++++++--- .../Jetson/GPIO/gpio_pinmux_lookup.pyi | 6 +++++ stubs/Jetson.GPIO/METADATA.toml | 2 +- 7 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 stubs/Jetson.GPIO/Jetson/GPIO/constants.pyi create mode 100644 stubs/Jetson.GPIO/Jetson/GPIO/gpio_pinmux_lookup.pyi diff --git a/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt b/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt index fffd609ed207..e52f5a0344b2 100644 --- a/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt +++ b/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt @@ -1,10 +1,13 @@ # The high level module can only be imported on a Jetson SBC -Jetson.GPIO # error: Jetson.GPIO failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. +Jetson.GPIO -Jetson.GPIO.gpio # error: Jetson.GPIO.gpio failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. +Jetson.GPIO.gpio + +# error: Jetson.GPIO.gpio_pinmux_lookup failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. +Jetson.GPIO.gpio_pinmux_lookup # This builtin error doesn't need to be re-exported Jetson.GPIO.gpio_event.InterruptedError diff --git a/stubs/Jetson.GPIO/Jetson/GPIO/constants.pyi b/stubs/Jetson.GPIO/Jetson/GPIO/constants.pyi new file mode 100644 index 000000000000..8de69f455183 --- /dev/null +++ b/stubs/Jetson.GPIO/Jetson/GPIO/constants.pyi @@ -0,0 +1,22 @@ +from typing import Final + +BOARD: Final = 10 +BCM: Final = 11 +TEGRA_SOC: Final = 1000 +CVM: Final = 1001 + +PUD_OFF: Final = 20 +PUD_DOWN: Final = 21 +PUD_UP: Final = 22 + +HIGH: Final = 1 +LOW: Final = 0 + +RISING: Final = 31 +FALLING: Final = 32 +BOTH: Final = 33 + +UNKNOWN: Final = -1 +OUT: Final = 0 +IN: Final = 1 +HARD_PWM: Final = 43 diff --git a/stubs/Jetson.GPIO/Jetson/GPIO/gpio.pyi b/stubs/Jetson.GPIO/Jetson/GPIO/gpio.pyi index f8c8047720c6..902334cf2eb4 100644 --- a/stubs/Jetson.GPIO/Jetson/GPIO/gpio.pyi +++ b/stubs/Jetson.GPIO/Jetson/GPIO/gpio.pyi @@ -1,26 +1,7 @@ from collections.abc import Callable, Sequence -from typing import Final, Literal +from typing import Literal -BOARD: Final = 10 -BCM: Final = 11 -TEGRA_SOC: Final = 1000 -CVM: Final = 1001 - -PUD_OFF: Final = 20 -PUD_DOWN: Final = 21 -PUD_UP: Final = 22 - -HIGH: Final = 1 -LOW: Final = 0 - -RISING: Final = 31 -FALLING: Final = 32 -BOTH: Final = 33 - -UNKNOWN: Final = -1 -OUT: Final = 0 -IN: Final = 1 -HARD_PWM: Final = 43 +from .constants import * model = ... JETSON_INFO = ... diff --git a/stubs/Jetson.GPIO/Jetson/GPIO/gpio_cdev.pyi b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_cdev.pyi index 463fc462e6a7..5965fc2d2c20 100644 --- a/stubs/Jetson.GPIO/Jetson/GPIO/gpio_cdev.pyi +++ b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_cdev.pyi @@ -1,4 +1,5 @@ import ctypes +from dataclasses import dataclass from typing import Final, Literal from .gpio_pin_data import ChannelInfo @@ -70,3 +71,13 @@ def request_handle(line_offset: int, direction: Literal[0, 1], initial: Literal[ def request_event(line_offset: int, edge: int, consumer: str) -> gpioevent_request: ... def get_value(line_handle: int) -> int: ... def set_value(line_handle: int, value: int) -> None: ... +@dataclass +class PadCtlRegister: + is_gpio: bool + is_input: bool + is_tristate: bool + def __init__(self, value: int) -> None: ... + @property + def is_bidi(self) -> bool: ... + +def check_pinmux(ch_info: ChannelInfo, direction: int) -> None: ... diff --git a/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pin_data.pyi b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pin_data.pyi index 07c4707ac1ef..364e5ce79838 100644 --- a/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pin_data.pyi +++ b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pin_data.pyi @@ -15,11 +15,11 @@ JETSON_THOR_REFERENCE: Final = "JETSON_THOR_REFERENCE" JETSON_MODELS: list[str] -JETSON_ORIN_NX_PIN_DEFS: list[tuple[int, str, str, int, int, str, str, str | None, int | None]] +JETSON_ORIN_NX_PIN_DEFS: list[tuple[int, str, str, int, int, str, str, str | None, int | None, int]] compats_jetson_orins_nx: Sequence[str] compats_jetson_orins_nano: Sequence[str] -JETSON_ORIN_PIN_DEFS: list[tuple[int, str, str, int, int, str, str, str | None, int | None]] +JETSON_ORIN_PIN_DEFS: list[tuple[int, str, str, int, int, str, str, str | None, int | None, int]] compats_jetson_orins: Sequence[str] CLARA_AGX_XAVIER_PIN_DEFS: list[tuple[int, str, str, int, int, str, str, str | None, int | None]] @@ -49,8 +49,27 @@ compats_jetson_thor_reference: Sequence[str] jetson_gpio_data: dict[str, tuple[list[tuple[int, str, str, int, int, str, str, str | None, int | None]], dict[str, Any]]] class ChannelInfo: + channel: int + chip_fd: int | None + line_handle: int | None + line_offset: int + direction: int | None + edge: int | None + consumer: str + gpio_name: str + gpio_chip: str + pwm_chip_dir: str + pwm_id: int + reg_addr: int | None def __init__( - self, channel: int, line_offset: int, gpio_name: str, gpio_chip: str, pwm_chip_dir: str, pwm_id: int + self, + channel: int, + line_offset: int, + gpio_name: str, + gpio_chip: str, + pwm_chip_dir: str, + pwm_id: int, + reg_addr: int | None = None, ) -> None: ... ids_warned: bool diff --git a/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pinmux_lookup.pyi b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pinmux_lookup.pyi new file mode 100644 index 000000000000..1cffa0bf2012 --- /dev/null +++ b/stubs/Jetson.GPIO/Jetson/GPIO/gpio_pinmux_lookup.pyi @@ -0,0 +1,6 @@ +from collections.abc import Iterable + +def lookup_mux_register( + gpio_pin: int, pin_defs: Iterable[tuple[int, str, str, int, int, str, str, str | None, int | None, int]] +) -> int: ... +def main() -> None: ... diff --git a/stubs/Jetson.GPIO/METADATA.toml b/stubs/Jetson.GPIO/METADATA.toml index 7a43272e13a4..b353483b67af 100644 --- a/stubs/Jetson.GPIO/METADATA.toml +++ b/stubs/Jetson.GPIO/METADATA.toml @@ -1,2 +1,2 @@ -version = "2.1.11" +version = "2.1.12" upstream_repository = "https://github.com/NVIDIA/jetson-gpio" From 4988d2f60a863fee0fb94f410c55110f32e89353 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 8 Oct 2025 18:59:39 +0400 Subject: [PATCH 2/2] Update comment --- stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt b/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt index e52f5a0344b2..0349b7eb0656 100644 --- a/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt +++ b/stubs/Jetson.GPIO/@tests/stubtest_allowlist.txt @@ -1,12 +1,8 @@ -# The high level module can only be imported on a Jetson SBC - -# error: Jetson.GPIO failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. +# stubtest produces false positives for Jetson.GPIO-related modules in CI +# The high-level Jetson.GPIO library can only be imported on Jetson SBC, +# and requires specific system permissions (/dev/gpiochip0 access). Jetson.GPIO - -# error: Jetson.GPIO.gpio failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. Jetson.GPIO.gpio - -# error: Jetson.GPIO.gpio_pinmux_lookup failed to import. RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this. It is also possible that /dev/gpiochip0 does not exist. Please check if that file is present. Jetson.GPIO.gpio_pinmux_lookup # This builtin error doesn't need to be re-exported