Commit Graph

35 Commits

Author SHA1 Message Date
Stefan Eßer
f20058955c sys/kbio.h: make pre-unicode keymap support optional
FreeBSD-9 had introduced support for the full set of Unicode
characters to the parsing and processing of keymap character tables.

This support has been extended to cover the table for accented
characters that are reached via dead key combinations in FreeBSD-13.2.

New ioctls have been introduced to support both the pre-Unicode and
the Unicode formats and keyboard drivers have been extended to support
those ioctls.

This commit makes the ABI compatibility functions in the kernel
optional and dependent on COMPAT_FREEBSD13 in -CURRENT.

The kbdcontrol command in -CURRENT and 13-STABLE (before 13.2) has
been made ABI compatible with old kernels to allow a new world to be
run on an old kernel (that does not have full Unicode support for
keymaps).

This commit is not to merged back to 12-STABLE or 13-STABLE. It is
part of review D38465, which has been split into 3 separate commits
due to different MFC and life-time requirements of either commit.

Approved by:	imp
Differential Revision:	https://reviews.freebsd.org/D38465
2023-02-14 14:03:28 +01:00
Stefan Eßer
4972fb9276 Support Unicode characters in keymap dead key tables
Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by:	imp, brooks
Approved by:	brooks
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38381
2023-02-06 23:48:47 +01:00
John Baldwin
c46fd01853 adb: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin
42f777fc20 Remove unused adb_devclass. 2022-05-10 10:21:38 -07:00
Mateusz Guzik
06261cf209 adb: clean up empty lines in .c and .h files 2020-09-01 21:34:24 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Kyle Evans
2899979df9 Revert r355806: kbd drivers: don't double register keyboard drivers
r356087 made it rather innocuous to double-register built-in keyboard
drivers; we now set a flag to indicate that it's been registered and only
act once on a registration anyways. There is no misleading here, as the
follow-up kbd_delete_driver will actually remove the driver as needed now
that the linker set isn't also consulted after kbdinit.
2019-12-26 17:09:36 +00:00
Kyle Evans
5a7a578be9 kbd drivers: don't double register keyboard drivers
Keyboard drivers are generally registered via linker set. In these cases,
they're also available as kmods which use KPI for registering/unregistering
keyboard drivers outside of the linker set.

For built-in modules, we still fire off MOD_LOAD and maybe even MOD_UNLOAD
if an error occurs, leading to registration via linker set and at MOD_LOAD
time.

This is a minor optimization at best, but it keeps the internal kbd driver
tidy as a future change will merge the linker set driver list into its
internal keyboard_drivers list via SYSINIT and simplify driver lookup by
removing the need to consult the linker set.
2019-12-16 16:41:24 +00:00
Kyle Evans
eefc662f0b kbd: provide default implementations of get_fkeystr/diag
Most keyboard drivers are using the genkbd implementations as it is;
formally use them for any that aren't set and make
genkbd_get_fkeystr/genkbd_diag private.
2019-12-16 02:44:56 +00:00
Kyle Evans
1c5c067aad keyboard switch definitions: standardize on c99 initializers
A future change will provide default implementations for some of these where
it makes sense and most of them are already using the genkbd
implementation (e.g. get_fkeystr, diag).
2019-12-16 02:05:44 +00:00
Conrad Meyer
e2e050c8ef Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions.  The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended).  Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Justin Hibbits
605e7281dc Force the setting of bit 7 in the sysmouse packet byte 1 to be unsigned.
Clang complains about the shift of (1 << 7) into a int8_t changing the value:

warning: implicit conversion from 'int' to 'int8_t' (aka 'signed char') changes
value from 128 to -128 [-Wconstant-conversion]

Squash this warning by forcing clang to see it as an unsigned bit.

This seems odd, given that it's still a conversion of 128->-128, but I'm
guessing the explicit unsigned attribute notifies clang that sign really doesn't
matter in this case.

Reported by:	Mark Millard <markmi AT dsl-only DOT net>
MFC after:	2 weeks
2017-01-30 02:32:33 +00:00
Pedro F. Giffuni
d9c9c81c08 sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code
and when the code has a high indentation level it was not really
advantageous to do the replacement.

This tries to strike a balance between readability using the macros
and flexibility of having the expressions, so not everything is
converted.
2016-04-21 19:57:40 +00:00
Pedro F. Giffuni
73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Justin Hibbits
0b3a30a65e No need to check if devd is running before posting an event. 2014-06-21 00:53:56 +00:00
Justin Hibbits
c821b4820f Properly sort the arguments to mtx_init(9).
PR:		misc/186020
Submitted by:	alfred
MFC after:	1 week
2014-01-23 01:09:33 +00:00
Nathan Whitehorn
f7d6cb2081 Return NOKEY instead of 0 if there are no more key presses queued. This
worked by accident if and only if akbd was part of a kbdmux (which it
always was in practice).

MFC after:	1 week
2013-10-29 00:53:17 +00:00
Justin Hibbits
791ab37d80 Fix powerpc/161045. ams_poll() needs to return that any data is available, not
just a new packet.

