From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B8121F0991 for ; Sat, 25 Jul 2026 07:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784964749; cv=none; b=N96aiwUrfJbIlgcxJyqDmus/xbw7xe2m1FuDpBWHrODzc3sXNYi4dp0OmOnWSyYTZ1g3Duyq5/lelzhmZsONo3FeD6owoKhI9WkNxPkJjwoEaYtvW6C9TcPSy0zGOLRQAPLeFJF8nl8UaavvleSn8wo1BuzjaP6CjGrkgHmqbPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784964749; c=relaxed/simple; bh=AQwUsaJyjCLgRN4dGNPNeCFVqZx0eYKgbL1H5GZFAJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RfI5QYuG+6AxgknQSONRPAQKhZYyzjE+IFGkdoa4qD2tXSeRy4qZzMo9C7LcmECeYrEbGCg8Rx6QNGKx3d9GnhWXjtElaEAd1vH5SEKfgbNqK+lxH6FZymXZCAZBfr3xgQbfQdlTipdwS6pw5Ut5gtXr9bQ1DGhFi1b4ja7B1L4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d9/4A4LL; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d9/4A4LL" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-495c63c41ceso491876b6e.2 for ; Sat, 25 Jul 2026 00:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784964747; x=1785569547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EBJMPsDIaUlKxFTZX7M5CaZJYE5N+5LrvYXn7n/pZ8A=; b=d9/4A4LLjgDaKFGzch5BETDB2Uk3ClIAABP3Fmc98f7vTvy5RZV6o3aWABI/COTOG7 9QrHrOUN9BuFMnrrMIEW+5qYbfmVJjlx+nG/a9WYElvQGkOZ6T7QQmtFKhJaC1+o688D OXrsiKIwTjF9BEMXeJMabzuSLMQyJ9mFVgwJIr7B9cBUVy267SY77rT0jm108qpBo8U9 OalJb/rwwelAC4JHhfZU/2h918MSsF3u0n1YbAczBJSuDSKs1sJvfHBQWEZ1dfpOcXU+ sb2gNr1PSuar4q9V5q76YBQqTs93abNn9WBdexm0UvOQeuZ5V059xs1cUOGMgdYLkeFj yt8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784964747; x=1785569547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EBJMPsDIaUlKxFTZX7M5CaZJYE5N+5LrvYXn7n/pZ8A=; b=Q0RUNneDzu8xPPlcWeFebiMtfLuqGJ2h3vBfUE37W6396SWIRY7oKh8pRIztMU+y40 JVkCntbCQjfOQ3ywgxZpWPodw7V0gYlFzkRyrkeysLdclPd29D5Zyn5MF4Ikb31n5d1U dpROL6tHdLSW9h7MVBA2tsCWBghvR5haW2XYIub2TEyCtV5zIC/zFyugFTVyi/X+ujIC TzMWOyTgiQYeDKZl9b/urskPO80rL76xq3u8dHGx5vF2V5UgE/PgqD+0NxyThYsweg9a UGuPYvGNhiDlgJrbJx4gTK0jyKLCh/DoiKO6DKPQUrNCo/YtQmdm92pwS7cWtAYkW1P1 A3bw== X-Forwarded-Encrypted: i=1; AHgh+RrjzgSyMy0dyBN0Iz/3m0MVU4u8KDhYpLQkI80dgaSlCatMcdN4xCYbCpKv8OIfm7uErv3WpHwYEUmfbl4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyw7j4IDnz8WSNMercQ0MpJlMQOxQuiLVeKgciEI+3A40YgiG5E 0HSjeqg7bH8oGFPoSD1m1q1w2NSF4tO2FLV5LEb6obWfqk6LwK2lxJpz X-Gm-Gg: AR+sD10mMTL2vNCftrX8AvKjE9P3/EigphGHKVzzeiwCcDjmB7biGje+TBU3e7BZgoT 4IYLGd4u6kPAWIeAnVJcuf/bR61Vgle5u2ZLsoAnVFVUWopqcDFbiNRm+NrgsQdPeaTJ/NqnSXy AS+MGw1ljnAsh9N4gO+jBkRiU1KovXwQOJImQGzRXi/VuusQxQ3ElDUcUpqS/6By1mAlqs6A9/Q MiNAyMUpRtwZ3kxyW6kW6u0UWCi4N3beZafVBJVswAAi3Tj8miVn8zfVBgeXJQa4N1GEoGdM7fb 17ID+ckuePKGw/nBIdo+nij4inyIJYgCQDMcV0BBlvhNh9PkgsWUU9P6yGYR55HOB5F/6MKWC6j 9D4qXT6DcWeMzYQvJSpFIW2Mi4QZbb+S/WaXfLyzhiCuJejzalh7oH3CVnf7xz6RQ7mkI2kzMx6 M3hrz2smMtyttpjlaZPpDaeaORJptcKA== X-Received: by 2002:a05:6808:1910:b0:48f:c907:7a40 with SMTP id 5614622812f47-4ab69f433d7mr1705930b6e.11.1784964746724; Sat, 25 Jul 2026 00:32:26 -0700 (PDT) Received: from u-ThinkPad-X1-Extreme-Gen-4i ([192.3.12.183]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4ab3b21331esm4823598b6e.14.2026.07.25.00.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2026 00:32:26 -0700 (PDT) From: Aaron Ma To: Dmitry Torokhov , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org Cc: Sanjay Govind , Vicki Pfau , Shengyu Qu , Aaron Ma , Qbeliw Tanaka , Elliot Tester , Kees Cook , Dmitriy Zharov Subject: [PATCH 2/2] Input: xpad - add wired Beitong BTP-KP20D support Date: Sat, 25 Jul 2026 15:28:13 +0800 Message-ID: <20260725072813.339112-2-mapengyu@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260725072813.339112-1-mapengyu@gmail.com> References: <20260725072813.339112-1-mapengyu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The wired BTP-KP20D resets itself when its interrupt-IN pipe is idle for a few seconds, causing periodic re-enumeration whenever no userspace client holds the input device open. Add a FLAG_KEEPALIVE quirk that keeps the input URB running from probe to disconnect, mirroring the XTYPE_XBOX360W URB lifecycle. The device also needs the MS OS descriptor query to stay in Xbox 360 mode. Signed-off-by: Aaron Ma --- drivers/input/joystick/xpad.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 1616047e65f5e..5369b880c6a08 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -73,6 +73,7 @@ #define FLAG_DELAY_INIT BIT(0) #define FLAG_MS_OS_DESC BIT(1) +#define FLAG_KEEPALIVE BIT(2) static bool dpad_to_buttons; module_param(dpad_to_buttons, bool, S_IRUGO); @@ -335,6 +336,7 @@ static const struct xpad_device { { 0x1ee9, 0x1590, "ZOTAC Gaming Zone", 0, XTYPE_XBOX360 }, { 0x20bc, 0x5134, "BETOP BTP-KP50B Xinput Dongle", 0, XTYPE_XBOX360 }, { 0x20bc, 0x514a, "BETOP BTP-KP50C Xinput Dongle", 0, XTYPE_XBOX360 }, + { 0x20bc, 0x5158, "Beitong BTP-KP20D Controller", 0, XTYPE_XBOX360, FLAG_MS_OS_DESC | FLAG_KEEPALIVE }, { 0x20bc, 0x5159, "Beitong BTP-KP20D Controller", 0, XTYPE_XBOX360, FLAG_MS_OS_DESC }, { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE }, { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE }, @@ -780,6 +782,7 @@ struct usb_xpad { time64_t mode_btn_down_ts; bool delay_init; /* init packets should be delayed */ bool delayed_init_done; + bool keepalive; /* int URB must run from probe to disconnect */ }; static int xpad_init_input(struct usb_xpad *xpad); @@ -1971,7 +1974,7 @@ static int xpad_init_input(struct usb_xpad *xpad) input_set_drvdata(input_dev, xpad); - if (xpad->xtype != XTYPE_XBOX360W) { + if (xpad->xtype != XTYPE_XBOX360W && !xpad->keepalive) { input_dev->open = xpad_open; input_dev->close = xpad_close; } @@ -2105,6 +2108,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->name = xpad_device[i].name; if (xpad_device[i].flags & FLAG_DELAY_INIT) xpad->delay_init = true; + if (xpad_device[i].flags & FLAG_KEEPALIVE) + xpad->keepalive = true; xpad->packet_type = PKT_XB; INIT_WORK(&xpad->work, xpad_presence_work); @@ -2227,9 +2232,22 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id error = xpad_init_input(xpad); if (error) goto err_deinit_output; + + if (xpad->keepalive) { + /* + * The device resets itself when the interrupt-IN pipe + * is idle for a few seconds, so keep the URB running + * from probe until disconnect. + */ + error = xpad_start_input(xpad); + if (error) + goto err_deinit_input; + } } return 0; +err_deinit_input: + xpad_deinit_input(xpad); err_deinit_output: xpad_deinit_output(xpad); err_free_in_urb: @@ -2247,6 +2265,8 @@ static void xpad_disconnect(struct usb_interface *intf) if (xpad->xtype == XTYPE_XBOX360W) xpad360w_stop_input(xpad); + else if (xpad->keepalive) + xpad_stop_input(xpad); xpad_deinit_input(xpad); @@ -2288,6 +2308,8 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message) */ if (auto_poweroff && xpad->pad_present) xpad360w_poweroff_controller(xpad); + } else if (xpad->keepalive) { + xpad_stop_input(xpad); } else { guard(mutex)(&input->mutex); @@ -2309,6 +2331,9 @@ static int xpad_resume(struct usb_interface *intf) if (xpad->xtype == XTYPE_XBOX360W) return xpad360w_start_input(xpad); + if (xpad->keepalive) + return xpad_start_input(xpad); + guard(mutex)(&input->mutex); if (input_device_enabled(input)) -- 2.53.0