xref: /openbmc/linux/sound/pci/echoaudio/gina24.c (revision 5c7587f6)
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 MODULE_FIRMWARE("ea/loader_dsp.fw");
57 MODULE_FIRMWARE("ea/gina24_301_dsp.fw");
58 MODULE_FIRMWARE("ea/gina24_361_dsp.fw");
59 MODULE_FIRMWARE("ea/gina24_301_asic.fw");
60 MODULE_FIRMWARE("ea/gina24_361_asic.fw");
61 
62 #define FW_361_LOADER		0
63 #define FW_GINA24_301_DSP	1
64 #define FW_GINA24_361_DSP	2
65 #define FW_GINA24_301_ASIC	3
66 #define FW_GINA24_361_ASIC	4
67 
68 static const struct firmware card_fw[] = {
69 	{0, "loader_dsp.fw"},
70 	{0, "gina24_301_dsp.fw"},
71 	{0, "gina24_361_dsp.fw"},
72 	{0, "gina24_301_asic.fw"},
73 	{0, "gina24_361_asic.fw"}
74 };
75 
76 static const struct pci_device_id snd_echo_ids[] = {
77 	{0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0},	/* DSP 56301 Gina24 rev.0 */
78 	{0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0},	/* DSP 56301 Gina24 rev.1 */
79 	{0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0},	/* DSP 56361 Gina24 rev.0 */
80 	{0x1057, 0x3410, 0xECC0, 0x0051, 0, 0, 0},	/* DSP 56361 Gina24 rev.1 */
81 	{0,}
82 };
83 
84 static const struct snd_pcm_hardware pcm_hardware_skel = {
85 	.info = SNDRV_PCM_INFO_MMAP |
86 		SNDRV_PCM_INFO_INTERLEAVED |
87 		SNDRV_PCM_INFO_BLOCK_TRANSFER |
88 		SNDRV_PCM_INFO_MMAP_VALID |
89 		SNDRV_PCM_INFO_PAUSE |
90 		SNDRV_PCM_INFO_SYNC_START,
91 	.formats =	SNDRV_PCM_FMTBIT_U8 |
92 			SNDRV_PCM_FMTBIT_S16_LE |
93 			SNDRV_PCM_FMTBIT_S24_3LE |
94 			SNDRV_PCM_FMTBIT_S32_LE |
95 			SNDRV_PCM_FMTBIT_S32_BE,
96 	.rates = 	SNDRV_PCM_RATE_8000_48000 |
97 			SNDRV_PCM_RATE_88200 |
98 			SNDRV_PCM_RATE_96000,
99 	.rate_min = 8000,
100 	.rate_max = 96000,
101 	.channels_min = 1,
102 	.channels_max = 8,
103 	.buffer_bytes_max = 262144,
104 	.period_bytes_min = 32,
105 	.period_bytes_max = 131072,
106 	.periods_min = 2,
107 	.periods_max = 220,
108 	/* One page (4k) contains 512 instructions. I don't know if the hw
109 	supports lists longer than this. In this case periods_max=220 is a
110 	safe limit to make sure the list never exceeds 512 instructions.
111 	220 ~= (512 - 1 - (BUFFER_BYTES_MAX / PAGE_SIZE)) / 2 */
112 };
113 
114 #include "gina24_dsp.c"
115 #include "echoaudio_dsp.c"
116 #include "echoaudio_gml.c"
117 #include "echoaudio.c"
118