diff options
Diffstat (limited to 'sound')
189 files changed, 3317 insertions, 1398 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index eb60cb8dbb8a..c40ae573346d 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -425,6 +425,26 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, return 0; } +static int snd_compress_check_input(struct snd_compr_params *params) +{ + /* first let's check the buffer parameter's */ + if (params->buffer.fragment_size == 0 || + params->buffer.fragments > SIZE_MAX / params->buffer.fragment_size) + return -EINVAL; + + /* now codec parameters */ + if (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX) + return -EINVAL; + + if (params->codec.ch_in == 0 || params->codec.ch_out == 0) + return -EINVAL; + + if (!(params->codec.sample_rate & SNDRV_PCM_RATE_8000_192000)) + return -EINVAL; + + return 0; +} + static int snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) { @@ -443,11 +463,17 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) retval = -EFAULT; goto out; } + + retval = snd_compress_check_input(params); + if (retval) + goto out; + retval = snd_compr_allocate_buffer(stream, params); if (retval) { retval = -ENOMEM; goto out; } + retval = stream->ops->set_params(stream, params); if (retval) goto out; diff --git a/sound/core/control.c b/sound/core/control.c index 2487a6bb1c54..7e86a5b9f3b5 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -246,6 +246,7 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, kctl.count = ncontrol->count ? ncontrol->count : 1; access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : (ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| + SNDRV_CTL_ELEM_ACCESS_VOLATILE| SNDRV_CTL_ELEM_ACCESS_INACTIVE| SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND| diff --git a/sound/core/info.c b/sound/core/info.c index c1e611c65c8f..6b368d25073b 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -28,7 +28,7 @@ #include <sound/core.h> #include <sound/minors.h> #include <sound/info.h> -#include <sound/version.h> +#include <linux/utsname.h> #include <linux/proc_fs.h> #include <linux/mutex.h> #include <stdarg.h> @@ -986,9 +986,8 @@ static struct snd_info_entry *snd_info_version_entry; static void snd_info_version_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { snd_iprintf(buffer, - "Advanced Linux Sound Architecture Driver Version " - CONFIG_SND_VERSION CONFIG_SND_DATE ".\n" - ); + "Advanced Linux Sound Architecture Driver Version k%s.\n", + init_utsname()->release); } static int __init snd_info_version_init(void) diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index cf42ab5080eb..83c29dbff9c0 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c @@ -26,7 +26,6 @@ #include <sound/core.h> #include <sound/minors.h> #include <sound/info.h> -#include <sound/version.h> #include <linux/utsname.h> #include <linux/mutex.h> @@ -94,7 +93,7 @@ static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int d static void snd_sndstat_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA v" CONFIG_SND_VERSION " emulation code)\n"); + snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA emulation code)\n"); snd_iprintf(buffer, "Kernel: %s %s %s %s %s\n", init_utsname()->sysname, init_utsname()->nodename, diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 18297f7f2c55..29f6ded02555 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -1046,6 +1046,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix if (kctl->info(kctl, uinfo)) { up_read(&mixer->card->controls_rwsem); + kfree(uinfo); return 0; } strcpy(str, ptr->name); @@ -1061,6 +1062,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix uinfo->value.enumerated.item = slot.capture_item; if (kctl->info(kctl, uinfo)) { up_read(&mixer->card->controls_rwsem); + kfree(uinfo); return 0; } if (!strcmp(uinfo->value.enumerated.name, str)) { diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 1a3070b4e5b5..f2991940b271 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1105,6 +1105,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) break; } snd_unregister_device(devtype, pcm->card, pcm->device); + if (pcm->streams[cidx].chmap_kctl) { + snd_ctl_remove(pcm->card, pcm->streams[cidx].chmap_kctl); + pcm->streams[cidx].chmap_kctl = NULL; + } } unlock: mutex_unlock(®ister_mutex); diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 7ae671923393..f42c10a43315 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -26,6 +26,7 @@ #include <linux/export.h> #include <sound/core.h> #include <sound/control.h> +#include <sound/tlv.h> #include <sound/info.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -2302,3 +2303,216 @@ snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, } EXPORT_SYMBOL(snd_pcm_lib_readv); + +/* + * standard channel mapping helpers + */ + +/* default channel maps for multi-channel playbacks, up to 8 channels */ +const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, + { .channels = 4, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { .channels = 6, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, + SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, + { .channels = 8, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, + SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, + SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, + { } +}; +EXPORT_SYMBOL_GPL(snd_pcm_std_chmaps); + +/* alternative channel maps with CLFE <-> surround swapped for 6/8 channels */ +const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, + { .channels = 4, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { .channels = 6, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { .channels = 8, + .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, + SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, + SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, + SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, + { } +}; +EXPORT_SYMBOL_GPL(snd_pcm_alt_chmaps); + +static bool valid_chmap_channels(const struct snd_pcm_chmap *info, int ch) +{ + if (ch > info->max_channels) + return false; + return !info->channel_mask || (info->channel_mask & (1U << ch)); +} + +static int pcm_chmap_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 0; + uinfo->count = info->max_channels; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = SNDRV_CHMAP_LAST; + return 0; +} + +/* get callback for channel map ctl element + * stores the channel position firstly matching with the current channels + */ +static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + struct snd_pcm_substream *substream; + const struct snd_pcm_chmap_elem *map; + + if (snd_BUG_ON(!info->chmap)) + return -EINVAL; + substream = snd_pcm_chmap_substream(info, idx); + if (!substream) + return -ENODEV; + memset(ucontrol->value.integer.value, 0, + sizeof(ucontrol->value.integer.value)); + if (!substream->runtime) + return 0; /* no channels set */ + for (map = info->chmap; map->channels; map++) { + int i; + if (map->channels == substream->runtime->channels && + valid_chmap_channels(info, map->channels)) { + for (i = 0; i < map->channels; i++) + ucontrol->value.integer.value[i] = map->map[i]; + return 0; + } + } + return -EINVAL; +} + +/* tlv callback for channel map ctl element + * expands the pre-defined channel maps in a form of TLV + */ +static int pcm_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, + unsigned int size, unsigned int __user *tlv) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + const struct snd_pcm_chmap_elem *map; + unsigned int __user *dst; + int c, count = 0; + + if (snd_BUG_ON(!info->chmap)) + return -EINVAL; + if (size < 8) + return -ENOMEM; + if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv)) + return -EFAULT; + size -= 8; + dst = tlv + 2; + for (map = info->chmap; map->channels; map++) { + int chs_bytes = map->channels * 4; + if (!valid_chmap_channels(info, map->channels)) + continue; + if (size < 8) + return -ENOMEM; + if (put_user(SNDRV_CTL_TLVT_CHMAP_FIXED, dst) || + put_user(chs_bytes, dst + 1)) + return -EFAULT; + dst += 2; + size -= 8; + count += 8; + if (size < chs_bytes) + return -ENOMEM; + size -= chs_bytes; + count += chs_bytes; + for (c = 0; c < map->channels; c++) { + if (put_user(map->map[c], dst)) + return -EFAULT; + dst++; + } + } + if (put_user(count, tlv + 1)) + return -EFAULT; + return 0; +} + +static void pcm_chmap_ctl_private_free(struct snd_kcontrol *kcontrol) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + info->pcm->streams[info->stream].chmap_kctl = NULL; + kfree(info); +} + +/** + * snd_pcm_add_chmap_ctls - create channel-mapping control elements + * @pcm: the assigned PCM instance + * @stream: stream direction + * @chmap: channel map elements (for query) + * @max_channels: the max number of channels for the stream + * @private_value: the value passed to each kcontrol's private_value field + * @info_ret: store struct snd_pcm_chmap instance if non-NULL + * + * Create channel-mapping control elements assigned to the given PCM stream(s). + * Returns zero if succeed, or a negative error value. + */ +int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, + const struct snd_pcm_chmap_elem *chmap, + int max_channels, + unsigned long private_value, + struct snd_pcm_chmap **info_ret) +{ + struct snd_pcm_chmap *info; + struct snd_kcontrol_new knew = { + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .access = SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_TLV_READ | + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, + .info = pcm_chmap_ctl_info, + .get = pcm_chmap_ctl_get, + .tlv.c = pcm_chmap_ctl_tlv, + }; + int err; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + info->pcm = pcm; + info->stream = stream; + info->chmap = chmap; + info->max_channels = max_channels; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + knew.name = "Playback Channel Map"; + else + knew.name = "Capture Channel Map"; + knew.device = pcm->device; + knew.count = pcm->streams[stream].substream_count; + knew.private_value = private_value; + info->kctl = snd_ctl_new1(&knew, info); + if (!info->kctl) { + kfree(info); + return -ENOMEM; + } + info->kctl->private_free = pcm_chmap_ctl_private_free; + err = snd_ctl_add(pcm->card, info->kctl); + if (err < 0) + return err; + pcm->streams[stream].chmap_kctl = info->kctl; + if (info_ret) + *info_ret = info; + return 0; +} +EXPORT_SYMBOL_GPL(snd_pcm_add_chmap_ctls); diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 957131366dd9..69e01c4fc32d 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -327,32 +327,6 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne } EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); - -/* - * compute the max chunk size with continuous pages on sg-buffer - */ -unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, - unsigned int ofs, unsigned int size) -{ - struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); - unsigned int start, end, pg; - - start = ofs >> PAGE_SHIFT; - end = (ofs + size - 1) >> PAGE_SHIFT; - /* check page continuity */ - pg = sg->table[start].addr >> PAGE_SHIFT; - for (;;) { - start++; - if (start > end) - break; - pg++; - if ((sg->table[start].addr >> PAGE_SHIFT) != pg) - return (start << PAGE_SHIFT) - ofs; - } - /* ok, all on continuous pages */ - return size; -} -EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size); #endif /* CONFIG_SND_DMA_SGBUF */ /** diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 53b5ada8f7c3..5e12e5bacbba 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1563,25 +1563,25 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) /* WARNING: Don't forget to fput back the file */ -static struct file *snd_pcm_file_fd(int fd) +static struct file *snd_pcm_file_fd(int fd, int *fput_needed) { struct file *file; struct inode *inode; unsigned int minor; - file = fget(fd); + file = fget_light(fd, fput_needed); if (!file) return NULL; inode = file->f_path.dentry->d_inode; if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) { - fput(file); + fput_light(file, *fput_needed); return NULL; } minor = iminor(inode); if (!snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) && !snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE)) { - fput(file); + fput_light(file, *fput_needed); return NULL; } return file; @@ -1597,8 +1597,9 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) struct snd_pcm_file *pcm_file; struct snd_pcm_substream *substream1; struct snd_pcm_group *group; + int fput_needed; - file = snd_pcm_file_fd(fd); + file = snd_pcm_file_fd(fd, &fput_needed); if (!file) return -EBADFD; pcm_file = file->private_data; @@ -1633,7 +1634,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) write_unlock_irq(&snd_pcm_link_rwlock); up_write(&snd_pcm_link_rwsem); _nolock: - fput(file); + fput_light(file, fput_needed); if (res < 0) kfree(group); return res; @@ -3038,7 +3039,7 @@ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_status; area->vm_private_data = substream; - area->vm_flags |= VM_RESERVED; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; return 0; } @@ -3075,7 +3076,7 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_control; area->vm_private_data = substream; - area->vm_flags |= VM_RESERVED; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; return 0; } #else /* ! coherent mmap */ @@ -3169,7 +3170,7 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = { int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *area) { - area->vm_flags |= VM_RESERVED; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; #ifdef ARCH_HAS_DMA_MMAP_COHERENT if (!substream->ops->page && substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 5cf8d65ed5ef..60e8fc1b3440 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -569,5 +569,7 @@ EXPORT_SYMBOL(snd_seq_device_load_drivers); EXPORT_SYMBOL(snd_seq_device_new); EXPORT_SYMBOL(snd_seq_device_register_driver); EXPORT_SYMBOL(snd_seq_device_unregister_driver); +#ifdef CONFIG_MODULES EXPORT_SYMBOL(snd_seq_autoload_lock); EXPORT_SYMBOL(snd_seq_autoload_unlock); +#endif diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c index d0f00356fc11..0a418503ec41 100644 --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c @@ -22,6 +22,7 @@ #include <linux/slab.h> #include <linux/mm.h> #include <linux/vmalloc.h> +#include <linux/export.h> #include <sound/memalloc.h> @@ -136,3 +137,29 @@ void *snd_malloc_sgbuf_pages(struct device *device, snd_free_sgbuf_pages(dmab); /* free the table */ return NULL; } + +/* + * compute the max chunk size with continuous pages on sg-buffer + */ +unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab, + unsigned int ofs, unsigned int size) +{ + struct snd_sg_buf *sg = dmab->private_data; + unsigned int start, end, pg; + + start = ofs >> PAGE_SHIFT; + end = (ofs + size - 1) >> PAGE_SHIFT; + /* check page continuity */ + pg = sg->table[start].addr >> PAGE_SHIFT; + for (;;) { + start++; + if (start > end) + break; + pg++; + if ((sg->table[start].addr >> PAGE_SHIFT) != pg) + return (start << PAGE_SHIFT) - ofs; + } + /* ok, all on continuous pages */ + return size; +} +EXPORT_SYMBOL(snd_sgbuf_get_chunk_size); diff --git a/sound/core/sound.c b/sound/core/sound.c index 28f35593a750..643976000ce8 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -27,7 +27,6 @@ #include <sound/core.h> #include <sound/minors.h> #include <sound/info.h> -#include <sound/version.h> #include <sound/control.h> #include <sound/initval.h> #include <linux/kmod.h> @@ -468,7 +467,7 @@ static int __init alsa_sound_init(void) } snd_info_minor_register(); #ifndef MODULE - printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n"); + printk(KERN_INFO "Advanced Linux Sound Architecture Driver Initialized.\n"); #endif return 0; } diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 5a34355e78e8..0fe6d64ff840 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -120,6 +120,7 @@ struct loopback_pcm { unsigned int last_drift; unsigned long last_jiffies; struct timer_list timer; + spinlock_t timer_lock; }; static struct platform_device *devices[SNDRV_CARDS]; @@ -170,6 +171,7 @@ static void loopback_timer_start(struct loopback_pcm *dpcm) unsigned long tick; unsigned int rate_shift = get_rate_shift(dpcm); + spin_lock(&dpcm->timer_lock); if (rate_shift != dpcm->pcm_rate_shift) { dpcm->pcm_rate_shift = rate_shift; dpcm->period_size_frac = frac_pos(dpcm, dpcm->pcm_period_size); @@ -182,12 +184,15 @@ static void loopback_timer_start(struct loopback_pcm *dpcm) tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps; dpcm->timer.expires = jiffies + tick; add_timer(&dpcm->timer); + spin_unlock(&dpcm->timer_lock); } static inline void loopback_timer_stop(struct loopback_pcm *dpcm) { + spin_lock(&dpcm->timer_lock); del_timer(&dpcm->timer); dpcm->timer.expires = 0; + spin_unlock(&dpcm->timer_lock); } #define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK) @@ -667,6 +672,7 @@ static int loopback_open(struct snd_pcm_substream *substream) dpcm->substream = substream; setup_timer(&dpcm->timer, loopback_timer_function, (unsigned long)dpcm); + spin_lock_init(&dpcm->timer_lock); cable = loopback->cables[substream->number][dev]; if (!cable) { diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 2bfe4bcb7a7d..0c796bcbc0a3 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -163,7 +163,7 @@ static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op, struct best *bp; for (i = 0; i < END; i++) { - best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */; + best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */ best[i].voice = -1; } diff --git a/sound/drivers/opl4/opl4_synth.c b/sound/drivers/opl4/opl4_synth.c index 49b9e240915c..4b91adc0238c 100644 --- a/sound/drivers/opl4/opl4_synth.c +++ b/sound/drivers/opl4/opl4_synth.c @@ -504,8 +504,7 @@ void snd_opl4_note_on(void *private_data, int note, int vel, struct snd_midi_cha spin_lock_irqsave(&opl4->reg_lock, flags); for (i = 0; i < voices; i++) { voice[i] = snd_opl4_get_voice(opl4); - list_del(&voice[i]->list); - list_add_tail(&voice[i]->list, &opl4->on_voices); + list_move_tail(&voice[i]->list, &opl4->on_voices); voice[i]->chan = chan; voice[i]->note = note; voice[i]->velocity = vel & 0x7f; @@ -555,8 +554,7 @@ void snd_opl4_note_on(void *private_data, int note, int vel, struct snd_midi_cha static void snd_opl4_voice_off(struct snd_opl4 *opl4, struct opl4_voice *voice) { - list_del(&voice->list); - list_add_tail(&voice->list, &opl4->off_voices); + list_move_tail(&voice->list, &opl4->off_voices); voice->reg_misc &= ~OPL4_KEY_ON_BIT; snd_opl4_write(opl4, OPL4_REG_MISC + voice->number, voice->reg_misc); @@ -571,8 +569,7 @@ void snd_opl4_note_off(void *private_data, int note, int vel, struct snd_midi_ch static void snd_opl4_terminate_voice(struct snd_opl4 *opl4, struct opl4_voice *voice) { - list_del(&voice->list); - list_add_tail(&voice->list, &opl4->off_voices); + list_move_tail(&voice->list, &opl4->off_voices); voice->reg_misc = (voice->reg_misc & ~OPL4_KEY_ON_BIT) | OPL4_DAMP_BIT; snd_opl4_write(opl4, OPL4_REG_MISC + voice->number, voice->reg_misc); diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 5e897b236cec..deed5efff33c 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -184,7 +184,7 @@ static int vx_set_format(struct vx_core *chip, struct vx_pipe *pipe, default : snd_BUG(); return -EINVAL; - }; + } return vx_set_stream_format(chip, pipe, header); } diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index dde5c9c92132..ef68d710d08c 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -141,7 +141,7 @@ void snd_ak4113_reinit(struct ak4113 *chip) { chip->init = 1; mb(); - flush_delayed_work_sync(&chip->work); + flush_delayed_work(&chip->work); ak4113_init_regs(chip); /* bring up statistics / event queing */ chip->init = 0; diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index fdf3c1b65e38..816e7d225fb0 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -154,7 +154,7 @@ void snd_ak4114_reinit(struct ak4114 *chip) { chip->init = 1; mb(); - flush_delayed_work_sync(&chip->work); + flush_delayed_work(&chip->work); ak4114_init_regs(chip); /* bring up statistics / event queing */ chip->init = 0; diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index d14edb7d6484..3c6c1e3226f3 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c @@ -37,9 +37,6 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); MODULE_LICENSE("GPL"); -#define FREQ_LO ((tea->tea5759 ? 760 : 875) * 1600U) -#define FREQ_HI ((tea->tea5759 ? 910 : 1080) * 1600U) - /* * definitions */ @@ -50,8 +47,8 @@ MODULE_LICENSE("GPL"); #define TEA575X_BIT_BAND_MASK (3<<20) #define TEA575X_BIT_BAND_FM (0<<20) #define TEA575X_BIT_BAND_MW (1<<20) -#define TEA575X_BIT_BAND_LW (1<<21) -#define TEA575X_BIT_BAND_SW (1<<22) +#define TEA575X_BIT_BAND_LW (2<<20) +#define TEA575X_BIT_BAND_SW (3<<20) #define TEA575X_BIT_PORT_0 (1<<19) /* user bit */ #define TEA575X_BIT_PORT_1 (1<<18) /* user bit */ #define TEA575X_BIT_SEARCH_MASK (3<<16) /* search level */ @@ -62,6 +59,37 @@ MODULE_LICENSE("GPL"); #define TEA575X_BIT_DUMMY (1<<15) /* buffer */ #define TEA575X_BIT_FREQ_MASK 0x7fff +enum { BAND_FM, BAND_FM_JAPAN, BAND_AM }; + +static const struct v4l2_frequency_band bands[] = { + { + .type = V4L2_TUNER_RADIO, + .index = 0, + .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | + V4L2_TUNER_CAP_FREQ_BANDS, + .rangelow = 87500 * 16, + .rangehigh = 108000 * 16, + .modulation = V4L2_BAND_MODULATION_FM, + }, + { + .type = V4L2_TUNER_RADIO, + .index = 0, + .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | + V4L2_TUNER_CAP_FREQ_BANDS, + .rangelow = 76000 * 16, + .rangehigh = 91000 * 16, + .modulation = V4L2_BAND_MODULATION_FM, + }, + { + .type = V4L2_TUNER_RADIO, + .index = 1, + .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_FREQ_BANDS, + .rangelow = 530 * 16, + .rangehigh = 1710 * 16, + .modulation = V4L2_BAND_MODULATION_AM, + }, +}; + /* * lowlevel part */ @@ -133,16 +161,29 @@ static u32 snd_tea575x_val_to_freq(struct snd_tea575x *tea, u32 val) if (freq == 0) return freq; - /* freq *= 12.5 */ - freq *= 125; - freq /= 10; - /* crystal fixup */ - if (tea->tea5759) - freq += TEA575X_FMIF; - else + switch (tea->band) { + case BAND_FM: + /* freq *= 12.5 */ + freq *= 125; + freq /= 10; + /* crystal fixup */ freq -= TEA575X_FMIF; + break; + case BAND_FM_JAPAN: + /* freq *= 12.5 */ + freq *= 125; + freq /= 10; + /* crystal fixup */ + freq += TEA575X_FMIF; + break; + case BAND_AM: + /* crystal fixup */ + freq -= TEA575X_AMIF; + break; + } - return clamp(freq * 16, FREQ_LO, FREQ_HI); /* from kHz */ + return clamp(freq * 16, bands[tea->band].rangelow, + bands[tea->band].rangehigh); /* from kHz */ } static u32 snd_tea575x_get_freq(struct snd_tea575x *tea) @@ -150,21 +191,37 @@ static u32 snd_tea575x_get_freq(struct snd_tea575x *tea) return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea)); } -static void snd_tea575x_set_freq(struct snd_tea575x *tea) +void snd_tea575x_set_freq(struct snd_tea575x *tea) { - u32 freq = tea->freq; + u32 freq = tea->freq / 16; /* to kHz */ + u32 band = 0; - freq /= 16; /* to kHz */ - /* crystal fixup */ - if (tea->tea5759) - freq -= TEA575X_FMIF; - else + switch (tea->band) { + case BAND_FM: + band = TEA575X_BIT_BAND_FM; + /* crystal fixup */ freq += TEA575X_FMIF; - /* freq /= 12.5 */ - freq *= 10; - freq /= 125; + /* freq /= 12.5 */ + freq *= 10; + freq /= 125; + break; + case BAND_FM_JAPAN: + band = TEA575X_BIT_BAND_FM; + /* crystal fixup */ + freq -= TEA575X_FMIF; + /* freq /= 12.5 */ + freq *= 10; + freq /= 125; + break; + case BAND_AM: + band = TEA575X_BIT_BAND_MW; + /* crystal fixup */ + freq += TEA575X_AMIF; + break; + } - tea->val &= ~TEA575X_BIT_FREQ_MASK; + tea->val &= ~(TEA575X_BIT_FREQ_MASK | TEA575X_BIT_BAND_MASK); + tea->val |= band; tea->val |= freq & TEA575X_BIT_FREQ_MASK; snd_tea575x_write(tea, tea->val); tea->freq = snd_tea575x_val_to_freq(tea, tea->val); @@ -190,23 +247,57 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } +static int vidioc_enum_freq_bands(struct file *file, void *priv, + struct v4l2_frequency_band *band) +{ + struct snd_tea575x *tea = video_drvdata(file); + int index; + + if (band->tuner != 0) + return -EINVAL; + + switch (band->index) { + case 0: + if (tea->tea5759) + index = BAND_FM_JAPAN; + else + index = BAND_FM; + break; + case 1: + if (tea->has_am) { + index = BAND_AM; + break; + } + /* Fall through */ + default: + return -EINVAL; + } + + *band = bands[index]; + if (!tea->cannot_read_data) + band->capability |= V4L2_TUNER_CAP_HWSEEK_BOUNDED; + + return 0; +} + static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { struct snd_tea575x *tea = video_drvdata(file); + struct v4l2_frequency_band band_fm = { 0, }; if (v->index > 0) return -EINVAL; snd_tea575x_read(tea); + vidioc_enum_freq_bands(file, priv, &band_fm); - strcpy(v->name, "FM"); + memset(v, 0, sizeof(*v)); + strlcpy(v->name, tea->has_am ? "FM/AM" : "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; - v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; - if (!tea->cannot_read_data) - v->capability |= V4L2_TUNER_CAP_HWSEEK_BOUNDED; - v->rangelow = FREQ_LO; - v->rangehigh = FREQ_HI; + v->capability = band_fm.capability; + v->rangelow = tea->has_am ? bands[BAND_AM].rangelow : band_fm.rangelow; + v->rangehigh = band_fm.rangehigh; v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; v->audmode = (tea->val & TEA575X_BIT_MONO) ? V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO; @@ -218,13 +309,17 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { struct snd_tea575x *tea = video_drvdata(file); + u32 orig_val = tea->val; if (v->index) return -EINVAL; tea->val &= ~TEA575X_BIT_MONO; if (v->audmode == V4L2_TUNER_MODE_MONO) tea->val |= TEA575X_BIT_MONO; - snd_tea575x_write(tea, tea->val); + /* Only apply changes if currently tuning FM */ + if (tea->band != BAND_AM && tea->val != orig_val) + snd_tea575x_set_freq(tea); + return 0; } @@ -248,24 +343,56 @@ static int vidioc_s_frequency(struct file *file, void *priv, if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) return -EINVAL; - tea->val &= ~TEA575X_BIT_SEARCH; - tea->freq = clamp(f->frequency, FREQ_LO, FREQ_HI); + if (tea->has_am && f->frequency < (20000 * 16)) + tea->band = BAND_AM; + else if (tea->tea5759) + tea->band = BAND_FM_JAPAN; + else + tea->band = BAND_FM; + + tea->freq = clamp(f->frequency, bands[tea->band].rangelow, + bands[tea->band].rangehigh); snd_tea575x_set_freq(tea); return 0; } static int vidioc_s_hw_freq_seek(struct file *file, void *fh, - struct v4l2_hw_freq_seek *a) + const struct v4l2_hw_freq_seek *a) { struct snd_tea575x *tea = video_drvdata(file); unsigned long timeout; - int i; + int i, spacing; if (tea->cannot_read_data) return -ENOTTY; if (a->tuner || a->wrap_around) return -EINVAL; + if (file->f_flags & O_NONBLOCK) + return -EWOULDBLOCK; + + if (a->rangelow || a->rangehigh) { + for (i = 0; i < ARRAY_SIZE(bands); i++) { + if ((i == BAND_FM && tea->tea5759) || + (i == BAND_FM_JAPAN && !tea->tea5759) || + (i == BAND_AM && !tea->has_am)) + continue; + if (bands[i].rangelow == a->rangelow && + bands[i].rangehigh == a->rangehigh) + break; + } + if (i == ARRAY_SIZE(bands)) + return -EINVAL; /* No matching band found */ + if (i != tea->band) { + tea->band = i; + tea->freq = clamp(tea->freq, bands[i].rangelow, + bands[i].rangehigh); + snd_tea575x_set_freq(tea); + } + } + + spacing = (tea->band == BAND_AM) ? 5 : 50; /* kHz */ + /* clear the frequency, HW will fill it in */ tea->val &= ~TEA575X_BIT_FREQ_MASK; tea->val |= TEA575X_BIT_SEARCH; @@ -297,10 +424,10 @@ static int vidioc_s_hw_freq_seek(struct file *file, void *fh, if (freq == 0) /* shouldn't happen */ break; /* - * if we moved by less than 50 kHz, or in the wrong - * direction, continue seeking + * if we moved by less than the spacing, or in the + * wrong direction, continue seeking */ - if (abs(tea->freq - freq) < 16 * 50 || + if (abs(tea->freq - freq) < 16 * spacing || (a->seek_upward && freq < tea->freq) || (!a->seek_upward && freq > tea->freq)) { snd_tea575x_write(tea, tea->val); @@ -344,6 +471,7 @@ static const struct v4l2_ioctl_ops tea575x_ioctl_ops = { .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, .vidioc_s_hw_freq_seek = vidioc_s_hw_freq_seek, + .vidioc_enum_freq_bands = vidioc_enum_freq_bands, .vidioc_log_status = v4l2_ctrl_log_status, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, @@ -446,3 +574,4 @@ module_exit(alsa_tea575x_module_exit) EXPORT_SYMBOL(snd_tea575x_init); EXPORT_SYMBOL(snd_tea575x_exit); +EXPORT_SYMBOL(snd_tea575x_set_freq); diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 52064cfa91f3..a38d9643e9d8 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -117,6 +117,18 @@ config SND_AZT2320 To compile this driver as a module, choose M here: the module will be called snd-azt2320. +config SND_CMI8328 + tristate "C-Media CMI8328" + select SND_WSS_LIB + select SND_OPL3_LIB + select SND_MPU401_UART + help + Say Y here to include support for soundcards based on the + C-Media CMI8328 chip. + + To compile this driver as a module, choose M here: the module + will be called snd-cmi8328. + config SND_CMI8330 tristate "C-Media CMI8330" select SND_WSS_LIB diff --git a/sound/isa/Makefile b/sound/isa/Makefile index 8d781e419e2e..9a15f1497b10 100644 --- a/sound/isa/Makefile +++ b/sound/isa/Makefile @@ -6,6 +6,7 @@ snd-adlib-objs := adlib.o snd-als100-objs := als100.o snd-azt2320-objs := azt2320.o +snd-cmi8328-objs := cmi8328.o snd-cmi8330-objs := cmi8330.o snd-es18xx-objs := es18xx.o snd-opl3sa2-objs := opl3sa2.o @@ -16,6 +17,7 @@ snd-sscape-objs := sscape.o obj-$(CONFIG_SND_ADLIB) += snd-adlib.o obj-$(CONFIG_SND_ALS100) += snd-als100.o obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o +obj-$(CONFIG_SND_CMI8328) += snd-cmi8328.o obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 94b83b6e46a3..2c2f829c3fd7 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -63,11 +63,6 @@ MODULE_PARM_DESC(enable, "Enable ad1816a based soundcard."); module_param_array(clockfreq, int, NULL, 0444); MODULE_PARM_DESC(clockfreq, "Clock frequency for ad1816a driver (default = 0)."); -struct snd_card_ad1816a { - struct pnp_dev *dev; - struct pnp_dev *devmpu; -}; - static struct pnp_card_device_id snd_ad1816a_pnpids[] = { /* Analog Devices AD1815 */ { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, @@ -99,25 +94,16 @@ MODULE_DEVICE_TABLE(pnp_card, snd_ad1816a_pnpids); #define DRIVER_NAME "snd-card-ad1816a" -static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acard, - struct pnp_card_link *card, +static int __devinit snd_card_ad1816a_pnp(int dev, struct pnp_card_link *card, const struct pnp_card_device_id *id) { struct pnp_dev *pdev; int err; - acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); - if (acard->dev == NULL) + pdev = pnp_request_card_device(card, id->devs[0].id, NULL); + if (pdev == NULL) return -EBUSY; - acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); - if (acard->devmpu == NULL) { - mpu_port[dev] = -1; - snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n"); - } - - pdev = acard->dev; - err = pnp_activate_dev(pdev); if (err < 0) { printk(KERN_ERR PFX "AUDIO PnP configure failure\n"); @@ -130,16 +116,17 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar dma2[dev] = pnp_dma(pdev, 1); irq[dev] = pnp_irq(pdev, 0); - if (acard->devmpu == NULL) + pdev = pnp_request_card_device(card, id->devs[1].id, NULL); + if (pdev == NULL) { + mpu_port[dev] = -1; + snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n"); return 0; - - pdev = acard->devmpu; + } err = pnp_activate_dev(pdev); if (err < 0) { printk(KERN_ERR PFX "MPU401 PnP configure failure\n"); mpu_port[dev] = -1; - acard->devmpu = NULL; } else { mpu_port[dev] = pnp_port_start(pdev, 0); mpu_irq[dev] = pnp_irq(pdev, 0); @@ -153,18 +140,17 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard { int error; struct snd_card *card; - struct snd_card_ad1816a *acard; struct snd_ad1816a *chip; struct snd_opl3 *opl3; struct snd_timer *timer; error = snd_card_create(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_ad1816a), &card); + sizeof(struct snd_ad1816a), &card); if (error < 0) return error; - acard = card->private_data; + chip = card->private_data; - if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) { + if ((error = snd_card_ad1816a_pnp(dev, pcard, pid))) { snd_card_free(card); return error; } @@ -174,7 +160,7 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard irq[dev], dma1[dev], dma2[dev], - &chip)) < 0) { + chip)) < 0) { snd_card_free(card); return error; } @@ -258,13 +244,37 @@ static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_ad1816a_pnp_suspend(struct pnp_card_link *pcard, + pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_ad1816a_suspend(card->private_data); + return 0; +} + +static int snd_ad1816a_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + + snd_ad1816a_resume(card->private_data); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pnp_card_driver ad1816a_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "ad1816a", .id_table = snd_ad1816a_pnpids, .probe = snd_ad1816a_pnp_detect, .remove = __devexit_p(snd_ad1816a_pnp_remove), - /* FIXME: suspend/resume */ +#ifdef CONFIG_PM + .suspend = snd_ad1816a_pnp_suspend, + .resume = snd_ad1816a_pnp_resume, +#endif }; static int __init alsa_card_ad1816a_init(void) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 177eed3271bc..db64df6023e0 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -491,7 +491,7 @@ static int snd_ad1816a_capture_close(struct snd_pcm_substream *substream) } -static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip) +static void snd_ad1816a_init(struct snd_ad1816a *chip) { unsigned long flags; @@ -511,6 +511,32 @@ static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip) spin_unlock_irqrestore(&chip->lock, flags); } +#ifdef CONFIG_PM +void snd_ad1816a_suspend(struct snd_ad1816a *chip) +{ + int reg; + unsigned long flags; + + snd_pcm_suspend_all(chip->pcm); + spin_lock_irqsave(&chip->lock, flags); + for (reg = 0; reg < 48; reg++) + chip->image[reg] = snd_ad1816a_read(chip, reg); + spin_unlock_irqrestore(&chip->lock, flags); +} + +void snd_ad1816a_resume(struct snd_ad1816a *chip) +{ + int reg; + unsigned long flags; + + snd_ad1816a_init(chip); + spin_lock_irqsave(&chip->lock, flags); + for (reg = 0; reg < 48; reg++) + snd_ad1816a_write(chip, reg, chip->image[reg]); + spin_unlock_irqrestore(&chip->lock, flags); +} +#endif + static int __devinit snd_ad1816a_probe(struct snd_ad1816a *chip) { unsigned long flags; @@ -548,7 +574,6 @@ static int snd_ad1816a_free(struct snd_ad1816a *chip) snd_dma_disable(chip->dma2); free_dma(chip->dma2); } - kfree(chip); return 0; } @@ -573,19 +598,13 @@ static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip) int __devinit snd_ad1816a_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, - struct snd_ad1816a **rchip) + struct snd_ad1816a *chip) { static struct snd_device_ops ops = { .dev_free = snd_ad1816a_dev_free, }; int error; - struct snd_ad1816a *chip; - - *rchip = NULL; - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) - return -ENOMEM; chip->irq = -1; chip->dma1 = -1; chip->dma2 = -1; @@ -631,7 +650,6 @@ int __devinit snd_ad1816a_create(struct snd_card *card, return error; } - *rchip = chip; return 0; } diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c new file mode 100644 index 000000000000..bde60139bb95 --- /dev/null +++ b/sound/isa/cmi8328.c @@ -0,0 +1,483 @@ +/* + * Driver for C-Media CMI8328-based soundcards, such as AudioExcel AV500 + * Copyright (c) 2012 Ondrej Zary + * + * AudioExcel AV500 card consists of: + * - CMI8328 - main chip (SB Pro emulation, gameport, OPL3, MPU401, CD-ROM) + * - CS4231A - WSS codec + * - Dream SAM9233+GMS950400+RAM+ROM: Wavetable MIDI, connected to MPU401 + */ + +#include <linux/init.h> +#include <linux/isa.h> +#include <linux/module.h> +#include <linux/gameport.h> +#include <asm/dma.h> +#include <sound/core.h> +#include <sound/wss.h> +#include <sound/opl3.h> +#include <sound/mpu401.h> +#define SNDRV_LEGACY_FIND_FREE_IOPORT +#define SNDRV_LEGACY_FIND_FREE_IRQ +#define SNDRV_LEGACY_FIND_FREE_DMA +#include <sound/initval.h> + +MODULE_AUTHOR("Ondrej Zary <linux@rainbow-software.org>"); +MODULE_DESCRIPTION("C-Media CMI8328"); +MODULE_LICENSE("GPL"); + +#if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE) +#define SUPPORT_JOYSTICK 1 +#endif + +/* I/O port is configured by jumpers on the card to one of these */ +static int cmi8328_ports[] = { 0x530, 0xe80, 0xf40, 0x604 }; +#define CMI8328_MAX ARRAY_SIZE(cmi8328_ports) + +static int index[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = -1}; +static char *id[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = NULL}; +static long port[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_PORT}; +static int irq[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_IRQ}; +static int dma1[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_DMA}; +static int dma2[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_DMA}; +static long mpuport[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_PORT}; +static int mpuirq[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = SNDRV_AUTO_IRQ}; +#ifdef SUPPORT_JOYSTICK +static bool gameport[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = true}; +#endif + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for CMI8328 soundcard."); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for CMI8328 soundcard."); + +module_param_array(port, long, NULL, 0444); +MODULE_PARM_DESC(port, "Port # for CMI8328 driver."); +module_param_array(irq, int, NULL, 0444); +MODULE_PARM_DESC(irq, "IRQ # for CMI8328 driver."); +module_param_array(dma1, int, NULL, 0444); +MODULE_PARM_DESC(dma1, "DMA1 for CMI8328 driver."); +module_param_array(dma2, int, NULL, 0444); +MODULE_PARM_DESC(dma2, "DMA2 for CMI8328 driver."); + +module_param_array(mpuport, long, NULL, 0444); +MODULE_PARM_DESC(mpuport, "MPU-401 port # for CMI8328 driver."); +module_param_array(mpuirq, int, NULL, 0444); +MODULE_PARM_DESC(mpuirq, "IRQ # for CMI8328 MPU-401 port."); +#ifdef SUPPORT_JOYSTICK +module_param_array(gameport, bool, NULL, 0444); +MODULE_PARM_DESC(gameport, "Enable gameport."); +#endif + +struct snd_cmi8328 { + u16 port; + u8 cfg[3]; + u8 wss_cfg; + struct snd_card *card; + struct snd_wss *wss; +#ifdef SUPPORT_JOYSTICK + struct gameport *gameport; +#endif +}; + +/* CMI8328 configuration registers */ +#define CFG1 0x61 +#define CFG1_SB_DISABLE (1 << 0) +#define CFG1_GAMEPORT (1 << 1) +/* + * bit 0: SB: 0=enabled, 1=disabled + * bit 1: gameport: 0=disabled, 1=enabled + * bits 2-4: SB IRQ: 001=3, 010=5, 011=7, 100=9, 101=10, 110=11 + * bits 5-6: SB DMA: 00=disabled (when SB disabled), 01=DMA0, 10=DMA1, 11=DMA3 + * bit 7: SB port: 0=0x220, 1=0x240 + */ +#define CFG2 0x62 +#define CFG2_MPU_ENABLE (1 << 2) +/* + * bits 0-1: CD-ROM mode: 00=disabled, 01=Panasonic, 10=Sony/Mitsumi/Wearnes, + 11=IDE + * bit 2: MPU401: 0=disabled, 1=enabled + * bits 3-4: MPU401 IRQ: 00=3, 01=5, 10=7, 11=9, + * bits 5-7: MPU401 port: 000=0x300, 001=0x310, 010=0x320, 011=0x330, 100=0x332, + 101=0x334, 110=0x336 + */ +#define CFG3 0x63 +/* + * bits 0-2: CD-ROM IRQ: 000=disabled, 001=3, 010=5, 011=7, 100=9, 101=10, + 110=11 + * bits 3-4: CD-ROM DMA: 00=disabled, 01=DMA0, 10=DMA1, 11=DMA3 + * bits 5-7: CD-ROM port: 000=0x300, 001=0x310, 010=0x320, 011=0x330, 100=0x340, + 101=0x350, 110=0x360, 111=0x370 + */ + +static u8 snd_cmi8328_cfg_read(u16 port, u8 reg) +{ + outb(0x43, port + 3); + outb(0x21, port + 3); + outb(reg, port + 3); + return inb(port); +} + +static void snd_cmi8328_cfg_write(u16 port, u8 reg, u8 val) +{ + outb(0x43, port + 3); + outb(0x21, port + 3); + outb(reg, port + 3); + outb(val, port + 3); /* yes, value goes to the same port as index */ +} + +static void snd_cmi8328_cfg_save(u16 port, u8 cfg[]) +{ + cfg[0] = snd_cmi8328_cfg_read(port, CFG1); + cfg[1] = snd_cmi8328_cfg_read(port, CFG2); + cfg[2] = snd_cmi8328_cfg_read(port, CFG3); +} + +static void snd_cmi8328_cfg_restore(u16 port, u8 cfg[]) +{ + snd_cmi8328_cfg_write(port, CFG1, cfg[0]); + snd_cmi8328_cfg_write(port, CFG2, cfg[1]); + snd_cmi8328_cfg_write(port, CFG3, cfg[2]); +} + +static int __devinit snd_cmi8328_mixer(struct snd_wss *chip) +{ + struct snd_card *card; + struct snd_ctl_elem_id id1, id2; + int err; + + card = chip->card; + + memset(&id1, 0, sizeof(id1)); + memset(&id2, 0, sizeof(id2)); + id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + /* rename AUX0 switch to CD */ + strcpy(id1.name, "Aux Playback Switch"); + strcpy(id2.name, "CD Playback Switch"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) { + snd_printk(KERN_ERR "error renaming control\n"); + return err; + } + /* rename AUX0 volume to CD */ + strcpy(id1.name, "Aux Playback Volume"); + strcpy(id2.name, "CD Playback Volume"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) { + snd_printk(KERN_ERR "error renaming control\n"); + return err; + } + /* rename AUX1 switch to Synth */ + strcpy(id1.name, "Aux Playback Switch"); + id1.index = 1; + strcpy(id2.name, "Synth Playback Switch"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) { + snd_printk(KERN_ERR "error renaming control\n"); + return err; + } + /* rename AUX1 volume to Synth */ + strcpy(id1.name, "Aux Playback Volume"); + id1.index = 1; + strcpy(id2.name, "Synth Playback Volume"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) { + snd_printk(KERN_ERR "error renaming control\n"); + return err; + } + + return 0; +} + +/* find index of an item in "-1"-ended array */ +int array_find(int array[], int item) +{ + int i; + + for (i = 0; array[i] != -1; i++) + if (array[i] == item) + return i; + + return -1; +} +/* the same for long */ +int array_find_l(long array[], long item) +{ + int i; + + for (i = 0; array[i] != -1; i++) + if (array[i] == item) + return i; + + return -1; +} + +static int __devinit snd_cmi8328_probe(struct device *pdev, unsigned int ndev) +{ + struct snd_card *card; + struct snd_opl3 *opl3; + struct snd_cmi8328 *cmi; +#ifdef SUPPORT_JOYSTICK + struct resource *res; +#endif + int err, pos; + static long mpu_ports[] = { 0x330, 0x300, 0x310, 0x320, 0x332, 0x334, + 0x336, -1 }; + static u8 mpu_port_bits[] = { 3, 0, 1, 2, 4, 5, 6 }; + static int mpu_irqs[] = { 9, 7, 5, 3, -1 }; + static u8 mpu_irq_bits[] = { 3, 2, 1, 0 }; + static int irqs[] = { 9, 10, 11, 7, -1 }; + static u8 irq_bits[] = { 2, 3, 4, 1 }; + static int dma1s[] = { 3, 1, 0, -1 }; + static u8 dma_bits[] = { 3, 2, 1 }; + static int dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, {0, -1} }; + u16 port = cmi8328_ports[ndev]; + u8 val; + + /* 0xff is invalid configuration (but settable - hope it isn't set) */ + if (snd_cmi8328_cfg_read(port, CFG1) == 0xff) + return -ENODEV; + /* the SB disable bit must NEVER EVER be cleared or the WSS dies */ + snd_cmi8328_cfg_write(port, CFG1, CFG1_SB_DISABLE); + if (snd_cmi8328_cfg_read(port, CFG1) != CFG1_SB_DISABLE) + return -ENODEV; + /* disable everything first */ + snd_cmi8328_cfg_write(port, CFG2, 0); /* disable CDROM and MPU401 */ + snd_cmi8328_cfg_write(port, CFG3, 0); /* disable CDROM IRQ and DMA */ + + if (irq[ndev] == SNDRV_AUTO_IRQ) { + irq[ndev] = snd_legacy_find_free_irq(irqs); + if (irq[ndev] < 0) { + snd_printk(KERN_ERR "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma1[ndev] == SNDRV_AUTO_DMA) { + dma1[ndev] = snd_legacy_find_free_dma(dma1s); + if (dma1[ndev] < 0) { + snd_printk(KERN_ERR "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[ndev] == SNDRV_AUTO_DMA) { + dma2[ndev] = snd_legacy_find_free_dma(dma2s[dma1[ndev] % 4]); + if (dma2[ndev] < 0) { + snd_printk(KERN_WARNING "unable to find a free DMA2, full-duplex will not work\n"); + dma2[ndev] = -1; + } + } + /* configure WSS IRQ... */ + pos = array_find(irqs, irq[ndev]); + if (pos < 0) { + snd_printk(KERN_ERR "invalid IRQ %d\n", irq[ndev]); + return -EINVAL; + } + val = irq_bits[pos] << 3; + /* ...and DMA... */ + pos = array_find(dma1s, dma1[ndev]); + if (pos < 0) { + snd_printk(KERN_ERR "invalid DMA1 %d\n", dma1[ndev]); + return -EINVAL; + } + val |= dma_bits[pos]; + /* ...and DMA2 */ + if (dma2[ndev] >= 0 && dma1[ndev] != dma2[ndev]) { + pos = array_find(dma2s[dma1[ndev]], dma2[ndev]); + if (pos < 0) { + snd_printk(KERN_ERR "invalid DMA2 %d\n", dma2[ndev]); + return -EINVAL; + } + val |= 0x04; /* enable separate capture DMA */ + } + outb(val, port); + + err = snd_card_create(index[ndev], id[ndev], THIS_MODULE, + sizeof(struct snd_cmi8328), &card); + if (err < 0) + return err; + cmi = card->private_data; + cmi->card = card; + cmi->port = port; + cmi->wss_cfg = val; + snd_card_set_dev(card, pdev); + + err = snd_wss_create(card, port + 4, -1, irq[ndev], dma1[ndev], + dma2[ndev], WSS_HW_DETECT, 0, &cmi->wss); + if (err < 0) + goto error; + + err = snd_wss_pcm(cmi->wss, 0, NULL); + if (err < 0) + goto error; + + err = snd_wss_mixer(cmi->wss); + if (err < 0) + goto error; + err = snd_cmi8328_mixer(cmi->wss); + if (err < 0) + goto error; + + if (snd_wss_timer(cmi->wss, 0, NULL) < 0) + snd_printk(KERN_WARNING "error initializing WSS timer\n"); + + if (mpuport[ndev] == SNDRV_AUTO_PORT) { + mpuport[ndev] = snd_legacy_find_free_ioport(mpu_ports, 2); + if (mpuport[ndev] < 0) + snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); + } + if (mpuirq[ndev] == SNDRV_AUTO_IRQ) { + mpuirq[ndev] = snd_legacy_find_free_irq(mpu_irqs); + if (mpuirq[ndev] < 0) + snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); + } + /* enable and configure MPU401 */ + if (mpuport[ndev] > 0 && mpuirq[ndev] > 0) { + val = CFG2_MPU_ENABLE; + pos = array_find_l(mpu_ports, mpuport[ndev]); + if (pos < 0) + snd_printk(KERN_WARNING "invalid MPU401 port 0x%lx\n", + mpuport[ndev]); + else { + val |= mpu_port_bits[pos] << 5; + pos = array_find(mpu_irqs, mpuirq[ndev]); + if (pos < 0) + snd_printk(KERN_WARNING "invalid MPU401 IRQ %d\n", + mpuirq[ndev]); + else { + val |= mpu_irq_bits[pos] << 3; + snd_cmi8328_cfg_write(port, CFG2, val); + if (snd_mpu401_uart_new(card, 0, + MPU401_HW_MPU401, mpuport[ndev], + 0, mpuirq[ndev], NULL) < 0) + snd_printk(KERN_ERR "error initializing MPU401\n"); + } + } + } + /* OPL3 is hardwired to 0x388 and cannot be disabled */ + if (snd_opl3_create(card, 0x388, 0x38a, OPL3_HW_AUTO, 0, &opl3) < 0) + snd_printk(KERN_ERR "error initializing OPL3\n"); + else + if (snd_opl3_hwdep_new(opl3, 0, 1, NULL) < 0) + snd_printk(KERN_WARNING "error initializing OPL3 hwdep\n"); + + strcpy(card->driver, "CMI8328"); + strcpy(card->shortname, "C-Media CMI8328"); + sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d,%d", + card->shortname, cmi->wss->port, irq[ndev], dma1[ndev], + (dma2[ndev] >= 0) ? dma2[ndev] : dma1[ndev]); + + dev_set_drvdata(pdev, card); + err = snd_card_register(card); + if (err < 0) + goto error; +#ifdef SUPPORT_JOYSTICK + if (!gameport[ndev]) + return 0; + /* gameport is hardwired to 0x200 */ + res = request_region(0x200, 8, "CMI8328 gameport"); + if (!res) + snd_printk(KERN_WARNING "unable to allocate gameport I/O port\n"); + else { + struct gameport *gp = cmi->gameport = gameport_allocate_port(); + if (!cmi->gameport) + release_and_free_resource(res); + else { + gameport_set_name(gp, "CMI8328 Gameport"); + gameport_set_phys(gp, "%s/gameport0", dev_name(pdev)); + gameport_set_dev_parent(gp, pdev); + gp->io = 0x200; + gameport_set_port_data(gp, res); + /* Enable gameport */ + snd_cmi8328_cfg_write(port, CFG1, + CFG1_SB_DISABLE | CFG1_GAMEPORT); + gameport_register_port(gp); + } + } +#endif + return 0; +error: + snd_card_free(card); + + return err; +} + +static int __devexit snd_cmi8328_remove(struct device *pdev, unsigned int dev) +{ + struct snd_card *card = dev_get_drvdata(pdev); + struct snd_cmi8328 *cmi = card->private_data; + +#ifdef SUPPORT_JOYSTICK + if (cmi->gameport) { + struct resource *res = gameport_get_port_data(cmi->gameport); + gameport_unregister_port(cmi->gameport); + release_and_free_resource(res); + } +#endif + /* disable everything */ + snd_cmi8328_cfg_write(cmi->port, CFG1, CFG1_SB_DISABLE); + snd_cmi8328_cfg_write(cmi->port, CFG2, 0); + snd_cmi8328_cfg_write(cmi->port, CFG3, 0); + snd_card_free(card); + dev_set_drvdata(pdev, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_cmi8328_suspend(struct device *pdev, unsigned int n, + pm_message_t state) +{ + struct snd_card *card = dev_get_drvdata(pdev); + struct snd_cmi8328 *cmi; + + if (!card) /* ignore absent devices */ + return 0; + cmi = card->private_data; + snd_cmi8328_cfg_save(cmi->port, cmi->cfg); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(cmi->wss->pcm); + cmi->wss->suspend(cmi->wss); + + return 0; +} + +static int snd_cmi8328_resume(struct device *pdev, unsigned int n) +{ + struct snd_card *card = dev_get_drvdata(pdev); + struct snd_cmi8328 *cmi; + + if (!card) /* ignore absent devices */ + return 0; + cmi = card->private_data; + snd_cmi8328_cfg_restore(cmi->port, cmi->cfg); + outb(cmi->wss_cfg, cmi->port); + cmi->wss->resume(cmi->wss); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + + return 0; +} +#endif + +static struct isa_driver snd_cmi8328_driver = { + .probe = snd_cmi8328_probe, + .remove = __devexit_p(snd_cmi8328_remove), +#ifdef CONFIG_PM + .suspend = snd_cmi8328_suspend, + .resume = snd_cmi8328_resume, +#endif + .driver = { + .name = "cmi8328" + }, +}; + +static int __init alsa_card_cmi8328_init(void) +{ + return isa_register_driver(&snd_cmi8328_driver, CMI8328_MAX); +} + +static void __exit alsa_card_cmi8328_exit(void) +{ + isa_unregister_driver(&snd_cmi8328_driver); +} + +module_init(alsa_card_cmi8328_init) +module_exit(alsa_card_cmi8328_exit) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index a76bc8d27c1d..3fc8b66fd167 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -443,9 +443,8 @@ static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus) for (i = 0; i < 8; ++i) iwave[i] = snd_gf1_peek(gus, bank_pos + i); #ifdef CONFIG_SND_DEBUG_ROM - printk(KERN_DEBUG "ROM at 0x%06x = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", bank_pos, - iwave[0], iwave[1], iwave[2], iwave[3], - iwave[4], iwave[5], iwave[6], iwave[7]); + printk(KERN_DEBUG "ROM at 0x%06x = %*phC\n", bank_pos, + 8, iwave); #endif if (strncmp(iwave, "INTRWAVE", 8)) continue; /* first check */ diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index c24594c866f4..3d1afb612b35 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -37,6 +37,7 @@ #include <sound/opl4.h> #include <sound/control.h> #include <sound/info.h> +#define SNDRV_LEGACY_FIND_FREE_IOPORT #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -770,20 +771,6 @@ static int __devinit snd_miro_mixer(struct snd_card *card, return 0; } -static long snd_legacy_find_free_ioport(long *port_table, long size) -{ - while (*port_table != -1) { - struct resource *res; - if ((res = request_region(*port_table, size, - "ALSA test")) != NULL) { - release_and_free_resource(res); - return *port_table; - } - port_table++; - } - return -1; -} - static int __devinit snd_miro_init(struct snd_miro *chip, unsigned short hardware) { diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index f8fbe22515c9..2899c9fd1ceb 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -39,6 +39,7 @@ #ifndef OPTi93X #include <sound/opl4.h> #endif +#define SNDRV_LEGACY_FIND_FREE_IOPORT #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -185,19 +186,6 @@ static char * snd_opti9xx_names[] = { "82C930", "82C931", "82C933" }; - -static long __devinit snd_legacy_find_free_ioport(long *port_table, long size) -{ - while (*port_table != -1) { - if (request_region(*port_table, size, "ALSA test")) { - release_region(*port_table, size); - return *port_table; - } - port_table++; - } - return -1; -} - static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) { diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 71887874679c..2aae6a0efbcd 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -417,9 +417,6 @@ size_dram(struct snd_emu8000 *emu) EMU8000_SMLD_READ(emu); /* discard stale data */ if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) break; /* no memory at this address */ - - detected_size = size; - snd_emu8000_read_wait(emu); /* @@ -432,6 +429,18 @@ size_dram(struct snd_emu8000 *emu) if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1) break; /* we must have wrapped around */ snd_emu8000_read_wait(emu); + + /* Otherwise, it's valid memory. */ + detected_size = size + 512 * 1024; + } + + /* Distinguish 512 KiB from 0. */ + if (detected_size == 0) { + snd_emu8000_read_wait(emu); + EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET); + EMU8000_SMLD_READ(emu); /* discard stale data */ + if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1) + detected_size = 512 * 1024; } /* wait until FULL bit in SMAxW register is false */ diff --git a/sound/isa/sb/emu8000_callback.c b/sound/isa/sb/emu8000_callback.c index 344b4355be1c..72a9ac5efb40 100644 --- a/sound/isa/sb/emu8000_callback.c +++ b/sound/isa/sb/emu8000_callback.c @@ -175,7 +175,7 @@ get_voice(struct snd_emux *emu, struct snd_emux_port *port) hw = emu->hw; for (i = 0; i < END; i++) { - best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */; + best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */ best[i].voice = -1; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 405f8b6a58b5..b1bf8d4e6494 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -538,7 +538,7 @@ munge_int32 (unsigned int src, /* Note: we leave the upper bits in place */ dst++; - }; + } return dst; }; diff --git a/sound/last.c b/sound/last.c index 7ffc182e0844..43f222825038 100644 --- a/sound/last.c +++ b/sound/last.c @@ -19,7 +19,6 @@ * */ -#define SNDRV_MAIN_OBJECT_FILE #include <linux/init.h> #include <sound/core.h> diff --git a/sound/oss/.gitignore b/sound/oss/.gitignore index 7efb12b45502..12a3920d6fb6 100644 --- a/sound/oss/.gitignore +++ b/sound/oss/.gitignore @@ -1,4 +1,3 @@ #Ignore generated files -maui_boot.h pss_boot.h trix_boot.h diff --git a/sound/oss/audio.c b/sound/oss/audio.c index 4b958b1c497c..09c932f899b8 100644 --- a/sound/oss/audio.c +++ b/sound/oss/audio.c @@ -354,7 +354,7 @@ int audio_read(int dev, struct file *file, char __user *buf, int count) if(copy_to_user(&(buf)[p], fixit, l)) return -EFAULT; - }; + } DMAbuf_rmchars(dev, buf_no, l); diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c index 407cd677950b..c5c24409ceb0 100644 --- a/sound/oss/opl3.c +++ b/sound/oss/opl3.c @@ -1190,7 +1190,7 @@ static int opl3_init(int ioaddr, struct module *owner) for (i = 0; i < 18; i++) pv_map[i].ioaddr = devc->left_io; - }; + } conf_printf2(devc->fm_info.name, ioaddr, 0, -1, -1); for (i = 0; i < SBFM_MAXINSTR; i++) diff --git a/sound/oss/pss.c b/sound/oss/pss.c index 0f32a561f15f..145e36b2cfd0 100644 --- a/sound/oss/pss.c +++ b/sound/oss/pss.c @@ -359,7 +359,7 @@ static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size { /*_____ Send the next byte */ outw (*block++, REG (PSS_DATA)); - }; + } count++; } diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c index 5c773dff5ac5..c0be085e4a20 100644 --- a/sound/oss/sb_ess.c +++ b/sound/oss/sb_ess.c @@ -1104,15 +1104,15 @@ int ess_init(sb_devc * devc, struct address_info *hw_config) default: printk (KERN_ERR "Invalid esstype=%d specified\n", devc->sbmo.esstype); return 0; - }; + } if (submodel != -1) { devc->submodel = submodel; sprintf (modelname, "ES%d", devc->sbmo.esstype); chip = modelname; - }; + } if (chip == NULL && (ess_minor & 0x0f) < 8) { chip = "ES688"; - }; + } #ifdef FKS_TEST FKS_test (devc); #endif @@ -1122,7 +1122,7 @@ FKS_test (devc); */ if (chip == NULL && devc->sbmo.esstype == ESSTYPE_LIKE20) { chip = "ES1688"; - }; + } if (chip == NULL) { int type; @@ -1150,8 +1150,8 @@ FKS_test (devc); if ((type & 0x00ff) != ((type >> 8) & 0x00ff)) { printk ("ess_init: Unrecognized %04x\n", type); } - }; - }; + } + } #if 0 /* * this one failed: @@ -1182,10 +1182,10 @@ FKS_test (devc); chip = "ES1788"; devc->submodel = SUBMDL_ES1788; } - }; + } if (chip == NULL) { chip = "ES1688"; - }; + } printk ( KERN_INFO "ESS chip %s %s%s\n" , chip @@ -1293,7 +1293,7 @@ printk(KERN_INFO "ess_set_dma_hw: dma8=%d,dma16=%d,dup=%d\n" default: printk(KERN_ERR "ESS1887: Invalid DMA16 %d\n", dma); return 0; - }; + } ess_chgmixer (devc, 0x78, 0x20, dma16_bits); ess_chgmixer (devc, 0x7d, 0x07, dma_bits); } @@ -1584,7 +1584,7 @@ printk(KERN_INFO "FKS: write mixer %x: %x\n", port, value); udelay(20); outb(((unsigned char) (value & 0xff)), MIXER_DATA); udelay(20); - }; + } spin_unlock_irqrestore(&devc->lock, flags); } @@ -1761,7 +1761,7 @@ int ess_mixer_reset (sb_devc * devc) ess_chgmixer(devc, 0x7a, 0x18, 0x08); ess_chgmixer(devc, 0x1c, 0x07, 0x07); break; - }; + } /* * Call set_recmask for proper initialization */ diff --git a/sound/oss/sb_mixer.c b/sound/oss/sb_mixer.c index f8f3b7a66b73..acf7586aeb47 100644 --- a/sound/oss/sb_mixer.c +++ b/sound/oss/sb_mixer.c @@ -410,7 +410,7 @@ static int set_recmask(sb_devc * devc, int mask) case MDL_SMW: if (devc->model == MDL_ESS && ess_set_recmask (devc, &devmask)) { break; - }; + } if (devmask != SOUND_MASK_MIC && devmask != SOUND_MASK_LINE && devmask != SOUND_MASK_CD) @@ -666,7 +666,7 @@ static void sb_mixer_reset(sb_devc * devc) if (devc->model != MDL_ESS || !ess_mixer_reset (devc)) { set_recmask(devc, SOUND_MASK_MIC); - }; + } } int sb_mixer_init(sb_devc * devc, struct module *owner) diff --git a/sound/oss/sys_timer.c b/sound/oss/sys_timer.c index 8db6aefe15e4..9f039831114c 100644 --- a/sound/oss/sys_timer.c +++ b/sound/oss/sys_timer.c @@ -57,7 +57,7 @@ poll_def_tmr(unsigned long dummy) { def_tmr.expires = (1) + jiffies; add_timer(&def_tmr); - }; + } if (tmr_running) { @@ -103,7 +103,7 @@ def_tmr_open(int dev, int mode) { def_tmr.expires = (1) + jiffies; add_timer(&def_tmr); - }; + } return 0; } diff --git a/sound/oss/uart6850.c b/sound/oss/uart6850.c index f3f914aa92ee..1079133dd6ab 100644 --- a/sound/oss/uart6850.c +++ b/sound/oss/uart6850.c @@ -146,7 +146,7 @@ static int uart6850_open(int dev, int mode, { /* printk("Midi6850: Midi busy\n");*/ return -EBUSY; - }; + } uart6850_cmd(UART_RESET); uart6850_input_loop(); diff --git a/sound/oss/waveartist.c b/sound/oss/waveartist.c index 24c430f721d4..672af8b56542 100644 --- a/sound/oss/waveartist.c +++ b/sound/oss/waveartist.c @@ -1482,9 +1482,9 @@ vnc_mute_spkr(wavnc_info *devc) { unsigned long flags; - spin_lock_irqsave(&nw_gpio_lock, flags); + raw_spin_lock_irqsave(&nw_gpio_lock, flags); nw_cpld_modify(CPLD_UNMUTE, devc->spkr_mute_state ? 0 : CPLD_UNMUTE); - spin_unlock_irqrestore(&nw_gpio_lock, flags); + raw_spin_unlock_irqrestore(&nw_gpio_lock, flags); } static void diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index ff3af6e77d61..f99fa2512286 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -2,8 +2,8 @@ config SND_TEA575X tristate - depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO || RADIO_SF16FMR2 || RADIO_MAXIRADIO - default SND_FM801 || SND_ES1968 || RADIO_SF16FMR2 || RADIO_MAXIRADIO + depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO || RADIO_SF16FMR2 || RADIO_MAXIRADIO || RADIO_SHARK + default SND_FM801 || SND_ES1968 || RADIO_SF16FMR2 || RADIO_MAXIRADIO || RADIO_SHARK menuconfig SND_PCI bool "PCI sound devices" diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 9473fca9681d..8b0f99688303 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1271,6 +1271,8 @@ static int snd_ac97_cvol_new(struct snd_card *card, char *name, int reg, unsigne tmp.index = ac97->num; kctl = snd_ctl_new1(&tmp, ac97); } + if (!kctl) + return -ENOMEM; if (reg >= AC97_PHONE && reg <= AC97_PCM) set_tlv_db_scale(kctl, db_scale_5bit_12db_max); else diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index a872d0a82976..66a3bc95fb84 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -2595,6 +2595,21 @@ static void alc650_update_jacks(struct snd_ac97 *ac97) shared ? 0 : 0x100); } +static int alc650_swap_surround_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_pcm_chmap *map = ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK]; + + if (map) { + if (ucontrol->value.integer.value[0]) + map->chmap = snd_pcm_std_chmaps; + else + map->chmap = snd_pcm_alt_chmaps; + } + return snd_ac97_put_volsw(kcontrol, ucontrol); +} + static const struct snd_kcontrol_new snd_ac97_controls_alc650[] = { AC97_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0), AC97_SINGLE("Surround Down Mix", AC97_ALC650_MULTICH, 1, 1, 0), @@ -2608,7 +2623,14 @@ static const struct snd_kcontrol_new snd_ac97_controls_alc650[] = { /* 9: Line-In/Surround share */ /* 10: Mic/CLFE share */ /* 11-13: in IEC958 controls */ - AC97_SINGLE("Swap Surround Slot", AC97_ALC650_MULTICH, 14, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Swap Surround Slot", + .info = snd_ac97_info_volsw, + .get = snd_ac97_get_volsw, + .put = alc650_swap_surround_put, + .private_value = AC97_SINGLE_VALUE(AC97_ALC650_MULTICH, 14, 1, 0), + }, #if 0 /* always set in patch_alc650 */ AC97_SINGLE("IEC958 Input Clock Enable", AC97_ALC650_CLOCK, 0, 1, 0), AC97_SINGLE("IEC958 Input Pin Enable", AC97_ALC650_CLOCK, 1, 1, 0), diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index ee895f3c8605..c7e3c533316e 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -270,7 +270,7 @@ struct snd_ali { spinlock_t reg_lock; spinlock_t voice_alloc; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP struct snd_ali_image *image; #endif }; @@ -1883,7 +1883,7 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int ali_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -1989,7 +1989,7 @@ static SIMPLE_DEV_PM_OPS(ali_pm, ali_suspend, ali_resume); #define ALI_PM_OPS &ali_pm #else #define ALI_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int snd_ali_free(struct snd_ali * codec) { @@ -2000,7 +2000,7 @@ static int snd_ali_free(struct snd_ali * codec) if (codec->port) pci_release_regions(codec->pci); pci_disable_device(codec->pci); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP kfree(codec->image); #endif pci_dev_put(codec->pci_m1533); @@ -2232,7 +2232,7 @@ static int __devinit snd_ali_create(struct snd_card *card, return err; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); if (!codec->image) snd_printk(KERN_WARNING "can't allocate apm buffer\n"); diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 68c4469c6d19..00f157a2cf64 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -765,7 +765,7 @@ static int __devinit snd_als300_create(struct snd_card *card, return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_als300_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 0eeca49c5754..feb2a1436830 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -987,7 +987,7 @@ static void __devexit snd_card_als4000_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_als4000_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -1040,7 +1040,7 @@ static SIMPLE_DEV_PM_OPS(snd_als4000_pm, snd_als4000_suspend, snd_als4000_resume #define SND_ALS4000_PM_OPS &snd_als4000_pm #else #define SND_ALS4000_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver als4000_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index e8de831f98bc..eedc017c1cd8 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -2658,7 +2658,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) hpi_ctl.dst_node_type, hpi_ctl.dst_node_index); continue; - }; + } if (err < 0) return err; } @@ -2968,7 +2968,7 @@ static struct pci_driver driver = { .id_table = asihpi_pci_tbl, .probe = snd_asihpi_probe, .remove = __devexit_p(snd_asihpi_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* .suspend = snd_asihpi_suspend, .resume = snd_asihpi_resume, */ #endif diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 31020d2a868b..368df8b0853e 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -535,7 +535,7 @@ static int snd_atiixp_aclink_reset(struct atiixp *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_atiixp_aclink_down(struct atiixp *chip) { // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */ @@ -1250,6 +1250,7 @@ static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = { static int __devinit snd_atiixp_pcm_new(struct atiixp *chip) { struct snd_pcm *pcm; + struct snd_pcm_chmap *chmap; struct snd_ac97_bus *pbus = chip->ac97_bus; int err, i, num_pcms; @@ -1293,6 +1294,14 @@ static int __devinit snd_atiixp_pcm_new(struct atiixp *chip) snd_dma_pci_data(chip->pci), 64*1024, 128*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, chip->max_channels, 0, + &chmap); + if (err < 0) + return err; + chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; + chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; + /* no SPDIF support on codec? */ if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates) return 0; @@ -1458,7 +1467,7 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock, } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -1533,7 +1542,7 @@ static SIMPLE_DEV_PM_OPS(snd_atiixp_pm, snd_atiixp_suspend, snd_atiixp_resume); #define SND_ATIIXP_PM_OPS &snd_atiixp_pm #else #define SND_ATIIXP_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_PROC_FS diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 79e204ec623f..6fc03d9f2cff 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -511,7 +511,7 @@ static int snd_atiixp_aclink_reset(struct atiixp_modem *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_atiixp_aclink_down(struct atiixp_modem *chip) { // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */ @@ -1113,7 +1113,7 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -1169,7 +1169,7 @@ static SIMPLE_DEV_PM_OPS(snd_atiixp_pm, snd_atiixp_suspend, snd_atiixp_resume); #define SND_ATIIXP_PM_OPS &snd_atiixp_pm #else #define SND_ATIIXP_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_PROC_FS /* diff --git a/sound/pci/au88x0/au88x0_game.c b/sound/pci/au88x0/au88x0_game.c index c07c792bde8d..30a456700d89 100644 --- a/sound/pci/au88x0/au88x0_game.c +++ b/sound/pci/au88x0/au88x0_game.c @@ -100,7 +100,7 @@ static int __devinit vortex_gameport_register(vortex_t * vortex) if (!gp) { printk(KERN_ERR "vortex: cannot allocate memory for gameport\n"); return -ENOMEM; - }; + } gameport_set_name(gp, "AU88x0 Gameport"); gameport_set_phys(gp, "pci%s/gameport0", pci_name(vortex->pci_dev)); diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index e59f120742a4..b2405020284c 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -585,7 +585,7 @@ static int snd_vortex_pcm_vol_put(struct snd_kcontrol *kcontrol, case 4: mixin = p->mixin[i]; break; - }; + } vol = p->vol[i]; vortex_mix_setinputvolumebyte(vortex, vortex->mixplayb[i], mixin, vol); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 4dddd871548b..c03b66b784a3 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -365,7 +365,7 @@ struct snd_azf3328 { * CONFIG_PM register storage below, but that's slightly difficult. */ u16 shadow_reg_ctrl_6AH; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* register value containers for power management * Note: not always full I/O range preserved (similar to Win driver!) */ u32 saved_regs_ctrl[AZF_ALIGN(AZF_IO_SIZE_CTRL_PM) / 4]; @@ -2729,7 +2729,7 @@ snd_azf3328_remove(struct pci_dev *pci) snd_azf3328_dbgcallleave(); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static inline void snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) { @@ -2866,7 +2866,7 @@ static SIMPLE_DEV_PM_OPS(snd_azf3328_pm, snd_azf3328_suspend, snd_azf3328_resume #define SND_AZF3328_PM_OPS &snd_azf3328_pm #else #define SND_AZF3328_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver azf3328_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index e8e8ccc96403..04402c14cb23 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h @@ -710,7 +710,7 @@ struct snd_ca0106 { u16 spi_dac_reg[16]; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP #define NUM_SAVED_VOLUMES 9 unsigned int saved_vol[NUM_SAVED_VOLUMES]; #endif @@ -733,7 +733,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value); int snd_ca0106_spi_write(struct snd_ca0106 * emu, unsigned int data); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip); void snd_ca0106_mixer_resume(struct snd_ca0106 *chip); #else diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 83277b747b36..65c55910566b 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1334,10 +1334,29 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static const struct snd_pcm_chmap_elem surround_map[] = { + { .channels = 2, + .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { } +}; + +static const struct snd_pcm_chmap_elem clfe_map[] = { + { .channels = 2, + .map = { SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, + { } +}; + +static const struct snd_pcm_chmap_elem side_map[] = { + { .channels = 2, + .map = { SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, + { } +}; + static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; + const struct snd_pcm_chmap_elem *map = NULL; int err; err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm); @@ -1350,18 +1369,22 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device) case 0: snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_front_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_0_ops); + map = snd_pcm_std_chmaps; break; case 1: snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_rear_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_1_ops); + map = surround_map; break; case 2: snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_center_lfe_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_2_ops); + map = clfe_map; break; case 3: snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_unknown_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_3_ops); + map = side_map; break; } @@ -1388,6 +1411,11 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device) return err; } + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, + 1 << 2, NULL); + if (err < 0) + return err; + emu->pcm[device] = pcm; return 0; @@ -1871,7 +1899,7 @@ static void __devexit snd_ca0106_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_ca0106_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 84f3f92436b5..68eacf7002d6 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -907,7 +907,7 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP struct ca0106_vol_tbl { unsigned int channel_id; unsigned int reg; @@ -953,4 +953,4 @@ void snd_ca0106_mixer_resume(struct snd_ca0106 *chip) if (chip->details->i2c_adc) ca0106_set_capture_mic_line_in(chip); } -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index b7d6f2b886ef..22122ff26e34 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -504,7 +504,7 @@ struct cmipci { spinlock_t reg_lock; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP unsigned int saved_regs[0x20]; unsigned char saved_mixers[0x20]; #endif @@ -1962,6 +1962,12 @@ static int __devinit snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(cm->pci), 64*1024, 128*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, cm->max_channels, 0, + NULL); + if (err < 0) + return err; + return 0; } @@ -3315,7 +3321,7 @@ static void __devexit snd_cmipci_remove(struct pci_dev *pci) } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -3403,7 +3409,7 @@ static SIMPLE_DEV_PM_OPS(snd_cmipci_pm, snd_cmipci_suspend, snd_cmipci_resume); #define SND_CMIPCI_PM_OPS &snd_cmipci_pm #else #define SND_CMIPCI_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver cmipci_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 45a8317085f4..8e86ec0031fc 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -486,7 +486,7 @@ struct cs4281 { struct gameport *gameport; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u32 suspend_regs[SUSPEND_REGISTERS]; #endif @@ -1977,7 +1977,7 @@ static void __devexit snd_cs4281_remove(struct pci_dev *pci) /* * Power Management */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int saved_regs[SUSPEND_REGISTERS] = { BA0_JSCTL, @@ -2089,7 +2089,7 @@ static SIMPLE_DEV_PM_OPS(cs4281_pm, cs4281_suspend, cs4281_resume); #define CS4281_PM_OPS &cs4281_pm #else #define CS4281_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver cs4281_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 1e007c736a8b..575bed0836ff 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -166,7 +166,7 @@ static struct pci_driver cs46xx_driver = { .id_table = snd_cs46xx_ids, .probe = snd_card_cs46xx_probe, .remove = __devexit_p(snd_card_cs46xx_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &snd_cs46xx_pm, }, diff --git a/sound/pci/cs46xx/cs46xx.h b/sound/pci/cs46xx/cs46xx.h index 29d8a8da1ba7..fc339ef0a0ae 100644 --- a/sound/pci/cs46xx/cs46xx.h +++ b/sound/pci/cs46xx/cs46xx.h @@ -1721,7 +1721,7 @@ struct snd_cs46xx { unsigned int play_ctl; #endif -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u32 *saved_regs; #endif }; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index a71d1c14a0f6..a2bb8c91ebe6 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2797,7 +2797,7 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip) } #endif -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP kfree(chip->saved_regs); #endif @@ -3590,7 +3590,7 @@ static struct cs_card_type __devinitdata cards[] = { /* * APM support */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static unsigned int saved_regs[] = { BA0_ACOSV, /*BA0_ASER_FADDR,*/ @@ -3711,7 +3711,7 @@ static int snd_cs46xx_resume(struct device *dev) } SIMPLE_DEV_PM_OPS(snd_cs46xx_pm, snd_cs46xx_suspend, snd_cs46xx_resume); -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ /* @@ -3868,7 +3868,7 @@ int __devinit snd_cs46xx_create(struct snd_card *card, snd_cs46xx_proc_init(card, chip); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) * ARRAY_SIZE(saved_regs), GFP_KERNEL); if (!chip->saved_regs) { diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h index b5189495d58a..86f14620f817 100644 --- a/sound/pci/cs46xx/cs46xx_lib.h +++ b/sound/pci/cs46xx/cs46xx_lib.h @@ -90,7 +90,7 @@ static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip); void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip); int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int cs46xx_dsp_resume(struct snd_cs46xx * chip); #endif struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 56fec0bc0efb..1686b4f4c44f 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -287,7 +287,7 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) if (ins->scbs[i].deleted) continue; cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP kfree(ins->scbs[i].data); #endif } @@ -1019,7 +1019,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 { struct dsp_scb_descriptor * desc; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* copy the data for resume */ scb_data = kmemdup(scb_data, SCB_BYTES, GFP_KERNEL); if (!scb_data) @@ -1032,7 +1032,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 _dsp_create_scb(chip,scb_data,dest); } else { snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP kfree(scb_data); #endif } @@ -1937,7 +1937,7 @@ int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int cs46xx_dsp_resume(struct snd_cs46xx * chip) { struct dsp_spos_instance * ins = chip->dsp_spos_instance; diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index c2c695b07f8c..409e8764fbeb 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -203,7 +203,7 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * remove_symbol (chip,scb->scb_symbol); ins->scbs[scb->index].deleted = 1; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP kfree(ins->scbs[scb->index].data); ins->scbs[scb->index].data = NULL; #endif diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index f1e4229993af..d1cca2831575 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c @@ -142,8 +142,7 @@ static int __devinit snd_cs5530_create(struct snd_card *card, mem = pci_ioremap_bar(pci, 0); if (mem == NULL) { - kfree(chip); - pci_disable_device(pci); + snd_cs5530_free(chip); return -EBUSY; } diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index ccc642269b9e..a8f75f8dfda9 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile @@ -3,7 +3,7 @@ # snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o -snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o +snd-cs5535audio-$(CONFIG_PM_SLEEP) += cs5535audio_pm.o snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o # Toplevel Module Dependency diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 51f64ba5facf..4915efa551fc 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -399,7 +399,7 @@ static struct pci_driver cs5535audio_driver = { .id_table = snd_cs5535audio_ids, .probe = snd_cs5535audio_probe, .remove = __devexit_p(snd_cs5535audio_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &snd_cs5535audio_pm, }, diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 2f6e9c762d3f..a2f997a9977a 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -1536,7 +1536,7 @@ static void atc_connect_resources(struct ct_atc *atc) } } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int atc_suspend(struct ct_atc *atc) { int i; @@ -1647,7 +1647,7 @@ static struct ct_atc atc_preset __devinitdata = { .output_switch_put = atc_output_switch_put, .mic_source_switch_get = atc_mic_source_switch_get, .mic_source_switch_put = atc_mic_source_switch_put, -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .suspend = atc_suspend, .resume = atc_resume, #endif diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 653e813ad142..69b51f9d345e 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h @@ -143,7 +143,7 @@ struct ct_atc { struct ct_timer *timer; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int (*suspend)(struct ct_atc *atc); int (*resume)(struct ct_atc *atc); #define NUM_PCMS (NUM_CTALSADEVS - 1) diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index c56fe533b3f3..5977e9a24b5c 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h @@ -72,7 +72,7 @@ struct hw { int (*card_init)(struct hw *hw, struct card_conf *info); int (*card_stop)(struct hw *hw); int (*pll_init)(struct hw *hw, unsigned int rsr); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int (*suspend)(struct hw *hw); int (*resume)(struct hw *hw, struct card_conf *info); #endif diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index dc1969bc67d4..4507f7088b24 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -2085,7 +2085,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int hw_suspend(struct hw *hw) { struct pci_dev *pci = hw->pci; @@ -2180,7 +2180,7 @@ static struct hw ct20k1_preset __devinitdata = { .is_adc_source_selected = hw_is_adc_input_selected, .select_adc_source = hw_adc_input_select, .capabilities = hw_capabilities, -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .suspend = hw_suspend, .resume = hw_resume, #endif diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 9d1231dc4ae2..b9c9349058bc 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -2201,7 +2201,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int hw_suspend(struct hw *hw) { struct pci_dev *pci = hw->pci; @@ -2250,7 +2250,7 @@ static struct hw ct20k2_preset __devinitdata = { .output_switch_put = hw_output_switch_put, .mic_source_switch_get = hw_mic_source_switch_get, .mic_source_switch_put = hw_mic_source_switch_put, -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .suspend = hw_suspend, .resume = hw_resume, #endif diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 0cc13eeef8da..48fe0e39c2be 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c @@ -1118,7 +1118,7 @@ mixer_set_input_right(struct ct_mixer *mixer, return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int mixer_resume(struct ct_mixer *mixer) { int i, state; @@ -1188,7 +1188,7 @@ int ct_mixer_create(struct ct_atc *atc, struct ct_mixer **rmixer) mixer->get_output_ports = mixer_get_output_ports; mixer->set_input_left = mixer_set_input_left; mixer->set_input_right = mixer_set_input_right; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP mixer->resume = mixer_resume; #endif diff --git a/sound/pci/ctxfi/ctmixer.h b/sound/pci/ctxfi/ctmixer.h index b009e989e77d..be881c639fee 100644 --- a/sound/pci/ctxfi/ctmixer.h +++ b/sound/pci/ctxfi/ctmixer.h @@ -56,7 +56,7 @@ struct ct_mixer { enum MIXER_PORT_T type, struct rsc *rsc); int (*set_input_right)(struct ct_mixer *mixer, enum MIXER_PORT_T type, struct rsc *rsc); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int (*resume)(struct ct_mixer *mixer); #endif }; diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 2c8622617c8c..e8a4feb1ed86 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -395,12 +395,38 @@ static struct snd_pcm_ops ct_pcm_capture_ops = { .page = snd_pcm_sgbuf_ops_page, }; +static const struct snd_pcm_chmap_elem surround_map[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { } +}; + +static const struct snd_pcm_chmap_elem clfe_map[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, + { } +}; + +static const struct snd_pcm_chmap_elem side_map[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, + { } +}; + /* Create ALSA pcm device */ int ct_alsa_pcm_create(struct ct_atc *atc, enum CTALSADEVS device, const char *device_name) { struct snd_pcm *pcm; + const struct snd_pcm_chmap_elem *map; + int chs; int err; int playback_count, capture_count; @@ -427,7 +453,31 @@ int ct_alsa_pcm_create(struct ct_atc *atc, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(atc->pci), 128*1024, 128*1024); -#ifdef CONFIG_PM + chs = 2; + switch (device) { + case FRONT: + chs = 8; + map = snd_pcm_std_chmaps; + break; + case SURROUND: + map = surround_map; + break; + case CLFE: + map = clfe_map; + break; + case SIDE: + map = side_map; + break; + default: + map = snd_pcm_std_chmaps; + break; + } + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, chs, + 0, NULL); + if (err < 0) + return err; + +#ifdef CONFIG_PM_SLEEP atc->pcms[device] = pcm; #endif diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c index e002183ef8b2..07c07d752fd8 100644 --- a/sound/pci/ctxfi/xfi.c +++ b/sound/pci/ctxfi/xfi.c @@ -125,7 +125,7 @@ static void __devexit ct_card_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int ct_card_suspend(struct device *dev) { struct snd_card *card = dev_get_drvdata(dev); diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 0ff754f180d0..abb0b86c41c9 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -46,7 +46,7 @@ static int get_firmware(const struct firmware **fw_entry, int err; char name[30]; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP if (chip->fw_cache[fw_index]) { DE_ACT(("firmware requested: %s is cached\n", card_fw[fw_index].data)); *fw_entry = chip->fw_cache[fw_index]; @@ -59,7 +59,7 @@ static int get_firmware(const struct firmware **fw_entry, err = request_firmware(fw_entry, name, pci_device(chip)); if (err < 0) snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP else chip->fw_cache[fw_index] = *fw_entry; #endif @@ -70,7 +70,7 @@ static int get_firmware(const struct firmware **fw_entry, static void free_firmware(const struct firmware *fw_entry) { -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP DE_ACT(("firmware not released (kept in cache)\n")); #else release_firmware(fw_entry); @@ -82,7 +82,7 @@ static void free_firmware(const struct firmware *fw_entry) static void free_firmware_cache(struct echoaudio *chip) { -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int i; for (i = 0; i < 8 ; i++) @@ -2203,7 +2203,7 @@ ctl_error: -#if defined(CONFIG_PM) +#if defined(CONFIG_PM_SLEEP) static int snd_echo_suspend(struct device *dev) { @@ -2313,7 +2313,7 @@ static SIMPLE_DEV_PM_OPS(snd_echo_pm, snd_echo_suspend, snd_echo_resume); #define SND_ECHO_PM_OPS &snd_echo_pm #else #define SND_ECHO_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static void __devexit snd_echo_remove(struct pci_dev *pci) diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h index 1df974dcb5f4..e158369f5faa 100644 --- a/sound/pci/echoaudio/echoaudio.h +++ b/sound/pci/echoaudio/echoaudio.h @@ -449,7 +449,7 @@ struct echoaudio { volatile u32 __iomem *dsp_registers; /* DSP's register base */ u32 active_mask; /* Chs. active mask or * punks out */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP const struct firmware *fw_cache[8]; /* Cached firmwares */ #endif diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index ddac4e6d660d..b7c1875ba90e 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -206,7 +206,7 @@ static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_emu10k1_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -268,7 +268,7 @@ static SIMPLE_DEV_PM_OPS(snd_emu10k1_pm, snd_emu10k1_suspend, snd_emu10k1_resume #define SND_EMU10K1_PM_OPS &snd_emu10k1_pm #else #define SND_EMU10K1_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver emu10k1_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index a0afa5057488..cae36597aa71 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -228,7 +228,7 @@ lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, int i; for (i = 0; i < V_END; i++) { - best[i].time = (unsigned int)-1; /* XXX MAX_?INT really */; + best[i].time = (unsigned int)-1; /* XXX MAX_?INT really */ best[i].voice = -1; } diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 754924081d0a..bed4485f34f6 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1241,7 +1241,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) * Create the EMU10K1 instance */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int alloc_pm_buffer(struct snd_emu10k1 *emu); static void free_pm_buffer(struct snd_emu10k1 *emu); #endif @@ -1275,7 +1275,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu) snd_dma_free_pages(&emu->ptb_pages); vfree(emu->page_ptr_table); vfree(emu->page_addr_table); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP free_pm_buffer(emu); #endif if (emu->port) @@ -1971,7 +1971,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card, err = snd_emu10k1_init(emu, enable_ir, 0); if (err < 0) goto error; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP err = alloc_pm_buffer(emu); if (err < 0) goto error; @@ -2000,7 +2000,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card, return err; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static unsigned char saved_regs[] = { CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 5c8978b2c4d9..556fd6f456e3 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -830,9 +830,22 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static const struct snd_pcm_chmap_elem surround_map[] = { + { .channels = 2, + .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { } +}; + +static const struct snd_pcm_chmap_elem clfe_map[] = { + { .channels = 2, + .map = { SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, + { } +}; + static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) { struct snd_pcm *pcm; + const struct snd_pcm_chmap_elem *map = NULL; int err; int capture = 0; @@ -861,12 +874,15 @@ static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct s switch(device) { case 0: strcpy(pcm->name, "EMU10K1X Front"); + map = snd_pcm_std_chmaps; break; case 1: strcpy(pcm->name, "EMU10K1X Rear"); + map = surround_map; break; case 2: strcpy(pcm->name, "EMU10K1X Center/LFE"); + map = clfe_map; break; } emu->pcm = pcm; @@ -875,6 +891,11 @@ static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct s snd_dma_pci_data(emu->pci), 32*1024, 32*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, + 1 << 2, NULL); + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index dae4050ede5c..52419959178c 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -2646,7 +2646,7 @@ int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int __devinit snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) { int len; diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index e22b8e2bbd88..0e6664fa6cd9 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1310,7 +1310,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) runtime->hw.channels_min = runtime->hw.channels_max = 16; break; - }; + } #endif #if 0 /* For 96kHz */ diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 0a436626182b..ae709c1ab3a8 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -263,8 +263,8 @@ int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *b spin_lock_irqsave(&emu->memblk_lock, flags); if (blk->mapped_page >= 0) { /* update order link */ - list_del(&blk->mapped_order_link); - list_add_tail(&blk->mapped_order_link, &emu->mapped_order_link_head); + list_move_tail(&blk->mapped_order_link, + &emu->mapped_order_link_head); spin_unlock_irqrestore(&emu->memblk_lock, flags); return 0; } diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index a81dc44228ea..88cec6b7dd41 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -893,7 +893,7 @@ int __devinit snd_p16v_mixer(struct snd_emu10k1 *emu) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP #define NUM_CHS 1 /* up to 4, but only first channel is used */ diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index f7e6f73186e1..5674cc316530 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -55,8 +55,10 @@ #ifdef CHIP1370 #define DRIVER_NAME "ENS1370" +#define CHIP_NAME "ES1370" /* it can be ENS but just to keep compatibility... */ #else #define DRIVER_NAME "ENS1371" +#define CHIP_NAME "ES1371" #endif @@ -1258,6 +1260,14 @@ static struct snd_pcm_ops snd_ensoniq_capture_ops = { .pointer = snd_ensoniq_capture_pointer, }; +static const struct snd_pcm_chmap_elem surround_map[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { } +}; + static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, struct snd_pcm ** rpcm) { @@ -1266,11 +1276,7 @@ static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, if (rpcm) *rpcm = NULL; -#ifdef CHIP1370 - err = snd_pcm_new(ensoniq->card, "ES1370/1", device, 1, 1, &pcm); -#else - err = snd_pcm_new(ensoniq->card, "ES1371/1", device, 1, 1, &pcm); -#endif + err = snd_pcm_new(ensoniq->card, CHIP_NAME "/1", device, 1, 1, &pcm); if (err < 0) return err; @@ -1283,16 +1289,22 @@ static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, pcm->private_data = ensoniq; pcm->info_flags = 0; -#ifdef CHIP1370 - strcpy(pcm->name, "ES1370 DAC2/ADC"); -#else - strcpy(pcm->name, "ES1371 DAC2/ADC"); -#endif + strcpy(pcm->name, CHIP_NAME " DAC2/ADC"); ensoniq->pcm1 = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); +#ifdef CHIP1370 + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + surround_map, 2, 0, NULL); +#else + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_std_chmaps, 2, 0, NULL); +#endif + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; return 0; @@ -1306,11 +1318,7 @@ static int __devinit snd_ensoniq_pcm2(struct ensoniq * ensoniq, int device, if (rpcm) *rpcm = NULL; -#ifdef CHIP1370 - err = snd_pcm_new(ensoniq->card, "ES1370/2", device, 1, 0, &pcm); -#else - err = snd_pcm_new(ensoniq->card, "ES1371/2", device, 1, 0, &pcm); -#endif + err = snd_pcm_new(ensoniq->card, CHIP_NAME "/2", device, 1, 0, &pcm); if (err < 0) return err; @@ -1321,16 +1329,22 @@ static int __devinit snd_ensoniq_pcm2(struct ensoniq * ensoniq, int device, #endif pcm->private_data = ensoniq; pcm->info_flags = 0; -#ifdef CHIP1370 - strcpy(pcm->name, "ES1370 DAC1"); -#else - strcpy(pcm->name, "ES1371 DAC1"); -#endif + strcpy(pcm->name, CHIP_NAME " DAC1"); ensoniq->pcm2 = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); +#ifdef CHIP1370 + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_std_chmaps, 2, 0, NULL); +#else + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + surround_map, 2, 0, NULL); +#endif + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; return 0; @@ -1885,11 +1899,7 @@ static void snd_ensoniq_proc_read(struct snd_info_entry *entry, { struct ensoniq *ensoniq = entry->private_data; -#ifdef CHIP1370 - snd_iprintf(buffer, "Ensoniq AudioPCI ES1370\n\n"); -#else - snd_iprintf(buffer, "Ensoniq AudioPCI ES1371\n\n"); -#endif + snd_iprintf(buffer, "Ensoniq AudioPCI " CHIP_NAME "\n\n"); snd_iprintf(buffer, "Joystick enable : %s\n", ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); #ifdef CHIP1370 @@ -2032,7 +2042,7 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) synchronize_irq(ensoniq->irq); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_ensoniq_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -2094,7 +2104,7 @@ static SIMPLE_DEV_PM_OPS(snd_ensoniq_pm, snd_ensoniq_suspend, snd_ensoniq_resume #define SND_ENSONIQ_PM_OPS &snd_ensoniq_pm #else #define SND_ENSONIQ_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int __devinit snd_ensoniq_create(struct snd_card *card, struct pci_dev *pci, @@ -2361,11 +2371,7 @@ static int __devinit snd_ensoniq_midi(struct ensoniq * ensoniq, int device, *rrawmidi = NULL; if ((err = snd_rawmidi_new(ensoniq->card, "ES1370/1", device, 1, 1, &rmidi)) < 0) return err; -#ifdef CHIP1370 - strcpy(rmidi->name, "ES1370"); -#else - strcpy(rmidi->name, "ES1371"); -#endif + strcpy(rmidi->name, CHIP_NAME); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_ensoniq_midi_output); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_ensoniq_midi_input); rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index dbb81807bc1a..394c5d413530 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -236,7 +236,7 @@ struct es1938 { #ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP unsigned char saved_regs[SAVED_REG_SIZE]; #endif }; @@ -1456,7 +1456,7 @@ static void snd_es1938_chip_init(struct es1938 *chip) outb(0, SLDM_REG(chip, DMACLEAR)); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * PM support */ @@ -1536,7 +1536,7 @@ static SIMPLE_DEV_PM_OPS(es1938_pm, es1938_suspend, es1938_resume); #define ES1938_PM_OPS &es1938_pm #else #define ES1938_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef SUPPORT_JOYSTICK static int __devinit snd_es1938_create_gameport(struct es1938 *chip) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index fb4c90b99c00..5d0e568fdea1 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -491,7 +491,7 @@ struct esschan { /* linked list */ struct list_head list; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u16 wc_map[4]; #endif }; @@ -544,7 +544,7 @@ struct es1968 { struct list_head substream_list; spinlock_t substream_lock; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u16 apu_map[NR_APUS][NR_APU_REGS]; #endif @@ -706,7 +706,7 @@ static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 dat { if (snd_BUG_ON(channel >= NR_APUS)) return; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->apu_map[channel][reg] = data; #endif reg |= (channel << 4); @@ -993,7 +993,7 @@ static void snd_es1968_program_wavecache(struct es1968 *chip, struct esschan *es /* set the wavecache control reg */ wave_set_register(chip, es->apu[channel] << 3, tmpval); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP es->wc_map[channel] = tmpval; #endif } @@ -2377,7 +2377,7 @@ static void snd_es1968_start_irq(struct es1968 *chip) outw(w, chip->io_port + ESM_PORT_HOST_IRQ); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * PM support */ @@ -2461,7 +2461,7 @@ static SIMPLE_DEV_PM_OPS(es1968_pm, es1968_suspend, es1968_resume); #define ES1968_PM_OPS &es1968_pm #else #define ES1968_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 522c8706f244..cc2e91d15538 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -205,7 +205,7 @@ struct fm801 { struct snd_tea575x tea; #endif -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u16 saved_regs[0x20]; #endif }; @@ -711,6 +711,13 @@ static int __devinit snd_fm801_pcm(struct fm801 *chip, int device, struct snd_pc snd_dma_pci_data(chip->pci), chip->multichannel ? 128*1024 : 64*1024, 128*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, + chip->multichannel ? 6 : 2, 0, + NULL); + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; return 0; @@ -1361,7 +1368,7 @@ static void __devexit snd_card_fm801_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static unsigned char saved_regs[] = { FM801_PCM_VOL, FM801_I2S_VOL, FM801_FM_VOL, FM801_REC_SRC, FM801_PLY_CTRL, FM801_PLY_COUNT, FM801_PLY_BUF1, FM801_PLY_BUF2, @@ -1421,7 +1428,7 @@ static SIMPLE_DEV_PM_OPS(snd_fm801_pm, snd_fm801_suspend, snd_fm801_resume); #define SND_FM801_PM_OPS &snd_fm801_pm #else #define SND_FM801_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver fm801_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 194d625c1f83..7105c3de1bca 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -228,17 +228,9 @@ config SND_HDA_GENERIC Say Y here to enable the generic HD-audio codec parser in snd-hda-intel driver. -config SND_HDA_POWER_SAVE - bool "Aggressive power-saving on HD-audio" - depends on PM - help - Say Y here to enable more aggressive power-saving mode on - HD-audio driver. The power-saving timeout can be configured - via power_save option or over sysfs on-the-fly. - config SND_HDA_POWER_SAVE_DEFAULT int "Default time-out for HD-audio power-save mode" - depends on SND_HDA_POWER_SAVE + depends on PM default 0 help The default time-out value in seconds for HD-audio automatic diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 4f7d2dfcef7b..4ec6dc88b7f8 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -141,7 +141,6 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, memset(sequences_hp, 0, sizeof(sequences_hp)); assoc_line_out = 0; - codec->ignore_misc_bit = true; end_nid = codec->start_nid + codec->num_nodes; for (nid = codec->start_nid; nid < end_nid; nid++) { unsigned int wid_caps = get_wcaps(codec, nid); @@ -157,9 +156,6 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, continue; def_conf = snd_hda_codec_get_pincfg(codec, nid); - if (!(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & - AC_DEFCFG_MISC_NO_PRESENCE)) - codec->ignore_misc_bit = false; conn = get_defcfg_connect(def_conf); if (conn == AC_JACK_PORT_NONE) continue; @@ -502,6 +498,38 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, return channel_sfx[i]; } +static const char *check_output_pfx(struct hda_codec *codec, hda_nid_t nid) +{ + unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); + int attr = snd_hda_get_input_pin_attr(def_conf); + + /* check the location */ + switch (attr) { + case INPUT_PIN_ATTR_DOCK: + return "Dock "; + case INPUT_PIN_ATTR_FRONT: + return "Front "; + } + return ""; +} + +static int get_hp_label_index(struct hda_codec *codec, hda_nid_t nid, + const hda_nid_t *pins, int num_pins) +{ + int i, j, idx = 0; + + const char *pfx = check_output_pfx(codec, nid); + + i = find_idx_in_nid_list(nid, pins, num_pins); + if (i < 0) + return -1; + for (j = 0; j < i; j++) + if (pfx == check_output_pfx(codec, pins[j])) + idx++; + + return idx; +} + static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, const struct auto_pin_cfg *cfg, const char *name, char *label, int maxlen, @@ -509,20 +537,13 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); int attr = snd_hda_get_input_pin_attr(def_conf); - const char *pfx = "", *sfx = ""; + const char *pfx, *sfx = ""; /* handle as a speaker if it's a fixed line-out */ if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) name = "Speaker"; - /* check the location */ - switch (attr) { - case INPUT_PIN_ATTR_DOCK: - pfx = "Dock "; - break; - case INPUT_PIN_ATTR_FRONT: - pfx = "Front "; - break; - } + pfx = check_output_pfx(codec, nid); + if (cfg) { /* try to give a unique suffix if needed */ sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, @@ -532,8 +553,8 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, indexp); if (!sfx) { /* don't add channel suffix for Headphone controls */ - int idx = find_idx_in_nid_list(nid, cfg->hp_pins, - cfg->hp_outs); + int idx = get_hp_label_index(codec, nid, cfg->hp_pins, + cfg->hp_outs); if (idx >= 0) *indexp = idx; sfx = ""; @@ -739,7 +760,8 @@ void snd_hda_pick_fixup(struct hda_codec *codec, for (q = quirk; q->subvendor; q++) { unsigned int vendorid = q->subdevice | (q->subvendor << 16); - if (vendorid == codec->subsystem_id) { + unsigned int mask = 0xffff0000 | q->subdevice_mask; + if ((codec->subsystem_id & mask) == (vendorid & mask)) { id = q->value; #ifdef CONFIG_SND_DEBUG_VERBOSE name = q->name; diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 1c65cc5e3a31..70d4848b5cd0 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -94,13 +94,19 @@ int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset) } EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static void hda_power_work(struct work_struct *work); static void hda_keep_power_on(struct hda_codec *codec); #define hda_codec_is_power_on(codec) ((codec)->power_on) +static inline void hda_call_pm_notify(struct hda_bus *bus, bool power_up) +{ + if (bus->ops.pm_notify) + bus->ops.pm_notify(bus, power_up); +} #else static inline void hda_keep_power_on(struct hda_codec *codec) {} #define hda_codec_is_power_on(codec) 1 +#define hda_call_pm_notify(bus, state) {} #endif /** @@ -808,7 +814,7 @@ find_codec_preset(struct hda_codec *codec) { struct hda_codec_preset_list *tbl; const struct hda_codec_preset *preset; - int mod_requested = 0; + unsigned int mod_requested = 0; if (is_generic_config(codec)) return NULL; /* use the generic parser */ @@ -1186,7 +1192,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) return; snd_hda_jack_tbl_clear(codec); restore_init_pincfgs(codec); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM cancel_delayed_work(&codec->power_work); flush_workqueue(codec->bus->workq); #endif @@ -1199,6 +1205,10 @@ static void snd_hda_codec_free(struct hda_codec *codec) codec->bus->caddr_tbl[codec->addr] = NULL; if (codec->patch_ops.free) codec->patch_ops.free(codec); +#ifdef CONFIG_PM + if (!codec->pm_down_notified) /* cancel leftover refcounts */ + hda_call_pm_notify(codec->bus, false); +#endif module_put(codec->owner); free_hda_cache(&codec->amp_cache); free_hda_cache(&codec->cmd_cache); @@ -1212,7 +1222,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg, unsigned int power_state); -static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, +static unsigned int hda_set_power_state(struct hda_codec *codec, unsigned int power_state); /** @@ -1229,6 +1239,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, { struct hda_codec *codec; char component[31]; + hda_nid_t fg; int err; if (snd_BUG_ON(!bus)) @@ -1263,7 +1274,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spin_lock_init(&codec->power_lock); INIT_DELAYED_WORK(&codec->power_work, hda_power_work); /* snd_hda_codec_new() marks the codec as power-up, and leave it as is. @@ -1271,6 +1282,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, * phase. */ hda_keep_power_on(codec); + hda_call_pm_notify(bus, true); #endif if (codec->bus->modelname) { @@ -1304,7 +1316,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, goto error; } - err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg); + fg = codec->afg ? codec->afg : codec->mfg; + err = read_widget_caps(codec, fg); if (err < 0) { snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); goto error; @@ -1314,20 +1327,22 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, goto error; if (!codec->subsystem_id) { - hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; codec->subsystem_id = - snd_hda_codec_read(codec, nid, 0, + snd_hda_codec_read(codec, fg, 0, AC_VERB_GET_SUBSYSTEM_ID, 0); } - codec->epss = snd_hda_codec_get_supported_ps(codec, - codec->afg ? codec->afg : codec->mfg, +#ifdef CONFIG_PM + codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, fg, + AC_PWRST_CLKSTOP); + if (!codec->d3_stop_clk) + bus->power_keep_link_on = 1; +#endif + codec->epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS); /* power-up all before initialization */ - hda_set_power_state(codec, - codec->afg ? codec->afg : codec->mfg, - AC_PWRST_D0); + hda_set_power_state(codec, AC_PWRST_D0); snd_hda_codec_proc_new(codec); @@ -2335,7 +2350,7 @@ int snd_hda_codec_reset(struct hda_codec *codec) /* OK, let it free */ -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM cancel_delayed_work_sync(&codec->power_work); codec->power_on = 0; codec->power_transition = 0; @@ -3500,20 +3515,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, power_state); } - - if (power_state == AC_PWRST_D0) { - unsigned long end_time; - int state; - /* wait until the codec reachs to D0 */ - end_time = jiffies + msecs_to_jiffies(500); - do { - state = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_POWER_STATE, 0); - if (state == power_state) - break; - msleep(1); - } while (time_after_eq(end_time, jiffies)); - } } EXPORT_SYMBOL_HDA(snd_hda_codec_set_power_to_all); @@ -3534,18 +3535,40 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg } /* - * set power state of the codec + * wait until the state is reached, returns the current state */ -static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, - unsigned int power_state) +static unsigned int hda_sync_power_state(struct hda_codec *codec, + hda_nid_t fg, + unsigned int power_state) { - int count; - unsigned int state; + unsigned long end_time = jiffies + msecs_to_jiffies(500); + unsigned int state, actual_state; - if (codec->patch_ops.set_power_state) { - codec->patch_ops.set_power_state(codec, fg, power_state); - return; + for (;;) { + state = snd_hda_codec_read(codec, fg, 0, + AC_VERB_GET_POWER_STATE, 0); + if (state & AC_PWRST_ERROR) + break; + actual_state = (state >> 4) & 0x0f; + if (actual_state == power_state) + break; + if (time_after_eq(jiffies, end_time)) + break; + /* wait until the codec reachs to the target state */ + msleep(1); } + return state; +} + +/* + * set power state of the codec, and return the power state + */ +static unsigned int hda_set_power_state(struct hda_codec *codec, + unsigned int power_state) +{ + hda_nid_t fg = codec->afg ? codec->afg : codec->mfg; + int count; + unsigned int state; /* this delay seems necessary to avoid click noise at power-down */ if (power_state == AC_PWRST_D3) { @@ -3555,14 +3578,22 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, /* repeat power states setting at most 10 times*/ for (count = 0; count < 10; count++) { - snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, - power_state); - snd_hda_codec_set_power_to_all(codec, fg, power_state, true); - state = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_POWER_STATE, 0); + if (codec->patch_ops.set_power_state) + codec->patch_ops.set_power_state(codec, fg, + power_state); + else { + snd_hda_codec_read(codec, fg, 0, + AC_VERB_SET_POWER_STATE, + power_state); + snd_hda_codec_set_power_to_all(codec, fg, power_state, + true); + } + state = hda_sync_power_state(codec, fg, power_state); if (!(state & AC_PWRST_ERROR)) break; } + + return state; } #ifdef CONFIG_SND_HDA_HWDEP @@ -3579,17 +3610,19 @@ static inline void hda_exec_init_verbs(struct hda_codec *codec) {} #ifdef CONFIG_PM /* * call suspend and power-down; used both from PM and power-save + * this function returns the power state in the end */ -static void hda_call_codec_suspend(struct hda_codec *codec) +static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq) { + unsigned int state; + if (codec->patch_ops.suspend) codec->patch_ops.suspend(codec); hda_cleanup_all_streams(codec); - hda_set_power_state(codec, - codec->afg ? codec->afg : codec->mfg, - AC_PWRST_D3); -#ifdef CONFIG_SND_HDA_POWER_SAVE - cancel_delayed_work(&codec->power_work); + state = hda_set_power_state(codec, AC_PWRST_D3); + /* Cancel delayed work if we aren't currently running from it. */ + if (!in_wq) + cancel_delayed_work_sync(&codec->power_work); spin_lock(&codec->power_lock); snd_hda_update_power_acct(codec); trace_hda_power_down(codec); @@ -3597,7 +3630,7 @@ static void hda_call_codec_suspend(struct hda_codec *codec) codec->power_transition = 0; codec->power_jiffies = jiffies; spin_unlock(&codec->power_lock); -#endif + return state; } /* @@ -3609,9 +3642,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) * in the resume / power-save sequence */ hda_keep_power_on(codec); - hda_set_power_state(codec, - codec->afg ? codec->afg : codec->mfg, - AC_PWRST_D0); + hda_set_power_state(codec, AC_PWRST_D0); restore_pincfgs(codec); /* restore all current pin configs */ restore_shutup_pins(codec); hda_exec_init_verbs(codec); @@ -3624,6 +3655,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_cache(codec); } + snd_hda_jack_report_sync(codec); snd_hda_power_down(codec); /* flag down before returning */ } #endif /* CONFIG_PM */ @@ -3658,6 +3690,36 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus) } EXPORT_SYMBOL_HDA(snd_hda_build_controls); +/* + * add standard channel maps if not specified + */ +static int add_std_chmaps(struct hda_codec *codec) +{ + int i, str, err; + + for (i = 0; i < codec->num_pcms; i++) { + for (str = 0; str < 2; str++) { + struct snd_pcm *pcm = codec->pcm_info[i].pcm; + struct hda_pcm_stream *hinfo = + &codec->pcm_info[i].stream[str]; + struct snd_pcm_chmap *chmap; + + if (codec->pcm_info[i].own_chmap) + continue; + if (!pcm || !hinfo->substreams) + continue; + err = snd_pcm_add_chmap_ctls(pcm, str, + snd_pcm_std_chmaps, + hinfo->channels_max, + 0, &chmap); + if (err < 0) + return err; + chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; + } + } + return 0; +} + int snd_hda_codec_build_controls(struct hda_codec *codec) { int err = 0; @@ -3669,6 +3731,13 @@ int snd_hda_codec_build_controls(struct hda_codec *codec) err = codec->patch_ops.build_controls(codec); if (err < 0) return err; + + /* we create chmaps here instead of build_pcms */ + err = add_std_chmaps(codec); + if (err < 0) + return err; + + snd_hda_jack_report_sync(codec); /* call at the last init point */ return 0; } @@ -4211,7 +4280,7 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec) * * This function returns 0 if successful, or a negative error code. */ -int __devinit snd_hda_build_pcms(struct hda_bus *bus) +int snd_hda_build_pcms(struct hda_bus *bus) { struct hda_codec *codec; @@ -4391,12 +4460,13 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static void hda_power_work(struct work_struct *work) { struct hda_codec *codec = container_of(work, struct hda_codec, power_work.work); struct hda_bus *bus = codec->bus; + unsigned int state; spin_lock(&codec->power_lock); if (codec->power_transition > 0) { /* during power-up sequence? */ @@ -4410,9 +4480,12 @@ static void hda_power_work(struct work_struct *work) } spin_unlock(&codec->power_lock); - hda_call_codec_suspend(codec); - if (bus->ops.pm_notify) - bus->ops.pm_notify(bus); + state = hda_call_codec_suspend(codec, true); + codec->pm_down_notified = 0; + if (!bus->power_keep_link_on && (state & AC_PWRST_CLK_STOP_OK)) { + codec->pm_down_notified = 1; + hda_call_pm_notify(bus, false); + } } static void hda_keep_power_on(struct hda_codec *codec) @@ -4438,19 +4511,16 @@ void snd_hda_update_power_acct(struct hda_codec *codec) /* Transition to powered up, if wait_power_down then wait for a pending * transition to D3 to complete. A pending D3 transition is indicated * with power_transition == -1. */ +/* call this with codec->power_lock held! */ static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down) { struct hda_bus *bus = codec->bus; - spin_lock(&codec->power_lock); - codec->power_count++; /* Return if power_on or transitioning to power_on, unless currently * powering down. */ if ((codec->power_on || codec->power_transition > 0) && - !(wait_power_down && codec->power_transition < 0)) { - spin_unlock(&codec->power_lock); + !(wait_power_down && codec->power_transition < 0)) return; - } spin_unlock(&codec->power_lock); cancel_delayed_work_sync(&codec->power_work); @@ -4462,9 +4532,9 @@ static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down) if (codec->power_on) { if (codec->power_transition < 0) codec->power_transition = 0; - spin_unlock(&codec->power_lock); return; } + trace_hda_power_up(codec); snd_hda_update_power_acct(codec); codec->power_on = 1; @@ -4472,71 +4542,54 @@ static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down) codec->power_transition = 1; /* avoid reentrance */ spin_unlock(&codec->power_lock); - if (bus->ops.pm_notify) - bus->ops.pm_notify(bus); + if (codec->pm_down_notified) { + codec->pm_down_notified = 0; + hda_call_pm_notify(bus, true); + } + hda_call_codec_resume(codec); spin_lock(&codec->power_lock); codec->power_transition = 0; - spin_unlock(&codec->power_lock); -} - -/** - * snd_hda_power_up - Power-up the codec - * @codec: HD-audio codec - * - * Increment the power-up counter and power up the hardware really when - * not turned on yet. - */ -void snd_hda_power_up(struct hda_codec *codec) -{ - __snd_hda_power_up(codec, false); } -EXPORT_SYMBOL_HDA(snd_hda_power_up); - -/** - * snd_hda_power_up_d3wait - Power-up the codec after waiting for any pending - * D3 transition to complete. This differs from snd_hda_power_up() when - * power_transition == -1. snd_hda_power_up sees this case as a nop, - * snd_hda_power_up_d3wait waits for the D3 transition to complete then powers - * back up. - * @codec: HD-audio codec - * - * Cancel any power down operation hapenning on the work queue, then power up. - */ -void snd_hda_power_up_d3wait(struct hda_codec *codec) -{ - /* This will cancel and wait for pending power_work to complete. */ - __snd_hda_power_up(codec, true); -} -EXPORT_SYMBOL_HDA(snd_hda_power_up_d3wait); #define power_save(codec) \ ((codec)->bus->power_save ? *(codec)->bus->power_save : 0) -/** - * snd_hda_power_down - Power-down the codec - * @codec: HD-audio codec - * - * Decrement the power-up counter and schedules the power-off work if - * the counter rearches to zero. - */ -void snd_hda_power_down(struct hda_codec *codec) +/* Transition to powered down */ +static void __snd_hda_power_down(struct hda_codec *codec) { - spin_lock(&codec->power_lock); - --codec->power_count; - if (!codec->power_on || codec->power_count || codec->power_transition) { - spin_unlock(&codec->power_lock); + if (!codec->power_on || codec->power_count || codec->power_transition) return; - } + if (power_save(codec)) { codec->power_transition = -1; /* avoid reentrance */ queue_delayed_work(codec->bus->workq, &codec->power_work, msecs_to_jiffies(power_save(codec) * 1000)); } +} + +/** + * snd_hda_power_save - Power-up/down/sync the codec + * @codec: HD-audio codec + * @delta: the counter delta to change + * + * Change the power-up counter via @delta, and power up or down the hardware + * appropriately. For the power-down, queue to the delayed action. + * Passing zero to @delta means to synchronize the power state. + */ +void snd_hda_power_save(struct hda_codec *codec, int delta, bool d3wait) +{ + spin_lock(&codec->power_lock); + codec->power_count += delta; + trace_hda_power_count(codec); + if (delta > 0) + __snd_hda_power_up(codec, d3wait); + else + __snd_hda_power_down(codec); spin_unlock(&codec->power_lock); } -EXPORT_SYMBOL_HDA(snd_hda_power_down); +EXPORT_SYMBOL_HDA(snd_hda_power_save); /** * snd_hda_check_amp_list_power - Check the amp list and update the power @@ -5076,7 +5129,7 @@ int snd_hda_suspend(struct hda_bus *bus) list_for_each_entry(codec, &bus->codec_list, list) { if (hda_codec_is_power_on(codec)) - hda_call_codec_suspend(codec); + hda_call_codec_suspend(codec, false); } return 0; } @@ -5087,9 +5140,6 @@ EXPORT_SYMBOL_HDA(snd_hda_suspend); * @bus: the HDA bus * * Returns 0 if successful. - * - * This function is defined only when POWER_SAVE isn't set. - * In the power-save mode, the codec is resumed dynamically. */ int snd_hda_resume(struct hda_bus *bus) { @@ -5118,6 +5168,8 @@ EXPORT_SYMBOL_HDA(snd_hda_resume); */ void *snd_array_new(struct snd_array *array) { + if (snd_BUG_ON(!array->elem_size)) + return NULL; if (array->used >= array->alloced) { int num = array->alloced + array->alloc_align; int size = (num + 1) * array->elem_size; diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index e5a7e19a8071..507fe8a917b6 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -386,6 +386,10 @@ enum { /* DIGITAL2 bits */ #define AC_DIG2_CC (0x7f<<0) +/* DIGITAL3 bits */ +#define AC_DIG3_ICT (0xf<<0) +#define AC_DIG3_KAE (1<<7) + /* Pin widget control - 8bit */ #define AC_PINCTL_EPT (0x3<<0) #define AC_PINCTL_EPT_NATIVE 0 @@ -610,9 +614,9 @@ struct hda_bus_ops { struct hda_pcm *pcm); /* reset bus for retry verb */ void (*bus_reset)(struct hda_bus *bus); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM /* notify power-up/down from codec to controller */ - void (*pm_notify)(struct hda_bus *bus); + void (*pm_notify)(struct hda_bus *bus, bool power_up); #endif }; @@ -708,8 +712,6 @@ struct hda_codec_ops { #ifdef CONFIG_PM int (*suspend)(struct hda_codec *codec); int (*resume)(struct hda_codec *codec); -#endif -#ifdef CONFIG_SND_HDA_POWER_SAVE int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid); #endif void (*reboot_notify)(struct hda_codec *codec); @@ -774,6 +776,7 @@ struct hda_pcm { unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */ int device; /* device number to assign */ struct snd_pcm *pcm; /* assigned PCM instance */ + bool own_chmap; /* codec driver provides own channel maps */ }; /* codec information */ @@ -859,12 +862,13 @@ struct hda_codec { unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */ unsigned int pins_shutup:1; /* pins are shut up */ unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ - unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */ unsigned int no_jack_detect:1; /* Machine has no jack-detection */ unsigned int pcm_format_first:1; /* PCM format must be set first */ unsigned int epss:1; /* supporting EPSS? */ -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM unsigned int power_on :1; /* current (global) power-state */ + unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ + unsigned int pm_down_notified:1; /* PM notified to controller */ int power_transition; /* power-state in transition */ int power_count; /* current (global) power refcount */ struct delayed_work power_work; /* delayed task for powerdown */ @@ -1042,7 +1046,7 @@ int snd_hda_resume(struct hda_bus *bus); static inline int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid) { -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM if (codec->patch_ops.check_power_status) return codec->patch_ops.check_power_status(codec, nid); #endif @@ -1059,22 +1063,70 @@ const char *snd_hda_get_jack_location(u32 cfg); /* * power saving */ -#ifdef CONFIG_SND_HDA_POWER_SAVE -void snd_hda_power_up(struct hda_codec *codec); -void snd_hda_power_up_d3wait(struct hda_codec *codec); -void snd_hda_power_down(struct hda_codec *codec); +#ifdef CONFIG_PM +void snd_hda_power_save(struct hda_codec *codec, int delta, bool d3wait); void snd_hda_update_power_acct(struct hda_codec *codec); #else -static inline void snd_hda_power_up(struct hda_codec *codec) {} -static inline void snd_hda_power_up_d3wait(struct hda_codec *codec) {} -static inline void snd_hda_power_down(struct hda_codec *codec) {} +static inline void snd_hda_power_save(struct hda_codec *codec, int delta, + bool d3wait) {} #endif +/** + * snd_hda_power_up - Power-up the codec + * @codec: HD-audio codec + * + * Increment the power-up counter and power up the hardware really when + * not turned on yet. + */ +static inline void snd_hda_power_up(struct hda_codec *codec) +{ + snd_hda_power_save(codec, 1, false); +} + +/** + * snd_hda_power_up_d3wait - Power-up the codec after waiting for any pending + * D3 transition to complete. This differs from snd_hda_power_up() when + * power_transition == -1. snd_hda_power_up sees this case as a nop, + * snd_hda_power_up_d3wait waits for the D3 transition to complete then powers + * back up. + * @codec: HD-audio codec + * + * Cancel any power down operation hapenning on the work queue, then power up. + */ +static inline void snd_hda_power_up_d3wait(struct hda_codec *codec) +{ + snd_hda_power_save(codec, 1, true); +} + +/** + * snd_hda_power_down - Power-down the codec + * @codec: HD-audio codec + * + * Decrement the power-up counter and schedules the power-off work if + * the counter rearches to zero. + */ +static inline void snd_hda_power_down(struct hda_codec *codec) +{ + snd_hda_power_save(codec, -1, false); +} + +/** + * snd_hda_power_sync - Synchronize the power-save status + * @codec: HD-audio codec + * + * Synchronize the actual power state with the power account; + * called when power_save parameter is changed + */ +static inline void snd_hda_power_sync(struct hda_codec *codec) +{ + snd_hda_power_save(codec, 0, false); +} + #ifdef CONFIG_SND_HDA_PATCH_LOADER /* * patch firmware */ -int snd_hda_load_patch(struct hda_bus *bus, const char *patch); +int snd_hda_load_patch(struct hda_bus *bus, size_t size, const void *buf); #endif /* diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 431bf868711e..b81d3d0b952d 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -70,7 +70,7 @@ struct hda_gspec { struct list_head nid_list; /* list of widgets */ -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM #define MAX_LOOPBACK_AMPS 7 struct hda_loopback_check loopback; int num_loopbacks; @@ -654,7 +654,7 @@ static int parse_input(struct hda_codec *codec) return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static void add_input_loopback(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) { @@ -1028,7 +1028,7 @@ static int build_generic_pcms(struct hda_codec *codec) return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static int generic_check_power_status(struct hda_codec *codec, hda_nid_t nid) { struct hda_gspec *spec = codec->spec; @@ -1043,7 +1043,7 @@ static struct hda_codec_ops generic_patch_ops = { .build_controls = build_generic_controls, .build_pcms = build_generic_pcms, .free = snd_hda_generic_free, -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM .check_power_status = generic_check_power_status, #endif }; diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 6b2efb8cb1f9..1af86d40eb23 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c @@ -25,7 +25,6 @@ #include <linux/mutex.h> #include <linux/ctype.h> #include <linux/string.h> -#include <linux/firmware.h> #include <linux/export.h> #include <sound/core.h> #include "hda_codec.h" @@ -156,7 +155,7 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec) return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static ssize_t power_on_acct_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -192,7 +191,7 @@ int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec) hwdep->device, &power_attrs[i]); return 0; } -#endif /* CONFIG_SND_HDA_POWER_SAVE */ +#endif /* CONFIG_PM */ #ifdef CONFIG_SND_HDA_RECONFIG @@ -747,18 +746,21 @@ static int parse_line_mode(char *buf, struct hda_bus *bus) * * the spaces at the beginning and the end of the line are stripped */ -static int get_line_from_fw(char *buf, int size, struct firmware *fw) +static int get_line_from_fw(char *buf, int size, size_t *fw_size_p, + const void **fw_data_p) { int len; - const char *p = fw->data; - while (isspace(*p) && fw->size) { + size_t fw_size = *fw_size_p; + const char *p = *fw_data_p; + + while (isspace(*p) && fw_size) { p++; - fw->size--; + fw_size--; } - if (!fw->size) + if (!fw_size) return 0; - for (len = 0; len < fw->size; len++) { + for (len = 0; len < fw_size; len++) { if (!*p) break; if (*p == '\n') { @@ -770,8 +772,8 @@ static int get_line_from_fw(char *buf, int size, struct firmware *fw) *buf++ = *p++; } *buf = 0; - fw->size -= len; - fw->data = p; + *fw_size_p = fw_size - len; + *fw_data_p = p; remove_trail_spaces(buf); return 1; } @@ -779,29 +781,15 @@ static int get_line_from_fw(char *buf, int size, struct firmware *fw) /* * load a "patch" firmware file and parse it */ -int snd_hda_load_patch(struct hda_bus *bus, const char *patch) +int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf) { - int err; - const struct firmware *fw; - struct firmware tmp; char buf[128]; struct hda_codec *codec; int line_mode; - struct device *dev = bus->card->dev; - - if (snd_BUG_ON(!dev)) - return -ENODEV; - err = request_firmware(&fw, patch, dev); - if (err < 0) { - printk(KERN_ERR "hda-codec: Cannot load the patch '%s'\n", - patch); - return err; - } - tmp = *fw; line_mode = LINE_MODE_NONE; codec = NULL; - while (get_line_from_fw(buf, sizeof(buf) - 1, &tmp)) { + while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) { if (!*buf || *buf == '#' || *buf == '\n') continue; if (*buf == '[') @@ -810,7 +798,6 @@ int snd_hda_load_patch(struct hda_bus *bus, const char *patch) (codec || !patch_items[line_mode].need_codec)) patch_items[line_mode].parser(buf, bus, &codec); } - release_firmware(fw); return 0; } EXPORT_SYMBOL_HDA(snd_hda_load_patch); diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index c4763c52eaf6..72b085ae7d46 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -46,6 +46,7 @@ #include <linux/mutex.h> #include <linux/reboot.h> #include <linux/io.h> +#include <linux/pm_runtime.h> #ifdef CONFIG_X86 /* for snoop control */ #include <asm/pgtable.h> @@ -55,6 +56,7 @@ #include <sound/initval.h> #include <linux/vgaarb.h> #include <linux/vga_switcheroo.h> +#include <linux/firmware.h> #include "hda_codec.h" @@ -62,7 +64,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; static char *model[SNDRV_CARDS]; -static int position_fix[SNDRV_CARDS]; +static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; static int probe_only[SNDRV_CARDS]; @@ -86,7 +88,7 @@ module_param_array(model, charp, NULL, 0444); MODULE_PARM_DESC(model, "Use the given board model."); module_param_array(position_fix, int, NULL, 0444); MODULE_PARM_DESC(position_fix, "DMA pointer read method." - "(0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO)."); + "(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO)."); module_param_array(bdl_pos_adj, int, NULL, 0644); MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); module_param_array(probe_mask, int, NULL, 0444); @@ -108,9 +110,16 @@ MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode " "(0=off, 1=on) (default=1)."); #endif -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM +static int param_set_xint(const char *val, const struct kernel_param *kp); +static struct kernel_param_ops param_ops_xint = { + .set = param_set_xint, + .get = param_get_int, +}; +#define param_check_xint param_check_int + static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; -module_param(power_save, int, 0644); +module_param(power_save, xint, 0644); MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " "(in second, 0 = disable)."); @@ -121,7 +130,7 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " static bool power_save_controller = 1; module_param(power_save_controller, bool, 0644); MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); -#endif +#endif /* CONFIG_PM */ static int align_buffer_size = -1; module_param(align_buffer_size, bint, 0644); @@ -406,6 +415,7 @@ struct azx_dev { */ unsigned int insufficient :1; unsigned int wc_marked:1; + unsigned int no_period_wakeup:1; }; /* CORB/RIRB */ @@ -471,6 +481,10 @@ struct azx { struct snd_dma_buffer rb; struct snd_dma_buffer posbuf; +#ifdef CONFIG_SND_HDA_PATCH_LOADER + const struct firmware *fw; +#endif + /* flags */ int position_fix[2]; /* for both playback/capture streams */ int poll_count; @@ -487,6 +501,7 @@ struct azx { /* VGA-switcheroo setup */ unsigned int use_vga_switcheroo:1; + unsigned int vga_switcheroo_registered:1; unsigned int init_failed:1; /* delayed init failed */ unsigned int disabled:1; /* disabled by VGA-switcher */ @@ -498,6 +513,9 @@ struct azx { /* reboot notifier (for mysterious hangup problem at power-down) */ struct notifier_block reboot_notifier; + + /* card list (for power_save trigger) */ + struct list_head list; }; /* driver types */ @@ -537,7 +555,7 @@ enum { #define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */ #define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */ #define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */ -#define AZX_DCAPS_POSFIX_COMBO (1 << 24) /* Use COMBO as default */ +#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */ /* quirks for ATI SB / AMD Hudson */ #define AZX_DCAPS_PRESET_ATI_SB \ @@ -560,13 +578,17 @@ enum { * VGA-switcher support */ #ifdef SUPPORT_VGA_SWITCHEROO +#define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo) +#else +#define use_vga_switcheroo(chip) 0 +#endif + +#if defined(SUPPORT_VGA_SWITCHEROO) || defined(CONFIG_SND_HDA_PATCH_LOADER) #define DELAYED_INIT_MARK #define DELAYED_INITDATA_MARK -#define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo) #else #define DELAYED_INIT_MARK __devinit #define DELAYED_INITDATA_MARK __devinitdata -#define use_vga_switcheroo(chip) 0 #endif static char *driver_short_names[] DELAYED_INITDATA_MARK = { @@ -1012,8 +1034,8 @@ static unsigned int azx_get_response(struct hda_bus *bus, return azx_rirb_get_response(bus, addr); } -#ifdef CONFIG_SND_HDA_POWER_SAVE -static void azx_power_notify(struct hda_bus *bus); +#ifdef CONFIG_PM +static void azx_power_notify(struct hda_bus *bus, bool power_up); #endif /* reset codec link */ @@ -1269,6 +1291,11 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) u8 sd_status; int i, ok; +#ifdef CONFIG_PM_RUNTIME + if (chip->pci->dev.power.runtime_status != RPM_ACTIVE) + return IRQ_NONE; +#endif + spin_lock(&chip->reg_lock); if (chip->disabled) { @@ -1394,7 +1421,7 @@ static int azx_setup_periods(struct azx *chip, ofs = 0; azx_dev->frags = 0; pos_adj = bdl_pos_adj[chip->dev_index]; - if (pos_adj > 0) { + if (!azx_dev->no_period_wakeup && pos_adj > 0) { struct snd_pcm_runtime *runtime = substream->runtime; int pos_align = pos_adj; pos_adj = (pos_adj * runtime->rate + 47999) / 48000; @@ -1410,8 +1437,7 @@ static int azx_setup_periods(struct azx *chip, pos_adj = 0; } else { ofs = setup_bdle(chip, substream, azx_dev, - &bdl, ofs, pos_adj, - !substream->runtime->no_period_wakeup); + &bdl, ofs, pos_adj, true); if (ofs < 0) goto error; } @@ -1424,7 +1450,7 @@ static int azx_setup_periods(struct azx *chip, else ofs = setup_bdle(chip, substream, azx_dev, &bdl, ofs, period_bytes, - !substream->runtime->no_period_wakeup); + !azx_dev->no_period_wakeup); if (ofs < 0) goto error; } @@ -1580,7 +1606,7 @@ static int DELAYED_INIT_MARK azx_codec_create(struct azx *chip, const char *mode bus_temp.ops.get_response = azx_get_response; bus_temp.ops.attach_pcm = azx_attach_pcm_stream; bus_temp.ops.bus_reset = azx_bus_reset; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM bus_temp.power_save = &power_save; bus_temp.ops.pm_notify = azx_power_notify; #endif @@ -1897,10 +1923,12 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) if (bufsize != azx_dev->bufsize || period_bytes != azx_dev->period_bytes || - format_val != azx_dev->format_val) { + format_val != azx_dev->format_val || + runtime->no_period_wakeup != azx_dev->no_period_wakeup) { azx_dev->bufsize = bufsize; azx_dev->period_bytes = period_bytes; azx_dev->format_val = format_val; + azx_dev->no_period_wakeup = runtime->no_period_wakeup; err = azx_setup_periods(chip, substream, azx_dev); if (err < 0) return err; @@ -1959,14 +1987,14 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) } spin_lock(&chip->reg_lock); - if (nsync > 1) { - /* first, set SYNC bits of corresponding streams */ - if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC) - azx_writel(chip, OLD_SSYNC, - azx_readl(chip, OLD_SSYNC) | sbits); - else - azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits); - } + + /* first, set SYNC bits of corresponding streams */ + if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC) + azx_writel(chip, OLD_SSYNC, + azx_readl(chip, OLD_SSYNC) | sbits); + else + azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits); + snd_pcm_group_for_each_entry(s, substream) { if (s->pcm->card != substream->pcm->card) continue; @@ -1984,8 +2012,6 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) } spin_unlock(&chip->reg_lock); if (start) { - if (nsync == 1) - return 0; /* wait until all FIFOs get ready */ for (timeout = 5000; timeout; timeout--) { nwait = 0; @@ -2018,16 +2044,14 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) cpu_relax(); } } - if (nsync > 1) { - spin_lock(&chip->reg_lock); - /* reset SYNC bits */ - if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC) - azx_writel(chip, OLD_SSYNC, - azx_readl(chip, OLD_SSYNC) & ~sbits); - else - azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits); - spin_unlock(&chip->reg_lock); - } + spin_lock(&chip->reg_lock); + /* reset SYNC bits */ + if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC) + azx_writel(chip, OLD_SSYNC, + azx_readl(chip, OLD_SSYNC) & ~sbits); + else + azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits); + spin_unlock(&chip->reg_lock); return 0; } @@ -2120,6 +2144,30 @@ static unsigned int azx_get_position(struct azx *chip, if (pos >= azx_dev->bufsize) pos = 0; + + /* calculate runtime delay from LPIB */ + if (azx_dev->substream->runtime && + chip->position_fix[stream] == POS_FIX_POSBUF && + (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { + unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB); + int delay; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + delay = pos - lpib_pos; + else + delay = lpib_pos - pos; + if (delay < 0) + delay += azx_dev->bufsize; + if (delay >= azx_dev->period_bytes) { + snd_printk(KERN_WARNING SFX + "Unstable LPIB (%d >= %d); " + "disabling LPIB delay counting\n", + delay, azx_dev->period_bytes); + delay = 0; + chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; + } + azx_dev->substream->runtime->delay = + bytes_to_frames(azx_dev->substream->runtime, delay); + } return pos; } @@ -2379,33 +2427,65 @@ static void azx_stop_chip(struct azx *chip) chip->initialized = 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM /* power-up/down the controller */ -static void azx_power_notify(struct hda_bus *bus) +static void azx_power_notify(struct hda_bus *bus, bool power_up) { struct azx *chip = bus->private_data; + + if (power_up) + pm_runtime_get_sync(&chip->pci->dev); + else + pm_runtime_put_sync(&chip->pci->dev); +} + +static DEFINE_MUTEX(card_list_lock); +static LIST_HEAD(card_list); + +static void azx_add_card_list(struct azx *chip) +{ + mutex_lock(&card_list_lock); + list_add(&chip->list, &card_list); + mutex_unlock(&card_list_lock); +} + +static void azx_del_card_list(struct azx *chip) +{ + mutex_lock(&card_list_lock); + list_del_init(&chip->list); + mutex_unlock(&card_list_lock); +} + +/* trigger power-save check at writing parameter */ +static int param_set_xint(const char *val, const struct kernel_param *kp) +{ + struct azx *chip; struct hda_codec *c; - int power_on = 0; + int prev = power_save; + int ret = param_set_int(val, kp); - list_for_each_entry(c, &bus->codec_list, list) { - if (c->power_on) { - power_on = 1; - break; - } + if (ret || prev == power_save) + return ret; + + mutex_lock(&card_list_lock); + list_for_each_entry(chip, &card_list, list) { + if (!chip->bus || chip->disabled) + continue; + list_for_each_entry(c, &chip->bus->codec_list, list) + snd_hda_power_sync(c); } - if (power_on) - azx_init_chip(chip, 1); - else if (chip->running && power_save_controller && - !bus->power_keep_link_on) - azx_stop_chip(chip); + mutex_unlock(&card_list_lock); + return 0; } -#endif /* CONFIG_SND_HDA_POWER_SAVE */ +#else +#define azx_add_card_list(chip) /* NOP */ +#define azx_del_card_list(chip) /* NOP */ +#endif /* CONFIG_PM */ -#ifdef CONFIG_PM +#if defined(CONFIG_PM_SLEEP) || defined(SUPPORT_VGA_SWITCHEROO) /* * power management */ - static int azx_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -2460,11 +2540,41 @@ static int azx_resume(struct device *dev) snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } -static SIMPLE_DEV_PM_OPS(azx_pm, azx_suspend, azx_resume); +#endif /* CONFIG_PM_SLEEP || SUPPORT_VGA_SWITCHEROO */ + +#ifdef CONFIG_PM_RUNTIME +static int azx_runtime_suspend(struct device *dev) +{ + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip = card->private_data; + + if (!power_save_controller) + return -EAGAIN; + + azx_stop_chip(chip); + azx_clear_irq_pending(chip); + return 0; +} + +static int azx_runtime_resume(struct device *dev) +{ + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip = card->private_data; + + azx_init_pci(chip); + azx_init_chip(chip, 1); + return 0; +} +#endif /* CONFIG_PM_RUNTIME */ + +#ifdef CONFIG_PM +static const struct dev_pm_ops azx_pm = { + SET_SYSTEM_SLEEP_PM_OPS(azx_suspend, azx_resume) + SET_RUNTIME_PM_OPS(azx_runtime_suspend, azx_runtime_resume, NULL) +}; + #define AZX_PM_OPS &azx_pm #else -#define azx_suspend(dev) -#define azx_resume(dev) #define AZX_PM_OPS NULL #endif /* CONFIG_PM */ @@ -2534,7 +2644,9 @@ static void azx_vs_set_state(struct pci_dev *pci, if (disabled) { azx_suspend(&pci->dev); chip->disabled = true; - snd_hda_lock_devices(chip->bus); + if (snd_hda_lock_devices(chip->bus)) + snd_printk(KERN_WARNING SFX + "Cannot lock devices!\n"); } else { snd_hda_unlock_devices(chip->bus); chip->disabled = false; @@ -2577,14 +2689,20 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = { static int __devinit register_vga_switcheroo(struct azx *chip) { + int err; + if (!chip->use_vga_switcheroo) return 0; /* FIXME: currently only handling DIS controller * is there any machine with two switchable HDMI audio controllers? */ - return vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, + err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, VGA_SWITCHEROO_DIS, chip->bus != NULL); + if (err < 0) + return err; + chip->vga_switcheroo_registered = 1; + return 0; } #else #define init_vga_switcheroo(chip) /* NOP */ @@ -2599,12 +2717,15 @@ static int azx_free(struct azx *chip) { int i; + azx_del_card_list(chip); + azx_notifier_unregister(chip); if (use_vga_switcheroo(chip)) { if (chip->disabled && chip->bus) snd_hda_unlock_devices(chip->bus); - vga_switcheroo_unregister_client(chip->pci); + if (chip->vga_switcheroo_registered) + vga_switcheroo_unregister_client(chip->pci); } if (chip->initialized) { @@ -2640,6 +2761,10 @@ static int azx_free(struct azx *chip) pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip->azx_dev); +#ifdef CONFIG_SND_HDA_PATCH_LOADER + if (chip->fw) + release_firmware(chip->fw); +#endif kfree(chip); return 0; @@ -2701,8 +2826,6 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = { SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), - SND_PCI_QUIRK(0x1043, 0x1ac3, "ASUS X53S", POS_FIX_POSBUF), - SND_PCI_QUIRK(0x1043, 0x1b43, "ASUS K53E", POS_FIX_POSBUF), SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), SND_PCI_QUIRK(0x10de, 0xcb89, "Macbook Pro 7,1", POS_FIX_LPIB), SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), @@ -2719,6 +2842,7 @@ static int __devinit check_position_fix(struct azx *chip, int fix) const struct snd_pci_quirk *q; switch (fix) { + case POS_FIX_AUTO: case POS_FIX_LPIB: case POS_FIX_POSBUF: case POS_FIX_VIACOMBO: @@ -2744,10 +2868,6 @@ static int __devinit check_position_fix(struct azx *chip, int fix) snd_printd(SFX "Using LPIB position fix\n"); return POS_FIX_LPIB; } - if (chip->driver_caps & AZX_DCAPS_POSFIX_COMBO) { - snd_printd(SFX "Using COMBO position fix\n"); - return POS_FIX_COMBO; - } return POS_FIX_AUTO; } @@ -2904,6 +3024,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, chip->dev_index = dev; INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); INIT_LIST_HEAD(&chip->pcm_list); + INIT_LIST_HEAD(&chip->list); init_vga_switcheroo(chip); chip->position_fix[0] = chip->position_fix[1] = @@ -2952,14 +3073,6 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, } ok: - err = register_vga_switcheroo(chip); - if (err < 0) { - snd_printk(KERN_ERR SFX - "Error registering VGA-switcheroo client\n"); - azx_free(chip); - return err; - } - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); @@ -3138,7 +3251,7 @@ static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) static void power_down_all_codecs(struct azx *chip) { -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM /* The codecs were powered up in snd_hda_codec_new(). * Now all initialization done, so turn them down if possible */ @@ -3149,12 +3262,40 @@ static void power_down_all_codecs(struct azx *chip) #endif } +#ifdef CONFIG_SND_HDA_PATCH_LOADER +/* callback from request_firmware_nowait() */ +static void azx_firmware_cb(const struct firmware *fw, void *context) +{ + struct snd_card *card = context; + struct azx *chip = card->private_data; + struct pci_dev *pci = chip->pci; + + if (!fw) { + snd_printk(KERN_ERR SFX "Cannot load firmware, aborting\n"); + goto error; + } + + chip->fw = fw; + if (!chip->disabled) { + /* continue probing */ + if (azx_probe_continue(chip)) + goto error; + } + return; /* OK */ + + error: + snd_card_free(card); + pci_set_drvdata(pci, NULL); +} +#endif + static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; struct snd_card *card; struct azx *chip; + bool probe_now; int err; if (dev >= SNDRV_CARDS) @@ -3170,15 +3311,28 @@ static int __devinit azx_probe(struct pci_dev *pci, return err; } - /* set this here since it's referred in snd_hda_load_patch() */ snd_card_set_dev(card, &pci->dev); err = azx_create(card, pci, dev, pci_id->driver_data, &chip); if (err < 0) goto out_free; card->private_data = chip; + probe_now = !chip->disabled; - if (!chip->disabled) { +#ifdef CONFIG_SND_HDA_PATCH_LOADER + if (patch[dev] && *patch[dev]) { + snd_printk(KERN_ERR SFX "Applying patch firmware '%s'\n", + patch[dev]); + err = request_firmware_nowait(THIS_MODULE, true, patch[dev], + &pci->dev, GFP_KERNEL, card, + azx_firmware_cb); + if (err < 0) + goto out_free; + probe_now = false; /* continued in azx_firmware_cb() */ + } +#endif /* CONFIG_SND_HDA_PATCH_LOADER */ + + if (probe_now) { err = azx_probe_continue(chip); if (err < 0) goto out_free; @@ -3186,6 +3340,16 @@ static int __devinit azx_probe(struct pci_dev *pci, pci_set_drvdata(pci, card); + if (pci_dev_run_wake(pci)) + pm_runtime_put_noidle(&pci->dev); + + err = register_vga_switcheroo(chip); + if (err < 0) { + snd_printk(KERN_ERR SFX + "Error registering VGA-switcheroo client\n"); + goto out_free; + } + dev++; return 0; @@ -3208,12 +3372,13 @@ static int DELAYED_INIT_MARK azx_probe_continue(struct azx *chip) if (err < 0) goto out_free; #ifdef CONFIG_SND_HDA_PATCH_LOADER - if (patch[dev] && *patch[dev]) { - snd_printk(KERN_ERR SFX "Applying patch firmware '%s'\n", - patch[dev]); - err = snd_hda_load_patch(chip->bus, patch[dev]); + if (chip->fw) { + err = snd_hda_load_patch(chip->bus, chip->fw->size, + chip->fw->data); if (err < 0) goto out_free; + release_firmware(chip->fw); /* no longer needed */ + chip->fw = NULL; } #endif if ((probe_only[dev] & 1) == 0) { @@ -3239,6 +3404,7 @@ static int DELAYED_INIT_MARK azx_probe_continue(struct azx *chip) chip->running = 1; power_down_all_codecs(chip); azx_notifier_register(chip); + azx_add_card_list(chip); return 0; @@ -3250,6 +3416,10 @@ out_free: static void __devexit azx_remove(struct pci_dev *pci) { struct snd_card *card = pci_get_drvdata(pci); + + if (pci_dev_run_wake(pci)) + pm_runtime_get_noresume(&pci->dev); + if (card) snd_card_free(card); pci_set_drvdata(pci, NULL); @@ -3260,7 +3430,7 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { /* CPT */ { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* PBG */ { PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | @@ -3268,23 +3438,30 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { /* Panther Point */ { PCI_DEVICE(0x8086, 0x1e20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* Lynx Point */ { PCI_DEVICE(0x8086, 0x8c20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* Lynx Point-LP */ { PCI_DEVICE(0x8086, 0x9c20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* Lynx Point-LP */ { PCI_DEVICE(0x8086, 0x9c21), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* Haswell */ { PCI_DEVICE(0x8086, 0x0c0c), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | - AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_COMBO }, + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, + { PCI_DEVICE(0x8086, 0x0d0c), + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, + /* 5 Series/3400 */ + { PCI_DEVICE(0x8086, 0x3b56), + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | + AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY }, /* SCH */ { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index aaccc0236bda..5c690cb873d4 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -26,9 +26,8 @@ bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) return false; if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT)) return false; - if (!codec->ignore_misc_bit && - (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & - AC_DEFCFG_MISC_NO_PRESENCE)) + if (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & + AC_DEFCFG_MISC_NO_PRESENCE) return false; if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) return false; @@ -193,8 +192,9 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect); /** * snd_hda_jack_detect_enable - enable the jack-detection */ -int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, - unsigned char action) +int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, + unsigned char action, + hda_jack_callback cb) { struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); if (!jack) @@ -204,10 +204,19 @@ int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, jack->jack_detect = 1; if (action) jack->action = action; + if (cb) + jack->callback = cb; return snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | jack->tag); } +EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable_callback); + +int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, + unsigned char action) +{ + return snd_hda_jack_detect_enable_callback(codec, nid, action, NULL); +} EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); /** @@ -412,3 +421,21 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, return 0; } EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls); + +void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res) +{ + struct hda_jack_tbl *event; + int tag = (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x7f; + + event = snd_hda_jack_tbl_get_from_tag(codec, tag); + if (!event) + return; + event->jack_dirty = 1; + + if (event->callback) + event->callback(codec, event); + + snd_hda_jack_report_sync(codec); +} +EXPORT_SYMBOL_HDA(snd_hda_jack_unsol_event); + diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index a9803da633c0..af8dd4724da5 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h @@ -13,12 +13,16 @@ #define __SOUND_HDA_JACK_H struct auto_pin_cfg; +struct hda_jack_tbl; + +typedef void (*hda_jack_callback) (struct hda_codec *, struct hda_jack_tbl *); struct hda_jack_tbl { hda_nid_t nid; unsigned char action; /* event action (0 = none) */ unsigned char tag; /* unsol event tag */ unsigned int private_data; /* arbitrary data */ + hda_jack_callback callback; /* jack-detection stuff */ unsigned int pin_sense; /* cached pin-sense value */ unsigned int jack_detect:1; /* capable of jack-detection? */ @@ -61,6 +65,10 @@ void snd_hda_jack_set_dirty_all(struct hda_codec *codec); int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, unsigned char action); +int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, + unsigned char action, + hda_jack_callback cb); + u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); @@ -74,5 +82,6 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, void snd_hda_jack_report_sync(struct hda_codec *codec); +void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res); #endif /* __SOUND_HDA_JACK_H */ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 1b4c12941baa..09dbdc37f781 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -529,7 +529,7 @@ int snd_hda_create_hwdep(struct hda_codec *codec); static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } #endif -#if defined(CONFIG_SND_HDA_POWER_SAVE) && defined(CONFIG_SND_HDA_HWDEP) +#if defined(CONFIG_PM) && defined(CONFIG_SND_HDA_HWDEP) int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec); #else static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec) diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 6894ec66258c..045e5d32f5de 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -402,6 +402,9 @@ static void print_digital_conv(struct snd_info_buffer *buffer, { unsigned int digi1 = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); + unsigned char digi2 = digi1 >> 8; + unsigned char digi3 = digi1 >> 16; + snd_iprintf(buffer, " Digital:"); if (digi1 & AC_DIG1_ENABLE) snd_iprintf(buffer, " Enabled"); @@ -419,9 +422,13 @@ static void print_digital_conv(struct snd_info_buffer *buffer, snd_iprintf(buffer, " Pro"); if (digi1 & AC_DIG1_LEVEL) snd_iprintf(buffer, " GenLevel"); + if (digi3 & AC_DIG3_KAE) + snd_iprintf(buffer, " KAE"); snd_iprintf(buffer, "\n"); snd_iprintf(buffer, " Digital category: 0x%x\n", - (digi1 >> 8) & AC_DIG2_CC); + digi2 & AC_DIG2_CC); + snd_iprintf(buffer, " IEC Coding Type: 0x%x\n", + digi3 & AC_DIG3_ICT); } static const char *get_pwr_state(u32 state) diff --git a/sound/pci/hda/hda_trace.h b/sound/pci/hda/hda_trace.h index 9884871ddb00..3a1c63161eb1 100644 --- a/sound/pci/hda/hda_trace.h +++ b/sound/pci/hda/hda_trace.h @@ -58,6 +58,7 @@ TRACE_EVENT(hda_bus_reset, TP_printk("[%d]", __entry->card) ); +#ifdef CONFIG_PM DECLARE_EVENT_CLASS(hda_power, TP_PROTO(struct hda_codec *codec), @@ -87,6 +88,31 @@ DEFINE_EVENT(hda_power, hda_power_up, TP_ARGS(codec) ); +TRACE_EVENT(hda_power_count, + TP_PROTO(struct hda_codec *codec), + TP_ARGS(codec), + TP_STRUCT__entry( + __field( unsigned int, card ) + __field( unsigned int, addr ) + __field( int, power_count ) + __field( int, power_on ) + __field( int, power_transition ) + ), + + TP_fast_assign( + __entry->card = (codec)->bus->card->number; + __entry->addr = (codec)->addr; + __entry->power_count = (codec)->power_count; + __entry->power_on = (codec)->power_on; + __entry->power_transition = (codec)->power_transition; + ), + + TP_printk("[%d:%d] power_count=%d, power_on=%d, power_transition=%d", + __entry->card, __entry->addr, __entry->power_count, + __entry->power_on, __entry->power_transition) +); +#endif /* CONFIG_PM */ + TRACE_EVENT(hda_unsol_event, TP_PROTO(struct hda_bus *bus, u32 res, u32 res_ex), diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 0208fa121e5a..cdd43eadbc67 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -85,7 +85,7 @@ struct ad198x_spec { unsigned int analog_beep: 1; /* analog beep input present */ unsigned int avoid_init_slave_vol:1; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM struct hda_loopback_check loopback; #endif /* for virtual master */ @@ -269,7 +269,7 @@ static int ad198x_build_controls(struct hda_codec *codec) return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid) { struct ad198x_spec *spec = codec->spec; @@ -654,10 +654,8 @@ static const struct hda_codec_ops ad198x_patch_ops = { .build_pcms = ad198x_build_pcms, .init = ad198x_init, .free = ad198x_free, -#ifdef CONFIG_SND_HDA_POWER_SAVE - .check_power_status = ad198x_check_power_status, -#endif #ifdef CONFIG_PM + .check_power_status = ad198x_check_power_status, .suspend = ad198x_suspend, #endif .reboot_notify = ad198x_shutup, @@ -1231,7 +1229,7 @@ static const struct snd_pci_quirk ad1986a_cfg_tbl[] = { {} }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1986a_loopbacks[] = { { 0x13, HDA_OUTPUT, 0 }, /* Mic */ { 0x14, HDA_OUTPUT, 0 }, /* Phone */ @@ -1278,7 +1276,7 @@ static int patch_ad1986a(struct hda_codec *codec) spec->mixers[0] = ad1986a_mixers; spec->num_init_verbs = 1; spec->init_verbs[0] = ad1986a_init_verbs; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1986a_loopbacks; #endif spec->vmaster_nid = 0x1b; @@ -1537,7 +1535,7 @@ static const struct hda_verb ad1983_init_verbs[] = { { } /* end */ }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1983_loopbacks[] = { { 0x12, HDA_OUTPUT, 0 }, /* Mic */ { 0x13, HDA_OUTPUT, 0 }, /* Line */ @@ -1576,7 +1574,7 @@ static int patch_ad1983(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = ad1983_init_verbs; spec->spdif_route = 0; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1983_loopbacks; #endif spec->vmaster_nid = 0x05; @@ -1704,7 +1702,7 @@ static const struct hda_verb ad1981_init_verbs[] = { { } /* end */ }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1981_loopbacks[] = { { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */ { 0x13, HDA_OUTPUT, 0 }, /* Line */ @@ -1812,7 +1810,7 @@ static const struct hda_input_mux ad1981_hp_capture_source = { .num_items = 3, .items = { { "Mic", 0x0 }, - { "Docking-Station", 0x1 }, + { "Dock Mic", 0x1 }, { "Mix", 0x2 }, }, }; @@ -1836,8 +1834,8 @@ static const struct snd_kcontrol_new ad1981_hp_mixers[] = { */ HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), - HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), /* FIXME: does this laptop have analog CD connection? */ @@ -1982,7 +1980,7 @@ static int patch_ad1981(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = ad1981_init_verbs; spec->spdif_route = 0; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1981_loopbacks; #endif spec->vmaster_nid = 0x05; @@ -2807,7 +2805,7 @@ static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) snd_hda_sequence_write(codec, ad1988_laptop_hp_off); } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1988_loopbacks[] = { { 0x20, HDA_INPUT, 0 }, /* Front Mic */ { 0x20, HDA_INPUT, 1 }, /* Line */ @@ -3399,7 +3397,7 @@ static int patch_ad1988(struct hda_codec *codec) codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; break; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1988_loopbacks; #endif spec->vmaster_nid = 0x04; @@ -3555,7 +3553,7 @@ static const struct hda_verb ad1884_init_verbs[] = { { } /* end */ }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1884_loopbacks[] = { { 0x20, HDA_INPUT, 0 }, /* Front Mic */ { 0x20, HDA_INPUT, 1 }, /* Mic */ @@ -3567,7 +3565,7 @@ static const struct hda_amp_list ad1884_loopbacks[] = { static const char * const ad1884_slave_vols[] = { "PCM", "Mic", "Mono", "Front Mic", "Mic", "CD", - "Internal Mic", "Docking Mic", /* "Beep", */ "IEC958", + "Internal Mic", "Dock Mic", /* "Beep", */ "IEC958", NULL }; @@ -3602,7 +3600,7 @@ static int patch_ad1884(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = ad1884_init_verbs; spec->spdif_route = 0; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1884_loopbacks; #endif spec->vmaster_nid = 0x04; @@ -3628,7 +3626,7 @@ static const struct hda_input_mux ad1984_thinkpad_capture_source = { { "Mic", 0x0 }, { "Internal Mic", 0x1 }, { "Mix", 0x3 }, - { "Docking-Station", 0x4 }, + { "Dock Mic", 0x4 }, }, }; @@ -3657,8 +3655,8 @@ static const struct snd_kcontrol_new ad1984_thinkpad_mixers[] = { HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), - HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT), - HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT), HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT), HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT), HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT), @@ -3994,7 +3992,7 @@ static const struct hda_verb ad1884a_init_verbs[] = { { } /* end */ }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static const struct hda_amp_list ad1884a_loopbacks[] = { { 0x20, HDA_INPUT, 0 }, /* Front Mic */ { 0x20, HDA_INPUT, 1 }, /* Mic */ @@ -4602,7 +4600,7 @@ static int patch_ad1884a(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = ad1884a_init_verbs; spec->spdif_route = 0; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1884a_loopbacks; #endif codec->patch_ops = ad198x_patch_ops; @@ -4814,6 +4812,32 @@ static const struct snd_kcontrol_new ad1882_3stack_mixers[] = { { } /* end */ }; +/* simple auto-mute control for AD1882 3-stack board */ +#define AD1882_HP_EVENT 0x01 + +static void ad1882_3stack_automute(struct hda_codec *codec) +{ + bool mute = snd_hda_jack_detect(codec, 0x11); + snd_hda_codec_write(codec, 0x12, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + mute ? 0 : PIN_OUT); +} + +static int ad1882_3stack_automute_init(struct hda_codec *codec) +{ + ad198x_init(codec); + ad1882_3stack_automute(codec); + return 0; +} + +static void ad1882_3stack_unsol_event(struct hda_codec *codec, unsigned int res) +{ + switch (res >> 26) { + case AD1882_HP_EVENT: + ad1882_3stack_automute(codec); + break; + } +} + static const struct snd_kcontrol_new ad1882_6stack_mixers[] = { HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT), @@ -4928,7 +4952,12 @@ static const struct hda_verb ad1882_init_verbs[] = { { } /* end */ }; -#ifdef CONFIG_SND_HDA_POWER_SAVE +static const struct hda_verb ad1882_3stack_automute_verbs[] = { + {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1882_HP_EVENT}, + { } /* end */ +}; + +#ifdef CONFIG_PM static const struct hda_amp_list ad1882_loopbacks[] = { { 0x20, HDA_INPUT, 0 }, /* Front Mic */ { 0x20, HDA_INPUT, 1 }, /* Mic */ @@ -4942,12 +4971,14 @@ static const struct hda_amp_list ad1882_loopbacks[] = { enum { AD1882_3STACK, AD1882_6STACK, + AD1882_3STACK_AUTOMUTE, AD1882_MODELS }; static const char * const ad1882_models[AD1986A_MODELS] = { [AD1882_3STACK] = "3stack", [AD1882_6STACK] = "6stack", + [AD1882_3STACK_AUTOMUTE] = "3stack-automute", }; @@ -4989,7 +5020,7 @@ static int patch_ad1882(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = ad1882_init_verbs; spec->spdif_route = 0; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->loopback.amplist = ad1882_loopbacks; #endif spec->vmaster_nid = 0x04; @@ -5002,6 +5033,7 @@ static int patch_ad1882(struct hda_codec *codec) switch (board_config) { default: case AD1882_3STACK: + case AD1882_3STACK_AUTOMUTE: spec->num_mixers = 3; spec->mixers[2] = ad1882_3stack_mixers; spec->channel_mode = ad1882_modes; @@ -5009,6 +5041,12 @@ static int patch_ad1882(struct hda_codec *codec) spec->need_dac_fix = 1; spec->multiout.max_channels = 2; spec->multiout.num_dacs = 1; + if (board_config != AD1882_3STACK) { + spec->init_verbs[spec->num_init_verbs++] = + ad1882_3stack_automute_verbs; + codec->patch_ops.unsol_event = ad1882_3stack_unsol_event; + codec->patch_ops.init = ad1882_3stack_automute_init; + } break; case AD1882_6STACK: spec->num_mixers = 3; diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 0c4c1a61b378..61a71131711c 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -34,7 +34,8 @@ */ struct cs_spec { - int board_config; + struct hda_gen_spec gen; + struct auto_pin_cfg autocfg; struct hda_multi_out multiout; struct snd_kcontrol *vmaster_sw; @@ -80,16 +81,20 @@ enum { CS420X_MBP53, CS420X_MBP55, CS420X_IMAC27, - CS420X_IMAC27_122, - CS420X_APPLE, + CS420X_GPIO_13, + CS420X_GPIO_23, + CS420X_MBP101, + CS420X_MBP101_COEF, CS420X_AUTO, - CS420X_MODELS + /* aliases */ + CS420X_IMAC27_122 = CS420X_GPIO_23, + CS420X_APPLE = CS420X_GPIO_13, }; /* CS421x boards */ enum { CS421X_CDB4210, - CS421X_MODELS + CS421X_SENSE_B, }; /* Vendor-specific processing widget */ @@ -892,7 +897,7 @@ static int build_digital_input(struct hda_codec *codec) * HP/SPK/SPDIF */ -static void cs_automute(struct hda_codec *codec) +static void cs_automute(struct hda_codec *codec, struct hda_jack_tbl *tbl) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -968,7 +973,7 @@ static void cs_automute(struct hda_codec *codec) * Switch max 3 inputs of a single ADC (nid 3) */ -static void cs_automic(struct hda_codec *codec) +static void cs_automic(struct hda_codec *codec, struct hda_jack_tbl *tbl) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -1030,7 +1035,7 @@ static void init_output(struct hda_codec *codec) if (!cfg->speaker_outs) continue; if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { - snd_hda_jack_detect_enable(codec, nid, HP_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, HP_EVENT, cs_automute); spec->hp_detect = 1; } } @@ -1041,7 +1046,7 @@ static void init_output(struct hda_codec *codec) /* SPDIF is enabled on presence detect for CS421x */ if (spec->hp_detect || spec->spdif_detect) - cs_automute(codec); + cs_automute(codec, NULL); } static void init_input(struct hda_codec *codec) @@ -1065,13 +1070,13 @@ static void init_input(struct hda_codec *codec) AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(spec->adc_idx[i])); if (spec->mic_detect && spec->automic_idx == i) - snd_hda_jack_detect_enable(codec, pin, MIC_EVENT); + snd_hda_jack_detect_enable_callback(codec, pin, MIC_EVENT, cs_automic); } /* CS420x has multiple ADC, CS421x has single ADC */ if (spec->vendor_nid == CS420X_VENDOR_NID) { change_cur_input(codec, spec->cur_input, 1); if (spec->mic_detect) - cs_automic(codec); + cs_automic(codec, NULL); coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ if (is_active_pin(codec, CS_DMIC2_PIN_NID)) @@ -1084,7 +1089,7 @@ static void init_input(struct hda_codec *codec) cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); } else { if (spec->mic_detect) - cs_automic(codec); + cs_automic(codec, NULL); else { spec->cur_adc = spec->adc_nid[spec->cur_input]; cs_update_input_select(codec); @@ -1157,6 +1162,14 @@ static const struct hda_verb cs_errata_init_verbs[] = { {} /* terminator */ }; +static const struct hda_verb mbp101_init_verbs[] = { + {0x11, AC_VERB_SET_COEF_INDEX, 0x0002}, + {0x11, AC_VERB_SET_PROC_COEF, 0x100a}, + {0x11, AC_VERB_SET_COEF_INDEX, 0x0004}, + {0x11, AC_VERB_SET_PROC_COEF, 0x000f}, + {} +}; + /* SPDIF setup */ static void init_digital(struct hda_codec *codec) { @@ -1193,7 +1206,6 @@ static int cs_init(struct hda_codec *codec) init_output(codec); init_input(codec); init_digital(codec); - snd_hda_jack_report_sync(codec); return 0; } @@ -1231,28 +1243,16 @@ static void cs_free(struct hda_codec *codec) struct cs_spec *spec = codec->spec; kfree(spec->capture_bind[0]); kfree(spec->capture_bind[1]); + snd_hda_gen_free(&spec->gen); kfree(codec->spec); } -static void cs_unsol_event(struct hda_codec *codec, unsigned int res) -{ - switch (snd_hda_jack_get_action(codec, res >> 26)) { - case HP_EVENT: - cs_automute(codec); - break; - case MIC_EVENT: - cs_automic(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - static const struct hda_codec_ops cs_patch_ops = { .build_controls = cs_build_controls, .build_pcms = cs_build_pcms, .init = cs_init, .free = cs_free, - .unsol_event = cs_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, }; static int cs_parse_auto_config(struct hda_codec *codec) @@ -1279,38 +1279,32 @@ static int cs_parse_auto_config(struct hda_codec *codec) return 0; } -static const char * const cs420x_models[CS420X_MODELS] = { - [CS420X_MBP53] = "mbp53", - [CS420X_MBP55] = "mbp55", - [CS420X_IMAC27] = "imac27", - [CS420X_IMAC27_122] = "imac27_122", - [CS420X_APPLE] = "apple", - [CS420X_AUTO] = "auto", +static const struct hda_model_fixup cs420x_models[] = { + { .id = CS420X_MBP53, .name = "mbp53" }, + { .id = CS420X_MBP55, .name = "mbp55" }, + { .id = CS420X_IMAC27, .name = "imac27" }, + { .id = CS420X_IMAC27_122, .name = "imac27_122" }, + { .id = CS420X_APPLE, .name = "apple" }, + { .id = CS420X_MBP101, .name = "mbp101" }, + {} }; - -static const struct snd_pci_quirk cs420x_cfg_tbl[] = { +static const struct snd_pci_quirk cs420x_fixup_tbl[] = { SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), /* this conflicts with too many other models */ /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/ - {} /* terminator */ -}; -static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = { + /* codec SSID */ SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122), + SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101), SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), {} /* terminator */ }; -struct cs_pincfg { - hda_nid_t nid; - u32 val; -}; - -static const struct cs_pincfg mbp53_pincfgs[] = { +static const struct hda_pintbl mbp53_pincfgs[] = { { 0x09, 0x012b4050 }, { 0x0a, 0x90100141 }, { 0x0b, 0x90100140 }, @@ -1324,7 +1318,7 @@ static const struct cs_pincfg mbp53_pincfgs[] = { {} /* terminator */ }; -static const struct cs_pincfg mbp55_pincfgs[] = { +static const struct hda_pintbl mbp55_pincfgs[] = { { 0x09, 0x012b4030 }, { 0x0a, 0x90100121 }, { 0x0b, 0x90100120 }, @@ -1338,7 +1332,7 @@ static const struct cs_pincfg mbp55_pincfgs[] = { {} /* terminator */ }; -static const struct cs_pincfg imac27_pincfgs[] = { +static const struct hda_pintbl imac27_pincfgs[] = { { 0x09, 0x012b4050 }, { 0x0a, 0x90100140 }, { 0x0b, 0x90100142 }, @@ -1352,22 +1346,78 @@ static const struct cs_pincfg imac27_pincfgs[] = { {} /* terminator */ }; -static const struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { - [CS420X_MBP53] = mbp53_pincfgs, - [CS420X_MBP55] = mbp55_pincfgs, - [CS420X_IMAC27] = imac27_pincfgs, +static const struct hda_pintbl mbp101_pincfgs[] = { + { 0x0d, 0x40ab90f0 }, + { 0x0e, 0x90a600f0 }, + { 0x12, 0x50a600f0 }, + {} /* terminator */ }; -static void fix_pincfg(struct hda_codec *codec, int model, - const struct cs_pincfg **pin_configs) +static void cs420x_fixup_gpio_13(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + if (action == HDA_FIXUP_ACT_PRE_PROBE) { + struct cs_spec *spec = codec->spec; + spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ + spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ + spec->gpio_mask = spec->gpio_dir = + spec->gpio_eapd_hp | spec->gpio_eapd_speaker; + } +} + +static void cs420x_fixup_gpio_23(struct hda_codec *codec, + const struct hda_fixup *fix, int action) { - const struct cs_pincfg *cfg = pin_configs[model]; - if (!cfg) - return; - for (; cfg->nid; cfg++) - snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); + if (action == HDA_FIXUP_ACT_PRE_PROBE) { + struct cs_spec *spec = codec->spec; + spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ + spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ + spec->gpio_mask = spec->gpio_dir = + spec->gpio_eapd_hp | spec->gpio_eapd_speaker; + } } +static const struct hda_fixup cs420x_fixups[] = { + [CS420X_MBP53] = { + .type = HDA_FIXUP_PINS, + .v.pins = mbp53_pincfgs, + .chained = true, + .chain_id = CS420X_APPLE, + }, + [CS420X_MBP55] = { + .type = HDA_FIXUP_PINS, + .v.pins = mbp55_pincfgs, + .chained = true, + .chain_id = CS420X_GPIO_13, + }, + [CS420X_IMAC27] = { + .type = HDA_FIXUP_PINS, + .v.pins = imac27_pincfgs, + .chained = true, + .chain_id = CS420X_GPIO_13, + }, + [CS420X_GPIO_13] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs420x_fixup_gpio_13, + }, + [CS420X_GPIO_23] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs420x_fixup_gpio_23, + }, + [CS420X_MBP101] = { + .type = HDA_FIXUP_PINS, + .v.pins = mbp101_pincfgs, + .chained = true, + .chain_id = CS420X_MBP101_COEF, + }, + [CS420X_MBP101_COEF] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = mbp101_init_verbs, + .chained = true, + .chain_id = CS420X_GPIO_13, + }, +}; + static int patch_cs420x(struct hda_codec *codec) { struct cs_spec *spec; @@ -1377,36 +1427,13 @@ static int patch_cs420x(struct hda_codec *codec) if (!spec) return -ENOMEM; codec->spec = spec; + snd_hda_gen_init(&spec->gen); spec->vendor_nid = CS420X_VENDOR_NID; - spec->board_config = - snd_hda_check_board_config(codec, CS420X_MODELS, - cs420x_models, cs420x_cfg_tbl); - if (spec->board_config < 0) - spec->board_config = - snd_hda_check_board_codec_sid_config(codec, - CS420X_MODELS, NULL, cs420x_codec_cfg_tbl); - if (spec->board_config >= 0) - fix_pincfg(codec, spec->board_config, cs_pincfgs); - - switch (spec->board_config) { - case CS420X_IMAC27: - case CS420X_MBP53: - case CS420X_MBP55: - case CS420X_APPLE: - spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ - spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ - spec->gpio_mask = spec->gpio_dir = - spec->gpio_eapd_hp | spec->gpio_eapd_speaker; - break; - case CS420X_IMAC27_122: - spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ - spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ - spec->gpio_mask = spec->gpio_dir = - spec->gpio_eapd_hp | spec->gpio_eapd_speaker; - break; - } + snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl, + cs420x_fixups); + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); err = cs_parse_auto_config(codec); if (err < 0) @@ -1414,10 +1441,12 @@ static int patch_cs420x(struct hda_codec *codec) codec->patch_ops = cs_patch_ops; + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); + return 0; error: - kfree(codec->spec); + cs_free(codec); codec->spec = NULL; return err; } @@ -1431,11 +1460,12 @@ static int patch_cs420x(struct hda_codec *codec) */ /* CS4210 board names */ -static const char *cs421x_models[CS421X_MODELS] = { - [CS421X_CDB4210] = "cdb4210", +static const struct hda_model_fixup cs421x_models[] = { + { .id = CS421X_CDB4210, .name = "cdb4210" }, + {} }; -static const struct snd_pci_quirk cs421x_cfg_tbl[] = { +static const struct snd_pci_quirk cs421x_fixup_tbl[] = { /* Test Intel board + CDB2410 */ SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210), {} /* terminator */ @@ -1443,7 +1473,7 @@ static const struct snd_pci_quirk cs421x_cfg_tbl[] = { /* CS4210 board pinconfigs */ /* Default CS4210 (CDB4210)*/ -static const struct cs_pincfg cdb4210_pincfgs[] = { +static const struct hda_pintbl cdb4210_pincfgs[] = { { 0x05, 0x0321401f }, { 0x06, 0x90170010 }, { 0x07, 0x03813031 }, @@ -1453,8 +1483,26 @@ static const struct cs_pincfg cdb4210_pincfgs[] = { {} /* terminator */ }; -static const struct cs_pincfg *cs421x_pincfgs[CS421X_MODELS] = { - [CS421X_CDB4210] = cdb4210_pincfgs, +/* Setup GPIO/SENSE for each board (if used) */ +static void cs421x_fixup_sense_b(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + struct cs_spec *spec = codec->spec; + if (action == HDA_FIXUP_ACT_PRE_PROBE) + spec->sense_b = 1; +} + +static const struct hda_fixup cs421x_fixups[] = { + [CS421X_CDB4210] = { + .type = HDA_FIXUP_PINS, + .v.pins = cdb4210_pincfgs, + .chained = true, + .chain_id = CS421X_SENSE_B, + }, + [CS421X_SENSE_B] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs421x_fixup_sense_b, + } }; static const struct hda_verb cs421x_coef_init_verbs[] = { @@ -1615,7 +1663,7 @@ static void init_cs421x_digital(struct hda_codec *codec) if (!cfg->speaker_outs) continue; if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { - snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, SPDIF_EVENT, cs_automute); spec->spdif_detect = 1; } } @@ -1643,7 +1691,6 @@ static int cs421x_init(struct hda_codec *codec) init_output(codec); init_input(codec); init_cs421x_digital(codec); - snd_hda_jack_report_sync(codec); return 0; } @@ -1831,21 +1878,6 @@ static int cs421x_build_controls(struct hda_codec *codec) return 0; } -static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res) -{ - switch (snd_hda_jack_get_action(codec, res >> 26)) { - case HP_EVENT: - case SPDIF_EVENT: - cs_automute(codec); - break; - - case MIC_EVENT: - cs_automic(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - static int parse_cs421x_input(struct hda_codec *codec) { struct cs_spec *spec = codec->spec; @@ -1919,7 +1951,7 @@ static struct hda_codec_ops cs421x_patch_ops = { .build_pcms = cs_build_pcms, .init = cs421x_init, .free = cs_free, - .unsol_event = cs421x_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = cs421x_suspend, #endif @@ -1934,29 +1966,13 @@ static int patch_cs4210(struct hda_codec *codec) if (!spec) return -ENOMEM; codec->spec = spec; + snd_hda_gen_init(&spec->gen); spec->vendor_nid = CS4210_VENDOR_NID; - spec->board_config = - snd_hda_check_board_config(codec, CS421X_MODELS, - cs421x_models, cs421x_cfg_tbl); - if (spec->board_config >= 0) - fix_pincfg(codec, spec->board_config, cs421x_pincfgs); - /* - Setup GPIO/SENSE for each board (if used) - */ - switch (spec->board_config) { - case CS421X_CDB4210: - snd_printd("CS4210 board: %s\n", - cs421x_models[spec->board_config]); -/* spec->gpio_mask = 3; - spec->gpio_dir = 3; - spec->gpio_data = 3; -*/ - spec->sense_b = 1; - - break; - } + snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl, + cs421x_fixups); + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); /* Update the GPIO/DMIC/SENSE_B pinmux before the configuration @@ -1971,10 +1987,12 @@ static int patch_cs4210(struct hda_codec *codec) codec->patch_ops = cs421x_patch_ops; + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); + return 0; error: - kfree(codec->spec); + cs_free(codec); codec->spec = NULL; return err; } @@ -1988,6 +2006,7 @@ static int patch_cs4213(struct hda_codec *codec) if (!spec) return -ENOMEM; codec->spec = spec; + snd_hda_gen_init(&spec->gen); spec->vendor_nid = CS4213_VENDOR_NID; @@ -1999,7 +2018,7 @@ static int patch_cs4213(struct hda_codec *codec) return 0; error: - kfree(codec->spec); + cs_free(codec); codec->spec = NULL; return err; } diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 5e22a8f43d2e..03b1dc317ff0 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -553,7 +553,7 @@ static int conexant_build_controls(struct hda_codec *codec) return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static int conexant_suspend(struct hda_codec *codec) { snd_hda_shutup_pins(codec); @@ -567,7 +567,7 @@ static const struct hda_codec_ops conexant_patch_ops = { .init = conexant_init, .free = conexant_free, .set_power_state = conexant_set_power, -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM .suspend = conexant_suspend, #endif .reboot_notify = snd_hda_shutup_pins, @@ -1710,8 +1710,8 @@ static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), - HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), - HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), + HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), + HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), {} }; @@ -3402,7 +3402,7 @@ static void cx_auto_update_speakers(struct hda_codec *codec) do_automute(codec, cfg->line_outs, cfg->line_out_pins, on); } -static void cx_auto_hp_automute(struct hda_codec *codec) +static void cx_auto_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct conexant_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -3413,7 +3413,7 @@ static void cx_auto_hp_automute(struct hda_codec *codec) cx_auto_update_speakers(codec); } -static void cx_auto_line_automute(struct hda_codec *codec) +static void cx_auto_line_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct conexant_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -3540,8 +3540,9 @@ static int __select_input_connection(struct hda_codec *codec, hda_nid_t mux, hda_nid_t pin, hda_nid_t *srcp, bool do_select, int depth) { + struct conexant_spec *spec = codec->spec; hda_nid_t conn[HDA_MAX_NUM_INPUTS]; - int i, nums; + int startidx, i, nums; switch (get_wcaps_type(get_wcaps(codec, mux))) { case AC_WID_AUD_IN: @@ -3565,14 +3566,25 @@ static int __select_input_connection(struct hda_codec *codec, hda_nid_t mux, depth++; if (depth == 2) return -1; + + /* Try to rotate around connections to avoid one boost controlling + another input path as well */ + startidx = 0; + for (i = 0; i < spec->private_imux.num_items; i++) + if (spec->imux_info[i].pin == pin) { + startidx = i; + break; + } + for (i = 0; i < nums; i++) { - int ret = __select_input_connection(codec, conn[i], pin, srcp, + int j = (i + startidx) % nums; + int ret = __select_input_connection(codec, conn[j], pin, srcp, do_select, depth); if (ret >= 0) { if (do_select) snd_hda_codec_write(codec, mux, 0, - AC_VERB_SET_CONNECT_SEL, i); - return i; + AC_VERB_SET_CONNECT_SEL, j); + return j; } } return -1; @@ -3652,7 +3664,7 @@ static bool select_automic(struct hda_codec *codec, int idx, bool detect) } /* automatic switch internal and external mic */ -static void cx_auto_automic(struct hda_codec *codec) +static void cx_auto_automic(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct conexant_spec *spec = codec->spec; @@ -3663,22 +3675,6 @@ static void cx_auto_automic(struct hda_codec *codec) select_automic(codec, spec->auto_mic_int, false); } -static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) -{ - switch (snd_hda_jack_get_action(codec, res >> 26)) { - case CONEXANT_HP_EVENT: - cx_auto_hp_automute(codec); - break; - case CONEXANT_LINE_EVENT: - cx_auto_line_automute(codec); - break; - case CONEXANT_MIC_EVENT: - cx_auto_automic(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - /* check whether the pin config is suitable for auto-mic switching; * auto-mic is enabled only when one int-mic and one ext- and/or * one dock-mic exist @@ -3888,11 +3884,12 @@ static void mute_outputs(struct hda_codec *codec, int num_nids, } static void enable_unsol_pins(struct hda_codec *codec, int num_pins, - hda_nid_t *pins, unsigned int action) + hda_nid_t *pins, unsigned int action, + hda_jack_callback cb) { int i; for (i = 0; i < num_pins; i++) - snd_hda_jack_detect_enable(codec, pins[i], action); + snd_hda_jack_detect_enable_callback(codec, pins[i], action, cb); } static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) @@ -3980,13 +3977,14 @@ static void cx_auto_init_output(struct hda_codec *codec) } if (spec->auto_mute) { enable_unsol_pins(codec, cfg->hp_outs, cfg->hp_pins, - CONEXANT_HP_EVENT); + CONEXANT_HP_EVENT, cx_auto_hp_automute); spec->hp_present = detect_jacks(codec, cfg->hp_outs, cfg->hp_pins); if (spec->detect_line) { enable_unsol_pins(codec, cfg->line_outs, cfg->line_out_pins, - CONEXANT_LINE_EVENT); + CONEXANT_LINE_EVENT, + cx_auto_line_automute); spec->line_present = detect_jacks(codec, cfg->line_outs, cfg->line_out_pins); @@ -4027,16 +4025,16 @@ static void cx_auto_init_input(struct hda_codec *codec) if (spec->auto_mic) { if (spec->auto_mic_ext >= 0) { - snd_hda_jack_detect_enable(codec, + snd_hda_jack_detect_enable_callback(codec, cfg->inputs[spec->auto_mic_ext].pin, - CONEXANT_MIC_EVENT); + CONEXANT_MIC_EVENT, cx_auto_automic); } if (spec->auto_mic_dock >= 0) { - snd_hda_jack_detect_enable(codec, + snd_hda_jack_detect_enable_callback(codec, cfg->inputs[spec->auto_mic_dock].pin, - CONEXANT_MIC_EVENT); + CONEXANT_MIC_EVENT, cx_auto_automic); } - cx_auto_automic(codec); + cx_auto_automic(codec, NULL); } else { select_input_connection(codec, spec->imux_info[0].adc, spec->imux_info[0].pin); @@ -4061,7 +4059,6 @@ static int cx_auto_init(struct hda_codec *codec) cx_auto_init_output(codec); cx_auto_init_input(codec); cx_auto_init_digital(codec); - snd_hda_jack_report_sync(codec); snd_hda_sync_vmaster_hook(&spec->vmaster_mute); return 0; } @@ -4262,7 +4259,7 @@ static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { spec->imux_info[idx].boost = mux; - return cx_auto_add_volume(codec, label, " Boost", 0, + return cx_auto_add_volume(codec, label, " Boost", cidx, mux, HDA_OUTPUT); } return 0; @@ -4395,8 +4392,8 @@ static const struct hda_codec_ops cx_auto_patch_ops = { .build_pcms = conexant_build_pcms, .init = cx_auto_init, .free = conexant_free, - .unsol_event = cx_auto_unsol_event, -#ifdef CONFIG_SND_HDA_POWER_SAVE + .unsol_event = snd_hda_jack_unsol_event, +#ifdef CONFIG_PM .suspend = conexant_suspend, #endif .reboot_notify = snd_hda_shutup_pins, @@ -4462,6 +4459,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), + SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), {} }; diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 8f23374fa642..71555cc54db1 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -34,6 +34,8 @@ #include <linux/module.h> #include <sound/core.h> #include <sound/jack.h> +#include <sound/asoundef.h> +#include <sound/tlv.h> #include "hda_codec.h" #include "hda_local.h" #include "hda_jack.h" @@ -71,6 +73,9 @@ struct hdmi_spec_per_pin { struct hdmi_eld sink_eld; struct delayed_work work; int repoll_count; + bool non_pcm; + bool chmap_set; /* channel-map override by ALSA API? */ + unsigned char chmap[8]; /* ALSA API channel-map */ }; struct hdmi_spec { @@ -80,6 +85,7 @@ struct hdmi_spec { int num_pins; struct hdmi_spec_per_pin pins[MAX_HDMI_PINS]; struct hda_pcm pcm_rec[MAX_HDMI_PINS]; + unsigned int channels_max; /* max over all cvts */ /* * Non-generic ATI/NVIDIA specific @@ -469,6 +475,17 @@ static void init_channel_allocations(void) } } +static int get_channel_allocation_order(int ca) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { + if (channel_allocations[i].ca_index == ca) + break; + } + return i; +} + /* * The transformation takes two steps: * @@ -535,24 +552,36 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec, } -static void hdmi_setup_channel_mapping(struct hda_codec *codec, +static void hdmi_std_setup_channel_mapping(struct hda_codec *codec, hda_nid_t pin_nid, + bool non_pcm, int ca) { int i; int err; + int order; + int non_pcm_mapping[8]; + + order = get_channel_allocation_order(ca); if (hdmi_channel_mapping[ca][1] == 0) { - for (i = 0; i < channel_allocations[ca].channels; i++) + for (i = 0; i < channel_allocations[order].channels; i++) hdmi_channel_mapping[ca][i] = i | (i << 4); for (; i < 8; i++) hdmi_channel_mapping[ca][i] = 0xf | (i << 4); } + if (non_pcm) { + for (i = 0; i < channel_allocations[order].channels; i++) + non_pcm_mapping[i] = i | (i << 4); + for (; i < 8; i++) + non_pcm_mapping[i] = 0xf | (i << 4); + } + for (i = 0; i < 8; i++) { err = snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_CHAN_SLOT, - hdmi_channel_mapping[ca][i]); + non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]); if (err) { snd_printdd(KERN_NOTICE "HDMI: channel mapping failed\n"); @@ -563,6 +592,136 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, hdmi_debug_channel_mapping(codec, pin_nid); } +struct channel_map_table { + unsigned char map; /* ALSA API channel map position */ + unsigned char cea_slot; /* CEA slot value */ + int spk_mask; /* speaker position bit mask */ +}; + +static struct channel_map_table map_tables[] = { + { SNDRV_CHMAP_FL, 0x00, FL }, + { SNDRV_CHMAP_FR, 0x01, FR }, + { SNDRV_CHMAP_RL, 0x04, RL }, + { SNDRV_CHMAP_RR, 0x05, RR }, + { SNDRV_CHMAP_LFE, 0x02, LFE }, + { SNDRV_CHMAP_FC, 0x03, FC }, + { SNDRV_CHMAP_RLC, 0x06, RLC }, + { SNDRV_CHMAP_RRC, 0x07, RRC }, + {} /* terminator */ +}; + +/* from ALSA API channel position to speaker bit mask */ +static int to_spk_mask(unsigned char c) +{ + struct channel_map_table *t = map_tables; + for (; t->map; t++) { + if (t->map == c) + return t->spk_mask; + } + return 0; +} + +/* from ALSA API channel position to CEA slot */ +static int to_cea_slot(unsigned char c) +{ + struct channel_map_table *t = map_tables; + for (; t->map; t++) { + if (t->map == c) + return t->cea_slot; + } + return 0x0f; +} + +/* from CEA slot to ALSA API channel position */ +static int from_cea_slot(unsigned char c) +{ + struct channel_map_table *t = map_tables; + for (; t->map; t++) { + if (t->cea_slot == c) + return t->map; + } + return 0; +} + +/* from speaker bit mask to ALSA API channel position */ +static int spk_to_chmap(int spk) +{ + struct channel_map_table *t = map_tables; + for (; t->map; t++) { + if (t->spk_mask == spk) + return t->map; + } + return 0; +} + +/* get the CA index corresponding to the given ALSA API channel map */ +static int hdmi_manual_channel_allocation(int chs, unsigned char *map) +{ + int i, spks = 0, spk_mask = 0; + + for (i = 0; i < chs; i++) { + int mask = to_spk_mask(map[i]); + if (mask) { + spk_mask |= mask; + spks++; + } + } + + for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { + if ((chs == channel_allocations[i].channels || + spks == channel_allocations[i].channels) && + (spk_mask & channel_allocations[i].spk_mask) == + channel_allocations[i].spk_mask) + return channel_allocations[i].ca_index; + } + return -1; +} + +/* set up the channel slots for the given ALSA API channel map */ +static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, + hda_nid_t pin_nid, + int chs, unsigned char *map) +{ + int i; + for (i = 0; i < 8; i++) { + int val, err; + if (i < chs) + val = to_cea_slot(map[i]); + else + val = 0xf; + val |= (i << 4); + err = snd_hda_codec_write(codec, pin_nid, 0, + AC_VERB_SET_HDMI_CHAN_SLOT, val); + if (err) + return -EINVAL; + } + return 0; +} + +/* store ALSA API channel map from the current default map */ +static void hdmi_setup_fake_chmap(unsigned char *map, int ca) +{ + int i; + for (i = 0; i < 8; i++) { + if (i < channel_allocations[ca].channels) + map[i] = from_cea_slot((hdmi_channel_mapping[ca][i] >> 4) & 0x0f); + else + map[i] = 0; + } +} + +static void hdmi_setup_channel_mapping(struct hda_codec *codec, + hda_nid_t pin_nid, bool non_pcm, int ca, + int channels, unsigned char *map) +{ + if (!non_pcm && map) { + hdmi_manual_setup_channel_mapping(codec, pin_nid, + channels, map); + } else { + hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca); + hdmi_setup_fake_chmap(map, ca); + } +} /* * Audio InfoFrame routines @@ -686,7 +845,8 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, } static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx, - struct snd_pcm_substream *substream) + bool non_pcm, + struct snd_pcm_substream *substream) { struct hdmi_spec *spec = codec->spec; struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; @@ -700,7 +860,12 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx, if (!eld->monitor_present) return; - ca = hdmi_channel_allocation(eld, channels); + if (!non_pcm && per_pin->chmap_set) + ca = hdmi_manual_channel_allocation(channels, per_pin->chmap); + else + ca = hdmi_channel_allocation(eld, channels); + if (ca < 0) + ca = 0; memset(&ai, 0, sizeof(ai)); if (eld->conn_type == 0) { /* HDMI */ @@ -737,12 +902,21 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx, "pin=%d channels=%d\n", pin_nid, channels); - hdmi_setup_channel_mapping(codec, pin_nid, ca); + hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca, + channels, per_pin->chmap); hdmi_stop_infoframe_trans(codec, pin_nid); hdmi_fill_audio_infoframe(codec, pin_nid, ai.bytes, sizeof(ai)); hdmi_start_infoframe_trans(codec, pin_nid); + } else { + /* For non-pcm audio switch, setup new channel mapping + * accordingly */ + if (per_pin->non_pcm != non_pcm) + hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca, + channels, per_pin->chmap); } + + per_pin->non_pcm = non_pcm; } @@ -1035,6 +1209,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) per_pin = &spec->pins[pin_idx]; per_pin->pin_nid = pin_nid; + per_pin->non_pcm = false; err = hdmi_read_pin_conn(codec, pin_idx); if (err < 0) @@ -1064,8 +1239,11 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) per_cvt->cvt_nid = cvt_nid; per_cvt->channels_min = 2; - if (chans <= 16) + if (chans <= 16) { per_cvt->channels_max = chans; + if (chans > spec->channels_max) + spec->channels_max = chans; + } err = snd_hda_query_supported_pcm(codec, cvt_nid, &per_cvt->rates, @@ -1115,7 +1293,7 @@ static int hdmi_parse_codec(struct hda_codec *codec) * can be lost and presence sense verb will become inaccurate if the * HDA link is powered off at hot plug or hw initialization time. */ -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & AC_PWRST_EPSS)) codec->bus->power_keep_link_on = 1; @@ -1133,6 +1311,19 @@ static char *get_hdmi_pcm_name(int idx) return &names[idx][0]; } +static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) +{ + struct hda_spdif_out *spdif; + bool non_pcm; + + mutex_lock(&codec->spdif_mutex); + spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); + non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); + mutex_unlock(&codec->spdif_mutex); + return non_pcm; +} + + /* * HDMI callbacks */ @@ -1148,10 +1339,13 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, int pin_idx = hinfo_to_pin_index(spec, hinfo); hda_nid_t pin_nid = spec->pins[pin_idx].pin_nid; int pinctl; + bool non_pcm; + + non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels); - hdmi_setup_audio_infoframe(codec, pin_idx, substream); + hdmi_setup_audio_infoframe(codec, pin_idx, non_pcm, substream); pinctl = snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); @@ -1200,7 +1394,10 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl & ~PIN_OUT); snd_hda_spdif_ctls_unassign(codec, pin_idx); + per_pin->chmap_set = false; + memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); } + return 0; } @@ -1211,6 +1408,135 @@ static const struct hda_pcm_ops generic_ops = { .cleanup = generic_hdmi_playback_pcm_cleanup, }; +/* + * ALSA API channel-map control callbacks + */ +static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + struct hda_codec *codec = info->private_data; + struct hdmi_spec *spec = codec->spec; + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = spec->channels_max; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = SNDRV_CHMAP_LAST; + return 0; +} + +static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, + unsigned int size, unsigned int __user *tlv) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + struct hda_codec *codec = info->private_data; + struct hdmi_spec *spec = codec->spec; + const unsigned int valid_mask = + FL | FR | RL | RR | LFE | FC | RLC | RRC; + unsigned int __user *dst; + int chs, count = 0; + + if (size < 8) + return -ENOMEM; + if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv)) + return -EFAULT; + size -= 8; + dst = tlv + 2; + for (chs = 2; chs <= spec->channels_max; chs++) { + int i, c; + struct cea_channel_speaker_allocation *cap; + cap = channel_allocations; + for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) { + int chs_bytes = chs * 4; + if (cap->channels != chs) + continue; + if (cap->spk_mask & ~valid_mask) + continue; + if (size < 8) + return -ENOMEM; + if (put_user(SNDRV_CTL_TLVT_CHMAP_VAR, dst) || + put_user(chs_bytes, dst + 1)) + return -EFAULT; + dst += 2; + size -= 8; + count += 8; + if (size < chs_bytes) + return -ENOMEM; + size -= chs_bytes; + count += chs_bytes; + for (c = 7; c >= 0; c--) { + int spk = cap->speakers[c]; + if (!spk) + continue; + if (put_user(spk_to_chmap(spk), dst)) + return -EFAULT; + dst++; + } + } + } + if (put_user(count, tlv + 1)) + return -EFAULT; + return 0; +} + +static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + struct hda_codec *codec = info->private_data; + struct hdmi_spec *spec = codec->spec; + int pin_idx = kcontrol->private_value; + struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; + int i; + + for (i = 0; i < ARRAY_SIZE(per_pin->chmap); i++) + ucontrol->value.integer.value[i] = per_pin->chmap[i]; + return 0; +} + +static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); + struct hda_codec *codec = info->private_data; + struct hdmi_spec *spec = codec->spec; + int pin_idx = kcontrol->private_value; + struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; + unsigned int ctl_idx; + struct snd_pcm_substream *substream; + unsigned char chmap[8]; + int i, ca, prepared = 0; + + ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + substream = snd_pcm_chmap_substream(info, ctl_idx); + if (!substream || !substream->runtime) + return -EBADFD; + switch (substream->runtime->status->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + break; + case SNDRV_PCM_STATE_PREPARED: + prepared = 1; + break; + default: + return -EBUSY; + } + memset(chmap, 0, sizeof(chmap)); + for (i = 0; i < ARRAY_SIZE(chmap); i++) + chmap[i] = ucontrol->value.integer.value[i]; + if (!memcmp(chmap, per_pin->chmap, sizeof(chmap))) + return 0; + ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap); + if (ca < 0) + return -EINVAL; + per_pin->chmap_set = true; + memcpy(per_pin->chmap, chmap, sizeof(chmap)); + if (prepared) + hdmi_setup_audio_infoframe(codec, pin_idx, per_pin->non_pcm, + substream); + + return 0; +} + static int generic_hdmi_build_pcms(struct hda_codec *codec) { struct hdmi_spec *spec = codec->spec; @@ -1223,6 +1549,7 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) info = &spec->pcm_rec[pin_idx]; info->name = get_hdmi_pcm_name(pin_idx); info->pcm_type = HDA_PCM_TYPE_HDMI; + info->own_chmap = true; pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; pstr->substreams = 1; @@ -1280,6 +1607,27 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) hdmi_present_sense(per_pin, 0); } + /* add channel maps */ + for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { + struct snd_pcm_chmap *chmap; + struct snd_kcontrol *kctl; + int i; + err = snd_pcm_add_chmap_ctls(codec->pcm_info[pin_idx].pcm, + SNDRV_PCM_STREAM_PLAYBACK, + NULL, 0, pin_idx, &chmap); + if (err < 0) + return err; + /* override handlers */ + chmap->private_data = codec; + kctl = chmap->kctl; + for (i = 0; i < kctl->count; i++) + kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE; + kctl->info = hdmi_chmap_ctl_info; + kctl->get = hdmi_chmap_ctl_get; + kctl->put = hdmi_chmap_ctl_put; + kctl->tlv.c = hdmi_chmap_ctl_tlv; + } + return 0; } @@ -1311,7 +1659,6 @@ static int generic_hdmi_init(struct hda_codec *codec) hdmi_init_pin(codec, pin_nid); snd_hda_jack_detect_enable(codec, pin_nid, pin_nid); } - snd_hda_jack_report_sync(codec); return 0; } @@ -1428,7 +1775,6 @@ static int simple_playback_init(struct hda_codec *codec) snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); snd_hda_jack_detect_enable(codec, pin, pin); - snd_hda_jack_report_sync(codec); return 0; } @@ -1809,6 +2155,43 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) return 0; } +static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + int err = simple_playback_build_pcms(codec); + spec->pcm_rec[0].own_chmap = true; + return err; +} + +static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + struct snd_pcm_chmap *chmap; + int err; + + err = simple_playback_build_controls(codec); + if (err < 0) + return err; + + /* add channel maps */ + err = snd_pcm_add_chmap_ctls(spec->pcm_rec[0].pcm, + SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, 8, 0, &chmap); + if (err < 0) + return err; + switch (codec->preset->id) { + case 0x10de0002: + case 0x10de0003: + case 0x10de0005: + case 0x10de0006: + chmap->channel_mask = (1U << 2) | (1U << 8); + break; + case 0x10de0007: + chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); + } + return 0; +} + static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) { struct hdmi_spec *spec; @@ -1819,6 +2202,8 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) spec->multiout.max_channels = 8; spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; codec->patch_ops.init = nvhdmi_7x_init_8ch; + codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; + codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; /* Initialize the audio infoframe channel mask and checksum to something * valid */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 4f81dd44c837..48d9d609f89b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -174,7 +174,7 @@ struct alc_spec { /* hooks */ void (*init_hook)(struct hda_codec *codec); -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM void (*power_hook)(struct hda_codec *codec); #endif void (*shutup)(struct hda_codec *codec); @@ -215,7 +215,7 @@ struct alc_spec { /* for virtual master */ hda_nid_t vmaster_nid; struct hda_vmaster_mute_hook vmaster_mute; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM struct hda_loopback_check loopback; int num_loopbacks; struct hda_amp_list loopback_list[8]; @@ -594,7 +594,7 @@ static void call_update_outputs(struct hda_codec *codec) } /* standard HP-automute helper */ -static void alc_hp_automute(struct hda_codec *codec) +static void alc_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct alc_spec *spec = codec->spec; @@ -607,10 +607,12 @@ static void alc_hp_automute(struct hda_codec *codec) } /* standard line-out-automute helper */ -static void alc_line_automute(struct hda_codec *codec) +static void alc_line_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct alc_spec *spec = codec->spec; + if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) + return; /* check LO jack only when it's different from HP */ if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) return; @@ -627,7 +629,7 @@ static void alc_line_automute(struct hda_codec *codec) snd_hda_get_conn_index(codec, mux, nid, 0) /* standard mic auto-switch helper */ -static void alc_mic_automute(struct hda_codec *codec) +static void alc_mic_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct alc_spec *spec = codec->spec; hda_nid_t *pins = spec->imux_pins; @@ -648,25 +650,8 @@ static void alc_mic_automute(struct hda_codec *codec) alc_mux_select(codec, 0, spec->int_mic_idx, false); } -/* handle the specified unsol action (ALC_XXX_EVENT) */ -static void alc_exec_unsol_event(struct hda_codec *codec, int action) -{ - switch (action) { - case ALC_HP_EVENT: - alc_hp_automute(codec); - break; - case ALC_FRONT_EVENT: - alc_line_automute(codec); - break; - case ALC_MIC_EVENT: - alc_mic_automute(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - /* update the master volume per volume-knob's unsol event */ -static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) +static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack) { unsigned int val; struct snd_kcontrol *kctl; @@ -678,7 +663,7 @@ static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (!uctl) return; - val = snd_hda_codec_read(codec, nid, 0, + val = snd_hda_codec_read(codec, jack->nid, 0, AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); val &= HDA_AMP_VOLMASK; uctl->value.integer.value[0] = val; @@ -687,37 +672,19 @@ static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) kfree(uctl); } -/* unsolicited event for HP jack sensing */ -static void alc_unsol_event(struct hda_codec *codec, unsigned int res) +static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) { - int action; - - if (codec->vendor_id == 0x10ec0880) - res >>= 28; - else - res >>= 26; - action = snd_hda_jack_get_action(codec, res); - if (action == ALC_DCVOL_EVENT) { - /* Execute the dc-vol event here as it requires the NID - * but we don't pass NID to alc_exec_unsol_event(). - * Once when we convert all static quirks to the auto-parser, - * this can be integerated into there. - */ - struct hda_jack_tbl *jack; - jack = snd_hda_jack_tbl_get_from_tag(codec, res); - if (jack) - alc_update_knob_master(codec, jack->nid); - return; - } - alc_exec_unsol_event(codec, action); + /* For some reason, the res given from ALC880 is broken. + Here we adjust it properly. */ + snd_hda_jack_unsol_event(codec, res >> 2); } /* call init functions of standard auto-mute helpers */ static void alc_inithook(struct hda_codec *codec) { - alc_hp_automute(codec); - alc_line_automute(codec); - alc_mic_automute(codec); + alc_hp_automute(codec, NULL); + alc_line_automute(codec, NULL); + alc_mic_automute(codec, NULL); } /* additional initialization for ALC888 variants */ @@ -999,7 +966,8 @@ static void alc_init_automute(struct hda_codec *codec) continue; snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", nid); - snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, + alc_hp_automute); spec->detect_hp = 1; } @@ -1011,10 +979,10 @@ static void alc_init_automute(struct hda_codec *codec) continue; snd_printdd("realtek: Enable Line-Out " "auto-muting on NID 0x%x\n", nid); - snd_hda_jack_detect_enable(codec, nid, - ALC_FRONT_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, + alc_line_automute); spec->detect_lo = 1; - } + } spec->automute_lo_possible = spec->detect_hp; } @@ -1110,10 +1078,12 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec) return false; /* no corresponding imux */ } - snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); + snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, + ALC_MIC_EVENT, alc_mic_automute); if (spec->dock_mic_pin) - snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, - ALC_MIC_EVENT); + snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, + ALC_MIC_EVENT, + alc_mic_automute); spec->auto_mic_valid_imux = 1; spec->auto_mic = 1; @@ -2053,13 +2023,11 @@ static int alc_init(struct hda_codec *codec) alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); - snd_hda_jack_report_sync(codec); - hda_call_check_power_status(codec, 0x01); return 0; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) { struct alc_spec *spec = codec->spec; @@ -2289,6 +2257,8 @@ static int alc_build_pcms(struct hda_codec *codec) p = &alc_pcm_analog_playback; info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = + spec->multiout.max_channels; } if (spec->adc_nids) { p = spec->stream_analog_capture; @@ -2437,7 +2407,7 @@ static void alc_free(struct hda_codec *codec) snd_hda_detach_beep_device(codec); } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static void alc_power_eapd(struct hda_codec *codec) { alc_auto_setup_eapd(codec, false); @@ -2473,17 +2443,18 @@ static const struct hda_codec_ops alc_patch_ops = { .build_pcms = alc_build_pcms, .init = alc_init, .free = alc_free, - .unsol_event = alc_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .resume = alc_resume, #endif -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM .suspend = alc_suspend, .check_power_status = alc_check_power_status, #endif .reboot_notify = alc_shutup, }; + /* replace the codec chip_name with the given string */ static int alc_codec_rename(struct hda_codec *codec, const char *name) { @@ -2627,13 +2598,15 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, return "PCM"; break; } - if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) + if (ch >= ARRAY_SIZE(channel_name)) { + snd_BUG(); return "PCM"; + } return channel_name[ch]; } -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM /* add the powersave loopback-list entry */ static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) { @@ -4276,6 +4249,7 @@ static void alc_auto_init_std(struct hda_codec *codec) ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) static const struct snd_pci_quirk beep_white_list[] = { + SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), @@ -4447,7 +4421,7 @@ static void alc880_fixup_vol_knob(struct hda_codec *codec, const struct alc_fixup *fix, int action) { if (action == ALC_FIXUP_ACT_PROBE) - snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); + snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master); } static const struct alc_fixup alc880_fixups[] = { @@ -4812,6 +4786,8 @@ static int patch_alc880(struct hda_codec *codec) } codec->patch_ops = alc_patch_ops; + codec->patch_ops.unsol_event = alc880_unsol_event; + alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); @@ -4866,7 +4842,8 @@ static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, spec->detect_hp = 1; spec->automute_speaker = 1; spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ - snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); + snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, + alc_hp_automute); snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); } } @@ -6189,6 +6166,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), + SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), @@ -6334,6 +6312,12 @@ static int patch_alc269(struct hda_codec *codec) spec = codec->spec; + alc_pick_fixup(codec, alc269_fixup_models, + alc269_fixup_tbl, alc269_fixups); + alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); + + alc_auto_parse_customize_define(codec); + if (codec->vendor_id == 0x10ec0269) { spec->codec_variant = ALC269_TYPE_ALC269VA; switch (alc_get_coef0(codec) & 0x00f0) { @@ -6361,12 +6345,6 @@ static int patch_alc269(struct hda_codec *codec) alc269_fill_coef(codec); } - alc_pick_fixup(codec, alc269_fixup_models, - alc269_fixup_tbl, alc269_fixups); - alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); - - alc_auto_parse_customize_define(codec); - /* automatic parse from the BIOS config */ err = alc269_parse_auto_config(codec); if (err < 0) @@ -6503,7 +6481,7 @@ static int patch_alc861(struct hda_codec *codec) } codec->patch_ops = alc_patch_ops; -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM spec->power_hook = alc_power_eapd; #endif @@ -7068,6 +7046,8 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, + { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, + { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", .patch = patch_alc861 }, { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 3d4722f0a1ca..770013ff556f 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -103,6 +103,8 @@ enum { STAC_HP_ZEPHYR, STAC_92HD83XXX_HP_LED, STAC_92HD83XXX_HP_INV_LED, + STAC_92HD83XXX_HP_MIC_LED, + STAC_92HD83XXX_HEADSET_JACK, STAC_92HD83XXX_MODELS }; @@ -203,6 +205,7 @@ struct sigmatel_spec { unsigned int check_volume_offset:1; unsigned int auto_mic:1; unsigned int linear_tone_beep:1; + unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */ /* gpio lines */ unsigned int eapd_mask; @@ -215,6 +218,9 @@ struct sigmatel_spec { unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */ unsigned int vref_led; + unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */ + bool mic_mute_led_on; /* current mic mute state */ + /* stream */ unsigned int stream_delay; @@ -1679,6 +1685,8 @@ static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { [STAC_HP_ZEPHYR] = "hp-zephyr", [STAC_92HD83XXX_HP_LED] = "hp-led", [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led", + [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led", + [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack", }; static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { @@ -1689,6 +1697,24 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { "DFI LanParty", STAC_92HD83XXX_REF), SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, "unknown Dell", STAC_DELL_S14), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532, + "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533, + "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534, + "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535, + "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c, + "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d, + "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549, + "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d, + "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584, + "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK), SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028, "Dell Vostro 3500", STAC_DELL_VOSTRO_3500), SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656, @@ -1703,6 +1729,8 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B, "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, + "HP Folio", STAC_92HD83XXX_HP_MIC_LED), SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388, "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389, @@ -2791,18 +2819,27 @@ stac_control_new(struct sigmatel_spec *spec, return knew; } -static int stac92xx_add_control_temp(struct sigmatel_spec *spec, - const struct snd_kcontrol_new *ktemp, - int idx, const char *name, - unsigned long val) +static struct snd_kcontrol_new * +add_control_temp(struct sigmatel_spec *spec, + const struct snd_kcontrol_new *ktemp, + int idx, const char *name, + unsigned long val) { struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, HDA_SUBDEV_AMP_FLAG); if (!knew) - return -ENOMEM; + return NULL; knew->index = idx; knew->private_value = val; - return 0; + return knew; +} + +static int stac92xx_add_control_temp(struct sigmatel_spec *spec, + const struct snd_kcontrol_new *ktemp, + int idx, const char *name, + unsigned long val) +{ + return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM; } static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, @@ -2839,6 +2876,9 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, char name[22]; if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { + if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf) + != INPUT_PIN_ATTR_DOCK) + return 0; if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD && nid == spec->line_switch) control = STAC_CTL_WIDGET_IO_SWITCH; @@ -3226,9 +3266,12 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, idx = i; break; case AUTO_PIN_SPEAKER_OUT: - name = "Speaker"; - idx = i; - break; + if (num_outs <= 1) { + name = "Speaker"; + idx = i; + break; + } + /* Fall through in case of multi speaker outs */ default: name = chname[i]; idx = 0; @@ -3242,18 +3285,56 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, return 0; } +static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, + unsigned int dir_mask, unsigned int data); + +/* hook for controlling mic-mute LED GPIO */ +static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + int err; + bool mute; + + err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); + if (err <= 0) + return err; + mute = !(ucontrol->value.integer.value[0] && + ucontrol->value.integer.value[1]); + if (spec->mic_mute_led_on != mute) { + spec->mic_mute_led_on = mute; + if (mute) + spec->gpio_data |= spec->mic_mute_led_gpio; + else + spec->gpio_data &= ~spec->mic_mute_led_gpio; + stac_gpio_set(codec, spec->gpio_mask, + spec->gpio_dir, spec->gpio_data); + } + return err; +} + static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, unsigned long sw, int idx) { + struct sigmatel_spec *spec = codec->spec; + struct snd_kcontrol_new *knew; int err; + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, "Capture Volume", vol); if (err < 0) return err; - err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, - "Capture Switch", sw); - if (err < 0) - return err; + + knew = add_control_temp(spec, + &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE], + idx, "Capture Switch", sw); + if (!knew) + return -ENOMEM; + /* add a LED hook for some HP laptops */ + if (spec->mic_mute_led_gpio) + knew->put = stac92xx_capture_sw_put_led; + return 0; } @@ -4155,6 +4236,9 @@ static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, return 0; } +static void handle_unsol_event(struct hda_codec *codec, + struct hda_jack_tbl *event); + /* check if given nid is a valid pin and no other events are assigned * to it. If OK, assign the event, set the unsol flag, and returns 1. * Otherwise, returns zero. @@ -4172,6 +4256,7 @@ static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, if (event->action && event->action != type) return 0; event->action = type; + event->callback = handle_unsol_event; snd_hda_jack_detect_enable(codec, nid, 0); return 1; } @@ -4418,8 +4503,6 @@ static int stac92xx_init(struct hda_codec *codec) stac_toggle_power_map(codec, nid, 0); } - snd_hda_jack_report_sync(codec); - /* sync mute LED */ if (spec->gpio_led) { if (spec->vmaster_mute.hook) @@ -4812,20 +4895,6 @@ static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) handle_unsol_event(codec, event); } -static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) -{ - struct hda_jack_tbl *event; - int tag; - - tag = (res >> 26) & 0x7f; - event = snd_hda_jack_tbl_get_from_tag(codec, tag); - if (!event) - return; - event->jack_dirty = 1; - handle_unsol_event(codec, event); - snd_hda_jack_report_sync(codec); -} - static int hp_blike_system(u32 subsystem_id); static void set_hp_led_gpio(struct hda_codec *codec) @@ -5076,7 +5145,7 @@ static const struct hda_codec_ops stac92xx_patch_ops = { .build_pcms = stac92xx_build_pcms, .init = stac92xx_init, .free = stac92xx_free, - .unsol_event = stac92xx_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = stac92xx_suspend, .resume = stac92xx_resume, @@ -5578,6 +5647,12 @@ again: case STAC_92HD83XXX_HP_INV_LED: default_polarity = 1; break; + case STAC_92HD83XXX_HP_MIC_LED: + spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ + break; + case STAC_92HD83XXX_HEADSET_JACK: + spec->headset_jack = 1; + break; } if (find_mute_led_cfg(codec, default_polarity)) @@ -5596,6 +5671,13 @@ again: } } + if (spec->mic_mute_led_gpio) { + spec->gpio_mask |= spec->mic_mute_led_gpio; + spec->gpio_dir |= spec->mic_mute_led_gpio; + spec->mic_mute_led_on = true; + spec->gpio_data |= spec->mic_mute_led_gpio; + } + err = stac92xx_parse_auto_config(codec); if (!err) { if (spec->board_config < 0) { diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 430771776915..72a2f60b087c 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -118,6 +118,8 @@ enum { }; struct via_spec { + struct hda_gen_spec gen; + /* codec parameterization */ const struct snd_kcontrol_new *mixers[6]; unsigned int num_mixers; @@ -246,6 +248,7 @@ static struct via_spec * via_new_spec(struct hda_codec *codec) /* VT1708BCE & VT1708S are almost same */ if (spec->codec_type == VT1708BCE) spec->codec_type = VT1708S; + snd_hda_gen_init(&spec->gen); return spec; } @@ -299,7 +302,6 @@ static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) #define VIA_JACK_EVENT 0x20 #define VIA_HP_EVENT 0x01 -#define VIA_GPIO_EVENT 0x02 #define VIA_LINE_EVENT 0x03 enum { @@ -1628,6 +1630,7 @@ static void via_free(struct hda_codec *codec) vt1708_stop_hp_work(spec); kfree(spec->bind_cap_vol); kfree(spec->bind_cap_sw); + snd_hda_gen_free(&spec->gen); kfree(spec); } @@ -1672,7 +1675,8 @@ static void via_hp_automute(struct hda_codec *codec) struct via_spec *spec = codec->spec; if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0] && - (spec->codec_type != VT1708 || spec->vt1708_jack_detect)) + (spec->codec_type != VT1708 || spec->vt1708_jack_detect) && + is_jack_detectable(codec, spec->autocfg.hp_pins[0])) present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); if (spec->smart51_enabled) @@ -1684,69 +1688,6 @@ static void via_hp_automute(struct hda_codec *codec) via_line_automute(codec, present); } -static void via_gpio_control(struct hda_codec *codec) -{ - unsigned int gpio_data; - unsigned int vol_counter; - unsigned int vol; - unsigned int master_vol; - - struct via_spec *spec = codec->spec; - - gpio_data = snd_hda_codec_read(codec, codec->afg, 0, - AC_VERB_GET_GPIO_DATA, 0) & 0x03; - - vol_counter = (snd_hda_codec_read(codec, codec->afg, 0, - 0xF84, 0) & 0x3F0000) >> 16; - - vol = vol_counter & 0x1F; - master_vol = snd_hda_codec_read(codec, 0x1A, 0, - AC_VERB_GET_AMP_GAIN_MUTE, - AC_AMP_GET_INPUT); - - if (gpio_data == 0x02) { - /* unmute line out */ - snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], - PIN_OUT); - if (vol_counter & 0x20) { - /* decrease volume */ - if (vol > master_vol) - vol = master_vol; - snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, - 0, HDA_AMP_VOLMASK, - master_vol-vol); - } else { - /* increase volume */ - snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, 0, - HDA_AMP_VOLMASK, - ((master_vol+vol) > 0x2A) ? 0x2A : - (master_vol+vol)); - } - } else if (!(gpio_data & 0x02)) { - /* mute line out */ - snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], 0); - } -} - -/* unsolicited event for jack sensing */ -static void via_unsol_event(struct hda_codec *codec, - unsigned int res) -{ - res >>= 26; - res = snd_hda_jack_get_action(codec, res); - - if (res & VIA_JACK_EVENT) - set_widgets_power_state(codec); - - res &= ~VIA_JACK_EVENT; - - if (res == VIA_HP_EVENT || res == VIA_LINE_EVENT) - via_hp_automute(codec); - else if (res == VIA_GPIO_EVENT) - via_gpio_control(codec); - snd_hda_jack_report_sync(codec); -} - #ifdef CONFIG_PM static int via_suspend(struct hda_codec *codec) { @@ -1764,7 +1705,7 @@ static int via_suspend(struct hda_codec *codec) } #endif -#ifdef CONFIG_SND_HDA_POWER_SAVE +#ifdef CONFIG_PM static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) { struct via_spec *spec = codec->spec; @@ -1782,11 +1723,9 @@ static const struct hda_codec_ops via_patch_ops = { .build_pcms = via_build_pcms, .init = via_init, .free = via_free, - .unsol_event = via_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = via_suspend, -#endif -#ifdef CONFIG_SND_HDA_POWER_SAVE .check_power_status = via_check_power_status, #endif }; @@ -2762,6 +2701,17 @@ static void via_auto_init_dig_in(struct hda_codec *codec) snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); } +static void via_jack_output_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) +{ + set_widgets_power_state(codec); + via_hp_automute(codec); +} + +static void via_jack_powerstate_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) +{ + set_widgets_power_state(codec); +} + /* initialize the unsolicited events */ static void via_auto_init_unsol_event(struct hda_codec *codec) { @@ -2769,26 +2719,31 @@ static void via_auto_init_unsol_event(struct hda_codec *codec) struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int ev; int i; + hda_jack_callback cb; if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0])) - snd_hda_jack_detect_enable(codec, cfg->hp_pins[0], - VIA_HP_EVENT | VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->hp_pins[0], + VIA_HP_EVENT | VIA_JACK_EVENT, + via_jack_output_event); if (cfg->speaker_pins[0]) ev = VIA_LINE_EVENT; else ev = 0; + cb = ev ? via_jack_output_event : via_jack_powerstate_event; + for (i = 0; i < cfg->line_outs; i++) { if (cfg->line_out_pins[i] && is_jack_detectable(codec, cfg->line_out_pins[i])) - snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i], - ev | VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->line_out_pins[i], + ev | VIA_JACK_EVENT, cb); } for (i = 0; i < cfg->num_inputs; i++) { if (is_jack_detectable(codec, cfg->inputs[i].pin)) - snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin, - VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->inputs[i].pin, + VIA_JACK_EVENT, + via_jack_powerstate_event); } } @@ -2815,7 +2770,6 @@ static int via_init(struct hda_codec *codec) via_hp_automute(codec); vt1708_update_hp_work(spec); - snd_hda_jack_report_sync(codec); return 0; } @@ -3669,6 +3623,32 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec) update_power_state(codec, 0x21, AC_PWRST_D3); } +/* + * pin fix-up + */ +enum { + VIA_FIXUP_INTMIC_BOOST, +}; + +static void via_fixup_intmic_boost(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + if (action == HDA_FIXUP_ACT_PRE_PROBE) + override_mic_boost(codec, 0x30, 0, 2, 40); +} + +static const struct hda_fixup via_fixups[] = { + [VIA_FIXUP_INTMIC_BOOST] = { + .type = HDA_FIXUP_FUNC, + .v.func = via_fixup_intmic_boost, + }, +}; + +static const struct snd_pci_quirk vt2002p_fixups[] = { + SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST), + {} +}; + /* patch for vt2002P */ static int patch_vt2002P(struct hda_codec *codec) { @@ -3685,6 +3665,9 @@ static int patch_vt2002P(struct hda_codec *codec) override_mic_boost(codec, 0x29, 0, 3, 40); add_secret_dac_path(codec); + snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); + /* automatic parse from the BIOS config */ err = via_parse_auto_config(codec); if (err < 0) { diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 3e4f8c12ffce..20bcddea2eab 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -2103,7 +2103,7 @@ static int aureon_reset(struct snd_ice1712 *ice) /* * suspend/resume */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int aureon_resume(struct snd_ice1712 *ice) { struct aureon_spec *spec = ice->spec; @@ -2160,7 +2160,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice) wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP ice->pm_resume = aureon_resume; ice->pm_suspend_enabled = 1; #endif diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index 0da778a69ef8..d0e7d87f09f0 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h @@ -384,7 +384,7 @@ struct snd_ice1712 { char **ext_clock_names; int ext_clock_count; void (*pro_open)(struct snd_ice1712 *, struct snd_pcm_substream *); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int (*pm_suspend)(struct snd_ice1712 *); int (*pm_resume)(struct snd_ice1712 *); unsigned int pm_suspend_enabled:1; diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index bed9f34f4efe..3050a5279253 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2792,7 +2792,7 @@ static void __devexit snd_vt1724_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_vt1724_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -2878,7 +2878,7 @@ static SIMPLE_DEV_PM_OPS(snd_vt1724_pm, snd_vt1724_suspend, snd_vt1724_resume); #define SND_VT1724_PM_OPS &snd_vt1724_pm #else #define SND_VT1724_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static struct pci_driver vt1724_driver = { .name = KBUILD_MODNAME, diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 98bc3b7681b5..14fd536b6452 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -486,7 +486,7 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice) * suspend/resume * */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int juli_resume(struct snd_ice1712 *ice) { struct snd_akm4xxx *ak = ice->akm; @@ -652,7 +652,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice) ice->spdif.ops.open = juli_spdif_in_open; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP ice->pm_resume = juli_resume; ice->pm_suspend = juli_suspend; ice->pm_suspend_enabled = 1; diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 075d5aa1fee0..7bf093c51ce5 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c @@ -1100,7 +1100,7 @@ static void ak4396_init(struct snd_ice1712 *ice) ak4396_write(ice, ak4396_inits[i], ak4396_inits[i+1]); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int prodigy_hd2_resume(struct snd_ice1712 *ice) { /* initialize ak4396 codec and restore previous mixer volumes */ @@ -1141,7 +1141,7 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) return -ENOMEM; ice->spec = spec; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP ice->pm_resume = &prodigy_hd2_resume; ice->pm_suspend_enabled = 1; #endif diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index cd553f592e2d..ea4b706c8d63 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1541,6 +1541,26 @@ static int __devinit snd_intel8x0_pcm1(struct intel8x0 *chip, int device, snd_dma_pci_data(chip->pci), rec->prealloc_size, rec->prealloc_max_size); + if (rec->ac97_idx == ICHD_PCMOUT && rec->playback_ops) { + struct snd_pcm_chmap *chmap; + int chs = 2; + if (rec->ac97_idx == ICHD_PCMOUT) { + if (chip->multi8) + chs = 8; + else if (chip->multi6) + chs = 6; + else if (chip->multi4) + chs = 4; + } + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, chs, 0, + &chmap); + if (err < 0) + return err; + chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; + chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; + } + return 0; } @@ -2206,7 +2226,7 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock, case DEVICE_INTEL_ICH4: chip->spdif_idx = ICHD_SPBAR; break; - }; + } } chip->in_ac97_init = 1; @@ -2620,7 +2640,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -2741,7 +2761,7 @@ static SIMPLE_DEV_PM_OPS(intel8x0_pm, intel8x0_suspend, intel8x0_resume); #define INTEL8X0_PM_OPS &intel8x0_pm #else #define INTEL8X0_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #define INTEL8X0_TESTBUF_SIZE 32768 /* enough large for one shot */ diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index da44bb3f8e7a..4d551736531e 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1008,7 +1008,7 @@ static int snd_intel8x0m_free(struct intel8x0m *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -1067,7 +1067,7 @@ static SIMPLE_DEV_PM_OPS(intel8x0m_pm, intel8x0m_suspend, intel8x0m_resume); #define INTEL8X0M_PM_OPS &intel8x0m_pm #else #define INTEL8X0M_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_PROC_FS static void snd_intel8x0m_proc_read(struct snd_info_entry * entry, diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index e69ce5f9c31e..8a67ce95f246 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -196,8 +196,8 @@ enum MonitorModeSelector { #define K1212_ADAT_BUF_SIZE (K1212_ADAT_CHANNELS * 2 * kPlayBufferFrames * kNumBuffers) #define K1212_MAX_BUF_SIZE (K1212_ANALOG_BUF_SIZE + K1212_ADAT_BUF_SIZE) -#define k1212MinADCSens 0x7f -#define k1212MaxADCSens 0x00 +#define k1212MinADCSens 0x00 +#define k1212MaxADCSens 0x7f #define k1212MaxVolume 0x7fff #define k1212MaxWaveVolume 0xffff #define k1212MinVolume 0x0000 diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index c85d1ffcc955..eb3cd3a4315e 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -789,7 +789,7 @@ struct snd_m3 { unsigned int in_suspend; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u16 *suspend_mem; #endif @@ -2368,7 +2368,7 @@ static int snd_m3_free(struct snd_m3 *chip) outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP vfree(chip->suspend_mem); #endif @@ -2390,7 +2390,7 @@ static int snd_m3_free(struct snd_m3 *chip) /* * APM support */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int m3_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -2485,7 +2485,7 @@ static SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume); #define M3_PM_OPS &m3_pm #else #define M3_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ #ifdef CONFIG_SND_MAESTRO3_INPUT static int __devinit snd_m3_input_register(struct snd_m3 *chip) @@ -2656,7 +2656,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, } chip->irq = pci->irq; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); if (chip->suspend_mem == NULL) snd_printk(KERN_WARNING "can't allocate apm buffer\n"); diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c index bfbdc91e4cb3..e0f4d87555a0 100644 --- a/sound/pci/mixart/mixart_hwdep.c +++ b/sound/pci/mixart/mixart_hwdep.c @@ -538,7 +538,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw if ((err = snd_card_register(chip->card)) < 0) return err; - }; + } snd_printdd("miXart firmware downloaded and successfully set up\n"); diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 465cff25b146..e80e9a1e84aa 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1377,7 +1377,7 @@ snd_nm256_peek_for_sig(struct nm256 *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * APM event handler, so the card is properly reinitialized after a power * event. @@ -1441,7 +1441,7 @@ static SIMPLE_DEV_PM_OPS(nm256_pm, nm256_suspend, nm256_resume); #define NM256_PM_OPS &nm256_pm #else #define NM256_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int snd_nm256_free(struct nm256 *chip) { diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index 37520a2b4dcf..2becae155a48 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c @@ -872,7 +872,7 @@ static struct pci_driver oxygen_driver = { .id_table = oxygen_ids, .probe = generic_oxygen_probe, .remove = __devexit_p(oxygen_pci_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &oxygen_pci_pm, }, diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 7112a89fb8bd..09a24b24958b 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h @@ -161,7 +161,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ) ); void oxygen_pci_remove(struct pci_dev *pci); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP extern const struct dev_pm_ops oxygen_pci_pm; #endif void oxygen_pci_shutdown(struct pci_dev *pci); diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index ab8738e21ad1..9562dc63ba60 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -573,8 +573,8 @@ static void oxygen_card_free(struct snd_card *card) oxygen_shutdown(chip); if (chip->irq >= 0) free_irq(chip->irq, chip); - flush_work_sync(&chip->spdif_input_bits_work); - flush_work_sync(&chip->gpio_work); + flush_work(&chip->spdif_input_bits_work); + flush_work(&chip->gpio_work); chip->model.cleanup(chip); kfree(chip->model_data); mutex_destroy(&chip->mutex); @@ -726,7 +726,7 @@ void oxygen_pci_remove(struct pci_dev *pci) } EXPORT_SYMBOL(oxygen_pci_remove); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int oxygen_pci_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -751,8 +751,8 @@ static int oxygen_pci_suspend(struct device *dev) spin_unlock_irq(&chip->reg_lock); synchronize_irq(chip->irq); - flush_work_sync(&chip->spdif_input_bits_work); - flush_work_sync(&chip->gpio_work); + flush_work(&chip->spdif_input_bits_work); + flush_work(&chip->gpio_work); chip->interrupt_mask = saved_interrupt_mask; pci_disable_device(pci); @@ -824,7 +824,7 @@ static int oxygen_pci_resume(struct device *dev) SIMPLE_DEV_PM_OPS(oxygen_pci_pm, oxygen_pci_suspend, oxygen_pci_resume); EXPORT_SYMBOL(oxygen_pci_pm); -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ void oxygen_pci_shutdown(struct pci_dev *pci) { diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index d3b606b69f3b..3d71423b23bc 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c @@ -93,7 +93,7 @@ static struct pci_driver xonar_driver = { .id_table = xonar_ids, .probe = xonar_probe, .remove = __devexit_p(oxygen_pci_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &oxygen_pci_pm, }, diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index e3ac1f768ff6..be4f1456009a 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -91,6 +91,14 @@ enum { PCI_ID_PCX924E, PCI_ID_PCX924HRMIC, PCI_ID_PCX924E_MIC, + PCI_ID_VX442HR, + PCI_ID_PCX442HR, + PCI_ID_VX442E, + PCI_ID_PCX442E, + PCI_ID_VX822HR, + PCI_ID_PCX822HR, + PCI_ID_VX822E, + PCI_ID_PCX822E, PCI_ID_LAST }; @@ -121,6 +129,14 @@ static DEFINE_PCI_DEVICE_TABLE(pcxhr_ids) = { { 0x10b5, 0x9056, 0x1369, 0xbb21, 0, 0, PCI_ID_PCX924E, }, { 0x10b5, 0x9056, 0x1369, 0xbf01, 0, 0, PCI_ID_PCX924HRMIC, }, { 0x10b5, 0x9056, 0x1369, 0xbf21, 0, 0, PCI_ID_PCX924E_MIC, }, + { 0x10b5, 0x9656, 0x1369, 0xd001, 0, 0, PCI_ID_VX442HR, }, + { 0x10b5, 0x9656, 0x1369, 0xd101, 0, 0, PCI_ID_PCX442HR, }, + { 0x10b5, 0x9056, 0x1369, 0xd021, 0, 0, PCI_ID_VX442E, }, + { 0x10b5, 0x9056, 0x1369, 0xd121, 0, 0, PCI_ID_PCX442E, }, + { 0x10b5, 0x9656, 0x1369, 0xd201, 0, 0, PCI_ID_VX822HR, }, + { 0x10b5, 0x9656, 0x1369, 0xd301, 0, 0, PCI_ID_PCX822HR, }, + { 0x10b5, 0x9056, 0x1369, 0xd221, 0, 0, PCI_ID_VX822E, }, + { 0x10b5, 0x9056, 0x1369, 0xd321, 0, 0, PCI_ID_PCX822E, }, { 0, } }; @@ -160,6 +176,14 @@ static struct board_parameters pcxhr_board_params[] = { [PCI_ID_PCX924E] = { "PCX924e", 1, 1, 5, 44 }, [PCI_ID_PCX924HRMIC] = { "PCX924HR-Mic", 1, 1, 5, 44 }, [PCI_ID_PCX924E_MIC] = { "PCX924e-Mic", 1, 1, 5, 44 }, +[PCI_ID_VX442HR] = { "VX442HR", 2, 2, 0, 41 }, +[PCI_ID_PCX442HR] = { "PCX442HR", 2, 2, 0, 41 }, +[PCI_ID_VX442E] = { "VX442e", 2, 2, 1, 41 }, +[PCI_ID_PCX442E] = { "PCX442e", 2, 2, 1, 41 }, +[PCI_ID_VX822HR] = { "VX822HR", 4, 1, 2, 42 }, +[PCI_ID_PCX822HR] = { "PCX822HR", 4, 1, 2, 42 }, +[PCI_ID_VX822E] = { "VX822e", 4, 1, 3, 42 }, +[PCI_ID_PCX822E] = { "PCX822e", 4, 1, 3, 42 }, }; /* boards without hw AES1 and SRC onboard are all using fw_file_set==4 */ diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index ec1587cddb0c..bf207e317f71 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -66,10 +66,10 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) err = pcxhr_send_msg(mgr, &rmh); if (err) return err; - /* test 8 or 12 phys out */ - if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) + /* test 4, 8 or 12 phys out */ + if ((rmh.stat[0] & MASK_FIRST_FIELD) < mgr->playback_chips * 2) return -EINVAL; - /* test 8 or 2 phys in */ + /* test 4, 8 or 2 phys in */ if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) < mgr->capture_chips * 2) return -EINVAL; diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 760ee467cd9a..7d291542c5ba 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -464,7 +464,7 @@ struct snd_riptide { unsigned long received_irqs; unsigned long handled_irqs; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP int in_suspend; #endif }; @@ -1150,7 +1150,7 @@ static void riptide_handleirq(unsigned long dev_id) } } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int riptide_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -1193,7 +1193,7 @@ static SIMPLE_DEV_PM_OPS(riptide_pm, riptide_suspend, riptide_resume); #define RIPTIDE_PM_OPS &riptide_pm #else #define RIPTIDE_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int try_to_load_firmware(struct cmdif *cif, struct snd_riptide *chip) { diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 805ab6e9a78f..51e43407ebc5 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -103,7 +103,7 @@ struct voice { * we're not doing power management, we still need to allocate a page * for the silence buffer. */ -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP #define SIS_SUSPEND_PAGES 4 #else #define SIS_SUSPEND_PAGES 1 @@ -1208,7 +1208,7 @@ static int sis_chip_init(struct sis7019 *sis) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int sis_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -1305,7 +1305,7 @@ static SIMPLE_DEV_PM_OPS(sis_pm, sis_suspend, sis_resume); #define SIS_PM_OPS &sis_pm #else #define SIS_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int sis_alloc_suspend(struct sis7019 *sis) { diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index d36e6ca147e1..8a6f1f76e870 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -177,7 +177,7 @@ static struct pci_driver trident_driver = { .id_table = snd_trident_ids, .probe = snd_trident_probe, .remove = __devexit_p(snd_trident_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &snd_trident_pm, }, diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 94011dcae731..06b10d1a76e5 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3919,7 +3919,7 @@ static void snd_trident_clear_voices(struct snd_trident * trident, unsigned shor } } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_trident_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); @@ -3983,4 +3983,4 @@ static int snd_trident_resume(struct device *dev) } SIMPLE_DEV_PM_OPS(snd_trident_pm, snd_trident_suspend, snd_trident_resume); -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 0eb7245dd362..f0b4efdb483c 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -362,7 +362,7 @@ struct via82xx { unsigned char old_legacy; unsigned char old_legacy_cfg; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP unsigned char legacy_saved; unsigned char legacy_cfg_saved; unsigned char spdif_ctrl_saved; @@ -1440,6 +1440,7 @@ static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset, static int __devinit snd_via8233_pcm_new(struct via82xx *chip) { struct snd_pcm *pcm; + struct snd_pcm_chmap *chmap; int i, err; chip->playback_devno = 0; /* x 4 */ @@ -1467,6 +1468,12 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip) snd_dma_pci_data(chip->pci), 64*1024, VIA_MAX_BUFSIZE); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_std_chmaps, 2, 0, + &chmap); + if (err < 0) + return err; + /* PCM #1: multi-channel playback and 2nd capture */ err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm); if (err < 0) @@ -1484,6 +1491,14 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), 64*1024, VIA_MAX_BUFSIZE); + + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, 6, 0, + &chmap); + if (err < 0) + return err; + chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; + return 0; } @@ -1493,6 +1508,7 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip) static int __devinit snd_via8233a_pcm_new(struct via82xx *chip) { struct snd_pcm *pcm; + struct snd_pcm_chmap *chmap; int err; chip->multi_devno = 0; @@ -1519,6 +1535,13 @@ static int __devinit snd_via8233a_pcm_new(struct via82xx *chip) snd_dma_pci_data(chip->pci), 64*1024, VIA_MAX_BUFSIZE); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_alt_chmaps, 6, 0, + &chmap); + if (err < 0) + return err; + chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; + /* SPDIF supported? */ if (! ac97_can_spdif(chip->ac97)) return 0; @@ -2038,7 +2061,7 @@ static int __devinit snd_via686_init_misc(struct via82xx *chip) if (mpu_port >= 0x200) { /* force MIDI */ mpu_port &= 0xfffc; pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->mpu_port_saved = mpu_port; #endif } else { @@ -2090,7 +2113,7 @@ static int __devinit snd_via686_init_misc(struct via82xx *chip) snd_via686_create_gameport(chip, &legacy); -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->legacy_saved = legacy; chip->legacy_cfg_saved = legacy_cfg; #endif @@ -2238,7 +2261,7 @@ static int snd_via82xx_chip_init(struct via82xx *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -2313,7 +2336,7 @@ static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume #define SND_VIA82XX_PM_OPS &snd_via82xx_pm #else #define SND_VIA82XX_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int snd_via82xx_free(struct via82xx *chip) { diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index e886bc16999d..8e0efc416f22 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1019,7 +1019,7 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP /* * power management */ @@ -1076,7 +1076,7 @@ static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume #define SND_VIA82XX_PM_OPS &snd_via82xx_pm #else #define SND_VIA82XX_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static int snd_via82xx_free(struct via82xx_modem *chip) { diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index b89e7a86e9d8..fdfbaf857233 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -257,7 +257,7 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int snd_vx222_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 4810356b97ba..e01fe34db9ec 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -355,7 +355,7 @@ static struct pci_driver ymfpci_driver = { .id_table = snd_ymfpci_ids, .probe = snd_card_ymfpci_probe, .remove = __devexit_p(snd_card_ymfpci_remove), -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .driver = { .pm = &snd_ymfpci_pm, }, diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h index bddc4052286b..4631a2348915 100644 --- a/sound/pci/ymfpci/ymfpci.h +++ b/sound/pci/ymfpci/ymfpci.h @@ -363,7 +363,7 @@ struct snd_ymfpci { const struct firmware *dsp_microcode; const struct firmware *controller_microcode; -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP u32 *saved_regs; u32 saved_ydsxgr_mode; u16 saved_dsxg_legacy; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 62b23635b754..3a6f03f9b02f 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1166,6 +1166,11 @@ int __devinit snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + snd_pcm_std_chmaps, 2, 0, NULL); + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; return 0; @@ -1257,6 +1262,14 @@ static struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { .pointer = snd_ymfpci_playback_pointer, }; +static const struct snd_pcm_chmap_elem surround_map[] = { + { .channels = 1, + .map = { SNDRV_CHMAP_MONO } }, + { .channels = 2, + .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, + { } +}; + int __devinit snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) { struct snd_pcm *pcm; @@ -1278,6 +1291,11 @@ int __devinit snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); + err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + surround_map, 2, 0, NULL); + if (err < 0) + return err; + if (rpcm) *rpcm = pcm; return 0; @@ -2242,7 +2260,7 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip) pci_set_power_state(chip->pci, 3); #endif -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP vfree(chip->saved_regs); #endif if (chip->irq >= 0) @@ -2272,7 +2290,7 @@ static int snd_ymfpci_dev_free(struct snd_device *device) return snd_ymfpci_free(chip); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int saved_regs_index[] = { /* spdif */ YDSXGR_SPDIFOUTCTRL, @@ -2374,7 +2392,7 @@ static int snd_ymfpci_resume(struct device *dev) } SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume); -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ int __devinit snd_ymfpci_create(struct snd_card *card, struct pci_dev * pci, @@ -2452,7 +2470,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card, return err; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP chip->saved_regs = vmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32)); if (chip->saved_regs == NULL) { snd_ymfpci_free(chip); diff --git a/sound/soc/cirrus/ep93xx-ac97.c b/sound/soc/cirrus/ep93xx-ac97.c index bdffab33e160..c3521653cfd3 100644 --- a/sound/soc/cirrus/ep93xx-ac97.c +++ b/sound/soc/cirrus/ep93xx-ac97.c @@ -21,7 +21,7 @@ #include <sound/ac97_codec.h> #include <sound/soc.h> -#include <mach/dma.h> +#include <linux/platform_data/dma-ep93xx.h> #include "ep93xx-pcm.h" /* diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c index 8df8f6dc474f..ac4a7515e7be 100644 --- a/sound/soc/cirrus/ep93xx-i2s.c +++ b/sound/soc/cirrus/ep93xx-i2s.c @@ -28,7 +28,7 @@ #include <mach/hardware.h> #include <mach/ep93xx-regs.h> -#include <mach/dma.h> +#include <linux/platform_data/dma-ep93xx.h> #include "ep93xx-pcm.h" diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c index 4eea98b42bc8..665d9c94cc17 100644 --- a/sound/soc/cirrus/ep93xx-pcm.c +++ b/sound/soc/cirrus/ep93xx-pcm.c @@ -25,7 +25,7 @@ #include <sound/soc.h> #include <sound/dmaengine_pcm.h> -#include <mach/dma.h> +#include <linux/platform_data/dma-ep93xx.h> #include <mach/hardware.h> #include <mach/ep93xx-regs.h> diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index b723e910fcdc..683dc43b1d87 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -726,7 +726,7 @@ static bool wm2000_readable_reg(struct device *dev, unsigned int reg) } static const struct regmap_config wm2000_regmap = { - .reg_bits = 8, + .reg_bits = 16, .val_bits = 8, .max_register = WM2000_REG_IF_CTL, diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 4da1b92b22c2..7f567585832e 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -1233,7 +1233,7 @@ static const struct snd_soc_dapm_route wm5100_dapm_routes[] = { { "PWM2", NULL, "PWM2 Driver" }, }; -static const __devinitdata struct reg_default wm5100_reva_patches[] = { +static const __devinitconst struct reg_default wm5100_reva_patches[] = { { WM5100_AUDIO_IF_1_10, 0 }, { WM5100_AUDIO_IF_1_11, 1 }, { WM5100_AUDIO_IF_1_12, 2 }, diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index d26c8ae4e6d9..a4cae060bf26 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1601,7 +1601,7 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) /* if there was any work waiting then we run it now and * wait for its completion */ - flush_delayed_work_sync(&codec->dapm.delayed_work); + flush_delayed_work(&codec->dapm.delayed_work); wm8350_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 13bff87ddcf5..2e4a775ae560 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1509,7 +1509,7 @@ static int wm8753_probe(struct snd_soc_codec *codec) /* power down chip */ static int wm8753_remove(struct snd_soc_codec *codec) { - flush_delayed_work_sync(&codec->dapm.delayed_work); + flush_delayed_work(&codec->dapm.delayed_work); wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 9a15bc4bd570..d85929b79c35 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -30,7 +30,7 @@ #include <sound/soc.h> #include <sound/dmaengine_pcm.h> -#include <mach/dma.h> +#include <linux/platform_data/dma-imx.h> #include "imx-pcm.h" diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index ee27ba3933bd..22c6130957ba 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -30,7 +30,7 @@ #include <asm/fiq.h> #include <mach/irqs.h> -#include <mach/ssi.h> +#include <linux/platform_data/asoc-imx-ssi.h> #include "imx-ssi.h" diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 3c520c46fa4a..006f7d465ed2 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -47,7 +47,7 @@ #include <sound/pcm_params.h> #include <sound/soc.h> -#include <mach/ssi.h> +#include <linux/platform_data/asoc-imx-ssi.h> #include <mach/hardware.h> #include "imx-ssi.h" diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index 5744e86ca878..dc114bdedce5 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h @@ -186,7 +186,7 @@ #define DRV_NAME "imx-ssi" #include <linux/dmaengine.h> -#include <mach/dma.h> +#include <linux/platform_data/dma-imx.h> #include "imx-pcm.h" struct imx_ssi { diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 7646dd7f30cb..542538d10ab7 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -21,7 +21,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-kirkwood.h> #include "kirkwood.h" #define DRV_NAME "kirkwood-i2s" diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c index 80bd59c33be4..c28540aeea25 100644 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ b/sound/soc/kirkwood/kirkwood-openrd.c @@ -17,7 +17,7 @@ #include <linux/slab.h> #include <sound/soc.h> #include <mach/kirkwood.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-kirkwood.h> #include <asm/mach-types.h> #include "../codecs/cs42l51.h" diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index f8983635f7ef..c67bbc574987 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c @@ -16,7 +16,7 @@ #include <linux/slab.h> #include <sound/soc.h> #include <mach/kirkwood.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-kirkwood.h> #include <asm/mach-types.h> #include "../codecs/alc5623.h" diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c index 77a87012977c..fad350682ca2 100644 --- a/sound/soc/omap/am3517evm.c +++ b/sound/soc/omap/am3517evm.c @@ -27,7 +27,7 @@ #include <asm/mach-types.h> #include <mach/hardware.h> #include <mach/gpio.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 7b18b748c177..d8e96b2cd03e 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -32,8 +32,8 @@ #include <asm/mach-types.h> -#include <plat/board-ams-delta.h> -#include <plat/mcbsp.h> +#include <mach/board-ams-delta.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index bc06175e6367..afb8d4f1bedf 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -26,7 +26,9 @@ #include <linux/slab.h> #include <linux/pm_runtime.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> + +#include <plat/cpu.h> #include "mcbsp.h" diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index abac4b690750..521bfc3d2b2b 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -32,7 +32,7 @@ #include <mach/hardware.h> #include <linux/gpio.h> #include <linux/module.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 750d595d01d7..a57a4e68dcc6 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -32,10 +32,6 @@ #include <sound/soc.h> #include <sound/jack.h> -#include <asm/mach-types.h> -#include <plat/hardware.h> -#include <plat/mux.h> - #include "omap-dmic.h" #include "omap-mcpdm.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index fef2f5933bb2..a6ee15747859 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -34,7 +34,8 @@ #include <sound/initval.h> #include <sound/soc.h> -#include <plat/mcbsp.h> +#include <plat/cpu.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "mcbsp.h" #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index e134b271a70a..56965bb3275c 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -43,6 +43,8 @@ #include "omap-mcpdm.h" #include "omap-pcm.h" +#define OMAP44XX_MCPDM_L3_BASE 0x49032000 + struct omap_mcpdm { struct device *dev; unsigned long phys_base; diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index a2636f6b8362..340874ebf9ae 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -32,6 +32,7 @@ #include <sound/dmaengine_pcm.h> #include <sound/soc.h> +#include <plat/cpu.h> #include "omap-pcm.h" static const struct snd_pcm_hardware omap_pcm_hardware = { diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 4c3a0978578a..43d950a79ff9 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -31,7 +31,7 @@ #include <sound/soc.h> #include <asm/mach-types.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index b1a9d64cbc56..3960e8df9c76 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c @@ -31,7 +31,7 @@ #include <mach/hardware.h> #include <linux/gpio.h> #include <linux/module.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "omap-mcbsp.h" #include "omap-pcm.h" diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 2712dd232b6d..d921ddbe3ecb 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -31,7 +31,7 @@ #include <sound/jack.h> #include <sound/pcm.h> #include <sound/soc.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> #include "../codecs/tpa6130a2.h" #include <asm/mach-types.h> diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 0e283226e2bf..597cae769cea 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -33,7 +33,8 @@ #include <asm/mach-types.h> #include <mach/hardware.h> #include <mach/gpio.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/gpio-omap.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> /* Register descriptions for twl4030 codec part */ #include <linux/mfd/twl4030-audio.h> diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c index df97a4196cd3..677b567935f8 100644 --- a/sound/soc/omap/zoom2.c +++ b/sound/soc/omap/zoom2.c @@ -29,7 +29,7 @@ #include <mach/hardware.h> #include <mach/gpio.h> #include <mach/board-zoom.h> -#include <plat/mcbsp.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> /* Register descriptions for twl4030 codec part */ #include <linux/mfd/twl4030-audio.h> diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index db24bc685bd3..aa3da91907c6 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -25,7 +25,7 @@ #include <asm/mach-types.h> #include <mach/audio.h> -#include <mach/palmasoc.h> +#include <linux/platform_data/asoc-palm27x.h> #include "../codecs/wm9712.h" #include "pxa2xx-ac97.h" diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c index 3d04c1fa6781..14fbcd30cae5 100644 --- a/sound/soc/samsung/ac97.c +++ b/sound/soc/samsung/ac97.c @@ -21,7 +21,7 @@ #include <mach/dma.h> #include <plat/regs-ac97.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-s3c.h> #include "dma.h" diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 6ac7b8281a02..40b00a13dcd1 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -20,7 +20,7 @@ #include <sound/soc.h> #include <sound/pcm_params.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-s3c.h> #include "dma.h" #include "idma.h" diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index 89b064650f14..c86081992dfd 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c @@ -19,7 +19,7 @@ #include <sound/soc.h> #include <sound/pcm_params.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-s3c.h> #include <mach/dma.h> #include "dma.h" diff --git a/sound/soc/samsung/s3c24xx_simtec.c b/sound/soc/samsung/s3c24xx_simtec.c index 656d5afe4ca9..335a7d8a4a8d 100644 --- a/sound/soc/samsung/s3c24xx_simtec.c +++ b/sound/soc/samsung/s3c24xx_simtec.c @@ -13,7 +13,7 @@ #include <sound/soc.h> -#include <plat/audio-simtec.h> +#include <linux/platform_data/asoc-s3c24xx_simtec.h> #include "s3c24xx-i2s.h" #include "s3c24xx_simtec.h" diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c index a5a56a120345..bc24c7af02b2 100644 --- a/sound/soc/samsung/spdif.c +++ b/sound/soc/samsung/spdif.c @@ -17,7 +17,7 @@ #include <sound/soc.h> #include <sound/pcm_params.h> -#include <plat/audio.h> +#include <linux/platform_data/asoc-s3c.h> #include <mach/dma.h> #include "dma.h" diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9a6daf997319..d1198627fc40 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -591,7 +591,7 @@ int snd_soc_suspend(struct device *dev) /* close any waiting streams and save state */ for (i = 0; i < card->num_rtd; i++) { - flush_delayed_work_sync(&card->rtd[i].delayed_work); + flush_delayed_work(&card->rtd[i].delayed_work); card->rtd[i].codec->dapm.suspend_bias_level = card->rtd[i].codec->dapm.bias_level; } @@ -1862,7 +1862,7 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card) /* make sure any delayed work runs */ for (i = 0; i < card->num_rtd; i++) { struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; - flush_delayed_work_sync(&rtd->delayed_work); + flush_delayed_work(&rtd->delayed_work); } /* remove auxiliary devices */ @@ -1906,7 +1906,7 @@ int snd_soc_poweroff(struct device *dev) * now, we're shutting down so no imminent restart. */ for (i = 0; i < card->num_rtd; i++) { struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; - flush_delayed_work_sync(&rtd->delayed_work); + flush_delayed_work(&rtd->delayed_work); } snd_soc_dapm_shutdown(card); diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index 5df529eda251..bbc125748a38 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -140,14 +140,18 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream) struct dma_chan *chan = prtd->dma_chan; struct dma_async_tx_descriptor *desc; enum dma_transfer_direction direction; + unsigned long flags = DMA_CTRL_ACK; direction = snd_pcm_substream_to_dma_direction(substream); + if (!substream->runtime->no_period_wakeup) + flags |= DMA_PREP_INTERRUPT; + prtd->pos = 0; desc = dmaengine_prep_dma_cyclic(chan, substream->runtime->dma_addr, snd_pcm_lib_buffer_bytes(substream), - snd_pcm_lib_period_bytes(substream), direction); + snd_pcm_lib_period_bytes(substream), direction, flags); if (!desc) return -ENOMEM; diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 02bcd308c189..19e5fe7cc403 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -1,6 +1,6 @@ config SND_SOC_TEGRA tristate "SoC Audio for the Tegra System-on-Chip" - depends on ARCH_TEGRA && (TEGRA_SYSTEM_DMA || TEGRA20_APB_DMA) + depends on ARCH_TEGRA && TEGRA20_APB_DMA select REGMAP_MMIO select SND_SOC_DMAENGINE_PCM if TEGRA20_APB_DMA help diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index 8d6900c1ee47..e18733963cb4 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -57,237 +57,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = { .fifo_size = 4, }; -#if defined(CONFIG_TEGRA_SYSTEM_DMA) -static void tegra_pcm_queue_dma(struct tegra_runtime_data *prtd) -{ - struct snd_pcm_substream *substream = prtd->substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - struct tegra_dma_req *dma_req; - unsigned long addr; - - dma_req = &prtd->dma_req[prtd->dma_req_idx]; - prtd->dma_req_idx = 1 - prtd->dma_req_idx; - - addr = buf->addr + prtd->dma_pos; - prtd->dma_pos += dma_req->size; - if (prtd->dma_pos >= prtd->dma_pos_end) - prtd->dma_pos = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dma_req->source_addr = addr; - else - dma_req->dest_addr = addr; - - tegra_dma_enqueue_req(prtd->dma_chan, dma_req); -} - -static void dma_complete_callback(struct tegra_dma_req *req) -{ - struct tegra_runtime_data *prtd = (struct tegra_runtime_data *)req->dev; - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - - spin_lock(&prtd->lock); - - if (!prtd->running) { - spin_unlock(&prtd->lock); - return; - } - - if (++prtd->period_index >= runtime->periods) - prtd->period_index = 0; - - tegra_pcm_queue_dma(prtd); - - spin_unlock(&prtd->lock); - - snd_pcm_period_elapsed(substream); -} - -static void setup_dma_tx_request(struct tegra_dma_req *req, - struct tegra_pcm_dma_params * dmap) -{ - req->complete = dma_complete_callback; - req->to_memory = false; - req->dest_addr = dmap->addr; - req->dest_wrap = dmap->wrap; - req->source_bus_width = 32; - req->source_wrap = 0; - req->dest_bus_width = dmap->width; - req->req_sel = dmap->req_sel; -} - -static void setup_dma_rx_request(struct tegra_dma_req *req, - struct tegra_pcm_dma_params * dmap) -{ - req->complete = dma_complete_callback; - req->to_memory = true; - req->source_addr = dmap->addr; - req->dest_wrap = 0; - req->source_bus_width = dmap->width; - req->source_wrap = dmap->wrap; - req->dest_bus_width = 32; - req->req_sel = dmap->req_sel; -} - -static int tegra_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct tegra_runtime_data *prtd; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct tegra_pcm_dma_params * dmap; - int ret = 0; - - prtd = kzalloc(sizeof(struct tegra_runtime_data), GFP_KERNEL); - if (prtd == NULL) - return -ENOMEM; - - runtime->private_data = prtd; - prtd->substream = substream; - - spin_lock_init(&prtd->lock); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - setup_dma_tx_request(&prtd->dma_req[0], dmap); - setup_dma_tx_request(&prtd->dma_req[1], dmap); - } else { - dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - setup_dma_rx_request(&prtd->dma_req[0], dmap); - setup_dma_rx_request(&prtd->dma_req[1], dmap); - } - - prtd->dma_req[0].dev = prtd; - prtd->dma_req[1].dev = prtd; - - prtd->dma_chan = tegra_dma_allocate_channel(TEGRA_DMA_MODE_ONESHOT); - if (prtd->dma_chan == NULL) { - ret = -ENOMEM; - goto err; - } - - /* Set HW params now that initialization is complete */ - snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware); - - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - goto err; - - return 0; - -err: - if (prtd->dma_chan) { - tegra_dma_free_channel(prtd->dma_chan); - } - - kfree(prtd); - - return ret; -} - -static int tegra_pcm_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct tegra_runtime_data *prtd = runtime->private_data; - - tegra_dma_free_channel(prtd->dma_chan); - - kfree(prtd); - - return 0; -} - -static int tegra_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct tegra_runtime_data *prtd = runtime->private_data; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - prtd->dma_req[0].size = params_period_bytes(params); - prtd->dma_req[1].size = prtd->dma_req[0].size; - - return 0; -} - -static int tegra_pcm_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_set_runtime_buffer(substream, NULL); - - return 0; -} - -static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct tegra_runtime_data *prtd = runtime->private_data; - unsigned long flags; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - prtd->dma_pos = 0; - prtd->dma_pos_end = frames_to_bytes(runtime, runtime->periods * runtime->period_size); - prtd->period_index = 0; - prtd->dma_req_idx = 0; - /* Fall-through */ - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - spin_lock_irqsave(&prtd->lock, flags); - prtd->running = 1; - spin_unlock_irqrestore(&prtd->lock, flags); - tegra_pcm_queue_dma(prtd); - tegra_pcm_queue_dma(prtd); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - spin_lock_irqsave(&prtd->lock, flags); - prtd->running = 0; - spin_unlock_irqrestore(&prtd->lock, flags); - tegra_dma_dequeue_req(prtd->dma_chan, &prtd->dma_req[0]); - tegra_dma_dequeue_req(prtd->dma_chan, &prtd->dma_req[1]); - break; - default: - return -EINVAL; - } - - return 0; -} - -static snd_pcm_uframes_t tegra_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct tegra_runtime_data *prtd = runtime->private_data; - - return prtd->period_index * runtime->period_size; -} - - -static int tegra_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - return dma_mmap_writecombine(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); -} - -static struct snd_pcm_ops tegra_pcm_ops = { - .open = tegra_pcm_open, - .close = tegra_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = tegra_pcm_hw_params, - .hw_free = tegra_pcm_hw_free, - .trigger = tegra_pcm_trigger, - .pointer = tegra_pcm_pointer, - .mmap = tegra_pcm_mmap, -}; -#else static int tegra_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -399,7 +168,6 @@ static struct snd_pcm_ops tegra_pcm_ops = { .pointer = snd_dmaengine_pcm_pointer, .mmap = tegra_pcm_mmap, }; -#endif static int tegra_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) { diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h index a3a450352dcf..b40279b9f413 100644 --- a/sound/soc/tegra/tegra_pcm.h +++ b/sound/soc/tegra/tegra_pcm.h @@ -40,20 +40,6 @@ struct tegra_pcm_dma_params { unsigned long req_sel; }; -#if defined(CONFIG_TEGRA_SYSTEM_DMA) -struct tegra_runtime_data { - struct snd_pcm_substream *substream; - spinlock_t lock; - int running; - int dma_pos; - int dma_pos_end; - int period_index; - int dma_req_idx; - struct tegra_dma_req dma_req[2]; - struct tegra_dma_channel *dma_chan; -}; -#endif - int tegra_pcm_platform_register(struct device *dev); void tegra_pcm_platform_unregister(struct device *dev); diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index b63b3a86d3f4..5701787c0e6b 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -813,7 +813,7 @@ static int snd_amd7930_get_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem default: swval = &amd->pgain; break; - }; + } ucontrol->value.integer.value[0] = *swval; @@ -838,7 +838,7 @@ static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem default: swval = &amd->pgain; break; - }; + } spin_lock_irqsave(&amd->lock, flags); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index a6b0deb77746..ae35f5342e10 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -592,7 +592,7 @@ static __u32 reverse_bytes(__u32 b, int len) break; default: printk(KERN_ERR "DBRI reverse_bytes: unsupported length\n"); - }; + } return b; } diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c index 56ad923bf6b5..a1d9b0792a1e 100644 --- a/sound/usb/6fire/firmware.c +++ b/sound/usb/6fire/firmware.c @@ -346,11 +346,10 @@ static int usb6fire_fw_check(u8 *version) if (!memcmp(version, known_fw_versions + i, 4)) return 0; - snd_printk(KERN_ERR PREFIX "invalid fimware version in device: " - "%02x %02x %02x %02x. " + snd_printk(KERN_ERR PREFIX "invalid fimware version in device: %*ph. " "please reconnect to power. if this failure " "still happens, check your firmware installation.", - version[0], version[1], version[2], version[3]); + 4, version); return -EINVAL; } diff --git a/sound/usb/card.c b/sound/usb/card.c index 4a469f0cb6d4..561bb74fd364 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -646,6 +646,8 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) list_for_each(p, &chip->pcm_list) { as = list_entry(p, struct snd_usb_stream, list); snd_pcm_suspend_all(as->pcm); + as->substream[0].need_setup_ep = + as->substream[1].need_setup_ep = true; } } } else { diff --git a/sound/usb/card.h b/sound/usb/card.h index 2b9fffff23b6..afa4f9e9b27a 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -92,6 +92,8 @@ struct snd_usb_endpoint { unsigned char silence_value; unsigned int stride; int iface, alt_idx; + int skip_packets; /* quirks for devices to ignore the first n packets + in a stream */ spinlock_t lock; struct list_head list; @@ -105,6 +107,8 @@ struct snd_usb_substream { int interface; /* current interface */ int endpoint; /* assigned endpoint */ struct audioformat *cur_audiofmt; /* current audioformat pointer (for hw_params callback) */ + snd_pcm_format_t pcm_format; /* current audio format (for hw_params callback) */ + unsigned int channels; /* current number of channels (for hw_params callback) */ unsigned int cur_rate; /* current rate (for hw_params callback) */ unsigned int period_bytes; /* current period bytes (for hw_params callback) */ unsigned int altset_idx; /* USB data format: index of alternate setting */ @@ -115,14 +119,13 @@ struct snd_usb_substream { unsigned int hwptr_done; /* processed byte position in the buffer */ unsigned int transfer_done; /* processed frames since last period update */ - unsigned long active_mask; /* bitmask of active urbs */ - unsigned long unlink_mask; /* bitmask of unlinked urbs */ /* data and sync endpoints for this stream */ unsigned int ep_num; /* the endpoint number */ struct snd_usb_endpoint *data_endpoint; struct snd_usb_endpoint *sync_endpoint; unsigned long flags; + bool need_setup_ep; /* (re)configure EP at prepare? */ u64 formats; /* format bitmasks (all or'ed) */ unsigned int num_formats; /* number of supported audio formats (list) */ diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index d6e2bb49c59c..7f78c6d782b0 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -31,6 +31,7 @@ #include "card.h" #include "endpoint.h" #include "pcm.h" +#include "quirks.h" #define EP_FLAG_ACTIVATED 0 #define EP_FLAG_RUNNING 1 @@ -170,6 +171,11 @@ static void retire_inbound_urb(struct snd_usb_endpoint *ep, { struct urb *urb = urb_ctx->urb; + if (unlikely(ep->skip_packets > 0)) { + ep->skip_packets--; + return; + } + if (ep->sync_slave) snd_usb_handle_sync_urb(ep->sync_slave, ep, urb); @@ -197,7 +203,13 @@ static void prepare_outbound_urb(struct snd_usb_endpoint *ep, /* no data provider, so send silence */ unsigned int offs = 0; for (i = 0; i < ctx->packets; ++i) { - int counts = ctx->packet_size[i]; + int counts; + + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; + else + counts = snd_usb_endpoint_next_packet_size(ep); + urb->iso_frame_desc[i].offset = offs * ep->stride; urb->iso_frame_desc[i].length = counts * ep->stride; offs += counts; @@ -561,20 +573,19 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force) * configure a data endpoint */ static int data_ep_set_params(struct snd_usb_endpoint *ep, - struct snd_pcm_hw_params *hw_params, + snd_pcm_format_t pcm_format, + unsigned int channels, + unsigned int period_bytes, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep) { unsigned int maxsize, i, urb_packs, total_packs, packs_per_ms; - int period_bytes = params_period_bytes(hw_params); - int format = params_format(hw_params); int is_playback = usb_pipeout(ep->pipe); - int frame_bits = snd_pcm_format_physical_width(params_format(hw_params)) * - params_channels(hw_params); + int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; ep->datainterval = fmt->datainterval; ep->stride = frame_bits >> 3; - ep->silence_value = format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; + ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; /* calculate max. frequency */ if (ep->maxpacksize) { @@ -687,7 +698,6 @@ out_of_memory: * configure a sync endpoint */ static int sync_ep_set_params(struct snd_usb_endpoint *ep, - struct snd_pcm_hw_params *hw_params, struct audioformat *fmt) { int i; @@ -730,7 +740,10 @@ out_of_memory: * snd_usb_endpoint_set_params: configure an snd_usb_endpoint * * @ep: the snd_usb_endpoint to configure - * @hw_params: the hardware parameters + * @pcm_format: the audio fomat. + * @channels: the number of audio channels. + * @period_bytes: the number of bytes in one alsa period. + * @rate: the frame rate. * @fmt: the USB audio format information * @sync_ep: the sync endpoint to use, if any * @@ -739,7 +752,10 @@ out_of_memory: * An endpoint that is already running can not be reconfigured. */ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, - struct snd_pcm_hw_params *hw_params, + snd_pcm_format_t pcm_format, + unsigned int channels, + unsigned int period_bytes, + unsigned int rate, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep) { @@ -759,9 +775,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX); if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) - ep->freqn = get_usb_full_speed_rate(params_rate(hw_params)); + ep->freqn = get_usb_full_speed_rate(rate); else - ep->freqn = get_usb_high_speed_rate(params_rate(hw_params)); + ep->freqn = get_usb_high_speed_rate(rate); /* calculate the frequency in 16.16 format */ ep->freqm = ep->freqn; @@ -771,10 +787,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, switch (ep->type) { case SND_USB_ENDPOINT_TYPE_DATA: - err = data_ep_set_params(ep, hw_params, fmt, sync_ep); + err = data_ep_set_params(ep, pcm_format, channels, + period_bytes, fmt, sync_ep); break; case SND_USB_ENDPOINT_TYPE_SYNC: - err = sync_ep_set_params(ep, hw_params, fmt); + err = sync_ep_set_params(ep, fmt); break; default: err = -EINVAL; @@ -822,6 +839,8 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) ep->unlink_mask = 0; ep->phase = 0; + snd_usb_endpoint_start_quirk(ep); + /* * If this endpoint has a data endpoint as implicit feedback source, * don't start the urbs here. Instead, mark them all as available, diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index cbbbdf226d66..6376ccf10fd4 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h @@ -9,7 +9,10 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, int ep_num, int direction, int type); int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, - struct snd_pcm_hw_params *hw_params, + snd_pcm_format_t pcm_format, + unsigned int channels, + unsigned int period_bytes, + unsigned int rate, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep); diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 9eed8f40b179..c1db28f874c2 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c @@ -21,6 +21,7 @@ #include "usbaudio.h" #include "helper.h" +#include "quirks.h" /* * combine bytes and get an integer value @@ -97,6 +98,10 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, memcpy(data, buf, size); kfree(buf); } + + snd_usb_ctl_msg_quirk(dev, pipe, request, requesttype, + value, index, data, size); + return err; } diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 4f40ba823163..fe56c9da38e9 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1267,6 +1267,13 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void /* disable non-functional volume control */ master_bits &= ~UAC_CONTROL_BIT(UAC_FU_VOLUME); break; + case USB_ID(0x1130, 0xf211): + snd_printk(KERN_INFO + "usbmixer: volume control quirk for Tenx TP6911 Audio Headset\n"); + /* disable non-functional volume control */ + channels = 0; + break; + } if (channels > 0) first_ch_bits = snd_usb_combine_bytes(bmaControls + csize, csize); diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index f782ce19bf5a..55e19e1b80ec 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -82,8 +82,7 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream /* * find a matching audio format */ -static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned int format, - unsigned int rate, unsigned int channels) +static struct audioformat *find_format(struct snd_usb_substream *subs) { struct list_head *p; struct audioformat *found = NULL; @@ -92,16 +91,17 @@ static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned list_for_each(p, &subs->fmt_list) { struct audioformat *fp; fp = list_entry(p, struct audioformat, list); - if (!(fp->formats & (1uLL << format))) + if (!(fp->formats & (1uLL << subs->pcm_format))) continue; - if (fp->channels != channels) + if (fp->channels != subs->channels) continue; - if (rate < fp->rate_min || rate > fp->rate_max) + if (subs->cur_rate < fp->rate_min || + subs->cur_rate > fp->rate_max) continue; if (! (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)) { unsigned int i; for (i = 0; i < fp->nr_rates; i++) - if (fp->rate_table[i] == rate) + if (fp->rate_table[i] == subs->cur_rate) break; if (i >= fp->nr_rates) continue; @@ -436,6 +436,42 @@ add_sync_ep: } /* + * configure endpoint params + * + * called during initial setup and upon resume + */ +static int configure_endpoint(struct snd_usb_substream *subs) +{ + int ret; + + mutex_lock(&subs->stream->chip->shutdown_mutex); + /* format changed */ + stop_endpoints(subs, 0, 0, 0); + ret = snd_usb_endpoint_set_params(subs->data_endpoint, + subs->pcm_format, + subs->channels, + subs->period_bytes, + subs->cur_rate, + subs->cur_audiofmt, + subs->sync_endpoint); + if (ret < 0) + goto unlock; + + if (subs->sync_endpoint) + ret = snd_usb_endpoint_set_params(subs->data_endpoint, + subs->pcm_format, + subs->channels, + subs->period_bytes, + subs->cur_rate, + subs->cur_audiofmt, + NULL); + +unlock: + mutex_unlock(&subs->stream->chip->shutdown_mutex); + return ret; +} + +/* * hw_params callback * * allocate a buffer and set the given audio format. @@ -450,63 +486,33 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, { struct snd_usb_substream *subs = substream->runtime->private_data; struct audioformat *fmt; - unsigned int channels, rate, format; - int ret, changed; + int ret; ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); if (ret < 0) return ret; - format = params_format(hw_params); - rate = params_rate(hw_params); - channels = params_channels(hw_params); - fmt = find_format(subs, format, rate, channels); + subs->pcm_format = params_format(hw_params); + subs->period_bytes = params_period_bytes(hw_params); + subs->channels = params_channels(hw_params); + subs->cur_rate = params_rate(hw_params); + + fmt = find_format(subs); if (!fmt) { snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n", - format, rate, channels); + subs->pcm_format, subs->cur_rate, subs->channels); return -EINVAL; } - changed = subs->cur_audiofmt != fmt || - subs->period_bytes != params_period_bytes(hw_params) || - subs->cur_rate != rate; if ((ret = set_format(subs, fmt)) < 0) return ret; - if (subs->cur_rate != rate) { - struct usb_host_interface *alts; - struct usb_interface *iface; - iface = usb_ifnum_to_if(subs->dev, fmt->iface); - alts = &iface->altsetting[fmt->altset_idx]; - ret = snd_usb_init_sample_rate(subs->stream->chip, fmt->iface, alts, fmt, rate); - if (ret < 0) - return ret; - subs->cur_rate = rate; - } - - if (changed) { - mutex_lock(&subs->stream->chip->shutdown_mutex); - /* format changed */ - stop_endpoints(subs, 0, 0, 0); - ret = snd_usb_endpoint_set_params(subs->data_endpoint, hw_params, fmt, - subs->sync_endpoint); - if (ret < 0) - goto unlock; + subs->interface = fmt->iface; + subs->altset_idx = fmt->altset_idx; + subs->need_setup_ep = true; - if (subs->sync_endpoint) - ret = snd_usb_endpoint_set_params(subs->sync_endpoint, - hw_params, fmt, NULL); -unlock: - mutex_unlock(&subs->stream->chip->shutdown_mutex); - } - - if (ret == 0) { - subs->interface = fmt->iface; - subs->altset_idx = fmt->altset_idx; - } - - return ret; + return 0; } /* @@ -537,6 +543,9 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_usb_substream *subs = runtime->private_data; + struct usb_host_interface *alts; + struct usb_interface *iface; + int ret; if (! subs->cur_audiofmt) { snd_printk(KERN_ERR "usbaudio: no format is specified!\n"); @@ -546,6 +555,27 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) if (snd_BUG_ON(!subs->data_endpoint)) return -EIO; + ret = set_format(subs, subs->cur_audiofmt); + if (ret < 0) + return ret; + + iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface); + alts = &iface->altsetting[subs->cur_audiofmt->altset_idx]; + ret = snd_usb_init_sample_rate(subs->stream->chip, + subs->cur_audiofmt->iface, + alts, + subs->cur_audiofmt, + subs->cur_rate); + if (ret < 0) + return ret; + + if (subs->need_setup_ep) { + ret = configure_endpoint(subs); + if (ret < 0) + return ret; + subs->need_setup_ep = false; + } + /* some unit conversions in runtime */ subs->data_endpoint->maxframesize = bytes_to_frames(runtime, subs->data_endpoint->maxpacksize); diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 79780fa57a43..88d8cebbb244 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -2780,6 +2780,105 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, +{ + /* Tascam US122 MKII - playback-only support */ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x0644, + .idProduct = 0x8021, + .bInterfaceClass = USB_CLASS_AUDIO, + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .vendor_name = "TASCAM", + .product_name = "US122 MKII", + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_COMPOSITE, + .data = (const struct snd_usb_audio_quirk[]) { + { + .ifnum = 0, + .type = QUIRK_IGNORE_INTERFACE + }, + { + .ifnum = 1, + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = &(const struct audioformat) { + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .channels = 2, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, + .endpoint = 0x02, + .ep_attr = USB_ENDPOINT_XFER_ISOC, + .rates = SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_88200 | + SNDRV_PCM_RATE_96000, + .rate_min = 44100, + .rate_max = 96000, + .nr_rates = 4, + .rate_table = (unsigned int[]) { + 44100, 48000, 88200, 96000 + } + } + }, + { + .ifnum = -1 + } + } + } +}, + +/* Microsoft XboxLive Headset/Xbox Communicator */ +{ + USB_DEVICE(0x045e, 0x0283), + .bInterfaceClass = USB_CLASS_PER_INTERFACE, + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .vendor_name = "Microsoft", + .product_name = "XboxLive Headset/Xbox Communicator", + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_COMPOSITE, + .data = &(const struct snd_usb_audio_quirk[]) { + { + /* playback */ + .ifnum = 0, + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = &(const struct audioformat) { + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels = 1, + .iface = 0, + .altsetting = 0, + .altset_idx = 0, + .attributes = 0, + .endpoint = 0x04, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 22050, + .rate_max = 22050 + } + }, + { + /* capture */ + .ifnum = 1, + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = &(const struct audioformat) { + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels = 1, + .iface = 1, + .altsetting = 0, + .altset_idx = 0, + .attributes = 0, + .endpoint = 0x85, + .ep_attr = 0x05, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 16000, + .rate_max = 16000 + } + }, + { + .ifnum = -1 + } + } + } +}, { /* diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 27817266867a..0f58b4b6d702 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -761,3 +761,27 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs, } } +void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep) +{ + /* + * "Playback Design" products send bogus feedback data at the start + * of the stream. Ignore them. + */ + if ((le16_to_cpu(ep->chip->dev->descriptor.idVendor) == 0x23ba) && + ep->type == SND_USB_ENDPOINT_TYPE_SYNC) + ep->skip_packets = 4; +} + +void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, + __u8 request, __u8 requesttype, __u16 value, + __u16 index, void *data, __u16 size) +{ + /* + * "Playback Design" products need a 20ms delay after each + * class compliant request + */ + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) && + (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) + mdelay(20); +} + diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index 03e5e94098cd..0ca9e91067a6 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -1,6 +1,10 @@ #ifndef __USBAUDIO_QUIRKS_H #define __USBAUDIO_QUIRKS_H +struct audioformat; +struct snd_usb_endpoint; +struct snd_usb_substream; + int snd_usb_create_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, @@ -20,4 +24,10 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs, int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *fp); +void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep); + +void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, + __u8 request, __u8 requesttype, __u16 value, + __u16 index, void *data, __u16 size); + #endif /* __USBAUDIO_QUIRKS_H */ diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index c4fd3b1d9592..d0323a693ba2 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -262,7 +262,7 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, } area->vm_ops = &usb_stream_hwdep_vm_ops; - area->vm_flags |= VM_RESERVED; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; area->vm_private_data = us122l; atomic_inc(&us122l->mmap_count); out: diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 04aafb43a13c..0b34dbc8f302 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -82,7 +82,7 @@ static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct v us428->us428ctls_sharedmem->CtlSnapShotLast = -2; } area->vm_ops = &us428ctls_vm_ops; - area->vm_flags |= VM_RESERVED | VM_DONTEXPAND; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; area->vm_private_data = hw->private_data; return 0; } diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 8e40b6e67e9e..cc56007791e0 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -723,7 +723,7 @@ static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, st return -ENODEV; } area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; - area->vm_flags |= VM_RESERVED | VM_DONTEXPAND; + area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; area->vm_private_data = hw->private_data; return 0; } |