Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __SOUND_SB16_CSP_H |
| 2 | #define __SOUND_SB16_CSP_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si> |
| 6 | * Takashi Iwai <tiwai@suse.de> |
| 7 | * |
| 8 | * SB16ASP/AWE32 CSP control |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* CSP modes */ |
| 27 | #define SNDRV_SB_CSP_MODE_NONE 0x00 |
| 28 | #define SNDRV_SB_CSP_MODE_DSP_READ 0x01 /* Record from DSP */ |
| 29 | #define SNDRV_SB_CSP_MODE_DSP_WRITE 0x02 /* Play to DSP */ |
| 30 | #define SNDRV_SB_CSP_MODE_QSOUND 0x04 /* QSound */ |
| 31 | |
| 32 | /* CSP load flags */ |
| 33 | #define SNDRV_SB_CSP_LOAD_FROMUSER 0x01 |
| 34 | #define SNDRV_SB_CSP_LOAD_INITBLOCK 0x02 |
| 35 | |
| 36 | /* CSP sample width */ |
| 37 | #define SNDRV_SB_CSP_SAMPLE_8BIT 0x01 |
| 38 | #define SNDRV_SB_CSP_SAMPLE_16BIT 0x02 |
| 39 | |
| 40 | /* CSP channels */ |
| 41 | #define SNDRV_SB_CSP_MONO 0x01 |
| 42 | #define SNDRV_SB_CSP_STEREO 0x02 |
| 43 | |
| 44 | /* CSP rates */ |
| 45 | #define SNDRV_SB_CSP_RATE_8000 0x01 |
| 46 | #define SNDRV_SB_CSP_RATE_11025 0x02 |
| 47 | #define SNDRV_SB_CSP_RATE_22050 0x04 |
| 48 | #define SNDRV_SB_CSP_RATE_44100 0x08 |
| 49 | #define SNDRV_SB_CSP_RATE_ALL 0x0f |
| 50 | |
| 51 | /* CSP running state */ |
| 52 | #define SNDRV_SB_CSP_ST_IDLE 0x00 |
| 53 | #define SNDRV_SB_CSP_ST_LOADED 0x01 |
| 54 | #define SNDRV_SB_CSP_ST_RUNNING 0x02 |
| 55 | #define SNDRV_SB_CSP_ST_PAUSED 0x04 |
| 56 | #define SNDRV_SB_CSP_ST_AUTO 0x08 |
| 57 | #define SNDRV_SB_CSP_ST_QSOUND 0x10 |
| 58 | |
| 59 | /* maximum QSound value (180 degrees right) */ |
| 60 | #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT 0x20 |
| 61 | |
| 62 | /* maximum microcode RIFF file size */ |
| 63 | #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000 |
| 64 | |
| 65 | /* microcode header */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 66 | struct snd_sb_csp_mc_header { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | char codec_name[16]; /* id name of codec */ |
| 68 | unsigned short func_req; /* requested function */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 69 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* microcode to be loaded */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 72 | struct snd_sb_csp_microcode { |
| 73 | struct snd_sb_csp_mc_header info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE]; |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 75 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | /* start CSP with sample_width in mono/stereo */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 78 | struct snd_sb_csp_start { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | int sample_width; /* sample width, look above */ |
| 80 | int channels; /* channels, look above */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 81 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | /* CSP information */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 84 | struct snd_sb_csp_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | char codec_name[16]; /* id name of codec */ |
| 86 | unsigned short func_nr; /* function number */ |
| 87 | unsigned int acc_format; /* accepted PCM formats */ |
| 88 | unsigned short acc_channels; /* accepted channels */ |
| 89 | unsigned short acc_width; /* accepted sample width */ |
| 90 | unsigned short acc_rates; /* accepted sample rates */ |
| 91 | unsigned short csp_mode; /* CSP mode, see above */ |
| 92 | unsigned short run_channels; /* current channels */ |
| 93 | unsigned short run_width; /* current sample width */ |
| 94 | unsigned short version; /* version id: 0x10 - 0x1f */ |
| 95 | unsigned short state; /* state bits */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 96 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | /* HWDEP controls */ |
| 99 | /* get CSP information */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 100 | #define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /* load microcode to CSP */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 102 | #define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, struct snd_sb_csp_microcode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | /* unload microcode from CSP */ |
| 104 | #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12) |
| 105 | /* start CSP */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 106 | #define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | /* stop CSP */ |
| 108 | #define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14) |
| 109 | /* pause CSP and DMA transfer */ |
| 110 | #define SNDRV_SB_CSP_IOCTL_PAUSE _IO('H', 0x15) |
| 111 | /* restart CSP and DMA transfer */ |
| 112 | #define SNDRV_SB_CSP_IOCTL_RESTART _IO('H', 0x16) |
| 113 | |
| 114 | #ifdef __KERNEL__ |
| 115 | #include "sb.h" |
| 116 | #include "hwdep.h" |
Clemens Ladisch | de66d53 | 2006-11-06 09:18:34 +0100 | [diff] [blame] | 117 | #include <linux/firmware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 119 | struct snd_sb_csp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Clemens Ladisch | de66d53 | 2006-11-06 09:18:34 +0100 | [diff] [blame] | 121 | /* indices for the known CSP programs */ |
| 122 | enum { |
| 123 | CSP_PROGRAM_MULAW, |
| 124 | CSP_PROGRAM_ALAW, |
| 125 | CSP_PROGRAM_ADPCM_INIT, |
| 126 | CSP_PROGRAM_ADPCM_PLAYBACK, |
| 127 | CSP_PROGRAM_ADPCM_CAPTURE, |
| 128 | |
| 129 | CSP_PROGRAM_COUNT |
| 130 | }; |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /* |
| 133 | * CSP operators |
| 134 | */ |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 135 | struct snd_sb_csp_ops { |
| 136 | int (*csp_use) (struct snd_sb_csp * p); |
| 137 | int (*csp_unuse) (struct snd_sb_csp * p); |
| 138 | int (*csp_autoload) (struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode); |
| 139 | int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels); |
| 140 | int (*csp_stop) (struct snd_sb_csp * p); |
| 141 | int (*csp_qsound_transfer) (struct snd_sb_csp * p); |
| 142 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | /* |
| 145 | * CSP private data |
| 146 | */ |
| 147 | struct snd_sb_csp { |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 148 | struct snd_sb *chip; /* SB16 DSP */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | int used; /* usage flag - exclusive */ |
| 150 | char codec_name[16]; /* name of codec */ |
| 151 | unsigned short func_nr; /* function number */ |
| 152 | unsigned int acc_format; /* accepted PCM formats */ |
| 153 | int acc_channels; /* accepted channels */ |
| 154 | int acc_width; /* accepted sample width */ |
| 155 | int acc_rates; /* accepted sample rates */ |
| 156 | int mode; /* MODE */ |
| 157 | int run_channels; /* current CSP channels */ |
| 158 | int run_width; /* current sample width */ |
| 159 | int version; /* CSP version (0x10 - 0x1f) */ |
| 160 | int running; /* running state */ |
| 161 | |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 162 | struct snd_sb_csp_ops ops; /* operators */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | spinlock_t q_lock; /* locking */ |
| 165 | int q_enabled; /* enabled flag */ |
| 166 | int qpos_left; /* left position */ |
| 167 | int qpos_right; /* right position */ |
| 168 | int qpos_changed; /* position changed flag */ |
| 169 | |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 170 | struct snd_kcontrol *qsound_switch; |
| 171 | struct snd_kcontrol *qsound_space; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Ingo Molnar | 8b7547f | 2006-01-16 16:33:08 +0100 | [diff] [blame] | 173 | struct mutex access_mutex; /* locking */ |
Clemens Ladisch | de66d53 | 2006-11-06 09:18:34 +0100 | [diff] [blame] | 174 | |
| 175 | const struct firmware *csp_programs[CSP_PROGRAM_COUNT]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
Takashi Iwai | 029d64b | 2005-11-17 14:34:36 +0100 | [diff] [blame] | 178 | int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #endif |
| 180 | |
| 181 | #endif /* __SOUND_SB16_CSP */ |