mmc: fsl_esdhc: Fix SDR104 and HS200 support
[oweals/u-boot.git] / include / input.h
index 31b1ef9603263fbee76f13ffc01b7219ecdf5c79..3285a3ffa28919d31c042fd08cfc1e5774155db8 100644 (file)
@@ -1,24 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Keyboard input helper functions (too small to be called a layer)
  *
  * Copyright (c) 2011 The Chromium OS Authors.
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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 _INPUT_H
@@ -32,8 +16,8 @@ enum {
 enum {
        /* Keyboard LEDs */
        INPUT_LED_SCROLL        = 1 << 0,
-       INPUT_LED_CAPS          = 1 << 1,
-       INPUT_LED_NUM           = 1 << 2,
+       INPUT_LED_NUM           = 1 << 1,
+       INPUT_LED_CAPS          = 1 << 2,
 };
 
 /*
@@ -51,13 +35,15 @@ struct input_key_xlate {
 };
 
 struct input_config {
+       struct udevice *dev;
        uchar fifo[INPUT_BUFFER_LEN];
        int fifo_in, fifo_out;
 
        /* Which modifiers are active (1 bit for each MOD_... value) */
        uchar modifiers;
        uchar flags;            /* active state keys (FLAGS_...) */
-       uchar leds;             /* active LEDS (INPUT_LED_...) */
+       uchar leds;             /* active LEDs (INPUT_LED_...) */
+       uchar leds_changed;     /* LEDs that just changed */
        uchar num_tables;       /* number of modifier tables */
        int prev_keycodes[INPUT_BUFFER_LEN];    /* keys held last time */
        int num_prev_keycodes;  /* number of prev keys */
@@ -71,6 +57,7 @@ struct input_config {
         *              unknown
         */
        int (*read_keys)(struct input_config *config);
+       bool allow_repeats;             /* Don't filter out repeats */
        unsigned int next_repeat_ms;    /* Next time we repeat a key */
        unsigned int repeat_delay_ms;   /* Time before autorepeat starts */
        unsigned int repeat_rate_ms;    /* Autorepeat rate in ms */
@@ -84,9 +71,31 @@ struct stdio_dev;
  * @param config       Input state
  * @param keycode      List of key codes to examine
  * @param num_keycodes Number of key codes
+ * @return number of ascii characters sent, or 0 if none, or -1 for an
+ *     internal error
  */
 int input_send_keycodes(struct input_config *config, int keycode[], int count);
 
+/**
+ * Add a new keycode to an existing list of keycodes
+ *
+ * This can be used to handle keyboards which do their own scanning. An
+ * internal list of depressed keys is maintained by the input library. Then
+ * this function is called to add a new key to the list (when a 'make code' is
+ * received), or remove a key (when a 'break code' is received).
+ *
+ * This function looks after maintenance of the list of active keys, and calls
+ * input_send_keycodes() with its updated list.
+ *
+ * @param config       Input state
+ * @param new_keycode  New keycode to add/remove
+ * @param release      true if this key was released, false if depressed
+ * @return number of ascii characters sent, or 0 if none, or -1 for an
+ *     internal error
+ */
+int input_add_keycode(struct input_config *config, int new_keycode,
+                     bool release);
+
 /**
  * Add a new key translation table to the input
  *
@@ -125,17 +134,63 @@ int input_getc(struct input_config *config);
  */
 int input_stdio_register(struct stdio_dev *dev);
 
+/**
+ * Set up the keyboard autorepeat delays
+ *
+ * @param repeat_delay_ms      Delay before key auto-repeat starts (in ms)
+ * @param repeat_rate_ms       Delay between successive key repeats (in ms)
+ */
+void input_set_delays(struct input_config *config, int repeat_delay_ms,
+              int repeat_rate_ms);
+
+/**
+ * Tell the input layer whether to allow the caller to determine repeats
+ *
+ * Generally the input library handles processing of a list of scanned keys.
+ * Repeated keys need to be generated based on a timer in this case, since all
+ * that is provided is a list of keys current depressed.
+ *
+ * Keyboards which do their own scanning will resend codes when they want to
+ * inject a repeating key. This function can be called at start-up to select
+ * this behaviour.
+ *
+ * @param config       Input state
+ * @param allow_repeats        true to repeat depressed keys every time
+ *                     input_send_keycodes() is called, false to do normal
+ *                     keyboard repeat processing with a timer.
+ */
+void input_allow_repeats(struct input_config *config, bool allow_repeats);
+
+/**
+ * Check if keyboard LEDs need to be updated
+ *
+ * This can be called after input_tstc() to see if keyboard LEDs need
+ * updating.
+ *
+ * @param config       Input state
+ * @return -1 if no LEDs need updating, other value if they do
+ */
+int input_leds_changed(struct input_config *config);
+
+/**
+ * Set up the key map tables
+ *
+ * This must be called after input_init() or keycode decoding will not work.
+ *
+ * @param config       Input state
+ * @param german       true to use German keyboard layout, false for US
+ * @return 0 if ok, -1 on error
+ */
+int input_add_tables(struct input_config *config, bool german);
+
 /**
  * Set up the input handler with basic key maps.
  *
  * @param config       Input state
  * @param leds         Initial LED value (INPUT_LED_ mask), 0 suggested
- * @param repeat_delay_ms      Delay before key auto-repeat starts (in ms)
- * @param repeat_rate_ms       Delay between successive key repeats (in ms)
  * @return 0 if ok, -1 on error
  */
-int input_init(struct input_config *config, int leds, int repeat_delay_ms,
-              int repeat_rate_ms);
+int input_init(struct input_config *config, int leds);
 
 #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 extern int overwrite_console(void);