mbox series

[v5,0/2] Apple Magic Keyboard Backlight

Message ID 20230220115203.76154-1-orlandoch.dev@gmail.com
Headers show
Series Apple Magic Keyboard Backlight | expand

Message

Orlando Chamberlain Feb. 20, 2023, 11:52 a.m. UTC
This patchseries adds support for the internal keyboard backlight of
Macs with Apple's "Magic" keyboard (MacBookPro16,* and MacBookAir9,1),
and also documents what names should be used for keyboard backlight
leds in Documentation/leds/well-known-leds.txt.

v4->v5:
- use <tab><space><space> for help in Kconfig
- prepend "hid-" to filename in MAINTAINERS

v3->v4:
- collect reviews from Andy and Thomas
- remove now unused hdev member of apple_magic_backlight

v2->v3:
- remove unneeded header inclusion
- use s32 for report value type
- remove unneeded null check
- don't set drvdata as its never used
- prepend "hid-" to module name

v1->v2:
- drop unneeded remove function
- combine set functions
- add missing header inclusions
- avoid char as argument in favour of u8
- handful of style/formatting fixes
- use standard led name ":white:kbd_backlight"
- rename USAGE_MAGIC_BL to HID_USAGE_MAGIC_BL
- New patch documenting preferred keyboard backlight names

v1: https://lore.kernel.org/linux-input/7D70F1FE-7F54-4D0A-8922-5466AA2AD364@live.com/
v2: https://lore.kernel.org/linux-input/20230216041224.4731-1-orlandoch.dev@gmail.com/
v3: https://lore.kernel.org/linux-input/20230217102319.3419-1-orlandoch.dev@gmail.com/
v4: https://lore.kernel.org/linux-input/20230218090709.7467-1-orlandoch.dev@gmail.com/

Orlando Chamberlain (2):
  Documentation: leds: standardise keyboard backlight led names
  HID: hid-apple-magic-backlight: Add driver for keyboard backlight on
    internal Magic Keyboards

 Documentation/leds/well-known-leds.txt  |   8 ++
 MAINTAINERS                             |   6 ++
 drivers/hid/Kconfig                     |  13 +++
 drivers/hid/Makefile                    |   1 +
 drivers/hid/hid-apple-magic-backlight.c | 120 ++++++++++++++++++++++++
 5 files changed, 148 insertions(+)
 create mode 100644 drivers/hid/hid-apple-magic-backlight.c

Comments

Jiri Kosina March 10, 2023, 2:36 p.m. UTC | #1
On Mon, 20 Feb 2023, Orlando Chamberlain wrote:

> This patchseries adds support for the internal keyboard backlight of
> Macs with Apple's "Magic" keyboard (MacBookPro16,* and MacBookAir9,1),
> and also documents what names should be used for keyboard backlight
> leds in Documentation/leds/well-known-leds.txt.
> 
> v4->v5:
> - use <tab><space><space> for help in Kconfig
> - prepend "hid-" to filename in MAINTAINERS
> 
> v3->v4:
> - collect reviews from Andy and Thomas
> - remove now unused hdev member of apple_magic_backlight
> 
> v2->v3:
> - remove unneeded header inclusion
> - use s32 for report value type
> - remove unneeded null check
> - don't set drvdata as its never used
> - prepend "hid-" to module name
> 
> v1->v2:
> - drop unneeded remove function
> - combine set functions
> - add missing header inclusions
> - avoid char as argument in favour of u8
> - handful of style/formatting fixes
> - use standard led name ":white:kbd_backlight"
> - rename USAGE_MAGIC_BL to HID_USAGE_MAGIC_BL
> - New patch documenting preferred keyboard backlight names
> 
> v1: https://lore.kernel.org/linux-input/7D70F1FE-7F54-4D0A-8922-5466AA2AD364@live.com/
> v2: https://lore.kernel.org/linux-input/20230216041224.4731-1-orlandoch.dev@gmail.com/
> v3: https://lore.kernel.org/linux-input/20230217102319.3419-1-orlandoch.dev@gmail.com/
> v4: https://lore.kernel.org/linux-input/20230218090709.7467-1-orlandoch.dev@gmail.com/
> 
> Orlando Chamberlain (2):
>   Documentation: leds: standardise keyboard backlight led names
>   HID: hid-apple-magic-backlight: Add driver for keyboard backlight on
>     internal Magic Keyboards
> 
>  Documentation/leds/well-known-leds.txt  |   8 ++
>  MAINTAINERS                             |   6 ++
>  drivers/hid/Kconfig                     |  13 +++
>  drivers/hid/Makefile                    |   1 +
>  drivers/hid/hid-apple-magic-backlight.c | 120 ++++++++++++++++++++++++
>  5 files changed, 148 insertions(+)
>  create mode 100644 drivers/hid/hid-apple-magic-backlight.c

