All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] Emulate dip switch language layout settings on SUN keyboard
@ 2023-01-14 11:50 Henrik Carlqvist
  2023-01-14 14:38 ` [PATCH v5] " Henrik Carlqvist
  0 siblings, 1 reply; 13+ messages in thread
From: Henrik Carlqvist @ 2023-01-14 11:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, atar4qemu, marcandre.lureau

This is my fourth attempt to contribute the patch which allows the emulation
of different keyboard layouts on sparc which uses a dip switch on the keyboard
for those settings.

After my third attempt I falsely thought that sourcehut stripped off my 
signed-off line, but it was me who forgot to call git with the -s switch
at commit.

regards Henrik

From 46233aaf57e27207c6d32cdf263b878edeea6263 Mon Sep 17 00:00:00 2001
From: Henrik Carlqvist <hc1245@poolhem.se>
Date: Fri, 6 Jan 2023 22:33:03 +0100
Subject: [PATCH] Emulating sun keyboard language layout dip switches, taking
 the value for the dip switches from the "-k" option to qemu.

SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
layout of the keyboard. Solaris makes an ioctl to query the value of the
dipswitches and uses that value to select keyboard layout. Also the SUN
bios like the one in the file ss5.bin uses this value to support at least
some keyboard layouts. However, the OpenBIOS provided with qemu is
hardcoded to always use an US keyboard layout.

Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
this patch uses the command line switch "-k" (keyboard layout) to select
dip switch value. A table is used to lookup values from arguments like:

-k fr
-k es

But the patch also accepts numeric dip switch values directly to the -k
switch:

-k 0x2b
-k 43

Both values above are the same and select swedish keyboard as explained in
table 3-15 at
https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html

Unless you want to do a full Solaris installation but happen to have
access to a bios file, the easiest way to test that the patch works is to:

qemu-system-sparc -k sv -bios /path/to/ss5.bin

If you already happen to have a Solaris installation in a qemu disk image
file you can easily try different keyboard layouts after this patch is
applied.

Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
---
 hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+), 1 deletion(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 17a908c59b..53022ccf39 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -31,6 +31,8 @@
 #include "qemu/module.h"
 #include "hw/char/escc.h"
 #include "ui/console.h"
+#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
 #include "trace.h"
 
 /*
@@ -190,6 +192,7 @@
 #define R_MISC1I 14
 #define R_EXTINT 15
 
+static unsigned char sun_keyboard_layout_dip_switch(void);
 static void handle_kbd_command(ESCCChannelState *s, int val);
 static int serial_can_receive(void *opaque);
 static void serial_receive_byte(ESCCChannelState *s, int ch);
@@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
     .event = sunkbd_handle_event,
 };
 
+static unsigned char sun_keyboard_layout_dip_switch(void)
+{
+    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
+    static unsigned char ret = 0xff;
+
+    if ((ret == 0xff) && keyboard_layout) {
+        int i;
+        struct layout_values {
+            const char *lang;
+            unsigned char dip;
+        } languages[] =
+    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards */
+            {
+                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
+                                 /* 0x22 is some other US (US_UNIX5.kt)*/
+                {"fr",    0x23}, /* France (France5.kt) */
+                {"da",    0x24}, /* Denmark (Denmark5.kt) */
+                {"de",    0x25}, /* Germany (Germany5.kt) */
+                {"it",    0x26}, /* Italy (Italy5.kt) */
+                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
+                {"no",    0x28}, /* Norway (Norway.kt) */
+                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
+                {"es",    0x2a}, /* Spain (Spain5.kt) */
+                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
+                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
+                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
+                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
+                {"ko",    0x2f}, /* Korea (Korea5.kt) */
+                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
+                {"ja",    0x31}, /* Japan (Japan5.kt) */
+                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
+                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
+                {"pl",    0x34}, /* Poland (Poland5.kt) */
+                {"cz",    0x35}, /* Czech (Czech5.kt) */
+                {"ru",    0x36}, /* Russia (Russia5.kt) */
+                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
+                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
+                {"gr",    0x39}, /* Greece (Greece5.kt) */
+                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
+                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
+                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
+                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
+            };
+
+        for (i = 0;
+             i < sizeof(languages) / sizeof(struct layout_values);
+             i++) {
+            if (!strcmp(keyboard_layout, languages[i].lang)) {
+                ret = languages[i].dip;
+                return ret;
+            }
+        }
+        /* Found no known language code */
+
+        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
+            unsigned int tmp;
+            /* As a fallback we also accept numeric dip switch value */
+            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
+                ret = (unsigned char)tmp;
+            }
+        }
+    }
+    if (ret == 0xff) {
+        /* Final fallback if keyboard_layout was not set or recognized */
+        ret = 0x21; /* en-us layout */
+    }
+    return ret;
+}
+
 static void handle_kbd_command(ESCCChannelState *s, int val)
 {
     trace_escc_kbd_command(val);
@@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int val)
     case 0xf:
         clear_queue(s);
         put_queue(s, 0xfe);
-        put_queue(s, 0x21); /*  en-us layout */
+        put_queue(s, sun_keyboard_layout_dip_switch());
         break;
     default:
         break;
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-14 11:50 [PATCH v4] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
@ 2023-01-14 14:38 ` Henrik Carlqvist
  2023-01-22 18:07   ` Mark Cave-Ayland
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Henrik Carlqvist @ 2023-01-14 14:38 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: qemu-devel, pbonzini, atar4qemu, marcandre.lureau

https://patchew.org/QEMU/20230114125029.7395a547.hc981@poolhem.se/ 
complains that "patch is empty", so here is my fifth attempt...

regards Henrik

SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
layout of the keyboard. Solaris makes an ioctl to query the value of the
dipswitches and uses that value to select keyboard layout. Also the SUN
bios like the one in the file ss5.bin uses this value to support at least
some keyboard layouts. However, the OpenBIOS provided with qemu is
hardcoded to always use an US keyboard layout.

Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
this patch uses the command line switch "-k" (keyboard layout) to select
dip switch value. A table is used to lookup values from arguments like:

-k fr
-k es

But the patch also accepts numeric dip switch values directly to the -k
switch:

-k 0x2b
-k 43

Both values above are the same and select swedish keyboard as explained in
table 3-15 at
https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html

Unless you want to do a full Solaris installation but happen to have
access to a bios file, the easiest way to test that the patch works is to:

qemu-system-sparc -k sv -bios /path/to/ss5.bin

If you already happen to have a Solaris installation in a qemu disk image
file you can easily try different keyboard layouts after this patch is
applied.

Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
---
 hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+), 1 deletion(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 17a908c59b..53022ccf39 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -31,6 +31,8 @@
 #include "qemu/module.h"
 #include "hw/char/escc.h"
 #include "ui/console.h"
+#include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
 #include "trace.h"
 
 /*
@@ -190,6 +192,7 @@
 #define R_MISC1I 14
 #define R_EXTINT 15
 
+static unsigned char sun_keyboard_layout_dip_switch(void);
 static void handle_kbd_command(ESCCChannelState *s, int val);
 static int serial_can_receive(void *opaque);
 static void serial_receive_byte(ESCCChannelState *s, int ch);
@@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
     .event = sunkbd_handle_event,
 };
 
+static unsigned char sun_keyboard_layout_dip_switch(void)
+{
+    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
+    static unsigned char ret = 0xff;
+
+    if ((ret == 0xff) && keyboard_layout) {
+        int i;
+        struct layout_values {
+            const char *lang;
+            unsigned char dip;
+        } languages[] =
+    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards */
+            {
+                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
+                                 /* 0x22 is some other US (US_UNIX5.kt)*/
+                {"fr",    0x23}, /* France (France5.kt) */
+                {"da",    0x24}, /* Denmark (Denmark5.kt) */
+                {"de",    0x25}, /* Germany (Germany5.kt) */
+                {"it",    0x26}, /* Italy (Italy5.kt) */
+                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
+                {"no",    0x28}, /* Norway (Norway.kt) */
+                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
+                {"es",    0x2a}, /* Spain (Spain5.kt) */
+                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
+                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
+                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
+                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
+                {"ko",    0x2f}, /* Korea (Korea5.kt) */
+                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
+                {"ja",    0x31}, /* Japan (Japan5.kt) */
+                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
+                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
+                {"pl",    0x34}, /* Poland (Poland5.kt) */
+                {"cz",    0x35}, /* Czech (Czech5.kt) */
+                {"ru",    0x36}, /* Russia (Russia5.kt) */
+                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
+                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
+                {"gr",    0x39}, /* Greece (Greece5.kt) */
+                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
+                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
+                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
+                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
+            };
+
+        for (i = 0;
+             i < sizeof(languages) / sizeof(struct layout_values);
+             i++) {
+            if (!strcmp(keyboard_layout, languages[i].lang)) {
+                ret = languages[i].dip;
+                return ret;
+            }
+        }
+        /* Found no known language code */
+
+        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
+            unsigned int tmp;
+            /* As a fallback we also accept numeric dip switch value */
+            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
+                ret = (unsigned char)tmp;
+            }
+        }
+    }
+    if (ret == 0xff) {
+        /* Final fallback if keyboard_layout was not set or recognized */
+        ret = 0x21; /* en-us layout */
+    }
+    return ret;
+}
+
 static void handle_kbd_command(ESCCChannelState *s, int val)
 {
     trace_escc_kbd_command(val);
@@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int val)
     case 0xf:
         clear_queue(s);
         put_queue(s, 0xfe);
-        put_queue(s, 0x21); /*  en-us layout */
+        put_queue(s, sun_keyboard_layout_dip_switch());
         break;
     default:
         break;
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-14 14:38 ` [PATCH v5] " Henrik Carlqvist
@ 2023-01-22 18:07   ` Mark Cave-Ayland
  2023-01-28 13:08     ` Henrik Carlqvist
  2023-02-12 11:31   ` Ping " Henrik Carlqvist
  2023-03-28 13:47   ` Daniel P. Berrangé
  2 siblings, 1 reply; 13+ messages in thread
