preliminary [PATCH] cs46xx independant PCM - Rear channel
Hi!
With this patch it should be possible to play a indpendent PCM stream to the "Rear" channel on a cs46xx based HW.
Well, I guess I dont need to tell you that this patch probably works fine with a Game Thater XP card, and probably some touches are neeeded for other cs46xx based soundcards.
The DSP will send the main PCM stream to the codec on slot 3 and 4, and for the Rear channel it send the PCM stream it uses slot 7 and 8, which works fine in a dual cs4294 combination setting the secondary codec in extended mode.
With other combinations probably we need experiment a little bit to find out how configure the codecs.
NOTE: sound is no longer duplicated in main and rear channels, so you need to run something like "aplay -D hw:0,1" to feed some sound in rear channel now.
Still left to have PCM channels for Center and LFE, and here I would need some suggestion how to proceed. Is it possible in some how to create a Mono PCM channel for this purpose with the ALSA API ??
/Benny
cvs/alsa-kernel/include/cs46xx.h renamed from include/cs46xx.h +7 -1
@@ -1790,6 +1790,7 @@struct pci_dev *pci;snd_card_t *card;snd_pcm_t *pcm; +snd_rawmidi_t *rmidi;snd_rawmidi_substream_t *midi_input;snd_rawmidi_substream_t *midi_output;
@@ -1814,12 +1815,15 @@struct pm_dev *pm_dev;#endif #ifdef CONFIG_SND_CS46XX_DEBUG_GPIO -int current_gpio; +int current_gpio;#endif #ifdef CONFIG_SND_CS46XX_NEW_DSP struct semaphore spos_mutex;dsp_spos_instance_t * dsp_spos_instance; + +snd_pcm_t *pcm_rear; +snd_pcm_t *pcm_iec958;#else /* for compatibility */ cs46xx_pcm_t *playback_pcm;unsigned int play_ctl;
@@ -1832,6 +1836,8 @@ cs46xx_t **rcodec);int snd_cs46xx_pcm (cs46xx_t *chip,int device,snd_pcm_t **rpcm); +int snd_cs46xx_pcm_rear (cs46xx_t *chip,int device,snd_pcm_t **rpcm); +int snd_cs46xx_pcm_iec958 (cs46xx_t *chip,int device,snd_pcm_t **rpcm);int snd_cs46xx_mixer (cs46xx_t *chip);int snd_cs46xx_midi (cs46xx_t *chip,int device,snd_rawmidi_t **rmidi);void snd_cs46xx_gameport (cs46xx_t *chip);
cvs/alsa-kernel/include/cs46xx_dsp_spos.h renamed from include/cs46xx_dsp_spos.h +10 -1
@@ -54,6 +54,9 @@#define DSP_MAX_PCM_CHANNELS 32#define DSP_MAX_SRC_NR 6 +#define DSP_PCM_MAIN_CHANNEL 1 +#define DSP_PCM_REAR_CHANNEL 2 +struct _dsp_module_desc_t ; typedef struct _symbol_entry_t {
@@ -129,6 +132,8 @@u32 unlinked;dsp_scb_descriptor_t * pcm_reader_scb;dsp_scb_descriptor_t * src_scb; +dsp_scb_descriptor_t * mixer_scb; +int pcm_channel_id;void * private_data; } pcm_channel_descriptor_t;
@@ -141,8 +146,12 @@segment_desc_t code; -/* PCM playback */ +/* Main PCM playback mixer */ dsp_scb_descriptor_t * master_mix_scb; + +/* Rear PCM playback mixer */ +dsp_scb_descriptor_t * rear_mix_scb; +int npcm_channels;int nsrc_scb;pcm_channel_descriptor_t pcm_channels[DSP_MAX_PCM_CHANNELS ];
cvs/alsa-kernel/pci/ac97/ac97_codec.c renamed from pci/ac97/ac97_codec.c +1 -1
@@ -966,7 +966,7 @@ reg =AC97_CENTER_LFE_MASTER ; mask =0x0080 ;break ; -case AC97_SURROUND_MASTER : +case AC97_SURROUND_MASTER :if ((ac97->ext_id &0x80 ) ==0 )return 0 ;break ;
cvs/alsa-kernel/pci/cs46xx/cs46xx.c renamed from pci/cs46xx/cs46xx.c +5 -0
@@ -110,6 +110,10 @@snd_card_free (card);return err; } +if ((err =snd_cs46xx_pcm_rear (chip,1 ,NULL )) <0 ) { +snd_card_free (card); +return err; + }if ((err =snd_cs46xx_mixer (chip)) <0 ) {snd_card_free (card);return err;
@@ -132,6 +136,7 @@snd_card_free (card);return err; } +pci_set_drvdata (pci, chip); dev++;return 0 ;
cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c renamed from pci/cs46xx/cs46xx_lib.c +215 -10
329 lines not on this page · raw message
cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h renamed from pci/cs46xx/cs46xx_lib.h +5 -1
@@ -51,6 +51,9 @@extern snd_pcm_ops_t snd_cs46xx_playback_indirect_ops;extern snd_pcm_ops_t snd_cs46xx_capture_ops;extern snd_pcm_ops_t snd_cs46xx_capture_indirect_ops; +extern snd_pcm_ops_t snd_cs46xx_playback_rear_ops; +extern snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops; +/*
@@ -185,7 +188,8 @@ dsp_scb_descriptor_t * snoop_scb, dsp_scb_descriptor_t * parent_scb, int scb_child_type); -pcm_channel_descriptor_t *cs46xx_dsp_create_pcm_channel (cs46xx_t * chip,u32 sample_rate,void * private_data,u32 hw_dma_addr); +pcm_channel_descriptor_t *cs46xx_dsp_create_pcm_channel (cs46xx_t * chip,u32 sample_rate,void * private_data,u32 hw_dma_addr, +int pcm_channel_id);void cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel); void cs46xx_dsp_set_src_sample_rate(cs46xx_t * chip,dsp_scb_descriptor_t * src,
cvs/alsa-kernel/pci/cs46xx/dsp_spos.c renamed from pci/cs46xx/dsp_spos.c +14 -2
@@ -1017,6 +1017,7 @@dsp_scb_descriptor_t * codec_in_scb;dsp_scb_descriptor_t * src_task_scb;dsp_scb_descriptor_t * master_mix_scb; +dsp_scb_descriptor_t * rear_mix_scb;dsp_scb_descriptor_t * record_mix_scb;dsp_scb_descriptor_t * write_back_scb;dsp_scb_descriptor_t * vari_decimate_scb;
@@ -1309,18 +1310,29 @@/* create secondary CODEC output */ sec_codec_out_scb =cs46xx_dsp_create_codec_out_scb (chip,"CodecOutSCB_II" ,0x0010 ,0x0040 , -OUTPUTSNOOP_SCB_ADDR , +REAR_MIXER_SCB_ADDR ,SEC_CODECOUT_SCB_ADDR ,codec_in_scb,SCB_ON_PARENT_NEXT_SCB );if (!sec_codec_out_scb) goto _fail_end; + +/* create the rear PCM channel mixer SCB */ + rear_mix_scb =cs46xx_dsp_create_mix_only_scb (chip,"RearMixerSCB" , +MIX_SAMPLE_BUF3 , +REAR_MIXER_SCB_ADDR , + sec_codec_out_scb, +SCB_ON_PARENT_SUBLIST_SCB ); + ins->rear_mix_scb = rear_mix_scb; +if (!rear_mix_scb) goto _fail_end; +/* the magic snooper */ magic_snoop_scb =cs46xx_dsp_create_magic_snoop_scb (chip,"MagicSnoopSCB_I" ,OUTPUTSNOOP_SCB_ADDR ,OUTPUT_SNOOP_BUFFER , codec_out_scb, sec_codec_out_scb, -SCB_ON_PARENT_SUBLIST_SCB ); +SCB_ON_PARENT_NEXT_SCB ); +if (!magic_snoop_scb) goto _fail_end; ins->ref_snoop_scb = magic_snoop_scb;
cvs/alsa-kernel/pci/cs46xx/dsp_spos.h renamed from pci/cs46xx/dsp_spos.h +3 -1
@@ -73,7 +73,8 @@#define SPDIFI_IP_OUTPUT_BUFFER1 0x0E00#define SPDIFO_IP_OUTPUT_BUFFER1 0x1000#define MIX_SAMPLE_BUF1 0x1400 -#define MIX_SAMPLE_BUF2 0x3000 +#define MIX_SAMPLE_BUF2 0x2D00 +#define MIX_SAMPLE_BUF3 0x2E00/* Task stack address */ #define HFG_STACK 0x066A
@@ -104,6 +105,7 @@#define OUTPUTSNOOPII_SCB_ADDR 0x150#define PCMSERIALIN_PCM_SCB_ADDR 0x160#define RECORD_MIXER_SCB_ADDR 0x170 +#define REAR_MIXER_SCB_ADDR 0x180/* hyperforground SCB's*/ #define HFG_TREE_SCB 0xBA0
cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c renamed from pci/cs46xx/dsp_spos_scb_lib.c +26 -7
@@ -1093,15 +1093,29 @@ }; -pcm_channel_descriptor_t *cs46xx_dsp_create_pcm_channel (cs46xx_t * chip,u32 sample_rate,void * private_data,u32 hw_dma_addr) +pcm_channel_descriptor_t *cs46xx_dsp_create_pcm_channel (cs46xx_t * chip, +u32 sample_rate,void * private_data, +u32 hw_dma_addr, +int pcm_channel_id) {dsp_spos_instance_t * ins = chip->dsp_spos_instance; -dsp_scb_descriptor_t * src_scb =NULL ,* pcm_scb; +dsp_scb_descriptor_t * src_scb =NULL ,* pcm_scb, * mixer_scb =NULL ;/*dsp_scb_descriptor_t * pcm_parent_scb;*/ char scb_name[DSP_MAX_SCB_NAME ];int i,pcm_index =-1 , insert_point, src_index =-1 ;unsigned long flags; +switch (pcm_channel_id) { +case DSP_PCM_MAIN_CHANNEL : + mixer_scb = ins->master_mix_scb; +break ; +case DSP_PCM_REAR_CHANNEL : + mixer_scb = ins->rear_mix_scb; +break ; +default : +snd_assert (0 ); +return NULL ; + }/* default sample rate is 44100 */ if (!sample_rate) sample_rate =44100 ;
@@ -1114,7 +1128,9 @@if (i ==CS46XX_DSP_CAPTURE_CHANNEL )continue ;if (ins->pcm_channels[i].active) { -if (!src_scb && ins->pcm_channels[i].sample_rate == sample_rate) { +if (!src_scb && + ins->pcm_channels[i].sample_rate == sample_rate && + ins->pcm_channels[i].mixer_scb == mixer_scb) { src_scb = ins->pcm_channels[i].src_scb; ins->pcm_channels[i].src_scb->ref_count ++; src_index = ins->pcm_channels[i].src_slot;
@@ -1148,11 +1164,11 @@ snd_assert (src_index != -1,return NULL);/* we need to create a new SRC SCB */ -if (ins->master_mix_scb->sub_list_ptr == ins->the_null_scb) { - src_parent_scb = ins->master_mix_scb; +if (mixer_scb->sub_list_ptr == ins->the_null_scb) { + src_parent_scb = mixer_scb; insert_point =SCB_ON_PARENT_SUBLIST_SCB ; }else { - src_parent_scb =find_next_free_scb (chip,ins->master_mix_scb->sub_list_ptr); + src_parent_scb =find_next_free_scb (chip,mixer_scb->sub_list_ptr); insert_point =SCB_ON_PARENT_NEXT_SCB ; }
@@ -1180,7 +1196,8 @@snprintf (scb_name,DSP_MAX_SCB_NAME ,"PCMReader_SCB%d" ,pcm_index); -snd_printdd ("dsp_spos: creating PCM \"%s\"\n" ,scb_name); +snd_printdd ("dsp_spos: creating PCM \"%s\" (%d)\n" ,scb_name, + pcm_channel_id); pcm_scb = cs46xx_dsp_create_pcm_reader_scb(chip,scb_name, pcm_reader_buffer_addr[pcm_index],
@@ -1206,6 +1223,8 @@ ins->pcm_channels[pcm_index].src_slot = src_index; ins->pcm_channels[pcm_index].active =1 ; ins->pcm_channels[pcm_index].pcm_slot = pcm_index; + ins->pcm_channels[pcm_index].mixer_scb = mixer_scb; + ins->pcm_channels[pcm_index].pcm_channel_id = pcm_channel_id; ins->npcm_channels ++;spin_unlock_irqrestore (&chip->reg_lock, flags);