emu10k1 cleanups
PATCH 1/1 emu10k1 cleanups
I hacked this up quickly, please review.
Some of these should probably be macros, like
IS_AUDIGY2(emu)
for
emu->card_capabilities->ca0108_chip || emu->card_capabilities->ca0151_chip
etc.
This will break binary compatibility as some redundant struct members have been removed.
Lee
Index: alsa-kernel/include/emu10k1.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/include/emu10k1.h,v retrieving revision 1.68
include/emu10k1.h +1 -2
@@ -1062,7 +1062,7 @@unsigned char emu10k2_chip;/* Audigy 1 or Audigy 2. */ unsigned char ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ unsigned char ca0108_chip;/* Audigy 2 Value */ -unsigned char ca0151_chip;/* P16V */ +unsigned char ca0151_chip;/* Audigy 2. Not SB Audigy 2 Value. AKA P16V */ unsigned char spk71;/* Has 7.1 speakers */ unsigned char sblive51;/* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ unsigned char spdif_bug;/* Has Spdif phasing bug */
@@ -1080,7 +1080,6 @@ unsigned int tos_link: 1, /* tos link detected */ rear_ac97: 1; /* rear channels are on AC'97 */const emu_chip_details_t *card_capabilities;/* Contains profile of card capabilities */ -unsigned int audigy;/* is Audigy? */ unsigned int revision;/* chip revision */ unsigned int serial;/* serial number */ unsigned short model;/* subsystem id */
Index: alsa-kernel/pci/emu10k1/emu10k1.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1.c,v retrieving revision 1.36
pci/emu10k1/emu10k1.c +3 -3
@@ -140,7 +140,7 @@return err; }/* This stores the periods table. */ -if (emu->audigy && emu->revision ==4 ) {/* P16V */ +if (emu->card_capabilities->ca0108_chip || emu->card_capabilities->ca0151_chip) {/* P16V */ if (snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV ,snd_dma_pci_data (pci),1024 , &emu->p16v_buffer) <0 ) {snd_p16v_free (emu);return -ENOMEM ;
@@ -161,13 +161,13 @@snd_card_free (card);return err; } -if (emu->audigy && emu->revision ==4 ) {/* P16V */ +if (emu->card_capabilities->ca0108_chip || emu->card_capabilities->ca0151_chip) {/* P16V */ if ((err =snd_p16v_pcm (emu,4 ,NULL )) <0 ) {snd_card_free (card);return err; } } -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) {if ((err =snd_emu10k1_audigy_midi (emu)) <0 ) {snd_card_free (card);return err;
Index: alsa-kernel/pci/emu10k1/emu10k1_callback.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_callback.c,v retrieving revision 1.13
pci/emu10k1/emu10k1_callback.c +1 -1
@@ -338,7 +338,7 @@/* set channel routing */ /* A = left(0), B = right(1), C = reverb(c), D = chorus(d) */ -if (hw->audigy) { +if (hw->card_capabilities->emu10k2_chip) { temp =FXBUS_MIDI_LEFT | (FXBUS_MIDI_RIGHT <<8 ) | (FXBUS_MIDI_REVERB <<16 ) | (FXBUS_MIDI_CHORUS <<24 );snd_emu10k1_ptr_write (hw,A_FXRT1 , ch, temp);
Index: alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.57
pci/emu10k1/emu10k1_main.c +17 -25
120 lines not on this page · raw message
Index: alsa-kernel/pci/emu10k1/emu10k1_synth.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_synth.c,v retrieving revision 1.10
pci/emu10k1/emu10k1_synth.c +1 -1
@@ -56,7 +56,7 @@ emu->pitch_shift =-501 ; emu->memhdr = hw->memhdr; emu->midi_ports = arg->seq_ports <2 ? arg->seq_ports :2 ;/* maximum two ports */ - emu->midi_devidx = hw->audigy ?2 :1 ;/* audigy has two external midis */ + emu->midi_devidx = hw->card_capabilities->emu10k2_chip ?2 :1 ;/* audigy has two external midis */ emu->linear_panning =0 ; emu->hwdep_idx =2 ;/* FIXED */
Index: alsa-kernel/pci/emu10k1/emufx.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emufx.c,v retrieving revision 1.74
pci/emu10k1/emufx.c +23 -23
168 lines not on this page · raw message
Index: alsa-kernel/pci/emu10k1/emumixer.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emumixer.c,v retrieving revision 1.37
pci/emu10k1/emumixer.c +27 -27
181 lines not on this page · raw message
Index: alsa-kernel/pci/emu10k1/emumpu401.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emumpu401.c,v retrieving revision 1.14
pci/emu10k1/emumpu401.c +2 -2
@@ -30,7 +30,7 @@static inline unsigned char mpu401_read (emu10k1_t *emu,emu10k1_midi_t *mpu,int idx) { -if (emu->audigy) +if (emu->card_capabilities->emu10k2_chip)return (unsigned char )snd_emu10k1_ptr_read (emu, mpu->port + idx,0 );else return inb (emu->port + mpu->port + idx);
@@ -38,7 +38,7 @@static inline void mpu401_write (emu10k1_t *emu,emu10k1_midi_t *mpu,int data,int idx) { -if (emu->audigy) +if (emu->card_capabilities->emu10k2_chip)snd_emu10k1_ptr_write (emu, mpu->port + idx,0 , data);else outb (data, emu->port + mpu->port + idx);
Index: alsa-kernel/pci/emu10k1/emupcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emupcm.c,v retrieving revision 1.47
pci/emu10k1/emupcm.c +15 -15
@@ -336,7 +336,7 @@ }// setup routing -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) {snd_emu10k1_ptr_write (emu,A_FXRT1 , voice,snd_emu10k1_compose_audigy_fxrt1 (send_routing)); snd_emu10k1_ptr_write(emu, A_FXRT2, voice,
@@ -585,7 +585,7 @@snd_emu10k1_ptr_write (emu,ADCCR ,0 ,0 );break ;case CAPTURE_EFX : -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) {snd_emu10k1_ptr_write (emu,A_FXWC1 ,0 ,0 );snd_emu10k1_ptr_write (emu,A_FXWC2 ,0 ,0 ); }else
@@ -608,10 +608,10 @@ epcm->capture_bs_val++; }if (epcm->type ==CAPTURE_AC97ADC ) { - epcm->capture_cr_val = emu->audigy ?A_ADCCR_LCHANENABLE :ADCCR_LCHANENABLE ; + epcm->capture_cr_val = emu->card_capabilities->emu10k2_chip ?A_ADCCR_LCHANENABLE :ADCCR_LCHANENABLE ;if (runtime->channels >1 ) - epcm->capture_cr_val |= emu->audigy ?A_ADCCR_RCHANENABLE :ADCCR_RCHANENABLE ; - epcm->capture_cr_val |= emu->audigy ? + epcm->capture_cr_val |= emu->card_capabilities->emu10k2_chip ?A_ADCCR_RCHANENABLE :ADCCR_RCHANENABLE ; + epcm->capture_cr_val |= emu->card_capabilities->emu10k2_chip ?snd_emu10k1_audigy_capture_rate_reg (runtime->rate) :snd_emu10k1_capture_rate_reg (runtime->rate); }
@@ -777,7 +777,7 @@snd_emu10k1_ptr_write (emu,ADCCR ,0 , epcm->capture_cr_val);break ;case CAPTURE_EFX : -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) {snd_emu10k1_ptr_write (emu,A_FXWC1 ,0 , epcm->capture_cr_val);snd_emu10k1_ptr_write (emu,A_FXWC2 ,0 , epcm->capture_cr_val2); }else
@@ -800,7 +800,7 @@snd_emu10k1_ptr_write (emu,ADCCR ,0 ,0 );break ;case CAPTURE_EFX : -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) {snd_emu10k1_ptr_write (emu,A_FXWC1 ,0 ,0 );snd_emu10k1_ptr_write (emu,A_FXWC2 ,0 ,0 ); }else
@@ -1106,7 +1106,7 @@ epcm->capture_inte =INTE_ADCBUFENABLE ; epcm->capture_ba_reg =ADCBA ; epcm->capture_bs_reg =ADCBS ; - epcm->capture_idx_reg = emu->audigy ?A_ADCIDX :ADCIDX ; + epcm->capture_idx_reg = emu->card_capabilities->emu10k2_chip ?A_ADCIDX :ADCIDX ; runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture;
@@ -1142,7 +1142,7 @@ epcm->capture_inte =INTE_MICBUFENABLE ; epcm->capture_ba_reg =MICBA ; epcm->capture_bs_reg =MICBS ; - epcm->capture_idx_reg = emu->audigy ?A_MICIDX :MICIDX ; + epcm->capture_idx_reg = emu->card_capabilities->emu10k2_chip ?A_MICIDX :MICIDX ; substream->runtime->private_data = epcm; substream->runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture;
@@ -1169,7 +1169,7 @@emu10k1_t *emu =snd_pcm_substream_chip (substream);emu10k1_pcm_t *epcm;snd_pcm_runtime_t *runtime = substream->runtime; -int nefx = emu->audigy ?64 :32 ; +int nefx = emu->card_capabilities->emu10k2_chip ?64 :32 ;int idx; epcm =kcalloc (1 ,sizeof (*epcm),GFP_KERNEL );
@@ -1374,7 +1374,7 @@static int snd_emu10k1_pcm_efx_voices_mask_info (snd_kcontrol_t *kcontrol,snd_ctl_elem_info_t * uinfo) {emu10k1_t *emu =snd_kcontrol_chip (kcontrol); -int nefx = emu->audigy ?64 :32 ; +int nefx = emu->card_capabilities->emu10k2_chip ?64 :32 ; uinfo->type =SNDRV_CTL_ELEM_TYPE_BOOLEAN ; uinfo->count = nefx; uinfo->value.integer.min =0 ;
@@ -1385,7 +1385,7 @@static int snd_emu10k1_pcm_efx_voices_mask_get (snd_kcontrol_t * kcontrol,snd_ctl_elem_value_t * ucontrol) {emu10k1_t *emu =snd_kcontrol_chip (kcontrol); -int nefx = emu->audigy ?64 :32 ; +int nefx = emu->card_capabilities->emu10k2_chip ?64 :32 ;int idx;spin_lock_irq (&emu->reg_lock);
@@ -1399,8 +1399,8 @@ {emu10k1_t *emu =snd_kcontrol_chip (kcontrol);unsigned int nval[2 ], bits; -int nefx = emu->audigy ?64 :32 ; -int nefxb = emu->audigy ?7 :6 ; +int nefx = emu->card_capabilities->emu10k2_chip ?64 :32 ; +int nefxb = emu->card_capabilities->emu10k2_chip ?7 :6 ;int change, idx; nval[0 ] = nval[1 ] =0 ;
@@ -1709,7 +1709,7 @@*/ /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) { emu->efx_voices_mask[0 ] =0 ; emu->efx_voices_mask[1 ] =0xffff ; }else {
Index: alsa-kernel/pci/emu10k1/emuproc.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emuproc.c,v retrieving revision 1.30
pci/emu10k1/emuproc.c +16 -16
@@ -183,25 +183,25 @@emu10k1_t *emu = entry->private_data;unsigned int val, val1; -int nefx = emu->audigy ?64 :32 ; -char **outputs = emu->audigy ? audigy_outs : creative_outs; +int nefx = emu->card_capabilities->emu10k2_chip ?64 :32 ; +char **outputs = emu->card_capabilities->emu10k2_chip ? audigy_outs : creative_outs;int idx;snd_iprintf (buffer,"EMU10K1\n\n" );snd_iprintf (buffer,"Card : %s\n" , - emu->audigy ?"Audigy" : (emu->card_capabilities->ecard ?"EMU APS" :"Creative" )); + emu->card_capabilities->emu10k2_chip ?"Audigy" : (emu->card_capabilities->ecard ?"EMU APS" :"Creative" ));snd_iprintf (buffer,"Internal TRAM (words) : 0x%x\n" , emu->fx8010.itram_size);snd_iprintf (buffer,"External TRAM (words) : 0x%x\n" , (int )emu->fx8010.etram_pages.bytes /2 );snd_iprintf (buffer,"\n" );snd_iprintf (buffer,"Effect Send Routing :\n" );for (idx =0 ; idx <NUM_G ; idx++) { - val = emu->audigy ? + val = emu->card_capabilities->emu10k2_chip ?snd_emu10k1_ptr_read (emu,A_FXRT1 , idx) :snd_emu10k1_ptr_read (emu,FXRT , idx); - val1 = emu->audigy ? + val1 = emu->card_capabilities->emu10k2_chip ?snd_emu10k1_ptr_read (emu,A_FXRT2 , idx) :0 ; -if (emu->audigy) { +if (emu->card_capabilities->emu10k2_chip) { snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i, ", idx, val & 0x3f,
@@ -228,7 +228,7 @@snd_iprintf (buffer," Output %02i [%s]\n" , idx, outputs[idx]); }snd_iprintf (buffer,"\nAll FX Outputs :\n" ); -for (idx =0 ; idx < (emu->audigy ?64 :32 ); idx++) +for (idx =0 ; idx < (emu->card_capabilities->emu10k2_chip ?64 :32 ); idx++)snd_iprintf (buffer," Output %02i [%s]\n" , idx, outputs[idx]); }
@@ -269,12 +269,12 @@snd_iprintf (buffer,"FX8010 Instruction List '%s'\n" , emu->fx8010.name);snd_iprintf (buffer," Code dump :\n" ); -for (pc =0 ; pc < (emu->audigy ?1024 :512 ); pc++) { +for (pc =0 ; pc < (emu->card_capabilities->emu10k2_chip ?1024 :512 ); pc++) {u32 low, high; low =snd_emu10k1_efx_read (emu, pc *2 ); high =snd_emu10k1_efx_read (emu, pc *2 +1 ); -if (emu->audigy) +if (emu->card_capabilities->emu10k2_chip) snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n", (high >> 24) & 0x0f, (high >> 12) & 0x7ff,
@@ -319,9 +319,9 @@ }else if (!strcmp (entry->name,"fx8010_tram_data" )) { offset =TANKMEMDATAREGBASE ; }else if (!strcmp (entry->name,"fx8010_code" )) { - offset = emu->audigy ?A_MICROCODEBASE :MICROCODEBASE ; + offset = emu->card_capabilities->emu10k2_chip ?A_MICROCODEBASE :MICROCODEBASE ; }else { - offset = emu->audigy ?A_FXGPREGBASE :FXGPREGBASE ; + offset = emu->card_capabilities->emu10k2_chip ?A_FXGPREGBASE :FXGPREGBASE ; } size = count;if (pos + size > entry->size)
@@ -333,7 +333,7 @@if ((tmp =kmalloc (size +8 ,GFP_KERNEL )) ==NULL )return -ENOMEM ;for (idx =0 ; idx < ((pos &3 ) + size +3 ) >>2 ; idx++) -if (tram_addr && emu->audigy) { +if (tram_addr && emu->card_capabilities->emu10k2_chip) { tmp[idx] =snd_emu10k1_ptr_read (emu, offset + idx + (pos >>2 ),0 ) >>11 ; tmp[idx] |=snd_emu10k1_ptr_read (emu,0x100 + idx + (pos >>2 ),0 ) <<20 ; }else
@@ -574,28 +574,28 @@ entry->content =SNDRV_INFO_CONTENT_DATA ; entry->private_data = emu; entry->mode =S_IFREG |S_IRUGO /*| S_IWUSR*/ ; - entry->size = emu->audigy ?A_TOTAL_SIZE_GPR :TOTAL_SIZE_GPR ; + entry->size = emu->card_capabilities->emu10k2_chip ?A_TOTAL_SIZE_GPR :TOTAL_SIZE_GPR ; entry->c.ops = &snd_emu10k1_proc_ops_fx8010; }if (!snd_card_proc_new (emu->card,"fx8010_tram_data" , &entry)) { entry->content =SNDRV_INFO_CONTENT_DATA ; entry->private_data = emu; entry->mode =S_IFREG |S_IRUGO /*| S_IWUSR*/ ; - entry->size = emu->audigy ?A_TOTAL_SIZE_TANKMEM_DATA :TOTAL_SIZE_TANKMEM_DATA ; + entry->size = emu->card_capabilities->emu10k2_chip ?A_TOTAL_SIZE_TANKMEM_DATA :TOTAL_SIZE_TANKMEM_DATA ; entry->c.ops = &snd_emu10k1_proc_ops_fx8010; }if (!snd_card_proc_new (emu->card,"fx8010_tram_addr" , &entry)) { entry->content =SNDRV_INFO_CONTENT_DATA ; entry->private_data = emu; entry->mode =S_IFREG |S_IRUGO /*| S_IWUSR*/ ; - entry->size = emu->audigy ?A_TOTAL_SIZE_TANKMEM_ADDR :TOTAL_SIZE_TANKMEM_ADDR ; + entry->size = emu->card_capabilities->emu10k2_chip ?A_TOTAL_SIZE_TANKMEM_ADDR :TOTAL_SIZE_TANKMEM_ADDR ; entry->c.ops = &snd_emu10k1_proc_ops_fx8010; }if (!snd_card_proc_new (emu->card,"fx8010_code" , &entry)) { entry->content =SNDRV_INFO_CONTENT_DATA ; entry->private_data = emu; entry->mode =S_IFREG |S_IRUGO /*| S_IWUSR*/ ; - entry->size = emu->audigy ?A_TOTAL_SIZE_CODE :TOTAL_SIZE_CODE ; + entry->size = emu->card_capabilities->emu10k2_chip ?A_TOTAL_SIZE_CODE :TOTAL_SIZE_CODE ; entry->c.ops = &snd_emu10k1_proc_ops_fx8010; }if (!snd_card_proc_new (emu->card,"fx8010_acode" , &entry)) {
Index: alsa-kernel/pci/emu10k1/io.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/io.c,v retrieving revision 1.10
pci/emu10k1/io.c +2 -2
@@ -36,7 +36,7 @@unsigned int regptr, val;unsigned int mask; - mask = emu->audigy ?A_PTR_ADDRESS_MASK :PTR_ADDRESS_MASK ; + mask = emu->card_capabilities->emu10k2_chip ?A_PTR_ADDRESS_MASK :PTR_ADDRESS_MASK ; regptr = ((reg <<16 ) & mask) | (chn &PTR_CHANNELNUM_MASK );if (reg &0xff000000 ) {
@@ -67,7 +67,7 @@unsigned long flags;unsigned int mask; - mask = emu->audigy ?A_PTR_ADDRESS_MASK :PTR_ADDRESS_MASK ; + mask = emu->card_capabilities->emu10k2_chip ?A_PTR_ADDRESS_MASK :PTR_ADDRESS_MASK ; regptr = ((reg <<16 ) & mask) | (chn &PTR_CHANNELNUM_MASK );if (reg &0xff000000 ) {
Index: alsa-kernel/pci/emu10k1/irq.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/irq.c,v retrieving revision 1.15
pci/emu10k1/irq.c +1 -1
@@ -191,7 +191,7 @@INTE_INTERVALTIMERENB |INTE_MIDITXENABLE |INTE_MIDIRXENABLE ; -if (emu->audigy) +if (emu->card_capabilities->emu10k2_chip) bits |=INTE_A_MIDITXENABLE2 |INTE_A_MIDIRXENABLE2 ;snd_emu10k1_intr_disable (emu, bits); }
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
Quoted 8 lines · Lee Revell
I hacked this up quickly, please review.
Some of these should probably be macros, like
IS_AUDIGY2(emu)for
Quoted 8 lines
emu->card_capabilities->ca0108_chip || emu->card_capabilities->ca0151_chipetc.
This will break binary compatibility as some redundant struct members have been removed.
Lee
Sorry, I can't accept this patch.
Different chips have different capabilities, and the ca0108(Audigy 2 Value) certainly does not have a ca0151 (P16V) chip.
The ca0102 is the DSP chip on Audigy 2 cards (and possibly Audigy 1, I don't know for sure).
emu10k2 is to indicate that the card has all the same features of the DSP chip found on Audigy 1 and Audigy 2 and Audigy 2 Value cards. So, the information is not redundent.
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
Quoted 3 lines · James Courtier-Dutton
Sorry, I can't accept this patch.
Different chips have different capabilities, and the ca0108(Audigy 2 Value) certainly does not have a ca0151 (P16V) chip.
That's why I used || rather than &&. But I see your point.
Quoted 6 lines
The ca0102 is the DSP chip on Audigy 2 cards (and possibly Audigy 1, I don't know for sure).
emu10k2 is to indicate that the card has all the same features of the DSP chip found on Audigy 1 and Audigy 2 and Audigy 2 Value cards. So, the information is not redundent.
OK, thanks for the info. That's why I posted the rough version before spending any serious time on it.
Lee
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005