From: Mark Cave-Ayland @ 2023-01-22 18:07 UTC (permalink / raw)
  To: Henrik Carlqvist, Henrik Carlqvist
  Cc: qemu-devel, pbonzini, atar4qemu, marcandre.lureau

On 14/01/2023 14:38, Henrik Carlqvist wrote:

> https://patchew.org/QEMU/20230114125029.7395a547.hc981@poolhem.se/
> complains that "patch is empty", so here is my fifth attempt...
> 
> regards Henrik
> 
> SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
> layout of the keyboard. Solaris makes an ioctl to query the value of the
> dipswitches and uses that value to select keyboard layout. Also the SUN
> bios like the one in the file ss5.bin uses this value to support at least
> some keyboard layouts. However, the OpenBIOS provided with qemu is
> hardcoded to always use an US keyboard layout.
> 
> Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
> this patch uses the command line switch "-k" (keyboard layout) to select
> dip switch value. A table is used to lookup values from arguments like:
> 
> -k fr
> -k es
> 
> But the patch also accepts numeric dip switch values directly to the -k
> switch:
> 
> -k 0x2b
> -k 43
> 
> Both values above are the same and select swedish keyboard as explained in
> table 3-15 at
> https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
> 
> Unless you want to do a full Solaris installation but happen to have
> access to a bios file, the easiest way to test that the patch works is to:
> 
> qemu-system-sparc -k sv -bios /path/to/ss5.bin
> 
> If you already happen to have a Solaris installation in a qemu disk image
> file you can easily try different keyboard layouts after this patch is
> applied.
> 
> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
> ---
>   hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 73 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 17a908c59b..53022ccf39 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -31,6 +31,8 @@
>   #include "qemu/module.h"
>   #include "hw/char/escc.h"
>   #include "ui/console.h"
> +#include "sysemu/sysemu.h"
> +#include "qemu/cutils.h"
>   #include "trace.h"
>   
>   /*
> @@ -190,6 +192,7 @@
>   #define R_MISC1I 14
>   #define R_EXTINT 15
>   
> +static unsigned char sun_keyboard_layout_dip_switch(void);
>   static void handle_kbd_command(ESCCChannelState *s, int val);
>   static int serial_can_receive(void *opaque);
>   static void serial_receive_byte(ESCCChannelState *s, int ch);
> @@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
>       .event = sunkbd_handle_event,
>   };
>   
> +static unsigned char sun_keyboard_layout_dip_switch(void)
> +{
> +    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
> +    static unsigned char ret = 0xff;
> +
> +    if ((ret == 0xff) && keyboard_layout) {
> +        int i;
> +        struct layout_values {
> +            const char *lang;
> +            unsigned char dip;
> +        } languages[] =
> +    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards */
> +            {
> +                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
> +                                 /* 0x22 is some other US (US_UNIX5.kt)*/
> +                {"fr",    0x23}, /* France (France5.kt) */
> +                {"da",    0x24}, /* Denmark (Denmark5.kt) */
> +                {"de",    0x25}, /* Germany (Germany5.kt) */
> +                {"it",    0x26}, /* Italy (Italy5.kt) */
> +                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
> +                {"no",    0x28}, /* Norway (Norway.kt) */
> +                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
> +                {"es",    0x2a}, /* Spain (Spain5.kt) */
> +                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
> +                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
> +                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
> +                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
> +                {"ko",    0x2f}, /* Korea (Korea5.kt) */
> +                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
> +                {"ja",    0x31}, /* Japan (Japan5.kt) */
> +                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
> +                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
> +                {"pl",    0x34}, /* Poland (Poland5.kt) */
> +                {"cz",    0x35}, /* Czech (Czech5.kt) */
> +                {"ru",    0x36}, /* Russia (Russia5.kt) */
> +                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
> +                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
> +                {"gr",    0x39}, /* Greece (Greece5.kt) */
> +                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
> +                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
> +                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
> +                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
> +            };
> +
> +        for (i = 0;
> +             i < sizeof(languages) / sizeof(struct layout_values);
> +             i++) {
> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
> +                ret = languages[i].dip;
> +                return ret;
> +            }
> +        }
> +        /* Found no known language code */
> +
> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
> +            unsigned int tmp;
> +            /* As a fallback we also accept numeric dip switch value */
> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
> +                ret = (unsigned char)tmp;
> +            }
> +        }
> +    }
> +    if (ret == 0xff) {
> +        /* Final fallback if keyboard_layout was not set or recognized */
> +        ret = 0x21; /* en-us layout */
> +    }
> +    return ret;
> +}
> +
>   static void handle_kbd_command(ESCCChannelState *s, int val)
>   {
>       trace_escc_kbd_command(val);
> @@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int val)
>       case 0xf:
>           clear_queue(s);
>           put_queue(s, 0xfe);
> -        put_queue(s, 0x21); /*  en-us layout */
> +        put_queue(s, sun_keyboard_layout_dip_switch());
>           break;
>       default:
>           break;

