2020-05-27 17:08:40 +02:00
|
|
|
/*
|
|
|
|
* tuxedo_keyboard_common.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#ifndef TUXEDO_KEYBOARD_COMMON_H
|
|
|
|
#define TUXEDO_KEYBOARD_COMMON_H
|
|
|
|
|
2020-05-29 16:20:02 +02:00
|
|
|
#include <linux/module.h>
|
2020-05-27 17:08:40 +02:00
|
|
|
#include <linux/input/sparse-keymap.h>
|
|
|
|
|
|
|
|
/* :::: Module specific Constants and simple Macros :::: */
|
|
|
|
#define __TUXEDO_PR(lvl, fmt, ...) do { pr_##lvl(fmt, ##__VA_ARGS__); } while (0)
|
|
|
|
#define TUXEDO_INFO(fmt, ...) __TUXEDO_PR(info, fmt, ##__VA_ARGS__)
|
|
|
|
#define TUXEDO_ERROR(fmt, ...) __TUXEDO_PR(err, fmt, ##__VA_ARGS__)
|
|
|
|
#define TUXEDO_DEBUG(fmt, ...) __TUXEDO_PR(debug, "[%s:%u] " fmt, __func__, __LINE__, ##__VA_ARGS__)
|
|
|
|
|
2020-05-29 16:20:02 +02:00
|
|
|
#ifndef DRIVER_NAME
|
|
|
|
#define DRIVER_NAME "tuxedo_keyboard"
|
|
|
|
#endif
|
|
|
|
|
2020-05-28 18:35:46 +02:00
|
|
|
struct tuxedo_keyboard_driver {
|
2020-05-29 11:41:05 +02:00
|
|
|
// Platform driver provided by driver
|
2020-05-28 18:35:46 +02:00
|
|
|
struct platform_driver *platform_driver;
|
2020-05-29 11:41:05 +02:00
|
|
|
// Probe method provided by driver
|
2020-05-28 18:35:46 +02:00
|
|
|
int (*probe)(struct platform_device *);
|
2020-05-29 11:41:05 +02:00
|
|
|
// Keymap provided by driver
|
2020-05-28 18:35:46 +02:00
|
|
|
struct key_entry *key_map;
|
2020-05-29 11:41:05 +02:00
|
|
|
// Input device reference filled in on module init after probe success
|
|
|
|
struct input_dev *input_device;
|
2020-05-28 18:35:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Global module devices
|
2020-05-27 17:08:40 +02:00
|
|
|
static struct platform_device *tuxedo_platform_device;
|
|
|
|
static struct input_dev *tuxedo_input_device;
|
|
|
|
|
2020-05-28 18:35:46 +02:00
|
|
|
// Currently chosen driver
|
|
|
|
static struct tuxedo_keyboard_driver *current_driver;
|
|
|
|
|
2020-05-27 17:08:40 +02:00
|
|
|
/**
|
|
|
|
* Basically a copy of the existing report event but doesn't report unknown events
|
|
|
|
*/
|
|
|
|
bool sparse_keymap_report_known_event(struct input_dev *dev, unsigned int code,
|
|
|
|
unsigned int value, bool autorelease)
|
|
|
|
{
|
|
|
|
const struct key_entry *ke =
|
|
|
|
sparse_keymap_entry_from_scancode(dev, code);
|
|
|
|
|
|
|
|
if (ke) {
|
|
|
|
sparse_keymap_report_entry(dev, ke, value, autorelease);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|