buzzer(4)

NAME
buzzer - device driver for TRAB board's buzzers.

SYNOPSIS
#include <linux/buzzer.h>

DESCRIPTION
There are two acoustic signals on the board: a magnetic buzzer and a piezo buzzer. The magnetic buzzer is controlled using two PWM channels running at a fixed frequency ratio of 2 : 1; the two PWM channels are phase-shifted by 60 degree relative to the channel with the higher frequency. The piezo buzzer uses a single PWM channel.
The following features are implemented for both buzzers, which operate completely independent of each other.
Set frequency [in Hz]
Set period (for monoflop and periodic functions) [in ms]
Switch permanently on
Switch permanently off
Monoflop: switch on for <period> milliseconds
Periodic: periodical switch on for <period> milliseconds and switch off for <period> milliseconds.
Both standard character device interface and /proc interface are provided for parameter adjustments.
The device nodes have the major number of 115 and minor numbers are constructed as follows:
   Name                 Minor number
   -------------        ------------
   /dev/piezo           0
   /dev/magnetic        1
For description of the /proc filesystem interface, see below.

FUNCTIONS
In general, the buzzer driver's functions behave as used with other drivers. A function return value of (-1) indicates an error, in which case an appropriate error code can be found in errno.
The buzzer driver supports the following driver calls:

open()
    The minor number of the device node indicates the buzzer device (see above).
    Error codes:
    ENXIO - no buzzer device correspond to this minor number.

close()
    Error codes:
    none

read()
    The read() function is not implemented by the buzzer driver. An attempt to call read() on a file descriptor corresponding to the buzzer driver will return (-1) with errno set to EINVAL.

write()
    The write() function is not implemented by the buzzer driver. An attempt to call read() on a file descriptor corresponding to the buzzer driver will return (-1) with errno set to EINVAL.

ioctl()
    The following IOCTL commands are supported for device nodes corresponding to each buzzer device:

    BUZZER_CMD_SET_FREQ
    Sets the frequency for the buzzer to the value in HZ of the variable of type int pointed to by the command argument. Note that the frequency actually set by the driver may differ from the one specified due to h/w restrictions, in which case the value of the variable pointed to by the command argument is updated to reflect the actual setting preformed by the driver. Until the BUZZER_CMD_SET_FREQ IOCTL is first issued, the default value of 400 HZ is used.
    BUZZER_CMD_SET_PERIOD
    Sets period for the buzzer to the value in ms of the variable of type int pointed to by the command argument.
    BUZZER_CMD_ON
    Switches the buzzer permanently on.
    BUZZER_CMD_OFF
    Switches the buzzer permanently off.
    BUZZER_CMD_MONOFLOP
    Switches the buzzer on for the period previously specified via the BUZZER_CMD_SET_PERIOD IOCTL command.
    Error codes:
    EINVL - buzzer period was not set.
    BUZZER_CMD_PERIODIC
    Puts the buzzer in periodic mode. In this mode, the buzzer is periodically switched on for the duration previously specified via the BUZZER_CMD_SET_PERIOD IOCTL command, and then switched off for the same duration.
    Error codes:
    EINVAL - buzzer period was not set.

poll()
    The poll() function is not implemented by the buzzer driver. An attempt to call poll() or select() on a file descriptor corresponding to the buzzer driver will not block and will report that the device is ready for reading and writing.

PROCFS INTERFACE
The /proc filesystem driver interface is via the following files:
   /proc/driver/buzzer_piezo
   /proc/driver/buzzer_mag
Reading from the procfs files returns three lines of text, providing information about the current state of the driver. The first line represents the driver mode (on, off, monoflop or periodic), the other two lines show the current values of the buzzer's frequency and period. Writing to the procfs files may be used to set the control values for the buzzers, similar to issuing IOCTL commands on the device node. The following input string formats are accepted:

echo "freq=<value>" > /proc/driver/buzzer_????
    Sets the frequency for the buzzer, similar to the BUZZER_CMD_SET_FREQ IOCTL command.

echo "period=<value>" > /proc/driver/buzzer_????
    Sets the period for the buzzer, similar to the BUZZER_CMD_SET_PERIOD IOCTL command.

echo "on" > /proc/driver/buzzer_????
    Switches the buzzer permanently on, similar to the BUZZER_CMD_ON IOCTL command.

echo "off" > /proc/driver/buzzer_????
    Switches the buzzer permanently off, similar to the BUZZER_CMD_OFF IOCTL command.

echo "monoflop" > /proc/driver/buzzer_????
    Switches the buzzer on for the previously specified period, similar to the BUZZER_CMD_MONOFLOP IOCTL command.

echo "periodic" > /proc/driver/buzzer_????
    Puts the buzzer in periodic mode, similar to the BUZZER_CMD_PERIODIC IOCTL command.

All attempts to write to the /proc files strings that do not match the patterns defined above are discarded by the driver.