📄 audioio.h
字号:
/* Return driver name/version to caller. (/dev/audio specific) */ void (*sunaudio_getdev)(struct sparcaudio_driver *, audio_device_t *); /* Get and set the output volume. (0-255) */ int (*set_output_volume)(struct sparcaudio_driver *, int); int (*get_output_volume)(struct sparcaudio_driver *); /* Get and set the input volume. (0-255) */ int (*set_input_volume)(struct sparcaudio_driver *, int); int (*get_input_volume)(struct sparcaudio_driver *); /* Get and set the monitor volume. (0-255) */ int (*set_monitor_volume)(struct sparcaudio_driver *, int); int (*get_monitor_volume)(struct sparcaudio_driver *); /* Get and set the output balance. (0-64) */ int (*set_output_balance)(struct sparcaudio_driver *, int); int (*get_output_balance)(struct sparcaudio_driver *); /* Get and set the input balance. (0-64) */ int (*set_input_balance)(struct sparcaudio_driver *, int); int (*get_input_balance)(struct sparcaudio_driver *); /* Get and set the output channels. (1-4) */ int (*set_output_channels)(struct sparcaudio_driver *, int); int (*get_output_channels)(struct sparcaudio_driver *); /* Get and set the input channels. (1-4) */ int (*set_input_channels)(struct sparcaudio_driver *, int); int (*get_input_channels)(struct sparcaudio_driver *); /* Get and set the output precision. (8-32) */ int (*set_output_precision)(struct sparcaudio_driver *, int); int (*get_output_precision)(struct sparcaudio_driver *); /* Get and set the input precision. (8-32) */ int (*set_input_precision)(struct sparcaudio_driver *, int); int (*get_input_precision)(struct sparcaudio_driver *); /* Get and set the output port. () */ int (*set_output_port)(struct sparcaudio_driver *, int); int (*get_output_port)(struct sparcaudio_driver *); /* Get and set the input port. () */ int (*set_input_port)(struct sparcaudio_driver *, int); int (*get_input_port)(struct sparcaudio_driver *); /* Get and set the output encoding. () */ int (*set_output_encoding)(struct sparcaudio_driver *, int); int (*get_output_encoding)(struct sparcaudio_driver *); /* Get and set the input encoding. () */ int (*set_input_encoding)(struct sparcaudio_driver *, int); int (*get_input_encoding)(struct sparcaudio_driver *); /* Get and set the output rate. () */ int (*set_output_rate)(struct sparcaudio_driver *, int); int (*get_output_rate)(struct sparcaudio_driver *); /* Get and set the input rate. () */ int (*set_input_rate)(struct sparcaudio_driver *, int); int (*get_input_rate)(struct sparcaudio_driver *); /* Return driver number to caller. (SunOS /dev/audio specific) */ int (*sunaudio_getdev_sunos)(struct sparcaudio_driver *); /* Get available ports */ int (*get_output_ports)(struct sparcaudio_driver *); int (*get_input_ports)(struct sparcaudio_driver *); /* Get and set output mute */ int (*set_output_muted)(struct sparcaudio_driver *, int); int (*get_output_muted)(struct sparcaudio_driver *); /* Get and set output pause */ int (*set_output_pause)(struct sparcaudio_driver *, int); int (*get_output_pause)(struct sparcaudio_driver *); /* Get and set input pause */ int (*set_input_pause)(struct sparcaudio_driver *, int); int (*get_input_pause)(struct sparcaudio_driver *); /* Get and set output samples */ int (*set_output_samples)(struct sparcaudio_driver *, int); int (*get_output_samples)(struct sparcaudio_driver *); /* Get and set input samples */ int (*set_input_samples)(struct sparcaudio_driver *, int); int (*get_input_samples)(struct sparcaudio_driver *); /* Get and set output error */ int (*set_output_error)(struct sparcaudio_driver *, int); int (*get_output_error)(struct sparcaudio_driver *); /* Get and set input error */ int (*set_input_error)(struct sparcaudio_driver *, int); int (*get_input_error)(struct sparcaudio_driver *); /* Get supported encodings */ int (*get_formats)(struct sparcaudio_driver *);};extern int register_sparcaudio_driver(struct sparcaudio_driver *, int);extern int unregister_sparcaudio_driver(struct sparcaudio_driver *, int);extern void sparcaudio_output_done(struct sparcaudio_driver *, int);extern void sparcaudio_input_done(struct sparcaudio_driver *, int);#endif/* Device minor numbers */#define SPARCAUDIO_MIXER_MINOR 0/* No sequencer (1) *//* No midi (2) */#define SPARCAUDIO_DSP_MINOR 3#define SPARCAUDIO_AUDIO_MINOR 4#define SPARCAUDIO_DSP16_MINOR 5#define SPARCAUDIO_STATUS_MINOR 6#define SPARCAUDIO_AUDIOCTL_MINOR 7/* No sequencer l2 (8) *//* No sound processor (9) *//* allocate 2^SPARCAUDIO_DEVICE_SHIFT minors per audio device */#define SPARCAUDIO_DEVICE_SHIFT 4/* With the coming of dummy devices this should perhaps be as high as 5? */#define SPARCAUDIO_MAX_DEVICES 3/* Streams crap for realaudio */typedefstruct strevent { struct strevent *se_next; /* next event for this stream or NULL*/ struct strevent *se_prev; /* previous event for this stream or last * event if this is the first one*/ pid_t se_pid; /* process to be signaled */ short se_evs; /* events wanted */} strevent_t;typedefstruct stdata{ struct stdata *sd_next ; /* all stdatas are linked together */ struct stdata *sd_prev ; struct strevent *sd_siglist; /* processes to be sent SIGPOLL */ int sd_sigflags; /* logical OR of all siglist events */} stdata_t;#define I_NREAD _IOR('S',01, int)#define I_NREAD_SOLARIS (('S'<<8)|1)#define I_FLUSH _IO('S',05)#define I_FLUSH_SOLARIS (('S'<<8)|5)#define FLUSHR 1 /* flush read queue */#define FLUSHW 2 /* flush write queue */#define FLUSHRW 3 /* flush both queues */#define I_SETSIG _IO('S',011)#define I_SETSIG_SOLARIS (('S'<<8)|11)#define S_INPUT 0x01#define S_HIPRI 0x02 #define S_OUTPUT 0x04 #define S_MSG 0x08 #define S_ERROR 0x0010 #define S_HANGUP 0x0020 #define S_RDNORM 0x0040 #define S_WRNORM S_OUTPUT#define S_RDBAND 0x0080 #define S_WRBAND 0x0100 #define S_BANDURG 0x0200 #define S_ALL 0x03FF#define I_GETSIG _IOR('S',012,int)#define I_GETSIG_SOLARIS (('S'<<8)|12)/* Conversion between Sun and OSS volume settings */static __inline__ int OSS_LEFT(int value){ return ((value & 0xff) % 101);}static __inline__ int OSS_RIGHT(int value){ return (((value >> 8) & 0xff) % 101);}static __inline__ int O_TO_S(int value){ return value * 255 / 100;}static __inline__ int S_TO_O(int value){ return value * 100 / 255;}static __inline__ int OSS_TO_GAIN(int value){ int l = O_TO_S(OSS_LEFT(value)); int r = O_TO_S(OSS_RIGHT(value)); return ((l > r) ? l : r);}static __inline__ int OSS_TO_LGAIN(int value){ int l = O_TO_S(OSS_LEFT(value)); int r = O_TO_S(OSS_RIGHT(value)); return ((l < r) ? l : r);}static __inline__ int OSS_TO_BAL(int value) { if (!OSS_TO_GAIN(value)) return AUDIO_MID_BALANCE; if (!OSS_TO_LGAIN(value)) { if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value))) return AUDIO_RIGHT_BALANCE; else return AUDIO_LEFT_BALANCE; } if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value))) return ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value)) >> AUDIO_BALANCE_SHIFT) + AUDIO_MID_BALANCE; else return AUDIO_MID_BALANCE - ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value)) >> AUDIO_BALANCE_SHIFT);}static __inline__ int BAL_TO_OSS(int value, unsigned char balance){ int l, r, adj; if (balance > 63) balance = 63; if (balance < AUDIO_MID_BALANCE) { l = (int)value * 100 / 255 + ((value * 100 % 255) > 0); adj = ((AUDIO_MID_BALANCE - balance) << AUDIO_BALANCE_SHIFT); if (adj < value) r = (int)(value - adj) * 100 / 255; else r = 0; } else if (balance > AUDIO_MID_BALANCE) { r = (int)value * 100 / 255 + ((value * 100 % 255) > 0); adj = ((balance - AUDIO_MID_BALANCE) << AUDIO_BALANCE_SHIFT); if (adj < value) l = (int)(value - adj) * 100 / 255; else l = 0; } else { l = r = (int)value * 100 / 255 + ((value * 100 % 255) > 0); } return ((r << 8) + l);}#ifdef __KERNEL__/* OSS mixer ioctl port handling */static __inline__int OSS_PORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set) { int p; if (drv->ops->get_output_port) { p = drv->ops->get_output_port(drv); if (p & set) return 0x6464; } return 0;}static __inline__int OSS_IPORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set) { int p; if (drv->ops->get_input_port) { p = drv->ops->get_input_port(drv); if (p & set) return 0x6464; } return 0;}static __inline__ void OSS_TWIDDLE_PORT(struct sparcaudio_driver *drv, unsigned int ioctl, unsigned int port, unsigned int set, unsigned int value) { if (ioctl == port) { int p; if (drv->ops->get_output_port && drv->ops->set_output_port) { p = drv->ops->get_output_port(drv); if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100))) drv->ops->set_output_port(drv, p & ~(set)); else drv->ops->set_output_port(drv, p | set); } }}static __inline__ void OSS_TWIDDLE_IPORT(struct sparcaudio_driver *drv, unsigned int ioctl, unsigned int port, unsigned int set, unsigned int value) { if (ioctl == port) { int p; if (drv->ops->get_input_port && drv->ops->set_input_port) { p = drv->ops->get_input_port(drv); if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100))) drv->ops->set_input_port(drv, p & ~(set)); else drv->ops->set_input_port(drv, p | set); } }}#endif /* __KERNEL__ */#endif /* _AUDIOIO_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -