Pull remove-hotkey into release branch
[linux-2.6] / sound / pci / cs46xx / cs46xx_lib.h
1 /*
2  *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
3  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4  *
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
38 #define CS46XX_MIN_PERIOD_SIZE 1
39 #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
60 static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
61 {
62         unsigned int bank = reg >> 16;
63         unsigned int offset = reg & 0xffff;
64
65         /*if (bank == 0) printk("snd_cs46xx_poke: %04X - %08X\n",reg >> 2,val); */
66         writel(val, chip->region.idx[bank+1].remap_addr + offset);
67 }
68
69 static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
70 {
71         unsigned int bank = reg >> 16;
72         unsigned int offset = reg & 0xffff;
73         return readl(chip->region.idx[bank+1].remap_addr + offset);
74 }
75
76 static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
77 {
78         writel(val, chip->region.name.ba0.remap_addr + offset);
79 }
80
81 static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
82 {
83         return readl(chip->region.name.ba0.remap_addr + offset);
84 }
85
86 struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
87 void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
88 int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
89 struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
90                                                    int symbol_type);
91 #ifdef CONFIG_PROC_FS
92 int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
93 int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
94 #else
95 #define cs46xx_dsp_proc_init(card, chip)
96 #define cs46xx_dsp_proc_done(chip)
97 #endif
98 int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
99 int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
100                          unsigned long len);
101 int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
102 int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
103 int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
104 int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
105 int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
106 int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
107 int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
108 int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
109 int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
110 int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
111 int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
112 struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
113                                                    u32 * scb_data, u32 dest);
114 #ifdef CONFIG_PROC_FS
115 void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
116 void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
117                                         struct dsp_scb_descriptor * scb);
118 #else
119 #define cs46xx_dsp_proc_free_scb_desc(scb)
120 #define cs46xx_dsp_proc_register_scb_desc(chip, scb)
121 #endif
122 struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
123 struct dsp_scb_descriptor *
124 cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
125                                 char * codec_name, u16 channel_disp, u16 fifo_addr,
126                                 u16 child_scb_addr, u32 dest,
127                                 struct dsp_scb_descriptor * parent_scb,
128                                 int scb_child_type);
129 struct dsp_scb_descriptor *
130 cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
131                                u16 channel_disp, u16 fifo_addr,
132                                u16 sample_buffer_addr, u32 dest,
133                                struct dsp_scb_descriptor * parent_scb,
134                                int scb_child_type);
135 void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
136                             struct dsp_scb_descriptor * scb);
137 struct dsp_scb_descriptor *
138 cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
139                                u16 channel_disp, u16 fifo_addr,
140                                u16 sample_buffer_addr, u32 dest,
141                                struct dsp_scb_descriptor * parent_scb,
142                                int scb_child_type);
143 struct dsp_scb_descriptor *
144 cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
145                                int sample_rate, u16 src_buffer_addr,
146                                u16 src_delay_buffer_addr, u32 dest,
147                                struct dsp_scb_descriptor * parent_scb,
148                                int scb_child_type, int pass_through);
149 struct dsp_scb_descriptor *
150 cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
151                                u16 mix_buffer_addr, u32 dest,
152                                struct dsp_scb_descriptor * parent_scb,
153                                int scb_child_type);
154
155 struct dsp_scb_descriptor *
156 cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
157                                     u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
158                                     struct dsp_scb_descriptor * parent_scb,
159                                     int scb_child_type);
160 struct dsp_scb_descriptor *
161 cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
162                                    u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
163                                    struct dsp_scb_descriptor * parent_scb,
164                                    int scb_child_type);
165 struct dsp_scb_descriptor *
166 cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
167                                  struct dsp_scb_descriptor * parent_scb,
168                                  int scb_child_type);
169 struct dsp_scb_descriptor *
170 cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
171                                      u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
172                                      struct dsp_scb_descriptor * parent_scb,
173                                      int scb_child_type);
174 struct dsp_scb_descriptor *
175 cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
176                                   u32 dest, u16 snoop_buffer_address,
177                                   struct dsp_scb_descriptor * snoop_scb,
178                                   struct dsp_scb_descriptor * parent_scb,
179                                   int scb_child_type);
180 struct dsp_pcm_channel_descriptor *
181 cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
182                                void * private_data, u32 hw_dma_addr,
183                                int pcm_channel_id);
184 void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
185                                      struct dsp_pcm_channel_descriptor * pcm_channel);
186 int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
187                            struct dsp_pcm_channel_descriptor * pcm_channel);
188 int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
189                          struct dsp_pcm_channel_descriptor * pcm_channel);
190 struct dsp_scb_descriptor *
191 cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
192                           u16 addr, char * scb_name);
193 int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
194 int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
195 int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
196 int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
197 int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
198                                        struct dsp_pcm_channel_descriptor * pcm_channel,
199                                        int period_size);
200 int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
201 int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
202 int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
203 #endif /* __CS46XX_LIB_H__ */