* [HID Patchsets for Samsung driver v2 5/6] HID: Samsung : Add Samsung wireless action mouse support.
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <20240108091917.1552013-1-sandeep.cs@samsung.com>
Add support for samsung wireless action mouse with input mapping events.
Device a004 (Samsung wireless action mouse)
Signed-off-by: Sandeep C S <sandeep.cs@samsung.com>
Signed-off-by: Junwan Cho <junwan.cho@samsung.com>
Signed-off-by: Jitender Sajwan <jitender.s21@samsung.com>
---
drivers/hid/hid-ids.h | 1 +
drivers/hid/hid-samsung.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 2851dc25f949..b1208d04712c 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1144,6 +1144,7 @@
#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_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE 0xa004
#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 6b08acd3c4fd..36ab9540e064 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -339,6 +339,29 @@ static int samsung_gamepad_input_mapping(struct hid_device *hdev,
return 1;
}
+static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
+ struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+
+ dbg_hid("samsung wireless actionmouse input mapping event [0x%x], [0x%x], %ld, %ld, [0x%x]\n",
+ usage->hid, usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0],
+ usage->hid & HID_USAGE_PAGE);
+
+ if (((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) && ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON))
+ return 0;
+
+ switch (usage->hid & HID_USAGE) {
+ case 0x301:
+ samsung_kbd_mouse_map_key_clear(254);
+ break;
+ default:
+ return 0;
+ }
+
+ return 1;
+}
+
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
@@ -362,6 +385,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD)
ret = samsung_gamepad_input_mapping(hdev,
hi, field, usage, bit, max);
+ else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE)
+ ret = samsung_actionmouse_input_mapping(hdev,
+ hi, field, usage, bit, max);
return ret;
}
@@ -406,6 +432,7 @@ static const struct hid_device_id samsung_devices[] = {
{ 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) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE) },
{ }
};
MODULE_DEVICE_TABLE(hid, samsung_devices);
--
2.34.1
^ permalink raw reply related
* [HID Patchsets for Samsung driver v2 4/6] HID: Samsung : Add Samsung wireless gamepad support.
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <20240108091917.1552013-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 <sandeep.cs@samsung.com>
Signed-off-by: Junwan Cho <junwan.cho@samsung.com>
Signed-off-by: Jitender Sajwan <jitender.s21@samsung.com>
---
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 2f526dc8983a..2851dc25f949 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1143,6 +1143,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 611acd7ffd6d..6b08acd3c4fd 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -248,6 +248,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)
{
@@ -268,6 +359,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;
}
@@ -311,6 +405,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);
--
2.34.1
^ permalink raw reply related
* [HID Patchsets for Samsung driver v2 3/6] HID: Samsung : Add Samsung wireless keyboard support.
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <20240108091917.1552013-1-sandeep.cs@samsung.com>
Add Support for samsung wireless keyboard with input mapping events.
Device 7021 (Samsung wireless keyboard)
Signed-off-by: Sandeep C S <sandeep.cs@samsung.com>
Signed-off-by: Junwan Cho <junwan.cho@samsung.com>
Signed-off-by: Jitender Sajwan <jitender.s21@samsung.com>
---
drivers/hid/hid-ids.h | 2 +
drivers/hid/hid-samsung.c | 108 ++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 72046039d1be..2f526dc8983a 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1139,8 +1139,10 @@
#define USB_DEVICE_ID_SAITEK_X65 0x0b6a
#define USB_VENDOR_ID_SAMSUNG 0x0419
+#define USB_VENDOR_ID_SAMSUNG_ELECTRONICS 0x04e8
#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_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 33cc92337394..611acd7ffd6d 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -144,6 +144,110 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
return 1;
}
+static int samsung_kbd_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_CONSUMER == (usage->hid & HID_USAGE_PAGE) ||
+ HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)))
+ return 0;
+
+ dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n",
+ usage->hid & HID_USAGE);
+
+ if (HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)) {
+ set_bit(EV_REP, hi->input->evbit);
+ switch (usage->hid & HID_USAGE) {
+ /* Only for UK keyboard */
+ /* key found */
+#ifdef CONFIG_HID_KK_UPGRADE
+ case 0x32:
+ samsung_kbd_mouse_map_key_clear(KEY_KBDILLUMTOGGLE);
+ break;
+ case 0x64:
+ samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
+ break;
+#else
+ case 0x32:
+ samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
+ break;
+ case 0x64:
+ samsung_kbd_mouse_map_key_clear(KEY_102ND);
+ break;
+#endif
+ /* Only for BR keyboard */
+ case 0x87:
+ samsung_kbd_mouse_map_key_clear(KEY_RO);
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
+ switch (usage->hid & HID_USAGE) {
+ /* report 2 */
+ /* MENU */
+ case 0x040:
+ samsung_kbd_mouse_map_key_clear(KEY_MENU);
+ break;
+ case 0x18a:
+ samsung_kbd_mouse_map_key_clear(KEY_MAIL);
+ break;
+ case 0x196:
+ samsung_kbd_mouse_map_key_clear(KEY_WWW);
+ break;
+ case 0x19e:
+ samsung_kbd_mouse_map_key_clear(KEY_SCREENLOCK);
+ break;
+ case 0x221:
+ samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
+ break;
+ case 0x223:
+ samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
+ break;
+ /* Smtart Voice Key */
+ case 0x300:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY13);
+ break;
+ /* RECENTAPPS */
+ case 0x301:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY1);
+ break;
+ /* APPLICATION */
+ case 0x302:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY2);
+ break;
+ /* Voice search */
+ case 0x305:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY4);
+ break;
+ /* QPANEL on/off */
+ case 0x306:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY5);
+ break;
+ /* SIP on/off */
+ case 0x307:
+ samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY3);
+ break;
+ /* LANG */
+ case 0x308:
+ samsung_kbd_mouse_map_key_clear(KEY_LANGUAGE);
+ break;
+ case 0x30a:
+ samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
+ break;
+ case 0x30b:
+ samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
@@ -161,6 +265,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE && hid_is_usb(hdev))
ret = samsung_kbd_mouse_input_mapping(hdev,
hi, field, usage, bit, max);
+ else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD)
+ ret = samsung_kbd_input_mapping(hdev,
+ hi, field, usage, bit, max);
return ret;
}
@@ -203,6 +310,7 @@ static int samsung_probe(struct hid_device *hdev,
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) },
{ }
};
MODULE_DEVICE_TABLE(hid, samsung_devices);
--
2.34.1
^ permalink raw reply related
* [HID Patchsets for Samsung driver v2 1/6] HID Samsung : Broaden device compatibility in samsung driver.
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <20240108091917.1552013-1-sandeep.cs@samsung.com>
The USB validation check has been moved wherever its required.
Earlier Samsung driver only handles USB HID devices and returns an error if it encounters a Bluetooth type of HID device.
This changes improves driver compatibility and extends its support for a wide range of devices.
Signed-off-by: Sandeep C S <sandeep.cs@samsung.com>
Signed-off-by: Junwan Cho <junwan.cho@samsung.com>
Signed-off-by: Jitender Sajwan <jitender.s21@samsung.com>
---
drivers/hid/hid-samsung.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index cf5992e97094..885657531607 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -128,7 +128,7 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
- if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product)
+ if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product && hid_is_usb(hdev))
rdesc = samsung_irda_report_fixup(hdev, rdesc, rsize);
return rdesc;
}
@@ -139,7 +139,7 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
{
int ret = 0;
- if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product)
+ if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product && hid_is_usb(hdev))
ret = samsung_kbd_mouse_input_mapping(hdev,
hi, field, usage, bit, max);
@@ -152,9 +152,6 @@ static int samsung_probe(struct hid_device *hdev,
int ret;
unsigned int cmask = HID_CONNECT_DEFAULT;
- if (!hid_is_usb(hdev))
- return -EINVAL;
-
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
@@ -162,6 +159,10 @@ static int samsung_probe(struct hid_device *hdev,
}
if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) {
+ if (!hid_is_usb(hdev)) {
+ ret = -EINVAL;
+ goto err_free;
+ }
if (hdev->rsize == 184) {
/* disable hidinput, force hiddev */
cmask = (cmask & ~HID_CONNECT_HIDINPUT) |
--
2.34.1
^ permalink raw reply related
* [HID Patchsets for Samsung driver v2 2/6] HID: Samsung : Fix the checkpatch complain.
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <20240108091917.1552013-1-sandeep.cs@samsung.com>
Warning found by checkpatch.pl script.
Signed-off-by: Sandeep C S <sandeep.cs@samsung.com>
Signed-off-by: Junwan Cho <junwan.cho@samsung.com>
Signed-off-by: Jitender Sajwan <jitender.s21@samsung.com>
---
drivers/hid/hid-samsung.c | 61 +++++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 21 deletions(-)
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index 885657531607..33cc92337394 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -67,20 +67,17 @@ static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
rdesc[178] = 0x08;
rdesc[180] = 0x06;
rdesc[182] = 0x42;
- } else
- if (*rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
+ } else if (*rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
rdesc[194] == 0x25 && rdesc[195] == 0x12) {
samsung_irda_dev_trace(hdev, 203);
rdesc[193] = 0x1;
rdesc[195] = 0xf;
- } else
- if (*rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
+ } else if (*rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
rdesc[126] == 0x25 && rdesc[127] == 0x11) {
samsung_irda_dev_trace(hdev, 135);
rdesc[125] = 0x1;
rdesc[127] = 0xe;
- } else
- if (*rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
+ } else if (*rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
rdesc[162] == 0x25 && rdesc[163] == 0x01) {
samsung_irda_dev_trace(hdev, 171);
rdesc[161] = 0x1;
@@ -99,7 +96,7 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
- if (1 != ifnum || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
+ if (ifnum != 1 || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
return 0;
dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n",
@@ -107,17 +104,39 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
switch (usage->hid & HID_USAGE) {
/* report 2 */
- case 0x183: samsung_kbd_mouse_map_key_clear(KEY_MEDIA); break;
- case 0x195: samsung_kbd_mouse_map_key_clear(KEY_EMAIL); break;
- case 0x196: samsung_kbd_mouse_map_key_clear(KEY_CALC); break;
- case 0x197: samsung_kbd_mouse_map_key_clear(KEY_COMPUTER); break;
- case 0x22b: samsung_kbd_mouse_map_key_clear(KEY_SEARCH); break;
- case 0x22c: samsung_kbd_mouse_map_key_clear(KEY_WWW); break;
- case 0x22d: samsung_kbd_mouse_map_key_clear(KEY_BACK); break;
- case 0x22e: samsung_kbd_mouse_map_key_clear(KEY_FORWARD); break;
- case 0x22f: samsung_kbd_mouse_map_key_clear(KEY_FAVORITES); break;
- case 0x230: samsung_kbd_mouse_map_key_clear(KEY_REFRESH); break;
- case 0x231: samsung_kbd_mouse_map_key_clear(KEY_STOP); break;
+ case 0x183:
+ samsung_kbd_mouse_map_key_clear(KEY_MEDIA);
+ break;
+ case 0x195:
+ samsung_kbd_mouse_map_key_clear(KEY_EMAIL);
+ break;
+ case 0x196:
+ samsung_kbd_mouse_map_key_clear(KEY_CALC);
+ break;
+ case 0x197:
+ samsung_kbd_mouse_map_key_clear(KEY_COMPUTER);
+ break;
+ case 0x22b:
+ samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
+ break;
+ case 0x22c:
+ samsung_kbd_mouse_map_key_clear(KEY_WWW);
+ break;
+ case 0x22d:
+ samsung_kbd_mouse_map_key_clear(KEY_BACK);
+ break;
+ case 0x22e:
+ samsung_kbd_mouse_map_key_clear(KEY_FORWARD);
+ break;
+ case 0x22f:
+ samsung_kbd_mouse_map_key_clear(KEY_FAVORITES);
+ break;
+ case 0x230:
+ samsung_kbd_mouse_map_key_clear(KEY_REFRESH);
+ break;
+ case 0x231:
+ samsung_kbd_mouse_map_key_clear(KEY_STOP);
+ break;
default:
return 0;
}
@@ -128,7 +147,7 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
- if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product && hid_is_usb(hdev))
+ if (hdev->product == USB_DEVICE_ID_SAMSUNG_IR_REMOTE && hid_is_usb(hdev))
rdesc = samsung_irda_report_fixup(hdev, rdesc, rsize);
return rdesc;
}
@@ -139,7 +158,7 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
{
int ret = 0;
- if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product && hid_is_usb(hdev))
+ if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE && hid_is_usb(hdev))
ret = samsung_kbd_mouse_input_mapping(hdev,
hi, field, usage, bit, max);
@@ -158,7 +177,7 @@ static int samsung_probe(struct hid_device *hdev,
goto err_free;
}
- if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) {
+ if (hdev->product == USB_DEVICE_ID_SAMSUNG_IR_REMOTE) {
if (!hid_is_usb(hdev)) {
ret = -EINVAL;
goto err_free;
--
2.34.1
^ permalink raw reply related
* [HID Patchsets for Samsung driver v2 0/6] HID Support for Samsung driver
From: Sandeep C S @ 2024-01-08 9:19 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: gaudium.lee, ih0923.kim, suhyun_.kim, jitender.s21, junwan.cho,
sandeep.cs, linux-input, linux-kernel
In-Reply-To: <CGME20240108091950epcas5p41633efaf7b62db312982aa2f94a26db3@epcas5p4.samsung.com>
Dear All,
I hope this email finds you well.
As per your review comments give by Mr. Benjamin Tissoires in our last converstaion over mail.
We refactored series with :
1. hid_is_usb() check being moved
2. fix the checkpatch complain
3+ Added bluetooth device support
As of today, Opensource kernel Samsung driver only supports USB HID devices and do not have support for Bluetooth HID devices.
Samsung would like to improve the samsung driver and extend it's support for bluetooth devices as well.
Summary of changes in Samsung driver:
1. Add support for below bluetooth devices
Samsung wireless Keyboard
Samsung wireless GamePad
Samsung Wireless Action Mouse
Samsung Wireless Book Cover
Samsung Wireless Universal Keyboard
Samsung Wireless HOGP Keyboard
2. Add support for Special key processing on each of the above devices.
Patch Series Overview:
--------------------------------------
[Patch 1/6]
HID Samsung : Broaden device compatibility in samsung driver.
hid_is_usb() check being moved.
[Patch 2/6]
HID: Samsung : Fix the checkpatch complain.
Warning found by checkpatch.pl script.
[Patch 3/6]
HID: Samsung : Add Samsung wireless keyboard support.
[Patch 4/6]
HID: Samsung : Add Samsung wireless gamepad support.
[Patch 5/6]
HID: Samsung : Add Samsung wireless action mouse support.
[Patch 6/6]
HID: Samsung : Add Samsung wireless bookcover and universal keyboard support.
All these changes have been verified and tested thoroughly in android devices.
Please accept our changes.
Thanks for your time and consideration
Best regards
Sandeep C S
Sandeep C S (6):
HID Samsung : Broaden device compatibility in samsung driver.
HID: Samsung : Fix the checkpatch complain.
HID: Samsung : Add Samsung wireless keyboard support.
HID: Samsung : Add Samsung wireless gamepad support.
HID: Samsung : Add Samsung wireless action mouse support.
HID: Samsung : Add Samsung wireless bookcover and universal keyboard
support.
drivers/hid/hid-ids.h | 7 +
drivers/hid/hid-samsung.c | 440 +++++++++++++++++++++++++++++++++++---
2 files changed, 423 insertions(+), 24 deletions(-)
--
2.34.1
^ permalink raw reply
* Re: [PATCH bpf-next v3 0/3] Annotate kfuncs in .BTF_ids section
From: Lorenz Bauer @ 2024-01-08 9:15 UTC (permalink / raw)
To: Daniel Xu
Cc: linux-input, coreteam, linux-arm-kernel, linux-kernel,
netfilter-devel, linux-kselftest, linux-trace-kernel, fsverity,
bpf, netdev, linux-stm32, cgroups, alexei.starovoitov, olsajiri,
quentin, alan.maguire, memxor
In-Reply-To: <cover.1704565248.git.dxu@dxuuu.xyz>
On Sat, Jan 6, 2024 at 7:25 PM Daniel Xu <dxu@dxuuu.xyz> wrote:
>
> === Description ===
>
> This is a bpf-treewide change that annotates all kfuncs as such inside
> .BTF_ids. This annotation eventually allows us to automatically generate
> kfunc prototypes from bpftool.
>
> We store this metadata inside a yet-unused flags field inside struct
> btf_id_set8 (thanks Kumar!). pahole will be taught where to look.
This is great, thanks for tackling this. With yout patches we can
figure out the full set of kfuncs. Is there a way to extend it so that
we can tell which program context a kfunc can be called from?
^ permalink raw reply
* Re: Mouse wheel resolution with kernel 6.6+
From: Randy Dunlap @ 2024-01-07 16:26 UTC (permalink / raw)
To: Klaus Ethgen, linux-kernel, linux-input
In-Reply-To: <ZZqwmckYIS1rLEAP@ikki.ethgen.ch>
[add linux-input mailing list]
On 1/7/24 06:09, Klaus Ethgen wrote:
> Hi,
>
> I have another minor issue that I don't know how to fix. (And even don't
> know which subsystem creates that issue.)
>
> I use a Logitech MX3 via bluetooth, which work fine for kernel 6.5 and
> under. But when using kernel 6.6+, the mouse wheel dropped the
> resolution to not usable slow. Scrolling is not really useful that way.
> It seems to me that only every second scroll event is forwarded to the X
> server.
>
> Any help to identify the source of this annoying bug is appreciated.
>
> Regards
> Klaus
>
> Ps. Please keep me in Cc as I am not subscribed to the list.
--
#Randy
^ permalink raw reply
* Re: [PATCH v5 4/5] Input: cs40l50 - Add support for the CS40L50 haptic driver
From: Dmitry Torokhov @ 2024-01-07 1:58 UTC (permalink / raw)
To: James Ogletree
Cc: James Ogletree, Fred Treven, Ben Bright, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Simon Trimmer, Charles Keepax,
Richard Fitzgerald, Lee Jones, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, James Schulman, David Rhodes,
Alexandre Belloni, Peng Fan, Jeff LaBundy, Sebastian Reichel,
Jacky Bai, Weidong Wang, Arnd Bergmann, Herve Codina, Shuming Fan,
Shenghao Ding, Ryan Lee, Linus Walleij,
open list:CIRRUS LOGIC HAPTIC DRIVERS,
open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS
In-Reply-To: <20240104223643.876292-5-jogletre@opensource.cirrus.com>
Hi James,
On Thu, Jan 04, 2024 at 10:36:37PM +0000, James Ogletree wrote:
> +static int vibra_add(struct input_dev *dev, struct ff_effect *effect,
> + struct ff_effect *old)
> +{
> + struct vibra_info *info = input_get_drvdata(dev);
> + u32 len = effect->u.periodic.custom_len;
> +
> + if (effect->type != FF_PERIODIC || effect->u.periodic.waveform != FF_CUSTOM) {
> + dev_err(info->dev, "Type (%#X) or waveform (%#X) unsupported\n",
> + effect->type, effect->u.periodic.waveform);
> + return -EINVAL;
> + }
> +
> + memcpy(&info->add_effect, effect, sizeof(struct ff_effect));
structures can be assigned, no need for memcpy.
> +
> + info->add_effect.u.periodic.custom_data = kcalloc(len, sizeof(s16), GFP_KERNEL);
> + if (!info->add_effect.u.periodic.custom_data)
> + return -ENOMEM;
> +
> + if (copy_from_user(info->add_effect.u.periodic.custom_data,
> + effect->u.periodic.custom_data, sizeof(s16) * len)) {
> + info->add_error = -EFAULT;
> + goto out_free;
> + }
> +
> + queue_work(info->vibe_wq, &info->add_work);
> + flush_work(&info->add_work);
I do not understand the need of scheduling a work here. You are
obviously in a sleeping context (otherwise you would not be able to
execute flush_work()) so you should be able to upload the effect right
here.
...
> +
> +static int vibra_playback(struct input_dev *dev, int effect_id, int val)
> +{
> + struct vibra_info *info = input_get_drvdata(dev);
> +
> + if (val > 0) {
value is supposed to signal how many times an effect should be repeated.
It looks like you are not handling this at all.
> + info->start_effect = &dev->ff->effects[effect_id];
> + queue_work(info->vibe_wq, &info->vibe_start_work);
The API allows playback of several effects at once, the way you have it
done here if multiple requests come at same time only one will be
handled.
> + } else {
> + queue_work(info->vibe_wq, &info->vibe_stop_work);
Which effect are you stopping? All of them? You need to stop a
particular one.
> + }
Essentially you need a queue of requests and a single work handling all
of them...
...
> +
> +static int cs40l50_vibra_probe(struct platform_device *pdev)
> +{
> + struct cs40l50 *cs40l50 = dev_get_drvdata(pdev->dev.parent);
> + struct vibra_info *info;
> + int error;
> +
> + info = devm_kzalloc(pdev->dev.parent, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + info->dev = cs40l50->dev;
> + info->regmap = cs40l50->regmap;
> +
> + info->input = devm_input_allocate_device(info->dev);
> + if (!info->input)
> + return -ENOMEM;
> +
> + info->input->id.product = cs40l50->devid & 0xFFFF;
> + info->input->id.version = cs40l50->revid;
> + info->input->name = "cs40l50_vibra";
> +
> + input_set_drvdata(info->input, info);
> + input_set_capability(info->input, EV_FF, FF_PERIODIC);
> + input_set_capability(info->input, EV_FF, FF_CUSTOM);
> +
> + error = input_ff_create(info->input, FF_MAX_EFFECTS);
> + if (error) {
> + dev_err(info->dev, "Failed to create input device\n");
> + return error;
> + }
> +
> + info->input->ff->upload = vibra_add;
> + info->input->ff->playback = vibra_playback;
> + info->input->ff->erase = vibra_erase;
> +
> + INIT_LIST_HEAD(&info->effect_head);
> +
> + info->dsp = cs40l50_dsp;
> +
> + info->vibe_wq = alloc_ordered_workqueue("vibe_wq", 0);
> + if (!info->vibe_wq)
> + return -ENOMEM;
> +
> + error = devm_add_action_or_reset(info->dev, vibra_remove_wq, info);
> + if (error)
> + return error;
Why do you need a dedicated workqueue? So you can flush works?
> +
> + mutex_init(&info->lock);
> +
> + INIT_WORK(&info->vibe_start_work, vibra_start_worker);
> + INIT_WORK(&info->vibe_stop_work, vibra_stop_worker);
> + INIT_WORK(&info->erase_work, vibra_erase_worker);
> + INIT_WORK(&info->add_work, vibra_add_worker);
> +
> + error = input_register_device(info->input);
> + if (error) {
> + dev_err(info->dev, "Failed to register input device\n");
> + input_free_device(info->input);
Not needed, you are using devm_input_allocate_device().
> + return error;
> + }
> +
> + return devm_add_action_or_reset(info->dev, vibra_input_unregister,
> + info->input);
Not needed, managed input devices will be unregistered automatically by
devm.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH bpf-next v2 3/3] bpf: treewide: Annotate BPF kfuncs in BTF
From: Jiri Olsa @ 2024-01-06 19:10 UTC (permalink / raw)
To: Daniel Xu
Cc: Jiri Olsa, alexandre.torgue, benjamin.tissoires, lizefan.x,
Herbert Xu, dsahern, hannes, rostedt, mcoquelin.stm32, pablo,
martin.lau, edumazet, daniel, ebiggers, yonghong.song,
john.fastabend, hawk, steffen.klassert, jikos, kuba, fw, ast,
song, pabeni, shuah, tytso, tj, kadlec, davem, mhiramat, andrii,
alexei.starovoitov, quentin, alan.maguire, memxor, kpsingh, sdf,
haoluo, mathieu.desnoyers, mykolal, linux-input, linux-kernel,
fsverity, bpf, cgroups, linux-trace-kernel, netdev,
netfilter-devel, coreteam, linux-kselftest, linux-stm32,
linux-arm-kernel
In-Reply-To: <4tsn6x45gh3vgdst3ozzmxori5gzylvpx6btxue6sbsmx7siok@6wajzdgwxfpa>
On Fri, Jan 05, 2024 at 09:55:43AM -0700, Daniel Xu wrote:
> On Fri, Jan 05, 2024 at 04:11:33PM +0100, Jiri Olsa wrote:
> > On Thu, Jan 04, 2024 at 07:45:49PM -0700, Daniel Xu wrote:
> >
> > SNIP
> >
> > > diff --git a/fs/verity/measure.c b/fs/verity/measure.c
> > > index bf7a5f4cccaf..3969d54158d1 100644
> > > --- a/fs/verity/measure.c
> > > +++ b/fs/verity/measure.c
> > > @@ -159,9 +159,9 @@ __bpf_kfunc int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr_ker
> > >
> > > __bpf_kfunc_end_defs();
> > >
> > > -BTF_SET8_START(fsverity_set_ids)
> > > +BTF_KFUNCS_START(fsverity_set_ids)
> > > BTF_ID_FLAGS(func, bpf_get_fsverity_digest, KF_TRUSTED_ARGS)
> > > -BTF_SET8_END(fsverity_set_ids)
> > > +BTF_KFUNCS_END(fsverity_set_ids)
> > >
> > > static int bpf_get_fsverity_digest_filter(const struct bpf_prog *prog, u32 kfunc_id)
> > > {
> > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> > > index 51e8b4bee0c8..8cc718f37a9d 100644
> > > --- a/kernel/bpf/btf.c
> > > +++ b/kernel/bpf/btf.c
> > > @@ -7802,6 +7802,10 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
> > > {
> > > enum btf_kfunc_hook hook;
> > >
> > > + /* All kfuncs need to be tagged as such in BTF */
> > > + if (WARN_ON(!(kset->set->flags & BTF_SET8_KFUNCS)))
> > > + return -EINVAL;
> >
> > having the warning for module with wrong set8 flags seems wrong to me,
> > I think we should trigger the warn only for kernel calls.. by adding
> > kset->owner check in the condition above
>
> Just checking:
>
> The reasoning is that =m and out-of-tree modules can and should check
> return code, right?
>
> And =y modules or vmlinux-based registrations do not check return code,
> so WARN() is necessary?
>
> If so, I'd agree.
right, I was also concerned we could flood console with loading module
that just uses wrong set8.. perhaps we could just use WARN_ON_ONCE with
no additional checks
jirka
^ permalink raw reply
* [PATCH bpf-next v3 3/3] bpf: treewide: Annotate BPF kfuncs in BTF
From: Daniel Xu @ 2024-01-06 18:24 UTC (permalink / raw)
To: andrii, john.fastabend, pablo, martin.lau, tj, lizefan.x, kadlec,
kuba, edumazet, song, davem, rostedt, Herbert Xu, yonghong.song,
jikos, daniel, hawk, pabeni, alexandre.torgue, mhiramat, hannes,
shuah, steffen.klassert, benjamin.tissoires, ebiggers, ast, fw,
mcoquelin.stm32, tytso, dsahern, alexei.starovoitov, olsajiri,
quentin, alan.maguire, memxor
Cc: kpsingh, sdf, haoluo, jolsa, mathieu.desnoyers, mykolal,
linux-input, linux-kernel, fsverity, bpf, cgroups,
linux-trace-kernel, netdev, netfilter-devel, coreteam,
linux-kselftest, linux-stm32, linux-arm-kernel
In-Reply-To: <cover.1704565248.git.dxu@dxuuu.xyz>
This commit marks kfuncs as such inside the .BTF_ids section. The upshot
of these annotations is that we'll be able to automatically generate
kfunc prototypes for downstream users. The process is as follows:
1. In source, use BTF_KFUNCS_START/END macro pair to mark kfuncs
2. During build, pahole injects into BTF a "bpf_kfunc" BTF_DECL_TAG for
each function inside BTF_KFUNCS sets
3. At runtime, vmlinux or module BTF is made available in sysfs
4. At runtime, bpftool (or similar) can look at provided BTF and
generate appropriate prototypes for functions with "bpf_kfunc" tag
To ensure future kfunc are similarly tagged, we now also return error
inside kfunc registration for untagged kfuncs. For vmlinux kfuncs,
we also WARN(), as initcall machinery does not handle errors.
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
drivers/hid/bpf/hid_bpf_dispatch.c | 8 ++++----
fs/verity/measure.c | 4 ++--
kernel/bpf/btf.c | 8 ++++++++
kernel/bpf/cpumask.c | 4 ++--
kernel/bpf/helpers.c | 8 ++++----
kernel/bpf/map_iter.c | 4 ++--
kernel/cgroup/rstat.c | 4 ++--
kernel/trace/bpf_trace.c | 8 ++++----
net/bpf/test_run.c | 8 ++++----
net/core/filter.c | 16 ++++++++--------
net/core/xdp.c | 4 ++--
net/ipv4/bpf_tcp_ca.c | 4 ++--
net/ipv4/fou_bpf.c | 4 ++--
net/ipv4/tcp_bbr.c | 4 ++--
net/ipv4/tcp_cubic.c | 4 ++--
net/ipv4/tcp_dctcp.c | 4 ++--
net/netfilter/nf_conntrack_bpf.c | 4 ++--
net/netfilter/nf_nat_bpf.c | 4 ++--
net/xfrm/xfrm_interface_bpf.c | 4 ++--
net/xfrm/xfrm_state_bpf.c | 4 ++--
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 8 ++++----
21 files changed, 64 insertions(+), 56 deletions(-)
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c
index d9ef45fcaeab..02c441aaa217 100644
--- a/drivers/hid/bpf/hid_bpf_dispatch.c
+++ b/drivers/hid/bpf/hid_bpf_dispatch.c
@@ -172,9 +172,9 @@ hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr
* The following set contains all functions we agree BPF programs
* can use.
*/
-BTF_SET8_START(hid_bpf_kfunc_ids)
+BTF_KFUNCS_START(hid_bpf_kfunc_ids)
BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL)
-BTF_SET8_END(hid_bpf_kfunc_ids)
+BTF_KFUNCS_END(hid_bpf_kfunc_ids)
static const struct btf_kfunc_id_set hid_bpf_kfunc_set = {
.owner = THIS_MODULE,
@@ -440,12 +440,12 @@ static const struct btf_kfunc_id_set hid_bpf_fmodret_set = {
};
/* for syscall HID-BPF */
-BTF_SET8_START(hid_bpf_syscall_kfunc_ids)
+BTF_KFUNCS_START(hid_bpf_syscall_kfunc_ids)
BTF_ID_FLAGS(func, hid_bpf_attach_prog)
BTF_ID_FLAGS(func, hid_bpf_allocate_context, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, hid_bpf_release_context, KF_RELEASE)
BTF_ID_FLAGS(func, hid_bpf_hw_request)
-BTF_SET8_END(hid_bpf_syscall_kfunc_ids)
+BTF_KFUNCS_END(hid_bpf_syscall_kfunc_ids)
static const struct btf_kfunc_id_set hid_bpf_syscall_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/fs/verity/measure.c b/fs/verity/measure.c
index bf7a5f4cccaf..3969d54158d1 100644
--- a/fs/verity/measure.c
+++ b/fs/verity/measure.c
@@ -159,9 +159,9 @@ __bpf_kfunc int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr_ker
__bpf_kfunc_end_defs();
-BTF_SET8_START(fsverity_set_ids)
+BTF_KFUNCS_START(fsverity_set_ids)
BTF_ID_FLAGS(func, bpf_get_fsverity_digest, KF_TRUSTED_ARGS)
-BTF_SET8_END(fsverity_set_ids)
+BTF_KFUNCS_END(fsverity_set_ids)
static int bpf_get_fsverity_digest_filter(const struct bpf_prog *prog, u32 kfunc_id)
{
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 51e8b4bee0c8..618fdd557730 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -7802,6 +7802,14 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
{
enum btf_kfunc_hook hook;
+ /* All kfuncs need to be tagged as such in BTF.
+ * WARN() for initcall registrations that do not check errors.
+ */
+ if (!(kset->set->flags & BTF_SET8_KFUNCS)) {
+ WARN_ON(!kset->owner);
+ return -EINVAL;
+ }
+
hook = bpf_prog_type_to_kfunc_hook(prog_type);
return __register_btf_kfunc_id_set(hook, kset);
}
diff --git a/kernel/bpf/cpumask.c b/kernel/bpf/cpumask.c
index 2e73533a3811..dad0fb1c8e87 100644
--- a/kernel/bpf/cpumask.c
+++ b/kernel/bpf/cpumask.c
@@ -424,7 +424,7 @@ __bpf_kfunc u32 bpf_cpumask_weight(const struct cpumask *cpumask)
__bpf_kfunc_end_defs();
-BTF_SET8_START(cpumask_kfunc_btf_ids)
+BTF_KFUNCS_START(cpumask_kfunc_btf_ids)
BTF_ID_FLAGS(func, bpf_cpumask_create, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_cpumask_release, KF_RELEASE)
BTF_ID_FLAGS(func, bpf_cpumask_acquire, KF_ACQUIRE | KF_TRUSTED_ARGS)
@@ -450,7 +450,7 @@ BTF_ID_FLAGS(func, bpf_cpumask_copy, KF_RCU)
BTF_ID_FLAGS(func, bpf_cpumask_any_distribute, KF_RCU)
BTF_ID_FLAGS(func, bpf_cpumask_any_and_distribute, KF_RCU)
BTF_ID_FLAGS(func, bpf_cpumask_weight, KF_RCU)
-BTF_SET8_END(cpumask_kfunc_btf_ids)
+BTF_KFUNCS_END(cpumask_kfunc_btf_ids)
static const struct btf_kfunc_id_set cpumask_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index be72824f32b2..277481eef361 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2543,7 +2543,7 @@ __bpf_kfunc void bpf_throw(u64 cookie)
__bpf_kfunc_end_defs();
-BTF_SET8_START(generic_btf_ids)
+BTF_KFUNCS_START(generic_btf_ids)
#ifdef CONFIG_KEXEC_CORE
BTF_ID_FLAGS(func, crash_kexec, KF_DESTRUCTIVE)
#endif
@@ -2572,7 +2572,7 @@ BTF_ID_FLAGS(func, bpf_task_get_cgroup1, KF_ACQUIRE | KF_RCU | KF_RET_NULL)
#endif
BTF_ID_FLAGS(func, bpf_task_from_pid, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_throw)
-BTF_SET8_END(generic_btf_ids)
+BTF_KFUNCS_END(generic_btf_ids)
static const struct btf_kfunc_id_set generic_kfunc_set = {
.owner = THIS_MODULE,
@@ -2588,7 +2588,7 @@ BTF_ID(struct, cgroup)
BTF_ID(func, bpf_cgroup_release_dtor)
#endif
-BTF_SET8_START(common_btf_ids)
+BTF_KFUNCS_START(common_btf_ids)
BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx)
BTF_ID_FLAGS(func, bpf_rdonly_cast)
BTF_ID_FLAGS(func, bpf_rcu_read_lock)
@@ -2617,7 +2617,7 @@ BTF_ID_FLAGS(func, bpf_dynptr_is_null)
BTF_ID_FLAGS(func, bpf_dynptr_is_rdonly)
BTF_ID_FLAGS(func, bpf_dynptr_size)
BTF_ID_FLAGS(func, bpf_dynptr_clone)
-BTF_SET8_END(common_btf_ids)
+BTF_KFUNCS_END(common_btf_ids)
static const struct btf_kfunc_id_set common_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c
index 6abd7c5df4b3..9575314f40a6 100644
--- a/kernel/bpf/map_iter.c
+++ b/kernel/bpf/map_iter.c
@@ -213,9 +213,9 @@ __bpf_kfunc s64 bpf_map_sum_elem_count(const struct bpf_map *map)
__bpf_kfunc_end_defs();
-BTF_SET8_START(bpf_map_iter_kfunc_ids)
+BTF_KFUNCS_START(bpf_map_iter_kfunc_ids)
BTF_ID_FLAGS(func, bpf_map_sum_elem_count, KF_TRUSTED_ARGS)
-BTF_SET8_END(bpf_map_iter_kfunc_ids)
+BTF_KFUNCS_END(bpf_map_iter_kfunc_ids)
static const struct btf_kfunc_id_set bpf_map_iter_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index c0adb7254b45..127858046712 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -520,10 +520,10 @@ void cgroup_base_stat_cputime_show(struct seq_file *seq)
}
/* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */
-BTF_SET8_START(bpf_rstat_kfunc_ids)
+BTF_KFUNCS_START(bpf_rstat_kfunc_ids)
BTF_ID_FLAGS(func, cgroup_rstat_updated)
BTF_ID_FLAGS(func, cgroup_rstat_flush, KF_SLEEPABLE)
-BTF_SET8_END(bpf_rstat_kfunc_ids)
+BTF_KFUNCS_END(bpf_rstat_kfunc_ids)
static const struct btf_kfunc_id_set bpf_rstat_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 7ac6c52b25eb..d786738ae5fa 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1412,14 +1412,14 @@ __bpf_kfunc int bpf_verify_pkcs7_signature(struct bpf_dynptr_kern *data_ptr,
__bpf_kfunc_end_defs();
-BTF_SET8_START(key_sig_kfunc_set)
+BTF_KFUNCS_START(key_sig_kfunc_set)
BTF_ID_FLAGS(func, bpf_lookup_user_key, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE)
BTF_ID_FLAGS(func, bpf_lookup_system_key, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_key_put, KF_RELEASE)
#ifdef CONFIG_SYSTEM_DATA_VERIFICATION
BTF_ID_FLAGS(func, bpf_verify_pkcs7_signature, KF_SLEEPABLE)
#endif
-BTF_SET8_END(key_sig_kfunc_set)
+BTF_KFUNCS_END(key_sig_kfunc_set)
static const struct btf_kfunc_id_set bpf_key_sig_kfunc_set = {
.owner = THIS_MODULE,
@@ -1475,9 +1475,9 @@ __bpf_kfunc int bpf_get_file_xattr(struct file *file, const char *name__str,
__bpf_kfunc_end_defs();
-BTF_SET8_START(fs_kfunc_set_ids)
+BTF_KFUNCS_START(fs_kfunc_set_ids)
BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE | KF_TRUSTED_ARGS)
-BTF_SET8_END(fs_kfunc_set_ids)
+BTF_KFUNCS_END(fs_kfunc_set_ids)
static int bpf_get_file_xattr_filter(const struct bpf_prog *prog, u32 kfunc_id)
{
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index dfd919374017..5535f9adc658 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -617,21 +617,21 @@ CFI_NOSEAL(bpf_kfunc_call_memb_release_dtor);
__bpf_kfunc_end_defs();
-BTF_SET8_START(bpf_test_modify_return_ids)
+BTF_KFUNCS_START(bpf_test_modify_return_ids)
BTF_ID_FLAGS(func, bpf_modify_return_test)
BTF_ID_FLAGS(func, bpf_modify_return_test2)
BTF_ID_FLAGS(func, bpf_fentry_test1, KF_SLEEPABLE)
-BTF_SET8_END(bpf_test_modify_return_ids)
+BTF_KFUNCS_END(bpf_test_modify_return_ids)
static const struct btf_kfunc_id_set bpf_test_modify_return_set = {
.owner = THIS_MODULE,
.set = &bpf_test_modify_return_ids,
};
-BTF_SET8_START(test_sk_check_kfunc_ids)
+BTF_KFUNCS_START(test_sk_check_kfunc_ids)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_release, KF_RELEASE)
BTF_ID_FLAGS(func, bpf_kfunc_call_memb_release, KF_RELEASE)
-BTF_SET8_END(test_sk_check_kfunc_ids)
+BTF_KFUNCS_END(test_sk_check_kfunc_ids)
static void *bpf_test_init(const union bpf_attr *kattr, u32 user_size,
u32 size, u32 headroom, u32 tailroom)
diff --git a/net/core/filter.c b/net/core/filter.c
index 24061f29c9dd..1f2303b9cce7 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -11853,17 +11853,17 @@ int bpf_dynptr_from_skb_rdonly(struct sk_buff *skb, u64 flags,
return 0;
}
-BTF_SET8_START(bpf_kfunc_check_set_skb)
+BTF_KFUNCS_START(bpf_kfunc_check_set_skb)
BTF_ID_FLAGS(func, bpf_dynptr_from_skb)
-BTF_SET8_END(bpf_kfunc_check_set_skb)
+BTF_KFUNCS_END(bpf_kfunc_check_set_skb)
-BTF_SET8_START(bpf_kfunc_check_set_xdp)
+BTF_KFUNCS_START(bpf_kfunc_check_set_xdp)
BTF_ID_FLAGS(func, bpf_dynptr_from_xdp)
-BTF_SET8_END(bpf_kfunc_check_set_xdp)
+BTF_KFUNCS_END(bpf_kfunc_check_set_xdp)
-BTF_SET8_START(bpf_kfunc_check_set_sock_addr)
+BTF_KFUNCS_START(bpf_kfunc_check_set_sock_addr)
BTF_ID_FLAGS(func, bpf_sock_addr_set_sun_path)
-BTF_SET8_END(bpf_kfunc_check_set_sock_addr)
+BTF_KFUNCS_END(bpf_kfunc_check_set_sock_addr)
static const struct btf_kfunc_id_set bpf_kfunc_set_skb = {
.owner = THIS_MODULE,
@@ -11936,9 +11936,9 @@ __bpf_kfunc int bpf_sock_destroy(struct sock_common *sock)
__bpf_kfunc_end_defs();
-BTF_SET8_START(bpf_sk_iter_kfunc_ids)
+BTF_KFUNCS_START(bpf_sk_iter_kfunc_ids)
BTF_ID_FLAGS(func, bpf_sock_destroy, KF_TRUSTED_ARGS)
-BTF_SET8_END(bpf_sk_iter_kfunc_ids)
+BTF_KFUNCS_END(bpf_sk_iter_kfunc_ids)
static int tracing_iter_filter(const struct bpf_prog *prog, u32 kfunc_id)
{
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 4869c1c2d8f3..034fb80f3fbe 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -771,11 +771,11 @@ __bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
__bpf_kfunc_end_defs();
-BTF_SET8_START(xdp_metadata_kfunc_ids)
+BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
#define XDP_METADATA_KFUNC(_, __, name, ___) BTF_ID_FLAGS(func, name, KF_TRUSTED_ARGS)
XDP_METADATA_KFUNC_xxx
#undef XDP_METADATA_KFUNC
-BTF_SET8_END(xdp_metadata_kfunc_ids)
+BTF_KFUNCS_END(xdp_metadata_kfunc_ids)
static const struct btf_kfunc_id_set xdp_metadata_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
index ae8b15e6896f..edecdf8229df 100644
--- a/net/ipv4/bpf_tcp_ca.c
+++ b/net/ipv4/bpf_tcp_ca.c
@@ -195,13 +195,13 @@ bpf_tcp_ca_get_func_proto(enum bpf_func_id func_id,
}
}
-BTF_SET8_START(bpf_tcp_ca_check_kfunc_ids)
+BTF_KFUNCS_START(bpf_tcp_ca_check_kfunc_ids)
BTF_ID_FLAGS(func, tcp_reno_ssthresh)
BTF_ID_FLAGS(func, tcp_reno_cong_avoid)
BTF_ID_FLAGS(func, tcp_reno_undo_cwnd)
BTF_ID_FLAGS(func, tcp_slow_start)
BTF_ID_FLAGS(func, tcp_cong_avoid_ai)
-BTF_SET8_END(bpf_tcp_ca_check_kfunc_ids)
+BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids)
static const struct btf_kfunc_id_set bpf_tcp_ca_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/ipv4/fou_bpf.c b/net/ipv4/fou_bpf.c
index 4da03bf45c9b..06e5572f296f 100644
--- a/net/ipv4/fou_bpf.c
+++ b/net/ipv4/fou_bpf.c
@@ -100,10 +100,10 @@ __bpf_kfunc int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
__bpf_kfunc_end_defs();
-BTF_SET8_START(fou_kfunc_set)
+BTF_KFUNCS_START(fou_kfunc_set)
BTF_ID_FLAGS(func, bpf_skb_set_fou_encap)
BTF_ID_FLAGS(func, bpf_skb_get_fou_encap)
-BTF_SET8_END(fou_kfunc_set)
+BTF_KFUNCS_END(fou_kfunc_set)
static const struct btf_kfunc_id_set fou_bpf_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index 22358032dd48..05dc2d05bc7c 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -1155,7 +1155,7 @@ static struct tcp_congestion_ops tcp_bbr_cong_ops __read_mostly = {
.set_state = bbr_set_state,
};
-BTF_SET8_START(tcp_bbr_check_kfunc_ids)
+BTF_KFUNCS_START(tcp_bbr_check_kfunc_ids)
#ifdef CONFIG_X86
#ifdef CONFIG_DYNAMIC_FTRACE
BTF_ID_FLAGS(func, bbr_init)
@@ -1168,7 +1168,7 @@ BTF_ID_FLAGS(func, bbr_min_tso_segs)
BTF_ID_FLAGS(func, bbr_set_state)
#endif
#endif
-BTF_SET8_END(tcp_bbr_check_kfunc_ids)
+BTF_KFUNCS_END(tcp_bbr_check_kfunc_ids)
static const struct btf_kfunc_id_set tcp_bbr_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 0fd78ecb67e7..44869ea089e3 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -485,7 +485,7 @@ static struct tcp_congestion_ops cubictcp __read_mostly = {
.name = "cubic",
};
-BTF_SET8_START(tcp_cubic_check_kfunc_ids)
+BTF_KFUNCS_START(tcp_cubic_check_kfunc_ids)
#ifdef CONFIG_X86
#ifdef CONFIG_DYNAMIC_FTRACE
BTF_ID_FLAGS(func, cubictcp_init)
@@ -496,7 +496,7 @@ BTF_ID_FLAGS(func, cubictcp_cwnd_event)
BTF_ID_FLAGS(func, cubictcp_acked)
#endif
#endif
-BTF_SET8_END(tcp_cubic_check_kfunc_ids)
+BTF_KFUNCS_END(tcp_cubic_check_kfunc_ids)
static const struct btf_kfunc_id_set tcp_cubic_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index bb23bb5b387a..e33fbe4933e4 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -260,7 +260,7 @@ static struct tcp_congestion_ops dctcp_reno __read_mostly = {
.name = "dctcp-reno",
};
-BTF_SET8_START(tcp_dctcp_check_kfunc_ids)
+BTF_KFUNCS_START(tcp_dctcp_check_kfunc_ids)
#ifdef CONFIG_X86
#ifdef CONFIG_DYNAMIC_FTRACE
BTF_ID_FLAGS(func, dctcp_init)
@@ -271,7 +271,7 @@ BTF_ID_FLAGS(func, dctcp_cwnd_undo)
BTF_ID_FLAGS(func, dctcp_state)
#endif
#endif
-BTF_SET8_END(tcp_dctcp_check_kfunc_ids)
+BTF_KFUNCS_END(tcp_dctcp_check_kfunc_ids)
static const struct btf_kfunc_id_set tcp_dctcp_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/netfilter/nf_conntrack_bpf.c b/net/netfilter/nf_conntrack_bpf.c
index 475358ec8212..d2492d050fe6 100644
--- a/net/netfilter/nf_conntrack_bpf.c
+++ b/net/netfilter/nf_conntrack_bpf.c
@@ -467,7 +467,7 @@ __bpf_kfunc int bpf_ct_change_status(struct nf_conn *nfct, u32 status)
__bpf_kfunc_end_defs();
-BTF_SET8_START(nf_ct_kfunc_set)
+BTF_KFUNCS_START(nf_ct_kfunc_set)
BTF_ID_FLAGS(func, bpf_xdp_ct_alloc, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_xdp_ct_lookup, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_skb_ct_alloc, KF_ACQUIRE | KF_RET_NULL)
@@ -478,7 +478,7 @@ BTF_ID_FLAGS(func, bpf_ct_set_timeout, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_ct_change_timeout, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_ct_set_status, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_ct_change_status, KF_TRUSTED_ARGS)
-BTF_SET8_END(nf_ct_kfunc_set)
+BTF_KFUNCS_END(nf_ct_kfunc_set)
static const struct btf_kfunc_id_set nf_conntrack_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/netfilter/nf_nat_bpf.c b/net/netfilter/nf_nat_bpf.c
index 6e3b2f58855f..481be15609b1 100644
--- a/net/netfilter/nf_nat_bpf.c
+++ b/net/netfilter/nf_nat_bpf.c
@@ -54,9 +54,9 @@ __bpf_kfunc int bpf_ct_set_nat_info(struct nf_conn___init *nfct,
__bpf_kfunc_end_defs();
-BTF_SET8_START(nf_nat_kfunc_set)
+BTF_KFUNCS_START(nf_nat_kfunc_set)
BTF_ID_FLAGS(func, bpf_ct_set_nat_info, KF_TRUSTED_ARGS)
-BTF_SET8_END(nf_nat_kfunc_set)
+BTF_KFUNCS_END(nf_nat_kfunc_set)
static const struct btf_kfunc_id_set nf_bpf_nat_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/xfrm/xfrm_interface_bpf.c b/net/xfrm/xfrm_interface_bpf.c
index 7d5e920141e9..5ea15037ebd1 100644
--- a/net/xfrm/xfrm_interface_bpf.c
+++ b/net/xfrm/xfrm_interface_bpf.c
@@ -93,10 +93,10 @@ __bpf_kfunc int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx, const struct bp
__bpf_kfunc_end_defs();
-BTF_SET8_START(xfrm_ifc_kfunc_set)
+BTF_KFUNCS_START(xfrm_ifc_kfunc_set)
BTF_ID_FLAGS(func, bpf_skb_get_xfrm_info)
BTF_ID_FLAGS(func, bpf_skb_set_xfrm_info)
-BTF_SET8_END(xfrm_ifc_kfunc_set)
+BTF_KFUNCS_END(xfrm_ifc_kfunc_set)
static const struct btf_kfunc_id_set xfrm_interface_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/net/xfrm/xfrm_state_bpf.c b/net/xfrm/xfrm_state_bpf.c
index 9e20d4a377f7..2248eda741f8 100644
--- a/net/xfrm/xfrm_state_bpf.c
+++ b/net/xfrm/xfrm_state_bpf.c
@@ -117,10 +117,10 @@ __bpf_kfunc void bpf_xdp_xfrm_state_release(struct xfrm_state *x)
__bpf_kfunc_end_defs();
-BTF_SET8_START(xfrm_state_kfunc_set)
+BTF_KFUNCS_START(xfrm_state_kfunc_set)
BTF_ID_FLAGS(func, bpf_xdp_get_xfrm_state, KF_RET_NULL | KF_ACQUIRE)
BTF_ID_FLAGS(func, bpf_xdp_xfrm_state_release, KF_RELEASE)
-BTF_SET8_END(xfrm_state_kfunc_set)
+BTF_KFUNCS_END(xfrm_state_kfunc_set)
static const struct btf_kfunc_id_set xfrm_state_xdp_kfunc_set = {
.owner = THIS_MODULE,
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index 91907b321f91..9faaefbe4a07 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -341,12 +341,12 @@ static struct bin_attribute bin_attr_bpf_testmod_file __ro_after_init = {
.write = bpf_testmod_test_write,
};
-BTF_SET8_START(bpf_testmod_common_kfunc_ids)
+BTF_KFUNCS_START(bpf_testmod_common_kfunc_ids)
BTF_ID_FLAGS(func, bpf_iter_testmod_seq_new, KF_ITER_NEW)
BTF_ID_FLAGS(func, bpf_iter_testmod_seq_next, KF_ITER_NEXT | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_iter_testmod_seq_destroy, KF_ITER_DESTROY)
BTF_ID_FLAGS(func, bpf_kfunc_common_test)
-BTF_SET8_END(bpf_testmod_common_kfunc_ids)
+BTF_KFUNCS_END(bpf_testmod_common_kfunc_ids)
static const struct btf_kfunc_id_set bpf_testmod_common_kfunc_set = {
.owner = THIS_MODULE,
@@ -492,7 +492,7 @@ __bpf_kfunc static u32 bpf_kfunc_call_test_static_unused_arg(u32 arg, u32 unused
return arg;
}
-BTF_SET8_START(bpf_testmod_check_kfunc_ids)
+BTF_KFUNCS_START(bpf_testmod_check_kfunc_ids)
BTF_ID_FLAGS(func, bpf_testmod_test_mod_kfunc)
BTF_ID_FLAGS(func, bpf_kfunc_call_test1)
BTF_ID_FLAGS(func, bpf_kfunc_call_test2)
@@ -518,7 +518,7 @@ BTF_ID_FLAGS(func, bpf_kfunc_call_test_ref, KF_TRUSTED_ARGS | KF_RCU)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_destructive, KF_DESTRUCTIVE)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_static_unused_arg)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_offset)
-BTF_SET8_END(bpf_testmod_check_kfunc_ids)
+BTF_KFUNCS_END(bpf_testmod_check_kfunc_ids)
static const struct btf_kfunc_id_set bpf_testmod_kfunc_set = {
.owner = THIS_MODULE,
--
2.42.1
^ permalink raw reply related
* [PATCH bpf-next v3 0/3] Annotate kfuncs in .BTF_ids section
From: Daniel Xu @ 2024-01-06 18:24 UTC (permalink / raw)
To: linux-input, coreteam, linux-arm-kernel, linux-kernel,
netfilter-devel, linux-kselftest, linux-trace-kernel, fsverity,
bpf, netdev, linux-stm32, cgroups, alexei.starovoitov, olsajiri,
quentin, alan.maguire, memxor
=== Description ===
This is a bpf-treewide change that annotates all kfuncs as such inside
.BTF_ids. This annotation eventually allows us to automatically generate
kfunc prototypes from bpftool.
We store this metadata inside a yet-unused flags field inside struct
btf_id_set8 (thanks Kumar!). pahole will be taught where to look.
More details about the full chain of events are available in commit 3's
description.
The accompanying pahole changes (still needs some cleanup) can be viewed
here on this "frozen" branch [0].
[0]: https://github.com/danobi/pahole/tree/kfunc_btf-mailed
=== Changelog ===
Changes from v2:
* Only WARN() for vmlinux kfuncs
Changes from v1:
* Move WARN_ON() up a call level
* Also return error when kfunc set is not properly tagged
* Use BTF_KFUNCS_START/END instead of flags
* Rename BTF_SET8_KFUNC to BTF_SET8_KFUNCS
Daniel Xu (3):
bpf: btf: Support flags for BTF_SET8 sets
bpf: btf: Add BTF_KFUNCS_START/END macro pair
bpf: treewide: Annotate BPF kfuncs in BTF
drivers/hid/bpf/hid_bpf_dispatch.c | 8 +++----
fs/verity/measure.c | 4 ++--
include/linux/btf_ids.h | 21 +++++++++++++++----
kernel/bpf/btf.c | 8 +++++++
kernel/bpf/cpumask.c | 4 ++--
kernel/bpf/helpers.c | 8 +++----
kernel/bpf/map_iter.c | 4 ++--
kernel/cgroup/rstat.c | 4 ++--
kernel/trace/bpf_trace.c | 8 +++----
net/bpf/test_run.c | 8 +++----
net/core/filter.c | 16 +++++++-------
net/core/xdp.c | 4 ++--
net/ipv4/bpf_tcp_ca.c | 4 ++--
net/ipv4/fou_bpf.c | 4 ++--
net/ipv4/tcp_bbr.c | 4 ++--
net/ipv4/tcp_cubic.c | 4 ++--
net/ipv4/tcp_dctcp.c | 4 ++--
net/netfilter/nf_conntrack_bpf.c | 4 ++--
net/netfilter/nf_nat_bpf.c | 4 ++--
net/xfrm/xfrm_interface_bpf.c | 4 ++--
net/xfrm/xfrm_state_bpf.c | 4 ++--
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 8 +++----
22 files changed, 81 insertions(+), 60 deletions(-)
--
2.42.1
^ permalink raw reply
* [PATCH] xpad: support 'share' button of 8BitDo Pro 2
From: Leonardo Brondani Schenkel @ 2024-01-06 12:11 UTC (permalink / raw)
To: linux-input; +Cc: Leonardo Brondani Schenkel
I have a 8BitDo Pro 2 Wired Controller for Xbox. This is a licensed
"Series S|X" type controller with a 'share' button below the big Xbox
button. The xpad driver has explicit support for this controller but was
not generating any raw input events when this button was pressed.
Analysis of GIP packet dumps showed that this button is reported via
byte 18, not byte 22 that the driver expects. As this is a licensed
product and the button works in Windows with the official Microsoft
drivers, it looks like both bytes are being used in the wild.
Another user confirmed the same findings:
> I can confirm that the official Microsoft controller I have reports
> the Share button in byte 22 (counting GIP_CMD_INPUT as byte 0) and the
> Hori Fighting Commander Octa reports the Share button in byte 18.
https://github.com/medusalix/xone/pull/17#issuecomment-1470807446
Therefore mark this controller as supporting the 'share' button, and
also recognize byte 18 as a 'share' button press. The latter will
benefit similar third-party controllers that report using the same byte.
Signed-off-by: Leonardo Brondani Schenkel <leonardo@schenkel.net>
---
drivers/input/joystick/xpad.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 1a58629c12b9..3b67c783b7b6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -357,7 +357,7 @@ static const struct xpad_device {
{ 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 },
{ 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
{ 0x2563, 0x058d, "OneXPlayer Gamepad", 0, XTYPE_XBOX360 },
- { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
+ { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SELECT_BUTTON, XTYPE_XBOXONE },
{ 0x2dc8, 0x3106, "8BitDo Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
{ 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 },
{ 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 },
@@ -1008,7 +1008,8 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
input_report_key(dev, BTN_START, data[4] & BIT(2));
input_report_key(dev, BTN_SELECT, data[4] & BIT(3));
if (xpad->mapping & MAP_SELECT_BUTTON)
- input_report_key(dev, KEY_RECORD, data[22] & BIT(0));
+ /* official controllers use byte 22 and some third-party use byte 18 */
+ input_report_key(dev, KEY_RECORD, data[22] & BIT(0) || data[18] & BIT(0));
/* buttons A,B,X,Y */
input_report_key(dev, BTN_A, data[4] & BIT(4));
--
2.43.0
^ permalink raw reply related
* [PATCH v12 2/2] input: joystick: driver for Adafruit Seesaw Gamepad
From: Anshul Dalal @ 2024-01-06 1:51 UTC (permalink / raw)
To: linux-input, devicetree
Cc: Anshul Dalal, Conor Dooley, Dmitry Torokhov,
Thomas Weißschuh, linux-kernel, Krzysztof Kozlowski,
Conor Dooley, Rob Herring, Krzysztof Kozlowski, Jeff LaBundy,
linux-kernel-mentees
In-Reply-To: <20240106015111.882325-1-anshulusr@gmail.com>
Adds a driver for a mini gamepad that communicates over i2c, the gamepad
has bidirectional thumb stick input and six buttons.
The gamepad chip utilizes the open framework from Adafruit called 'Seesaw'
to transmit the ADC data for the joystick and digital pin state for the
buttons. I have only implemented the functionality required to receive the
thumb stick and button state.
Steps in reading the gamepad state over i2c:
1. Reset the registers
2. Set the pin mode of the pins specified by the `BUTTON_MASK` to input
`BUTTON_MASK`: A bit-map for the six digital pins internally
connected to the joystick buttons.
3. Enable internal pullup resistors for the `BUTTON_MASK`
4. Bulk set the pin state HIGH for `BUTTON_MASK`
5. Poll the device for button and joystick state done by:
`seesaw_read_data(struct i2c_client *client, struct seesaw_data *data)`
Product page:
https://www.adafruit.com/product/5743
Arduino driver:
https://github.com/adafruit/Adafruit_Seesaw
Driver tested on RPi Zero 2W
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Anshul Dalal <anshulusr@gmail.com>
---
Changes for v12:
- Added time unit of ms to SEESAW_GAMEPAD_POLL_INTERVAL_MS
- Use a single u16 register as argument instead of two u8s in:
seesaw_register_read
seesaw_register_write_u8
seesaw_register_write_u32
- Fixed improper usage of varaible name 'ret' where an error should be
reported
Changes for v11:
- Removed `of_match_ptr` to prevent warning:
'seesaw_of_table' defined but not used
on non OF platforms
Changes for v10:
- no updates
Changes for v9:
- Added of_device_id
Changes for v8:
- Updated invalid references to `adafruit_seesaw` to `adafruit-seesaw`
Changes for v7:
adafruit-seesaw.c
- Fixed formatting for macro definitions
- Made SEESAW_BUTTON_MASK static const
- Removed __be16 type for x and y fields of seesaw_data
- Used sparse_keymap implementation instead of custom keymap
- Used i2c_msg instead of i2c_master_send and recv in
seesaw_register_read
- Use temporary variable `adc_data` to store data received from ADC
- Changed read_buf from u8[4] to __be32
- Use usleep_range instead of msleep
- Removed 'Reviewed-by: Thomas Weißschuh' due to large number of changes
since last review
Kconfig:
- Added `select INPUT_SPARSEKMAP`
Changes for v6:
- Added TODO
- Removed `clang-format` directives
- Namespaced device buttons
- Removed `char physical_path[32]` field from `struct seesaw_gamepad`
- Added `packed` attribute to `struct seesaw_data`
- Moved from having booleans per button to single `u32 button_state`
- Added `seesaw_button_description` array to directly associate device
buttons with respective keycodes
- Added wrapper functions `seesaw_register_` around `i2c_master_` API
- Ratelimited input error reporting with `dev_err_ratelimited`
- Removed `of_device_id`
Changes for v5:
- Added link to the datasheet
- Added debug log message when `seesaw_read_data` fails
Changes for v4:
- Changed `1UL << BUTTON_` to BIT(BUTTON_)
- Removed `hardware_id` field from `struct seesaw_gamepad`
- Removed redundant checks for the number of bytes written and received by
`i2c_master_send` and `i2c_master_recv`
- Used `get_unaligned_be32` to instantiate `u32 result` from `read_buf`
- Changed `result & (1UL << BUTTON_)` to
`test_bit(BUTTON_, (long *)&result)`
- Changed `KBUILD_MODNAME` in id-tables to `SEESAW_DEVICE_NAME`
- Fixed formatting issues
- Changed button reporting:
Since the gamepad had the action buttons in a non-standard layout:
(X)
(Y) (A)
(B)
Therefore moved to using generic directional action button event codes
instead of BTN_[ABXY].
Changes for v3:
- no updates
Changes for v2:
adafruit-seesaw.c:
- Renamed file from 'adafruit_seesaw.c'
- Changed device name from 'seesaw_gamepad' to 'seesaw-gamepad'
- Changed count parameter for receiving joystick x on line 118:
`2` to `sizeof(write_buf)`
- Fixed invalid buffer size on line 123 and 126:
`data->y` to `sizeof(data->y)`
- Added comment for the `mdelay(10)` on line 169
- Changed inconsistent indentation on line 271
Kconfig:
- Fixed indentation for the help text
- Updated module name
Makefile:
- Updated module object file name
MAINTAINERS:
- Updated file name for the driver and bindings
Previous versions:
v11: https://lore.kernel.org/lkml/20231215031125.284939-2-anshulusr@gmail.com/
v10: https://lore.kernel.org/lkml/20231121123409.2231115-2-anshulusr@gmail.com/
v9: https://lore.kernel.org/lkml/20231121101751.2189965-2-anshulusr@gmail.com/
v8: https://lore.kernel.org/lkml/20231108005337.45069-2-anshulusr@gmail.com/
v7: https://lore.kernel.org/lkml/20231106164134.114668-2-anshulusr@gmail.com/
v6: https://lore.kernel.org/lkml/20231027051819.81333-2-anshulusr@gmail.com/
v5: https://lore.kernel.org/lkml/20231017034356.1436677-2-anshulusr@gmail.com/
v4: https://lore.kernel.org/lkml/20231010184827.1213507-2-anshulusr@gmail.com/
v3: https://lore.kernel.org/linux-input/20231008185709.2448423-2-anshulusr@gmail.com/
v2: https://lore.kernel.org/linux-input/20231008172435.2391009-2-anshulusr@gmail.com/
v1: https://lore.kernel.org/linux-input/20231007144052.1535417-2-anshulusr@gmail.com/
---
MAINTAINERS | 7 +
drivers/input/joystick/Kconfig | 10 +
drivers/input/joystick/Makefile | 1 +
drivers/input/joystick/adafruit-seesaw.c | 312 +++++++++++++++++++++++
4 files changed, 330 insertions(+)
create mode 100644 drivers/input/joystick/adafruit-seesaw.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 81d5fc0bba68..b3f101edc24b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -441,6 +441,13 @@ W: http://wiki.analog.com/AD7879
W: https://ez.analog.com/linux-software-drivers
F: drivers/input/touchscreen/ad7879.c
+ADAFRUIT MINI I2C GAMEPAD
+M: Anshul Dalal <anshulusr@gmail.com>
+L: linux-input@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/input/adafruit,seesaw-gamepad.yaml
+F: drivers/input/joystick/adafruit-seesaw.c
+
ADDRESS SPACE LAYOUT RANDOMIZATION (ASLR)
M: Jiri Kosina <jikos@kernel.org>
S: Maintained
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index ac6925ce8366..7755e5b454d2 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -412,4 +412,14 @@ config JOYSTICK_SENSEHAT
To compile this driver as a module, choose M here: the
module will be called sensehat_joystick.
+config JOYSTICK_SEESAW
+ tristate "Adafruit Mini I2C Gamepad with Seesaw"
+ depends on I2C
+ select INPUT_SPARSEKMAP
+ help
+ Say Y here if you want to use the Adafruit Mini I2C Gamepad.
+
+ To compile this driver as a module, choose M here: the module will be
+ called adafruit-seesaw.
+
endif
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
index 3937535f0098..9976f596a920 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_JOYSTICK_N64) += n64joy.o
obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o
obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o
obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o
+obj-$(CONFIG_JOYSTICK_SEESAW) += adafruit-seesaw.o
obj-$(CONFIG_JOYSTICK_SENSEHAT) += sensehat-joystick.o
obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o
obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o
diff --git a/drivers/input/joystick/adafruit-seesaw.c b/drivers/input/joystick/adafruit-seesaw.c
new file mode 100644
index 000000000000..5aff3b3c97ac
--- /dev/null
+++ b/drivers/input/joystick/adafruit-seesaw.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2023 Anshul Dalal <anshulusr@gmail.com>
+ *
+ * Driver for Adafruit Mini I2C Gamepad
+ *
+ * Based on the work of:
+ * Oleh Kravchenko (Sparkfun Qwiic Joystick driver)
+ *
+ * Datasheet: https://cdn-learn.adafruit.com/downloads/pdf/gamepad-qt.pdf
+ * Product page: https://www.adafruit.com/product/5743
+ * Firmware and hardware sources: https://github.com/adafruit/Adafruit_Seesaw
+ *
+ * TODO:
+ * - Add interrupt support
+ */
+
+#include <asm/unaligned.h>
+#include <linux/bits.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#define SEESAW_DEVICE_NAME "seesaw-gamepad"
+
+#define SEESAW_ADC_BASE 0x0900
+
+#define SEESAW_GPIO_DIRCLR_BULK 0x0103
+#define SEESAW_GPIO_BULK 0x0104
+#define SEESAW_GPIO_BULK_SET 0x0105
+#define SEESAW_GPIO_PULLENSET 0x010b
+
+#define SEESAW_STATUS_HW_ID 0x0001
+#define SEESAW_STATUS_SWRST 0x007f
+
+#define SEESAW_ADC_OFFSET 0x07
+
+#define SEESAW_BUTTON_A 0x05
+#define SEESAW_BUTTON_B 0x01
+#define SEESAW_BUTTON_X 0x06
+#define SEESAW_BUTTON_Y 0x02
+#define SEESAW_BUTTON_START 0x10
+#define SEESAW_BUTTON_SELECT 0x00
+
+#define SEESAW_ANALOG_X 0x0e
+#define SEESAW_ANALOG_Y 0x0f
+
+#define SEESAW_JOYSTICK_MAX_AXIS 1023
+#define SEESAW_JOYSTICK_FUZZ 2
+#define SEESAW_JOYSTICK_FLAT 4
+
+#define SEESAW_GAMEPAD_POLL_INTERVAL_MS 16
+#define SEESAW_GAMEPAD_POLL_MIN 8
+#define SEESAW_GAMEPAD_POLL_MAX 32
+
+static const u32 SEESAW_BUTTON_MASK =
+ BIT(SEESAW_BUTTON_A) | BIT(SEESAW_BUTTON_B) | BIT(SEESAW_BUTTON_X) |
+ BIT(SEESAW_BUTTON_Y) | BIT(SEESAW_BUTTON_START) |
+ BIT(SEESAW_BUTTON_SELECT);
+
+struct seesaw_gamepad {
+ struct input_dev *input_dev;
+ struct i2c_client *i2c_client;
+};
+
+struct seesaw_data {
+ u16 x;
+ u16 y;
+ u32 button_state;
+};
+
+static const struct key_entry seesaw_buttons_new[] = {
+ { KE_KEY, SEESAW_BUTTON_A, .keycode = BTN_SOUTH },
+ { KE_KEY, SEESAW_BUTTON_B, .keycode = BTN_EAST },
+ { KE_KEY, SEESAW_BUTTON_X, .keycode = BTN_NORTH },
+ { KE_KEY, SEESAW_BUTTON_Y, .keycode = BTN_WEST },
+ { KE_KEY, SEESAW_BUTTON_START, .keycode = BTN_START },
+ { KE_KEY, SEESAW_BUTTON_SELECT, .keycode = BTN_SELECT },
+ { KE_END, 0 }
+};
+
+static int seesaw_register_read(struct i2c_client *client, u16 reg, void *buf,
+ int count)
+{
+ int ret;
+ __be16 register_buf = cpu_to_be16(reg);
+ struct i2c_msg message_buf[2] = {
+ {
+ .addr = client->addr,
+ .flags = client->flags,
+ .len = sizeof(register_buf),
+ .buf = (u8 *)®ister_buf,
+ },
+ {
+ .addr = client->addr,
+ .flags = client->flags | I2C_M_RD,
+ .len = count,
+ .buf = (u8 *)buf,
+ },
+ };
+
+ ret = i2c_transfer(client->adapter, message_buf,
+ ARRAY_SIZE(message_buf));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int seesaw_register_write_u8(struct i2c_client *client, u16 reg,
+ u8 value)
+{
+ int ret;
+ u8 write_buf[3];
+
+ put_unaligned_be16(reg, write_buf);
+ write_buf[sizeof(reg)] = value;
+
+ ret = i2c_master_send(client, write_buf, sizeof(write_buf));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int seesaw_register_write_u32(struct i2c_client *client, u16 reg,
+ u32 value)
+{
+ int ret;
+ u8 write_buf[6];
+
+ put_unaligned_be16(reg, write_buf);
+ put_unaligned_be32(value, write_buf + sizeof(reg));
+ ret = i2c_master_send(client, write_buf, sizeof(write_buf));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int seesaw_read_data(struct i2c_client *client, struct seesaw_data *data)
+{
+ int err;
+ __be16 adc_data;
+ __be32 read_buf;
+
+ err = seesaw_register_read(client, SEESAW_GPIO_BULK, (char *)&read_buf,
+ sizeof(read_buf));
+ if (err)
+ return err;
+
+ data->button_state = ~be32_to_cpu(read_buf);
+
+ err = seesaw_register_read(
+ client, SEESAW_ADC_BASE | (SEESAW_ADC_OFFSET + SEESAW_ANALOG_X),
+ (char *)&adc_data, sizeof(adc_data));
+ if (err)
+ return err;
+ /*
+ * ADC reads left as max and right as 0, must be reversed since kernel
+ * expects reports in opposite order.
+ */
+ data->x = SEESAW_JOYSTICK_MAX_AXIS - be16_to_cpu(adc_data);
+
+ err = seesaw_register_read(
+ client, SEESAW_ADC_BASE | (SEESAW_ADC_OFFSET + SEESAW_ANALOG_Y),
+ (char *)&adc_data, sizeof(adc_data));
+ if (err)
+ return err;
+ data->y = be16_to_cpu(adc_data);
+
+ return 0;
+}
+
+static void seesaw_poll(struct input_dev *input)
+{
+ int err, i;
+ struct seesaw_gamepad *private = input_get_drvdata(input);
+ struct seesaw_data data;
+
+ err = seesaw_read_data(private->i2c_client, &data);
+ if (err) {
+ dev_err_ratelimited(&input->dev,
+ "failed to read joystick state: %d\n", err);
+ return;
+ }
+
+ input_report_abs(input, ABS_X, data.x);
+ input_report_abs(input, ABS_Y, data.y);
+
+ for_each_set_bit(i, (long *)&SEESAW_BUTTON_MASK,
+ BITS_PER_TYPE(SEESAW_BUTTON_MASK)) {
+ if (!sparse_keymap_report_event(input, i,
+ data.button_state & BIT(i),
+ false))
+ dev_err_ratelimited(&input->dev,
+ "failed to report keymap event");
+ }
+
+ input_sync(input);
+}
+
+static int seesaw_probe(struct i2c_client *client)
+{
+ int err;
+ u8 hardware_id;
+ struct seesaw_gamepad *seesaw;
+
+ err = seesaw_register_write_u8(client, SEESAW_STATUS_SWRST, 0xFF);
+ if (err)
+ return err;
+
+ /* Wait for the registers to reset before proceeding */
+ usleep_range(10000, 15000);
+
+ seesaw = devm_kzalloc(&client->dev, sizeof(*seesaw), GFP_KERNEL);
+ if (!seesaw)
+ return -ENOMEM;
+
+ err = seesaw_register_read(client, SEESAW_STATUS_HW_ID, &hardware_id,
+ sizeof(hardware_id));
+ if (err)
+ return err;
+
+ dev_dbg(&client->dev, "Adafruit Seesaw Gamepad, Hardware ID: %02x\n",
+ hardware_id);
+
+ /* Set Pin Mode to input and enable pull-up resistors */
+ err = seesaw_register_write_u32(client, SEESAW_GPIO_DIRCLR_BULK,
+ SEESAW_BUTTON_MASK);
+ if (err)
+ return err;
+ err = seesaw_register_write_u32(client, SEESAW_GPIO_PULLENSET,
+ SEESAW_BUTTON_MASK);
+ if (err)
+ return err;
+ err = seesaw_register_write_u32(client, SEESAW_GPIO_BULK_SET,
+ SEESAW_BUTTON_MASK);
+ if (err)
+ return err;
+
+ seesaw->i2c_client = client;
+ seesaw->input_dev = devm_input_allocate_device(&client->dev);
+ if (!seesaw->input_dev)
+ return -ENOMEM;
+
+ seesaw->input_dev->id.bustype = BUS_I2C;
+ seesaw->input_dev->name = "Adafruit Seesaw Gamepad";
+ seesaw->input_dev->phys = "i2c/" SEESAW_DEVICE_NAME;
+ input_set_drvdata(seesaw->input_dev, seesaw);
+ input_set_abs_params(seesaw->input_dev, ABS_X, 0,
+ SEESAW_JOYSTICK_MAX_AXIS, SEESAW_JOYSTICK_FUZZ,
+ SEESAW_JOYSTICK_FLAT);
+ input_set_abs_params(seesaw->input_dev, ABS_Y, 0,
+ SEESAW_JOYSTICK_MAX_AXIS, SEESAW_JOYSTICK_FUZZ,
+ SEESAW_JOYSTICK_FLAT);
+
+ err = sparse_keymap_setup(seesaw->input_dev, seesaw_buttons_new, NULL);
+ if (err) {
+ dev_err(&client->dev,
+ "failed to set up input device keymap: %d\n", err);
+ return err;
+ }
+
+ err = input_setup_polling(seesaw->input_dev, seesaw_poll);
+ if (err) {
+ dev_err(&client->dev, "failed to set up polling: %d\n", err);
+ return err;
+ }
+
+ input_set_poll_interval(seesaw->input_dev,
+ SEESAW_GAMEPAD_POLL_INTERVAL_MS);
+ input_set_max_poll_interval(seesaw->input_dev, SEESAW_GAMEPAD_POLL_MAX);
+ input_set_min_poll_interval(seesaw->input_dev, SEESAW_GAMEPAD_POLL_MIN);
+
+ err = input_register_device(seesaw->input_dev);
+ if (err) {
+ dev_err(&client->dev, "failed to register joystick: %d\n", err);
+ return err;
+ }
+
+ return 0;
+}
+
+static const struct i2c_device_id seesaw_id_table[] = {
+ { SEESAW_DEVICE_NAME },
+ { /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, seesaw_id_table);
+
+static const struct of_device_id seesaw_of_table[] = {
+ { .compatible = "adafruit,seesaw-gamepad"},
+ { /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, seesaw_of_table);
+
+static struct i2c_driver seesaw_driver = {
+ .driver = {
+ .name = SEESAW_DEVICE_NAME,
+ .of_match_table = seesaw_of_table,
+ },
+ .id_table = seesaw_id_table,
+ .probe = seesaw_probe,
+};
+module_i2c_driver(seesaw_driver);
+
+MODULE_AUTHOR("Anshul Dalal <anshulusr@gmail.com>");
+MODULE_DESCRIPTION("Adafruit Mini I2C Gamepad driver");
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related
* [PATCH v12 1/2] dt-bindings: input: bindings for Adafruit Seesaw Gamepad
From: Anshul Dalal @ 2024-01-06 1:50 UTC (permalink / raw)
To: linux-input, devicetree
Cc: Anshul Dalal, Conor Dooley, Dmitry Torokhov,
Thomas Weißschuh, linux-kernel, Krzysztof Kozlowski,
Conor Dooley, Rob Herring, Krzysztof Kozlowski, Jeff LaBundy,
linux-kernel-mentees
Adds bindings for the Adafruit Seesaw Gamepad.
The gamepad functions as an i2c device with the default address of 0x50
and has an IRQ pin that can be enabled in the driver to allow for a rising
edge trigger on each button press or joystick movement.
Product page:
https://www.adafruit.com/product/5743
Arduino driver:
https://github.com/adafruit/Adafruit_Seesaw
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Anshul Dalal <anshulusr@gmail.com>
---
Changes for v11,12:
- no updates
Changes for v10:
- Added interrupt-controller/irq.h header
Changes for v9:
- Added interrupt in example
Changes for v8:
- no updates
Changes for v7:
- no updates
Changes for v6:
- no updates
Changes for v5:
- Added link to the datasheet
Changes for v4:
- Fixed the URI for the id field
- Added `interrupts` property
Changes for v3:
- Updated id field to reflect updated file name from previous version
- Added `reg` property
Changes for v2:
- Renamed file to `adafruit,seesaw-gamepad.yaml`
- Removed quotes for `$id` and `$schema`
- Removed "Bindings for" from the description
- Changed node name to the generic name "joystick"
- Changed compatible to 'adafruit,seesaw-gamepad' instead of
'adafruit,seesaw_gamepad'
Previous versions:
v11: https://lore.kernel.org/lkml/20231215031125.284939-1-anshulusr@gmail.com/
v10: https://lore.kernel.org/lkml/20231121123409.2231115-1-anshulusr@gmail.com/
v9: https://lore.kernel.org/lkml/20231121101751.2189965-1-anshulusr@gmail.com/
v8: https://lore.kernel.org/lkml/20231108005337.45069-1-anshulusr@gmail.com/
v7: https://lore.kernel.org/lkml/20231106164134.114668-1-anshulusr@gmail.com/
v6: https://lore.kernel.org/lkml/20231027051819.81333-1-anshulusr@gmail.com/
v5: https://lore.kernel.org/lkml/20231017034356.1436677-1-anshulusr@gmail.com/
v4: https://lore.kernel.org/lkml/20231010184827.1213507-1-anshulusr@gmail.com/
v3: https://lore.kernel.org/linux-input/20231008185709.2448423-1-anshulusr@gmail.com/
v2: https://lore.kernel.org/linux-input/20231008172435.2391009-1-anshulusr@gmail.com/
v1: https://lore.kernel.org/linux-input/20231007144052.1535417-1-anshulusr@gmail.com/
---
.../input/adafruit,seesaw-gamepad.yaml | 63 +++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/adafruit,seesaw-gamepad.yaml
diff --git a/Documentation/devicetree/bindings/input/adafruit,seesaw-gamepad.yaml b/Documentation/devicetree/bindings/input/adafruit,seesaw-gamepad.yaml
new file mode 100644
index 000000000000..5e86f6de6978
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/adafruit,seesaw-gamepad.yaml
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/adafruit,seesaw-gamepad.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Adafruit Mini I2C Gamepad with seesaw
+
+maintainers:
+ - Anshul Dalal <anshulusr@gmail.com>
+
+description: |
+ Adafruit Mini I2C Gamepad
+
+ +-----------------------------+
+ | ___ |
+ | / \ (X) |
+ | | S | __ __ (Y) (A) |
+ | \___/ |ST| |SE| (B) |
+ | |
+ +-----------------------------+
+
+ S -> 10-bit precision bidirectional analog joystick
+ ST -> Start
+ SE -> Select
+ X, A, B, Y -> Digital action buttons
+
+ Datasheet: https://cdn-learn.adafruit.com/downloads/pdf/gamepad-qt.pdf
+ Product page: https://www.adafruit.com/product/5743
+ Arduino Driver: https://github.com/adafruit/Adafruit_Seesaw
+
+properties:
+ compatible:
+ const: adafruit,seesaw-gamepad
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+ description:
+ The gamepad's IRQ pin triggers a rising edge if interrupts are enabled.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ joystick@50 {
+ compatible = "adafruit,seesaw-gamepad";
+ interrupts = <18 IRQ_TYPE_EDGE_RISING>;
+ reg = <0x50>;
+ };
+ };
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v4 2/2] i8042: Use new forcenorestore quirk to replace old buggy quirk combination
From: Hans de Goede @ 2024-01-05 19:38 UTC (permalink / raw)
To: Werner Sembach, dmitry.torokhov; +Cc: linux-input, linux-kernel
In-Reply-To: <20240104183118.779778-3-wse@tuxedocomputers.com>
Hi,
On 1/4/24 19:31, Werner Sembach wrote:
> The old quirk combination sometimes cause a laggy keyboard after boot. With
> the new quirk the initial issue of an unresponsive keyboard after s3 resume
> is also fixed, but it doesn't have the negative side effect of the
> sometimes laggy keyboard.
>
> Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
> Cc: stable@vger.kernel.org
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/input/serio/i8042-acpipnpio.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/input/serio/i8042-acpipnpio.h b/drivers/input/serio/i8042-acpipnpio.h
> index 10ec4534e5e14..e631a26394e92 100644
> --- a/drivers/input/serio/i8042-acpipnpio.h
> +++ b/drivers/input/serio/i8042-acpipnpio.h
> @@ -1142,18 +1142,10 @@ static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = {
> SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
> },
> {
> - /*
> - * Setting SERIO_QUIRK_NOMUX or SERIO_QUIRK_RESET_ALWAYS makes
> - * the keyboard very laggy for ~5 seconds after boot and
> - * sometimes also after resume.
> - * However both are required for the keyboard to not fail
> - * completely sometimes after boot or resume.
> - */
> .matches = {
> DMI_MATCH(DMI_BOARD_NAME, "N150CU"),
> },
> - .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
> - SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
> + .driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
> },
> {
> .matches = {
^ permalink raw reply
* Re: [PATCH v4 1/2] i8042: Add forcenorestore quirk to leave controller untouched even on s3
From: Hans de Goede @ 2024-01-05 19:38 UTC (permalink / raw)
To: Werner Sembach, dmitry.torokhov; +Cc: linux-input, linux-kernel
In-Reply-To: <20240104183118.779778-2-wse@tuxedocomputers.com>
Hi,
On 1/4/24 19:31, Werner Sembach wrote:
> On s3 resume the i8042 driver tries to restore the controller to a known
> state by reinitializing things, however this can confuse the controller
> with different effects. Mostly occasionally unresponsive keyboards after
> resume.
>
> These issues do not rise on s0ix resume as here the controller is assumed
> to preserved its state from before suspend.
>
> This patch adds a quirk for devices where the reinitialization on s3 resume
> is not needed and might be harmful as described above. It does this by
> using the s0ix resume code path at selected locations.
>
> This new quirk goes beyond what the preexisting reset=never quirk does,
> which only skips some reinitialization steps.
>
> Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
> Cc: stable@vger.kernel.org
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/input/serio/i8042-acpipnpio.h | 10 +++++++---
> drivers/input/serio/i8042.c | 10 +++++++---
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/serio/i8042-acpipnpio.h b/drivers/input/serio/i8042-acpipnpio.h
> index b585b1dab870e..10ec4534e5e14 100644
> --- a/drivers/input/serio/i8042-acpipnpio.h
> +++ b/drivers/input/serio/i8042-acpipnpio.h
> @@ -83,6 +83,7 @@ static inline void i8042_write_command(int val)
> #define SERIO_QUIRK_KBDRESET BIT(12)
> #define SERIO_QUIRK_DRITEK BIT(13)
> #define SERIO_QUIRK_NOPNP BIT(14)
> +#define SERIO_QUIRK_FORCENORESTORE BIT(15)
>
> /* Quirk table for different mainboards. Options similar or identical to i8042
> * module parameters.
> @@ -1657,6 +1658,8 @@ static void __init i8042_check_quirks(void)
> if (quirks & SERIO_QUIRK_NOPNP)
> i8042_nopnp = true;
> #endif
> + if (quirks & SERIO_QUIRK_FORCENORESTORE)
> + i8042_forcenorestore = true;
> }
> #else
> static inline void i8042_check_quirks(void) {}
> @@ -1690,7 +1693,7 @@ static int __init i8042_platform_init(void)
>
> i8042_check_quirks();
>
> - pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
> + pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
> i8042_nokbd ? " nokbd" : "",
> i8042_noaux ? " noaux" : "",
> i8042_nomux ? " nomux" : "",
> @@ -1710,10 +1713,11 @@ static int __init i8042_platform_init(void)
> "",
> #endif
> #ifdef CONFIG_PNP
> - i8042_nopnp ? " nopnp" : "");
> + i8042_nopnp ? " nopnp" : "",
> #else
> - "");
> + "",
> #endif
> + i8042_forcenorestore ? " forcenorestore" : "");
>
> retval = i8042_pnp_init();
> if (retval)
> diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
> index 9fbb8d31575ae..2233d93f90e81 100644
> --- a/drivers/input/serio/i8042.c
> +++ b/drivers/input/serio/i8042.c
> @@ -115,6 +115,10 @@ module_param_named(nopnp, i8042_nopnp, bool, 0);
> MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
> #endif
>
> +static bool i8042_forcenorestore;
> +module_param_named(forcenorestore, i8042_forcenorestore, bool, 0);
> +MODULE_PARM_DESC(forcenorestore, "Force no restore on s3 resume, copying s2idle behaviour");
> +
> #define DEBUG
> #ifdef DEBUG
> static bool i8042_debug;
> @@ -1232,7 +1236,7 @@ static int i8042_pm_suspend(struct device *dev)
> {
> int i;
>
> - if (pm_suspend_via_firmware())
> + if (!i8042_forcenorestore && pm_suspend_via_firmware())
> i8042_controller_reset(true);
>
> /* Set up serio interrupts for system wakeup. */
> @@ -1248,7 +1252,7 @@ static int i8042_pm_suspend(struct device *dev)
>
> static int i8042_pm_resume_noirq(struct device *dev)
> {
> - if (!pm_resume_via_firmware())
> + if (i8042_forcenorestore || !pm_resume_via_firmware())
> i8042_interrupt(0, NULL);
>
> return 0;
> @@ -1271,7 +1275,7 @@ static int i8042_pm_resume(struct device *dev)
> * not restore the controller state to whatever it had been at boot
> * time, so we do not need to do anything.
> */
> - if (!pm_suspend_via_firmware())
> + if (i8042_forcenorestore || !pm_suspend_via_firmware())
> return 0;
>
> /*
^ permalink raw reply
* Re: [PATCH v6 2/4] Input: touch-overlay - Add touchscreen overlay handling
From: Javier Carrasco @ 2024-01-05 19:21 UTC (permalink / raw)
To: Jeff LaBundy
Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Henrik Rydberg, Bastian Hecht, Michael Riesch, linux-kernel,
linux-input, devicetree
In-Reply-To: <ZZB9x+0eNL8e+xI3@nixie71>
Hi Jeff,
On 30.12.23 21:29, Jeff LaBundy wrote:
> Having reviewed this version in detail, it's clear how the implementation
> imposes this restriction. However, it's not clear why we have to have this
> restriction straight out of the gate; it also breaks the "square doughnut"
> example we discussed in v5, where a button resides inside a touch surface
> which is split into four discrete rectangles that report X/Y coordinates
> relative to the same origin.
>
> From my naive point of view, a driver should merely pass a contact's ID
> (for HW that can track contacts), coordinates, and pressure. Your helper(s)
> are then responisble for iterating over the list, determining the segment
> in which the coordinates fall, and then reporting the event by way of
> input_report_abs() or input_report_key() based on whether or not a keycode
> is defined.
>
> I think the problem with that approach is that touchscreen drivers only
> report coordinates when the pressure is nonzero. The process of dropping
> a contact, i.e. button release for some segments, happens inside input-mt
> by virtue of the driver calling input_mt_sync_frame().
>
> It makes sense now why you are duplicating the contact tracking to a degree
> here. Therefore, it's starting to look more and more like the overlay segment
> handling needs to move into the input-mt core, where much of the information
> you need already exists.
>
> If we look at input_mt_report_pointer_emulation(), the concept of button
> release is already happening; all we really want to do here is gently
> expand the core to understand that some ranges of coordinates are simply
> quantized to a keycode with binary pressure (i.e. press/release).
>
> In addition to removing duplicate code as well as the restriction of supporting
> only one X/Y surface, moving overlay support into the input-mt core would
> remove the need to modify each touchscreen driver one at a time with what
> are largely the same nontrivial changes. If we think about it more, the
> touchscreen controller itself is not changing, so the driver really shouldn't
> have to change much either.
>
> Stated another way, I think it's a better design pattern if we let drivers
> continue to do their job of merely lobbing hardware state to the input
> subsytem via input_mt_slot(), touchscreen_report_pos() and input_mt_sync_frame(),
> then leave it to the input subsystem alone to iterate over the list and
> determine whether some coordinates must be handled differently.
>
> The main drawback to this approach is that the overlay buttons would need
> to go back to being part of the touchscreen input device as in v1, as opposed
> to giving the driver the flexibility of splitting the buttons and X/Y surfaces
> into two separate input devices.
>
> When we first discussed this with Peter, we agreed that splitting them into two
> input devices grants the most flexibility, in case user space opts to inhibit
> one but not the other, etc. However since the buttons and X/Y surfaces are all
> part of the same physical substrate, it seems the chances of user space being
> interested in one but not the other are low.
>
> Furthermore, folding the buttons and X/Y surfaces back into the same input
> device would remove the need for each touchscreen driver to preemptively
> allocate a second input device, but then remove it later as in patch [4/4]
> in case the helpers did not find any buttons.
>
> What are your thoughts on evolving the approach in this way? It's obviously
> another big change and carries some risk to the core, so I'm curious to hear
> Dmitry's and others' thoughts as well. I appreciate that you've been iterating
> on this for some time, and good is not the enemy of great; therefore, maybe
> a compromise is to move forward with the current approach in support of the
> hardware you have today, then work it into the input-mt core over time. But
> it would be nice to avoid ripping up participating touchscreen drivers twice.
>
> Thank you for your patience and continued effort. In the meantime, please note
> some minor comments that are independent of this architectural decision.
>
Thanks again for your thorough reviews and proposals to improve the code.
I am basically open to any solution that improves the quality of the
feature. If I get you right, moving everything to the input-mt core
would hide the overlay stuff from the device drivers (which sounds good)
and a bit of code could be simplified by using the existing infrastructure.
On the other hand, adding this feature to the input-mt core right away
increases the risk of breaking things that many users need. We are
already using this feature in some prototypes since v1 without any issue
so far, but it would be great if it could be tested under different
circumstances (hardware, configurations, etc.) before it goes into the
core, wouldn't it?
I would also like to know what more experienced people think about it,
if we should go all out and add it to the input-mt core now or as you
also suggested, move forward with the current approach and let it
"mature" first. The cost of that would be modifying device driver code
twice, but I suppose that not so many drivers will add this feature in
the next kernel iterations... maybe you? it sounds like that you might
have a use case for it :)
>> +struct button {
>> + u32 key;
>> + bool pressed;
>> + int slot;
>> +};
>> +
>> +struct touch_overlay_segment {
>> + struct list_head list;
>> + u32 x_origin;
>> + u32 y_origin;
>> + u32 x_size;
>> + u32 y_size;
>> + struct button *btn;
>
> I think you can simply declare the struct itself here as opposed to a pointer to
> one; this would avoid a second call to devm_kzalloc().
>
That was the other option I mentioned in my reply and I am fine with the
modification you propose.
>> + if (fwnode_property_present(segment_node, "linux,code")) {
>
> Instead of walking the device tree twice by calling fwnode_property_present()
> followed by fwnode_property_read_u32(), you can simply check whether the
> latter returns -EINVAL, which indicates the optional property was absent.
>
Ack.
>> + segment->btn = devm_kzalloc(dev, sizeof(*segment->btn),
>> + GFP_KERNEL);
>> + if (!segment->btn)
>> + return -ENOMEM;
>> +
>> + fwnode_for_each_child_node(overlay, fw_segment) {
>> + segment = devm_kzalloc(dev, sizeof(*segment), GFP_KERNEL);
>> + if (!segment) {
>> + error = -ENOMEM;
>> + goto put_overlay;
>
> For this and the below case where you exit the loop early in case of an
> error, you must call fwnode_handle_put(fw_segment) manually. The reference
> count is handled automatically only when the loop iterates and terminates
> naturally.
>
> Since nothing else happens between the loop and the 'put_overlay' label,
> you can also replace the goto with a break and remove the label altogether.
>
Ack.
>
> Kind regards,
> Jeff LaBundy
Thanks and best regards,
Javier Carrasco
^ permalink raw reply
* Re: [PATCH bpf-next v2 3/3] bpf: treewide: Annotate BPF kfuncs in BTF
From: Daniel Xu @ 2024-01-05 16:55 UTC (permalink / raw)
To: Jiri Olsa
Cc: alexandre.torgue, benjamin.tissoires, lizefan.x, Herbert Xu,
dsahern, hannes, rostedt, mcoquelin.stm32, pablo, martin.lau,
edumazet, daniel, ebiggers, yonghong.song, john.fastabend, hawk,
steffen.klassert, jikos, kuba, fw, ast, song, pabeni, shuah,
tytso, tj, kadlec, davem, mhiramat, andrii, alexei.starovoitov,
quentin, alan.maguire, memxor, kpsingh, sdf, haoluo,
mathieu.desnoyers, mykolal, linux-input, linux-kernel, fsverity,
bpf, cgroups, linux-trace-kernel, netdev, netfilter-devel,
coreteam, linux-kselftest, linux-stm32, linux-arm-kernel
In-Reply-To: <ZZgcJTdwMZHglPtr@krava>
On Fri, Jan 05, 2024 at 04:11:33PM +0100, Jiri Olsa wrote:
> On Thu, Jan 04, 2024 at 07:45:49PM -0700, Daniel Xu wrote:
>
> SNIP
>
> > diff --git a/fs/verity/measure.c b/fs/verity/measure.c
> > index bf7a5f4cccaf..3969d54158d1 100644
> > --- a/fs/verity/measure.c
> > +++ b/fs/verity/measure.c
> > @@ -159,9 +159,9 @@ __bpf_kfunc int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr_ker
> >
> > __bpf_kfunc_end_defs();
> >
> > -BTF_SET8_START(fsverity_set_ids)
> > +BTF_KFUNCS_START(fsverity_set_ids)
> > BTF_ID_FLAGS(func, bpf_get_fsverity_digest, KF_TRUSTED_ARGS)
> > -BTF_SET8_END(fsverity_set_ids)
> > +BTF_KFUNCS_END(fsverity_set_ids)
> >
> > static int bpf_get_fsverity_digest_filter(const struct bpf_prog *prog, u32 kfunc_id)
> > {
> > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> > index 51e8b4bee0c8..8cc718f37a9d 100644
> > --- a/kernel/bpf/btf.c
> > +++ b/kernel/bpf/btf.c
> > @@ -7802,6 +7802,10 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
> > {
> > enum btf_kfunc_hook hook;
> >
> > + /* All kfuncs need to be tagged as such in BTF */
> > + if (WARN_ON(!(kset->set->flags & BTF_SET8_KFUNCS)))
> > + return -EINVAL;
>
> having the warning for module with wrong set8 flags seems wrong to me,
> I think we should trigger the warn only for kernel calls.. by adding
> kset->owner check in the condition above
Just checking:
The reasoning is that =m and out-of-tree modules can and should check
return code, right?
And =y modules or vmlinux-based registrations do not check return code,
so WARN() is necessary?
If so, I'd agree.
[..]
Thanks,
Daniel
^ permalink raw reply
* Re: [PATCH v5 1/5] firmware: cs_dsp: Add write sequencer interface
From: Charles Keepax @ 2024-01-05 16:36 UTC (permalink / raw)
To: James Ogletree
Cc: James Ogletree, Fred Treven, Ben Bright, Dmitry Torokhov,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Simon Trimmer,
Richard Fitzgerald, Lee Jones, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, James Schulman, David Rhodes,
Jeff LaBundy, Alexandre Belloni, Peng Fan, Jacky Bai,
Sebastian Reichel, Weidong Wang, Arnd Bergmann, Herve Codina,
Shenghao Ding, Ryan Lee, Linus Walleij, Maxim Kochetkov,
Ajye Huang, Pierre-Louis Bossart, Shuming Fan,
open list:CIRRUS LOGIC HAPTIC DRIVERS,
open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS
In-Reply-To: <20240104223643.876292-2-jogletre@opensource.cirrus.com>
On Thu, Jan 04, 2024 at 10:36:34PM +0000, James Ogletree wrote:
> A write sequencer is a sequence of register addresses
> and values executed by some Cirrus DSPs following
> power-up or exit from hibernation, used for avoiding
> the overhead of bus transactions.
>
> Add support for Cirrus drivers to update or add to a
> write sequencer present in firmware.
>
> Signed-off-by: James Ogletree <jogletre@opensource.cirrus.com>
> ---
> drivers/firmware/cirrus/cs_dsp.c | 261 +++++++++++++++++++++++++
> include/linux/firmware/cirrus/cs_dsp.h | 28 +++
> 2 files changed, 289 insertions(+)
>
> diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
> index 79d4254d1f9b..31a999f42e84 100644
> --- a/drivers/firmware/cirrus/cs_dsp.c
> +++ b/drivers/firmware/cirrus/cs_dsp.c
> @@ -275,6 +275,15 @@
> #define HALO_MPU_VIO_ERR_SRC_MASK 0x00007fff
> #define HALO_MPU_VIO_ERR_SRC_SHIFT 0
>
> +/*
> + * Write Sequencer
> + */
> +#define WSEQ_OP_FULL_WORDS 3
> +#define WSEQ_OP_X16_WORDS 2
> +#define WSEQ_OP_END_WORDS 1
> +#define WSEQ_OP_UNLOCK_WORDS 1
> +#define WSEQ_END_OF_SCRIPT 0xFFFFFF
> +
> struct cs_dsp_ops {
> bool (*validate_version)(struct cs_dsp *dsp, unsigned int version);
> unsigned int (*parse_sizes)(struct cs_dsp *dsp,
> @@ -2233,6 +2242,111 @@ static int cs_dsp_create_name(struct cs_dsp *dsp)
> return 0;
> }
>
> +struct cs_dsp_wseq_op {
> + struct list_head list;
> + u32 words[3];
> + u32 address;
> + u32 data;
> + u16 offset;
> + u8 operation;
> +};
> +
> +static int cs_dsp_populate_wseq(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq)
> +{
> + struct cs_dsp_wseq_op *op = NULL;
> + struct cs_dsp_chunk ch;
> + int i, num_words, ret;
> + u32 *words;
> +
> + if (wseq->size <= 0 || !wseq->reg)
> + return -EINVAL;
I would be tempted to give this an error message.
> +
> + words = kcalloc(wseq->size, sizeof(u32), GFP_KERNEL);
> + if (!words)
> + return -ENOMEM;
> +
> + INIT_LIST_HEAD(&wseq->ops);
> +
> + ret = regmap_raw_read(dsp->regmap, wseq->reg, words,
> + wseq->size * sizeof(u32));
> + if (ret)
> + goto err_free;
> +
> + ch = cs_dsp_chunk(words, wseq->size * sizeof(u32));
> +
> + for (i = 0; i < wseq->size; i += num_words) {
Can just drop num_words and i, and just do:
while(!cs_dsp_chunk_end(&ch)) {
Also allows you to drop the length defines for each OP.
> + op = devm_kzalloc(dsp->dev, sizeof(*op), GFP_KERNEL);
> + if (!op) {
> + ret = -ENOMEM;
> + goto err_free;
> + }
> +
> + op->offset = ch.bytes;
Use cs_dsp_chunk_bytes, cleaner to not access the internals
directly incase we need to refactor them at some point.
> + op->operation = cs_dsp_chunk_read(&ch, 8);
> +
> + switch (op->operation) {
> + case CS_DSP_WSEQ_END:
> + num_words = WSEQ_OP_END_WORDS;
> + break;
> + case CS_DSP_WSEQ_UNLOCK:
> + num_words = WSEQ_OP_UNLOCK_WORDS;
> + op->address = 0;
> + op->data = cs_dsp_chunk_read(&ch, 16);
> + break;
> + case CS_DSP_WSEQ_ADDR8:
> + case CS_DSP_WSEQ_H16:
> + case CS_DSP_WSEQ_L16:
> + num_words = WSEQ_OP_X16_WORDS;
> + op->address = cs_dsp_chunk_read(&ch, 24);
> + op->data = cs_dsp_chunk_read(&ch, 16);
> + break;
> + case CS_DSP_WSEQ_FULL:
> + num_words = WSEQ_OP_FULL_WORDS;
> + op->address = cs_dsp_chunk_read(&ch, 32);
> + op->data = cs_dsp_chunk_read(&ch, 32);
> + break;
> + default:
> + ret = -EINVAL;
> + cs_dsp_err(dsp, "Unsupported op: %u\n", op->operation);
> + goto err_free;
> + }
> +
> + list_add(&op->list, &wseq->ops);
> +
> + if (op->operation == CS_DSP_WSEQ_END)
> + break;
> + }
> +
> + if (op && op->operation != CS_DSP_WSEQ_END)
> + ret = -ENOENT;
This definitely wants an error message, since this indicates the
firmware is in a broken state, or the buffer passed in was not a
write sequence.
> +err_free:
> + kfree(words);
> +
> + return ret;
> +}
> +
> +/**
> + * cs_dsp_wseq_init() - Initialize write sequences contained within the loaded DSP firmware
> + * @dsp: pointer to DSP structure
> + * @wseqs: list of write sequences to initialize
> + * @num_wseqs: number of write sequences to initialize
> + *
> + * Return: Zero for success, a negative number on error.
> + */
> +int cs_dsp_wseq_init(struct cs_dsp *dsp, struct cs_dsp_wseq *wseqs, unsigned int num_wseqs)
> +{
> + int i, ret;
> +
> + for (i = 0; i < num_wseqs; i++) {
> + ret = cs_dsp_populate_wseq(dsp, &wseqs[i]);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(cs_dsp_wseq_init);
> +
This location in the middle of the file is a bit weird, would be
nicer to keep all the wseq stuff together move this down to the
bottom of the file with the other functions.
> static int cs_dsp_common_init(struct cs_dsp *dsp)
> {
> int ret;
> @@ -3339,6 +3453,153 @@ int cs_dsp_chunk_read(struct cs_dsp_chunk *ch, int nbits)
> }
> EXPORT_SYMBOL_NS_GPL(cs_dsp_chunk_read, FW_CS_DSP);
>
> +static struct cs_dsp_wseq_op *cs_dsp_wseq_find_op(u8 op_code, u32 addr,
> + struct list_head *wseq_ops)
> +{
> + struct cs_dsp_wseq_op *op;
> +
> + list_for_each_entry(op, wseq_ops, list) {
> + if (op->operation == op_code && op->address == addr)
> + return op;
> + }
> +
> + return NULL;
> +}
> +
> +/**
> + * cs_dsp_wseq_write() - Add or update an entry in a write sequence
> + * @dsp: Pointer to a DSP structure
> + * @wseq: Write sequence to write to
> + * @addr: Address of the register to be written to
> + * @data: Data to be written
> + * @update: If true, searches for the first entry in the Write Sequencer with
> + * the same address and op_code, and replaces it. If false, creates a new entry
> + * at the tail.
> + * @op_code: The type of operation of the new entry
> + *
> + * This function formats register address and value pairs into the format
> + * required for write sequence entries, and either updates or adds the
> + * new entry into the write sequence.
> + *
> + * Return: Zero for success, a negative number on error.
> + */
> +int cs_dsp_wseq_write(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq,
> + u32 addr, u32 data, bool update, u8 op_code)
Feels weird to have the op_code after the update flag in the
order of arguments. addr, data and op_code are all parts of
the new entry they should go together. Also be nice for the API
to be consistent in the order it uses them, wseq_find_op is
op_code, addr.
> +{
> + struct cs_dsp_wseq_op *op_end, *op_new;
> + struct cs_dsp_chunk ch;
> + u32 wseq_bytes;
> + int new_op_size, ret;
> +
> + if (update) {
> + op_new = cs_dsp_wseq_find_op(op_code, addr, &wseq->ops);
> + if (!op_new)
> + return -EINVAL;
This could also have an error message.
> + } else {
I would be tempted to pull the init of op_end up here like:
op_end = cs_dsp_wseq_find_op(CS_DSP_WSEQ_END, 0, &wseq->ops);
if (!op_end) {
cs_dsp_err(dsp, "Missing write sequencer list terminator\n");
return -EINVAL;
}
> + op_new = devm_kzalloc(dsp->dev, sizeof(*op_new), GFP_KERNEL);
> + if (!op_new)
> + return -ENOMEM;
> +
> + op_new->operation = op_code;
> + op_new->address = addr;
And:
op_new->offset = op_end->offset;
> + }
> +
> + op_new->data = data;
> +
> + ch = cs_dsp_chunk((void *) op_new->words,
> + WSEQ_OP_FULL_WORDS * sizeof(u32));
Since this is the only place you use op->words make it a local
variable, its only 3 ints on the stack and it saves having 3
redundant ints in every op in the list.
> + cs_dsp_chunk_write(&ch, 8, op_new->operation);
> + switch (op_code) {
> + case CS_DSP_WSEQ_FULL:
> + cs_dsp_chunk_write(&ch, 32, op_new->address);
> + cs_dsp_chunk_write(&ch, 32, op_new->data);
> + break;
> + case CS_DSP_WSEQ_L16:
> + case CS_DSP_WSEQ_H16:
> + cs_dsp_chunk_write(&ch, 24, op_new->address);
> + cs_dsp_chunk_write(&ch, 16, op_new->data);
> + break;
> + default:
> + ret = -EINVAL;
> + goto op_new_free;
This also could have an error message, in general I would
recommend have error messages for places where handling
arguments from the user of the API. It is much more friendly
for other developers, since they get immediate feedback if
when they do something wrong when using the API.
> + }
> +
With op_end pre-initialised this bit becomes:
> + new_op_size = cs_dsp_chunk_bytes(&ch);
> +
> + wseq_bytes = wseq->size * sizeof(u32);
> +
> + if (wseq_bytes - op_end->offset < new_op_size) {
> + cs_dsp_err(dsp, "Not enough memory in Write Sequencer for entry\n");
> + ret = -ENOMEM;
> + goto op_new_free;
> + }
> +
> + ret = regmap_raw_write(dsp->regmap, wseq->reg + op_new->offset,
> + op_new->words, new_op_size);
> + if (ret)
> + goto op_new_free;
> +
> + if (!update) {
Then pull the shift of op_end->offset into here:
op_end->offset += new_op_size;
> + ret = regmap_write(dsp->regmap, wseq->reg + op_end->offset,
> + WSEQ_END_OF_SCRIPT);
> + if (ret)
> + goto op_new_free;
> +
> + list_add(&op_new->list, &wseq->ops);
> + }
> +
> + return 0;
> +
> +op_new_free:
> + devm_kfree(dsp->dev, op_new);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(cs_dsp_wseq_write);
> +
> +/**
> + * cs_dsp_wseq_multi_write() - Add or update multiple entries in the write sequence
> + * @dsp: Pointer to a DSP structure
> + * @wseq: Write sequence to write to
> + * @reg_seq: List of address-data pairs
> + * @num_regs: Number of address-data pairs
> + * @update: If true, searches for the first entry in the write sequence with the same
> + * address and op code, and replaces it. If false, creates a new entry at the tail.
> + * @op_code: The types of operations of the new entries
> + *
> + * This function calls cs_dsp_wseq_write() for multiple address-data pairs.
> + *
> + * Return: Zero for success, a negative number on error.
> + */
> +int cs_dsp_wseq_multi_write(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq,
> + const struct reg_sequence *reg_seq,
> + int num_regs, bool update, u8 op_code)
> +{
> + int ret, i;
> +
> + for (i = 0; i < num_regs; i++) {
> + ret = cs_dsp_wseq_write(dsp, wseq, reg_seq[i].reg,
> + reg_seq[i].def, update, op_code);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(cs_dsp_wseq_multi_write);
> +
> MODULE_DESCRIPTION("Cirrus Logic DSP Support");
> MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>");
> MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/firmware/cirrus/cs_dsp.h b/include/linux/firmware/cirrus/cs_dsp.h
> index 29cd11d5a3cf..d674fc061e9d 100644
> --- a/include/linux/firmware/cirrus/cs_dsp.h
> +++ b/include/linux/firmware/cirrus/cs_dsp.h
> @@ -42,6 +42,16 @@
> #define CS_DSP_ACKED_CTL_MIN_VALUE 0
> #define CS_DSP_ACKED_CTL_MAX_VALUE 0xFFFFFF
>
> +/*
> + * Write sequencer operation codes
> + */
> +#define CS_DSP_WSEQ_FULL 0x00
> +#define CS_DSP_WSEQ_ADDR8 0x02
> +#define CS_DSP_WSEQ_L16 0x04
> +#define CS_DSP_WSEQ_H16 0x05
> +#define CS_DSP_WSEQ_UNLOCK 0xFD
> +#define CS_DSP_WSEQ_END 0xFF
> +
> /**
> * struct cs_dsp_region - Describes a logical memory region in DSP address space
> * @type: Memory region type
> @@ -107,6 +117,18 @@ struct cs_dsp_coeff_ctl {
> struct cs_dsp_ops;
> struct cs_dsp_client_ops;
>
> +/**
> + * struct cs_dsp_wseq - Describes a write sequence
> + * @reg: Address of the head of the write sequence register
> + * @size: Size of the write sequence in words
The only user that wants the size in words is the loop counter
that can be deleted. Is there any reason not to specify the
size in bytes?
> + * @ops: Operations contained within the write sequence
> + */
> +struct cs_dsp_wseq {
> + unsigned int reg;
> + unsigned int size;
> + struct list_head ops;
> +};
> +
> /**
> * struct cs_dsp - Configuration and state of a Cirrus Logic DSP
> * @name: The name of the DSP instance
> @@ -254,6 +276,12 @@ struct cs_dsp_alg_region *cs_dsp_find_alg_region(struct cs_dsp *dsp,
> int type, unsigned int id);
>
> const char *cs_dsp_mem_region_name(unsigned int type);
> +int cs_dsp_wseq_init(struct cs_dsp *dsp, struct cs_dsp_wseq *wseqs, unsigned int num_wseqs);
> +int cs_dsp_wseq_write(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq, u32 addr, u32 data,
> + bool update, u8 op_code);
> +int cs_dsp_wseq_multi_write(struct cs_dsp *dsp, struct cs_dsp_wseq *wseq,
> + const struct reg_sequence *reg_seq,
> + int num_regs, bool update, u8 op_code);
>
This is also pretty spaced through the file, leave the defines
where they are, but gather the struct and the funcs and move
them to the bottom of the file in a group. Keeps all the API
together when someone is looking it up.
> /**
> * struct cs_dsp_chunk - Describes a buffer holding data formatted for the DSP
> --
> 2.25.1
>
Overall my only other concern is still the register based API
rather than control based. I guess there is some precident
with the compressed stuff although that is at least taking
addresses from the DSP and translating them into register
addresses so the host can use them.
Richard is off today, but back on Monday let me discuss with
him then and we should have a chat too.
Thanks,
Charles
^ permalink raw reply
* Re: [PATCH bpf-next v2 0/3] Annotate kfuncs in .BTF_ids section
From: Jiri Olsa @ 2024-01-05 15:19 UTC (permalink / raw)
To: Daniel Xu
Cc: bpf, fsverity, linux-kernel, linux-trace-kernel, linux-kselftest,
netfilter-devel, coreteam, linux-input, linux-arm-kernel,
linux-stm32, cgroups, netdev, alexei.starovoitov, olsajiri,
quentin, alan.maguire, memxor
In-Reply-To: <cover.1704422454.git.dxu@dxuuu.xyz>
On Thu, Jan 04, 2024 at 07:45:46PM -0700, Daniel Xu wrote:
> === Description ===
>
> This is a bpf-treewide change that annotates all kfuncs as such inside
> .BTF_ids. This annotation eventually allows us to automatically generate
> kfunc prototypes from bpftool.
>
> We store this metadata inside a yet-unused flags field inside struct
> btf_id_set8 (thanks Kumar!). pahole will be taught where to look.
>
> More details about the full chain of events are available in commit 3's
> description.
>
> The accompanying pahole changes (still needs some cleanup) can be viewed
> here on this "frozen" branch [0].
>
> [0]: https://github.com/danobi/pahole/tree/kfunc_btf-mailed
great, lgtm.. seems I've got the tags in right places (128 kfuncs)
please send it on the list once you're done with that, so we could
comment on that
thanks,
jirka
>
> === Changelog ===
>
> Changes from v1:
> * Move WARN_ON() up a call level
> * Also return error when kfunc set is not properly tagged
> * Use BTF_KFUNCS_START/END instead of flags
> * Rename BTF_SET8_KFUNC to BTF_SET8_KFUNCS
>
> Daniel Xu (3):
> bpf: btf: Support flags for BTF_SET8 sets
> bpf: btf: Add BTF_KFUNCS_START/END macro pair
> bpf: treewide: Annotate BPF kfuncs in BTF
>
> drivers/hid/bpf/hid_bpf_dispatch.c | 8 +++----
> fs/verity/measure.c | 4 ++--
> include/linux/btf_ids.h | 21 +++++++++++++++----
> kernel/bpf/btf.c | 4 ++++
> kernel/bpf/cpumask.c | 4 ++--
> kernel/bpf/helpers.c | 8 +++----
> kernel/bpf/map_iter.c | 4 ++--
> kernel/cgroup/rstat.c | 4 ++--
> kernel/trace/bpf_trace.c | 8 +++----
> net/bpf/test_run.c | 8 +++----
> net/core/filter.c | 16 +++++++-------
> net/core/xdp.c | 4 ++--
> net/ipv4/bpf_tcp_ca.c | 4 ++--
> net/ipv4/fou_bpf.c | 4 ++--
> net/ipv4/tcp_bbr.c | 4 ++--
> net/ipv4/tcp_cubic.c | 4 ++--
> net/ipv4/tcp_dctcp.c | 4 ++--
> net/netfilter/nf_conntrack_bpf.c | 4 ++--
> net/netfilter/nf_nat_bpf.c | 4 ++--
> net/xfrm/xfrm_interface_bpf.c | 4 ++--
> net/xfrm/xfrm_state_bpf.c | 4 ++--
> .../selftests/bpf/bpf_testmod/bpf_testmod.c | 8 +++----
> 22 files changed, 77 insertions(+), 60 deletions(-)
>
> --
> 2.42.1
>
^ permalink raw reply
* Re: [PATCH bpf-next v2 3/3] bpf: treewide: Annotate BPF kfuncs in BTF
From: Jiri Olsa @ 2024-01-05 15:11 UTC (permalink / raw)
To: Daniel Xu
Cc: alexandre.torgue, benjamin.tissoires, lizefan.x, Herbert Xu,
dsahern, hannes, rostedt, mcoquelin.stm32, pablo, martin.lau,
edumazet, daniel, ebiggers, yonghong.song, john.fastabend, hawk,
steffen.klassert, jikos, kuba, fw, ast, song, pabeni, shuah,
tytso, tj, kadlec, davem, mhiramat, andrii, alexei.starovoitov,
olsajiri, quentin, alan.maguire, memxor, kpsingh, sdf, haoluo,
mathieu.desnoyers, mykolal, linux-input, linux-kernel, fsverity,
bpf, cgroups, linux-trace-kernel, netdev, netfilter-devel,
coreteam, linux-kselftest, linux-stm32, linux-arm-kernel
In-Reply-To: <a923e3809955bdfd2bc8d6a103c20e01f1636dbc.1704422454.git.dxu@dxuuu.xyz>
On Thu, Jan 04, 2024 at 07:45:49PM -0700, Daniel Xu wrote:
SNIP
> diff --git a/fs/verity/measure.c b/fs/verity/measure.c
> index bf7a5f4cccaf..3969d54158d1 100644
> --- a/fs/verity/measure.c
> +++ b/fs/verity/measure.c
> @@ -159,9 +159,9 @@ __bpf_kfunc int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr_ker
>
> __bpf_kfunc_end_defs();
>
> -BTF_SET8_START(fsverity_set_ids)
> +BTF_KFUNCS_START(fsverity_set_ids)
> BTF_ID_FLAGS(func, bpf_get_fsverity_digest, KF_TRUSTED_ARGS)
> -BTF_SET8_END(fsverity_set_ids)
> +BTF_KFUNCS_END(fsverity_set_ids)
>
> static int bpf_get_fsverity_digest_filter(const struct bpf_prog *prog, u32 kfunc_id)
> {
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 51e8b4bee0c8..8cc718f37a9d 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -7802,6 +7802,10 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
> {
> enum btf_kfunc_hook hook;
>
> + /* All kfuncs need to be tagged as such in BTF */
> + if (WARN_ON(!(kset->set->flags & BTF_SET8_KFUNCS)))
> + return -EINVAL;
having the warning for module with wrong set8 flags seems wrong to me,
I think we should trigger the warn only for kernel calls.. by adding
kset->owner check in the condition above
jirka
> +
> hook = bpf_prog_type_to_kfunc_hook(prog_type);
> return __register_btf_kfunc_id_set(hook, kset);
> }
SNIP
^ permalink raw reply
* Re: [PATCH v5 4/5] Input: cs40l50 - Add support for the CS40L50 haptic driver
From: Charles Keepax @ 2024-01-05 15:01 UTC (permalink / raw)
To: James Ogletree
Cc: James Ogletree, Fred Treven, Ben Bright, Dmitry Torokhov,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Simon Trimmer,
Richard Fitzgerald, Lee Jones, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, James Schulman, David Rhodes,
Alexandre Belloni, Peng Fan, Jeff LaBundy, Sebastian Reichel,
Jacky Bai, Weidong Wang, Arnd Bergmann, Herve Codina, Shuming Fan,
Shenghao Ding, Ryan Lee, Linus Walleij,
open list:CIRRUS LOGIC HAPTIC DRIVERS,
open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS
In-Reply-To: <20240104223643.876292-5-jogletre@opensource.cirrus.com>
On Thu, Jan 04, 2024 at 10:36:37PM +0000, James Ogletree wrote:
> Introduce support for Cirrus Logic Device CS40L50: a
> haptic driver with waveform memory, integrated DSP,
> and closed-loop algorithms.
>
> The input driver provides the interface for control of
> haptic effects through the device.
>
> Signed-off-by: James Ogletree <jogletre@opensource.cirrus.com>
> ---
> +#include <linux/input.h>
> +#include <linux/mfd/cs40l50.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
Need bitfield.h
Thanks,
Charles
^ permalink raw reply
* Re: [PATCH v5 5/5] ASoC: cs40l50: Support I2S streaming to CS40L50
From: Charles Keepax @ 2024-01-05 14:24 UTC (permalink / raw)
To: James Ogletree
Cc: James Ogletree, Fred Treven, Ben Bright, Dmitry Torokhov,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Simon Trimmer,
Richard Fitzgerald, Lee Jones, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, James Schulman, David Rhodes,
Jacky Bai, Alexandre Belloni, Jeff LaBundy, Sebastian Reichel,
Peng Fan, Weidong Wang, Arnd Bergmann, Herve Codina, Shuming Fan,
Shenghao Ding, Ryan Lee, Linus Walleij, Maxim Kochetkov,
open list:CIRRUS LOGIC HAPTIC DRIVERS,
open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS
In-Reply-To: <20240104223643.876292-6-jogletre@opensource.cirrus.com>
On Thu, Jan 04, 2024 at 10:36:38PM +0000, James Ogletree wrote:
> Introduce support for Cirrus Logic Device CS40L50: a
> haptic driver with waveform memory, integrated DSP,
> and closed-loop algorithms.
>
> The ASoC driver enables I2S streaming to the device.
>
> Signed-off-by: James Ogletree <jogletre@opensource.cirrus.com>
> ---
> +#include <linux/mfd/cs40l50.h>
> +#include <linux/pm_runtime.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
Need to also include bitfield.h for FIELD_PREP etc.
> +static int cs40l50_clk_en(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol,
> + int event)
> +{
> + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
> + struct cs40l50_codec *codec = snd_soc_component_get_drvdata(comp);
> + int ret;
> +
> + switch (event) {
> + case SND_SOC_DAPM_POST_PMU:
> + ret = regmap_write(codec->regmap, CS40L50_DSP_QUEUE, CS40L50_STOP_PLAYBACK);
> + if (ret)
> + return ret;
> +
> + ret = regmap_write(codec->regmap, CS40L50_DSP_QUEUE, CS40L50_START_I2S);
> + if (ret)
> + return ret;
> +
Feels weird that we don't wait for these two commands to be
acknowledged by the DSP before doing the clock swap. Is that
intentional? Is the DSP just guaranteed to be so fast it doesn't
matter, in which case a comment would be nice.
> +static int cs40l50_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
> +{
> + struct cs40l50_codec *codec = snd_soc_component_get_drvdata(codec_dai->component);
> +
> + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)
> + return -EINVAL;
> +
> + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
> + case SND_SOC_DAIFMT_NB_NF:
> + codec->daifmt = 0;
> + break;
> + case SND_SOC_DAIFMT_NB_IF:
> + codec->daifmt = CS40L50_ASP_FSYNC_INV_MASK;
> + break;
> + case SND_SOC_DAIFMT_IB_NF:
> + codec->daifmt = CS40L50_ASP_BCLK_INV_MASK;
> + break;
> + case SND_SOC_DAIFMT_IB_IF:
> + codec->daifmt = CS40L50_ASP_FSYNC_INV_MASK | CS40L50_ASP_BCLK_INV_MASK;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S)
> + codec->daifmt |= FIELD_PREP(CS40L50_ASP_FMT_MASK, CS40L50_ASP_FMT_I2S);
It feels unlikely the chip supports all formats with no
additional settings? Probably should have a switch for the
supported formats and return an error.
> +static struct snd_soc_dai_driver cs40l50_dai[] = {
> + {
> + .name = "cs40l50-pcm",
> + .id = 0,
> + .playback = {
> + .stream_name = "ASP Playback",
> + .channels_min = 1,
> + .channels_max = 2,
> + .rates = SNDRV_PCM_RATE_48000,
> + .formats = CS40L50_FORMATS,
> + },
> + .ops = &cs40l50_dai_ops,
> + .symmetric_rate = 1,
The symmetric_rate feels a bit redundant since we only have
playback supported.
Thanks,
Charles
^ permalink raw reply
* Re: [PATCH v5 3/5] mfd: cs40l50: Add support for CS40L50 core driver
From: Charles Keepax @ 2024-01-05 14:04 UTC (permalink / raw)
To: James Ogletree
Cc: James Ogletree, Fred Treven, Ben Bright, Dmitry Torokhov,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Simon Trimmer,
Richard Fitzgerald, Lee Jones, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, James Schulman, David Rhodes,
Sebastian Reichel, Jacky Bai, Jeff LaBundy, Peng Fan,
Weidong Wang, Herve Codina, Arnd Bergmann, Shenghao Ding,
Ryan Lee, Linus Walleij, Maxim Kochetkov, Shuming Fan,
open list:CIRRUS LOGIC HAPTIC DRIVERS,
open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list,
open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS
In-Reply-To: <20240104223643.876292-4-jogletre@opensource.cirrus.com>
On Thu, Jan 04, 2024 at 10:36:36PM +0000, James Ogletree wrote:
> Introduce support for Cirrus Logic Device CS40L50: a
> haptic driver with waveform memory, integrated DSP,
> and closed-loop algorithms.
>
> The MFD component registers and initializes the device.
>
> Signed-off-by: James Ogletree <jogletre@opensource.cirrus.com>
> ---
> +config MFD_CS40L50_CORE
> + tristate
> + select MFD_CORE
> + select FW_CS_DSP
> + select REGMAP_IRQ
> +
> +config MFD_CS40L50_I2C
> + tristate "Cirrus Logic CS40L50 (I2C)"
> + select REGMAP_I2C
> + select MFD_CS40L50_CORE
> + depends on I2C
> + help
> + Select this to support the Cirrus Logic CS40L50 Haptic
> + Driver over I2C.
> +
> + This driver can be built as a module. If built as a module it will be
> + called "cs40l50-i2c".
> +
> +config MFD_CS40L50_SPI
> + tristate "Cirrus Logic CS40L50 (SPI)"
> + select REGMAP_SPI
> + select MFD_CS40L50_CORE
> + depends on SPI
> + help
> + Select this to support the Cirrus Logic CS40L50 Haptic
> + Driver over SPI.
> +
> + This driver can be built as a module. If built as a module it will be
> + called "cs40l50-spi".
> +
Generally the order in Kconfigs should be alphabetical, probably
up around Cirrus Madera stuff would make most sense.
> +static int cs40l50_dsp_init(struct cs40l50 *cs40l50)
> +{
> + int err;
> +
> + cs40l50->dsp.num = 1;
> + cs40l50->dsp.type = WMFW_HALO;
> + cs40l50->dsp.dev = cs40l50->dev;
> + cs40l50->dsp.regmap = cs40l50->regmap;
> + cs40l50->dsp.base = CS40L50_CORE_BASE;
> + cs40l50->dsp.base_sysinfo = CS40L50_SYS_INFO_ID;
> + cs40l50->dsp.mem = cs40l50_dsp_regions;
> + cs40l50->dsp.num_mems = ARRAY_SIZE(cs40l50_dsp_regions);
> + cs40l50->dsp.no_core_startstop = true;
> +
> + err = cs_dsp_halo_init(&cs40l50->dsp);
> + if (err)
> + return err;
> +
> + return devm_add_action_or_reset(cs40l50->dev, cs40l50_dsp_remove,
> + &cs40l50->dsp);
Hmm... I notice you use this for both dsp_remove and
dsp_power_down. Are you sure devm will guarantee those are called
in the right order? Its not immediately clear to me that would be
have to be the case.
> +static irqreturn_t cs40l50_irq_handler(int irq, void *data)
> +{
> + struct cs40l50 *cs40l50 = data;
> + int err;
> +
> + mutex_lock(&cs40l50->lock);
> +
> + if (irq == cs40l50_irqs[0].virq)
> + err = cs40l50_process_dsp_queue(cs40l50);
> + else
> + err = cs40l50_handle_hw_err(cs40l50, irq);
Feels kinda weird to assign the same handler to every IRQ and
then depending on which IRQ it was call a different function.
Would it not be simpler just to assign a different handler?
> +static int cs40l50_power_up_dsp(struct cs40l50 *cs40l50)
> +{
> + int err;
> +
> + mutex_lock(&cs40l50->lock);
> +
> + if (cs40l50->patch) {
> + /* Stop core if loading patch file */
> + err = regmap_multi_reg_write(cs40l50->regmap, cs40l50_stop_core,
> + ARRAY_SIZE(cs40l50_stop_core));
> + if (err)
> + goto err_mutex;
> + }
> +
> + err = cs_dsp_power_up(&cs40l50->dsp, cs40l50->patch, "cs40l50.wmfw",
> + cs40l50->bin, "cs40l50.bin", "cs40l50");
> + if (err)
> + goto err_mutex;
> +
> + err = devm_add_action_or_reset(cs40l50->dev, cs40l50_dsp_power_down,
> + &cs40l50->dsp);
> + if (err)
> + goto err_mutex;
> +
> + if (cs40l50->patch) {
> + /* Resume core after loading patch file */
> + err = regmap_write(cs40l50->regmap, CS40L50_CCM_CORE_CONTROL,
> + CS40L50_CLOCK_ENABLE);
This feels like this needs a comment, why are we skipping the
normal DSP init and doing it manually (this appears to be the
same writes start_core would have done)? I assume its something to
do with what you are really doing is you don't want lock_memory
to run?
> +static int cs40l50_configure_dsp(struct cs40l50 *cs40l50)
> +{
> + u32 nwaves;
> + int err;
> +
> + if (cs40l50->bin) {
> + /* Log number of effects if wavetable was loaded */
> + err = regmap_read(cs40l50->regmap, CS40L50_NUM_WAVES, &nwaves);
> + if (err)
> + return err;
> +
> + dev_info(cs40l50->dev, "Loaded with %u RAM waveforms\n", nwaves);
Kinda nervous about the fact we access all these DSP controls
directly through address, rather than using the DSP control
accessors, we have the accessors for a reason. They manage things
like access permissions etc. and historically, the firmware
guys have not been able to guarantee these remain in consistent
locations between firmware versions.
I guess this is so you can access them even in the case of the
ROM firmware, but you could have a meta-data only firmware file
that you load in that case to give you the controls. I don't
feel the need to NAK the driver based on this but please think
about this very carefully it's a strange way to use the DSP
controls, and feels likely to cause problems to me. It is also
quite hostile to fixing it in the future since as you are not
using the controls no one will be checking that things like the
access flags in the firmware are set correctly, which is annoying
if the decision has to be reversed later since there will likely
be a bunch of broken firmwares already in the field.
> +int cs40l50_probe(struct cs40l50 *cs40l50)
> +{
> + struct device *dev = cs40l50->dev;
> + int err;
> +
> + mutex_init(&cs40l50->lock);
> +
> + cs40l50->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(cs40l50->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(cs40l50->reset_gpio),
> + "Failed getting reset GPIO\n");
> +
> + err = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(cs40l50_supplies),
> + cs40l50_supplies);
> + if (err)
> + return dev_err_probe(dev, err, "Failed getting supplies\n");
> +
> + /* Ensure minimum reset pulse width */
> + usleep_range(CS40L50_RESET_PULSE_US, CS40L50_RESET_PULSE_US + 100);
> +
> + gpiod_set_value_cansleep(cs40l50->reset_gpio, 0);
> +
> + /* Wait for control port to be ready */
> + usleep_range(CS40L50_CP_READY_US, CS40L50_CP_READY_US + 100);
> +
> + err = cs40l50_dsp_init(cs40l50);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to initialize DSP\n");
> +
> + cs40l50_pm_runtime_setup(dev);
> +
> + err = cs40l50_get_model(cs40l50);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to get part number\n");
> +
> + err = cs40l50_irq_init(cs40l50);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to initialize IRQs\n");
> +
> + err = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT, CS40L50_FW,
> + dev, GFP_KERNEL, cs40l50, cs40l50_request_patch);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to request %s\n", CS40L50_FW);
> +
> + err = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, cs40l50_devs,
> + ARRAY_SIZE(cs40l50_devs), NULL, 0, NULL);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to add sub devices\n");
> +
Do you want to add the child devices here? Or after the firmware
init has been done? If you do it here then the child devices may
well probe and become available before all the setup you have in
the DSP loading stuff is done. What happens if one of those
drivers tries to do something before init is complete?
> +static int cs40l50_runtime_resume(struct device *dev)
> +{
> + struct cs40l50 *cs40l50 = dev_get_drvdata(dev);
> + int err, i;
> + u32 val;
> +
> + /* Device NAKs when exiting hibernation, so optionally retry here. */
> + for (i = 0; i < CS40L50_DSP_TIMEOUT_COUNT; i++) {
> + err = regmap_write(cs40l50->regmap, CS40L50_DSP_QUEUE,
> + CS40L50_PREVENT_HIBER);
> + if (!err)
> + break;
> +
> + usleep_range(CS40L50_DSP_POLL_US, CS40L50_DSP_POLL_US + 100);
> + }
Are you comfortable with the behaviour here? If the chip fails to
respond before the TIMEOUT, you will proceed on and do the read
loop. Since the read loop is just looking for a zero in the
queue, it looks like if for some reason the chip was too slow to
respond this function would succeed despite the chip never
receiving the PREVENT_HIBER. Would it not be safer to skip the
read loop if you fail to send the PREVENT_HIBER?
> +
> + for (i = 0; i < CS40L50_DSP_TIMEOUT_COUNT; i++) {
> + err = regmap_read(cs40l50->regmap, CS40L50_DSP_QUEUE, &val);
> + if (!err && val == 0)
> + return 0;
> +
> + usleep_range(CS40L50_DSP_POLL_US, CS40L50_DSP_POLL_US + 100);
> + }
I am not sure if the ignoring errors is important here (as it is
for the first loop), but if it is a comment should be added to
say why, and if it isn't, couldn't this be a
regmap_read_poll_timeout instead of a manual loop?
> +++ b/drivers/mfd/cs40l50-spi.c
> @@ -0,0 +1,69 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * CS40L50 Advanced Haptic Driver with waveform memory,
> + * integrated DSP, and closed-loop algorithms
> + *
> + * Copyright 2023 Cirrus Logic, Inc.
> + *
> + * Author: James Ogletree <james.ogletree@cirrus.com>
> + */
> +
> +#include <linux/mfd/cs40l50.h>
> +#include <linux/mfd/spi.h>
Should be linux/spi/spi.h, make sure your build testing the whole
patch.
> +#ifndef __CS40L50_H__
> +#define __CS40L50_H__
> +
> +#include <linux/firmware/cirrus/cs_dsp.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/pm.h>
> +#include <linux/regmap.h>
> +
> +/* Power Supply Configuration */
> +#define CS40L50_BLOCK_ENABLES2 0x201C
> +#define CS40L50_ERR_RLS 0x2034
> +#define CS40L50_PWRMGT_CTL 0x2900
> +#define CS40L50_BST_LPMODE_SEL 0x3810
> +#define CS40L50_DCM_LOW_POWER 0x1
> +#define CS40L50_OVERTEMP_WARN 0x4000010
> +
> +/* Interrupts */
> +#define CS40L50_IRQ1_INT_1 0xE010
> +#define CS40L50_IRQ1_MASK_1 0xE090
> +#define CS40L50_IRQ1_MASK_2 0xE094
> +#define CS40L50_IRQ1_MASK_20 0xE0DC
> +#define CS40L50_IRQ_MASK_2_OVERRIDE 0xFFDF7FFF
> +#define CS40L50_IRQ_MASK_20_OVERRIDE 0x15C01000
> +#define CS40L50_IRQ1_INT_1_OFFSET (4 * 0)
> +#define CS40L50_IRQ1_INT_2_OFFSET (4 * 1)
> +#define CS40L50_IRQ1_INT_8_OFFSET (4 * 7)
> +#define CS40L50_IRQ1_INT_9_OFFSET (4 * 8)
> +#define CS40L50_IRQ1_INT_10_OFFSET (4 * 9)
> +#define CS40L50_IRQ1_INT_18_OFFSET (4 * 17)
> +#define CS40L50_GLOBAL_ERR_RLS_SET BIT(11)
> +#define CS40L50_GLOBAL_ERR_RLS_CLEAR 0
> +#define CS40L50_AMP_SHORT_MASK BIT(31)
> +#define CS40L50_DSP_QUEUE_MASK BIT(21)
> +#define CS40L50_TEMP_ERR_MASK BIT(31)
> +#define CS40L50_BST_UVP_MASK BIT(6)
> +#define CS40L50_BST_SHORT_MASK BIT(7)
> +#define CS40L50_BST_ILIMIT_MASK BIT(18)
> +#define CS40L50_UVLO_VDDBATT_MASK BIT(16)
> +#define CS40L50_GLOBAL_ERROR_MASK BIT(15)
> +
> +enum cs40l50_irq_list {
> + CS40L50_DSP_QUEUE_IRQ,
> + CS40L50_GLOBAL_ERROR_IRQ,
> + CS40L50_UVLO_VDDBATT_IRQ,
> + CS40L50_BST_ILIMIT_IRQ,
> + CS40L50_BST_SHORT_IRQ,
> + CS40L50_BST_UVP_IRQ,
> + CS40L50_TEMP_ERR_IRQ,
> + CS40L50_AMP_SHORT_IRQ,
> +};
> +
> +/* DSP */
> +#define CS40L50_XMEM_PACKED_0 0x2000000
> +#define CS40L50_XMEM_UNPACKED24_0 0x2800000
> +#define CS40L50_SYS_INFO_ID 0x25E0000
> +#define CS40L50_RAM_INIT 0x28021DC
> +#define CS40L50_DSP_QUEUE_WT 0x28042C8
> +#define CS40L50_DSP_QUEUE_RD 0x28042CC
> +#define CS40L50_POWER_ON_WSEQ 0x2804320
> +#define CS40L50_NUM_WAVES 0x280CB4C
> +#define CS40L50_CORE_BASE 0x2B80000
> +#define CS40L50_CCM_CORE_CONTROL 0x2BC1000
> +#define CS40L50_YMEM_PACKED_0 0x2C00000
> +#define CS40L50_YMEM_UNPACKED24_0 0x3400000
> +#define CS40L50_PMEM_0 0x3800000
> +#define CS40L50_MEM_RDY_HW 0x2
> +#define CS40L50_RAM_INIT_FLAG 0x1
> +#define CS40L50_CLOCK_DISABLE 0x80
> +#define CS40L50_CLOCK_ENABLE 0x281
> +#define CS40L50_DSP_POLL_US 1000
> +#define CS40L50_DSP_TIMEOUT_COUNT 100
> +#define CS40L50_RESET_PULSE_US 2200
> +#define CS40L50_CP_READY_US 3100
> +#define CS40L50_AUTOSUSPEND_MS 2000
> +#define CS40L50_PSEQ_SIZE 200
> +
> +/* DSP Commands */
> +#define CS40L50_DSP_QUEUE_BASE 0x11004
> +#define CS40L50_DSP_QUEUE_END 0x1101C
> +#define CS40L50_DSP_QUEUE 0x11020
> +#define CS40L50_PREVENT_HIBER 0x2000003
> +#define CS40L50_ALLOW_HIBER 0x2000004
> +#define CS40L50_START_I2S 0x3000002
> +#define CS40L50_OWT_PUSH 0x3000008
> +#define CS40L50_STOP_PLAYBACK 0x5000000
> +#define CS40L50_OWT_DELETE 0xD000000
> +
> +/* Firmware files */
> +#define CS40L50_FW "cs40l50.wmfw"
> +#define CS40L50_WT "cs40l50.bin"
> +
> +/* Device */
> +#define CS40L50_DEVID 0x0
> +#define CS40L50_REVID 0x4
> +#define CS40L50_DEVID_A 0x40A50
> +#define CS40L50_REVID_B0 0xB0
Admittedly a bit nitpicky but the tabbing here is all over the
place, would be nicer to line up the values on these defines.
Thanks,
Charles
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox