audioio.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:20k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * include/asm-sparc/audioio.h
  3.  *
  4.  * Sparc Audio Midlayer
  5.  * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
  6.  */
  7. #ifndef _AUDIOIO_H_
  8. #define _AUDIOIO_H_
  9. /*
  10.  * SunOS/Solaris /dev/audio interface
  11.  */
  12. #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  13. #include <linux/types.h>
  14. #include <linux/time.h>
  15. #include <linux/ioctl.h>
  16. #endif
  17. /*
  18.  * This structure contains state information for audio device IO streams.
  19.  */
  20. typedef struct audio_prinfo {
  21. /*
  22.  * The following values describe the audio data encoding.
  23.  */
  24. unsigned int sample_rate; /* samples per second */
  25. unsigned int channels; /* number of interleaved channels */
  26. unsigned int precision; /* bit-width of each sample */
  27. unsigned int encoding; /* data encoding method */
  28. /*
  29.  * The following values control audio device configuration
  30.  */
  31. unsigned int gain; /* gain level: 0 - 255 */
  32. unsigned int port; /* selected I/O port (see below) */
  33. unsigned int avail_ports; /* available I/O ports (see below) */
  34. unsigned int _xxx[2]; /* Reserved for future use */
  35. unsigned int buffer_size; /* I/O buffer size */
  36. /*
  37.  * The following values describe driver state
  38.  */
  39. unsigned int samples; /* number of samples converted */
  40. unsigned int eof; /* End Of File counter (play only) */
  41. unsigned char pause; /* non-zero for pause, zero to resume */
  42. unsigned char error; /* non-zero if overflow/underflow */
  43. unsigned char waiting; /* non-zero if a process wants access */
  44. unsigned char balance; /* stereo channel balance */
  45. unsigned short minordev;
  46. /*
  47.  * The following values are read-only state flags
  48.  */
  49. unsigned char open; /* non-zero if open access permitted */
  50. unsigned char active; /* non-zero if I/O is active */
  51. } audio_prinfo_t;
  52. /*
  53.  * This structure describes the current state of the audio device.
  54.  */
  55. typedef struct audio_info {
  56. /*
  57.  * Per-stream information
  58.  */
  59. audio_prinfo_t play; /* output status information */
  60. audio_prinfo_t record; /* input status information */
  61. /*
  62.  * Per-unit/channel information
  63.  */
  64. unsigned int monitor_gain; /* input to output mix: 0 - 255 */
  65. unsigned char output_muted; /* non-zero if output is muted */
  66. unsigned char _xxx[3]; /* Reserved for future use */
  67. unsigned int _yyy[3]; /* Reserved for future use */
  68. } audio_info_t;
  69. /*
  70.  * Audio encoding types
  71.  */
  72. #define AUDIO_ENCODING_NONE (0) /* no encoding assigned   */
  73. #define AUDIO_ENCODING_ULAW (1) /* u-law encoding   */
  74. #define AUDIO_ENCODING_ALAW (2) /* A-law encoding   */
  75. #define AUDIO_ENCODING_LINEAR (3) /* Linear PCM encoding   */
  76. #define AUDIO_ENCODING_FLOAT    (4)     /* IEEE float (-1. <-> +1.) */
  77. #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM   */
  78. #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED   */
  79. #define AUDIO_ENCODING_LINEARLE (106) /* Linear PCM LE encoding */
  80. /*
  81.  * These ranges apply to record, play, and monitor gain values
  82.  */
  83. #define AUDIO_MIN_GAIN (0) /* minimum gain value */
  84. #define AUDIO_MAX_GAIN (255) /* maximum gain value */
  85. /*
  86.  * These values apply to the balance field to adjust channel gain values
  87.  */
  88. #define AUDIO_LEFT_BALANCE (0) /* left channel only */
  89. #define AUDIO_MID_BALANCE (32) /* equal left/right channel */
  90. #define AUDIO_RIGHT_BALANCE (64) /* right channel only */
  91. #define AUDIO_BALANCE_SHIFT (3)
  92. /*
  93.  * Generic minimum/maximum limits for number of channels, both modes
  94.  */
  95. #define AUDIO_MIN_PLAY_CHANNELS (1)
  96. #define AUDIO_MAX_PLAY_CHANNELS (4)
  97. #define AUDIO_MIN_REC_CHANNELS (1)
  98. #define AUDIO_MAX_REC_CHANNELS (4)
  99. /*
  100.  * Generic minimum/maximum limits for sample precision
  101.  */
  102. #define AUDIO_MIN_PLAY_PRECISION (8)
  103. #define AUDIO_MAX_PLAY_PRECISION (32)
  104. #define AUDIO_MIN_REC_PRECISION (8)
  105. #define AUDIO_MAX_REC_PRECISION (32)
  106. /*
  107.  * Define some convenient names for typical audio ports
  108.  */
  109. /*
  110.  * output ports (several may be enabled simultaneously)
  111.  */
  112. #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */
  113. #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */
  114. #define AUDIO_LINE_OUT 0x04 /* output to line out  */
  115. /*
  116.  * input ports (usually only one at a time)
  117.  */
  118. #define AUDIO_MICROPHONE 0x01 /* input from microphone */
  119. #define AUDIO_LINE_IN 0x02 /* input from line in  */
  120. #define AUDIO_CD 0x04 /* input from on-board CD inputs */
  121. #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */
  122. #define AUDIO_ANALOG_LOOPBACK   0x40    /* input from output */
  123. /*
  124.  * This macro initializes an audio_info structure to 'harmless' values.
  125.  * Note that (~0) might not be a harmless value for a flag that was
  126.  * a signed int.
  127.  */
  128. #define AUDIO_INITINFO(i) {
  129. unsigned int *__x__;
  130. for (__x__ = (unsigned int *)(i);
  131.     (char *) __x__ < (((char *)(i)) + sizeof (audio_info_t));
  132.     *__x__++ = ~0);
  133. }
  134. /*
  135.  * These allow testing for what the user wants to set 
  136.  */
  137. #define AUD_INITVALUE   (~0)
  138. #define Modify(X)       ((unsigned int)(X) != AUD_INITVALUE)
  139. #define Modifys(X)      ((X) != (unsigned short)AUD_INITVALUE)
  140. #define Modifyc(X)      ((X) != (unsigned char)AUD_INITVALUE)
  141. /*
  142.  * Parameter for the AUDIO_GETDEV ioctl to determine current
  143.  * audio devices.
  144.  */
  145. #define MAX_AUDIO_DEV_LEN (16)
  146. typedef struct audio_device {
  147. char name[MAX_AUDIO_DEV_LEN];
  148. char version[MAX_AUDIO_DEV_LEN];
  149. char config[MAX_AUDIO_DEV_LEN];
  150. } audio_device_t;
  151. /*
  152.  * Ioctl calls for the audio device.
  153.  */
  154. /*
  155.  * AUDIO_GETINFO retrieves the current state of the audio device.
  156.  *
  157.  * AUDIO_SETINFO copies all fields of the audio_info structure whose
  158.  * values are not set to the initialized value (-1) to the device state.
  159.  * It performs an implicit AUDIO_GETINFO to return the new state of the
  160.  * device.  Note that the record.samples and play.samples fields are set
  161.  * to the last value before the AUDIO_SETINFO took effect.  This allows
  162.  * an application to reset the counters while atomically retrieving the
  163.  * last value.
  164.  *
  165.  * AUDIO_DRAIN suspends the calling process until the write buffers are
  166.  * empty.
  167.  *
  168.  * AUDIO_GETDEV returns a structure of type audio_device_t which contains
  169.  * three strings.  The string "name" is a short identifying string (for
  170.  * example, the SBus Fcode name string), the string "version" identifies
  171.  * the current version of the device, and the "config" string identifies
  172.  * the specific configuration of the audio stream.  All fields are
  173.  * device-dependent -- see the device specific manual pages for details.
  174.  *
  175.  * AUDIO_GETDEV_SUNOS returns a number which is an audio device defined 
  176.  * herein (making it not too portable)
  177.  *
  178.  * AUDIO_FLUSH stops all playback and recording, clears all queued buffers, 
  179.  * resets error counters, and restarts recording and playback as appropriate
  180.  * for the current sampling mode.
  181.  */
  182. #define AUDIO_GETINFO _IOR('A', 1, audio_info_t)
  183. #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t)
  184. #define AUDIO_DRAIN _IO('A', 3)
  185. #define AUDIO_GETDEV _IOR('A', 4, audio_device_t)
  186. #define AUDIO_GETDEV_SUNOS _IOR('A', 4, int)
  187. #define AUDIO_FLUSH     _IO('A', 5)
  188. /* Define possible audio hardware configurations for 
  189.  * old SunOS-style AUDIO_GETDEV ioctl */
  190. #define AUDIO_DEV_UNKNOWN       (0)     /* not defined */
  191. #define AUDIO_DEV_AMD           (1)     /* audioamd device */
  192. #define AUDIO_DEV_SPEAKERBOX    (2)     /* dbri device with speakerbox */
  193. #define AUDIO_DEV_CODEC         (3)     /* dbri device (internal speaker) */
  194. #define AUDIO_DEV_CS4231        (5)     /* cs4231 device */
  195. /*
  196.  * The following ioctl sets the audio device into an internal loopback mode,
  197.  * if the hardware supports this.  The argument is TRUE to set loopback,
  198.  * FALSE to reset to normal operation.  If the hardware does not support
  199.  * internal loopback, the ioctl should fail with EINVAL.
  200.  * Causes ADC data to be digitally mixed in and sent to the DAC.
  201.  */
  202. #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int)
  203. /*
  204.  * Linux kernel internal implementation.
  205.  */
  206. #ifdef __KERNEL__
  207. #include <linux/fs.h>
  208. #include <linux/tqueue.h>
  209. #include <linux/wait.h>
  210. #define SDF_OPEN_WRITE 0x00000001
  211. #define SDF_OPEN_READ 0x00000002
  212. struct sparcaudio_ringbuffer
  213. {
  214.   __u8 *rb_start, *rb_end; /* start, end of this memory buffer */
  215.   __u8 *rb_in, *rb_out; /* input, output pointers */
  216.   int rb_fragsize; /* size of an audio frag */
  217.   int rb_numfrags; /* number of frags */
  218.   int rb_count, rb_hiwat, rb_lowat; /* bytes in use, hi/lo wat points */
  219.   int rb_bufsize; /* total size of buffer */
  220. };
  221. struct sparcaudio_driver
  222. {
  223. const char * name;
  224. struct sparcaudio_operations *ops;
  225. void *private;
  226. unsigned long flags;
  227.         struct strevent *sd_siglist;
  228.         /* duplex: 0=simplex, 1=duplex, 2=loop */
  229.         int sd_sigflags, duplex;
  230.         /* Which audio device are we? */
  231.         int index; 
  232.         /* This device */
  233.         struct sbus_dev *dev;
  234. /* Processes blocked on open() sit here. */
  235. wait_queue_head_t open_wait;
  236. /* Task queue for this driver's bottom half. */
  237. struct tq_struct tqueue;
  238.         /* Start of ring buffer support */
  239.         __u8 *input_buffer, *output_buffer;
  240. /* Support for a circular queue of output buffers. */
  241. __u8 **output_buffers;
  242. size_t *output_sizes, output_size, output_buffer_size;
  243. int num_output_buffers, output_front, output_rear, output_offset;
  244. int output_count, output_active, playing_count, output_eof;
  245. wait_queue_head_t output_write_wait, output_drain_wait;
  246.         char *output_notify;
  247.         /* Support for a circular queue of input buffers. */
  248.         __u8 **input_buffers;
  249. size_t *input_sizes, input_size, input_buffer_size;
  250.         int num_input_buffers, input_front, input_rear, input_offset;
  251.         int input_count, input_active, recording_count;
  252.         wait_queue_head_t input_read_wait;
  253.         /* Hack to make it look like we support variable size buffers. */
  254.         int buffer_size;
  255.         int mixer_modify_counter;
  256. };
  257. struct sparcaudio_operations
  258. {
  259. int (*open)(struct inode *, struct file *, struct sparcaudio_driver *);
  260. void (*release)(struct inode *, struct file *, struct sparcaudio_driver *);
  261. int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long,
  262.      struct sparcaudio_driver *);
  263. /* Ask driver to begin playing a buffer. */
  264. void (*start_output)(struct sparcaudio_driver *, __u8 *, unsigned long);
  265. /* Ask driver to stop playing a buffer. */
  266. void (*stop_output)(struct sparcaudio_driver *);
  267. /* Ask driver to begin recording into a buffer. */
  268. void (*start_input)(struct sparcaudio_driver *, __u8 *, unsigned long);
  269. /* Ask driver to stop recording. */
  270. void (*stop_input)(struct sparcaudio_driver *);
  271. /* Return driver name/version to caller. (/dev/audio specific) */
  272. void (*sunaudio_getdev)(struct sparcaudio_driver *, audio_device_t *);
  273.         /* Get and set the output volume. (0-255) */
  274.         int (*set_output_volume)(struct sparcaudio_driver *, int);
  275.         int (*get_output_volume)(struct sparcaudio_driver *);
  276.         /* Get and set the input volume. (0-255) */
  277.         int (*set_input_volume)(struct sparcaudio_driver *, int);
  278.         int (*get_input_volume)(struct sparcaudio_driver *);
  279.         /* Get and set the monitor volume. (0-255) */
  280.         int (*set_monitor_volume)(struct sparcaudio_driver *, int);
  281.         int (*get_monitor_volume)(struct sparcaudio_driver *);
  282.         /* Get and set the output balance. (0-64) */
  283.         int (*set_output_balance)(struct sparcaudio_driver *, int);
  284.         int (*get_output_balance)(struct sparcaudio_driver *);
  285.         /* Get and set the input balance. (0-64) */
  286.         int (*set_input_balance)(struct sparcaudio_driver *, int);
  287.         int (*get_input_balance)(struct sparcaudio_driver *);
  288.         /* Get and set the output channels. (1-4) */
  289.         int (*set_output_channels)(struct sparcaudio_driver *, int);
  290.         int (*get_output_channels)(struct sparcaudio_driver *);
  291.         /* Get and set the input channels. (1-4) */
  292.         int (*set_input_channels)(struct sparcaudio_driver *, int);
  293.         int (*get_input_channels)(struct sparcaudio_driver *);
  294.         /* Get and set the output precision. (8-32) */
  295.         int (*set_output_precision)(struct sparcaudio_driver *, int);
  296.         int (*get_output_precision)(struct sparcaudio_driver *);
  297.         /* Get and set the input precision. (8-32) */
  298.         int (*set_input_precision)(struct sparcaudio_driver *, int);
  299.         int (*get_input_precision)(struct sparcaudio_driver *);
  300.         /* Get and set the output port. () */
  301.         int (*set_output_port)(struct sparcaudio_driver *, int);
  302.         int (*get_output_port)(struct sparcaudio_driver *);
  303.         /* Get and set the input port. () */
  304.         int (*set_input_port)(struct sparcaudio_driver *, int);
  305.         int (*get_input_port)(struct sparcaudio_driver *);
  306.         /* Get and set the output encoding. () */
  307.         int (*set_output_encoding)(struct sparcaudio_driver *, int);
  308.         int (*get_output_encoding)(struct sparcaudio_driver *);
  309.         /* Get and set the input encoding. () */
  310.         int (*set_input_encoding)(struct sparcaudio_driver *, int);
  311.         int (*get_input_encoding)(struct sparcaudio_driver *);
  312.         /* Get and set the output rate. () */
  313.         int (*set_output_rate)(struct sparcaudio_driver *, int);
  314.         int (*get_output_rate)(struct sparcaudio_driver *);
  315.         /* Get and set the input rate. () */
  316.         int (*set_input_rate)(struct sparcaudio_driver *, int);
  317.         int (*get_input_rate)(struct sparcaudio_driver *);
  318. /* Return driver number to caller. (SunOS /dev/audio specific) */
  319. int (*sunaudio_getdev_sunos)(struct sparcaudio_driver *);
  320.         /* Get available ports */
  321.         int (*get_output_ports)(struct sparcaudio_driver *);
  322.         int (*get_input_ports)(struct sparcaudio_driver *);
  323.         /* Get and set output mute */
  324.         int (*set_output_muted)(struct sparcaudio_driver *, int);
  325.         int (*get_output_muted)(struct sparcaudio_driver *);
  326.         /* Get and set output pause */
  327.         int (*set_output_pause)(struct sparcaudio_driver *, int);
  328.         int (*get_output_pause)(struct sparcaudio_driver *);
  329.         /* Get and set input pause */
  330.         int (*set_input_pause)(struct sparcaudio_driver *, int);
  331.         int (*get_input_pause)(struct sparcaudio_driver *);
  332.         /* Get and set output samples */
  333.         int (*set_output_samples)(struct sparcaudio_driver *, int);
  334.         int (*get_output_samples)(struct sparcaudio_driver *);
  335.         /* Get and set input samples */
  336.         int (*set_input_samples)(struct sparcaudio_driver *, int);
  337.         int (*get_input_samples)(struct sparcaudio_driver *);
  338.         /* Get and set output error */
  339.         int (*set_output_error)(struct sparcaudio_driver *, int);
  340.         int (*get_output_error)(struct sparcaudio_driver *);
  341.         /* Get and set input error */
  342.         int (*set_input_error)(struct sparcaudio_driver *, int);
  343.         int (*get_input_error)(struct sparcaudio_driver *);
  344.         /* Get supported encodings */
  345.         int (*get_formats)(struct sparcaudio_driver *);
  346. };
  347. extern int register_sparcaudio_driver(struct sparcaudio_driver *, int);
  348. extern int unregister_sparcaudio_driver(struct sparcaudio_driver *, int);
  349. extern void sparcaudio_output_done(struct sparcaudio_driver *, int);
  350. extern void sparcaudio_input_done(struct sparcaudio_driver *, int);
  351. #endif
  352. /* Device minor numbers */
  353. #define SPARCAUDIO_MIXER_MINOR 0
  354. /* No sequencer (1) */
  355. /* No midi (2) */
  356. #define SPARCAUDIO_DSP_MINOR   3
  357. #define SPARCAUDIO_AUDIO_MINOR 4
  358. #define SPARCAUDIO_DSP16_MINOR 5
  359. #define SPARCAUDIO_STATUS_MINOR 6
  360. #define SPARCAUDIO_AUDIOCTL_MINOR 7
  361. /* No sequencer l2 (8) */
  362. /* No sound processor (9) */
  363. /* allocate 2^SPARCAUDIO_DEVICE_SHIFT minors per audio device */
  364. #define SPARCAUDIO_DEVICE_SHIFT 4
  365. /* With the coming of dummy devices this should perhaps be as high as 5? */
  366. #define SPARCAUDIO_MAX_DEVICES 3
  367. /* Streams crap for realaudio */
  368. typedef
  369. struct strevent {
  370.     struct strevent *se_next;   /* next event for this stream or NULL*/
  371.     struct strevent *se_prev;   /* previous event for this stream or last
  372.                                  * event if this is the first one*/
  373.     pid_t se_pid;               /* process to be signaled */
  374.     short se_evs;               /* events wanted */
  375. } strevent_t;
  376. typedef
  377. struct stdata
  378. {
  379.         struct stdata    *sd_next ;     /* all stdatas are linked together */
  380.         struct stdata    *sd_prev ;
  381.         struct strevent   *sd_siglist;  /* processes to be sent SIGPOLL */
  382.         int  sd_sigflags;               /* logical OR of all siglist events */
  383. } stdata_t;
  384. #define I_NREAD _IOR('S',01, int)
  385. #define I_NREAD_SOLARIS (('S'<<8)|1)
  386. #define I_FLUSH _IO('S',05)
  387. #define I_FLUSH_SOLARIS (('S'<<8)|5)
  388. #define FLUSHR  1                       /* flush read queue */
  389. #define FLUSHW  2                       /* flush write queue */
  390. #define FLUSHRW 3                       /* flush both queues */
  391. #define I_SETSIG _IO('S',011)
  392. #define I_SETSIG_SOLARIS (('S'<<8)|11)
  393. #define S_INPUT         0x01
  394. #define S_HIPRI         0x02           
  395. #define S_OUTPUT        0x04           
  396. #define S_MSG           0x08           
  397. #define S_ERROR         0x0010         
  398. #define S_HANGUP        0x0020         
  399. #define S_RDNORM        0x0040         
  400. #define S_WRNORM        S_OUTPUT
  401. #define S_RDBAND        0x0080         
  402. #define S_WRBAND        0x0100         
  403. #define S_BANDURG       0x0200         
  404. #define S_ALL           0x03FF
  405. #define I_GETSIG _IOR('S',012,int)
  406. #define I_GETSIG_SOLARIS (('S'<<8)|12)
  407. /* Conversion between Sun and OSS volume settings */
  408. static __inline__ 
  409. int OSS_LEFT(int value)
  410. {
  411.   return ((value & 0xff) % 101);
  412. }
  413. static __inline__ 
  414. int OSS_RIGHT(int value)
  415. {
  416.   return  (((value >> 8) & 0xff) % 101);
  417. }
  418. static __inline__ 
  419. int O_TO_S(int value)
  420. {
  421.   return value * 255 / 100;
  422. }
  423. static __inline__ 
  424. int S_TO_O(int value)
  425. {
  426.   return value * 100 / 255;
  427. }
  428. static __inline__ 
  429. int OSS_TO_GAIN(int value)
  430. {
  431.   int l = O_TO_S(OSS_LEFT(value));
  432.   int r = O_TO_S(OSS_RIGHT(value));
  433.   return ((l > r) ? l : r);
  434. }
  435. static __inline__ 
  436. int OSS_TO_LGAIN(int value)
  437. {
  438.   int l = O_TO_S(OSS_LEFT(value));
  439.   int r = O_TO_S(OSS_RIGHT(value));
  440.   return ((l < r) ? l : r);
  441. }
  442. static __inline__ 
  443. int OSS_TO_BAL(int value) 
  444. {
  445.   if (!OSS_TO_GAIN(value))
  446.     return AUDIO_MID_BALANCE;
  447.   if (!OSS_TO_LGAIN(value)) {
  448.     if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value)))
  449.       return AUDIO_RIGHT_BALANCE;
  450.     else
  451.       return AUDIO_LEFT_BALANCE;
  452.   }
  453.   if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value)))
  454.     return ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value)) >> AUDIO_BALANCE_SHIFT)
  455.       + AUDIO_MID_BALANCE;
  456.   else
  457.     return AUDIO_MID_BALANCE - ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value)) 
  458. >> AUDIO_BALANCE_SHIFT);
  459. }
  460. static __inline__ 
  461. int BAL_TO_OSS(int value, unsigned char balance)
  462. {
  463.   int l, r, adj;
  464.   if (balance > 63) balance = 63;
  465.   if (balance < AUDIO_MID_BALANCE) {
  466.     l = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
  467.     adj = ((AUDIO_MID_BALANCE - balance) << AUDIO_BALANCE_SHIFT);
  468.     if (adj < value)
  469.       r = (int)(value - adj)
  470. * 100 / 255;
  471.     else r = 0;
  472.   } else if (balance > AUDIO_MID_BALANCE) {
  473.     r = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
  474.     adj = ((balance - AUDIO_MID_BALANCE) << AUDIO_BALANCE_SHIFT);
  475.     if (adj < value)
  476.       l = (int)(value - adj)
  477. * 100 / 255;
  478.     else l = 0;
  479.   } else {
  480.     l = r = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
  481.   }
  482.   return ((r << 8) + l);
  483. }
  484. #ifdef __KERNEL__
  485. /* OSS mixer ioctl port handling */
  486. static __inline__
  487. int OSS_PORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set) 
  488. {
  489.   int p;
  490.   if (drv->ops->get_output_port) {
  491.     p = drv->ops->get_output_port(drv);
  492.     if (p & set)
  493.       return 0x6464;
  494.   }  
  495.   return 0;
  496. }
  497. static __inline__
  498. int OSS_IPORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set) 
  499. {
  500.   int p;
  501.   if (drv->ops->get_input_port) {
  502.     p = drv->ops->get_input_port(drv);
  503.     if (p & set)
  504.       return 0x6464;
  505.   }  
  506.   return 0;
  507. }
  508. static __inline__ 
  509. void OSS_TWIDDLE_PORT(struct sparcaudio_driver *drv, unsigned int ioctl, 
  510.       unsigned int port, unsigned int set, unsigned int value) 
  511. {
  512.   if (ioctl == port) {
  513.     int p;
  514.     if (drv->ops->get_output_port && drv->ops->set_output_port) {
  515.       p = drv->ops->get_output_port(drv);
  516.       if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100)))
  517. drv->ops->set_output_port(drv, p & ~(set));
  518.       else
  519. drv->ops->set_output_port(drv, p | set);
  520.     }
  521.   }
  522. }
  523. static __inline__ 
  524. void OSS_TWIDDLE_IPORT(struct sparcaudio_driver *drv, unsigned int ioctl, 
  525.       unsigned int port, unsigned int set, unsigned int value) 
  526. {
  527.   if (ioctl == port) {
  528.     int p;
  529.     if (drv->ops->get_input_port && drv->ops->set_input_port) {
  530.       p = drv->ops->get_input_port(drv);
  531.       if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100)))
  532. drv->ops->set_input_port(drv, p & ~(set));
  533.       else
  534. drv->ops->set_input_port(drv, p | set);
  535.     }
  536.   }
  537. }
  538. #endif /* __KERNEL__ */
  539. #endif /* _AUDIOIO_H_ */