Hi,

thanks for creating the support for backlight.

Is there any reason why not to fold all this into existing hid-apple? I 
don't think we need separate driver for the backlist, separated from the 
rest of hid-apple support.

Thanks,
Aditya Garg March 10, 2023, 4:16 p.m. UTC | #2
> Hi,
> 
> thanks for creating the support for backlight.
> 
> Is there any reason why not to fold all this into existing hid-apple? I 
> don't think we need separate driver for the backlist, separated from the 
> rest of hid-apple support.
> 
> Thanks,
> 
> -- 
> Jiri Kosina
> SUSE Labs
> 

As far as I know, hid-apple manages the keyboards and trackpads on Macs.

The magic backlight is managed by the touchbar on T2 Macs, so if you wanna integrate the driver in some other one, then it should be the to-be-upstreamed touchbar driver.

But when we did that, the MacBook Air 2020, the model which has magic backlight, but no touchbar faced issues. lsusb interestingly shows presence of touch bar backlight even on this model, but backlight is registered at the 0th interface on Air, and 1st interface on the Pros. So, the co-author, Kerem Karabay suggested using a separate driver.

Although, the authors may give more detailed reason for the same.
Orlando Chamberlain March 11, 2023, 6:33 a.m. UTC | #3
On Fri, 10 Mar 2023 15:36:34 +0100 (CET)
Jiri Kosina <jikos@kernel.org> wrote:

> On Mon, 20 Feb 2023, Orlando Chamberlain wrote:
> 
> > This patchseries adds support for the internal keyboard backlight of
> > Macs with Apple's "Magic" keyboard (MacBookPro16,* and
> > MacBookAir9,1), and also documents what names should be used for
> > keyboard backlight leds in Documentation/leds/well-known-leds.txt.
> > 
> > v4->v5:
> > - use <tab><space><space> for help in Kconfig
> > - prepend "hid-" to filename in MAINTAINERS
> > 
> > v3->v4:
> > - collect reviews from Andy and Thomas
> > - remove now unused hdev member of apple_magic_backlight
> > 
> > v2->v3:
> > - remove unneeded header inclusion
> > - use s32 for report value type
> > - remove unneeded null check
> > - don't set drvdata as its never used
> > - prepend "hid-" to module name
> > 
> > v1->v2:
> > - drop unneeded remove function
> > - combine set functions
> > - add missing header inclusions
> > - avoid char as argument in favour of u8
> > - handful of style/formatting fixes
> > - use standard led name ":white:kbd_backlight"
> > - rename USAGE_MAGIC_BL to HID_USAGE_MAGIC_BL
> > - New patch documenting preferred keyboard backlight names
> > 
> > v1:
> > https://lore.kernel.org/linux-input/7D70F1FE-7F54-4D0A-8922-5466AA2AD364@live.com/
> > v2:
> > https://lore.kernel.org/linux-input/20230216041224.4731-1-orlandoch.dev@gmail.com/
> > v3:
> > https://lore.kernel.org/linux-input/20230217102319.3419-1-orlandoch.dev@gmail.com/
> > v4:
> > https://lore.kernel.org/linux-input/20230218090709.7467-1-orlandoch.dev@gmail.com/
> > 
> > Orlando Chamberlain (2):
> >   Documentation: leds: standardise keyboard backlight led names
> >   HID: hid-apple-magic-backlight: Add driver for keyboard backlight
> > on internal Magic Keyboards
> > 
> >  Documentation/leds/well-known-leds.txt  |   8 ++
> >  MAINTAINERS                             |   6 ++
> >  drivers/hid/Kconfig                     |  13 +++
> >  drivers/hid/Makefile                    |   1 +
> >  drivers/hid/hid-apple-magic-backlight.c | 120
> > ++++++++++++++++++++++++ 5 files changed, 148 insertions(+)
> >  create mode 100644 drivers/hid/hid-apple-magic-backlight.c  
> 
> Hi,
> 
> thanks for creating the support for backlight.
> 
> Is there any reason why not to fold all this into existing hid-apple?
> I don't think we need separate driver for the backlist, separated
> from the rest of hid-apple support.

Hi Jiri,

I think we can do that if we modify hid-apple to support usb endpoints
with only the keyboard backlight and no keyboard, assuming it doesn't
prevent the (not upstream) touchbar driver from using the touchbar
backlight interface (and I don't think it will, given hid-apple lets a
different driver bind to the trackpad interface of the
keyboard/trackpad usb device).

> 
> Thanks,
>