X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Denis Benato <denis.benato@linux.dev>
Cc: LKML <linux-kernel@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org, linux-input@vger.kernel.org,
	kernel@lists.opengamingcollective.org,
	"Benjamin Tissoires" <bentiss@kernel.org>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Luke D . Jones" <luke@ljones.dev>,
	"Mateusz Schwartz" <matthew.schwartz@linux.dev>,
	"Denis Benato" <benato.denis96@gmail.com>,
	"Jonathan LoBue" <jlobue10@gmail.com>,
	"Khamunetri Clark" <khamunetriclark@gmail.com>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Joshua Leivenzon" <hacker1024@users.sourceforge.net>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Rebecca Mara Müller" <rebecca.mara@posteo.de>,
	"Ivan Levchenko" <me@livan.pro>,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>
Subject: Re: [PATCH v11 01/18] HID: asus: add support for ROG Ally handhelds
Date: Fri, 30 Oct 2026 15:56:01 +0200 (EET)	[thread overview]
Message-ID: <e78dc7ed-a23a-7f84-ce77-7aec3eee62ac@linux.intel.com> (raw)
In-Reply-To: <3791151b-8530-4c38-a9a5-77f415625116@linux.dev>

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

On Fri, 30 Oct 2026, Denis Benato wrote:

> 
> On 10/26/26 13:38, Ilpo Järvinen wrote:
> > On Sun, 25 Oct 2026, Denis Benato wrote:
> >
> >> Implement the core functionality for ASUS handhelds:
> >> - extend functionality of hid-asus if driver is enabled
> >> - initialise the device to a "ready" state
> >> - implement Ally X input mapping
> >> - emit a single proper event for AC button long press
> >> - reject probes from a different controller and from duplicated
> >>   interfaces of the same one, which could evict the shared state
> >>
> >> Signed-off-by: Khamunetri Clark <khamunetriclark@gmail.com>
> >> Signed-off-by: Denis Benato <denis.benato@linux.dev>
> >> Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> >> Signed-off-by: Luke Jones <luke@ljones.dev>
> >> Signed-off-by: Jonathan LoBue <jlobue10@gmail.com>
> > Shouldn't you be using some Co-developed-by tags too?

> >> +/**
> >> + * ally_gamepad_check_ready() - Wait for the gamepad MCU to report ready
> >> + * @ally: ally handheld structure
> >> + * @hdev: HID device
> >> + *
> >> + * This should be called before any remapping attempts, and on driver
> >> + * init/resume, after the asus handshake has been performed on the
> >> + * configuration endpoint.
> >> + *
> >> + * Return: 0 on success, negative errno on failure
> >> + */
> >> +static int ally_gamepad_check_ready(struct ally_handheld *ally, struct hid_device *hdev)
> >> +{
> >> +	u8 payload[] = { 0x00 };
> > = {} is enough to initialize.
> >
> >> +	int ret;
> >> +
> >> +	for (int i = 0; i < HID_ALLY_READY_MAX_TRIES; i++) {
> >> +		u8 *buf __free(kfree) = ally_alloc_cmd(CMD_CHECK_READY, payload, sizeof(payload));
> >> +		if (!buf)
> >> +			return -ENOMEM;
> >> +
> >> +		ret = ally_gamepad_send_receive_packet(ally, hdev, buf, ROG_ALLY_REPORT_SIZE);
> > ally_gamepad_send_packet()'s buf is const so why you need to alloc it over 
> > and over again?
> >
> > Arguably, I'm not sure if this retry loop is expected to execute many 
> > times.
> 
> no the used buffer is u8 *buf (non const) and it gets overwritten by the method
> with the MCU response.

Ah, yes the buf arg seems not const now that I double check. I must have 
accidently searched for some other function name which inputed const buf 
(e.g. old function name in the copy-paste buffer for some reason). I'm 
sorry about that.

> Since I am not sure if while not ready it can write other bytes I have opted to
> free it and reallocate it with correct data sice it is what gets sent and also
> what is returned.
> 
> Also yes, that cycle has to run many times to await for the MCU to come back:
> it has caused quite a few troubles in the past.
> 
> >> +		if (ret < 0) {
> >> +			hid_dbg(hdev, "ROG Ally check %d/%d failed: %d\n", i,
> >> +				HID_ALLY_READY_MAX_TRIES, ret);
> >> +			continue;
> >> +		}
> >> +
> >> +		if (buf[2] == CMD_CHECK_READY)
> >> +			return 0;
> >> +
> >> +		usleep_range(1000, 2000);
> >> +	}
> >> +
> >> +	hid_err(hdev, "ROG Ally never responded with a ready\n");
> >> +	return -ENODEV;
> >> +}


