Skip to contentSkip to conversation

add CONFIG_VT_UNICODE

PATCH In review Bill Nottingham 4 participants 11 messages Aug 31, 2007 – Sep 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add CONFIG_VT_UNICODE

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

drivers/char/keyboard.c renamed from drivers/char/keyboard.c.foo +1 -1
diff -up linux-2.6.22.noarch/drivers/char/keyboard.c.foo linux-2.6.22.noarch/drivers/char/keyboard.c
@@ -1366,7 +1366,7 @@ int __init kbd_init(void)
 		kbd_table[i].lockstate = KBD_DEFLOCK;
 		kbd_table[i].slockstate = 0;
 		kbd_table[i].modeflags = KBD_DEFMODE;
-		kbd_table[i].kbdmode = VC_XLATE;
+		kbd_table[i].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 	}
 
 	error = input_register_handler(&kbd_handler);
drivers/char/vt_ioctl.c renamed from drivers/char/vt_ioctl.c.foo +1 -1
diff -up linux-2.6.22.noarch/drivers/char/vt_ioctl.c.foo linux-2.6.22.noarch/drivers/char/vt_ioctl.c
@@ -1070,7 +1070,7 @@ int vt_waitactive(int vt)
 void reset_vc(struct vc_data *vc)
 {
 	vc->vc_mode = KD_TEXT;
-	kbd_table[vc->vc_num].kbdmode = VC_XLATE;
+	kbd_table[vc->vc_num].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 	vc->vt_mode.mode = VT_AUTO;
 	vc->vt_mode.waitv = 0;
 	vc->vt_mode.relsig = 0;
drivers/char/Kconfig renamed from drivers/char/Kconfig.foo +17 -0
diff -up linux-2.6.22.noarch/drivers/char/Kconfig.foo linux-2.6.22.noarch/drivers/char/Kconfig
@@ -36,6 +36,23 @@ config VT
 	  If unsure, say Y, or else you won't be able to do much with your new
 	  shiny Linux system :-)
 
+config VT_UNICODE
+	bool "Virtual console is Unicode by default"
+	depends on VT
+	default n
+	---help---
+	  If you say Y here, the virtual terminal will be in UTF-8 by default,
+	  and the keyboard will run in unicode mode.
+
+	  If you say N here, the virtual terminal will not be in UTF-8 by
+	  default, and the keyboard will run in XLATE mode.
+
+	  This can also be changed by passing 'default_utf8=<0|1>' on the
+	  kernel command line.
+
+	  Historically, the kernel has defaulted to non-UTF8 and XLATE mode.
+	  If unsure, say N here.
+
 config VT_CONSOLE
 	bool "Support for console on virtual terminal" if EMBEDDED
 	depends on VT
