lkml.org 
[lkml]   [2021]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v17] tty: Fix the keyboard led light display problem
Date
By judging the value of kb->kbdmode to determine whether it is necessary
to forcibly set the led state of the keyboard when switching between
different ttys. Solve the problem of the inconsistency between the
keyboard led status and the keyboard lock status in some scenarios,
such as the scenario where the desktop and tty switch mutually.

Signed-off-by: lianzhi chang <changlianzhi@uniontech.com>
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
v17: Modify the description information.

drivers/tty/vt/keyboard.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index c7fbbcdcc346..e60ac9f39d6c 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -153,6 +153,7 @@ static int shift_state = 0;

static unsigned int ledstate = -1U; /* undefined */
static unsigned char ledioctl;
+static bool vt_switch;

/*
* Notifier list for console keyboard events
@@ -412,9 +413,21 @@ static void do_compute_shiftstate(void)
/* We still have to export this method to vt.c */
void vt_set_leds_compute_shiftstate(void)
{
+ struct kbd_struct *kb;
unsigned long flags;

- set_leds();
+ /*
+ * When switching VT, according to the value of kb->kbdmode,
+ * judge whether it is necessary to force the keyboard light
+ * state to be issued.
+ */
+ kb = kbd_table + fg_console;
+ if (kb->kbdmode == VC_RAW ||
+ kb->kbdmode == VC_MEDIUMRAW ||
+ kb->kbdmode == VC_OFF) {
+ vt_switch = true;
+ set_leds();
+ }

spin_lock_irqsave(&kbd_event_lock, flags);
do_compute_shiftstate();
@@ -1255,6 +1268,11 @@ static void kbd_bh(struct tasklet_struct *unused)
leds |= (unsigned int)kbd->lockstate << 8;
spin_unlock_irqrestore(&led_lock, flags);

+ if (vt_switch) {
+ ledstate = ~leds;
+ vt_switch = false;
+ }
+
if (leds != ledstate) {
kbd_propagate_led_state(ledstate, leds);
ledstate = leds;
--
2.20.1


\
 
 \ /
  Last update: 2021-11-26 12:31    [W:0.067 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site