xref: /linux/include/sound/ad1816a.h (revision 37744feebc086908fd89760650f458ab19071750)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef __SOUND_AD1816A_H
3 #define __SOUND_AD1816A_H
4 
5 /*
6     ad1816a.h - definitions for ADI SoundPort AD1816A chip.
7     Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
8 
9 */
10 
11 #include <sound/control.h>
12 #include <sound/pcm.h>
13 #include <sound/timer.h>
14 
15 #define AD1816A_REG(r)			(chip->port + r)
16 
17 #define AD1816A_CHIP_STATUS		0x00
18 #define AD1816A_INDIR_ADDR		0x00
19 #define AD1816A_INTERRUPT_STATUS	0x01
20 #define AD1816A_INDIR_DATA_LOW		0x02
21 #define AD1816A_INDIR_DATA_HIGH		0x03
22 #define AD1816A_PIO_DEBUG		0x04
23 #define AD1816A_PIO_STATUS		0x05
24 #define AD1816A_PIO_DATA		0x06
25 #define AD1816A_RESERVED_7		0x07
26 #define AD1816A_PLAYBACK_CONFIG		0x08
27 #define AD1816A_CAPTURE_CONFIG		0x09
28 #define AD1816A_RESERVED_10		0x0a
29 #define AD1816A_RESERVED_11		0x0b
30 #define AD1816A_JOYSTICK_RAW_DATA	0x0c
31 #define AD1816A_JOYSTICK_CTRL		0x0d
32 #define AD1816A_JOY_POS_DATA_LOW	0x0e
33 #define AD1816A_JOY_POS_DATA_HIGH	0x0f
34 
35 #define AD1816A_LOW_BYTE_TMP		0x00
36 #define AD1816A_INTERRUPT_ENABLE	0x01
37 #define AD1816A_EXTERNAL_CTRL		0x01
38 #define AD1816A_PLAYBACK_SAMPLE_RATE	0x02
39 #define AD1816A_CAPTURE_SAMPLE_RATE	0x03
40 #define AD1816A_VOICE_ATT		0x04
41 #define AD1816A_FM_ATT			0x05
42 #define AD1816A_I2S_1_ATT		0x06
43 #define AD1816A_I2S_0_ATT		0x07
44 #define AD1816A_PLAYBACK_BASE_COUNT	0x08
45 #define AD1816A_PLAYBACK_CURR_COUNT	0x09
46 #define AD1816A_CAPTURE_BASE_COUNT	0x0a
47 #define AD1816A_CAPTURE_CURR_COUNT	0x0b
48 #define AD1816A_TIMER_BASE_COUNT	0x0c
49 #define AD1816A_TIMER_CURR_COUNT	0x0d
50 #define AD1816A_MASTER_ATT		0x0e
51 #define AD1816A_CD_GAIN_ATT		0x0f
52 #define AD1816A_SYNTH_GAIN_ATT		0x10
53 #define AD1816A_VID_GAIN_ATT		0x11
54 #define AD1816A_LINE_GAIN_ATT		0x12
55 #define AD1816A_MIC_GAIN_ATT		0x13
56 #define AD1816A_PHONE_IN_GAIN_ATT	0x13
57 #define AD1816A_ADC_SOURCE_SEL		0x14
58 #define AD1816A_ADC_PGA			0x14
59 #define AD1816A_CHIP_CONFIG		0x20
60 #define AD1816A_DSP_CONFIG		0x21
61 #define AD1816A_FM_SAMPLE_RATE		0x22
62 #define AD1816A_I2S_1_SAMPLE_RATE	0x23
63 #define AD1816A_I2S_0_SAMPLE_RATE	0x24
64 #define AD1816A_RESERVED_37		0x25
65 #define AD1816A_PROGRAM_CLOCK_RATE	0x26
66 #define AD1816A_3D_PHAT_CTRL		0x27
67 #define AD1816A_PHONE_OUT_ATT		0x27
68 #define AD1816A_RESERVED_40		0x28
69 #define AD1816A_HW_VOL_BUT		0x29
70 #define AD1816A_DSP_MAILBOX_0		0x2a
71 #define AD1816A_DSP_MAILBOX_1		0x2b
72 #define AD1816A_POWERDOWN_CTRL		0x2c
73 #define AD1816A_TIMER_CTRL		0x2c
74 #define AD1816A_VERSION_ID		0x2d
75 #define AD1816A_RESERVED_46		0x2e
76 
77 #define AD1816A_READY			0x80
78 
79 #define AD1816A_PLAYBACK_IRQ_PENDING	0x80
80 #define AD1816A_CAPTURE_IRQ_PENDING	0x40
81 #define AD1816A_TIMER_IRQ_PENDING	0x20
82 
83 #define AD1816A_PLAYBACK_ENABLE		0x01
84 #define AD1816A_PLAYBACK_PIO		0x02
85 #define AD1816A_CAPTURE_ENABLE		0x01
86 #define AD1816A_CAPTURE_PIO		0x02
87 
88 #define AD1816A_FMT_LINEAR_8		0x00
89 #define AD1816A_FMT_ULAW_8		0x08
90 #define AD1816A_FMT_LINEAR_16_LIT	0x10
91 #define AD1816A_FMT_ALAW_8		0x18
92 #define AD1816A_FMT_LINEAR_16_BIG	0x30
93 #define AD1816A_FMT_ALL			0x38
94 #define AD1816A_FMT_STEREO		0x04
95 
96 #define AD1816A_PLAYBACK_IRQ_ENABLE	0x8000
97 #define AD1816A_CAPTURE_IRQ_ENABLE	0x4000
98 #define AD1816A_TIMER_IRQ_ENABLE	0x2000
99 #define AD1816A_TIMER_ENABLE		0x0080
100 
101 #define AD1816A_SRC_LINE		0x00
102 #define AD1816A_SRC_OUT			0x10
103 #define AD1816A_SRC_CD			0x20
104 #define AD1816A_SRC_SYNTH		0x30
105 #define AD1816A_SRC_VIDEO		0x40
106 #define AD1816A_SRC_MIC			0x50
107 #define AD1816A_SRC_MONO		0x50
108 #define AD1816A_SRC_PHONE_IN		0x60
109 #define AD1816A_SRC_MASK		0x70
110 
111 #define AD1816A_CAPTURE_NOT_EQUAL	0x1000
112 #define AD1816A_WSS_ENABLE		0x8000
113 
114 struct snd_ad1816a {
115 	unsigned long port;
116 	struct resource *res_port;
117 	int irq;
118 	int dma1;
119 	int dma2;
120 
121 	unsigned short hardware;
122 	unsigned short version;
123 
124 	spinlock_t lock;
125 
126 	unsigned short mode;
127 	unsigned int clock_freq;
128 
129 	struct snd_card *card;
130 	struct snd_pcm *pcm;
131 
132 	struct snd_pcm_substream *playback_substream;
133 	struct snd_pcm_substream *capture_substream;
134 	unsigned int p_dma_size;
135 	unsigned int c_dma_size;
136 
137 	struct snd_timer *timer;
138 #ifdef CONFIG_PM
139 	unsigned short image[48];
140 #endif
141 };
142 
143 
144 #define AD1816A_HW_AUTO		0
145 #define AD1816A_HW_AD1816A	1
146 #define AD1816A_HW_AD1815	2
147 #define AD1816A_HW_AD18MAX10	3
148 
149 #define AD1816A_MODE_PLAYBACK	0x01
150 #define AD1816A_MODE_CAPTURE	0x02
151 #define AD1816A_MODE_TIMER	0x04
152 #define AD1816A_MODE_OPEN	(AD1816A_MODE_PLAYBACK |	\
153 				AD1816A_MODE_CAPTURE |		\
154 				AD1816A_MODE_TIMER)
155 
156 
157 extern int snd_ad1816a_create(struct snd_card *card, unsigned long port,
158 			      int irq, int dma1, int dma2,
159 			      struct snd_ad1816a *chip);
160 
161 extern int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device);
162 extern int snd_ad1816a_mixer(struct snd_ad1816a *chip);
163 extern int snd_ad1816a_timer(struct snd_ad1816a *chip, int device);
164 #ifdef CONFIG_PM
165 extern void snd_ad1816a_suspend(struct snd_ad1816a *chip);
166 extern void snd_ad1816a_resume(struct snd_ad1816a *chip);
167 #endif
168 
169 #endif	/* __SOUND_AD1816A_H */
170