[ALSA] Add echoaudio sound drivers
[safe/jmp/linux-2.6] / sound / pci / echoaudio / gina24.c
1 /*
2  *  ALSA driver for Echoaudio soundcards.
3  *  Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; version 2 of the License.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 #define ECHO24_FAMILY
20 #define ECHOCARD_GINA24
21 #define ECHOCARD_NAME "Gina24"
22 #define ECHOCARD_HAS_MONITOR
23 #define ECHOCARD_HAS_ASIC
24 #define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
25 #define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
26 #define ECHOCARD_HAS_SUPER_INTERLEAVE
27 #define ECHOCARD_HAS_DIGITAL_IO
28 #define ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
29 #define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
30 #define ECHOCARD_HAS_EXTERNAL_CLOCK
31 #define ECHOCARD_HAS_ADAT       6
32 #define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
33
34 /* Pipe indexes */
35 #define PX_ANALOG_OUT   0       /* 8 */
36 #define PX_DIGITAL_OUT  8       /* 8 */
37 #define PX_ANALOG_IN    16      /* 2 */
38 #define PX_DIGITAL_IN   18      /* 8 */
39 #define PX_NUM          26
40
41 /* Bus indexes */
42 #define BX_ANALOG_OUT   0       /* 8 */
43 #define BX_DIGITAL_OUT  8       /* 8 */
44 #define BX_ANALOG_IN    16      /* 2 */
45 #define BX_DIGITAL_IN   18      /* 8 */
46 #define BX_NUM          26
47
48
49 #include <sound/driver.h>
50 #include <linux/delay.h>
51 #include <linux/init.h>
52 #include <linux/interrupt.h>
53 #include <linux/pci.h>
54 #include <linux/slab.h>
55 #include <linux/moduleparam.h>
56 #include <linux/firmware.h>
57 #include <sound/core.h>
58 #include <sound/info.h>
59 #include <sound/control.h>
60 #include <sound/pcm.h>
61 #include <sound/pcm_params.h>
62 #include <sound/asoundef.h>
63 #include <sound/initval.h>
64 #include <asm/io.h>
65 #include <asm/atomic.h>
66 #include "echoaudio.h"
67
68 #define FW_361_LOADER           0
69 #define FW_GINA24_301_DSP       1
70 #define FW_GINA24_361_DSP       2
71 #define FW_GINA24_301_ASIC      3
72 #define FW_GINA24_361_ASIC      4
73
74 static const struct firmware card_fw[] = {
75         {0, "loader_dsp.fw"},
76         {0, "gina24_301_dsp.fw"},
77         {0, "gina24_361_dsp.fw"},
78         {0, "gina24_301_asic.fw"},
79         {0, "gina24_361_asic.fw"}
80 };
81
82 static struct pci_device_id snd_echo_ids[] = {
83         {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0},      /* DSP 56301 Gina24 rev.0 */
84         {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0},      /* DSP 56301 Gina24 rev.1 */
85         {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0},      /* DSP 56361 Gina24 rev.0 */
86         {0x1057, 0x3410, 0xECC0, 0x0051, 0, 0, 0},      /* DSP 56361 Gina24 rev.1 */
87         {0,}
88 };
89
90 static struct snd_pcm_hardware pcm_hardware_skel = {
91         .info = SNDRV_PCM_INFO_MMAP |
92                 SNDRV_PCM_INFO_INTERLEAVED |
93                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
94                 SNDRV_PCM_INFO_MMAP_VALID |
95                 SNDRV_PCM_INFO_PAUSE |
96                 SNDRV_PCM_INFO_SYNC_START,
97         .formats =      SNDRV_PCM_FMTBIT_U8 |
98                         SNDRV_PCM_FMTBIT_S16_LE |
99                         SNDRV_PCM_FMTBIT_S24_3LE |
100                         SNDRV_PCM_FMTBIT_S32_LE |
101                         SNDRV_PCM_FMTBIT_S32_BE,
102         .rates =        SNDRV_PCM_RATE_8000_48000 |
103                         SNDRV_PCM_RATE_88200 |
104                         SNDRV_PCM_RATE_96000,
105         .rate_min = 8000,
106         .rate_max = 96000,
107         .channels_min = 1,
108         .channels_max = 8,
109         .buffer_bytes_max = 262144,
110         .period_bytes_min = 32,
111         .period_bytes_max = 131072,
112         .periods_min = 2,
113         .periods_max = 220,
114         /* One page (4k) contains 512 instructions. I don't know if the hw
115         supports lists longer than this. In this case periods_max=220 is a
116         safe limit to make sure the list never exceeds 512 instructions.
117         220 ~= (512 - 1 - (BUFFER_BYTES_MAX / PAGE_SIZE)) / 2 */
118 };
119
120 #include "gina24_dsp.c"
121 #include "echoaudio_dsp.c"
122 #include "echoaudio_gml.c"
123 #include "echoaudio.c"