drivers/char/vt.c renamed from drivers/char/vt.c.foo +5 -1
diff -up linux-2.6.22.noarch/drivers/char/vt.c.foo linux-2.6.22.noarch/drivers/char/vt.c
@@ -158,7 +158,11 @@ static void blank_screen_t(unsigned long
 static void set_palette(struct vc_data *vc);
 
 static int printable;		/* Is console ready for printing? */
-static int default_utf8;
+#ifdef CONFIG_VT_UNICODE
+int default_utf8 = 1;
+#else
+int default_utf8;
+#endif
 module_param(default_utf8, int, S_IRUGO | S_IWUSR);
 
 /*
drivers/char/sysrq.c renamed from drivers/char/sysrq.c.foo +2 -2
diff -up linux-2.6.22.noarch/drivers/char/sysrq.c.foo linux-2.6.22.noarch/drivers/char/sysrq.c
@@ -107,12 +107,12 @@ static void sysrq_handle_unraw(int key, 
 	struct kbd_struct *kbd = &kbd_table[fg_console];
 
 	if (kbd)
-		kbd->kbdmode = VC_XLATE;
+		kbd->kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 }
 static struct sysrq_key_op sysrq_unraw_op = {
 	.handler	= sysrq_handle_unraw,
 	.help_msg	= "unRaw",
-	.action_msg	= "Keyboard mode set to XLATE",
+	.action_msg	= "Keyboard mode set to system default",
 	.enable_mask	= SYSRQ_ENABLE_KEYBOARD,
 };
 #else
include/linux/vt_kern.h renamed from include/linux/vt_kern.h.foo +1 -0
diff -up linux-2.6.22.x86_64/include/linux/vt_kern.h.foo linux-2.6.22.x86_64/include/linux/vt_kern.h
@@ -87,6 +87,7 @@ extern int unbind_con_driver(const struc
 extern char con_buf[CON_BUF_SIZE];
 extern struct mutex con_buf_mtx;
 extern char vt_dont_switch;
+extern int default_utf8;
 
 struct vt_spawn_console {
 	spinlock_t lock;
#1 lore raw
Quoted 9 lines · On Fri, 31 Aug 2007 16:18:20 -0400 Bill Nottingham wrote:

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

Hi,

A diffstat would be nice.

Please document 'default_utf8=' in Documentation/kernel-parameters.txt.

Quoted 89 lines

diff -up linux-2.6.22.noarch/drivers/char/keyboard.c.foo linux-2.6.22.noarch/drivers/char/keyboard.c

drivers/char/keyboard.c renamed from drivers/char/keyboard.c.foo +1 -1
@@ -1366,7 +1366,7 @@ int __init kbd_init(void)
 		kbd_table[i].lockstate = KBD_DEFLOCK;
 		kbd_table[i].slockstate = 0;
 		kbd_table[i].modeflags = KBD_DEFMODE;
-		kbd_table[i].kbdmode = VC_XLATE;
+		kbd_table[i].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 	}
 
 	error = input_register_handler(&kbd_handler);

diff -up linux-2.6.22.noarch/drivers/char/vt_ioctl.c.foo linux-2.6.22.noarch/drivers/char/vt_ioctl.c

drivers/char/vt_ioctl.c renamed from drivers/char/vt_ioctl.c.foo +1 -1
@@ -1070,7 +1070,7 @@ int vt_waitactive(int vt)
 void reset_vc(struct vc_data *vc)
 {
 	vc->vc_mode = KD_TEXT;
-	kbd_table[vc->vc_num].kbdmode = VC_XLATE;
+	kbd_table[vc->vc_num].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 	vc->vt_mode.mode = VT_AUTO;
 	vc->vt_mode.waitv = 0;
 	vc->vt_mode.relsig = 0;

diff -up linux-2.6.22.noarch/drivers/char/Kconfig.foo linux-2.6.22.noarch/drivers/char/Kconfig

drivers/char/Kconfig renamed from drivers/char/Kconfig.foo +17 -0
@@ -36,6 +36,23 @@ config VT
 	  If unsure, say Y, or else you won't be able to do much with your new
 	  shiny Linux system :-)
 
+config VT_UNICODE
+	bool "Virtual console is Unicode by default"
+	depends on VT
+	default n
+	---help---
+	  If you say Y here, the virtual terminal will be in UTF-8 by default,
+	  and the keyboard will run in unicode mode.
+
+	  If you say N here, the virtual terminal will not be in UTF-8 by
+	  default, and the keyboard will run in XLATE mode.
+
+	  This can also be changed by passing 'default_utf8=<0|1>' on the
+	  kernel command line.
+
+	  Historically, the kernel has defaulted to non-UTF8 and XLATE mode.
+	  If unsure, say N here.
+
 config VT_CONSOLE
 	bool "Support for console on virtual terminal" if EMBEDDED
 	depends on VT

diff -up linux-2.6.22.noarch/drivers/char/vt.c.foo linux-2.6.22.noarch/drivers/char/vt.c

drivers/char/vt.c renamed from drivers/char/vt.c.foo +5 -1
@@ -158,7 +158,11 @@ static void blank_screen_t(unsigned long
 static void set_palette(struct vc_data *vc);
 
 static int printable;		/* Is console ready for printing? */
-static int default_utf8;
+#ifdef CONFIG_VT_UNICODE
+int default_utf8 = 1;
+#else
+int default_utf8;
+#endif
 module_param(default_utf8, int, S_IRUGO | S_IWUSR);
 
 /*

diff -up linux-2.6.22.noarch/drivers/char/sysrq.c.foo linux-2.6.22.noarch/drivers/char/sysrq.c

drivers/char/sysrq.c renamed from drivers/char/sysrq.c.foo +2 -2
@@ -107,12 +107,12 @@ static void sysrq_handle_unraw(int key, 
 	struct kbd_struct *kbd = &kbd_table[fg_console];
 
 	if (kbd)
-		kbd->kbdmode = VC_XLATE;
+		kbd->kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;
 }
 static struct sysrq_key_op sysrq_unraw_op = {
 	.handler	= sysrq_handle_unraw,
 	.help_msg	= "unRaw",
-	.action_msg	= "Keyboard mode set to XLATE",
+	.action_msg	= "Keyboard mode set to system default",
 	.enable_mask	= SYSRQ_ENABLE_KEYBOARD,
 };
 #else

diff -up linux-2.6.22.x86_64/include/linux/vt_kern.h.foo linux-2.6.22.x86_64/include/linux/vt_kern.h

include/linux/vt_kern.h extern int unbind_con_driver(const struc

Quoted 8 lines
include/linux/vt_kern.h renamed from include/linux/vt_kern.h.foo +1 -1
@@ -87,6 +87,7 @@ extern int unbind_con_driver(const struc
 extern char con_buf[CON_BUF_SIZE];
 extern struct mutex con_buf_mtx;
 extern char vt_dont_switch;
+extern int default_utf8;
 
 struct vt_spawn_console {
 	spinlock_t lock;
-

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#2 lore raw
Quoted 1 line · Randy Dunlap

A diffstat would be nice.

Sure.

 linux-2.6.22.noarch/drivers/char/Kconfig    |   17 +++++++++++++++++
 linux-2.6.22.noarch/drivers/char/keyboard.c |    2 +-
 linux-2.6.22.noarch/drivers/char/sysrq.c    |    4 ++--
 linux-2.6.22.noarch/drivers/char/vt.c       |    6 +++++-
 linux-2.6.22.noarch/drivers/char/vt_ioctl.c |    2 +-
 linux-2.6.22.x86_64/include/linux/vt_kern.h |    1 +
 6 files changed, 27 insertions(+), 5 deletions(-)
Quoted 1 line

Please document 'default_utf8=' in Documentation/kernel-parameters.txt.

It's already documented there (existed before this patch).

Bill

#3 lore raw
Quoted 13 lines · Bill Nottingham
Quoted 1 line · Randy Dunlap

A diffstat would be nice.

Sure.

 linux-2.6.22.noarch/drivers/char/Kconfig    |   17 +++++++++++++++++
 linux-2.6.22.noarch/drivers/char/keyboard.c |    2 +-
 linux-2.6.22.noarch/drivers/char/sysrq.c    |    4 ++--
 linux-2.6.22.noarch/drivers/char/vt.c       |    6 +++++-
 linux-2.6.22.noarch/drivers/char/vt_ioctl.c |    2 +-
 linux-2.6.22.x86_64/include/linux/vt_kern.h |    1 +
 6 files changed, 27 insertions(+), 5 deletions(-)
Quoted 3 lines
Quoted 1 line

Please document 'default_utf8=' in Documentation/kernel-parameters.txt.

It's already documented there (existed before this patch).

Great :)

Thanks.

Signature · 2 lines
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
#4 lore raw
In reply to Bill Nottingham
Quoted 9 lines · Bill Nottingham

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

Wasn't there a patch floating around about this a couple of months ago, which also let you set the system-wide default via sysctl?

-hpa

#5 lore raw
Quoted 5 lines · H. Peter Anvin
Quoted 4 lines · Bill Nottingham

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

Quoted 8 lines
Quoted 5 lines

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

Wasn't there a patch floating around about this a couple of months ago, which also let you set the system-wide default via sysctl?

sysfs, and you were on the discussion (your idea won, basically....) And the way I see it, it got merged.
Commit 042f10ec6533e53181284c96d22ae051e49ac707

As I further see it, this CONFIG_VT_UNICODE patch defines the starting value for the default.

E.g. CONFIG_VT_UNICODE=y, you start with utf8, and can, at will, at runtime, change it. CONFIG_VT_UNICODE=n, you start with 8bit, and can, at will, at runtime, too, change it ;-)

Jan

#6 lore raw
Quoted 9 lines · Jan Engelhardt

sysfs, and you were on the discussion (your idea won, basically....) And the way I see it, it got merged.
Commit 042f10ec6533e53181284c96d22ae051e49ac707

As I further see it, this CONFIG_VT_UNICODE patch defines the starting value for the default.

E.g. CONFIG_VT_UNICODE=y, you start with utf8, and can, at will, at runtime, change it. CONFIG_VT_UNICODE=n, you start with 8bit, and can, at will, at runtime, too, change it ;-)

Hmmm...

Personally I'd suggest making it the default unless overridden in /etc/sysctl.conf. My second preference would be a command-line option, not a compile-time default.

This is 2007, after all, and it seems Unicode should be the default, anything else legacy...

-hpa

#7 lore raw
Quoted 8 lines · H. Peter Anvin

Hmmm...

Personally I'd suggest making it the default unless overridden in /etc/sysctl.conf. My second preference would be a command-line option, not a compile-time default.

This is 2007, after all, and it seems Unicode should be the default, anything else legacy...

At the moment, it's a module parameter (ergo sysfs), not /proc/sys. Also, this patch ties unicode for the keyboard as well.

Bill

#8 lore raw
In reply to H. Peter Anvin
Quoted 11 lines · H. Peter Anvin
Quoted 10 lines

sysfs, and you were on the discussion (your idea won, basically....) And the way I see it, it got merged.
Commit 042f10ec6533e53181284c96d22ae051e49ac707

As I further see it, this CONFIG_VT_UNICODE patch defines the starting value for the default.

E.g. CONFIG_VT_UNICODE=y, you start with utf8, and can, at will, at runtime, change it. CONFIG_VT_UNICODE=n, you start with 8bit, and can, at will, at runtime, too, change it ;-)

Quoted 8 lines

Hmmm...

Personally I'd suggest making it the default unless overridden in /etc/sysctl.conf. My second preference would be a command-line option, not a compile-time default.

This is 2007, after all, and it seems Unicode should be the default, anything else legacy...

Yeah. You have a command line option already, called vt.default_utf={0|1}.

Jan

#9 lore raw
In reply to Bill Nottingham
Quoted 8 lines · Bill Nottingham

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

I would prefer to:
- make default_utf=1 in the source
- add "default_utf8 ? VC_UNICODE : VC_XLATE" to the keyboard code as your patch does
- and do away with the new CONFIG_ option, since, surprise, surprise, you can change it at runtime, so there is no need to do it at compile-time too.

Jan

#10 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 7 lines · Bill Nottingham

As of now, the kernel defaults to non-unicode and XLATE for the keyboard. We've been changing this in Fedora, but that requires patching the defaults in the kernel.

The attached introduces CONFIG_VT_UNICODE, which sets the console in unicode mode by default on boot, including both the virtual terminal and the keyboard driver.

Quoted 8 lines

I would prefer to:
- make default_utf=1 in the source
- add "default_utf8 ? VC_UNICODE : VC_XLATE" to the keyboard code as your patch does
- and do away with the new CONFIG_ option, since, surprise, surprise, you can change it at runtime, so there is no need to do it at compile-time too.

I concur.

-hpa