ALSA: emu10k1: use more existing defines instead of open-coded numbers
PATCH RESEND 1/1 ALSA: emu10k1: use more existing defines instead of open-coded numbers
Using the *_MASK defines for "maximal value" is debatable. I got the idea from FreeBSD, and it sorta makes sense to me.
Some hunks look a bit incomplete, because code that is going to be subsequently removed is not touched here.
---
this failed to build previously due to a missed logical dependency on the "use high-level I/O functions also during init" patch. that patch was applied meanwhile, so it's now safe to apply this one as well.
--- sound/pci/emu10k1/emu10k1_callback.c | 15 ++++----- sound/pci/emu10k1/emu10k1_main.c | 46 ++++++++++++++-------------- sound/pci/emu10k1/emufx.c | 6 ++-- sound/pci/emu10k1/emumixer.c | 8 ++--- sound/pci/emu10k1/emupcm.c | 12 ++++---- sound/pci/emu10k1/io.c | 18 +++++------ sound/pci/emu10k1/p16v.c | 29 ++++++++++-------- 7 files changed, 69 insertions(+), 65 deletions(-)
sound/pci/emu10k1/emu10k1_callback.c +8 -7
@@ -120,9 +120,9 @@ release_voice(struct snd_emux_voice *vp)struct snd_emu10k1 *hw; hw = vp->hw; - dcysusv =0x8000 | (unsigned char )vp->reg.parm.modrelease; + dcysusv = (unsigned char )vp->reg.parm.modrelease |DCYSUSM_PHASE1_MASK ;snd_emu10k1_ptr_write (hw,DCYSUSM , vp->ch, dcysusv); - dcysusv =0x8000 | (unsigned char )vp->reg.parm.volrelease |DCYSUSV_CHANNELENABLE_MASK ; + dcysusv = (unsigned char )vp->reg.parm.volrelease |DCYSUSV_PHASE1_MASK |DCYSUSV_CHANNELENABLE_MASK ;snd_emu10k1_ptr_write (hw,DCYSUSV , vp->ch, dcysusv); }
@@ -138,7 +138,8 @@ terminate_voice(struct snd_emux_voice *vp)if (snd_BUG_ON (!vp))return ; hw = vp->hw; -snd_emu10k1_ptr_write (hw,DCYSUSV , vp->ch,0x807f |DCYSUSV_CHANNELENABLE_MASK ); +snd_emu10k1_ptr_write (hw,DCYSUSV , vp->ch, +DCYSUSV_PHASE1_MASK |DCYSUSV_DECAYTIME_MASK |DCYSUSV_CHANNELENABLE_MASK );if (vp->block) {struct snd_emu10k1_memblk *emem; emem = (struct snd_emu10k1_memblk *)vp->block;
@@ -347,9 +348,9 @@ start_voice(struct snd_emux_voice *vp) }/* channel to be silent and idle */ -snd_emu10k1_ptr_write (hw,DCYSUSV , ch,0x0000 ); -snd_emu10k1_ptr_write (hw,VTFT , ch,0x0000FFFF ); -snd_emu10k1_ptr_write (hw,CVCF , ch,0x0000FFFF ); +snd_emu10k1_ptr_write (hw,DCYSUSV , ch,0 ); +snd_emu10k1_ptr_write (hw,VTFT , ch,VTFT_FILTERTARGET_MASK ); +snd_emu10k1_ptr_write (hw,CVCF , ch,CVCF_CURRENTFILTER_MASK );snd_emu10k1_ptr_write (hw,PTRX , ch,0 );snd_emu10k1_ptr_write (hw,CPF , ch,0 );
@@ -453,7 +454,7 @@ start_voice(struct snd_emux_voice *vp)/* reset volume */ temp = (unsigned int )vp->vtarget <<16 ;snd_emu10k1_ptr_write (hw,VTFT , ch, temp | vp->ftarget); -snd_emu10k1_ptr_write (hw,CVCF , ch, temp |0xff00 ); +snd_emu10k1_ptr_write (hw,CVCF , ch, temp |CVCF_CURRENTFILTER_MASK );return 0 ; }
sound/pci/emu10k1/emu10k1_main.c +23 -23
105 lines not on this page · raw message
sound/pci/emu10k1/emufx.c +3 -3
@@ -1355,7 +1355,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) gpr +=2 ;/* mic capture buffer */ -A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),0xcd ,A_EXTIN (A_EXTIN_AC97_R )); +A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),A_C_40000000 ,A_EXTIN (A_EXTIN_AC97_R ));/* Audigy CD Playback Volume */ A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_SPDIF_CD_L );
@@ -1438,7 +1438,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))/* Stereo Mix Center Playback */ /* Center = sub = Left/2 + Right/2 */ -A_OP (icode, &ptr, iINTERP,A_GPR (tmp),A_GPR (stereo_mix),0xcd ,A_GPR (stereo_mix+1 )); +A_OP (icode, &ptr, iINTERP,A_GPR (tmp),A_GPR (stereo_mix),A_C_40000000 ,A_GPR (stereo_mix+1 ));A_OP (icode, &ptr, iMAC0,A_GPR (playback+4 ),A_GPR (playback+4 ),A_GPR (gpr),A_GPR (tmp));snd_emu10k1_init_mono_control (&controls[nctl++],"Center Playback Volume" , gpr,0 ); gpr++;
@@ -2478,7 +2478,7 @@ int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size)outl (HCFG_LOCKTANKCACHE_MASK |inl (emu->port +HCFG ), emu->port +HCFG );spin_unlock_irq (&emu->emu_lock);snd_emu10k1_ptr_write (emu,TCB ,0 ,0 ); -snd_emu10k1_ptr_write (emu,TCBS ,0 ,0 ); +snd_emu10k1_ptr_write (emu,TCBS ,0 ,TCBS_BUFFSIZE_16K );if (emu->fx8010.etram_pages.area !=NULL ) {snd_dma_free_pages (&emu->fx8010.etram_pages); emu->fx8010.etram_pages.area =NULL ;
sound/pci/emu10k1/emumixer.c +4 -4
@@ -827,8 +827,8 @@ static int snd_emu1010_optical_out_put(struct snd_kcontrol *kcontrol, change = (emu->emu1010.optical_out != val);if (change) { emu->emu1010.optical_out = val; - tmp = (emu->emu1010.optical_in ?EMU_HANA_OPTICAL_IN_ADAT :0 ) | - (emu->emu1010.optical_out ?EMU_HANA_OPTICAL_OUT_ADAT :0 ); + tmp = (emu->emu1010.optical_in ?EMU_HANA_OPTICAL_IN_ADAT :EMU_HANA_OPTICAL_IN_SPDIF ) | + (emu->emu1010.optical_out ?EMU_HANA_OPTICAL_OUT_ADAT :EMU_HANA_OPTICAL_OUT_SPDIF );snd_emu1010_fpga_write (emu,EMU_HANA_OPTICAL_TYPE , tmp); }return change;
@@ -878,8 +878,8 @@ static int snd_emu1010_optical_in_put(struct snd_kcontrol *kcontrol, change = (emu->emu1010.optical_in != val);if (change) { emu->emu1010.optical_in = val; - tmp = (emu->emu1010.optical_in ?EMU_HANA_OPTICAL_IN_ADAT :0 ) | - (emu->emu1010.optical_out ?EMU_HANA_OPTICAL_OUT_ADAT :0 ); + tmp = (emu->emu1010.optical_in ?EMU_HANA_OPTICAL_IN_ADAT :EMU_HANA_OPTICAL_IN_SPDIF ) | + (emu->emu1010.optical_out ?EMU_HANA_OPTICAL_OUT_ADAT :EMU_HANA_OPTICAL_OUT_SPDIF );snd_emu1010_fpga_write (emu,EMU_HANA_OPTICAL_TYPE , tmp); }return change;
sound/pci/emu10k1/emupcm.c +6 -6
@@ -352,8 +352,8 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,snd_emu10k1_ptr_write (emu,MAPA , voice, silent_page);snd_emu10k1_ptr_write (emu,MAPB , voice, silent_page);/* modulation envelope */ -snd_emu10k1_ptr_write (emu,CVCF , voice,0xffff ); -snd_emu10k1_ptr_write (emu,VTFT , voice,0xffff ); +snd_emu10k1_ptr_write (emu,VTFT , voice,VTFT_FILTERTARGET_MASK ); +snd_emu10k1_ptr_write (emu,CVCF , voice,CVCF_CURRENTFILTER_MASK );snd_emu10k1_ptr_write (emu,ATKHLDM , voice,0 );snd_emu10k1_ptr_write (emu,DCYSUSM , voice,0x007f );snd_emu10k1_ptr_write (emu,LFOVAL1 , voice,0x8000 );
@@ -621,8 +621,8 @@ static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1 *emu, struct s tmp = runtime->channels ==2 ? (master ?1 :2 ) :0 ; vattn = mix !=NULL ? (mix->attn[tmp] <<16 ) :0 ;snd_emu10k1_ptr_write (emu,IFATN , voice, attn); -snd_emu10k1_ptr_write (emu,VTFT , voice, vattn |0xffff ); -snd_emu10k1_ptr_write (emu,CVCF , voice, vattn |0xffff ); +snd_emu10k1_ptr_write (emu,VTFT , voice, vattn |VTFT_FILTERTARGET_MASK ); +snd_emu10k1_ptr_write (emu,CVCF , voice, vattn |CVCF_CURRENTFILTER_MASK );snd_emu10k1_ptr_write (emu,DCYSUSV , voice,0x7f7f );snd_emu10k1_voice_clear_loop_stop (emu, voice); }
@@ -663,8 +663,8 @@ static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1 *emu, struct snd_snd_emu10k1_ptr_write (emu,PTRX_PITCHTARGET , voice,0 );snd_emu10k1_ptr_write (emu,CPF_CURRENTPITCH , voice,0 );snd_emu10k1_ptr_write (emu,IFATN , voice,0xffff ); -snd_emu10k1_ptr_write (emu,VTFT , voice,0xffff ); -snd_emu10k1_ptr_write (emu,CVCF , voice,0xffff ); +snd_emu10k1_ptr_write (emu,VTFT , voice,VTFT_FILTERTARGET_MASK ); +snd_emu10k1_ptr_write (emu,CVCF , voice,CVCF_CURRENTFILTER_MASK );snd_emu10k1_ptr_write (emu,IP , voice,0 ); }
sound/pci/emu10k1/io.c +9 -9
@@ -95,8 +95,8 @@ unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, regptr = (reg <<16 ) | chn;spin_lock_irqsave (&emu->emu_lock, flags); -outl (regptr, emu->port +0x20 +PTR ); - val =inl (emu->port +0x20 +DATA ); +outl (regptr, emu->port +PTR2 ); + val =inl (emu->port +DATA2 );spin_unlock_irqrestore (&emu->emu_lock, flags);return val; }
@@ -112,8 +112,8 @@ void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, regptr = (reg <<16 ) | chn;spin_lock_irqsave (&emu->emu_lock, flags); -outl (regptr, emu->port +0x20 +PTR ); -outl (data, emu->port +0x20 +DATA ); +outl (regptr, emu->port +PTR2 ); +outl (data, emu->port +DATA2 );spin_unlock_irqrestore (&emu->emu_lock, flags); }
@@ -128,7 +128,7 @@ int snd_emu10k1_spi_write(struct snd_emu10k1 * emu,/* This function is not re-entrant, so protect against it. */ spin_lock (&emu->spi_lock);if (emu->card_capabilities->ca0108_chip) - reg =0x3c ;/* PTR20, reg 0x3c */ + reg =P17V_SPI ;else {/* For other chip types the SPI register * is currently unknown. */
@@ -280,10 +280,10 @@ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 sreturn ;if (snd_BUG_ON (src & ~0x71f ))return ; -snd_emu1010_fpga_write (emu,0x00 , dst >>8 ); -snd_emu1010_fpga_write (emu,0x01 , dst &0x1f ); -snd_emu1010_fpga_write (emu,0x02 , src >>8 ); -snd_emu1010_fpga_write (emu,0x03 , src &0x1f ); +snd_emu1010_fpga_write (emu,EMU_HANA_DESTHI , dst >>8 ); +snd_emu1010_fpga_write (emu,EMU_HANA_DESTLO , dst &0x1f ); +snd_emu1010_fpga_write (emu,EMU_HANA_SRCHI , src >>8 ); +snd_emu1010_fpga_write (emu,EMU_HANA_SRCLO , src &0x1f ); }void snd_emu10k1_intr_enable (struct snd_emu10k1 *emu,unsigned int intrenb)
sound/pci/emu10k1/p16v.c +16 -13
@@ -254,19 +254,24 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) emu->p16v_buffer->bytes);#endif /* debug */ tmp =snd_emu10k1_ptr_read (emu,A_SPDIF_SAMPLERATE , channel); + tmp &= ~(A_SPDIF_RATE_MASK |A_EHC_SRC48_MASK );switch (runtime->rate) {case 44100 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0xe0e0 ) |0x8080 ); +snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, + tmp |A_SPDIF_44100 |A_EHC_SRC48_44 );break ;case 96000 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0xe0e0 ) |0x4040 ); +snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, + tmp |A_SPDIF_96000 |A_EHC_SRC48_96 );break ;case 192000 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0xe0e0 ) |0x2020 ); +snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, + tmp |A_SPDIF_192000 |A_EHC_SRC48_192 );break ;case 48000 :default : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0xe0e0 ) |0x0000 ); +snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, + tmp |A_SPDIF_48000 |A_EHC_SRC48_BYPASS );break ; }/* FIXME: Check emu->buffer.size before actually writing to it. */
@@ -282,46 +287,44 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)//snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes snd_emu10k1_ptr20_write (emu,PLAYBACK_PERIOD_SIZE , channel,0 );// buffer size in bytes snd_emu10k1_ptr20_write (emu,PLAYBACK_POINTER , channel,0 ); -snd_emu10k1_ptr20_write (emu,0x07 , channel,0x0 ); -snd_emu10k1_ptr20_write (emu,0x08 , channel,0 ); +snd_emu10k1_ptr20_write (emu,PLAYBACK_FIFO_END_ADDRESS , channel,0 ); +snd_emu10k1_ptr20_write (emu,PLAYBACK_FIFO_POINTER , channel,0 );return 0 ; }/* prepare capture callback */ static int snd_p16v_pcm_prepare_capture (struct snd_pcm_substream *substream) {struct snd_emu10k1 *emu =snd_pcm_substream_chip (substream);struct snd_pcm_runtime *runtime = substream->runtime;int channel = substream->pcm->device - emu->p16v_device_offset; -u32 tmp;/* dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, " "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, " "frames_to_bytes=%d\n", channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); */ - tmp =snd_emu10k1_ptr_read (emu,A_SPDIF_SAMPLERATE , channel);switch (runtime->rate) {case 44100 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0x0e00 ) |0x0800 ); +snd_emu10k1_ptr_write (emu,A_I2S_CAPTURE_RATE , channel,A_I2S_CAPTURE_44100 );break ;case 96000 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0x0e00 ) |0x0400 ); +snd_emu10k1_ptr_write (emu,A_I2S_CAPTURE_RATE , channel,A_I2S_CAPTURE_96000 );break ;case 192000 : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0x0e00 ) |0x0200 ); +snd_emu10k1_ptr_write (emu,A_I2S_CAPTURE_RATE , channel,A_I2S_CAPTURE_192000 );break ;case 48000 :default : -snd_emu10k1_ptr_write (emu,A_SPDIF_SAMPLERATE , channel, (tmp & ~0x0e00 ) |0x0000 ); +snd_emu10k1_ptr_write (emu,A_I2S_CAPTURE_RATE , channel,A_I2S_CAPTURE_48000 );break ; }/* FIXME: Check emu->buffer.size before actually writing to it. */ -snd_emu10k1_ptr20_write (emu,0x13 , channel,0 ); +snd_emu10k1_ptr20_write (emu,CAPTURE_FIFO_POINTER , channel,0 );snd_emu10k1_ptr20_write (emu,CAPTURE_DMA_ADDR , channel, runtime->dma_addr);snd_emu10k1_ptr20_write (emu,CAPTURE_BUFFER_SIZE , channel,frames_to_bytes (runtime, runtime->buffer_size) <<16 );// buffer size in bytes snd_emu10k1_ptr20_write (emu,CAPTURE_POINTER , channel,0 );
Signature · 1 line
2.40.0.152.g15d061e6df
Takashi Iwai
AppliedQuoted 7 lines · Oswald Buddenhagen
Using the
*_MASKdefines for "maximal value" is debatable. I got the idea from FreeBSD, and it sorta makes sense to me.Some hunks look a bit incomplete, because code that is going to be subsequently removed is not touched here.
Quoted 6 lines
Signed-off-by Oswald Buddenhagen <[email protected]>---
this failed to build previously due to a missed logical dependency on the "use high-level I/O functions also during init" patch. that patch was applied meanwhile, so it's now safe to apply this one as well.
Thanks, applied now.
Takashi