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