Merge branch 'topic/powermac' into for-linus

This commit is contained in:
Takashi Iwai 2009-03-24 00:36:20 +01:00
commit d7b6df5d1a
7 changed files with 95 additions and 24 deletions

View file

@ -13,6 +13,7 @@ config SND_POWERMAC
tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
depends on I2C && INPUT && PPC_PMAC
select SND_PCM
select SND_VMASTER
help
Say Y here to include support for the integrated sound device.

View file

@ -608,9 +608,12 @@ static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] __initdata = {
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0),
};
static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = {
static struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] __initdata = {
AWACS_VOLUME("Line out Playback Volume", 2, 6, 1),
AWACS_VOLUME("Master Playback Volume", 5, 6, 1),
};
static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = {
AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1),
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
};
@ -627,6 +630,10 @@ static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] __initdata = {
AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0),
};
static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] __initdata = {
AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1),
};
static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = {
AWACS_VOLUME("Master Playback Volume", 2, 6, 1),
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
@ -645,12 +652,19 @@ static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __initdata = {
AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0),
};
static struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] __initdata = {
AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0),
};
static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata =
AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1);
static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __initdata =
AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1);
static struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 __initdata =
AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1);
static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = {
AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0),
};
@ -766,12 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
}
#endif /* CONFIG_PM */
#define IS_PM7500 (machine_is_compatible("AAPL,7500"))
#define IS_PM7500 (machine_is_compatible("AAPL,7500") \
|| machine_is_compatible("AAPL,8500") \
|| machine_is_compatible("AAPL,9500"))
#define IS_PM5500 (machine_is_compatible("AAPL,e411"))
#define IS_BEIGE (machine_is_compatible("AAPL,Gossamer"))
#define IS_IMAC1 (machine_is_compatible("PowerMac2,1"))
#define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \
|| machine_is_compatible("PowerMac4,1"))
#define IS_G4AGP (machine_is_compatible("PowerMac3,1"))
#define IS_LOMBARD (machine_is_compatible("PowerBook1,1"))
static int imac1, imac2;
@ -858,10 +876,14 @@ int __init
snd_pmac_awacs_init(struct snd_pmac *chip)
{
int pm7500 = IS_PM7500;
int pm5500 = IS_PM5500;
int beige = IS_BEIGE;
int g4agp = IS_G4AGP;
int lombard = IS_LOMBARD;
int imac;
int err, vol;
struct snd_kcontrol *vmaster_sw, *vmaster_vol;
struct snd_kcontrol *master_vol, *speaker_vol;
imac1 = IS_IMAC1;
imac2 = IS_IMAC2;
@ -915,7 +937,7 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
/* set headphone-jack detection bit */
switch (chip->model) {
case PMAC_AWACS:
chip->hp_stat_mask = pm7500 ? MASK_HDPCONN
chip->hp_stat_mask = pm7500 || pm5500 ? MASK_HDPCONN
: MASK_LOCONN;
break;
case PMAC_SCREAMER:
@ -954,7 +976,7 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
return err;
if (beige || g4agp)
;
else if (chip->model == PMAC_SCREAMER)
else if (chip->model == PMAC_SCREAMER || pm5500)
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_screamer_mixers2),
snd_pmac_screamer_mixers2);
else if (!pm7500)
@ -962,19 +984,35 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
snd_pmac_awacs_mixers2);
if (err < 0)
return err;
if (pm5500) {
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_awacs_mixers2_pmac5500),
snd_pmac_awacs_mixers2_pmac5500);
if (err < 0)
return err;
}
if (pm7500)
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_awacs_mixers_pmac7500),
snd_pmac_awacs_mixers_pmac7500);
else if (pm5500)
err = snd_ctl_add(chip->card,
(master_vol = snd_ctl_new1(snd_pmac_awacs_mixers_pmac5500,
chip)));
else if (beige)
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_screamer_mixers_beige),
snd_pmac_screamer_mixers_beige);
else if (imac)
else if (imac || lombard) {
err = snd_ctl_add(chip->card,
(master_vol = snd_ctl_new1(snd_pmac_screamer_mixers_lo,
chip)));
if (err < 0)
return err;
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_screamer_mixers_imac),
snd_pmac_screamer_mixers_imac);
else if (g4agp)
} else if (g4agp)
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_screamer_mixers_g4agp),
snd_pmac_screamer_mixers_g4agp);
@ -984,8 +1022,10 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
snd_pmac_awacs_mixers_pmac);
if (err < 0)
return err;
chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp)
chip->master_sw_ctl = snd_ctl_new1((pm7500 || imac || g4agp || lombard)
? &snd_pmac_awacs_master_sw_imac
: pm5500
? &snd_pmac_awacs_master_sw_pmac5500
: &snd_pmac_awacs_master_sw, chip);
err = snd_ctl_add(chip->card, chip->master_sw_ctl);
if (err < 0)
@ -1017,8 +1057,9 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
#endif /* PMAC_AMP_AVAIL */
{
/* route A = headphone, route C = speaker */
err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol),
snd_pmac_awacs_speaker_vol);
err = snd_ctl_add(chip->card,
(speaker_vol = snd_ctl_new1(snd_pmac_awacs_speaker_vol,
chip)));
if (err < 0)
return err;
chip->speaker_sw_ctl = snd_ctl_new1(imac1
@ -1031,6 +1072,33 @@ snd_pmac_awacs_init(struct snd_pmac *chip)
return err;
}
if (pm5500 || imac || lombard) {
vmaster_sw = snd_ctl_make_virtual_master(
"Master Playback Switch", (unsigned int *) NULL);
err = snd_ctl_add_slave_uncached(vmaster_sw,
chip->master_sw_ctl);
if (err < 0)
return err;
err = snd_ctl_add_slave_uncached(vmaster_sw,
chip->speaker_sw_ctl);
if (err < 0)
return err;
err = snd_ctl_add(chip->card, vmaster_sw);
if (err < 0)
return err;
vmaster_vol = snd_ctl_make_virtual_master(
"Master Playback Volume", (unsigned int *) NULL);
err = snd_ctl_add_slave(vmaster_vol, master_vol);
if (err < 0)
return err;
err = snd_ctl_add_slave(vmaster_vol, speaker_vol);
if (err < 0)
return err;
err = snd_ctl_add(chip->card, vmaster_vol);
if (err < 0)
return err;
}
if (beige || g4agp)
err = build_mixers(chip,
ARRAY_SIZE(snd_pmac_screamer_mic_boost_beige),

View file

@ -35,7 +35,7 @@ snd_pmac_burgundy_busy_wait(struct snd_pmac *chip)
int timeout = 50;
while ((in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) && timeout--)
udelay(1);
if (! timeout)
if (timeout < 0)
printk(KERN_DEBUG "burgundy_busy_wait: timeout\n");
}

