1/*- 2 * Copyright (c) 1996-1999 3 * Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * from kbdio.c,v 1.13 1998/09/25 11:55:46 yokota Exp 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: stable/11/sys/dev/atkbdc/atkbdc.c 343158 2019-01-18 21:12:00Z wulf $"); |
35 36#include "opt_kbd.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/bus.h> 41#include <sys/malloc.h> 42#include <sys/syslog.h> --- 246 unchanged lines hidden (view full) --- 289#endif 290 291 if (sc->ioh0 == 0) { /* XXX */ 292 sc->command_byte = -1; 293 sc->command_mask = 0; 294 sc->lock = FALSE; 295 sc->kbd.head = sc->kbd.tail = 0; 296 sc->aux.head = sc->aux.tail = 0; |
297 sc->aux_mux_enabled = FALSE; |
298#if KBDIO_DEBUG >= 2 299 sc->kbd.call_count = 0; 300 sc->kbd.qcount = sc->kbd.max_qcount = 0; 301 sc->aux.call_count = 0; 302 sc->aux.qcount = sc->aux.max_qcount = 0; 303#endif 304 } 305 sc->iot = tag; --- 327 unchanged lines hidden (view full) --- 633 write_data(kbdcp(p), c); 634 return TRUE; 635} 636 637/* write a one byte auxiliary device command */ 638int 639write_aux_command(KBDC p, int c) 640{ |
641 int f; 642 643 f = aux_mux_is_enabled(p) ? 644 KBDC_WRITE_TO_AUX_MUX + kbdcp(p)->aux_mux_port : KBDC_WRITE_TO_AUX; 645 646 if (!write_controller_command(p, f)) |
647 return FALSE; 648 return write_controller_data(p, c); 649} 650 651/* send a command to the keyboard and wait for ACK */ 652int 653send_kbd_command(KBDC p, int c) 654{ --- 545 unchanged lines hidden (view full) --- 1200 kbdcp(p)->command_byte = command; 1201 1202 if (verbose) 1203 log(LOG_DEBUG, "kbdc: new command byte:%04x (set_controller...)\n", 1204 command); 1205 1206 return TRUE; 1207} |
1208 1209/* 1210 * Rudimentary support for active PS/2 AUX port multiplexing. 1211 * Only write commands can be routed to a selected AUX port. 1212 * Source port of data processed by read commands is totally ignored. 1213 */ 1214static int 1215set_aux_mux_state(KBDC p, int enabled) 1216{ 1217 int command, version; 1218 1219 if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || 1220 write_controller_data(p, 0xF0) == 0 || 1221 read_controller_data(p) != 0xF0) 1222 return (-1); 1223 1224 if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || 1225 write_controller_data(p, 0x56) == 0 || 1226 read_controller_data(p) != 0x56) 1227 return (-1); 1228 1229 command = enabled ? 0xa4 : 0xa5; 1230 if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || 1231 write_controller_data(p, command) == 0 || 1232 (version = read_controller_data(p)) == command) 1233 return (-1); 1234 1235 return (version); 1236} 1237 1238int 1239set_active_aux_mux_port(KBDC p, int port) 1240{ 1241 1242 if (!aux_mux_is_enabled(p)) 1243 return (FALSE); 1244 1245 if (port < 0 || port >= KBDC_AUX_MUX_NUM_PORTS) 1246 return (FALSE); 1247 1248 kbdcp(p)->aux_mux_port = port; 1249 1250 return (TRUE); 1251} 1252 1253/* Checks for active multiplexing support and enables it */ 1254int 1255enable_aux_mux(KBDC p) 1256{ 1257 int version; 1258 1259 version = set_aux_mux_state(p, TRUE); 1260 if (version >= 0) { 1261 kbdcp(p)->aux_mux_enabled = TRUE; 1262 set_active_aux_mux_port(p, 0); 1263 } 1264 1265 return (version); 1266} 1267 1268int 1269disable_aux_mux(KBDC p) 1270{ 1271 1272 kbdcp(p)->aux_mux_enabled = FALSE; 1273 1274 return (set_aux_mux_state(p, FALSE)); 1275} 1276 1277int 1278aux_mux_is_enabled(KBDC p) 1279{ 1280 1281 return (kbdcp(p)->aux_mux_enabled); 1282} |