Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
0004  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
0005  */
0006 
0007 #ifndef __CS46XX_LIB_H__
0008 #define __CS46XX_LIB_H__
0009 
0010 /*
0011  *  constants
0012  */
0013 
0014 #define CS46XX_BA0_SIZE       0x1000
0015 #define CS46XX_BA1_DATA0_SIZE 0x3000
0016 #define CS46XX_BA1_DATA1_SIZE 0x3800
0017 #define CS46XX_BA1_PRG_SIZE   0x7000
0018 #define CS46XX_BA1_REG_SIZE   0x0100
0019 
0020 
0021 
0022 #ifdef CONFIG_SND_CS46XX_NEW_DSP
0023 #define CS46XX_MIN_PERIOD_SIZE 64
0024 #define CS46XX_MAX_PERIOD_SIZE 1024*1024
0025 #else
0026 #define CS46XX_MIN_PERIOD_SIZE 2048
0027 #define CS46XX_MAX_PERIOD_SIZE 2048
0028 #endif
0029 
0030 #define CS46XX_FRAGS 2
0031 /* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */
0032 
0033 #define SCB_NO_PARENT             0
0034 #define SCB_ON_PARENT_NEXT_SCB    1
0035 #define SCB_ON_PARENT_SUBLIST_SCB 2
0036 
0037 /* 3*1024 parameter, 3.5*1024 sample, 2*3.5*1024 code */
0038 #define BA1_DWORD_SIZE      (13 * 1024 + 512)
0039 #define BA1_MEMORY_COUNT    3
0040 
0041 /*
0042  *  common I/O routines
0043  */
0044 
0045 static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
0046 {
0047     unsigned int bank = reg >> 16;
0048     unsigned int offset = reg & 0xffff;
0049 
0050     /*
0051     if (bank == 0)
0052         printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
0053                reg >> 2,val);
0054     */
0055     writel(val, chip->region.idx[bank+1].remap_addr + offset);
0056 }
0057 
0058 static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
0059 {
0060     unsigned int bank = reg >> 16;
0061     unsigned int offset = reg & 0xffff;
0062     return readl(chip->region.idx[bank+1].remap_addr + offset);
0063 }
0064 
0065 static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
0066 {
0067     writel(val, chip->region.name.ba0.remap_addr + offset);
0068 }
0069 
0070 static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
0071 {
0072     return readl(chip->region.name.ba0.remap_addr + offset);
0073 }
0074 
0075 struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
0076 void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
0077 int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
0078 #ifdef CONFIG_PM_SLEEP
0079 int cs46xx_dsp_resume(struct snd_cs46xx * chip);
0080 #endif
0081 struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
0082                            int symbol_type);
0083 #ifdef CONFIG_SND_PROC_FS
0084 int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
0085 int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
0086 #else
0087 #define cs46xx_dsp_proc_init(card, chip)
0088 #define cs46xx_dsp_proc_done(chip)
0089 #endif
0090 int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
0091 int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
0092              unsigned long len);
0093 int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
0094 int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
0095 int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
0096 int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
0097 int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
0098 int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
0099 int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
0100 int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
0101 int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
0102 int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
0103 int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
0104 struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
0105                            u32 * scb_data, u32 dest);
0106 #ifdef CONFIG_SND_PROC_FS
0107 void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
0108 void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
0109                     struct dsp_scb_descriptor * scb);
0110 #else
0111 #define cs46xx_dsp_proc_free_scb_desc(scb)
0112 #define cs46xx_dsp_proc_register_scb_desc(chip, scb)
0113 #endif
0114 struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
0115 struct dsp_scb_descriptor *
0116 cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
0117                 char * codec_name, u16 channel_disp, u16 fifo_addr,
0118                 u16 child_scb_addr, u32 dest,
0119                 struct dsp_scb_descriptor * parent_scb,
0120                 int scb_child_type);
0121 struct dsp_scb_descriptor *
0122 cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
0123                    u16 channel_disp, u16 fifo_addr,
0124                    u16 sample_buffer_addr, u32 dest,
0125                    struct dsp_scb_descriptor * parent_scb,
0126                    int scb_child_type);
0127 void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
0128                 struct dsp_scb_descriptor * scb);
0129 struct dsp_scb_descriptor *
0130 cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
0131                    u16 channel_disp, u16 fifo_addr,
0132                    u16 sample_buffer_addr, u32 dest,
0133                    struct dsp_scb_descriptor * parent_scb,
0134                    int scb_child_type);
0135 struct dsp_scb_descriptor *
0136 cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
0137                    int sample_rate, u16 src_buffer_addr,
0138                    u16 src_delay_buffer_addr, u32 dest,
0139                    struct dsp_scb_descriptor * parent_scb,
0140                    int scb_child_type, int pass_through);
0141 struct dsp_scb_descriptor *
0142 cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
0143                    u16 mix_buffer_addr, u32 dest,
0144                    struct dsp_scb_descriptor * parent_scb,
0145                    int scb_child_type);
0146 
0147 struct dsp_scb_descriptor *
0148 cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
0149                     u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
0150                     struct dsp_scb_descriptor * parent_scb,
0151                     int scb_child_type);
0152 struct dsp_scb_descriptor *
0153 cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
0154                    u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
0155                    struct dsp_scb_descriptor * parent_scb,
0156                    int scb_child_type);
0157 struct dsp_scb_descriptor *
0158 cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
0159                  struct dsp_scb_descriptor * parent_scb,
0160                  int scb_child_type);
0161 struct dsp_scb_descriptor *
0162 cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
0163                      u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
0164                      struct dsp_scb_descriptor * parent_scb,
0165                      int scb_child_type);
0166 struct dsp_scb_descriptor *
0167 cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
0168                   u32 dest, u16 snoop_buffer_address,
0169                   struct dsp_scb_descriptor * snoop_scb,
0170                   struct dsp_scb_descriptor * parent_scb,
0171                   int scb_child_type);
0172 struct dsp_pcm_channel_descriptor *
0173 cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
0174                    void * private_data, u32 hw_dma_addr,
0175                    int pcm_channel_id);
0176 void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
0177                      struct dsp_pcm_channel_descriptor * pcm_channel);
0178 int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
0179                struct dsp_pcm_channel_descriptor * pcm_channel);
0180 int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
0181              struct dsp_pcm_channel_descriptor * pcm_channel);
0182 struct dsp_scb_descriptor *
0183 cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
0184               u16 addr, char * scb_name);
0185 int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
0186 int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
0187 int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
0188 int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
0189 int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
0190                        struct dsp_pcm_channel_descriptor * pcm_channel,
0191                        int period_size);
0192 int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
0193 int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
0194 int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
0195 #endif /* __CS46XX_LIB_H__ */