All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>, Pavel Machek <pavel@ucw.cz>,
	Werner Sembach <wse@tuxedocomputers.com>
Cc: jikos@kernel.org, Jelle van der Waa <jelle@vdwaa.nl>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Lee Jones <lee@kernel.org>,
	linux-kernel@vger.kernel.org,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	linux-input@vger.kernel.org, ojeda@kernel.org,
	linux-leds@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: Re: Implement per-key keyboard backlight as auxdisplay?
Date: Fri, 19 Jan 2024 12:51:21 +0200	[thread overview]
Message-ID: <87bk9hppee.fsf@intel.com> (raw)
In-Reply-To: <6bbfdd62-e663-4a45-82f4-445069a8d690@redhat.com>

On Fri, 19 Jan 2024, Hans de Goede <hdegoede@redhat.com> wrote:
> For per key controllable rgb LEDs we need to discuss a coordinate
> system. I propose using a fixed size of 16 rows of 64 keys,
> so 64x16 in standard WxH notation.
>
> And then storing RGB in separate bytes, so userspace will then
> always send a buffer of 192 bytes per line (64x3) x 14 rows
> = 3072 bytes. With the kernel driver ignoring parts of
> the buffer where there are no actual keys.
>
> I would then like the map the standard 105 key layout onto this,
> starting at x.y (column.row) coordinates of 16.6 (with 0.0 being
> the top left). Leaving plenty of space on the left top and right
> (and some on the bottom) for extra media key rows, macro keys, etc.
>
> The idea to have the standard layout at a fixed place is to allow
> userspace to have a database of preset patterns which will work
> everywhere.
>
> Note I say standard 105 key layout, but in reality for
> defining the standardized part of the buffer we should
> use the maximum amount of keys per row of all the standard layouts,
> so for row 6 (the ESC row) and for extra keys on the right outside
> the main block we use the standard layout as shown here:

Doesn't the input stack already have to have pretty much all of this
already covered? I can view the keyboard layout in my desktop
environment, and it's a reasonably accurate match, even if unlikely to
be pixel perfect. But crucially, it has to have all the possible layouts
covered already.

And while I would personally hate it, you can imagine a use case where
you'd like a keypress to have a visual effect around the key you
pressed. A kind of force feedback, if you will. I don't actually know,
and correct me if I'm wrong, but feels like implementing that outside of
the input subsystem would be non-trivial.

Cc: Dmitry, could we at least have some input from the input subsystem
POV on this? AFAICT we have received none.


BR,
Jani.


