matrix_keypad_build_keymap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– matrix_keypad_build_keymap ✨

okay so you're reading the Kernel API Manual, section 9, and the star of the show is matrix_keypad_build_keymap β€” the little function that takes your platform keymap and turns it into a matrix keymap. bestie, it's giving "glow-up for keycodes" and honestly? iconic. πŸŽ€


🌸 NAME 🌸

matrix_keypad_build_keymap β€” convert platform keymap into matrix keymap πŸ’…


✨ SYNOPSIS ✨

int matrix_keypad_build_keymap (const struct matrix_keymap_data
*keymap_data , const char *keymap_name , unsigned int rows , unsigned
int cols , unsigned short *keymap , struct input_dev *input_dev );

like, look at all those args. she's thriving. πŸ¦‹


🫢 ARGUMENTS 🫢

  • keymap_data β€” the keymap your platform code hands over. the source material, the blueprint, the moment. ✨
  • keymap_name β€” the name of the device tree property that contains the keymap (only if device tree support is enabled, iykyk). 🌈
  • rows β€” how many rows the target keymap array has. math but make it cute. πŸ”’
  • cols β€” how many cols the target keymap array has. yes queen, dimensions. πŸ‘‘
  • keymap β€” the expanded version of the keymap, suitable for use by a matrix keyboard driver. the glow-up result! πŸ’–
  • input_dev β€” the input device we're setting up the keymap for. main character energy fr fr. 🧚

πŸ’œ DESCRIPTION πŸ’œ

so what she does is: this function converts the platform keymap (encoded with the KEY macro) into an array of keycodes that's suitable for using in a standard matrix keyboard driver that uses row and col as indices. no cap, that's the whole vibe. πŸ¦‹

if keymap_data is not supplied and device tree support is enabled, she'll attempt to load the keymap from the property specified by the keymap_name argument β€” or "linux,keymap" if keymap_name is NULL. fallback queen behavior. πŸ’…

if keymap is NULL, the function will automatically allocate a managed block of memory to store the keymap. that memory gets associated with the parent device and is automatically freed when the device unbinds from the driver. literal self-care. ✨

⚠️ real talk: callers are expected to set up input_dev->dev.parent before calling this function. do that first or it's gonna be a mess, bestie. 😭

πŸ”₯ SEE ALSO πŸ”₯

  • Kernel file ./drivers/input/matrix-keymap.c β€” go read the source, it's lowkey fascinating πŸ“–
  • matrix_keypad_parse_properties(9) β€” her bestie, obviously 🫢

and that's the whole page, bestie! πŸŽ€ this one shipped out of ./drivers/input, dated October 2026, and it's your girl matrix_keypad_build_keymap(9) signing off β€” slay, stay keyed, and don't forget your parent device πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from