blob: 86f14620f817f70821aabe16086a20a238f0c0c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02003 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#ifndef __CS46XX_LIB_H__
23#define __CS46XX_LIB_H__
24
25/*
26 * constants
27 */
28
29#define CS46XX_BA0_SIZE 0x1000
30#define CS46XX_BA1_DATA0_SIZE 0x3000
31#define CS46XX_BA1_DATA1_SIZE 0x3800
32#define CS46XX_BA1_PRG_SIZE 0x7000
33#define CS46XX_BA1_REG_SIZE 0x0100
34
35
36
37#ifdef CONFIG_SND_CS46XX_NEW_DSP
Sophie Hamilton6148b132009-09-08 10:58:42 +020038#define CS46XX_MIN_PERIOD_SIZE 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define CS46XX_MAX_PERIOD_SIZE 1024*1024
40#else
41#define CS46XX_MIN_PERIOD_SIZE 2048
42#define CS46XX_MAX_PERIOD_SIZE 2048
43#endif
44
45#define CS46XX_FRAGS 2
46/* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */
47
48#define SCB_NO_PARENT 0
49#define SCB_ON_PARENT_NEXT_SCB 1
50#define SCB_ON_PARENT_SUBLIST_SCB 2
51
52/* 3*1024 parameter, 3.5*1024 sample, 2*3.5*1024 code */
53#define BA1_DWORD_SIZE (13 * 1024 + 512)
54#define BA1_MEMORY_COUNT 3
55
56/*
57 * common I/O routines
58 */
59
Takashi Iwai3d19f802005-11-17 14:48:14 +010060static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
62 unsigned int bank = reg >> 16;
63 unsigned int offset = reg & 0xffff;
64
Takashi Iwaiee419652009-02-05 16:11:31 +010065 /*
66 if (bank == 0)
67 printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
68 reg >> 2,val);
69 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 writel(val, chip->region.idx[bank+1].remap_addr + offset);
71}
72
Takashi Iwai3d19f802005-11-17 14:48:14 +010073static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
75 unsigned int bank = reg >> 16;
76 unsigned int offset = reg & 0xffff;
77 return readl(chip->region.idx[bank+1].remap_addr + offset);
78}
79
Takashi Iwai3d19f802005-11-17 14:48:14 +010080static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 writel(val, chip->region.name.ba0.remap_addr + offset);
83}
84
Takashi Iwai3d19f802005-11-17 14:48:14 +010085static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
87 return readl(chip->region.name.ba0.remap_addr + offset);
88}
89
Takashi Iwai3d19f802005-11-17 14:48:14 +010090struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
91void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
92int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
Takashi Iwaic7561cd2012-08-14 18:12:04 +020093#ifdef CONFIG_PM_SLEEP
Takashi Iwai89f157d2007-07-19 11:23:21 +020094int cs46xx_dsp_resume(struct snd_cs46xx * chip);
95#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +010096struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
97 int symbol_type);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +010098#ifdef CONFIG_PROC_FS
Takashi Iwai3d19f802005-11-17 14:48:14 +010099int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
100int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +0100101#else
102#define cs46xx_dsp_proc_init(card, chip)
103#define cs46xx_dsp_proc_done(chip)
104#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +0100105int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
106int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
107 unsigned long len);
108int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
109int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
110int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
111int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
112int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
113int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
114int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
115int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
116int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
117int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
118int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
119struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
120 u32 * scb_data, u32 dest);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +0100121#ifdef CONFIG_PROC_FS
Takashi Iwai3d19f802005-11-17 14:48:14 +0100122void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
123void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
124 struct dsp_scb_descriptor * scb);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +0100125#else
126#define cs46xx_dsp_proc_free_scb_desc(scb)
127#define cs46xx_dsp_proc_register_scb_desc(chip, scb)
128#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +0100129struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
130struct dsp_scb_descriptor *
131cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
132 char * codec_name, u16 channel_disp, u16 fifo_addr,
133 u16 child_scb_addr, u32 dest,
134 struct dsp_scb_descriptor * parent_scb,
135 int scb_child_type);
136struct dsp_scb_descriptor *
137cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
138 u16 channel_disp, u16 fifo_addr,
139 u16 sample_buffer_addr, u32 dest,
140 struct dsp_scb_descriptor * parent_scb,
141 int scb_child_type);
142void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
143 struct dsp_scb_descriptor * scb);
144struct dsp_scb_descriptor *
145cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
146 u16 channel_disp, u16 fifo_addr,
147 u16 sample_buffer_addr, u32 dest,
148 struct dsp_scb_descriptor * parent_scb,
149 int scb_child_type);
150struct dsp_scb_descriptor *
151cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
152 int sample_rate, u16 src_buffer_addr,
153 u16 src_delay_buffer_addr, u32 dest,
154 struct dsp_scb_descriptor * parent_scb,
155 int scb_child_type, int pass_through);
156struct dsp_scb_descriptor *
157cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
158 u16 mix_buffer_addr, u32 dest,
159 struct dsp_scb_descriptor * parent_scb,
160 int scb_child_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Takashi Iwai3d19f802005-11-17 14:48:14 +0100162struct dsp_scb_descriptor *
163cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
164 u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
165 struct dsp_scb_descriptor * parent_scb,
166 int scb_child_type);
167struct dsp_scb_descriptor *
168cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
169 u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
170 struct dsp_scb_descriptor * parent_scb,
171 int scb_child_type);
172struct dsp_scb_descriptor *
173cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
174 struct dsp_scb_descriptor * parent_scb,
175 int scb_child_type);
176struct dsp_scb_descriptor *
177cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
178 u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
179 struct dsp_scb_descriptor * parent_scb,
180 int scb_child_type);
181struct dsp_scb_descriptor *
182cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
183 u32 dest, u16 snoop_buffer_address,
184 struct dsp_scb_descriptor * snoop_scb,
185 struct dsp_scb_descriptor * parent_scb,
186 int scb_child_type);
187struct dsp_pcm_channel_descriptor *
188cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
189 void * private_data, u32 hw_dma_addr,
190 int pcm_channel_id);
191void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
192 struct dsp_pcm_channel_descriptor * pcm_channel);
193int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
194 struct dsp_pcm_channel_descriptor * pcm_channel);
195int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
196 struct dsp_pcm_channel_descriptor * pcm_channel);
197struct dsp_scb_descriptor *
198cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
199 u16 addr, char * scb_name);
200int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
201int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
202int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
203int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
204int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
205 struct dsp_pcm_channel_descriptor * pcm_channel,
206 int period_size);
207int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
208int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
209int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210#endif /* __CS46XX_LIB_H__ */