From: Aditya Garg <gargaditya08@live.com>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: "Thomas Weißschuh" <thomas@t-8ch.de>,
"Jiri Kosina" <jikos@kernel.org>,
"jkosina@suse.cz" <jkosina@suse.cz>,
"Andy Shevchenko" <andy@infradead.org>,
"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"ronald@innovation.ch" <ronald@innovation.ch>,
"kekrby@gmail.com" <kekrby@gmail.com>,
"Orlando Chamberlain" <orlandoch.dev@gmail.com>
Subject: Re: [PATCH 1/3] HID: apple-ibridge: Add Apple iBridge HID driver for T1 chip.
Date: Fri, 10 Feb 2023 08:54:35 +0000 [thread overview]
Message-ID: <B472CABB-5D94-4E15-AE6D-EF8B8BF4CBF3@live.com> (raw)
In-Reply-To: <CAO-hwJK=-9n885crMM8sHFGdNCZfjhqwuQXb2OtgMQiqaoZ66g@mail.gmail.com>
> On 10-Feb-2023, at 2:09 PM, Benjamin Tissoires <benjamin.tissoires@redhat.com> wrote:
>
> On Fri, Feb 10, 2023 at 9:30 AM Aditya Garg <gargaditya08@live.com> wrote:
>>
>>
>>
>>> On 10-Feb-2023, at 10:26 AM, Thomas Weißschuh <thomas@t-8ch.de> wrote:
>>>
>>> Hi,
>>>
>>> some comments inline.
>>>
>>> On Fri, Feb 10, 2023 at 03:43:24AM +0000, Aditya Garg wrote:
>>>> From: Ronald Tschalär <ronald@innovation.ch>
>>>>
>>>> The iBridge device provides access to several devices, including:
>>>> - the Touch Bar
>>>> - the iSight webcam
>>>> - the light sensor
>>>> - the fingerprint sensor
>>>>
>>>> This driver provides the core support for managing the iBridge device
>>>> and the access to the underlying devices. In particular, the
>>>> functionality for the touch bar and light sensor is exposed via USB HID
>>>> interfaces, and on devices with the T1 chip one of the HID devices is
>>>> used for both functions. So this driver creates virtual HID devices, one
>>>> per top-level report collection on each HID device (for a total of 3
>>>> virtual HID devices). The sub-drivers then bind to these virtual HID
>>>> devices.
>>>>
>>>> This way the Touch Bar and ALS drivers can be kept in their own modules,
>>>> while at the same time making them look very much like as if they were
>>>> connected to the real HID devices. And those drivers then work (mostly)
>>>> without further changes on MacBooks with the T2 chip that don't need
>>>> this driver.
>>>>
>>>> Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
>>>> [Kerem Karabay: convert to a platform driver]
>>>> [Kerem Karabay: fix appleib_forward_int_op]
>>>> [Kerem Karabay: rely on HID core's parsing in appleib_add_device]
>>>> Signed-off-by: Kerem Karabay <kekrby@gmail.com>
>>>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>>>> ---
>>>> drivers/hid/Kconfig | 15 +
>>>> drivers/hid/Makefile | 1 +
>>>> drivers/hid/apple-ibridge.c | 610 ++++++++++++++++++++++++++++++++++++
>>>> drivers/hid/apple-ibridge.h | 15 +
>>>> drivers/hid/hid-ids.h | 1 +
>>>> drivers/hid/hid-quirks.c | 3 +
>>>> 6 files changed, 645 insertions(+)
>>>> create mode 100644 drivers/hid/apple-ibridge.c
>>>> create mode 100644 drivers/hid/apple-ibridge.h
>>>>
>>>
>>>>
>>>> +}
>>>> +
>>>> +static int appleib_ll_raw_request(struct hid_device *hdev,
>>>> + unsigned char reportnum, __u8 *buf,
>>>> + size_t len, unsigned char rtype, int reqtype)
>>>> +{
>>>> + struct appleib_hid_dev_info *hdev_info = hdev->driver_data;
>>>> +
>>>> + return hid_hw_raw_request(hdev_info->hdev, reportnum, buf, len, rtype,
>>>> + reqtype);
>>>> +}
>>>> +
>>>> +static int appleib_ll_output_report(struct hid_device *hdev, __u8 *buf,
>>>> + size_t len)
>>>> +{
>>>> + struct appleib_hid_dev_info *hdev_info = hdev->driver_data;
>>>> +
>>>> + return hid_hw_output_report(hdev_info->hdev, buf, len);
>>>> +}
>>>> +
>>>> +static struct hid_ll_driver appleib_ll_driver = {
>>>> + .start = appleib_ll_start,
>>>> + .stop = appleib_ll_stop,
>>>> + .open = appleib_ll_open,
>>>> + .close = appleib_ll_close,
>>>> + .power = appleib_ll_power,
>>>> + .parse = appleib_ll_parse,
>>>> + .request = appleib_ll_request,
>>>> + .wait = appleib_ll_wait,
>>>> + .raw_request = appleib_ll_raw_request,
>>>> + .output_report = appleib_ll_output_report,
>>>> +};
>>>
>>> const
>>
>> Are you sure about const here?
>>
>>>
>>>> +
>>>> + if (udev->actconfig->desc.bConfigurationValue != APPLEIB_BASIC_CONFIG) {
>>>> + rc = usb_driver_set_configuration(udev, APPLEIB_BASIC_CONFIG);
>>>> + return rc ? rc : -ENODEV;
>>>> + }
>>>> +
>>>> + rc = hid_parse(hdev);
>>>> + if (rc) {
>>>> + hid_err(hdev, "ib: hid parse failed (%d)\n", rc);
>>>> + goto error;
>>>> + }
>>>> +
>>>> + rc = hid_hw_start(hdev, HID_CONNECT_DRIVER);
>>>> + if (rc) {
>>>> + hid_err(hdev, "ib: hw start failed (%d)\n", rc);
>>>> + goto error;
>>>> + }
>>>> +
>>>> + hdev_info = appleib_add_device(hdev);
>>>> + if (IS_ERR(hdev_info)) {
>>>> + rc = PTR_ERR(hdev_info);
>>>> + goto stop_hw;
>>>> + }
>>>> +
>>>> + hid_set_drvdata(hdev, hdev_info);
>>>> +
>>>> + rc = hid_hw_open(hdev);
>>>> + if (rc) {
>>>> + hid_err(hdev, "ib: failed to open hid: %d\n", rc);
>>>> + goto remove_dev;
>>>> + }
>>>> +
>>>> + return 0;
>>>> +
>>>> +remove_dev:
>>>> + appleib_remove_device(hdev);
>>>> +stop_hw:
>>>> + hid_hw_stop(hdev);
>>>> +error:
>>>> + return rc;
>>>> +}
>>>> +
>>>> +static void appleib_hid_remove(struct hid_device *hdev)
>>>> +{
>>>> + hid_hw_close(hdev);
>>>> + appleib_remove_device(hdev);
>>>> + hid_hw_stop(hdev);
>>>> +}
>>>> +
>>>> +static const struct hid_device_id appleib_hid_ids[] = {
>>>> + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IBRIDGE) },
>>>> + { },
>>>> +};
>>>> +
>>>> +static struct hid_driver appleib_hid_driver = {
>>>> + .name = "apple-ibridge-hid",
>>>> + .id_table = appleib_hid_ids,
>>>> + .probe = appleib_hid_probe,
>>>> + .remove = appleib_hid_remove,
>>>> + .raw_event = appleib_hid_raw_event,
>>>> + .report_fixup = appleib_report_fixup,
>>>> +#ifdef CONFIG_PM
>>>> + .suspend = appleib_hid_suspend,
>>>> + .resume = appleib_hid_resume,
>>>> + .reset_resume = appleib_hid_reset_resume,
>>>> +#endif
>>>> +};
>>>
>>> const
>>
>> Are you sure you want to do const here, cause other hid-drivers are NOT using const.
>
> It is scheduled for 6.3:
> https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/log/?h=for-6.3/hid-core
>
> So yes, please make them const.
Makes sense for `hid_ll_driver` as per the tree you send me, but I don’t see such a thing for
`static struct hid_driver`. Is that scheduled as well?
>
> Cheers,
> Benjamin
>
>>
>>>> +
>>>> +static struct appleib_device *appleib_alloc_device(struct platform_device *pdev)
>>>> +{
>>>> + struct appleib_device *ib_dev;
>>>> + acpi_status sts;
next prev parent reply other threads:[~2023-02-10 8:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 3:41 [PATCH 0/3] Touch Bar and Keyboard backlight driver for Intel Macs Aditya Garg
2023-02-10 3:43 ` [PATCH 1/3] HID: apple-ibridge: Add Apple iBridge HID driver for T1 chip Aditya Garg
2023-02-10 3:44 ` [PATCH 2/3] HID: apple-touchbar: Add driver for the Touch Bar on MacBook Pros Aditya Garg
2023-02-10 3:45 ` [PATCH 3/3] HID: apple-magic-backlight: Add driver for keyboard backlight on internal Magic Keyboards Aditya Garg
2023-02-10 16:25 ` Thomas Weißschuh
2023-02-10 23:24 ` Orlando Chamberlain
2023-02-11 2:23 ` Thomas Weißschuh
2023-02-11 2:42 ` Thomas Weißschuh
2023-02-11 16:56 ` Pavel Machek
2023-02-12 2:28 ` Orlando Chamberlain
2023-02-12 5:16 ` Aditya Garg
2023-02-12 11:18 ` Andy Shevchenko
2023-02-16 1:17 ` Orlando Chamberlain
2023-02-10 16:13 ` [PATCH 2/3] HID: apple-touchbar: Add driver for the Touch Bar on MacBook Pros Thomas Weißschuh
2023-02-12 11:56 ` Andy Shevchenko
2023-02-10 4:56 ` [PATCH 1/3] HID: apple-ibridge: Add Apple iBridge HID driver for T1 chip Thomas Weißschuh
2023-02-10 8:30 ` Aditya Garg
2023-02-10 8:39 ` Benjamin Tissoires
2023-02-10 8:54 ` Aditya Garg [this message]
2023-02-10 9:21 ` Benjamin Tissoires
2023-02-10 12:05 ` Aditya Garg
2023-02-10 12:20 ` Orlando Chamberlain
2023-02-10 13:07 ` Aditya Garg
2023-02-10 14:01 ` Benjamin Tissoires
2023-02-10 15:33 ` Thomas Weißschuh
2023-02-10 15:49 ` Aditya Garg
2023-02-10 18:36 ` Thomas Weißschuh
2023-02-12 11:35 ` Andy Shevchenko
2023-02-10 10:18 ` [PATCH 0/3] Touch Bar and Keyboard backlight driver for Intel Macs Andy Shevchenko
2023-02-10 10:41 ` Aditya Garg
2023-02-10 10:47 ` Orlando Chamberlain
2023-02-10 11:12 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B472CABB-5D94-4E15-AE6D-EF8B8BF4CBF3@live.com \
--to=gargaditya08@live.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@infradead.org \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=jkosina@suse.cz \
--cc=kekrby@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orlandoch.dev@gmail.com \
--cc=ronald@innovation.ch \
--cc=thomas@t-8ch.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®