> >> +	byte = in_report->buttons[0];
> >> +	input_report_key(input, BTN_A, byte & BIT(0));
> >> +	input_report_key(input, BTN_B, byte & BIT(1));
> >> +	input_report_key(input, BTN_X, byte & BIT(2));
> >> +	input_report_key(input, BTN_Y, byte & BIT(3));
> >> +	input_report_key(input, BTN_TL, byte & BIT(4));
> >> +	input_report_key(input, BTN_TR, byte & BIT(5));
> >> +	input_report_key(input, BTN_SELECT, byte & BIT(6));
> >> +	input_report_key(input, BTN_START, byte & BIT(7));
> >> +
> >> +	byte = in_report->buttons[1];
> >> +	input_report_key(input, BTN_THUMBL, byte & BIT(0));
> >> +	input_report_key(input, BTN_THUMBR, byte & BIT(1));
> >> +	input_report_key(input, BTN_MODE, byte & BIT(2));

BTW, while cutting text I noticed these BIT()s should be named with 
defines.



-- 
 i.

  reply	other threads:[~2026-10-30 13:56 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 23:52 [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-10-25 23:52 ` [PATCH v11 01/18] " Denis Benato
2026-10-26 12:38   ` Ilpo Järvinen
2026-10-30 13:38     ` Denis Benato
2026-10-30 13:56       ` Ilpo Järvinen [this message]
2026-10-25 23:52 ` [PATCH v11 02/18] HID: asus: add gamepad configuration Denis Benato
2026-10-26 12:56   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 03/18] HID: asus: add vibration strength configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 04/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-10-26 13:00   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 05/18] HID: asus: add triggers " Denis Benato
2026-10-25 23:52 ` [PATCH v11 06/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 07/18] HID: asus: add support for response curve Denis Benato
2026-10-26 13:06   ` Ilpo Järvinen
2026-10-30 14:38     ` Denis Benato
2026-10-30 14:49       ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 08/18] HID: asus: add support to force feedback Denis Benato
2026-10-26 12:36   ` Sakari Ailus
2026-10-26 18:21     ` Ilpo Järvinen
2026-10-26 18:27       ` Sakari Ailus
2026-10-26 13:13   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 09/18] HID: asus: add support for gamepad mode Denis Benato
2026-10-26 13:20   ` Ilpo Järvinen
2026-10-30 14:58     ` Denis Benato
2026-10-25 23:52 ` [PATCH v11 10/18] HID: asus: add support for turbo buttons Denis Benato
2026-10-26 13:29   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 11/18] HID: asus: add support for btn remapping Denis Benato
2026-10-26 14:03   ` Ilpo Järvinen
2026-10-30 15:44     ` Denis Benato
2026-10-30 15:57       ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 12/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-10-26 13:06   ` Rebecca Mara Müller
2026-10-26 19:38     ` Denis Benato
2026-10-25 23:52 ` [PATCH v11 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-10-25 23:52 ` [PATCH v11 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-10-26 14:10   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 15/18] HID: asus: size ally gamepad commands from the HID report descriptor Denis Benato
2026-10-25 23:52 ` [PATCH v11 16/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-10-25 23:52 ` [PATCH v11 17/18] HID: asus: report the XG Mobile GPU vendor to asus-wmi Denis Benato
2026-10-26 14:15   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato
2026-10-26 14:24 ` [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Ilpo Järvinen
2026-10-26 18:03   ` Denis Benato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e78dc7ed-a23a-7f84-ce77-7aec3eee62ac@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=benato.denis96@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=derekjohn.clark@gmail.com \
    --cc=hacker1024@users.sourceforge.net \
    --cc=hansg@kernel.org \
    --cc=jikos@kernel.org \
    --cc=jlobue10@gmail.com \
    --cc=kernel@lists.opengamingcollective.org \
    --cc=khamunetriclark@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=matthew.schwartz@linux.dev \
    --cc=me@livan.pro \
    --cc=nathan@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rebecca.mara@posteo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox