to also support scan code set #3 in addition to the existing scan code set #2.
This makes the built-in keyboard on the Tadpole UltraBook IIe work.
-/* $OpenBSD: gsckbc.c,v 1.21 2022/03/13 08:04:38 mpi Exp $ */
+/* $OpenBSD: gsckbc.c,v 1.22 2023/07/25 10:00:44 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
}
int
-pckbc_xt_translation(self)
+pckbc_xt_translation(self, table)
pckbc_tag_t self;
+ int *table;
{
/* Translation isn't supported... */
return (-1);
-/* $OpenBSD: pckbc_ebus.c,v 1.16 2022/10/16 01:22:39 jsg Exp $ */
+/* $OpenBSD: pckbc_ebus.c,v 1.17 2023/07/25 10:00:44 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
}
/*
- * The 8042 controller found on the Tadpole SPARCLE doesn't
+ * Tadpole/RDI systems use a 8042 controller which does not
* implement XT scan code translation.
- * XXX I have not checked the value of the model property on
- * XXX UltraAXe boards...
+ * - on the SPARCLE and the Viper, which sport a PC-style
+ * keyboard with no L function keys, the keyboard defaults
+ * to scan code set #2.
+ * - on the UltraBook IIe, which sports a complete Sun-style
+ * keyboard with L function keys and diamond keys,
+ * the keyboard defaults to scan code set #3.
*/
{
- char model[128];
- OF_getprop(ea->ea_node, "model", &model, sizeof model);
- if (strcmp(model, "INTC,80c42") == 0)
- flags = PCKBC_CANT_TRANSLATE | PCKBC_NEED_AUXWRITE;
+ char buf[128];
+ OF_getprop(ea->ea_node, "model", buf, sizeof buf);
+ if (strcmp(buf, "INTC,80c42") == 0) {
+ /*
+ * This is a Tadpole/RDI system. Tell the RDI design
+ * (UltraBook IIe) from the Tadpole design (SPARCLE)
+ * by looking for a tadpmu child node in the latter.
+ */
+ int sparcle = 0;
+ int node;
+ for (node = OF_child(sc->sc_node); node;
+ node = OF_peer(node)) {
+ if (OF_getprop(node, "name", buf,
+ sizeof buf) <= 0)
+ continue;
+ if (strcmp(buf, "tadpmu") == 0) {
+ sparcle = 1;
+ break;
+ }
+ }
+ flags = PCKBC_NEED_AUXWRITE;
+ if (sparcle)
+ flags |= PCKBC_FIXED_SET2;
+ else
+ flags |= PCKBC_FIXED_SET3;
+ }
}
if (console) {
-/* $OpenBSD: pckbc.c,v 1.53 2019/11/30 18:18:34 cheloha Exp $ */
+/* $OpenBSD: pckbc.c,v 1.54 2023/07/25 10:00:44 miod Exp $ */
/* $NetBSD: pckbc.c,v 1.5 2000/06/09 04:58:35 soda Exp $ */
/*
* set scancode translation on
*/
int
-pckbc_xt_translation(pckbc_tag_t self)
+pckbc_xt_translation(pckbc_tag_t self, int *table)
{
struct pckbc_internal *t = self;
- if (ISSET(t->t_flags, PCKBC_CANT_TRANSLATE))
+#ifdef __sparc64__ /* only pckbc@ebus on sparc64 uses this */
+ if ((t->t_flags & PCKBC_CANT_TRANSLATE) != 0) {
+ /* Hardware lacks translation capability. Nothing to do! */
+ if (t->t_flags & PCKBC_FIXED_SET2)
+ *table = 2;
+ else /* PCKBC_FIXED_SET3 */
+ *table = 3;
return (-1);
+ }
+#endif
if (t->t_cmdbyte & KC8_TRANS)
return (0);
-/* $OpenBSD: pckbcvar.h,v 1.16 2017/03/11 11:55:03 mpi Exp $ */
+/* $OpenBSD: pckbcvar.h,v 1.17 2023/07/25 10:00:44 miod Exp $ */
/* $NetBSD: pckbcvar.h,v 1.4 2000/06/09 04:58:35 soda Exp $ */
/*
u_char t_cmdbyte; /* shadow */
int t_flags;
-#define PCKBC_CANT_TRANSLATE 0x0001 /* can't translate to XT scancodes */
-#define PCKBC_NEED_AUXWRITE 0x0002 /* need auxwrite command to find aux */
- int t_haveaux; /* controller has an aux port */
+ /* need auxwrite command to find aux */
+#define PCKBC_NEED_AUXWRITE 0x0001
+ /* can't translate to XT scancodes, stuck to set #2 */
+#define PCKBC_FIXED_SET2 0x0002
+ /* can't translate to XT scancodes, stuck to set #3 */
+#define PCKBC_FIXED_SET3 0x0004
+#define PCKBC_CANT_TRANSLATE (PCKBC_FIXED_SET2 | PCKBC_FIXED_SET3)
+ int t_haveaux; /* controller has an aux port */
struct pckbc_slotdata *t_slotdata[PCKBC_NSLOTS];
int pckbc_poll_data1(bus_space_tag_t, bus_space_handle_t,
bus_space_handle_t, pckbc_slot_t, int);
void pckbc_set_poll(pckbc_tag_t, pckbc_slot_t, int);
-int pckbc_xt_translation(pckbc_tag_t);
+int pckbc_xt_translation(pckbc_tag_t, int *);
void pckbc_slot_enable(pckbc_tag_t, pckbc_slot_t, int);
void pckbc_attach(struct pckbc_softc *, int);
-/* $OpenBSD: pckbd.c,v 1.49 2023/07/24 19:29:39 miod Exp $ */
+/* $OpenBSD: pckbd.c,v 1.50 2023/07/25 10:00:44 miod Exp $ */
/* $NetBSD: pckbd.c,v 1.24 2000/06/05 22:20:57 sommerfeld Exp $ */
/*-
pckbc_tag_t t_kbctag;
pckbc_slot_t t_kbcslot;
- int t_translating;
- int t_table;
+ int t_translating; /* nonzero if hardware performs translation */
+ int t_table; /* scan code set in use */
int t_lastchar;
int t_extended;
pckbd_set_xtscancode(pckbc_tag_t kbctag, pckbc_slot_t kbcslot,
struct pckbd_internal *id)
{
- int table = 3;
+ int table = 0;
- if (pckbc_xt_translation(kbctag)) {
+ if (pckbc_xt_translation(kbctag, &table)) {
#ifdef DEBUG
printf("pckbd: enabling of translation failed\n");
+#endif
+#ifdef __sparc64__ /* only pckbc@ebus on sparc64 uses this */
+ /*
+ * If hardware lacks translation capability, stick to the
+ * table it is using.
+ */
+ if (table != 0) {
+ id->t_translating = 0;
+ id->t_table = table;
+ return 0;
+ }
#endif
/*
* Since the keyboard controller can not translate scan
if (id != NULL)
id->t_translating = 0;
} else {
+ table = 3;
if (id != NULL) {
id->t_translating = 1;
if (id->t_table == 0) {
return (0);
}
-const u_int8_t pckbd_xtbl[] = {
+/*
+ * Scan code set #2 translation tables
+ */
+
+const u_int8_t pckbd_xtbl2[] = {
/* 0x00 */
0,
RAWKEY_f9,
0 /* Alt-Print Screen */
};
-const u_int8_t pckbd_xtbl_ext[] = {
+const u_int8_t pckbd_xtbl2_ext[] = {
/* 0x00 */
0,
0,
0
};
+#ifdef __sparc64__ /* only pckbc@ebus on sparc64 uses this */
+
+/*
+ * Scan code set #3 translation table
+ */
+
+const u_int8_t pckbd_xtbl3[] = {
+/* 0x00 */
+ 0,
+ RAWKEY_L5, /* Front */
+ RAWKEY_L1, /* Stop */
+ RAWKEY_L3, /* Props */
+ 0,
+ RAWKEY_L7, /* Open */
+ RAWKEY_L9, /* Find */
+ RAWKEY_f1,
+ RAWKEY_Escape,
+ RAWKEY_L10, /* Cut */
+ 0,
+ 0,
+ 0,
+ RAWKEY_Tab,
+ RAWKEY_grave,
+ RAWKEY_f2,
+/* 0x10 */
+ RAWKEY_Help,
+ RAWKEY_Control_L,
+ RAWKEY_Shift_L,
+ 0,
+ RAWKEY_Caps_Lock,
+ RAWKEY_q,
+ RAWKEY_1,
+ RAWKEY_f3,
+ 0,
+ RAWKEY_Alt_L,
+ RAWKEY_z,
+ RAWKEY_s,
+ RAWKEY_a,
+ RAWKEY_w,
+ RAWKEY_2,
+ RAWKEY_f4,
+/* 0x20 */
+ 0,
+ RAWKEY_c,
+ RAWKEY_x,
+ RAWKEY_d,
+ RAWKEY_e,
+ RAWKEY_4,
+ RAWKEY_3,
+ RAWKEY_f5,
+ RAWKEY_L4, /* Undo */
+ RAWKEY_space,
+ RAWKEY_v,
+ RAWKEY_f,
+ RAWKEY_t,
+ RAWKEY_r,
+ RAWKEY_5,
+ RAWKEY_f6,
+/* 0x30 */
+ RAWKEY_L2, /* Again */
+ RAWKEY_n,
+ RAWKEY_b,
+ RAWKEY_h,
+ RAWKEY_g,
+ RAWKEY_y,
+ RAWKEY_6,
+ RAWKEY_f7,
+ 0,
+ RAWKEY_Alt_R,
+ RAWKEY_m,
+ RAWKEY_j,
+ RAWKEY_u,
+ RAWKEY_7,
+ RAWKEY_8,
+ RAWKEY_f8,
+/* 0x40 */
+ 0,
+ RAWKEY_comma,
+ RAWKEY_k,
+ RAWKEY_i,
+ RAWKEY_o,
+ RAWKEY_0,
+ RAWKEY_9,
+ RAWKEY_f9,
+ RAWKEY_L6, /* Copy */
+ RAWKEY_period,
+ RAWKEY_slash,
+ RAWKEY_l,
+ RAWKEY_semicolon,
+ RAWKEY_p,
+ RAWKEY_minus,
+ RAWKEY_f10,
+/* 0x50 */
+ 0,
+ 0,
+ RAWKEY_apostrophe,
+ 0,
+ RAWKEY_bracketleft,
+ RAWKEY_equal,
+ RAWKEY_f11,
+ RAWKEY_Print_Screen,
+ RAWKEY_Control_R,
+ RAWKEY_Shift_R,
+ RAWKEY_Return,
+ RAWKEY_bracketright,
+ RAWKEY_backslash,
+ 0,
+ RAWKEY_f12,
+ RAWKEY_Hold_Screen,
+/* 0x60 */
+ RAWKEY_Down,
+ RAWKEY_Left,
+ RAWKEY_Pause,
+ RAWKEY_Up,
+ RAWKEY_Delete,
+ RAWKEY_End,
+ RAWKEY_BackSpace,
+ RAWKEY_Insert,
+ RAWKEY_L8, /* Paste */
+ RAWKEY_KP_End,
+ RAWKEY_Right,
+ RAWKEY_KP_Left,
+ RAWKEY_KP_Home,
+ RAWKEY_Next,
+ RAWKEY_Home,
+ RAWKEY_Prior,
+/* 0x70 */
+ RAWKEY_KP_Insert,
+ RAWKEY_KP_Delete,
+ RAWKEY_KP_Down,
+ RAWKEY_KP_Begin,
+ RAWKEY_KP_Right,
+ RAWKEY_KP_Up,
+ RAWKEY_Num_Lock,
+ RAWKEY_KP_Divide,
+ 0,
+ RAWKEY_KP_Enter,
+ RAWKEY_KP_Next,
+ 0,
+ RAWKEY_KP_Add,
+ RAWKEY_KP_Prior,
+ RAWKEY_KP_Multiply,
+ 0,
+/* 0x80 */
+ 0,
+ 0,
+ 0,
+ 0,
+ RAWKEY_KP_Subtract,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ RAWKEY_Meta_L,
+ RAWKEY_Meta_R
+};
+
+#endif
+
/*
- * Translate scan codes from set 2 to set 1
+ * Translate scan codes from set 2 or 3 to set 1
*/
int
pckbd_scancode_translate(struct pckbd_internal *id, int datain)
return 0; /* consume scancode */
}
- /*
- * Convert BREAK sequence (14 77 -> 1D 45)
- */
- if (id->t_extended1 == 2 && datain == 0x14)
- return 0x1d | id->t_releasing;
- else if (id->t_extended1 == 1 && datain == 0x77)
- return 0x45 | id->t_releasing;
-
- if (id->t_extended != 0) {
- if (datain >= sizeof pckbd_xtbl_ext)
- datain = 0;
- else
- datain = pckbd_xtbl_ext[datain] & ~0x80;
- } else {
- if (datain >= sizeof pckbd_xtbl)
+ switch (id->t_table) {
+ case 2:
+ /*
+ * Convert BREAK sequence (14 77 -> 1D 45)
+ */
+ if (id->t_extended1 == 2 && datain == 0x14)
+ return 0x1d | id->t_releasing;
+ else if (id->t_extended1 == 1 && datain == 0x77)
+ return 0x45 | id->t_releasing;
+
+ if (id->t_extended != 0) {
+ if (datain >= sizeof pckbd_xtbl2_ext)
+ datain = 0;
+ else
+ datain = pckbd_xtbl2_ext[datain];
+ /* xtbl2_ext already has the upper bit set */
+ id->t_extended = 0;
+ } else {
+ if (datain >= sizeof pckbd_xtbl2)
+ datain = 0;
+ else
+ datain = pckbd_xtbl2[datain] & ~0x80;
+ }
+ break;
+#ifdef __sparc64__ /* only pckbc@ebus on sparc64 uses this */
+ case 3:
+ if (datain >= sizeof pckbd_xtbl3)
datain = 0;
else
- datain = pckbd_xtbl[datain] & ~0x80;
+ datain = pckbd_xtbl3[datain] & ~0x80;
+ break;
+#endif
}
if (datain == 0) {
int
pckbd_cnattach(pckbc_tag_t kbctag)
{
-
pckbd_init(&pckbd_consdata, kbctag, PCKBC_KBD_SLOT, 1);
-
wskbd_cnattach(&pckbd_consops, &pckbd_consdata, &pckbd_keymapdata);
-
return (0);
}