xref: /openbmc/linux/include/uapi/sound/sb16_csp.h (revision 349d03ff)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  *  Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
4  *                        Takashi Iwai <tiwai@suse.de>
5  *
6  *  SB16ASP/AWE32 CSP control
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  *
22  */
23 #ifndef _UAPI__SOUND_SB16_CSP_H
24 #define _UAPI__SOUND_SB16_CSP_H
25 
26 
27 /* CSP modes */
28 #define SNDRV_SB_CSP_MODE_NONE		0x00
29 #define SNDRV_SB_CSP_MODE_DSP_READ	0x01	/* Record from DSP */
30 #define SNDRV_SB_CSP_MODE_DSP_WRITE	0x02	/* Play to DSP */
31 #define SNDRV_SB_CSP_MODE_QSOUND		0x04	/* QSound */
32 
33 /* CSP load flags */
34 #define SNDRV_SB_CSP_LOAD_FROMUSER	0x01
35 #define SNDRV_SB_CSP_LOAD_INITBLOCK	0x02
36 
37 /* CSP sample width */
38 #define SNDRV_SB_CSP_SAMPLE_8BIT		0x01
39 #define SNDRV_SB_CSP_SAMPLE_16BIT		0x02
40 
41 /* CSP channels */
42 #define SNDRV_SB_CSP_MONO			0x01
43 #define SNDRV_SB_CSP_STEREO		0x02
44 
45 /* CSP rates */
46 #define SNDRV_SB_CSP_RATE_8000		0x01
47 #define SNDRV_SB_CSP_RATE_11025		0x02
48 #define SNDRV_SB_CSP_RATE_22050		0x04
49 #define SNDRV_SB_CSP_RATE_44100		0x08
50 #define SNDRV_SB_CSP_RATE_ALL		0x0f
51 
52 /* CSP running state */
53 #define SNDRV_SB_CSP_ST_IDLE		0x00
54 #define SNDRV_SB_CSP_ST_LOADED		0x01
55 #define SNDRV_SB_CSP_ST_RUNNING		0x02
56 #define SNDRV_SB_CSP_ST_PAUSED		0x04
57 #define SNDRV_SB_CSP_ST_AUTO		0x08
58 #define SNDRV_SB_CSP_ST_QSOUND		0x10
59 
60 /* maximum QSound value (180 degrees right) */
61 #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT	0x20
62 
63 /* maximum microcode RIFF file size */
64 #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE	0x3000
65 
66 /* microcode header */
67 struct snd_sb_csp_mc_header {
68 	char codec_name[16];		/* id name of codec */
69 	unsigned short func_req;	/* requested function */
70 };
71 
72 /* microcode to be loaded */
73 struct snd_sb_csp_microcode {
74 	struct snd_sb_csp_mc_header info;
75 	unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
76 };
77 
78 /* start CSP with sample_width in mono/stereo */
79 struct snd_sb_csp_start {
80 	int sample_width;	/* sample width, look above */
81 	int channels;		/* channels, look above */
82 };
83 
84 /* CSP information */
85 struct snd_sb_csp_info {
86 	char codec_name[16];		/* id name of codec */
87 	unsigned short func_nr;		/* function number */
88 	unsigned int acc_format;	/* accepted PCM formats */
89 	unsigned short acc_channels;	/* accepted channels */
90 	unsigned short acc_width;	/* accepted sample width */
91 	unsigned short acc_rates;	/* accepted sample rates */
92 	unsigned short csp_mode;	/* CSP mode, see above */
93 	unsigned short run_channels;	/* current channels  */
94 	unsigned short run_width;	/* current sample width */
95 	unsigned short version;		/* version id: 0x10 - 0x1f */
96 	unsigned short state;		/* state bits */
97 };
98 
99 /* HWDEP controls */
100 /* get CSP information */
101 #define SNDRV_SB_CSP_IOCTL_INFO		_IOR('H', 0x10, struct snd_sb_csp_info)
102 /* load microcode to CSP */
103 /* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
104  * defined for some architectures like MIPS, and it leads to build errors.
105  * (x86 and co have 14-bit size, thus it's valid, though.)
106  * As a workaround for skipping the size-limit check, here we don't use the
107  * normal _IOW() macro but _IOC() with the manual argument.
108  */
109 #define SNDRV_SB_CSP_IOCTL_LOAD_CODE	\
110 	_IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
111 /* unload microcode from CSP */
112 #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE	_IO('H', 0x12)
113 /* start CSP */
114 #define SNDRV_SB_CSP_IOCTL_START		_IOW('H', 0x13, struct snd_sb_csp_start)
115 /* stop CSP */
116 #define SNDRV_SB_CSP_IOCTL_STOP		_IO('H', 0x14)
117 /* pause CSP and DMA transfer */
118 #define SNDRV_SB_CSP_IOCTL_PAUSE		_IO('H', 0x15)
119 /* restart CSP and DMA transfer */
120 #define SNDRV_SB_CSP_IOCTL_RESTART	_IO('H', 0x16)
121 
122 
123 #endif /* _UAPI__SOUND_SB16_CSP_H */
124