patch-2.4.22 linux-2.4.22/drivers/sound/emu10k1/main.c
Next file: linux-2.4.22/drivers/sound/emu10k1/mixer.c
Previous file: linux-2.4.22/drivers/sound/emu10k1/hwaccess.h
Back to the patch index
Back to the overall index
- Lines: 158
- Date:
2003-08-25 04:44:42.000000000 -0700
- Orig file:
linux-2.4.21/drivers/sound/emu10k1/main.c
- Orig date:
2002-11-28 15:53:14.000000000 -0800
diff -urN linux-2.4.21/drivers/sound/emu10k1/main.c linux-2.4.22/drivers/sound/emu10k1/main.c
@@ -224,21 +224,31 @@
{
char s[32];
- struct ac97_codec *codec = &card->ac97;
- card->ac97.dev_mixer = register_sound_mixer(&emu10k1_mixer_fops, -1);
- if (card->ac97.dev_mixer < 0) {
- printk(KERN_ERR "emu10k1: cannot register mixer device\n");
+ struct ac97_codec *codec = ac97_alloc_codec();
+
+ if(codec == NULL)
+ {
+ printk(KERN_ERR "emu10k1: cannot allocate mixer\n");
return -EIO;
+ }
+ card->ac97 = codec;
+
+#warning "Initialisation order race. Must register after usable"
+
+ card->ac97->dev_mixer = register_sound_mixer(&emu10k1_mixer_fops, -1);
+ if (card->ac97->dev_mixer < 0) {
+ printk(KERN_ERR "emu10k1: cannot register mixer device\n");
+ goto err_codec;
}
- card->ac97.private_data = card;
+ card->ac97->private_data = card;
if (!card->is_aps) {
- card->ac97.id = 0;
- card->ac97.codec_read = emu10k1_ac97_read;
- card->ac97.codec_write = emu10k1_ac97_write;
+ card->ac97->id = 0;
+ card->ac97->codec_read = emu10k1_ac97_read;
+ card->ac97->codec_write = emu10k1_ac97_write;
- if (ac97_probe_codec (&card->ac97) == 0) {
+ if (ac97_probe_codec (card->ac97) == 0) {
printk(KERN_ERR "emu10k1: unable to probe AC97 codec\n");
goto err_out;
}
@@ -250,7 +260,7 @@
}
// Force 5bit:
- //card->ac97.bit_resolution=5;
+ //card->ac97->bit_resolution=5;
if (!proc_mkdir ("driver/emu10k1", 0)) {
printk(KERN_ERR "emu10k1: unable to create proc directory driver/emu10k1\n");
@@ -264,14 +274,14 @@
}
sprintf(s, "driver/emu10k1/%s/ac97", card->pci_dev->slot_name);
- if (!create_proc_read_entry (s, 0, 0, ac97_read_proc, &card->ac97)) {
+ if (!create_proc_read_entry (s, 0, 0, ac97_read_proc, card->ac97)) {
printk(KERN_ERR "emu10k1: unable to create proc entry %s\n", s);
goto err_ac97_proc;
}
/* these will store the original values and never be modified */
- card->ac97_supported_mixers = card->ac97.supported_mixers;
- card->ac97_stereo_mixers = card->ac97.stereo_mixers;
+ card->ac97_supported_mixers = card->ac97->supported_mixers;
+ card->ac97_stereo_mixers = card->ac97->stereo_mixers;
}
return 0;
@@ -283,7 +293,9 @@
err_emu10k1_proc:
remove_proc_entry("driver/emu10k1", NULL);
err_out:
- unregister_sound_mixer (card->ac97.dev_mixer);
+ unregister_sound_mixer (card->ac97->dev_mixer);
+ err_codec:
+ ac97_release_codec(card->ac97);
return -EIO;
}
@@ -301,7 +313,8 @@
remove_proc_entry("driver/emu10k1", NULL);
}
- unregister_sound_mixer (card->ac97.dev_mixer);
+ unregister_sound_mixer (card->ac97->dev_mixer);
+ ac97_release_codec(card->ac97);
}
static int __devinit emu10k1_midi_init(struct emu10k1_card *card)
@@ -695,21 +708,21 @@
mgr->ctrl_gpr[SOUND_MIXER_VOLUME][0] = 8;
mgr->ctrl_gpr[SOUND_MIXER_VOLUME][1] = 9;
- left = card->ac97.mixer_state[SOUND_MIXER_VOLUME] & 0xff;
- right = (card->ac97.mixer_state[SOUND_MIXER_VOLUME] >> 8) & 0xff;
+ left = card->ac97->mixer_state[SOUND_MIXER_VOLUME] & 0xff;
+ right = (card->ac97->mixer_state[SOUND_MIXER_VOLUME] >> 8) & 0xff;
- emu10k1_set_volume_gpr(card, 8, left, 1 << card->ac97.bit_resolution);
- emu10k1_set_volume_gpr(card, 9, right, 1 << card->ac97.bit_resolution);
+ emu10k1_set_volume_gpr(card, 8, left, 1 << card->ac97->bit_resolution);
+ emu10k1_set_volume_gpr(card, 9, right, 1 << card->ac97->bit_resolution);
//Rear volume
mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][0] = 0x19;
mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][1] = 0x1a;
left = right = 67;
- card->ac97.mixer_state[SOUND_MIXER_OGAIN] = (right << 8) | left;
+ card->ac97->mixer_state[SOUND_MIXER_OGAIN] = (right << 8) | left;
- card->ac97.supported_mixers |= SOUND_MASK_OGAIN;
- card->ac97.stereo_mixers |= SOUND_MASK_OGAIN;
+ card->ac97->supported_mixers |= SOUND_MASK_OGAIN;
+ card->ac97->stereo_mixers |= SOUND_MASK_OGAIN;
emu10k1_set_volume_gpr(card, 0x19, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 0x1a, right, VOL_5BIT);
@@ -718,8 +731,8 @@
mgr->ctrl_gpr[SOUND_MIXER_PCM][0] = 6;
mgr->ctrl_gpr[SOUND_MIXER_PCM][1] = 7;
- left = card->ac97.mixer_state[SOUND_MIXER_PCM] & 0xff;
- right = (card->ac97.mixer_state[SOUND_MIXER_PCM] >> 8) & 0xff;
+ left = card->ac97->mixer_state[SOUND_MIXER_PCM] & 0xff;
+ right = (card->ac97->mixer_state[SOUND_MIXER_PCM] >> 8) & 0xff;
emu10k1_set_volume_gpr(card, 6, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 7, right, VOL_5BIT);
@@ -729,22 +742,22 @@
mgr->ctrl_gpr[SOUND_MIXER_DIGITAL1][1] = 0xf;
left = right = 67;
- card->ac97.mixer_state[SOUND_MIXER_DIGITAL1] = (right << 8) | left;
+ card->ac97->mixer_state[SOUND_MIXER_DIGITAL1] = (right << 8) | left;
- card->ac97.supported_mixers |= SOUND_MASK_DIGITAL1;
- card->ac97.stereo_mixers |= SOUND_MASK_DIGITAL1;
+ card->ac97->supported_mixers |= SOUND_MASK_DIGITAL1;
+ card->ac97->stereo_mixers |= SOUND_MASK_DIGITAL1;
emu10k1_set_volume_gpr(card, 0xd, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 0xf, right, VOL_5BIT);
//hard wire the ac97's pcm, we'll do that in dsp code instead.
- emu10k1_ac97_write(&card->ac97, 0x18, 0x0);
+ emu10k1_ac97_write(card->ac97, 0x18, 0x0);
card->ac97_supported_mixers &= ~SOUND_MASK_PCM;
card->ac97_stereo_mixers &= ~SOUND_MASK_PCM;
//set Igain to 0dB by default, maybe consider hardwiring it here.
- emu10k1_ac97_write(&card->ac97, AC97_RECORD_GAIN, 0x0000);
- card->ac97.mixer_state[SOUND_MIXER_IGAIN] = 0x101;
+ emu10k1_ac97_write(card->ac97, AC97_RECORD_GAIN, 0x0000);
+ card->ac97->mixer_state[SOUND_MIXER_IGAIN] = 0x101;
return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)