Commit f100aab7 authored by Alan Cox's avatar Alan Cox Committed by Steve French

[PATCH] Switch the SB Live! to the new ac97 api

parent 206e87e7
...@@ -101,10 +101,10 @@ void emu10k1_set_oss_vol(struct emu10k1_card *card, int oss_mixer, ...@@ -101,10 +101,10 @@ void emu10k1_set_oss_vol(struct emu10k1_card *card, int oss_mixer,
{ {
extern char volume_params[SOUND_MIXER_NRDEVICES]; extern char volume_params[SOUND_MIXER_NRDEVICES];
card->ac97.mixer_state[oss_mixer] = (right << 8) | left; card->ac97->mixer_state[oss_mixer] = (right << 8) | left;
if (!card->is_aps) if (!card->is_aps)
card->ac97.write_mixer(&card->ac97, oss_mixer, left, right); card->ac97->write_mixer(card->ac97, oss_mixer, left, right);
emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][0], left, emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][0], left,
volume_params[oss_mixer]); volume_params[oss_mixer]);
...@@ -125,7 +125,7 @@ void emu10k1_mute_irqhandler(struct emu10k1_card *card) ...@@ -125,7 +125,7 @@ void emu10k1_mute_irqhandler(struct emu10k1_card *card)
right = (val >> 8) & 0xff; right = (val >> 8) & 0xff;
val = 0; val = 0;
} else { } else {
val = card->ac97.mixer_state[oss_channel]; val = card->ac97->mixer_state[oss_channel];
left = 0; left = 0;
right = 0; right = 0;
} }
...@@ -138,8 +138,8 @@ void emu10k1_volincr_irqhandler(struct emu10k1_card *card) ...@@ -138,8 +138,8 @@ void emu10k1_volincr_irqhandler(struct emu10k1_card *card)
int oss_channel = VOLCTRL_CHANNEL; int oss_channel = VOLCTRL_CHANNEL;
int left, right; int left, right;
left = card->ac97.mixer_state[oss_channel] & 0xff; left = card->ac97->mixer_state[oss_channel] & 0xff;
right = (card->ac97.mixer_state[oss_channel] >> 8) & 0xff; right = (card->ac97->mixer_state[oss_channel] >> 8) & 0xff;
if ((left += VOLCTRL_STEP_SIZE) > 100) if ((left += VOLCTRL_STEP_SIZE) > 100)
left = 100; left = 100;
...@@ -155,8 +155,8 @@ void emu10k1_voldecr_irqhandler(struct emu10k1_card *card) ...@@ -155,8 +155,8 @@ void emu10k1_voldecr_irqhandler(struct emu10k1_card *card)
int oss_channel = VOLCTRL_CHANNEL; int oss_channel = VOLCTRL_CHANNEL;
int left, right; int left, right;
left = card->ac97.mixer_state[oss_channel] & 0xff; left = card->ac97->mixer_state[oss_channel] & 0xff;
right = (card->ac97.mixer_state[oss_channel] >> 8) & 0xff; right = (card->ac97->mixer_state[oss_channel] >> 8) & 0xff;
if ((left -= VOLCTRL_STEP_SIZE) < 0) if ((left -= VOLCTRL_STEP_SIZE) < 0)
left = 0; left = 0;
......
...@@ -162,7 +162,7 @@ struct emu10k1_card ...@@ -162,7 +162,7 @@ struct emu10k1_card
struct emu10k1_mididevice *seq_mididev; struct emu10k1_mididevice *seq_mididev;
#endif #endif
struct ac97_codec ac97; struct ac97_codec *ac97;
int ac97_supported_mixers; int ac97_supported_mixers;
int ac97_stereo_mixers; int ac97_stereo_mixers;
......
...@@ -223,21 +223,31 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card) ...@@ -223,21 +223,31 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card)
{ {
char s[32]; char s[32];
struct ac97_codec *codec = &card->ac97; struct ac97_codec *codec = ac97_alloc_codec();
card->ac97.dev_mixer = register_sound_mixer(&emu10k1_mixer_fops, -1);
if (card->ac97.dev_mixer < 0) { if(codec == NULL)
printk(KERN_ERR "emu10k1: cannot register mixer device\n"); {
printk(KERN_ERR "emu10k1: cannot allocate mixer\n");
return -EIO; 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) { if (!card->is_aps) {
card->ac97.id = 0; card->ac97->id = 0;
card->ac97.codec_read = emu10k1_ac97_read; card->ac97->codec_read = emu10k1_ac97_read;
card->ac97.codec_write = emu10k1_ac97_write; 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"); printk(KERN_ERR "emu10k1: unable to probe AC97 codec\n");
goto err_out; goto err_out;
} }
...@@ -249,7 +259,7 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card) ...@@ -249,7 +259,7 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card)
} }
// Force 5bit: // Force 5bit:
//card->ac97.bit_resolution=5; //card->ac97->bit_resolution=5;
if (!proc_mkdir ("driver/emu10k1", 0)) { if (!proc_mkdir ("driver/emu10k1", 0)) {
printk(KERN_ERR "emu10k1: unable to create proc directory driver/emu10k1\n"); printk(KERN_ERR "emu10k1: unable to create proc directory driver/emu10k1\n");
...@@ -263,14 +273,14 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card) ...@@ -263,14 +273,14 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card)
} }
sprintf(s, "driver/emu10k1/%s/ac97", card->pci_dev->slot_name); 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); printk(KERN_ERR "emu10k1: unable to create proc entry %s\n", s);
goto err_ac97_proc; goto err_ac97_proc;
} }
/* these will store the original values and never be modified */ /* these will store the original values and never be modified */
card->ac97_supported_mixers = card->ac97.supported_mixers; card->ac97_supported_mixers = card->ac97->supported_mixers;
card->ac97_stereo_mixers = card->ac97.stereo_mixers; card->ac97_stereo_mixers = card->ac97->stereo_mixers;
} }
return 0; return 0;
...@@ -282,7 +292,9 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card) ...@@ -282,7 +292,9 @@ static int __devinit emu10k1_mixer_init(struct emu10k1_card *card)
err_emu10k1_proc: err_emu10k1_proc:
remove_proc_entry("driver/emu10k1", NULL); remove_proc_entry("driver/emu10k1", NULL);
err_out: 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; return -EIO;
} }
...@@ -300,7 +312,8 @@ static void __devinit emu10k1_mixer_cleanup(struct emu10k1_card *card) ...@@ -300,7 +312,8 @@ static void __devinit emu10k1_mixer_cleanup(struct emu10k1_card *card)
remove_proc_entry("driver/emu10k1", NULL); 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) static int __devinit emu10k1_midi_init(struct emu10k1_card *card)
...@@ -694,21 +707,21 @@ static int __devinit fx_init(struct emu10k1_card *card) ...@@ -694,21 +707,21 @@ static int __devinit fx_init(struct emu10k1_card *card)
mgr->ctrl_gpr[SOUND_MIXER_VOLUME][0] = 8; mgr->ctrl_gpr[SOUND_MIXER_VOLUME][0] = 8;
mgr->ctrl_gpr[SOUND_MIXER_VOLUME][1] = 9; mgr->ctrl_gpr[SOUND_MIXER_VOLUME][1] = 9;
left = card->ac97.mixer_state[SOUND_MIXER_VOLUME] & 0xff; left = card->ac97->mixer_state[SOUND_MIXER_VOLUME] & 0xff;
right = (card->ac97.mixer_state[SOUND_MIXER_VOLUME] >> 8) & 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, 8, left, 1 << card->ac97->bit_resolution);
emu10k1_set_volume_gpr(card, 9, right, 1 << card->ac97.bit_resolution); emu10k1_set_volume_gpr(card, 9, right, 1 << card->ac97->bit_resolution);
//Rear volume //Rear volume
mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][0] = 0x19; mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][0] = 0x19;
mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][1] = 0x1a; mgr->ctrl_gpr[ SOUND_MIXER_OGAIN ][1] = 0x1a;
left = right = 67; 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->supported_mixers |= SOUND_MASK_OGAIN;
card->ac97.stereo_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, 0x19, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 0x1a, right, VOL_5BIT); emu10k1_set_volume_gpr(card, 0x1a, right, VOL_5BIT);
...@@ -717,8 +730,8 @@ static int __devinit fx_init(struct emu10k1_card *card) ...@@ -717,8 +730,8 @@ static int __devinit fx_init(struct emu10k1_card *card)
mgr->ctrl_gpr[SOUND_MIXER_PCM][0] = 6; mgr->ctrl_gpr[SOUND_MIXER_PCM][0] = 6;
mgr->ctrl_gpr[SOUND_MIXER_PCM][1] = 7; mgr->ctrl_gpr[SOUND_MIXER_PCM][1] = 7;
left = card->ac97.mixer_state[SOUND_MIXER_PCM] & 0xff; left = card->ac97->mixer_state[SOUND_MIXER_PCM] & 0xff;
right = (card->ac97.mixer_state[SOUND_MIXER_PCM] >> 8) & 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, 6, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 7, right, VOL_5BIT); emu10k1_set_volume_gpr(card, 7, right, VOL_5BIT);
...@@ -728,22 +741,22 @@ static int __devinit fx_init(struct emu10k1_card *card) ...@@ -728,22 +741,22 @@ static int __devinit fx_init(struct emu10k1_card *card)
mgr->ctrl_gpr[SOUND_MIXER_DIGITAL1][1] = 0xf; mgr->ctrl_gpr[SOUND_MIXER_DIGITAL1][1] = 0xf;
left = right = 67; 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->supported_mixers |= SOUND_MASK_DIGITAL1;
card->ac97.stereo_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, 0xd, left, VOL_5BIT);
emu10k1_set_volume_gpr(card, 0xf, right, 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. //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_supported_mixers &= ~SOUND_MASK_PCM;
card->ac97_stereo_mixers &= ~SOUND_MASK_PCM; card->ac97_stereo_mixers &= ~SOUND_MASK_PCM;
//set Igain to 0dB by default, maybe consider hardwiring it here. //set Igain to 0dB by default, maybe consider hardwiring it here.
emu10k1_ac97_write(&card->ac97, AC97_RECORD_GAIN, 0x0000); emu10k1_ac97_write(card->ac97, AC97_RECORD_GAIN, 0x0000);
card->ac97.mixer_state[SOUND_MIXER_IGAIN] = 0x101; card->ac97->mixer_state[SOUND_MIXER_IGAIN] = 0x101;
return 0; return 0;
} }
......
...@@ -457,29 +457,29 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un ...@@ -457,29 +457,29 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un
break; break;
if (addr >= 0) { if (addr >= 0) {
unsigned int state = card->ac97.mixer_state[id]; unsigned int state = card->ac97->mixer_state[id];
if (ch == 1) { if (ch == 1) {
state >>= 8; state >>= 8;
card->ac97.stereo_mixers |= (1 << id); card->ac97->stereo_mixers |= (1 << id);
} }
card->ac97.supported_mixers |= (1 << id); card->ac97->supported_mixers |= (1 << id);
if (id == SOUND_MIXER_TREBLE) { if (id == SOUND_MIXER_TREBLE) {
set_treble(card, card->ac97.mixer_state[id] & 0xff, (card->ac97.mixer_state[id] >> 8) & 0xff); set_treble(card, card->ac97->mixer_state[id] & 0xff, (card->ac97->mixer_state[id] >> 8) & 0xff);
} else if (id == SOUND_MIXER_BASS) { } else if (id == SOUND_MIXER_BASS) {
set_bass(card, card->ac97.mixer_state[id] & 0xff, (card->ac97.mixer_state[id] >> 8) & 0xff); set_bass(card, card->ac97->mixer_state[id] & 0xff, (card->ac97->mixer_state[id] >> 8) & 0xff);
} else } else
emu10k1_set_volume_gpr(card, addr, state & 0xff, emu10k1_set_volume_gpr(card, addr, state & 0xff,
volume_params[id]); volume_params[id]);
} else { } else {
card->ac97.stereo_mixers &= ~(1 << id); card->ac97->stereo_mixers &= ~(1 << id);
card->ac97.stereo_mixers |= card->ac97_stereo_mixers; card->ac97->stereo_mixers |= card->ac97_stereo_mixers;
if (ch == 0) { if (ch == 0) {
card->ac97.supported_mixers &= ~(1 << id); card->ac97->supported_mixers &= ~(1 << id);
card->ac97.supported_mixers |= card->ac97_supported_mixers; card->ac97->supported_mixers |= card->ac97_supported_mixers;
} }
} }
break; break;
...@@ -500,9 +500,9 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un ...@@ -500,9 +500,9 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un
case CMD_AC97_BOOST: case CMD_AC97_BOOST:
if(ctl->val[0]) if(ctl->val[0])
emu10k1_ac97_write(&card->ac97, 0x18, 0x0); emu10k1_ac97_write(card->ac97, 0x18, 0x0);
else else
emu10k1_ac97_write(&card->ac97, 0x18, 0x0808); emu10k1_ac97_write(card->ac97, 0x18, 0x0808);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -577,7 +577,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer, ...@@ -577,7 +577,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer,
int val; int val;
int scale; int scale;
card->ac97.modcnt++; card->ac97->modcnt++;
if (get_user(val, (int *)arg)) if (get_user(val, (int *)arg))
return -EFAULT; return -EFAULT;
...@@ -589,7 +589,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer, ...@@ -589,7 +589,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer,
if (right > 100) right = 100; if (right > 100) right = 100;
if (left > 100) left = 100; if (left > 100) left = 100;
card->ac97.mixer_state[oss_mixer] = (right << 8) | left; card->ac97->mixer_state[oss_mixer] = (right << 8) | left;
if (oss_mixer == SOUND_MIXER_TREBLE) { if (oss_mixer == SOUND_MIXER_TREBLE) {
set_treble(card, left, right); set_treble(card, left, right);
return 0; return 0;
...@@ -599,7 +599,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer, ...@@ -599,7 +599,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer,
} }
if (oss_mixer == SOUND_MIXER_VOLUME) if (oss_mixer == SOUND_MIXER_VOLUME)
scale = 1 << card->ac97.bit_resolution; scale = 1 << card->ac97->bit_resolution;
else else
scale = volume_params[oss_mixer]; scale = volume_params[oss_mixer];
...@@ -607,7 +607,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer, ...@@ -607,7 +607,7 @@ static int emu10k1_dsp_mixer(struct emu10k1_card *card, unsigned int oss_mixer,
emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][1], right, scale); emu10k1_set_volume_gpr(card, card->mgr.ctrl_gpr[oss_mixer][1], right, scale);
if (card->ac97_supported_mixers & (1 << oss_mixer)) if (card->ac97_supported_mixers & (1 << oss_mixer))
card->ac97.write_mixer(&card->ac97, oss_mixer, left, right); card->ac97->write_mixer(card->ac97, oss_mixer, left, right);
return 0; return 0;
} }
...@@ -623,9 +623,9 @@ static int emu10k1_mixer_ioctl(struct inode *inode, struct file *file, unsigned ...@@ -623,9 +623,9 @@ static int emu10k1_mixer_ioctl(struct inode *inode, struct file *file, unsigned
if (cmd == SOUND_MIXER_INFO) { if (cmd == SOUND_MIXER_INFO) {
mixer_info info; mixer_info info;
strlcpy(info.id, card->ac97.name, sizeof(info.id)); strncpy(info.id, card->ac97->name, sizeof(info.id));
strlcpy(info.name, "Creative SBLive - Emu10k1", sizeof(info.name)); strncpy(info.name, "Creative SBLive - Emu10k1", sizeof(info.name));
info.modify_counter = card->ac97.modcnt; info.modify_counter = card->ac97->modcnt;
if (copy_to_user((void *)arg, &info, sizeof(info))) if (copy_to_user((void *)arg, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
...@@ -636,7 +636,7 @@ static int emu10k1_mixer_ioctl(struct inode *inode, struct file *file, unsigned ...@@ -636,7 +636,7 @@ static int emu10k1_mixer_ioctl(struct inode *inode, struct file *file, unsigned
if ((_SIOC_DIR(cmd) == (_SIOC_WRITE|_SIOC_READ)) && oss_mixer <= SOUND_MIXER_NRDEVICES) if ((_SIOC_DIR(cmd) == (_SIOC_WRITE|_SIOC_READ)) && oss_mixer <= SOUND_MIXER_NRDEVICES)
ret = emu10k1_dsp_mixer(card, oss_mixer, arg); ret = emu10k1_dsp_mixer(card, oss_mixer, arg);
else else
ret = card->ac97.mixer_ioctl(&card->ac97, cmd, arg); ret = card->ac97->mixer_ioctl(card->ac97, cmd, arg);
} }
if (ret < 0) if (ret < 0)
...@@ -656,7 +656,7 @@ static int emu10k1_mixer_open(struct inode *inode, struct file *file) ...@@ -656,7 +656,7 @@ static int emu10k1_mixer_open(struct inode *inode, struct file *file)
list_for_each(entry, &emu10k1_devs) { list_for_each(entry, &emu10k1_devs) {
card = list_entry(entry, struct emu10k1_card, list); card = list_entry(entry, struct emu10k1_card, list);
if (card->ac97.dev_mixer == minor) if (card->ac97->dev_mixer == minor)
goto match; goto match;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment