Linux-libre 5.7.6-gnu
[librecmc/linux-libre.git] / sound / pci / echoaudio / gina24.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  ALSA driver for Echoaudio soundcards.
4  *  Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
5  */
6
7 #define ECHO24_FAMILY
8 #define ECHOCARD_GINA24
9 #define ECHOCARD_NAME "Gina24"
10 #define ECHOCARD_HAS_MONITOR
11 #define ECHOCARD_HAS_ASIC
12 #define ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
13 #define ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
14 #define ECHOCARD_HAS_SUPER_INTERLEAVE
15 #define ECHOCARD_HAS_DIGITAL_IO
16 #define ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
17 #define ECHOCARD_HAS_DIGITAL_MODE_SWITCH
18 #define ECHOCARD_HAS_EXTERNAL_CLOCK
19 #define ECHOCARD_HAS_ADAT       6
20 #define ECHOCARD_HAS_STEREO_BIG_ENDIAN32
21
22 /* Pipe indexes */
23 #define PX_ANALOG_OUT   0       /* 8 */
24 #define PX_DIGITAL_OUT  8       /* 8 */
25 #define PX_ANALOG_IN    16      /* 2 */
26 #define PX_DIGITAL_IN   18      /* 8 */
27 #define PX_NUM          26
28
29 /* Bus indexes */
30 #define BX_ANALOG_OUT   0       /* 8 */
31 #define BX_DIGITAL_OUT  8       /* 8 */
32 #define BX_ANALOG_IN    16      /* 2 */
33 #define BX_DIGITAL_IN   18      /* 8 */
34 #define BX_NUM          26
35
36
37 #include <linux/delay.h>
38 #include <linux/init.h>
39 #include <linux/interrupt.h>
40 #include <linux/pci.h>
41 #include <linux/module.h>
42 #include <linux/firmware.h>
43 #include <linux/slab.h>
44 #include <linux/io.h>
45 #include <sound/core.h>
46 #include <sound/info.h>
47 #include <sound/control.h>
48 #include <sound/tlv.h>
49 #include <sound/pcm.h>
50 #include <sound/pcm_params.h>
51 #include <sound/asoundef.h>
52 #include <sound/initval.h>
53 #include <linux/atomic.h>
54 #include "echoaudio.h"
55
56 /*(DEBLOBBED)*/
57
58 #define FW_361_LOADER           0
59 #define FW_GINA24_301_DSP       1
60 #define FW_GINA24_361_DSP       2
61 #define FW_GINA24_301_ASIC      3
62 #define FW_GINA24_361_ASIC      4
63
64 static const struct firmware card_fw[] = {
65         {0, "/*(DEBLOBBED)*/"},
66         {0, "/*(DEBLOBBED)*/"},
67         {0, "/*(DEBLOBBED)*/"},
68         {0, "/*(DEBLOBBED)*/"},
69         {0, "/*(DEBLOBBED)*/"}
70 };
71
72 static const struct pci_device_id snd_echo_ids[] = {
73         {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0},      /* DSP 56301 Gina24 rev.0 */
74         {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0},      /* DSP 56301 Gina24 rev.1 */
75         {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0},      /* DSP 56361 Gina24 rev.0 */
76         {0x1057, 0x3410, 0xECC0, 0x0051, 0, 0, 0},      /* DSP 56361 Gina24 rev.1 */
77         {0,}
78 };
79
80 static const struct snd_pcm_hardware pcm_hardware_skel = {
81         .info = SNDRV_PCM_INFO_MMAP |
82                 SNDRV_PCM_INFO_INTERLEAVED |
83                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
84                 SNDRV_PCM_INFO_MMAP_VALID |
85                 SNDRV_PCM_INFO_PAUSE |
86                 SNDRV_PCM_INFO_SYNC_START,
87         .formats =      SNDRV_PCM_FMTBIT_U8 |
88                         SNDRV_PCM_FMTBIT_S16_LE |
89                         SNDRV_PCM_FMTBIT_S24_3LE |
90                         SNDRV_PCM_FMTBIT_S32_LE |
91                         SNDRV_PCM_FMTBIT_S32_BE,
92         .rates =        SNDRV_PCM_RATE_8000_48000 |
93                         SNDRV_PCM_RATE_88200 |
94                         SNDRV_PCM_RATE_96000,
95         .rate_min = 8000,
96         .rate_max = 96000,
97         .channels_min = 1,
98         .channels_max = 8,
99         .buffer_bytes_max = 262144,
100         .period_bytes_min = 32,
101         .period_bytes_max = 131072,
102         .periods_min = 2,
103         .periods_max = 220,
104         /* One page (4k) contains 512 instructions. I don't know if the hw
105         supports lists longer than this. In this case periods_max=220 is a
106         safe limit to make sure the list never exceeds 512 instructions.
107         220 ~= (512 - 1 - (BUFFER_BYTES_MAX / PAGE_SIZE)) / 2 */
108 };
109
110 #include "gina24_dsp.c"
111 #include "echoaudio_dsp.c"
112 #include "echoaudio_gml.c"
113 #include "echoaudio.c"