From 318133d0fa37c0f11ca68252b98992f958fab23d Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:29:36 +0000 Subject: [PATCH 1/3] Clean up RK3326 & RK3399 sleep vars --- .../quirks/devices/Anbernic RG552/sleep.d/pre/002-freq | 4 ++-- .../hardware/quirks/platforms/RK3326/sleep.d/pre/002-freq | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/hardware/quirks/devices/Anbernic RG552/sleep.d/pre/002-freq b/packages/hardware/quirks/devices/Anbernic RG552/sleep.d/pre/002-freq index 9e66aefa2..64d15b20e 100644 --- a/packages/hardware/quirks/devices/Anbernic RG552/sleep.d/pre/002-freq +++ b/packages/hardware/quirks/devices/Anbernic RG552/sleep.d/pre/002-freq @@ -7,8 +7,8 @@ . /etc/profile ### Get the current cpu and gpu governor, save for when the device wakes from sleep. -CUR_CPU_FREQ="$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor)" -CUR_GPU_FREQ="$(cat /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/governor)" +CUR_CPU_FREQ="$(cat ${CPU_FREQ}/scaling_governor)" +CUR_GPU_FREQ="$(cat ${GPU_FREQ}/governor)" set_setting sleep.cpugovernor "${CUR_CPU_FREQ}" set_setting sleep.gpugovernor "${CUR_GPU_FREQ}" diff --git a/packages/hardware/quirks/platforms/RK3326/sleep.d/pre/002-freq b/packages/hardware/quirks/platforms/RK3326/sleep.d/pre/002-freq index 9fcc29bd9..4fbe8c64f 100644 --- a/packages/hardware/quirks/platforms/RK3326/sleep.d/pre/002-freq +++ b/packages/hardware/quirks/platforms/RK3326/sleep.d/pre/002-freq @@ -7,8 +7,8 @@ . /etc/profile ### Get the current cpu and gpu governor, save for when the device wakes from sleep. -CUR_CPU_FREQ="$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor)" -CUR_GPU_FREQ="$(cat /sys/devices/platform/ff400000.gpu/devfreq/ff400000.gpu/governor)" +CUR_CPU_FREQ="$(cat ${CPU_FREQ}/scaling_governor)" +CUR_GPU_FREQ="$(cat ${GPU_FREQ}/governor)" set_setting sleep.cpugovernor "${CUR_CPU_FREQ}" set_setting sleep.gpugovernor "${CUR_GPU_FREQ}" From 444bfdbab60fd82304f4f0a55a84f63c1bfb5d63 Mon Sep 17 00:00:00 2001 From: fewtarius Date: Sat, 30 Dec 2023 21:02:14 +0000 Subject: [PATCH 2/3] Add a guard to set_epp so it isn't executed on devices that don't have it available. --- packages/jelos/sources/scripts/runemu.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/jelos/sources/scripts/runemu.sh b/packages/jelos/sources/scripts/runemu.sh index 103a7580b..c9536ef5a 100755 --- a/packages/jelos/sources/scripts/runemu.sh +++ b/packages/jelos/sources/scripts/runemu.sh @@ -336,11 +336,14 @@ case ${CPU_VENDOR} in esac ### Apply energy performance preference -EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}") -if [ ! -z ${EPP} ] +if [ -e "/usr/bin/set_epp" ] then - ${VERBOSE} && log $0 "Set EPP to (${EPP})" - /usr/bin/set_epp ${EPP} + EPP=$(get_setting "power.epp" "${PLATFORM}" "${ROMNAME##*/}") + if [ ! -z ${EPP} ] + then + ${VERBOSE} && log $0 "Set EPP to (${EPP})" + /usr/bin/set_epp ${EPP} + fi fi ### Configure GPU performance mode From 8b873a06c0674fc6516db11100c3049860836032 Mon Sep 17 00:00:00 2001 From: fewtarius Date: Mon, 1 Jan 2024 11:38:19 +0000 Subject: [PATCH 3/3] Add invert-abs patches, update kernel to RC8. --- projects/Rockchip/packages/linux/package.mk | 2 +- .../RK3566/008-invert-abs-helper.patch | 71 +++++++++++++++++ .../linux/patches/RK3566/009-invert-abs.patch | 77 +++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 projects/Rockchip/packages/linux/patches/RK3566/008-invert-abs-helper.patch create mode 100644 projects/Rockchip/packages/linux/patches/RK3566/009-invert-abs.patch diff --git a/projects/Rockchip/packages/linux/package.mk b/projects/Rockchip/packages/linux/package.mk index 0b5346c9f..e340fdb52 100644 --- a/projects/Rockchip/packages/linux/package.mk +++ b/projects/Rockchip/packages/linux/package.mk @@ -24,7 +24,7 @@ case ${DEVICE} in PKG_GIT_CLONE_BRANCH="main" ;; RK356*) - PKG_VERSION="6.7-rc7" + PKG_VERSION="6.7-rc8" PKG_URL="https://git.kernel.org/torvalds/t/${PKG_NAME}-${PKG_VERSION}.tar.gz" ;; RK33*) diff --git a/projects/Rockchip/packages/linux/patches/RK3566/008-invert-abs-helper.patch b/projects/Rockchip/packages/linux/patches/RK3566/008-invert-abs-helper.patch new file mode 100644 index 000000000..afb829f4a --- /dev/null +++ b/projects/Rockchip/packages/linux/patches/RK3566/008-invert-abs-helper.patch @@ -0,0 +1,71 @@ +From: Chris Morgan +To: linux-input@vger.kernel.org +Cc: dmitry.torokhov@gmail.com, hdegoede@redhat.com, + paul@crapouillou.net, peter.hutterer@who-t.net, svv@google.com, + biswarupp@google.com, contact@artur-rojek.eu, + Chris Morgan +Subject: [PATCH 1/2] Input: add input_invert_abs() +Date: Sun, 31 Dec 2023 14:56:42 -0600 [thread overview] +Message-ID: <20231231205643.129435-2-macroalpha82@gmail.com> (raw) +In-Reply-To: <20231231205643.129435-1-macroalpha82@gmail.com> + +From: Chris Morgan + +Add a helper function to make it easier for a driver to invert abs +values when needed. It is up to the driver itself to track axes that +need to be inverted and normalize the data before it is passed on. + +This function assumes that drivers will set the min and max values +so that min < max and then will simply call this function each time +the values need to be inverted. + +Signed-off-by: Chris Morgan +--- + drivers/input/input.c | 19 +++++++++++++++++++ + include/linux/input.h | 1 + + 2 files changed, 20 insertions(+) + +diff --git a/drivers/input/input.c b/drivers/input/input.c +index 8c5fdb0f858a..f135aed165a1 100644 +--- a/drivers/input/input.c ++++ b/drivers/input/input.c +@@ -552,6 +552,25 @@ void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, + } + EXPORT_SYMBOL(input_copy_abs); + ++/** ++ * input_invert_abs - Invert the abs value for an inverted axis. ++ * @dev: Input device with absolute events ++ * @axis: ABS_* value selecting the destination axis for the event to ++ * invert. ++ * @val: Value to be inverted based on min and max values of the axis. ++ * ++ * Return an inverted value for a given ABS axis based on its min and ++ * max values. ++ */ ++int input_invert_abs(struct input_dev *dev, unsigned int axis, int val) ++{ ++ int min = dev->absinfo[axis].minimum; ++ int max = dev->absinfo[axis].maximum; ++ ++ return (max + min) - val; ++} ++EXPORT_SYMBOL(input_invert_abs); ++ + /** + * input_grab_device - grabs device for exclusive use + * @handle: input handle that wants to own the device +diff --git a/include/linux/input.h b/include/linux/input.h +index de6503c0edb8..deb5f8bb0ec7 100644 +--- a/include/linux/input.h ++++ b/include/linux/input.h +@@ -477,6 +477,7 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis, + int min, int max, int fuzz, int flat); + void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, + const struct input_dev *src, unsigned int src_axis); ++int input_invert_abs(struct input_dev *dev, unsigned int axis, int val); + + #define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \ + static inline int input_abs_get_##_suffix(struct input_dev *dev, \ +-- +2.34.1 diff --git a/projects/Rockchip/packages/linux/patches/RK3566/009-invert-abs.patch b/projects/Rockchip/packages/linux/patches/RK3566/009-invert-abs.patch new file mode 100644 index 000000000..5635651a1 --- /dev/null +++ b/projects/Rockchip/packages/linux/patches/RK3566/009-invert-abs.patch @@ -0,0 +1,77 @@ +From: Chris Morgan +To: linux-input@vger.kernel.org +Cc: dmitry.torokhov@gmail.com, hdegoede@redhat.com, + paul@crapouillou.net, peter.hutterer@who-t.net, svv@google.com, + biswarupp@google.com, contact@artur-rojek.eu, + Chris Morgan +Subject: [PATCH 2/2] Input: adc-joystick: Handle inverted axes +Date: Sun, 31 Dec 2023 14:56:43 -0600 [thread overview] +Message-ID: <20231231205643.129435-3-macroalpha82@gmail.com> (raw) +In-Reply-To: <20231231205643.129435-1-macroalpha82@gmail.com> + +From: Chris Morgan + +When one or more axes are inverted, (where min > max), normalize the +data so that min < max and call a helper function to invert the +values reported to the input stack. + +This ensures we can continue defining the device correctly in the +device tree while not breaking downstream assumptions that min is +always less than max. + +Signed-off-by: Chris Morgan +--- + drivers/input/joystick/adc-joystick.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c +index c0deff5d4282..4e8d446987b6 100644 +--- a/drivers/input/joystick/adc-joystick.c ++++ b/drivers/input/joystick/adc-joystick.c +@@ -18,6 +18,7 @@ struct adc_joystick_axis { + s32 range[2]; + s32 fuzz; + s32 flat; ++ bool inverted; + }; + + struct adc_joystick { +@@ -38,6 +39,8 @@ static void adc_joystick_poll(struct input_dev *input) + ret = iio_read_channel_raw(&joy->chans[i], &val); + if (ret < 0) + return; ++ if (joy->axes[i].inverted) ++ val = input_invert_abs(input, i, val); + input_report_abs(input, joy->axes[i].code, val); + } + input_sync(input); +@@ -86,6 +89,8 @@ static int adc_joystick_handle(const void *data, void *private) + val = sign_extend32(val, msb); + else + val &= GENMASK(msb, 0); ++ if (joy->axes[i].inverted) ++ val = input_invert_abs(joy->input, i, val); + input_report_abs(joy->input, joy->axes[i].code, val); + } + +@@ -168,11 +173,17 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) + goto err_fwnode_put; + } + ++ if (axes[i].range[0] > axes[i].range[1]) { ++ dev_dbg(dev, "abs-axis %d inverted\n", i); ++ axes[i].inverted = 1; ++ } ++ + fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz); + fwnode_property_read_u32(child, "abs-flat", &axes[i].flat); + + input_set_abs_params(joy->input, axes[i].code, +- axes[i].range[0], axes[i].range[1], ++ min_array(axes[i].range, 2), ++ max_array(axes[i].range, 2), + axes[i].fuzz, axes[i].flat); + input_set_capability(joy->input, EV_ABS, axes[i].code); + } +-- +2.34.1