xfree86: os-support: bsd: factor out bell ring into driver functions

factor it out into per console-driver functions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2026-01-16 19:15:17 +01:00
committed by Enrico Weigelt
parent 8a4089e53d
commit 4c2c8a2fcd
6 changed files with 49 additions and 67 deletions

View File

@@ -1,66 +0,0 @@
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Dawes <dawes@xfree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Rich Murphey and David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Rich Murphey and
* David Dawes make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#include <xorg-config.h>
#if defined (SYSCONS_SUPPORT)
#include <sys/kbio.h>
#endif
#include <termios.h>
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_os_support.h"
#include "xf86_OSlib.h"
void
xf86OSRingBell(int loudness, int pitch, int duration)
{
#ifdef WSCONS_SUPPORT
struct wskbd_bell_data wsb;
#endif
if (loudness && pitch) {
switch (xf86Info.consType) {
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDMKTONE,
((1193190 / pitch) & 0xffff) |
(((unsigned long) duration * loudness / 50) << 16));
break;
#endif
#if defined (WSCONS_SUPPORT)
case WSCONS:
wsb.which = WSKBD_BELL_DOALL;
wsb.pitch = pitch;
wsb.period = duration;
wsb.volume = loudness;
ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, &wsb);
break;
#endif
}
}
}

View File

@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#include <xorg-config.h>
#include "xf86_console_priv.h"
#include "xf86_os_support.h"
void xf86OSRingBell(int loudness, int pitch, int duration)
{
if (xf86_console_proc_bell)
xf86_console_proc_bell(loudness, pitch, duration);
}

View File

@@ -59,6 +59,15 @@ void xf86_console_pcvt_reactivate(void)
LogMessageVerb(X_WARNING, 1, "xf86_console_pcvt_reactivate: VT_ACTIVATE failed\n");
}
static void xf86_console_pcvt_bell(int loudness, int pitch, int duration)
{
if (loudness && pitch) {
ioctl(xf86Info.consoleFd, KDMKTONE,
((1193190 / pitch) & 0xffff) |
(((unsigned long) duration * loudness / 50) << 16));
}
}
bool xf86_console_pcvt_open(void)
{
/* This looks much like syscons, since pcvt is API compatible */
@@ -173,6 +182,7 @@ bool xf86_console_pcvt_open(void)
goto out;
out:
xf86_bsd_acquire_vt();
xf86_console_proc_bell = xf86_console_pcvt_bell;
xf86_console_proc_close = xf86_console_pcvt_close;
xf86_console_proc_reactivate = xf86_console_pcvt_reactivate;
return (fd > 0);

View File

@@ -44,6 +44,15 @@ void xf86_console_syscons_reactivate(void)
LogMessageVerb(X_WARNING, 1, "xf86_console_syscons_reactivate: VT_ACTIVATE failed\n");
}
static void xf86_console_syscons_bell(int loudness, int pitch, int duration)
{
if (loudness && pitch) {
ioctl(xf86Info.consoleFd, KDMKTONE,
((1193190 / pitch) & 0xffff) |
(((unsigned long) duration * loudness / 50) << 16));
}
}
/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
@@ -145,6 +154,7 @@ bool xf86_console_syscons_open(void)
}
xf86Info.consoleFd = fd;
xf86_bsd_acquire_vt();
xf86_console_proc_bell = xf86_console_syscons_bell;
xf86_console_proc_close = xf86_console_syscons_close;
xf86_console_proc_reactivate = xf86_console_syscons_reactivate;
return (fd > 0);

View File

@@ -25,6 +25,19 @@ void xf86_console_wscons_close(void)
xf86Info.consoleFd = -1;
}
static void xf86_console_wscons_bell(int loudness, int pitch, int duration)
{
if (loudness && pitch) {
struct wskbd_bell_data wsb = {
.which = WSKBD_BELL_DOALL,
.pitch = pitch,
.period = duration,
.volume = loudness,
};
ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, &wsb);
}
}
bool xf86_console_wscons_open(void)
{
int fd = -1;
@@ -52,6 +65,7 @@ bool xf86_console_wscons_open(void)
}
xf86Info.consoleFd = fd;
xf86_console_proc_bell = xf86_console_wscons_bell;
xf86_console_proc_close = xf86_console_wscons_close;
/* nothing special to do for acquiring the VT */

View File

@@ -96,8 +96,8 @@ elif host_machine.system() == 'sunos'
elif host_machine.system().endswith('bsd') or host_machine.system() == 'dragonfly'
srcs_xorg_os_support += [
'bsd/bsd_VTsw.c',
'bsd/bsd_bell.c',
'bsd/bsd_init.c',
'bsd/console.c',
'bsd/console_pcvt.c',
'bsd/console_syscons.c',
'bsd/console_wscons.c',