xref: /openbmc/linux/include/uapi/sound/sb16_csp.h (revision 83b975b5)
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 #ifndef _UAPI__SOUND_SB16_CSP_H
9 #define _UAPI__SOUND_SB16_CSP_H
10 
11 
12 /* CSP modes */
13 #define SNDRV_SB_CSP_MODE_NONE		0x00
14 #define SNDRV_SB_CSP_MODE_DSP_READ	0x01	/* Record from DSP */
15 #define SNDRV_SB_CSP_MODE_DSP_WRITE	0x02	/* Play to DSP */
16 #define SNDRV_SB_CSP_MODE_QSOUND		0x04	/* QSound */
17 
18 /* CSP load flags */
19 #define SNDRV_SB_CSP_LOAD_FROMUSER	0x01
20 #define SNDRV_SB_CSP_LOAD_INITBLOCK	0x02
21 
22 /* CSP sample width */
23 #define SNDRV_SB_CSP_SAMPLE_8BIT		0x01
24 #define SNDRV_SB_CSP_SAMPLE_16BIT		0x02
25 
26 /* CSP channels */
27 #define SNDRV_SB_CSP_MONO			0x01
28 #define SNDRV_SB_CSP_STEREO		0x02
29 
30 /* CSP rates */
31 #define SNDRV_SB_CSP_RATE_8000		0x01
32 #define SNDRV_SB_CSP_RATE_11025		0x02
33 #define SNDRV_SB_CSP_RATE_22050		0x04
34 #define SNDRV_SB_CSP_RATE_44100		0x08
35 #define SNDRV_SB_CSP_RATE_ALL		0x0f
36 
37 /* CSP running state */
38 #define SNDRV_SB_CSP_ST_IDLE		0x00
39 #define SNDRV_SB_CSP_ST_LOADED		0x01
40 #define SNDRV_SB_CSP_ST_RUNNING		0x02
41 #define SNDRV_SB_CSP_ST_PAUSED		0x04
42 #define SNDRV_SB_CSP_ST_AUTO		0x08
43 #define SNDRV_SB_CSP_ST_QSOUND		0x10
44 
45 /* maximum QSound value (180 degrees right) */
46 #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT	0x20
47 
48 /* maximum microcode RIFF file size */
49 #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE	0x3000
50 
51 /* microcode header */
52 struct snd_sb_csp_mc_header {
53 	char codec_name[16];		/* id name of codec */
54 	unsigned short func_req;	/* requested function */
55 };
56 
57 /* microcode to be loaded */
58 struct snd_sb_csp_microcode {
59 	struct snd_sb_csp_mc_header info;
60 	unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
61 };
62 
63 /* start CSP with sample_width in mono/stereo */
64 struct snd_sb_csp_start {
65 	int sample_width;	/* sample width, look above */
66 	int channels;		/* channels, look above */
67 };
68 
69 /* CSP information */
70 struct snd_sb_csp_info {
71 	char codec_name[16];		/* id name of codec */
72 	unsigned short func_nr;		/* function number */
73 	unsigned int acc_format;	/* accepted PCM formats */
74 	unsigned short acc_channels;	/* accepted channels */
75 	unsigned short acc_width;	/* accepted sample width */
76 	unsigned short acc_rates;	/* accepted sample rates */
77 	unsigned short csp_mode;	/* CSP mode, see above */
78 	unsigned short run_channels;	/* current channels  */
79 	unsigned short run_width;	/* current sample width */
80 	unsigned short version;		/* version id: 0x10 - 0x1f */
81 	unsigned short state;		/* state bits */
82 };
83 
84 /* HWDEP controls */
85 /* get CSP information */
86 #define SNDRV_SB_CSP_IOCTL_INFO		_IOR('H', 0x10, struct snd_sb_csp_info)
87 /* load microcode to CSP */
88 /* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
89  * defined for some architectures like MIPS, and it leads to build errors.
90  * (x86 and co have 14-bit size, thus it's valid, though.)
91  * As a workaround for skipping the size-limit check, here we don't use the
92  * normal _IOW() macro but _IOC() with the manual argument.
93  */
94 #define SNDRV_SB_CSP_IOCTL_LOAD_CODE	\
95 	_IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
96 /* unload microcode from CSP */
97 #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE	_IO('H', 0x12)
98 /* start CSP */
99 #define SNDRV_SB_CSP_IOCTL_START		_IOW('H', 0x13, struct snd_sb_csp_start)
100 /* stop CSP */
101 #define SNDRV_SB_CSP_IOCTL_STOP		_IO('H', 0x14)
102 /* pause CSP and DMA transfer */
103 #define SNDRV_SB_CSP_IOCTL_PAUSE		_IO('H', 0x15)
104 /* restart CSP and DMA transfer */
105 #define SNDRV_SB_CSP_IOCTL_RESTART	_IO('H', 0x16)
106 
107 
108 #endif /* _UAPI__SOUND_SB16_CSP_H */
109