brintos

brintos / linux-shallow public Read only

0
0
Text · 7.7 KiB · 6bcf2b6 Raw
196 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards4 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>5 */6 7#ifndef __CS46XX_LIB_H__8#define __CS46XX_LIB_H__9 10/*11 *  constants12 */13 14#define CS46XX_BA0_SIZE		  0x100015#define CS46XX_BA1_DATA0_SIZE 0x300016#define CS46XX_BA1_DATA1_SIZE 0x380017#define CS46XX_BA1_PRG_SIZE	  0x700018#define CS46XX_BA1_REG_SIZE	  0x010019 20 21 22#ifdef CONFIG_SND_CS46XX_NEW_DSP23#define CS46XX_MIN_PERIOD_SIZE 6424#define CS46XX_MAX_PERIOD_SIZE 1024*102425#else26#define CS46XX_MIN_PERIOD_SIZE 204827#define CS46XX_MAX_PERIOD_SIZE 204828#endif29 30#define CS46XX_FRAGS 231/* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */32 33#define SCB_NO_PARENT             034#define SCB_ON_PARENT_NEXT_SCB    135#define SCB_ON_PARENT_SUBLIST_SCB 236 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	340 41/*42 *  common I/O routines43 */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_SLEEP79int cs46xx_dsp_resume(struct snd_cs46xx * chip);80#endif81struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,82						   int symbol_type);83#ifdef CONFIG_SND_PROC_FS84int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);85int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);86#else87#define cs46xx_dsp_proc_init(card, chip)88#define cs46xx_dsp_proc_done(chip)89#endif90int 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_FS107void 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#else111#define cs46xx_dsp_proc_free_scb_desc(scb)112#define cs46xx_dsp_proc_register_scb_desc(chip, scb)113#endif114struct 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__ */196