From patchwork Thu Jan 25 04:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "sandeep.cs" X-Patchwork-Id: 13529998 X-Patchwork-Delegate: jikos@jikos.cz Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09581111AE for ; Thu, 25 Jan 2024 04:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706157447; cv=none; b=R2tvN328AZ8cuQFB6EO5yAREHHkxlpeG1SHsaqNEZgi+tpXbgnBPEh9WBA8xJVSLeSsq+yMi9J1g5JMrdoinZl+1S8yzv2J7l9TX+hYk57MJHihj9AVpyZUgJSVkern6kZoWuPEOCGuN3G3Gxu+xL1qAMQ7uMtq7BLOLxcq21n4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706157447; c=relaxed/simple; bh=htuLjyh7MD+2wiik6bveKuTHw4ikcwrKyoVr5y6JoGU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=MxmsQgW9s4t2oeEbhltTpioM6c5WMHNrpzsUzIcuP5IkJdLImCQJ23omdhU1AE6U7wGxrbn1vACUDo83n87xNfY8QODlJyMVXlQsPGiHAZcYhXI0AYO+lb9GLvN6oFkj1/OE4Js8l2jaP5T8ocQCIWk1yDAcmCLyHgFYxU+TTwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Al2c6Ffo; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Al2c6Ffo" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240125043724epoutp028ba71e8e4bdc6f621581dc5e15cc0979~tfSfnhxqd2165921659epoutp02N for ; Thu, 25 Jan 2024 04:37:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240125043724epoutp028ba71e8e4bdc6f621581dc5e15cc0979~tfSfnhxqd2165921659epoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706157444; bh=wqIAJgHOb3PONZDIIwi4erzvBZlBhVaiZg3QWPzJs4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Al2c6Ffotznj7MwZejSPuU4oUEdiqwHpC2zICGJlubBP/+LbzJLJ7IGk/5FwwDKhc 9STEjYbfd0CH1YkvzUN0WxOCLrBylKk8sG9A/IgO9CgWsC6dPxviK/Nh4VgCKGlbq9 gxkeL+XtlIIiApdsSxbIm4X8hbZVpTbsGFgVeD+Y= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240125043723epcas5p140bd0e63e9326f03eb25fcbac351cc78~tfSfTXtUw2411224112epcas5p1u; Thu, 25 Jan 2024 04:37:23 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4TL7N218F8z4x9QJ; Thu, 25 Jan 2024 04:37:22 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 2F.EC.10009.085E1B56; Thu, 25 Jan 2024 13:37:21 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240125043720epcas5p26d753bd642085849574b82af5c60ecb1~tfScIMvjY0578005780epcas5p2J; Thu, 25 Jan 2024 04:37:20 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240125043720epsmtrp2c6a37642e8aded006805999e30d2ee29~tfScHdm9y1848518485epsmtrp2T; Thu, 25 Jan 2024 04:37:20 +0000 (GMT) X-AuditID: b6c32a4a-261fd70000002719-2f-65b1e5808fb1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FD.4A.07368.085E1B56; Thu, 25 Jan 2024 13:37:20 +0900 (KST) Received: from ws2030077324.sa.corp.samsungelectronics.net (unknown [107.99.237.91]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240125043718epsmtip237e0a4e89dcada12e41922fb6853f06c~tfSaoZOOu1132311323epsmtip2X; Thu, 25 Jan 2024 04:37:18 +0000 (GMT) From: Sandeep C S To: Jiri Kosina , Benjamin Tissoires Cc: gaudium.lee@samsung.com, ih0923.kim@samsung.com, suhyun_.kim@samsung.com, jitender.s21@samsung.com, junwan.cho@samsung.com, sandeep.cs@samsung.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [HID Patchsets for Samsung driver v4 4/6] HID: Samsung : Add Samsung wireless gamepad support. Date: Thu, 25 Jan 2024 10:06:27 +0530 Message-Id: <20240125043630.4031634-5-sandeep.cs@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125043630.4031634-1-sandeep.cs@samsung.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLz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x/1uYybs11mVuT9OrybCvvG2F9PRvmrNo8678SS3FGoqEW c1FxIgDZG0fi4wIAAA== X-CMS-MailID: 20240125043720epcas5p26d753bd642085849574b82af5c60ecb1 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240125043720epcas5p26d753bd642085849574b82af5c60ecb1 References: <20240125043630.4031634-1-sandeep.cs@samsung.com> Add support for samsung wireless gamepad with input mapping events. Device a000 (Samsung wireless gamepad) Signed-off-by: Sandeep C S Signed-off-by: Junwan Cho Signed-off-by: Jitender Sajwan --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-samsung.c | 95 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index d7572ab5ea6c..8a106fd6b339 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1147,6 +1147,7 @@ #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 #define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 #define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD 0x7021 +#define USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD 0xa000 #define USB_VENDOR_ID_SEMICO 0x1a2c #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023 diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c index aa8e7805be76..217b30b71bb8 100644 --- a/drivers/hid/hid-samsung.c +++ b/drivers/hid/hid-samsung.c @@ -232,6 +232,97 @@ static int samsung_kbd_input_mapping(struct hid_device *hdev, return 1; } +static int samsung_gamepad_input_mapping(struct hid_device *hdev, + struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + if (!(HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE) || + HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE))) + return 0; + + dbg_hid("samsung wireless gamepad input mapping event [0x%x], %ld, %ld, [0x%x]\n", + usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0], usage->hid & HID_USAGE_PAGE); + + if (HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE)) { + switch (usage->hid & HID_USAGE) { + case 0x01: + samsung_kbd_mouse_map_key_clear(BTN_A); + break; + case 0x02: + samsung_kbd_mouse_map_key_clear(BTN_B); + break; + case 0x03: + samsung_kbd_mouse_map_key_clear(BTN_C); + break; + case 0x04: + samsung_kbd_mouse_map_key_clear(BTN_X); + break; + case 0x05: + samsung_kbd_mouse_map_key_clear(BTN_Y); + break; + case 0x06: + samsung_kbd_mouse_map_key_clear(BTN_Z); + break; + case 0x07: + samsung_kbd_mouse_map_key_clear(BTN_TL); + break; + case 0x08: + samsung_kbd_mouse_map_key_clear(BTN_TR); + break; + case 0x09: + samsung_kbd_mouse_map_key_clear(BTN_TL2); + break; + case 0x0a: + samsung_kbd_mouse_map_key_clear(BTN_TR2); + break; + case 0x0b: + samsung_kbd_mouse_map_key_clear(BTN_SELECT); + break; + case 0x0c: + samsung_kbd_mouse_map_key_clear(BTN_START); + break; + case 0x0d: + samsung_kbd_mouse_map_key_clear(BTN_MODE); + break; + case 0x0e: + samsung_kbd_mouse_map_key_clear(BTN_THUMBL); + break; + case 0x0f: + samsung_kbd_mouse_map_key_clear(BTN_THUMBR); + break; + case 0x10: + samsung_kbd_mouse_map_key_clear(0x13f); + break; + default: + return 0; + } + } + + if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) { + switch (usage->hid & HID_USAGE) { + case 0x040: + samsung_kbd_mouse_map_key_clear(KEY_MENU); + break; + case 0x223: + samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE); + break; + case 0x224: + samsung_kbd_mouse_map_key_clear(KEY_BACK); + break; + + /* Screen Capture */ + case 0x303: + samsung_kbd_mouse_map_key_clear(KEY_SYSRQ); + break; + + default: + return 0; + } + } + + return 1; +} + static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { @@ -252,6 +343,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi, else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) ret = samsung_kbd_input_mapping(hdev, hi, field, usage, bit, max); + else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD) + ret = samsung_gamepad_input_mapping(hdev, + hi, field, usage, bit, max); return ret; } @@ -295,6 +389,7 @@ static const struct hid_device_id samsung_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD) }, { } }; MODULE_DEVICE_TABLE(hid, samsung_devices);