162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Helpers for ChromeOS Vivaldi keyboard function row mapping
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2022 Google, Inc
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/export.h>
962306a36Sopenharmony_ci#include <linux/input/vivaldi-fmap.h>
1062306a36Sopenharmony_ci#include <linux/kernel.h>
1162306a36Sopenharmony_ci#include <linux/module.h>
1262306a36Sopenharmony_ci#include <linux/types.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/**
1562306a36Sopenharmony_ci * vivaldi_function_row_physmap_show - Print vivaldi function row physmap attribute
1662306a36Sopenharmony_ci * @data: The vivaldi function row map
1762306a36Sopenharmony_ci * @buf: Buffer to print the function row phsymap to
1862306a36Sopenharmony_ci */
1962306a36Sopenharmony_cissize_t vivaldi_function_row_physmap_show(const struct vivaldi_data *data,
2062306a36Sopenharmony_ci					  char *buf)
2162306a36Sopenharmony_ci{
2262306a36Sopenharmony_ci	ssize_t size = 0;
2362306a36Sopenharmony_ci	int i;
2462306a36Sopenharmony_ci	const u32 *physmap = data->function_row_physmap;
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci	if (!data->num_function_row_keys)
2762306a36Sopenharmony_ci		return 0;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	for (i = 0; i < data->num_function_row_keys; i++)
3062306a36Sopenharmony_ci		size += scnprintf(buf + size, PAGE_SIZE - size,
3162306a36Sopenharmony_ci				  "%s%02X", size ? " " : "", physmap[i]);
3262306a36Sopenharmony_ci	if (size)
3362306a36Sopenharmony_ci		size += scnprintf(buf + size, PAGE_SIZE - size, "\n");
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci	return size;
3662306a36Sopenharmony_ci}
3762306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(vivaldi_function_row_physmap_show);
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciMODULE_LICENSE("GPL");
40