blob: 6bcf2b636e8f9ca61616d570765a0b760998b0e3 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02004 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6
7#ifndef __CS46XX_LIB_H__
8#define __CS46XX_LIB_H__
9
10/*
11 * constants
12 */
13
14#define CS46XX_BA0_SIZE 0x1000
15#define CS46XX_BA1_DATA0_SIZE 0x3000
16#define CS46XX_BA1_DATA1_SIZE 0x3800
17#define CS46XX_BA1_PRG_SIZE 0x7000
18#define CS46XX_BA1_REG_SIZE 0x0100
19
20
21
22#ifdef CONFIG_SND_CS46XX_NEW_DSP
Sophie Hamilton6148b132009-09-08 10:58:42 +020023#define CS46XX_MIN_PERIOD_SIZE 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#define CS46XX_MAX_PERIOD_SIZE 1024*1024
25#else
26#define CS46XX_MIN_PERIOD_SIZE 2048
27#define CS46XX_MAX_PERIOD_SIZE 2048
28#endif
29
30#define CS46XX_FRAGS 2
31/* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */
32
33#define SCB_NO_PARENT 0
34#define SCB_ON_PARENT_NEXT_SCB 1
35#define SCB_ON_PARENT_SUBLIST_SCB 2
36
37/* 3*1024 parameter, 3.5*1024 sample, 2*3.5*1024 code */
38#define BA1_DWORD_SIZE (13 * 1024 + 512)
39#define BA1_MEMORY_COUNT 3
40
41/*
42 * common I/O routines
43 */
44
Takashi Iwai3d19f802005-11-17 14:48:14 +010045static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046{
47 unsigned int bank = reg >> 16;
48 unsigned int offset = reg & 0xffff;
49
Takashi Iwaiee419652009-02-05 16:11:31 +010050 /*
51 if (bank == 0)
52 printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
53 reg >> 2,val);
54 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 writel(val, chip->region.idx[bank+1].remap_addr + offset);
56}
57
Takashi Iwai3d19f802005-11-17 14:48:14 +010058static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059{
60 unsigned int bank = reg >> 16;
61 unsigned int offset = reg & 0xffff;
62 return readl(chip->region.idx[bank+1].remap_addr + offset);
63}
64
Takashi Iwai3d19f802005-11-17 14:48:14 +010065static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
67 writel(val, chip->region.name.ba0.remap_addr + offset);
68}
69
Takashi Iwai3d19f802005-11-17 14:48:14 +010070static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 return readl(chip->region.name.ba0.remap_addr + offset);
73}
74
Takashi Iwai3d19f802005-11-17 14:48:14 +010075struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
76void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
77int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
Takashi Iwaic7561cd2012-08-14 18:12:04 +020078#ifdef CONFIG_PM_SLEEP
Takashi Iwai89f157d2007-07-19 11:23:21 +020079int cs46xx_dsp_resume(struct snd_cs46xx * chip);
80#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +010081struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
82 int symbol_type);
Takashi Iwai95bb6252015-05-29 07:55:37 +020083#ifdef CONFIG_SND_PROC_FS
Takashi Iwai3d19f802005-11-17 14:48:14 +010084int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
85int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +010086#else
87#define cs46xx_dsp_proc_init(card, chip)
88#define cs46xx_dsp_proc_done(chip)
89#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +010090int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
91int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
92 unsigned long len);
93int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
94int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
95int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
96int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
97int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
98int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
99int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
100int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
101int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
102int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
103int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
104struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
105 u32 * scb_data, u32 dest);
Takashi Iwai95bb6252015-05-29 07:55:37 +0200106#ifdef CONFIG_SND_PROC_FS
Takashi Iwai3d19f802005-11-17 14:48:14 +0100107void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
108void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
109 struct dsp_scb_descriptor * scb);
Takashi Iwaiadf1b3d2005-12-01 10:49:58 +0100110#else
111#define cs46xx_dsp_proc_free_scb_desc(scb)
112#define cs46xx_dsp_proc_register_scb_desc(chip, scb)
113#endif
Takashi Iwai3d19f802005-11-17 14:48:14 +0100114struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
115struct dsp_scb_descriptor *
116cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
117 char * codec_name, u16 channel_disp, u16 fifo_addr,
118 u16 child_scb_addr, u32 dest,
119 struct dsp_scb_descriptor * parent_scb,
120 int scb_child_type);
121struct dsp_scb_descriptor *
122cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
123 u16 channel_disp, u16 fifo_addr,
124 u16 sample_buffer_addr, u32 dest,
125 struct dsp_scb_descriptor * parent_scb,
126 int scb_child_type);
127void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
128 struct dsp_scb_descriptor * scb);
129struct dsp_scb_descriptor *
130cs46xx_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);
135struct dsp_scb_descriptor *
136cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
137 int sample_rate, u16 src_buffer_addr,
138 u16 src_delay_buffer_addr, u32 dest,
139 struct dsp_scb_descriptor * parent_scb,
140 int scb_child_type, int pass_through);
141struct dsp_scb_descriptor *
142cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
143 u16 mix_buffer_addr, u32 dest,
144 struct dsp_scb_descriptor * parent_scb,
145 int scb_child_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Takashi Iwai3d19f802005-11-17 14:48:14 +0100147struct dsp_scb_descriptor *
148cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
149 u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
150 struct dsp_scb_descriptor * parent_scb,
151 int scb_child_type);
152struct dsp_scb_descriptor *
153cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
154 u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
155 struct dsp_scb_descriptor * parent_scb,
156 int scb_child_type);
157struct dsp_scb_descriptor *
158cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
159 struct dsp_scb_descriptor * parent_scb,
160 int scb_child_type);
161struct dsp_scb_descriptor *
162cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
163 u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
164 struct dsp_scb_descriptor * parent_scb,
165 int scb_child_type);
166struct dsp_scb_descriptor *
167cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
168 u32 dest, u16 snoop_buffer_address,
169 struct dsp_scb_descriptor * snoop_scb,
170 struct dsp_scb_descriptor * parent_scb,
171 int scb_child_type);
172struct dsp_pcm_channel_descriptor *
173cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
174 void * private_data, u32 hw_dma_addr,
175 int pcm_channel_id);
176void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
177 struct dsp_pcm_channel_descriptor * pcm_channel);
178int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
179 struct dsp_pcm_channel_descriptor * pcm_channel);
180int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
181 struct dsp_pcm_channel_descriptor * pcm_channel);
182struct dsp_scb_descriptor *
183cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
184 u16 addr, char * scb_name);
185int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
186int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
187int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
188int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
189int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
190 struct dsp_pcm_channel_descriptor * pcm_channel,
191 int period_size);
192int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
193int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
194int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195#endif /* __CS46XX_LIB_H__ */