>
> http://www.maxkeyboard.com/images/105_ISO_6_25_Key_Layout.jpg
>
> For the main area of the keyboard looking at:
>
> http://bopqehorizon.weebly.com/uploads/1/3/4/3/134337299/913246919_orig.png
>
> We want to max rows per key, so this means that per row we use
> (from the above image) :
>
> row  7: 106/109 - JIS 
> row  8: 101/104 - ANSI
> row  9: 102/105 - ISO
> row 10: 104/107 - ABNT
> row 11: 106/109 - JIS
>
> (with row 7 being the main area top row)
>
> This way we can address all the possible keys in the various
> standard layouts in one standard wat and then the drivers can
> just skip keys which are not there when preparing the buffer
> to send to the hw / fw.
>
> One open question is if we should add padding after the main
> area so that the printscreen / ins / del / leftarrow of the
> "middle" block of 
>
> http://www.maxkeyboard.com/images/105_ISO_6_25_Key_Layout.jpg
>
> all start at the same x (say 32) or we just pack these directly
> after the main area.
>
> And the same question for the numlock block, do we align
> this to an x of say 36, or pack it ?
>
>
> As for the actual IOCTL API I think there should be
> the following ioctls:
>
> 1. A get-info ioctl returning a struct with the following members:
>
> {
> char name[64]      /* Keyboard model name / identifier */
> int row_begin[16]; /* The x address of the first available key per row. On a std 105key kbd this will be 16 for rows 6-11, 0 for other rows */
> int row_end[16];   /* x+1 for the address of the last available key per row, end - begin gives number of keys in a row */
> int rgb_zones;     /* number of rgb zones for zoned keyboards. Note both
>                       zones and per key addressing may be available if
>                       effects are applied per zone. */
> ?
> }
>
> 2. A set-leds ioctl which takes the earlier discussed 3092 bytes buffer
> to set all the LEDs at once, only valid if at least one row has a non 0 lenght.
>
> 3. A set-zones ioctl which takes an array of bytes sized 3 * number-of-zones
> containing RGB values for each zone
>
> 4. A enum_effects ioctl which takes a struct with the following members:
>
> {
> long size; /* Size of passed in struct including the size member itself */
> long effects_mask[]
> }
>
> the idea being that there is an enum with effects, which gets extended
> as we encounter more effects and the bitmask in effects_mask has a bit set
> for each effects enum value which is supported. effects_mask is an array
> so that we don't run out of bits. If older userspace only passes 1 long
> (size == (2*sizeof(long)) when 2 are needed at some point in the future 
> then the kernel will simply only fill the first long.
>
> 5. A set_effect ioctl which takes a struct with the following members:
>
> {
> long size; /* Size of passed in struct including the size member itself */
> int effect_nr; /* enum value of the effect to enable, 0 for disable effect */
> int zone;  /* zone to apply the effect to */
> int speed; /* cycle speed of the effect in milli-hz */
> char color1[3]; /* effect dependend may be unused. */
> char color2[3]; /* effect dependend may be unused. */
> }
>
> Again the idea with the size member is that the struct can be extended with
> new members if necessary and the kernel will supply a default value for
> older userspaces which provide a smaller struct (note size being smaller
> then sizeof(struct-v1) will invalid).
>
>
> Note this is all just a rough sketch suggestions welcome!
>
> Regards,
>
> Hans
>
>
>

-- 
Jani Nikula, Intel

WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>, Pavel Machek <pavel@ucw.cz>,
	Werner Sembach <wse@tuxedocomputers.com>
Cc: Lee Jones <lee@kernel.org>, Jiri Kosina <jikos@kernel.org>,
	linux-kernel@vger.kernel.org,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Jelle van der Waa <jelle@vdwaa.nl>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, ojeda@kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-leds@vger.kernel.org
Subject: Re: Implement per-key keyboard backlight as auxdisplay?
Date: Fri, 19 Jan 2024 12:51:21 +0200	[thread overview]
Message-ID: <87bk9hppee.fsf@intel.com> (raw)
In-Reply-To: <6bbfdd62-e663-4a45-82f4-445069a8d690@redhat.com>

On Fri, 19 Jan 2024, Hans de Goede <hdegoede@redhat.com> wrote:
> For per key controllable rgb LEDs we need to discuss a coordinate
> system. I propose using a fixed size of 16 rows of 64 keys,
> so 64x16 in standard WxH notation.
>
> And then storing RGB in separate bytes, so userspace will then
> always send a buffer of 192 bytes per line (64x3) x 14 rows
> = 3072 bytes. With the kernel driver ignoring parts of
> the buffer where there are no actual keys.
>
> I would then like the map the standard 105 key layout onto this,
> starting at x.y (column.row) coordinates of 16.6 (with 0.0 being
> the top left). Leaving plenty of space on the left top and right
> (and some on the bottom) for extra media key rows, macro keys, etc.
>
> The idea to have the standard layout at a fixed place is to allow
> userspace to have a database of preset patterns which will work
> everywhere.
>
> Note I say standard 105 key layout, but in reality for
> defining the standardized part of the buffer we should
> use the maximum amount of keys per row of all the standard layouts,
> so for row 6 (the ESC row) and for extra keys on the right outside
> the main block we use the standard layout as shown here:

Doesn't the input stack already have to have pretty much all of this
already covered? I can view the keyboard layout in my desktop
environment, and it's a reasonably accurate match, even if unlikely to
be pixel perfect. But crucially, it has to have all the possible layouts
covered already.

And while I would personally hate it, you can imagine a use case where
you'd like a keypress to have a visual effect around the key you
pressed. A kind of force feedback, if you will. I don't actually know,
and correct me if I'm wrong, but feels like implementing that outside of
the input subsystem would be non-trivial.

Cc: Dmitry, could we at least have some input from the input subsystem
POV on this? AFAICT we have received none.


BR,
Jani.


>
> http://www.maxkeyboard.com/images/105_ISO_6_25_Key_Layout.jpg
>
> For the main area of the keyboard looking at:
>
> http://bopqehorizon.weebly.com/uploads/1/3/4/3/134337299/913246919_orig.png
>
> We want to max rows per key, so this means that per row we use
> (from the above image) :
>
> row  7: 106/109 - JIS 
> row  8: 101/104 - ANSI
> row  9: 102/105 - ISO
> row 10: 104/107 - ABNT
> row 11: 106/109 - JIS
>
> (with row 7 being the main area top row)
>
> This way we can address all the possible keys in the various
> standard layouts in one standard wat and then the drivers can
> just skip keys which are not there when preparing the buffer
> to send to the hw / fw.
>
> One open question is if we should add padding after the main
> area so that the printscreen / ins / del / leftarrow of the
> "middle" block of 
>
> http://www.maxkeyboard.com/images/105_ISO_6_25_Key_Layout.jpg
>
> all start at the same x (say 32) or we just pack these directly
> after the main area.
>
> And the same question for the numlock block, do we align
> this to an x of say 36, or pack it ?
>
>
> As for the actual IOCTL API I think there should be
> the following ioctls:
>
> 1. A get-info ioctl returning a struct with the following members:
>
> {
> char name[64]      /* Keyboard model name / identifier */
> int row_begin[16]; /* The x address of the first available key per row. On a std 105key kbd this will be 16 for rows 6-11, 0 for other rows */
> int row_end[16];   /* x+1 for the address of the last available key per row, end - begin gives number of keys in a row */
> int rgb_zones;     /* number of rgb zones for zoned keyboards. Note both
>                       zones and per key addressing may be available if
>                       effects are applied per zone. */
> ?
> }
>
> 2. A set-leds ioctl which takes the earlier discussed 3092 bytes buffer
> to set all the LEDs at once, only valid if at least one row has a non 0 lenght.
>
> 3. A set-zones ioctl which takes an array of bytes sized 3 * number-of-zones
> containing RGB values for each zone
>
> 4. A enum_effects ioctl which takes a struct with the following members:
>
> {
> long size; /* Size of passed in struct including the size member itself */
> long effects_mask[]
> }
>
> the idea being that there is an enum with effects, which gets extended
> as we encounter more effects and the bitmask in effects_mask has a bit set
> for each effects enum value which is supported. effects_mask is an array
> so that we don't run out of bits. If older userspace only passes 1 long
> (size == (2*sizeof(long)) when 2 are needed at some point in the future 
> then the kernel will simply only fill the first long.
>
> 5. A set_effect ioctl which takes a struct with the following members:
>
> {
> long size; /* Size of passed in struct including the size member itself */
> int effect_nr; /* enum value of the effect to enable, 0 for disable effect */
> int zone;  /* zone to apply the effect to */
> int speed; /* cycle speed of the effect in milli-hz */
> char color1[3]; /* effect dependend may be unused. */
> char color2[3]; /* effect dependend may be unused. */
> }
>
> Again the idea with the size member is that the struct can be extended with
> new members if necessary and the kernel will supply a default value for
> older userspaces which provide a smaller struct (note size being smaller
> then sizeof(struct-v1) will invalid).
>
>
> Note this is all just a rough sketch suggestions welcome!
>
> Regards,
>
> Hans
>
>
>

-- 
Jani Nikula, Intel

  reply	other threads:[~2024-01-19 10:51 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 19:00 [PATCH] leds: rgb: Implement per-key keyboard backlight for several TUXEDO devices Werner Sembach
2023-10-11 19:21 ` Werner Sembach
2023-10-12  8:58 ` Pavel Machek
2023-10-12 10:02   ` Werner Sembach
2023-10-12 14:05     ` Pavel Machek
2023-10-12 16:35       ` Werner Sembach
2023-10-13 12:19         ` Pavel Machek
2023-10-13 14:38           ` Werner Sembach
2023-10-13 14:54           ` Implement per-key keyboard backlight as auxdisplay? Werner Sembach
2023-10-13 14:54             ` Werner Sembach
2023-10-13 19:56             ` Pavel Machek
2023-10-13 19:56               ` Pavel Machek
2023-10-13 20:03               ` Pavel Machek
2023-10-13 20:03                 ` Pavel Machek
2023-10-16 10:57               ` Miguel Ojeda
2023-10-16 10:57                 ` Miguel Ojeda
2023-10-23 11:40                 ` Jani Nikula
2023-10-23 11:40                   ` Jani Nikula
2023-10-23 11:44                   ` Miguel Ojeda
2023-10-23 11:44                     ` Miguel Ojeda
2023-11-20 20:53                     ` Pavel Machek
2023-11-20 20:53                       ` Pavel Machek
2023-11-20 20:52                   ` Pavel Machek
2023-11-20 20:52                     ` Pavel Machek
2023-11-21 11:33                     ` Werner Sembach
2023-11-21 11:33                       ` Werner Sembach
2023-11-21 12:20                       ` Hans de Goede
2023-11-21 12:20                         ` Hans de Goede
2023-11-21 13:29                         ` Werner Sembach
2023-11-21 13:29                           ` Werner Sembach
2023-11-22 18:34                           ` Hans de Goede
2023-11-22 18:34                             ` Hans de Goede
2023-11-27 10:59                             ` Werner Sembach
2023-11-27 10:59                               ` Werner Sembach
2023-12-29 19:13                               ` Werner Sembach
2024-01-17 15:26                               ` Hans de Goede
2024-01-17 15:26                                 ` Hans de Goede
2024-01-17 16:50                               ` Userspace API for per key backlight for non HID (no hidraw) keyboards Hans de Goede
2024-01-17 16:50                                 ` Hans de Goede
2024-01-17 19:03                                 ` Armin Wolf
2024-01-17 19:03                                   ` Armin Wolf
2024-01-18  0:58                                   ` Werner Sembach
2024-01-18  0:58                                     ` Werner Sembach
2024-01-18 17:45                               ` Implement per-key keyboard backlight as auxdisplay? Pavel Machek
2024-01-18 17:45                                 ` Pavel Machek
2024-01-18 22:32                                 ` Werner Sembach
2024-01-18 22:32                                   ` Werner Sembach
2024-01-19  8:44                                 ` Hans de Goede
2024-01-19  8:44                                   ` Hans de Goede
2024-01-19 10:51                                   ` Jani Nikula [this message]
2024-01-19 10:51                                     ` Jani Nikula
2024-01-19 16:06                                     ` Werner Sembach
2024-01-19 16:06                                       ` Werner Sembach
2024-01-19 18:33                                     ` Dmitry Torokhov
2024-01-19 18:33                                       ` Dmitry Torokhov
2024-01-19 22:14                                       ` Pavel Machek
2024-01-19 22:14                                         ` Pavel Machek
2024-01-23 16:51                                         ` Werner Sembach
2024-01-23 16:51                                           ` Werner Sembach
2024-01-19 15:19                                   ` Werner Sembach
2024-01-19 16:04                                   ` Werner Sembach
2024-01-19 16:04                                     ` Werner Sembach
2024-01-29 13:24                                     ` Hans de Goede
2024-01-29 13:24                                       ` Hans de Goede
2024-01-30 11:12                                       ` Werner Sembach
2024-01-30 11:12                                         ` Werner Sembach
2024-01-30 17:10                                         ` Hans de Goede
2024-01-30 17:10                                           ` Hans de Goede
2024-01-30 18:01                                           ` Werner Sembach
2024-01-30 18:09                                           ` Werner Sembach
2024-01-30 18:09                                             ` Werner Sembach
2024-01-30 18:35                                             ` Hans de Goede
2024-01-30 18:35                                               ` Hans de Goede
2024-01-30 19:08                                               ` Werner Sembach
2024-01-30 19:08                                                 ` Werner Sembach
2024-01-30 19:46                                                 ` Hans de Goede
2024-01-30 19:46                                                   ` Hans de Goede
2024-01-31 11:41                                                   ` Future handling of complex RGB devices on Linux Werner Sembach
2024-01-31 11:41                                                     ` Werner Sembach
2024-01-31 15:52                                                     ` Roderick Colenbrander
2024-01-31 15:52                                                       ` Roderick Colenbrander
2024-02-21 11:12                                                     ` Future handling of complex RGB devices on Linux v2 Werner Sembach
2024-02-21 22:17                                                       ` Pavel Machek
2024-02-22  9:04                                                         ` Pekka Paalanen
2024-02-22 17:38                                                           ` Pavel Machek
2024-02-23  8:53                                                             ` Pekka Paalanen
2024-07-23 20:40                                                               ` Keybaords with arrays of RGB LEDs was " Pavel Machek
2024-02-23  9:21                                                             ` Thomas Zimmermann
2024-02-22 10:46                                                         ` Hans de Goede
2024-02-22 11:38                                                           ` Gregor Riepl
2024-02-22 12:39                                                             ` Hans de Goede
2024-02-22 13:14                                                               ` Future handling of complex RGB devices on Linux v3 Werner Sembach
2024-03-18 11:11                                                                 ` Hans de Goede
2024-03-19 15:18                                                                   ` Werner Sembach
2024-03-25 14:18                                                                     ` Hans de Goede
2024-03-25 17:01                                                                       ` Werner Sembach
2024-03-20 11:16                                                                 ` Werner Sembach
2024-03-20 11:33                                                                   ` Werner Sembach
2024-03-20 18:45                                                                     ` Werner Sembach
2024-03-25 14:25                                                                   ` In kernel virtual HID devices (was Future handling of complex RGB devices on Linux v3) Hans de Goede
2024-03-25 15:56                                                                     ` Benjamin Tissoires
2024-03-25 16:48                                                                       ` Werner Sembach
2024-03-25 18:30                                                                         ` Hans de Goede
2024-03-26  7:57                                                                           ` Werner Sembach
2024-03-26 15:39                                                                             ` Benjamin Tissoires
2024-03-26 16:57                                                                               ` Werner Sembach
2024-03-27 11:03                                                                                 ` Benjamin Tissoires
2024-03-28 23:52                                                                                   ` Werner Sembach
2024-03-27 11:01                                                                               ` Hans de Goede
2024-07-24 17:36                                                                         ` Pavel Machek
2024-07-24 21:05                                                                           ` Werner Sembach
2024-07-24 21:08                                                                           ` Werner Sembach
2024-03-25 18:38                                                                     ` Miguel Ojeda
2024-04-09 13:33                                                                       ` Andy Shevchenko
2024-02-22 17:42                                                               ` Future handling of complex RGB devices on Linux v2 Pavel Machek
2024-02-22 17:52                                                               ` Pavel Machek
2024-02-22 17:23                                                           ` Pavel Machek
2024-02-23  8:33                                                         ` Werner Sembach
2024-01-19 20:15                                   ` Implement per-key keyboard backlight as auxdisplay? Pavel Machek
2024-01-19 20:15                                     ` Pavel Machek
2024-01-19 20:22                                     ` Werner Sembach
2024-01-19 20:22                                       ` Werner Sembach
2024-01-19 20:32                                       ` Pavel Machek
2024-01-19 20:32                                         ` Pavel Machek
2024-01-29 13:24                                     ` Hans de Goede
2024-01-29 13:24                                       ` Hans de Goede
2023-10-12 13:00 ` [PATCH] leds: rgb: Implement per-key keyboard backlight for several TUXEDO devices kernel test robot
2023-10-16 11:21 ` kernel test robot

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=87bk9hppee.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=jelle@vdwaa.nl \
    --cc=jikos@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=wse@tuxedocomputers.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.