-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Input: extract ChromeOS vivaldi physmap show function
Let's introduce a common library file for the physmap show function duplicated between three different keyboard drivers. This largely copies the code from cros_ec_keyb.c which has the most recent version of the show function, while using the vivaldi_data struct from the hid-vivaldi driver. This saves a small amount of space in an allyesconfig build. $ ./scripts/bloat-o-meter vmlinux.before vmlinux.after add/remove: 3/0 grow/shrink: 2/3 up/down: 412/-720 (-308) Function old new delta vivaldi_function_row_physmap_show - 292 +292 _sub_I_65535_1 1057564 1057616 +52 _sub_D_65535_0 1057564 1057616 +52 e843419@49f2_00062737_9b04 - 8 +8 e843419@20f6_0002a34d_35bc - 8 +8 atkbd_parse_fwnode_data 480 472 -8 atkbd_do_show_function_row_physmap 316 76 -240 function_row_physmap_show 620 148 -472 Total: Before=285581925, After=285581617, chg -0.00% Signed-off-by: Stephen Boyd <swboyd@chromium.org> Tested-by: Stephen Boyd <swboyd@chromium.org> # coachz, wormdingler Link: https://lore.kernel.org/r/20220228075446.466016-3-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
- Loading branch information
Stephen Boyd
authored and
Dmitry Torokhov
committed
Mar 15, 2022
1 parent
d950db3
commit 45ceaf1
Showing
9 changed files
with
108 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Helpers for ChromeOS Vivaldi keyboard function row mapping | ||
* | ||
* Copyright (C) 2022 Google, Inc | ||
*/ | ||
|
||
#include <linux/export.h> | ||
#include <linux/input/vivaldi-fmap.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/types.h> | ||
|
||
/** | ||
* vivaldi_function_row_physmap_show - Print vivaldi function row physmap attribute | ||
* @data: The vivaldi function row map | ||
* @buf: Buffer to print the function row phsymap to | ||
*/ | ||
ssize_t vivaldi_function_row_physmap_show(const struct vivaldi_data *data, | ||
char *buf) | ||
{ | ||
ssize_t size = 0; | ||
int i; | ||
const u32 *physmap = data->function_row_physmap; | ||
|
||
if (!data->num_function_row_keys) | ||
return 0; | ||
|
||
for (i = 0; i < data->num_function_row_keys; i++) | ||
size += scnprintf(buf + size, PAGE_SIZE - size, | ||
"%s%02X", size ? " " : "", physmap[i]); | ||
if (size) | ||
size += scnprintf(buf + size, PAGE_SIZE - size, "\n"); | ||
|
||
return size; | ||
} | ||
EXPORT_SYMBOL_GPL(vivaldi_function_row_physmap_show); | ||
|
||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _VIVALDI_FMAP_H | ||
#define _VIVALDI_FMAP_H | ||
|
||
#include <linux/types.h> | ||
|
||
#define VIVALDI_MAX_FUNCTION_ROW_KEYS 24 | ||
|
||
/** | ||
* struct vivaldi_data - Function row map data for ChromeOS Vivaldi keyboards | ||
* @function_row_physmap: An array of scancodes or their equivalent (HID usage | ||
* codes, encoded rows/columns, etc) for the top | ||
* row function keys, in an order from left to right | ||
* @num_function_row_keys: The number of top row keys in a custom keyboard | ||
* | ||
* This structure is supposed to be used by ChromeOS keyboards using | ||
* the Vivaldi keyboard function row design. | ||
*/ | ||
struct vivaldi_data { | ||
u32 function_row_physmap[VIVALDI_MAX_FUNCTION_ROW_KEYS]; | ||
unsigned int num_function_row_keys; | ||
}; | ||
|
||
ssize_t vivaldi_function_row_physmap_show(const struct vivaldi_data *data, | ||
char *buf); | ||
|
||
#endif /* _VIVALDI_FMAP_H */ |