View file

@ -82,7 +82,7 @@ static int daca_set_volume(struct pmac_daca *mix)
data[1] |= mix->deemphasis ? 0x40 : 0;
if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL,
2, data) < 0) {
snd_printk("failed to set volume \n");
snd_printk(KERN_ERR "failed to set volume \n");
return -EINVAL;
}
return 0;

View file

@ -299,7 +299,7 @@ static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec,
case SNDRV_PCM_TRIGGER_SUSPEND:
spin_lock(&chip->reg_lock);
rec->running = 0;
/*printk("stopped!!\n");*/
/*printk(KERN_DEBUG "stopped!!\n");*/
snd_pmac_dma_stop(rec);
for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
out_le16(&cp->command, DBDMA_STOP);
@ -334,7 +334,7 @@ static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip,
}
#endif
count += rec->cur_period * rec->period_size;
/*printk("pointer=%d\n", count);*/
/*printk(KERN_DEBUG "pointer=%d\n", count);*/
return bytes_to_frames(subs->runtime, count);
}
@ -486,7 +486,7 @@ static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec)
if (! (stat & ACTIVE))
break;
/*printk("update frag %d\n", rec->cur_period);*/
/*printk(KERN_DEBUG "update frag %d\n", rec->cur_period);*/
st_le16(&cp->xfer_status, 0);
st_le16(&cp->req_count, rec->period_size);
/*st_le16(&cp->res_count, 0);*/
@ -806,7 +806,7 @@ snd_pmac_ctrl_intr(int irq, void *devid)
struct snd_pmac *chip = devid;
int ctrl = in_le32(&chip->awacs->control);
/*printk("pmac: control interrupt.. 0x%x\n", ctrl);*/
/*printk(KERN_DEBUG "pmac: control interrupt.. 0x%x\n", ctrl);*/
if (ctrl & MASK_PORTCHG) {
/* do something when headphone is plugged/unplugged? */
if (chip->update_automute)
@ -1033,7 +1033,8 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
}
if (of_device_is_compatible(sound, "tumbler")) {
chip->model = PMAC_TUMBLER;
chip->can_capture = machine_is_compatible("PowerMac4,2");
chip->can_capture = machine_is_compatible("PowerMac4,2")
|| machine_is_compatible("PowerBook4,1");
chip->can_duplex = 0;
// chip->can_byte_swap = 0; /* FIXME: check this */
chip->num_freqs = ARRAY_SIZE(tumbler_freqs);

View file

@ -110,7 +110,7 @@ static int __init snd_pmac_probe(struct platform_device *devptr)
goto __error;
break;
default:
snd_printk("unsupported hardware %d\n", chip->model);
snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model);
err = -EINVAL;
goto __error;
}

View file

@ -41,7 +41,7 @@
#undef DEBUG
#ifdef DEBUG
#define DBG(fmt...) printk(fmt)
#define DBG(fmt...) printk(KERN_DEBUG fmt)
#else
#define DBG(fmt...)
#endif
@ -240,7 +240,7 @@ static int tumbler_set_master_volume(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_VOL, 6,
block) < 0) {
snd_printk("failed to set volume \n");
snd_printk(KERN_ERR "failed to set volume \n");
return -EINVAL;
}
return 0;
@ -350,7 +350,7 @@ static int tumbler_set_drc(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
2, val) < 0) {
snd_printk("failed to set DRC\n");
snd_printk(KERN_ERR "failed to set DRC\n");
return -EINVAL;
}
return 0;
@ -386,7 +386,7 @@ static int snapper_set_drc(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
6, val) < 0) {
snd_printk("failed to set DRC\n");
snd_printk(KERN_ERR "failed to set DRC\n");
return -EINVAL;
}
return 0;
@ -506,7 +506,8 @@ static int tumbler_set_mono_volume(struct pmac_tumbler *mix,
block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff;
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, info->reg,
info->bytes, block) < 0) {
snd_printk("failed to set mono volume %d\n", info->index);
snd_printk(KERN_ERR "failed to set mono volume %d\n",
info->index);
return -EINVAL;
}
return 0;
@ -643,7 +644,7 @@ static int snapper_set_mix_vol1(struct pmac_tumbler *mix, int idx, int ch, int r
}
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, reg,
9, block) < 0) {
snd_printk("failed to set mono volume %d\n", reg);
snd_printk(KERN_ERR "failed to set mono volume %d\n", reg);
return -EINVAL;
}
return 0;