Did you see my comments re: OpenBIOS for the earlier version of this patch?


ATB,

Mark.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-22 18:07   ` Mark Cave-Ayland
@ 2023-01-28 13:08     ` Henrik Carlqvist
  0 siblings, 0 replies; 13+ messages in thread
From: Henrik Carlqvist @ 2023-01-28 13:08 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: hc981, qemu-devel, pbonzini, atar4qemu, marcandre.lureau

On Sun, 22 Jan 2023 18:07:47 +0000
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> Did you see my comments re: OpenBIOS for the earlier version of this patch?

Sorry again for missing that comment, I sent a reply (
https://lists.nongnu.org/archive/html/qemu-devel/2023-01/msg05134.html )

I have now unsubscribed from the mailing list and hope that I will get copies
of any replies which then will be easier for me to note with a more reasonable
flow of emails through my inbox.

Having read about the CI gitlab issue I understand that my patch might not be
considered for integration until februari, but I am in no hurry, my first
attempt to submit this patch was in 2020 (
https://lists.nongnu.org/archive/html/qemu-devel/2020-07/msg03826.html ), that
attempt resulted in a broken patch as my mail client wrapped long lines.

Best regards Henrik


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Ping [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-14 14:38 ` [PATCH v5] " Henrik Carlqvist
  2023-01-22 18:07   ` Mark Cave-Ayland
@ 2023-02-12 11:31   ` Henrik Carlqvist
  2023-03-01 11:52     ` Mark Cave-Ayland
  2023-03-28 13:47   ` Daniel P. Berrangé
  2 siblings, 1 reply; 13+ messages in thread
From: Henrik Carlqvist @ 2023-02-12 11:31 UTC (permalink / raw)
  To: Henrik Carlqvist
  Cc: mark.cave-ayland, qemu-devel, pbonzini, atar4qemu, marcandre.lureau

Would you please consider this patch or let me know if you want me to somehow
update it before it can be accepted?

Best regards Henrik

On Sat, 14 Jan 2023 15:38:53 +0100
Henrik Carlqvist <hc94@poolhem.se> wrote:

> https://patchew.org/QEMU/20230114125029.7395a547.hc981@poolhem.se/ 
> complains that "patch is empty", so here is my fifth attempt...
> 
> regards Henrik
> 
> SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
> layout of the keyboard. Solaris makes an ioctl to query the value of the
> dipswitches and uses that value to select keyboard layout. Also the SUN
> bios like the one in the file ss5.bin uses this value to support at least
> some keyboard layouts. However, the OpenBIOS provided with qemu is
> hardcoded to always use an US keyboard layout.
> 
> Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
> this patch uses the command line switch "-k" (keyboard layout) to select
> dip switch value. A table is used to lookup values from arguments like:
> 
> -k fr
> -k es
> 
> But the patch also accepts numeric dip switch values directly to the -k
> switch:
> 
> -k 0x2b
> -k 43
> 
> Both values above are the same and select swedish keyboard as explained in
> table 3-15 at
> https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
> 
> Unless you want to do a full Solaris installation but happen to have
> access to a bios file, the easiest way to test that the patch works is to:
> 
> qemu-system-sparc -k sv -bios /path/to/ss5.bin
> 
> If you already happen to have a Solaris installation in a qemu disk image
> file you can easily try different keyboard layouts after this patch is
> applied.
> 
> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
> ---
>  hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 73 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 17a908c59b..53022ccf39 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -31,6 +31,8 @@
>  #include "qemu/module.h"
>  #include "hw/char/escc.h"
>  #include "ui/console.h"
> +#include "sysemu/sysemu.h"
> +#include "qemu/cutils.h"
>  #include "trace.h"
>  
>  /*
> @@ -190,6 +192,7 @@
>  #define R_MISC1I 14
>  #define R_EXTINT 15
>  
> +static unsigned char sun_keyboard_layout_dip_switch(void);
>  static void handle_kbd_command(ESCCChannelState *s, int val);
>  static int serial_can_receive(void *opaque);
>  static void serial_receive_byte(ESCCChannelState *s, int ch);
> @@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
>      .event = sunkbd_handle_event,
>  };
>  
> +static unsigned char sun_keyboard_layout_dip_switch(void)
> +{
> +    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
> +    static unsigned char ret = 0xff;
> +
> +    if ((ret == 0xff) && keyboard_layout) {
> +        int i;
> +        struct layout_values {
> +            const char *lang;
> +            unsigned char dip;
> +        } languages[] =
> +    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards
> */+            {
> +                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
> +                                 /* 0x22 is some other US (US_UNIX5.kt)*/
> +                {"fr",    0x23}, /* France (France5.kt) */
> +                {"da",    0x24}, /* Denmark (Denmark5.kt) */
> +                {"de",    0x25}, /* Germany (Germany5.kt) */
> +                {"it",    0x26}, /* Italy (Italy5.kt) */
> +                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
> +                {"no",    0x28}, /* Norway (Norway.kt) */
> +                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
> +                {"es",    0x2a}, /* Spain (Spain5.kt) */
> +                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
> +                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
> +                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
> +                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
> +                {"ko",    0x2f}, /* Korea (Korea5.kt) */
> +                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
> +                {"ja",    0x31}, /* Japan (Japan5.kt) */
> +                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
> +                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
> +                {"pl",    0x34}, /* Poland (Poland5.kt) */
> +                {"cz",    0x35}, /* Czech (Czech5.kt) */
> +                {"ru",    0x36}, /* Russia (Russia5.kt) */
> +                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
> +                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
> +                {"gr",    0x39}, /* Greece (Greece5.kt) */
> +                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
> +                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
> +                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
> +                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
> +            };
> +
> +        for (i = 0;
> +             i < sizeof(languages) / sizeof(struct layout_values);
> +             i++) {
> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
> +                ret = languages[i].dip;
> +                return ret;
> +            }
> +        }
> +        /* Found no known language code */
> +
> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
> +            unsigned int tmp;
> +            /* As a fallback we also accept numeric dip switch value */
> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
> +                ret = (unsigned char)tmp;
> +            }
> +        }
> +    }
> +    if (ret == 0xff) {
> +        /* Final fallback if keyboard_layout was not set or recognized */
> +        ret = 0x21; /* en-us layout */
> +    }
> +    return ret;
> +}
> +
>  static void handle_kbd_command(ESCCChannelState *s, int val)
>  {
>      trace_escc_kbd_command(val);
> @@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int
> val)
>      case 0xf:
>          clear_queue(s);
>          put_queue(s, 0xfe);
> -        put_queue(s, 0x21); /*  en-us layout */
> +        put_queue(s, sun_keyboard_layout_dip_switch());
>          break;
>      default:
>          break;
> -- 
> 2.35.1
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ping [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-02-12 11:31   ` Ping " Henrik Carlqvist
@ 2023-03-01 11:52     ` Mark Cave-Ayland
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Cave-Ayland @ 2023-03-01 11:52 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: qemu-devel, pbonzini, atar4qemu, marcandre.lureau

On 12/02/2023 11:31, Henrik Carlqvist wrote:

> Would you please consider this patch or let me know if you want me to somehow
> update it before it can be accepted?

I've done a quick grep for similar examples for serial devices that use 
keyboard_layout but it looks like this would be the first.

My first instinct is that you'd want to make this a device property that is 
configured during machine init using keyboard_layout (rather than using 
keyboard_layout directly), but I'd be interested to hear what Paolo and Marc-André 
think about what the best approach should be.

Another aspect to consider is whether keyboard_layout should just use standard 
strings, in which case it may not make sense to accept numeric hex values.

Paolo, Marc-André - what do you think?


ATB,

Mark.

> On Sat, 14 Jan 2023 15:38:53 +0100
> Henrik Carlqvist <hc94@poolhem.se> wrote:
> 
>> https://patchew.org/QEMU/20230114125029.7395a547.hc981@poolhem.se/
>> complains that "patch is empty", so here is my fifth attempt...
>>
>> regards Henrik
>>
>> SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
>> layout of the keyboard. Solaris makes an ioctl to query the value of the
>> dipswitches and uses that value to select keyboard layout. Also the SUN
>> bios like the one in the file ss5.bin uses this value to support at least
>> some keyboard layouts. However, the OpenBIOS provided with qemu is
>> hardcoded to always use an US keyboard layout.
>>
>> Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
>> this patch uses the command line switch "-k" (keyboard layout) to select
>> dip switch value. A table is used to lookup values from arguments like:
>>
>> -k fr
>> -k es
>>
>> But the patch also accepts numeric dip switch values directly to the -k
>> switch:
>>
>> -k 0x2b
>> -k 43
>>
>> Both values above are the same and select swedish keyboard as explained in
>> table 3-15 at
>> https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
>>
>> Unless you want to do a full Solaris installation but happen to have
>> access to a bios file, the easiest way to test that the patch works is to:
>>
>> qemu-system-sparc -k sv -bios /path/to/ss5.bin
>>
>> If you already happen to have a Solaris installation in a qemu disk image
>> file you can easily try different keyboard layouts after this patch is
>> applied.
>>
>> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
>> ---
>>   hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 73 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/char/escc.c b/hw/char/escc.c
>> index 17a908c59b..53022ccf39 100644
>> --- a/hw/char/escc.c
>> +++ b/hw/char/escc.c
>> @@ -31,6 +31,8 @@
>>   #include "qemu/module.h"
>>   #include "hw/char/escc.h"
>>   #include "ui/console.h"
>> +#include "sysemu/sysemu.h"
>> +#include "qemu/cutils.h"
>>   #include "trace.h"
>>   
>>   /*
>> @@ -190,6 +192,7 @@
>>   #define R_MISC1I 14
>>   #define R_EXTINT 15
>>   
>> +static unsigned char sun_keyboard_layout_dip_switch(void);
>>   static void handle_kbd_command(ESCCChannelState *s, int val);
>>   static int serial_can_receive(void *opaque);
>>   static void serial_receive_byte(ESCCChannelState *s, int ch);
>> @@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
>>       .event = sunkbd_handle_event,
>>   };
>>   
>> +static unsigned char sun_keyboard_layout_dip_switch(void)
>> +{
>> +    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
>> +    static unsigned char ret = 0xff;
>> +
>> +    if ((ret == 0xff) && keyboard_layout) {
>> +        int i;
>> +        struct layout_values {
>> +            const char *lang;
>> +            unsigned char dip;
>> +        } languages[] =
>> +    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards
>> */+            {
>> +                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
>> +                                 /* 0x22 is some other US (US_UNIX5.kt)*/
>> +                {"fr",    0x23}, /* France (France5.kt) */
>> +                {"da",    0x24}, /* Denmark (Denmark5.kt) */
>> +                {"de",    0x25}, /* Germany (Germany5.kt) */
>> +                {"it",    0x26}, /* Italy (Italy5.kt) */
>> +                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
>> +                {"no",    0x28}, /* Norway (Norway.kt) */
>> +                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
>> +                {"es",    0x2a}, /* Spain (Spain5.kt) */
>> +                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
>> +                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
>> +                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
>> +                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
>> +                {"ko",    0x2f}, /* Korea (Korea5.kt) */
>> +                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
>> +                {"ja",    0x31}, /* Japan (Japan5.kt) */
>> +                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
>> +                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
>> +                {"pl",    0x34}, /* Poland (Poland5.kt) */
>> +                {"cz",    0x35}, /* Czech (Czech5.kt) */
>> +                {"ru",    0x36}, /* Russia (Russia5.kt) */
>> +                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
>> +                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
>> +                {"gr",    0x39}, /* Greece (Greece5.kt) */
>> +                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
>> +                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
>> +                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
>> +                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
>> +            };
>> +
>> +        for (i = 0;
>> +             i < sizeof(languages) / sizeof(struct layout_values);
>> +             i++) {
>> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
>> +                ret = languages[i].dip;
>> +                return ret;
>> +            }
>> +        }
>> +        /* Found no known language code */
>> +
>> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
>> +            unsigned int tmp;
>> +            /* As a fallback we also accept numeric dip switch value */
>> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
>> +                ret = (unsigned char)tmp;
>> +            }
>> +        }
>> +    }
>> +    if (ret == 0xff) {
>> +        /* Final fallback if keyboard_layout was not set or recognized */
>> +        ret = 0x21; /* en-us layout */
>> +    }
>> +    return ret;
>> +}
>> +
>>   static void handle_kbd_command(ESCCChannelState *s, int val)
>>   {
>>       trace_escc_kbd_command(val);
>> @@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int
>> val)
>>       case 0xf:
>>           clear_queue(s);
>>           put_queue(s, 0xfe);
>> -        put_queue(s, 0x21); /*  en-us layout */
>> +        put_queue(s, sun_keyboard_layout_dip_switch());
>>           break;
>>       default:
>>           break;
>> -- 
>> 2.35.1
>>
> 



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-14 14:38 ` [PATCH v5] " Henrik Carlqvist
  2023-01-22 18:07   ` Mark Cave-Ayland
  2023-02-12 11:31   ` Ping " Henrik Carlqvist
@ 2023-03-28 13:47   ` Daniel P. Berrangé
  2 siblings, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2023-03-28 13:47 UTC (permalink / raw)
  To: Henrik Carlqvist
  Cc: Henrik Carlqvist, qemu-devel, pbonzini, atar4qemu, marcandre.lureau

On Sat, Jan 14, 2023 at 03:38:53PM +0100, Henrik Carlqvist wrote:
> https://patchew.org/QEMU/20230114125029.7395a547.hc981@poolhem.se/ 
> complains that "patch is empty", so here is my fifth attempt...
> 
> regards Henrik
> 
> SUN Type 4, 5 and 5c keyboards have dip switches to choose the language
> layout of the keyboard. Solaris makes an ioctl to query the value of the
> dipswitches and uses that value to select keyboard layout. Also the SUN
> bios like the one in the file ss5.bin uses this value to support at least
> some keyboard layouts. However, the OpenBIOS provided with qemu is
> hardcoded to always use an US keyboard layout.
> 
> Before this patch, qemu allways gave dip switch value 0x21 (US keyboard),
> this patch uses the command line switch "-k" (keyboard layout) to select
> dip switch value. A table is used to lookup values from arguments like:
> 
> -k fr
> -k es
> 
> But the patch also accepts numeric dip switch values directly to the -k
> switch:
> 
> -k 0x2b
> -k 43

I'm not convinced this is a sensible thing to do

The '-k' argument / keyboard_layout  global in QEMU is used to control
the keyboard layout used by the various UI frontends in QEMU, when they
are converting input events received from the user into QMEU's internal
keycodes.

Overload this to also change the virtual hardware settings, which is
guest ABI sensitive feels like a bad idea, given that we usually aim to
separate backend and frontend configuration tunables.

IOW, it looks like there are two distinct configuration axes that need
to be controllable independently.

Since it is a hardware property then the obvious place to put this would
be as a property in the hardware device - ie the escc device. This could
then be set with -global escc.sunkbd_layout=XXX  IIUC.


> 
> Both values above are the same and select swedish keyboard as explained in
> table 3-15 at
> https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
> 
> Unless you want to do a full Solaris installation but happen to have
> access to a bios file, the easiest way to test that the patch works is to:
> 
> qemu-system-sparc -k sv -bios /path/to/ss5.bin
> 
> If you already happen to have a Solaris installation in a qemu disk image
> file you can easily try different keyboard layouts after this patch is
> applied.
> 
> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
> ---
>  hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 73 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 17a908c59b..53022ccf39 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -31,6 +31,8 @@
>  #include "qemu/module.h"
>  #include "hw/char/escc.h"
>  #include "ui/console.h"
> +#include "sysemu/sysemu.h"
> +#include "qemu/cutils.h"
>  #include "trace.h"
>  
>  /*
> @@ -190,6 +192,7 @@
>  #define R_MISC1I 14
>  #define R_EXTINT 15
>  
> +static unsigned char sun_keyboard_layout_dip_switch(void);
>  static void handle_kbd_command(ESCCChannelState *s, int val);
>  static int serial_can_receive(void *opaque);
>  static void serial_receive_byte(ESCCChannelState *s, int ch);
> @@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler = {
>      .event = sunkbd_handle_event,
>  };
>  
> +static unsigned char sun_keyboard_layout_dip_switch(void)
> +{
> +    /* Return the value of the dip-switches in a SUN Type 5 keyboard */
> +    static unsigned char ret = 0xff;
> +
> +    if ((ret == 0xff) && keyboard_layout) {
> +        int i;
> +        struct layout_values {
> +            const char *lang;
> +            unsigned char dip;
> +        } languages[] =
> +    /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards */
> +            {
> +                {"en-us", 0x21}, /* U.S.A. (US5.kt) */
> +                                 /* 0x22 is some other US (US_UNIX5.kt)*/
> +                {"fr",    0x23}, /* France (France5.kt) */
> +                {"da",    0x24}, /* Denmark (Denmark5.kt) */
> +                {"de",    0x25}, /* Germany (Germany5.kt) */
> +                {"it",    0x26}, /* Italy (Italy5.kt) */
> +                {"nl",    0x27}, /* The Netherlands (Netherland5.kt) */
> +                {"no",    0x28}, /* Norway (Norway.kt) */
> +                {"pt",    0x29}, /* Portugal (Portugal5.kt) */
> +                {"es",    0x2a}, /* Spain (Spain5.kt) */
> +                {"sv",    0x2b}, /* Sweden (Sweden5.kt) */
> +                {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */
> +                {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */
> +                {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */
> +                {"ko",    0x2f}, /* Korea (Korea5.kt) */
> +                {"tw",    0x30}, /* Taiwan (Taiwan5.kt) */
> +                {"ja",    0x31}, /* Japan (Japan5.kt) */
> +                {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */
> +                {"hu",    0x33}, /* Hungary (Hungary5.kt) */
> +                {"pl",    0x34}, /* Poland (Poland5.kt) */
> +                {"cz",    0x35}, /* Czech (Czech5.kt) */
> +                {"ru",    0x36}, /* Russia (Russia5.kt) */
> +                {"lv",    0x37}, /* Latvia (Latvia5.kt) */
> +                {"tr",    0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */
> +                {"gr",    0x39}, /* Greece (Greece5.kt) */
> +                {"ar",    0x3a}, /* Arabic (Arabic5.kt) */
> +                {"lt",    0x3b}, /* Lithuania (Lithuania5.kt) */
> +                {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */
> +                {"be",    0x3c}, /* Belgium (Belgian5.kt) */
> +            };
> +
> +        for (i = 0;
> +             i < sizeof(languages) / sizeof(struct layout_values);
> +             i++) {
> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
> +                ret = languages[i].dip;
> +                return ret;
> +            }
> +        }
> +        /* Found no known language code */
> +
> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
> +            unsigned int tmp;
> +            /* As a fallback we also accept numeric dip switch value */
> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
> +                ret = (unsigned char)tmp;
> +            }
> +        }
> +    }
> +    if (ret == 0xff) {
> +        /* Final fallback if keyboard_layout was not set or recognized */
> +        ret = 0x21; /* en-us layout */
> +    }
> +    return ret;
> +}
> +
>  static void handle_kbd_command(ESCCChannelState *s, int val)
>  {
>      trace_escc_kbd_command(val);
> @@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int val)
>      case 0xf:
>          clear_queue(s);
>          put_queue(s, 0xfe);
> -        put_queue(s, 0x21); /*  en-us layout */
> +        put_queue(s, sun_keyboard_layout_dip_switch());
>          break;
>      default:
>          break;
> -- 
> 2.35.1
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-03-28 17:59           ` Daniel P. Berrangé
@ 2023-03-28 20:16             ` Henrik Carlqvist
  0 siblings, 0 replies; 13+ messages in thread
From: Henrik Carlqvist @ 2023-03-28 20:16 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: mark.cave-ayland, hc1245, qemu-devel

On Tue, 28 Mar 2023 18:59:26 +0100
Daniel P. Berrangé <berrange@redhat.com> wrote:
> I'm generally not in favour of creating many different ways to set
> the same thing, especially not multiple string based names, but if
> a single vocabulary for strings is insufficient, then having support
> for numbers feels reasonable.

If only a single way to set them would be allowed, I think that the
hexadecimal number would make most sense as we are emulating dip-switches.
However, it would be nice to also allow more easy to remember strings where
applicable.

> If you care about documentation then I think there ought to be docs
> added in QEMU for it, as out of the 33 currrent keymap names supported
> by QEMU, only 28 seem to be supported by this device.

Maybe it could be documented by printing some text if given

-global escc.sunkbd_layout=help

or

-global escc.sunkbd_layout=list

Best regards Henrik


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-03-28 17:19         ` Henrik Carlqvist
@ 2023-03-28 17:59           ` Daniel P. Berrangé
  2023-03-28 20:16             ` Henrik Carlqvist
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel P. Berrangé @ 2023-03-28 17:59 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel

On Tue, Mar 28, 2023 at 07:19:58PM +0200, Henrik Carlqvist wrote:
> Thanks for your feedback!
> 
> On Tue, 28 Mar 2023 15:01:55 +0100
> Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> > This is another reason why use of the '-k' switch is a bad idea. Its
> > range of permissible values / vocabulary does not match the range of
> > values / vocabulary needed for this hardware device.
> > 
> > In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
> > the keyboard layouts have distinct names
> > 
> > "Norway4" vs "Norway5" and "US4" vs  "US5" vs "US_UNIX5"
> 
> Those distinct names are names of files in the OS filesystem. This is a link
> to a description of a patch which gives those keyboard layouts support for
> the euro sign:
> 
> http://download.nust.na/pub3/solaris/patches/106839.readme
> 
> > I'd suggest a property to the escc device should take the names
> > given by that reference page above. eg
> > 
> >   -global escc.sunkbd_layout=Norway4
> 
> Would you mind if such an assignment could also be given in multiple ways,
> that is:
> 
> -global escc.sunkbd_layout=33
> -global escc.sunkbd_layout=0x21
> -global escc.sunkbd_layout=US5
> -global escc.sunkbd_layout=en_us
> 
> would all result in the same dip switch setting 0x21?

I'm generally not in favour of creating many different ways to set
the same thing, especially not multiple string based names, but if
a single vocabulary for strings is insufficient, then having support
for numbers feels reasonable.

> The nice thing with being able to assign keyboard layouts with a string like
> "en_us" is that it does not require the user to read reference documentation
> from Oracle to see which odd named layouts to choose from.
> 
> The nice thing to also being able to give numerical values like 33 or 0x21 is
> that some possible dip switch settings (like 0x20) are not mentioned in the
> Oracle reference documentation, but of course they would be possible to set
> with physical dip switches even though they might not be supported by the OS.

If you care about documentation then I think there ought to be docs
added in QEMU for it, as out of the 33 currrent keymap names supported
by QEMU, only 28 seem to be supported by this device.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-03-28 14:01       ` Daniel P. Berrangé
@ 2023-03-28 17:19         ` Henrik Carlqvist
  2023-03-28 17:59           ` Daniel P. Berrangé
  0 siblings, 1 reply; 13+ messages in thread
From: Henrik Carlqvist @ 2023-03-28 17:19 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: mark.cave-ayland, hc1245, qemu-devel

Thanks for your feedback!

On Tue, 28 Mar 2023 15:01:55 +0100
Daniel P. Berrangé <berrange@redhat.com> wrote:

> This is another reason why use of the '-k' switch is a bad idea. Its
> range of permissible values / vocabulary does not match the range of
> values / vocabulary needed for this hardware device.
> 
> In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
> the keyboard layouts have distinct names
> 
> "Norway4" vs "Norway5" and "US4" vs  "US5" vs "US_UNIX5"

Those distinct names are names of files in the OS filesystem. This is a link
to a description of a patch which gives those keyboard layouts support for
the euro sign:

http://download.nust.na/pub3/solaris/patches/106839.readme

> I'd suggest a property to the escc device should take the names
> given by that reference page above. eg
> 
>   -global escc.sunkbd_layout=Norway4

Would you mind if such an assignment could also be given in multiple ways,
that is:

-global escc.sunkbd_layout=33
-global escc.sunkbd_layout=0x21
-global escc.sunkbd_layout=US5
-global escc.sunkbd_layout=en_us

would all result in the same dip switch setting 0x21? 

The nice thing with being able to assign keyboard layouts with a string like
"en_us" is that it does not require the user to read reference documentation
from Oracle to see which odd named layouts to choose from.

The nice thing to also being able to give numerical values like 33 or 0x21 is
that some possible dip switch settings (like 0x20) are not mentioned in the
Oracle reference documentation, but of course they would be possible to set
with physical dip switches even though they might not be supported by the OS.

> the only ambguity I see is that 0x0 and 0x1 both have the same
> name (US4), which could be resolved by handling 0x0 as the default
> with an empty string perhaps.

With multiple ways to give the values as I suggest it would be possible to
give 0x0 and 0x1 as values but "US4" would allways result in one of them,
probably 0x0. 

The default value when no value is given or when some invalid value is given
to escc.sunkbd_layout would preferably be 0x21 for backwards compability as
that is the only value you can get from the dip switch in qemu today.

Once we find a method we all agree on I am willing to rewrite my patch, but
maybe I will not be able to do it before summer when I get my vacation.

best regards Henrik


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-03-04 21:07     ` Henrik Carlqvist
@ 2023-03-28 14:01       ` Daniel P. Berrangé
  2023-03-28 17:19         ` Henrik Carlqvist
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel P. Berrangé @ 2023-03-28 14:01 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel

On Sat, Mar 04, 2023 at 10:07:54PM +0100, Henrik Carlqvist wrote:
> On Wed, 1 Mar 2023 11:52:42 +0000
> Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> > Another aspect to consider is whether keyboard_layout should just use
> > standard strings, in which case it may not make sense to accept numeric hex
> > values. 
> 
> I agree that those standard strings will make most sense to most people.
> 
> However, as the choices of valid keyboard layouts are limited by the 64 values
> allowed by the 6 bits on the dip switch I initially did choose to also truly
> emulate the dip switch value as decimal or hexadecimal number to the -k
> option. It might also be worth noting that the sun keyboard layouts have
> multiple dip switch settings for a single language, probably with some minor
> differences in keyboard layout or keyboard type. So both value 8 and 40 (0x28)
> will give some norwegian keyboard layout. if someone, for some reason, would
> want to emulate for example one of the four possible US keyboard layouts (0x0,
> 0x1, 0x21 or 0x22) it would be harder to do without being able to give those
> numerical values to the -k switch.

This is another reason why use of the '-k' switch is a bad idea. Its
range of permissible values / vocabulary does not match the range of
values / vocabulary needed for this hardware device.

In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html
the keyboard layouts have distinct names

"Norway4" vs "Norway5" and "US4" vs  "US5" vs "US_UNIX5"

I'd suggest a property to the escc device should take the names
given by that reference page above. eg

  -global escc.sunkbd_layout=Norway4

the only ambguity I see is that 0x0 and 0x1 both have the same
name (US4), which could be resolved by handling 0x0 as the default
with an empty string perhaps.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-23 19:09   ` [PATCH v5] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
@ 2023-03-04 21:07     ` Henrik Carlqvist
  2023-03-28 14:01       ` Daniel P. Berrangé
  0 siblings, 1 reply; 13+ messages in thread
From: Henrik Carlqvist @ 2023-03-04 21:07 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel

On Wed, 1 Mar 2023 11:52:42 +0000
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> I've done a quick grep for similar examples for serial devices that use
> keyboard_layout but it looks like this would be the first. 

Thanks again for your reply!

It is probably not a very common solution with hardware in the keyboard
telling the computer about its language layout. Maybe it is even less common
with such hardware possible to adjust with a dip switch to choose language
layout. But that was the solution Sun selected for their keybords back in the
days and back then (and even still today) it was common for keyboards to
communicate with the computer by some kind of serial interface.

> My first instinct is that you'd want to make this a device property that is
> configured during machine init using keyboard_layout (rather than using
> keyboard_layout directly),

If it does matter in any way, my patch will only at first call to the
sun_keyboard_layout_dip_switch function look at the keyboard_layout variable.
Once the static "ret" variable has gotten a valid value (the initial value
0xff is not valid for a 6-bit dip swithc) the ret value assigned at the
initial call will be immediately returned without any more evaluations of the
keyboard_layout string.

> but I'd be interested to hear what Paolo and Marc-André think about what the
> best approach should be.

As I found your latest reply only on
https://lists.nongnu.org/archive/html/qemu-devel/2023-03/msg00097.html and
can't see the email addresses of any receiver of that post this reply does not
go to Paolo or Marc-André, only to you and the mailing list.

I must admit that I am not very failiar with qemu programming and device
properties. 

> Another aspect to consider is whether keyboard_layout should just use
> standard strings, in which case it may not make sense to accept numeric hex
> values. 

I agree that those standard strings will make most sense to most people.

However, as the choices of valid keyboard layouts are limited by the 64 values
allowed by the 6 bits on the dip switch I initially did choose to also truly
emulate the dip switch value as decimal or hexadecimal number to the -k
option. It might also be worth noting that the sun keyboard layouts have
multiple dip switch settings for a single language, probably with some minor
differences in keyboard layout or keyboard type. So both value 8 and 40 (0x28)
will give some norwegian keyboard layout. if someone, for some reason, would
want to emulate for example one of the four possible US keyboard layouts (0x0,
0x1, 0x21 or 0x22) it would be harder to do without being able to give those
numerical values to the -k switch.

best regards Henrik


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard
  2023-01-10 23:08 ` Mark Cave-Ayland
@ 2023-01-23 19:09   ` Henrik Carlqvist
  2023-03-04 21:07     ` Henrik Carlqvist
  0 siblings, 1 reply; 13+ messages in thread
From: Henrik Carlqvist @ 2023-01-23 19:09 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: hc1245, qemu-devel, atar4qemu

On Sun, 22 Jan 2023 18:07:47 +0000
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> Did you see my comments re: OpenBIOS for the earlier version of this patch?

Thanks for your replies! Sorry, I missed that reply... To make sure that I
wouldn't miss any reply I subscribed to the mailing list, but that made many
mails to me drown in mails from the list...

On Tue, 10 Jan 2023 23:08:27 +0000
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> Thanks for the patch. I think what you're effectively doing here is
> equivalent to creating a qdev property that is used to set the keyboard
> layout, which is a nicer approach because it enables better control from the
> command line and also handles the default value.

I must admit that I am not very familiar with "qdev properties", to me it
seemed like a rather intuitive solution to use the existing -k switch for this
purpose as it is intended to use for keyboard layouts. Would you prefer some
other implementation?

> Does changing the keyboard layout work with other OSs?

To my knowledge only Solaris and the SUN sparc openboot bios cares about those
dip switch settings in the 32 bit SUN sparc machine keyboards.

This post on a forum makes me think that it doesn't work with NetBSD:
https://www.linuxquestions.org/questions/%2Absd-17/netbsd-sparc-non-us-keyboard-layout-issue-367601/

It does seem as if the Linux kernel supports those layout dip switches,
however I don't know if it is used in any Linux distribution. I have never run
any Linux distribution on sparc myself. From the Linux kernel source file
sunkbd.c:

-8<--------------------
	if (sunkbd->type == 4) {	/* Type 4 keyboard */
		sunkbd->layout = -2;
		serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT);
		wait_event_interruptible_timeout(sunkbd->wait,
						 sunkbd->layout >= 0, HZ / 4);
		if (sunkbd->layout < 0)
			return -1;
		if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK)
			sunkbd->type = 5;
	}
-8<--------------------

> It may also be that OpenBIOS will be difficult to use if the layout
> defaults to anything other than en-us since I suspect it will be hardcoded
> there too.

Today qemu is hardcoded to emulate dip switch setting 0x21 (en-us layout). My
patch keeps 0x21 (en-us layout) as default value, but also makes it possible
to give other values with the -k option. From may experience it seems as if
OpenBIOS does not care about the settings of the dip switch and allways uses
en-us layout. Suns openboot bios (which is possible to find for download and
use with qemu) supports some, but not all layout dip switch settings which are
supported by Solaris.

regards Henrik


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-03-28 20:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14 11:50 [PATCH v4] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
2023-01-14 14:38 ` [PATCH v5] " Henrik Carlqvist
2023-01-22 18:07   ` Mark Cave-Ayland
2023-01-28 13:08     ` Henrik Carlqvist
2023-02-12 11:31   ` Ping " Henrik Carlqvist
2023-03-01 11:52     ` Mark Cave-Ayland
2023-03-28 13:47   ` Daniel P. Berrangé
  -- strict thread matches above, loose matches on Subject: below --
2023-01-06 21:33 [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu ~henca
2023-01-10 23:08 ` Mark Cave-Ayland
2023-01-23 19:09   ` [PATCH v5] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
2023-03-04 21:07     ` Henrik Carlqvist
2023-03-28 14:01       ` Daniel P. Berrangé
2023-03-28 17:19         ` Henrik Carlqvist
2023-03-28 17:59           ` Daniel P. Berrangé
2023-03-28 20:16             ` Henrik Carlqvist

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.