buzzer(4)

NAME
buzzer - device driver for INKA4x0 board's buzzer.

SYNOPSIS
#include <linux/buzzer.h>

DESCRIPTION
There is acoustic signal on the board - a buzzer. It uses a single PWM channel.
The following features are implemented for the buzzer.
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 node have the major number of 115 and minor number of 0.
For description of the /proc filesystem interface, see below.

FUNCTIONS
In general, the buzzer driver 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()
    Error codes:
    none

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_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. Until the BUZZER_SET_FREQ IOCTL is first issued, the default value of 2000 HZ is used.
    BUZZER_GET_FREQ
    Retrieves the frequency of the buzzer to the value in HZ of the variable of type int pointed to by the command argument.
    BUZZER_SET_PERIOD
    Sets the period for the buzzer to the value in ms of the variable of type int pointed to by the command argument. Until the BUZZER_SET_PERIOD IOCTL is first issued, the default value of 1000 ms is used.
    BUZZER_GET_PERIOD
    Retrieves the period of the buzzer to the value in ms of the variable of type int pointed to by the command argument.
    BUZZER_SET_MODE
    Sets the mode for the buzzer to the value of buzzer mode code (see below) of the variable of type int pointed to by the command argument.

        0   Switches the buzzer permanently off.

        1   Switches the buzzer permanently on.

        2   Switches the buzzer on for the period previously specified via the BUZZER_SET_PERIOD IOCTL command.

        3   Puts the buzzer in periodic mode. In this mode, the buzzer is periodically switched on for the duration previously specified via the BUZZER_SET_PERIOD IOCTL command, and then switched off for the same duration.
BUZZER_GET_MODE
Retrieves the mode of the buzzer to the value of buzzer mode code (see BUZZER_SET_MODE command above) of the variable of type int pointed to by the command argument.

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/buzzer/mode
   /proc/buzzer/freq
   /proc/buzzer/period
Reading from the procfs files returns information about the current state of the driver. The first file represents the driver mode (on, off, monoflop or periodic), the other two files 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 buzzer, similar to issuing IOCTL commands on the device node. The following input string formats are accepted:

echo "<value>" > /proc/buzzer/freq
    Sets the frequency for the buzzer, similar to the BUZZER_SET_FREQ IOCTL command.

echo "<value>" > /proc/buzzer
    Sets the period for the buzzer, similar to the BUZZER_SET_PERIOD IOCTL command.

echo "off" > /proc/buzzer/mode
    Switches the buzzer permanently off, similar to the BUZZER_SET_MODE IOCTL command with argument containing code 0

echo "on" > /proc/buzzer/mode
    Switches the buzzer permanently on, similar to the BUZZER_SET_MODE IOCTL command with argument containing code 1

echo "monoflop" > /proc/buzzer/mode
    Switches the buzzer on for the previously specified period, similar to the BUZZER_SET_MODE IOCTL command with argument containing code 2

echo "periodic" > /proc/buzzer/mode
    Puts the buzzer in periodic mode, similar to the BUZZER_SET_MODE IOCTL command with argument containing code 3

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