PR:		powerpc/161045
Approved by:	re(marius)
MFC after:	1 week
2013-09-28 02:13:59 +00:00
Kevin Lo
07ab70a447 Use uiomove return value instead of returning 0. 2012-11-13 06:03:43 +00:00
Justin Hibbits
ff1b355c91 Release the ADB keyboard mutex when handling the power button
press/release.  Found by WITNESS.

Approved by:	nwhitehorn (mentor)
MFC after:	3 days
2012-06-23 13:52:44 +00:00
Nathan Whitehorn
b6faf3cfdb Add support for special keys (volume/brightness/eject) on Apple laptops with
ADB keyboards.

Submitted by:	Justin Hibbits <jrh29 at alumni dot cwru dot edu>
MFC after:	9.0-RELEASE
2011-10-16 21:01:42 +00:00
Ed Schouten
78d4d8eeb2 Restore binary compatibility for GIO_KEYMAP and PIO_KEYMAP.
Back in 2009 I changed the ABI of the GIO_KEYMAP and PIO_KEYMAP ioctls
to support wide characters. I created a patch to add ABI compatibility
for the old calls, but I didn't get any feedback to that.

It seems now people are upgrading from 8 to 9 they experience this
issue, so add it anyway.
2011-07-17 08:19:19 +00:00
Nathan Whitehorn
f697a802bb Add support for interpreting taps on ADB touchpads as a button click.
Submitted by:	Andreas Tobler <andreast-list at fgznet dot ch>
MFC after:	2 weeks
2009-11-28 17:48:25 +00:00
John Baldwin
a56fe095f0 Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by:	re (kib), attilio
2009-08-20 19:17:53 +00:00
Attilio Rao
444b91868b Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by:    ed, hps, jhb, imp, mav, scottl
No answer by:   ariff, thompsa, yongari
Tested by:      pho,
                G. Trematerra <giovanni dot trematerra at gmail dot com>,
                Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by:   Yahoo! Incorporated
Approved by:	re (ksmith)
2009-08-02 14:28:40 +00:00
John Baldwin
be57da218c Use si_drv1 to hold the softc for the adb_mouse character device instead of
using devclass_get_softc().

Tested by:	nwhitehorn
2009-01-29 16:18:49 +00:00
Ed Schouten
218653a7fc Make adb_mouse use dev2unit() instead of minor().
A real fix would be to migrate it to si_drv0 to store the softc
directly, but this is the quickest way to fix it right now.
2009-01-29 05:59:42 +00:00
Nathan Whitehorn
4fb52093a8 Improve the AT keyboard emulation of the ADB keyboard driver, by supporting
an AT-like K_RAW mode instead of just K_CODE. This has the effect of making
the arrow keys on ADB keyboards work in X11.

Copied from: sunkbd(4)
2009-01-08 17:47:45 +00:00
Nathan Whitehorn
582434bd08 Fix some nasty race conditions in the VIA-CUDA driver that ended up preventing
my right mouse button and keyboard LEDs from working due to mangled
configuration packets. Fixed several other races and associated problems in the
main ADB stack that were exposed while fixing this.
2008-12-06 23:26:02 +00:00
Nathan Whitehorn
669518d7d5 Probe ADB miscellaneous devices (ID 7) instead of stopping at ID 6. This
allows us to probe the brightness and volume control buttons on PPC Apple
laptops, though there is not yet a driver to do anything useful with them.
2008-11-12 17:33:36 +00:00
Ed Schouten
3c5f535bbf Make the touch pad on my PowerBook G4 12" a little more usable.
For an unknown reason the touch pad of my PowerBook generates button 5
events when you operate it. This causes the adb_mouse code to convert
them to button 2 events, which is not what we want.

Add a new flag, AMS_TOUCHPAD, which is used to distinguish the touch
pad. When set, don't convert button events of unknown buttons to the
last button.

There are still three problems left with respect to user input:

- The mouse button events are not properly processed when the touch pad
  isn't touched.

- The arrow keys on the keyboard don't work inside X11.

- The power button isn't handled by the kernel, similar to the ACPI
  power button on i386/amd64.

Approved by:	nwhitehorn
2008-11-02 19:08:10 +00:00
Ed Schouten
b75d197096 Allow a read() on /dev/ams[0-9] to be interrupted.
Right now ams_read() uses cv_wait() to wait for new data to arrive on
the mouse device. This means that when you run `cat /dev/ams0', it
cannot be interrupted directly. After you press ^C, you first need to
move the mouse before cat will quit. Make this function use
cv_wait_sig(), which allows it to be interrupted directly.

Reviewed by:	nwhitehorn
2008-11-01 08:07:02 +00:00
Nathan Whitehorn
014186973a Fix some possible infinite loops in the ADB code, and remove some hacks
that were inserted in desperation during bring-up. In addition, move ADB bus
enumeration and child attachment to when interrupts are available.
2008-10-30 15:27:13 +00:00
Nathan Whitehorn
b4dbc59983 Add ADB support. This provides support for the external ADB bus on the PowerMac
G3 as well as the internal ADB keyboard and mice in PowerBooks and iBooks. This
also brings in Mac GPIO support, for which we should eventually have a better
interface.

Obtained from:  NetBSD (CUDA and PMU drivers)
2008-10-26 19:37:38 +00:00