sscape: drop redundant fields from soundscape struct
Takashi Iwai napisał(a):
Quoted 9 lines
At Sun, 1 Feb 2009 21:12:31 +0100,
Quoted 3 lines · Krzysztof Helt
The
midi_volis set only to 0 so it does not work as detection of change in midi volume. It is removed.It's used to cache the value. You should better to keep it, but fix
sscape_midi_put()function to remember the last uctl->value.integer.value[0] value in this field.
I know that it was supposed to cache the volume value, but is it really needed? It is not something time critical and the less code the better.
Quoted 3 lines
(And also better to change
sscape_midi_get()to returnmidi_vol
value.)
Ok.
Regards,
Krzysztof
----------------------------------------------------------------------
Doladuj telefon!
Sprawdz >> http://link.interia.pl/f2047
At 02 Feb 2009 09:20:11 +0100,
Quoted 5 lines · [email protected] wrote:
Takashi Iwai napisał(a):
Quoted 3 lines
At Sun, 1 Feb 2009 21:12:31 +0100,
Quoted 1 line · Krzysztof Helt
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
The
midi_volis set only to 0 so it does not work as detection of change in midi volume. It is removed.It's used to cache the value. You should better to keep it, but fix
sscape_midi_put()function to remember the last uctl->value.integer.value[0] value in this field.I know that it was supposed to cache the volume value, but is it really needed?
Yes, if it's possible, it's always better. get/put callbacks are called relatively often. It's no time-critical path, but the frequency isn't negligible.
Quoted 1 line
It is not something time critical and the less code the better.
The code will be shorter since it simplifies the get callback, too.
Takashi
Quoted 12 lines
Quoted 3 lines
(And also better to change
sscape_midi_get()to returnmidi_vol
value.)Ok.
Regards,
Krzysztof----------------------------------------------------------------------
Doladuj telefon!
Sprawdz >> http://link.interia.pl/f2047
PATCH 1/1 sscape: drop redundant fields from soundscape struct (2nd rev)
From: Krzysztof Helt <[email protected]>
The wss_base is disguised parameter for one function. It is converted to a function parameter.
The code_type is only set but never read.
It is removed.
The midi_vol is set only to 0 so it does not work as detection of change in midi volume. It is fixed.
The xport variable is alias to the port[dev]. Use the port[dev] directly to increase readability.
---
sound/isa/sscape.c +15 -21
@@ -135,8 +135,6 @@ enum card_type {struct soundscape {spinlock_t lock;unsigned io_base; -unsigned wss_base; -int codec_type;int ic_type;enum card_type type;struct resource *io_res;
@@ -767,6 +765,7 @@ static int sscape_midi_put(struct snd_kcontrol *kctl, change = (host_write_ctrl_unsafe (s->io_base,CMD_SET_MIDI_VOL ,100 ) &&host_write_ctrl_unsafe (s->io_base, ((unsigned char ) uctl->value.integer. value[0 ]) &127 ,100 ) &&host_write_ctrl_unsafe (s->io_base,CMD_XXX_MIDI_VOL ,100 )); + s->midi_vol = (unsigned char ) uctl->value.integer.value[0 ] &127 ; __skip_change:/*
@@ -809,12 +808,11 @@ static unsigned __devinit get_irq_config(int irq)* Perform certain arcane port-checks to see whether there * is a SoundScape board lurking behind the given ports. */ -static int __devinit detect_sscape (struct soundscape *s) +static int __devinit detect_sscape (struct soundscape *s,long wss_io) {unsigned long flags;unsigned d;int retval =0 ; -int codec = s->wss_base;spin_lock_irqsave (&s->lock, flags);
@@ -830,13 +828,11 @@ static int __devinit detect_sscape(struct soundscape *s)if ((d &0x80 ) !=0 ) goto _done; -if (d ==0 ) { - s->codec_type =1 ; +if (d ==0 ) s->ic_type =IC_ODIE ; - }else if ((d &0x60 ) !=0 ) { - s->codec_type =2 ; +else if ((d &0x60 ) !=0 ) s->ic_type =IC_OPUS ; - }else +else goto _done;outb (0xfa ,ODIE_ADDR_IO (s->io_base));
@@ -856,10 +852,10 @@ static int __devinit detect_sscape(struct soundscape *s)sscape_write_unsafe (s->io_base,GA_HMCTL_REG , d |0xc0 );if (s->type ==SSCAPE_VIVO ) - codec +=4 ; + wss_io +=4 ;/* wait for WSS codec */ for (d =0 ; d <500 ; d++) { -if ((inb (codec) &0x80 ) ==0 ) +if ((inb (wss_io) &0x80 ) ==0 )break ;spin_unlock_irqrestore (&s->lock, flags);msleep (1 );
@@ -1057,7 +1053,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)unsigned dma_cfg;unsigned irq_cfg;unsigned mpu_irq_cfg; -unsigned xport;struct resource *io_res;struct resource *wss_res;unsigned long flags;
@@ -1077,15 +1072,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)printk (KERN_ERR "sscape: Invalid IRQ %d\n" , mpu_irq[dev]);return -ENXIO ; } - xport = port[dev];/* * Grab IO ports that we will need to probe so that we * can detect and control this hardware ... */ - io_res =request_region (xport,8 ,"SoundScape" ); + io_res =request_region (port[dev],8 ,"SoundScape" );if (!io_res) { -snd_printk (KERN_ERR "sscape: can't grab port 0x%x\n" , xport); +snd_printk (KERN_ERR +"sscape: can't grab port 0x%lx\n" , port[dev]);return -EBUSY ; } wss_res =NULL ;
@@ -1112,10 +1107,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card)spin_lock_init (&sscape->fwlock); sscape->io_res = io_res; sscape->wss_res = wss_res; - sscape->io_base = xport; - sscape->wss_base = wss_port[dev]; + sscape->io_base = port[dev]; -if (!detect_sscape (sscape)) { +if (!detect_sscape (sscape, wss_port[dev])) {printk (KERN_ERR "sscape: hardware not detected at 0x%x\n" , sscape->io_base); err = -ENODEV ; goto _release_dma;
@@ -1188,11 +1182,11 @@ static int __devinit create_sscape(int dev, struct snd_card *card) }#define MIDI_DEVNUM 0if (sscape->type !=SSCAPE_VIVO ) { - err =create_mpu401 (card,MIDI_DEVNUM , xport, mpu_irq[dev]); + err =create_mpu401 (card,MIDI_DEVNUM , port[dev], mpu_irq[dev]);if (err <0 ) {printk (KERN_ERR "sscape: Failed to create " -"MPU-401 device at 0x%x\n" , - xport); +"MPU-401 device at 0x%lx\n" , + port[dev]); goto _release_dma; }
----------------------------------------------------------------------
Nie boj sie przyszlosci!
Zapytaj wrozke >> http://link.interia.pl/f2049
Re: [PATCH] sscape: drop redundant fields from soundscape struct (2nd rev)
At Mon, 2 Feb 2009 19:52:57 +0100,
Quoted 32 lines · Krzysztof Helt
From: Krzysztof Helt <[email protected]>
The
wss_baseis disguised parameter for one function. It is converted to a function parameter.The
code_typeis only set but never read.
It is removed.The
midi_volis set only to 0 so it does not work as detection of change in midi volume. It is fixed.The xport variable is alias to the port[dev]. Use the port[dev] directly to increase readability.
Signed-off-by Krzysztof Helt <[email protected]>---
sound/isa/sscape.c +0
-2@@ -135,8 +135,6 @@ enum card_type {struct soundscape {spinlock_t lock;unsigned io_base; -unsigned wss_base; -int codec_type;int ic_type;enum card_type type;struct resource *io_res;
sound/isa/sscape.c static int sscape_midi_put(struct snd_kcontrol *kctl, · line 771
Quoted 7 lines
sound/isa/sscape.c +1
-0@@ -767,6 +765,7 @@ static int sscape_midi_put(struct snd_kcontrol *kctl, change = (host_write_ctrl_unsafe (s->io_base,CMD_SET_MIDI_VOL ,100 ) &&host_write_ctrl_unsafe (s->io_base, ((unsigned char ) uctl->value.integer. value[0 ]) &127 ,100 ) &&host_write_ctrl_unsafe (s->io_base,CMD_XXX_MIDI_VOL ,100 )); + s->midi_vol = (unsigned char ) uctl->value.integer.value[0 ] &127 ; __skip_change:/*
You can change sscape_midi_get() to just return s->midi_vol instead of probing the hardware value. That's why I suggested it'd be less code.
thanks,
Takashi