/*
 * $Header: /smsa/bsd:include/dev/sndioctl.h:bsd  1.3  $
 * $Source: /smsa/bsd:include/dev/sndioctl.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */

/*
 * Sound device control functions.
 */


#ifndef __dev_sndioctl_h
#define __dev_sndioctl_h

/*
 * Limit on number of channels (hardware defined).  The number of
 * channels must always be a power of 2, i.e.  only 1, 2, 4 and 8 are
 * valid numbers.
 */
#define	SND_MAX_CHANS	8

/*
 * Channel sample rate limits vary according to the number of channels
 * in use.  The final sample period is the channel period divided by
 * the number of channels in use, and is limited as below.
 */
#define	SND_MIN_PERIOD	6
#define SND_MAX_PERIOD	255

/* Possible positions of each channel in stereo spread */
#define SND_LEFT_100  1
#define SND_LEFT_83   2
#define SND_LEFT_67   3
#define SND_CENTRE    4
#define SND_RIGHT_67  5
#define SND_RIGHT_83  6
#define SND_RIGHT_100 7

/*
 * Description of settings of the sound device, for user control.
 * This is at a low-level mapping directly onto the hardware: the
 * driver is unconcerned about how many logically distinct sound
 * channels are being used; it is the responsibility of the
 * controlling process to determine the correct combination of period
 * and image position values according to the effective number of
 * channels.  The period value is the hardware inter-sample period in
 * microseconds (limited as specified by SND_{MIN,MAX}_PERIOD): each
 * channel sample effectively lasts for (#channels) times longer.
 * Image position values are normally replicated in the image_pos[]
 * array to suit the number of channels in use: for 1 channel, all
 * entries should be the same; for 2 channels, all even entries must
 * be programmed with the channel 0 position, and all odd entries with
 * the channel 1 position; for 4 channels, program entries 0 and 4 for
 * channel 0, 1 and 5 for channel 2, etc; for 8 channels each entry
 * corresponds to one channel's position.  Note that breaking these
 * rules is not an error (the driver cannot check, since it has no
 * knowledge of the number of channels): doing so will in theory
 * produce interesting(?) diffuse sound positioning.
 */
typedef struct snd_params
{
    unsigned int period;		/* final inter-sample time in usec */
    unsigned char image_pos[SND_MAX_CHANS];
} SNDParams, *SNDParamsRef;

#define SNDIOCGETPARAMS _IOR('S', 1, SNDParams)
#define SNDIOCSETPARAMS _IOW('S', 2, SNDParams)

/* Calls to read and write the state of the loudspeaker control flag */
#define SNDIOCGETSPKR	_IOR('S', 3, int)
#define SNDIOCSETSPKR	_IOW('S', 4, int)


#endif/*__dev_sndioctl_h*/

/* EOF sndioctl.h */
