Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
  4 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  5 */
  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
 23#define CS46XX_MIN_PERIOD_SIZE 64
 24#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
 45static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
 46{
 47	unsigned int bank = reg >> 16;
 48	unsigned int offset = reg & 0xffff;
 49
 50	/*
 51	if (bank == 0)
 52		printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
 53		       reg >> 2,val);
 54	*/
 55	writel(val, chip->region.idx[bank+1].remap_addr + offset);
 56}
 57
 58static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
 59{
 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
 65static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
 66{
 67	writel(val, chip->region.name.ba0.remap_addr + offset);
 68}
 69
 70static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
 71{
 72	return readl(chip->region.name.ba0.remap_addr + offset);
 73}
 74
 75struct 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);
 78#ifdef CONFIG_PM_SLEEP
 79int cs46xx_dsp_resume(struct snd_cs46xx * chip);
 80#endif
 81struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
 82						   int symbol_type);
 83#ifdef CONFIG_SND_PROC_FS
 84int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
 85int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
 86#else
 87#define cs46xx_dsp_proc_init(card, chip)
 88#define cs46xx_dsp_proc_done(chip)
 89#endif
 90int 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);
106#ifdef CONFIG_SND_PROC_FS
107void 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);
110#else
111#define cs46xx_dsp_proc_free_scb_desc(scb)
112#define cs46xx_dsp_proc_register_scb_desc(chip, scb)
113#endif
114struct 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);
146
147struct 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);
195#endif /* __CS46XX_LIB_H__ */
v3.5.6
 
  1/*
  2 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
  3 *  Copyright (c) by Jaroslav Kysela <perex@perex.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 64
 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
 60static 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	/*
 66	if (bank == 0)
 67		printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
 68		       reg >> 2,val);
 69	*/
 70	writel(val, chip->region.idx[bank+1].remap_addr + offset);
 71}
 72
 73static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
 74{
 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
 80static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
 81{
 82	writel(val, chip->region.name.ba0.remap_addr + offset);
 83}
 84
 85static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
 86{
 87	return readl(chip->region.name.ba0.remap_addr + offset);
 88}
 89
 90struct 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);
 93#ifdef CONFIG_PM
 94int cs46xx_dsp_resume(struct snd_cs46xx * chip);
 95#endif
 96struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
 97						   int symbol_type);
 98#ifdef CONFIG_PROC_FS
 99int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
100int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
101#else
102#define cs46xx_dsp_proc_init(card, chip)
103#define cs46xx_dsp_proc_done(chip)
104#endif
105int 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);
121#ifdef CONFIG_PROC_FS
122void 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);
125#else
126#define cs46xx_dsp_proc_free_scb_desc(scb)
127#define cs46xx_dsp_proc_register_scb_desc(chip, scb)
128#endif
129struct 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);
161
162struct 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);
210#endif /* __CS46XX_LIB_H__ */