diff options
Diffstat (limited to 'sound')
258 files changed, 4090 insertions, 8920 deletions
diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c index f341539..faa3174 100644 --- a/sound/aoa/core/gpio-feature.c +++ b/sound/aoa/core/gpio-feature.c @@ -10,9 +10,8 @@ * registers. */ -#include <linux/of_irq.h> -#include <linux/interrupt.h> #include <asm/pmac_feature.h> +#include <linux/interrupt.h> #include "../aoa.h" /* TODO: these are lots of global variables diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index 9dc5806..61ab640 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c @@ -644,7 +644,7 @@ static int n##_control_put(struct snd_kcontrol *kcontrol, \ struct snd_ctl_elem_value *ucontrol) \ { \ struct gpio_runtime *gpio = snd_kcontrol_chip(kcontrol); \ - if (gpio->methods && gpio->methods->set_##n) \ + if (gpio->methods && gpio->methods->get_##n) \ gpio->methods->set_##n(gpio, \ !!ucontrol->value.integer.value[0]); \ return 1; \ @@ -1135,7 +1135,7 @@ static int aoa_fabric_layout_resume(struct soundbus_dev *sdev) { struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); - if (ldev->gpio.methods && ldev->gpio.methods->all_amps_restore) + if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) ldev->gpio.methods->all_amps_restore(&ldev->gpio); return 0; diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 4678360..15e7613 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c @@ -11,8 +11,6 @@ #include <linux/pci.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> #include <sound/core.h> diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c index 66de90e..e6f4633 100644 --- a/sound/arm/pxa2xx-ac97-lib.c +++ b/sound/arm/pxa2xx-ac97-lib.c @@ -117,7 +117,8 @@ static inline void pxa_ac97_warm_pxa25x(void) { gsr_bits = 0; - GCR |= GCR_WARM_RST; + GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN; + wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); } static inline void pxa_ac97_cold_pxa25x(void) @@ -128,6 +129,8 @@ static inline void pxa_ac97_cold_pxa25x(void) gsr_bits = 0; GCR = GCR_COLD_RST; + GCR |= GCR_CDONE_IE|GCR_SDONE_IE; + wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); } #endif @@ -146,6 +149,8 @@ static inline void pxa_ac97_warm_pxa27x(void) static inline void pxa_ac97_cold_pxa27x(void) { + unsigned int timeout; + GCR &= GCR_COLD_RST; /* clear everything but nCRST */ GCR &= ~GCR_COLD_RST; /* then assert nCRST */ @@ -156,20 +161,29 @@ static inline void pxa_ac97_cold_pxa27x(void) udelay(5); clk_disable(ac97conf_clk); GCR = GCR_COLD_RST | GCR_WARM_RST; + timeout = 100; /* wait for the codec-ready bit to be set */ + while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) + mdelay(1); } #endif #ifdef CONFIG_PXA3xx static inline void pxa_ac97_warm_pxa3xx(void) { + int timeout = 100; + gsr_bits = 0; /* Can't use interrupts */ GCR |= GCR_WARM_RST; + while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) + mdelay(1); } static inline void pxa_ac97_cold_pxa3xx(void) { + int timeout = 1000; + /* Hold CLKBPB for 100us */ GCR = 0; GCR = GCR_CLKBPB; @@ -185,13 +199,14 @@ static inline void pxa_ac97_cold_pxa3xx(void) GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); GCR = GCR_WARM_RST | GCR_COLD_RST; + while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--) + mdelay(10); } #endif bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) { unsigned long gsr; - unsigned int timeout = 100; #ifdef CONFIG_PXA25x if (cpu_is_pxa25x()) @@ -208,11 +223,7 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) pxa_ac97_warm_pxa3xx(); else #endif - snd_BUG(); - - while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) - mdelay(1); - + BUG(); gsr = GSR | gsr_bits; if (!(gsr & (GSR_PCR | GSR_SCR))) { printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", @@ -228,7 +239,6 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset); bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) { unsigned long gsr; - unsigned int timeout = 1000; #ifdef CONFIG_PXA25x if (cpu_is_pxa25x()) @@ -245,10 +255,7 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) pxa_ac97_cold_pxa3xx(); else #endif - snd_BUG(); - - while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) - mdelay(1); + BUG(); gsr = GSR | gsr_bits; if (!(gsr & (GSR_PCR | GSR_SCR))) { diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 9a2ac1e..5066a37 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -185,7 +185,7 @@ static int pxa2xx_ac97_probe(struct platform_device *dev) goto err; card->dev = &dev->dev; - strlcpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); + strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm); if (ret) diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c index e6c727b..69a2455 100644 --- a/sound/arm/pxa2xx-pcm.c +++ b/sound/arm/pxa2xx-pcm.c @@ -11,7 +11,6 @@ */ #include <linux/module.h> -#include <linux/dma-mapping.h> #include <linux/dmaengine.h> #include <sound/core.h> @@ -84,6 +83,8 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; +static u64 pxa2xx_pcm_dmamask = 0xffffffff; + int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, struct snd_pcm **rpcm) { @@ -99,9 +100,10 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, pcm->private_data = client; pcm->private_free = pxa2xx_pcm_free_dma_buffers; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - goto out; + if (!card->dev->dma_mask) + card->dev->dma_mask = &pxa2xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = 0xffffffff; if (play) { int stream = SNDRV_PCM_STREAM_PLAYBACK; diff --git a/sound/atmel/abdac.c b/sound/atmel/abdac.c index 721d8fd..872d59e 100644 --- a/sound/atmel/abdac.c +++ b/sound/atmel/abdac.c @@ -357,8 +357,7 @@ static int set_sample_rates(struct atmel_abdac *dac) if (new_rate < 0) break; /* make sure we are below the ABDAC clock */ - if (index < MAX_NUM_RATES && - new_rate <= clk_get_rate(dac->pclk)) { + if (new_rate <= clk_get_rate(dac->pclk)) { dac->rates[index] = new_rate / 256; index++; } diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index c5f0ddd..ae63d22 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -34,6 +34,7 @@ #include <linux/dw_dmac.h> #include <mach/cpu.h> +#include <mach/gpio.h> #ifdef CONFIG_ARCH_AT91 #include <mach/hardware.h> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 9d518ac..bea523a 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -384,7 +384,8 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait) return -EFAULT; mutex_lock(&stream->device->lock); - if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) { + if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED || + stream->runtime->state == SNDRV_PCM_STATE_OPEN) { retval = -EBADFD; goto out; } @@ -679,48 +680,14 @@ static int snd_compr_stop(struct snd_compr_stream *stream) return -EPERM; retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); if (!retval) { - snd_compr_drain_notify(stream); + stream->runtime->state = SNDRV_PCM_STATE_SETUP; + wake_up(&stream->runtime->sleep); stream->runtime->total_bytes_available = 0; stream->runtime->total_bytes_transferred = 0; } return retval; } -static int snd_compress_wait_for_drain(struct snd_compr_stream *stream) -{ - int ret; - - /* - * We are called with lock held. So drop the lock while we wait for - * drain complete notfication from the driver - * - * It is expected that driver will notify the drain completion and then - * stream will be moved to SETUP state, even if draining resulted in an - * error. We can trigger next track after this. - */ - stream->runtime->state = SNDRV_PCM_STATE_DRAINING; - mutex_unlock(&stream->device->lock); - - /* we wait for drain to complete here, drain can return when - * interruption occurred, wait returned error or success. - * For the first two cases we don't do anything different here and - * return after waking up - */ - - ret = wait_event_interruptible(stream->runtime->sleep, - (stream->runtime->state != SNDRV_PCM_STATE_DRAINING)); - if (ret == -ERESTARTSYS) - pr_debug("wait aborted by a signal"); - else if (ret) - pr_debug("wait for drain failed with %d\n", ret); - - - wake_up(&stream->runtime->sleep); - mutex_lock(&stream->device->lock); - - return ret; -} - static int snd_compr_drain(struct snd_compr_stream *stream) { int retval; @@ -728,15 +695,12 @@ static int snd_compr_drain(struct snd_compr_stream *stream) if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || stream->runtime->state == SNDRV_PCM_STATE_SETUP) return -EPERM; - retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); - if (retval) { - pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval); + if (!retval) { + stream->runtime->state = SNDRV_PCM_STATE_DRAINING; wake_up(&stream->runtime->sleep); - return retval; } - - return snd_compress_wait_for_drain(stream); + return retval; } static int snd_compr_next_track(struct snd_compr_stream *stream) @@ -772,14 +736,9 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) return -EPERM; retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); - if (retval) { - pr_debug("Partial drain returned failure\n"); - wake_up(&stream->runtime->sleep); - return retval; - } stream->next_track = false; - return snd_compress_wait_for_drain(stream); + return retval; } static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) diff --git a/sound/core/init.c b/sound/core/init.c index 1351f22..6b90871 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -66,7 +66,7 @@ static int module_slot_match(struct module *module, int idx) #ifdef MODULE const char *s1, *s2; - if (!module || !*module->name || !slots[idx]) + if (!module || !module->name || !slots[idx]) return 0; s1 = module->name; @@ -597,7 +597,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src, /* last resort... */ snd_printk(KERN_ERR "unable to set card id (%s)\n", id); if (card->proc_root->name) - strlcpy(card->id, card->proc_root->name, sizeof(card->id)); + strcpy(card->id, card->proc_root->name); } /** diff --git a/sound/core/jack.c b/sound/core/jack.c index 8658578..b35fe73 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -34,12 +34,12 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { SW_LINEIN_INSERT, }; -static int snd_jack_dev_disconnect(struct snd_device *device) +static int snd_jack_dev_free(struct snd_device *device) { struct snd_jack *jack = device->device_data; - if (!jack->input_dev) - return 0; + if (jack->private_free) + jack->private_free(jack); /* If the input device is registered with the input subsystem * then we need to use a different deallocator. */ @@ -47,18 +47,6 @@ static int snd_jack_dev_disconnect(struct snd_device *device) input_unregister_device(jack->input_dev); else input_free_device(jack->input_dev); - jack->input_dev = NULL; - return 0; -} - -static int snd_jack_dev_free(struct snd_device *device) -{ - struct snd_jack *jack = device->device_data; - - if (jack->private_free) - jack->private_free(jack); - - snd_jack_dev_disconnect(device); kfree(jack->id); kfree(jack); @@ -122,7 +110,6 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, - .dev_disconnect = snd_jack_dev_disconnect, }; jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 5e1c7bc..bdf826f 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -30,7 +30,6 @@ #include <linux/seq_file.h> #include <asm/uaccess.h> #include <linux/dma-mapping.h> -#include <linux/genalloc.h> #include <linux/moduleparam.h> #include <linux/mutex.h> #include <sound/memalloc.h> @@ -158,47 +157,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, dec_snd_pages(pg); dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); } - -#ifdef CONFIG_GENERIC_ALLOCATOR -/** - * snd_malloc_dev_iram - allocate memory from on-chip internal ram - * @dmab: buffer allocation record to store the allocated data - * @size: number of bytes to allocate from the iram - * - * This function requires iram phandle provided via of_node - */ -static void snd_malloc_dev_iram(struct snd_dma_buffer *dmab, size_t size) -{ - struct device *dev = dmab->dev.dev; - struct gen_pool *pool = NULL; - - dmab->area = NULL; - dmab->addr = 0; - - if (dev->of_node) - pool = of_get_named_gen_pool(dev->of_node, "iram", 0); - - if (!pool) - return; - - /* Assign the pool into private_data field */ - dmab->private_data = pool; - - dmab->area = gen_pool_dma_alloc(pool, size, &dmab->addr); -} - -/** - * snd_free_dev_iram - free allocated specific memory from on-chip internal ram - * @dmab: buffer allocation record to store the allocated data - */ -static void snd_free_dev_iram(struct snd_dma_buffer *dmab) -{ - struct gen_pool *pool = dmab->private_data; - - if (pool && dmab->area) - gen_pool_free(pool, (unsigned long)dmab->area, dmab->bytes); -} -#endif /* CONFIG_GENERIC_ALLOCATOR */ #endif /* CONFIG_HAS_DMA */ /* @@ -239,16 +197,6 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, dmab->addr = 0; break; #ifdef CONFIG_HAS_DMA -#ifdef CONFIG_GENERIC_ALLOCATOR - case SNDRV_DMA_TYPE_DEV_IRAM: - snd_malloc_dev_iram(dmab, size); - if (dmab->area) - break; - /* Internal memory might have limited size and no enough space, - * so if we fail to malloc, try to fetch memory traditionally. - */ - dmab->dev.type = SNDRV_DMA_TYPE_DEV; -#endif /* CONFIG_GENERIC_ALLOCATOR */ case SNDRV_DMA_TYPE_DEV: dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); break; @@ -321,11 +269,6 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) snd_free_pages(dmab->area, dmab->bytes); break; #ifdef CONFIG_HAS_DMA -#ifdef CONFIG_GENERIC_ALLOCATOR - case SNDRV_DMA_TYPE_DEV_IRAM: - snd_free_dev_iram(dmab); - break; -#endif /* CONFIG_GENERIC_ALLOCATOR */ case SNDRV_DMA_TYPE_DEV: snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); break; diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c index 94d0873..aa924d9 100644 --- a/sound/core/pcm_dmaengine.c +++ b/sound/core/pcm_dmaengine.c @@ -63,19 +63,23 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, struct dma_slave_config *slave_config) { enum dma_slave_buswidth buswidth; - int bits; - bits = snd_pcm_format_physical_width(params_format(params)); - if (bits < 8 || bits > 64) - return -EINVAL; - else if (bits == 8) + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S8: buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; - else if (bits == 16) + break; + case SNDRV_PCM_FORMAT_S16_LE: buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; - else if (bits <= 32) + break; + case SNDRV_PCM_FORMAT_S18_3LE: + case SNDRV_PCM_FORMAT_S20_3LE: + case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S32_LE: buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; - else - buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES; + break; + default: + return -EINVAL; + } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { slave_config->direction = DMA_MEM_TO_DEV; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 01a5e05..a68d4c6 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2428,7 +2428,6 @@ static int snd_pcm_hwsync(struct snd_pcm_substream *substream) case SNDRV_PCM_STATE_DRAINING: if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) goto __badfd; - /* Fall through */ case SNDRV_PCM_STATE_RUNNING: if ((err = snd_pcm_update_hw_ptr(substream)) < 0) break; @@ -2461,7 +2460,6 @@ static int snd_pcm_delay(struct snd_pcm_substream *substream, case SNDRV_PCM_STATE_DRAINING: if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) goto __badfd; - /* Fall through */ case SNDRV_PCM_STATE_RUNNING: if ((err = snd_pcm_update_hw_ptr(substream)) < 0) break; @@ -3201,14 +3199,6 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *area) { area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; -#ifdef CONFIG_GENERIC_ALLOCATOR - if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { - area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); - return remap_pfn_range(area, area->vm_start, - substream->dma_buffer.addr >> PAGE_SHIFT, - area->vm_end - area->vm_start, area->vm_page_prot); - } -#endif /* CONFIG_GENERIC_ALLOCATOR */ #ifdef ARCH_HAS_DMA_MMAP_COHERENT if (!substream->ops->page && substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) diff --git a/sound/core/sound.c b/sound/core/sound.c index 437c25e..f002bd9 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -153,7 +153,7 @@ static int snd_open(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); struct snd_minor *mptr = NULL; - const struct file_operations *new_fops; + const struct file_operations *old_fops; int err = 0; if (minor >= ARRAY_SIZE(snd_minors)) @@ -167,14 +167,24 @@ static int snd_open(struct inode *inode, struct file *file) return -ENODEV; } } - new_fops = fops_get(mptr->f_ops); + old_fops = file->f_op; + file->f_op = fops_get(mptr->f_ops); + if (file->f_op == NULL) { + file->f_op = old_fops; + err = -ENODEV; + } mutex_unlock(&sound_mutex); - if (!new_fops) - return -ENODEV; - replace_fops(file, new_fops); + if (err < 0) + return err; - if (file->f_op->open) + if (file->f_op->open) { err = file->f_op->open(inode, file); + if (err) { + fops_put(file->f_op); + file->f_op = fops_get(old_fops); + } + } + fops_put(old_fops); return err; } diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 6c6d09a..0c796bc 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -390,11 +390,6 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) voice = snd_opl3_oss_map[chan->number]; } - if (voice < 0) { - spin_unlock_irqrestore(&opl3->voice_lock, flags); - return; - } - if (voice < MAX_OPL2_VOICES) { /* Left register block for voices 0 .. 8 */ reg_side = OPL3_LEFT; diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 328bd29..1c19cd7 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -46,9 +46,8 @@ static int snd_pcsp_create(struct snd_card *card) int err; int div, min_div, order; - hrtimer_get_res(CLOCK_MONOTONIC, &tp); - if (!nopcm) { + hrtimer_get_res(CLOCK_MONOTONIC, &tp); if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { printk(KERN_ERR "PCSP: Timer resolution is not sufficient " "(%linS)\n", tp.tv_nsec); @@ -188,8 +187,8 @@ static int pcsp_probe(struct platform_device *dev) static int pcsp_remove(struct platform_device *dev) { struct snd_pcsp *chip = platform_get_drvdata(dev); - pcspkr_input_remove(chip->input_dev); alsa_card_pcsp_exit(chip); + pcspkr_input_remove(chip->input_dev); return 0; } diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig index b3e274f..ea063e1 100644 --- a/sound/firewire/Kconfig +++ b/sound/firewire/Kconfig @@ -11,21 +11,6 @@ config SND_FIREWIRE_LIB tristate depends on SND_PCM -config SND_DICE - tristate "DICE-based DACs (EXPERIMENTAL)" - select SND_HWDEP - select SND_PCM - select SND_FIREWIRE_LIB - help - Say Y here to include support for many DACs based on the DICE - chip family (DICE-II/Jr/Mini) from TC Applied Technologies. - - At the moment, this driver supports playback only. If you - want to use devices that support capturing, use FFADO instead. - - To compile this driver as a module, choose M here: the module - will be called snd-dice. - config SND_FIREWIRE_SPEAKERS tristate "FireWire speakers" select SND_PCM diff --git a/sound/firewire/Makefile b/sound/firewire/Makefile index 5099550..460179d 100644 --- a/sound/firewire/Makefile +++ b/sound/firewire/Makefile @@ -1,12 +1,10 @@ snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \ fcp.o cmp.o amdtp.o -snd-dice-objs := dice.o snd-firewire-speakers-objs := speakers.o snd-isight-objs := isight.o snd-scs1x-objs := scs1x.o obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o -obj-$(CONFIG_SND_DICE) += snd-dice.o obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o obj-$(CONFIG_SND_ISIGHT) += snd-isight.o obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 9048777..ea995af 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -42,6 +42,9 @@ static void pcm_period_tasklet(unsigned long data); int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, enum cip_out_flags flags) { + if (flags != CIP_NONBLOCKING) + return -EINVAL; + s->unit = fw_unit_get(unit); s->flags = flags; s->context = ERR_PTR(-1); @@ -59,91 +62,73 @@ EXPORT_SYMBOL(amdtp_out_stream_init); */ void amdtp_out_stream_destroy(struct amdtp_out_stream *s) { - WARN_ON(amdtp_out_stream_running(s)); + WARN_ON(!IS_ERR(s->context)); mutex_destroy(&s->mutex); fw_unit_put(s->unit); } EXPORT_SYMBOL(amdtp_out_stream_destroy); -const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT] = { - [CIP_SFC_32000] = 8, - [CIP_SFC_44100] = 8, - [CIP_SFC_48000] = 8, - [CIP_SFC_88200] = 16, - [CIP_SFC_96000] = 16, - [CIP_SFC_176400] = 32, - [CIP_SFC_192000] = 32, -}; -EXPORT_SYMBOL(amdtp_syt_intervals); - /** - * amdtp_out_stream_set_parameters - set stream parameters + * amdtp_out_stream_set_rate - set the sample rate * @s: the AMDTP output stream to configure * @rate: the sample rate - * @pcm_channels: the number of PCM samples in each data block, to be encoded - * as AM824 multi-bit linear audio - * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels) * - * The parameters must be set before the stream is started, and must not be + * The sample rate must be set before the stream is started, and must not be * changed while the stream is running. */ -void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s, - unsigned int rate, - unsigned int pcm_channels, - unsigned int midi_ports) +void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate) { - static const unsigned int rates[] = { - [CIP_SFC_32000] = 32000, - [CIP_SFC_44100] = 44100, - [CIP_SFC_48000] = 48000, - [CIP_SFC_88200] = 88200, - [CIP_SFC_96000] = 96000, - [CIP_SFC_176400] = 176400, - [CIP_SFC_192000] = 192000, + static const struct { + unsigned int rate; + unsigned int syt_interval; + } rate_info[] = { + [CIP_SFC_32000] = { 32000, 8, }, + [CIP_SFC_44100] = { 44100, 8, }, + [CIP_SFC_48000] = { 48000, 8, }, + [CIP_SFC_88200] = { 88200, 16, }, + [CIP_SFC_96000] = { 96000, 16, }, + [CIP_SFC_176400] = { 176400, 32, }, + [CIP_SFC_192000] = { 192000, 32, }, }; unsigned int sfc; - if (WARN_ON(amdtp_out_stream_running(s))) + if (WARN_ON(!IS_ERR(s->context))) return; - for (sfc = 0; sfc < CIP_SFC_COUNT; ++sfc) - if (rates[sfc] == rate) - goto sfc_found; + for (sfc = 0; sfc < ARRAY_SIZE(rate_info); ++sfc) + if (rate_info[sfc].rate == rate) { + s->sfc = sfc; + s->syt_interval = rate_info[sfc].syt_interval; + return; + } WARN_ON(1); - return; - -sfc_found: - s->dual_wire = (s->flags & CIP_HI_DUALWIRE) && sfc > CIP_SFC_96000; - if (s->dual_wire) { - sfc -= 2; - rate /= 2; - pcm_channels *= 2; - } - s->sfc = sfc; - s->data_block_quadlets = pcm_channels + DIV_ROUND_UP(midi_ports, 8); - s->pcm_channels = pcm_channels; - s->midi_ports = midi_ports; - - s->syt_interval = amdtp_syt_intervals[sfc]; - - /* default buffering in the device */ - s->transfer_delay = TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; - if (s->flags & CIP_BLOCKING) - /* additional buffering needed to adjust for no-data packets */ - s->transfer_delay += TICKS_PER_SECOND * s->syt_interval / rate; } -EXPORT_SYMBOL(amdtp_out_stream_set_parameters); +EXPORT_SYMBOL(amdtp_out_stream_set_rate); /** * amdtp_out_stream_get_max_payload - get the stream's packet size * @s: the AMDTP output stream * * This function must not be called before the stream has been configured - * with amdtp_out_stream_set_parameters(). + * with amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and + * amdtp_out_stream_set_midi(). */ unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s) { - return 8 + s->syt_interval * s->data_block_quadlets * 4; + static const unsigned int max_data_blocks[] = { + [CIP_SFC_32000] = 4, + [CIP_SFC_44100] = 6, + [CIP_SFC_48000] = 6, + [CIP_SFC_88200] = 12, + [CIP_SFC_96000] = 12, + [CIP_SFC_176400] = 23, + [CIP_SFC_192000] = 24, + }; + + s->data_block_quadlets = s->pcm_channels; + s->data_block_quadlets += DIV_ROUND_UP(s->midi_ports, 8); + + return 8 + max_data_blocks[s->sfc] * 4 * s->data_block_quadlets; } EXPORT_SYMBOL(amdtp_out_stream_get_max_payload); @@ -153,26 +138,19 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, static void amdtp_write_s32(struct amdtp_out_stream *s, struct snd_pcm_substream *pcm, __be32 *buffer, unsigned int frames); -static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s, - struct snd_pcm_substream *pcm, - __be32 *buffer, unsigned int frames); -static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s, - struct snd_pcm_substream *pcm, - __be32 *buffer, unsigned int frames); /** * amdtp_out_stream_set_pcm_format - set the PCM format * @s: the AMDTP output stream to configure * @format: the format of the ALSA PCM device * - * The sample format must be set after the other paramters (rate/PCM channels/ - * MIDI) and before the stream is started, and must not be changed while the - * stream is running. + * The sample format must be set before the stream is started, and must not be + * changed while the stream is running. */ void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, snd_pcm_format_t format) { - if (WARN_ON(amdtp_out_stream_running(s))) + if (WARN_ON(!IS_ERR(s->context))) return; switch (format) { @@ -180,16 +158,10 @@ void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, WARN_ON(1); /* fall through */ case SNDRV_PCM_FORMAT_S16: - if (s->dual_wire) - s->transfer_samples = amdtp_write_s16_dualwire; - else - s->transfer_samples = amdtp_write_s16; + s->transfer_samples = amdtp_write_s16; break; case SNDRV_PCM_FORMAT_S32: - if (s->dual_wire) - s->transfer_samples = amdtp_write_s32_dualwire; - else - s->transfer_samples = amdtp_write_s32; + s->transfer_samples = amdtp_write_s32; break; } } @@ -276,7 +248,7 @@ static unsigned int calculate_syt(struct amdtp_out_stream *s, s->last_syt_offset = syt_offset; if (syt_offset < TICKS_PER_CYCLE) { - syt_offset += s->transfer_delay; + syt_offset += TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; syt = (cycle + syt_offset / TICKS_PER_CYCLE) << 12; syt += syt_offset % TICKS_PER_CYCLE; @@ -296,7 +268,7 @@ static void amdtp_write_s32(struct amdtp_out_stream *s, channels = s->pcm_channels; src = (void *)runtime->dma_area + - frames_to_bytes(runtime, s->pcm_buffer_pointer); + s->pcm_buffer_pointer * (runtime->frame_bits / 8); remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; frame_step = s->data_block_quadlets - channels; @@ -322,7 +294,7 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, channels = s->pcm_channels; src = (void *)runtime->dma_area + - frames_to_bytes(runtime, s->pcm_buffer_pointer); + s->pcm_buffer_pointer * (runtime->frame_bits / 8); remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; frame_step = s->data_block_quadlets - channels; @@ -338,68 +310,6 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, } } -static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s, - struct snd_pcm_substream *pcm, - __be32 *buffer, unsigned int frames) -{ - struct snd_pcm_runtime *runtime = pcm->runtime; - unsigned int channels, frame_adjust_1, frame_adjust_2, i, c; - const u32 *src; - - channels = s->pcm_channels; - src = (void *)runtime->dma_area + - s->pcm_buffer_pointer * (runtime->frame_bits / 8); - frame_adjust_1 = channels - 1; - frame_adjust_2 = 1 - (s->data_block_quadlets - channels); - - channels /= 2; - for (i = 0; i < frames; ++i) { - for (c = 0; c < channels; ++c) { - *buffer = cpu_to_be32((*src >> 8) | 0x40000000); - src++; - buffer += 2; - } - buffer -= frame_adjust_1; - for (c = 0; c < channels; ++c) { - *buffer = cpu_to_be32((*src >> 8) | 0x40000000); - src++; - buffer += 2; - } - buffer -= frame_adjust_2; - } -} - -static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s, - struct snd_pcm_substream *pcm, - __be32 *buffer, unsigned int frames) -{ - struct snd_pcm_runtime *runtime = pcm->runtime; - unsigned int channels, frame_adjust_1, frame_adjust_2, i, c; - const u16 *src; - - channels = s->pcm_channels; - src = (void *)runtime->dma_area + - s->pcm_buffer_pointer * (runtime->frame_bits / 8); - frame_adjust_1 = channels - 1; - frame_adjust_2 = 1 - (s->data_block_quadlets - channels); - - channels /= 2; - for (i = 0; i < frames; ++i) { - for (c = 0; c < channels; ++c) { - *buffer = cpu_to_be32((*src << 8) | 0x40000000); - src++; - buffer += 2; - } - buffer -= frame_adjust_1; - for (c = 0; c < channels; ++c) { - *buffer = cpu_to_be32((*src << 8) | 0x40000000); - src++; - buffer += 2; - } - buffer -= frame_adjust_2; - } -} - static void amdtp_fill_pcm_silence(struct amdtp_out_stream *s, __be32 *buffer, unsigned int frames) { @@ -434,14 +344,8 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle) return; index = s->packet_index; - /* this module generate empty packet for 'no data' */ + data_blocks = calculate_data_blocks(s); syt = calculate_syt(s, cycle); - if (!(s->flags & CIP_BLOCKING)) - data_blocks = calculate_data_blocks(s); - else if (syt != 0xffff) - data_blocks = s->syt_interval; - else - data_blocks = 0; buffer = s->buffer.packets[index].buffer; buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) | @@ -482,9 +386,6 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle) s->packet_index = index; if (pcm) { - if (s->dual_wire) - data_blocks *= 2; - ptr = s->pcm_buffer_pointer + data_blocks; if (ptr >= pcm->runtime->buffer_size) ptr -= pcm->runtime->buffer_size; @@ -554,8 +455,9 @@ static int queue_initial_skip_packets(struct amdtp_out_stream *s) * @speed: firewire speed code * * The stream cannot be started until it has been configured with - * amdtp_out_stream_set_parameters() and amdtp_out_stream_set_pcm_format(), - * and it must be started before any PCM or MIDI device can be started. + * amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and + * amdtp_out_stream_set_midi(); and it must be started before any + * PCM or MIDI device can be started. */ int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed) { @@ -575,7 +477,7 @@ int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed) mutex_lock(&s->mutex); - if (WARN_ON(amdtp_out_stream_running(s) || + if (WARN_ON(!IS_ERR(s->context) || (!s->pcm_channels && !s->midi_ports))) { err = -EBADFD; goto err_unlock; @@ -671,7 +573,7 @@ void amdtp_out_stream_stop(struct amdtp_out_stream *s) { mutex_lock(&s->mutex); - if (!amdtp_out_stream_running(s)) { + if (IS_ERR(s->context)) { mutex_unlock(&s->mutex); return; } diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h index 2746ecd..f6103d6 100644 --- a/sound/firewire/amdtp.h +++ b/sound/firewire/amdtp.h @@ -1,10 +1,8 @@ #ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED #define SOUND_FIREWIRE_AMDTP_H_INCLUDED -#include <linux/err.h> #include <linux/interrupt.h> #include <linux/mutex.h> -#include <sound/asound.h> #include "packets-buffer.h" /** @@ -13,18 +11,9 @@ * sample_rate/8000 samples, with rounding up or down to adjust * for clock skew and left-over fractional samples. This should * be used if supported by the device. - * @CIP_BLOCKING: In blocking mode, each packet contains either zero or - * SYT_INTERVAL samples, with these two types alternating so that - * the overall sample rate comes out right. - * @CIP_HI_DUALWIRE: At rates above 96 kHz, pretend that the stream runs - * at half the actual sample rate with twice the number of channels; - * two samples of a channel are stored consecutively in the packet. - * Requires blocking mode and SYT_INTERVAL-aligned PCM buffer size. */ enum cip_out_flags { - CIP_NONBLOCKING = 0x00, - CIP_BLOCKING = 0x01, - CIP_HI_DUALWIRE = 0x02, + CIP_NONBLOCKING = 0, }; /** @@ -38,7 +27,6 @@ enum cip_sfc { CIP_SFC_96000 = 4, CIP_SFC_176400 = 5, CIP_SFC_192000 = 6, - CIP_SFC_COUNT }; #define AMDTP_OUT_PCM_FORMAT_BITS (SNDRV_PCM_FMTBIT_S16 | \ @@ -55,7 +43,6 @@ struct amdtp_out_stream { struct mutex mutex; enum cip_sfc sfc; - bool dual_wire; unsigned int data_block_quadlets; unsigned int pcm_channels; unsigned int midi_ports; @@ -64,7 +51,6 @@ struct amdtp_out_stream { __be32 *buffer, unsigned int frames); unsigned int syt_interval; - unsigned int transfer_delay; unsigned int source_node_id_field; struct iso_packets_buffer buffer; @@ -88,10 +74,7 @@ int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, enum cip_out_flags flags); void amdtp_out_stream_destroy(struct amdtp_out_stream *s); -void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s, - unsigned int rate, - unsigned int pcm_channels, - unsigned int midi_ports); +void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate); unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s); int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed); @@ -104,11 +87,31 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s); unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s); void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s); -extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT]; +/** + * amdtp_out_stream_set_pcm - configure format of PCM samples + * @s: the AMDTP output stream to be configured + * @pcm_channels: the number of PCM samples in each data block, to be encoded + * as AM824 multi-bit linear audio + * + * This function must not be called while the stream is running. + */ +static inline void amdtp_out_stream_set_pcm(struct amdtp_out_stream *s, + unsigned int pcm_channels) +{ + s->pcm_channels = pcm_channels; +} -static inline bool amdtp_out_stream_running(struct amdtp_out_stream *s) +/** + * amdtp_out_stream_set_midi - configure format of MIDI data + * @s: the AMDTP output stream to be configured + * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels) + * + * This function must not be called while the stream is running. + */ +static inline void amdtp_out_stream_set_midi(struct amdtp_out_stream *s, + unsigned int midi_ports) { - return !IS_ERR(s->context); + s->midi_ports = midi_ports; } /** diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c index efdbf58..645cb0b 100644 --- a/sound/firewire/cmp.c +++ b/sound/firewire/cmp.c @@ -48,6 +48,9 @@ static int pcr_modify(struct cmp_connection *c, int (*check)(struct cmp_connection *c, __be32 pcr), enum bus_reset_handling bus_reset_handling) { + struct fw_device *device = fw_parent_device(c->resources.unit); + int generation = c->resources.generation; + int rcode, errors = 0; __be32 old_arg, buffer[2]; int err; @@ -56,31 +59,36 @@ static int pcr_modify(struct cmp_connection *c, old_arg = buffer[0]; buffer[1] = modify(c, buffer[0]); - err = snd_fw_transaction( - c->resources.unit, TCODE_LOCK_COMPARE_SWAP, + rcode = fw_run_transaction( + device->card, TCODE_LOCK_COMPARE_SWAP, + device->node_id, generation, device->max_speed, CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index), - buffer, 8, - FW_FIXED_GENERATION | c->resources.generation); - - if (err < 0) { - if (err == -EAGAIN && - bus_reset_handling == SUCCEED_ON_BUS_RESET) - err = 0; - return err; - } - - if (buffer[0] == old_arg) /* success? */ - break; - - if (check) { - err = check(c, buffer[0]); - if (err < 0) - return err; - } + buffer, 8); + + if (rcode == RCODE_COMPLETE) { + if (buffer[0] == old_arg) /* success? */ + break; + + if (check) { + err = check(c, buffer[0]); + if (err < 0) + return err; + } + } else if (rcode == RCODE_GENERATION) + goto bus_reset; + else if (rcode_is_permanent_error(rcode) || ++errors >= 3) + goto io_error; } c->last_pcr_value = buffer[1]; return 0; + +io_error: + cmp_error(c, "transaction failed: %s\n", fw_rcode_string(rcode)); + return -EIO; + +bus_reset: + return bus_reset_handling == ABORT_ON_BUS_RESET ? -EAGAIN : 0; } @@ -100,7 +108,7 @@ int cmp_connection_init(struct cmp_connection *c, err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, CSR_REGISTER_BASE + CSR_IMPR, - &impr_be, 4, 0); + &impr_be, 4); if (err < 0) return err; impr = be32_to_cpu(impr_be); diff --git a/sound/firewire/dice-interface.h b/sound/firewire/dice-interface.h deleted file mode 100644 index 27b044f..0000000 --- a/sound/firewire/dice-interface.h +++ /dev/null @@ -1,371 +0,0 @@ -#ifndef SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED -#define SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED - -/* - * DICE device interface definitions - */ - -/* - * Generally, all registers can be read like memory, i.e., with quadlet read or - * block read transactions with at least quadlet-aligned offset and length. - * Writes are not allowed except where noted; quadlet-sized registers must be - * written with a quadlet write transaction. - * - * All values are in big endian. The DICE firmware runs on a little-endian CPU - * and just byte-swaps _all_ quadlets on the bus, so values without endianness - * (e.g. strings) get scrambled and must be byte-swapped again by the driver. - */ - -/* - * Streaming is handled by the "DICE driver" interface. Its registers are - * located in this private address space. - */ -#define DICE_PRIVATE_SPACE 0xffffe0000000uLL - -/* - * The registers are organized in several sections, which are organized - * separately to allow them to be extended individually. Whether a register is - * supported can be detected by checking its offset against its section's size. - * - * The section offset values are relative to DICE_PRIVATE_SPACE; the offset/ - * size values are measured in quadlets. Read-only. - */ -#define DICE_GLOBAL_OFFSET 0x00 -#define DICE_GLOBAL_SIZE 0x04 -#define DICE_TX_OFFSET 0x08 -#define DICE_TX_SIZE 0x0c -#define DICE_RX_OFFSET 0x10 -#define DICE_RX_SIZE 0x14 -#define DICE_EXT_SYNC_OFFSET 0x18 -#define DICE_EXT_SYNC_SIZE 0x1c -#define DICE_UNUSED2_OFFSET 0x20 -#define DICE_UNUSED2_SIZE 0x24 - -/* - * Global settings. - */ - -/* - * Stores the full 64-bit address (node ID and offset in the node's address - * space) where the device will send notifications. Must be changed with - * a compare/swap transaction by the owner. This register is automatically - * cleared on a bus reset. - */ -#define GLOBAL_OWNER 0x000 -#define OWNER_NO_OWNER 0xffff000000000000uLL -#define OWNER_NODE_SHIFT 48 - -/* - * A bitmask with asynchronous events; read-only. When any event(s) happen, - * the bits of previous events are cleared, and the value of this register is - * also written to the address stored in the owner register. - */ -#define GLOBAL_NOTIFICATION 0x008 -/* Some registers in the Rx/Tx sections may have changed. */ -#define NOTIFY_RX_CFG_CHG 0x00000001 -#define NOTIFY_TX_CFG_CHG 0x00000002 -/* Lock status of the current clock source may have changed. */ -#define NOTIFY_LOCK_CHG 0x00000010 -/* Write to the clock select register has been finished. */ -#define NOTIFY_CLOCK_ACCEPTED 0x00000020 -/* Lock status of some clock source has changed. */ -#define NOTIFY_EXT_STATUS 0x00000040 -/* Other bits may be used for device-specific events. */ - -/* - * A name that can be customized for each device; read/write. Padded with zero - * bytes. Quadlets are byte-swapped. The encoding is whatever the host driver - * happens to be using. - */ -#define GLOBAL_NICK_NAME 0x00c -#define NICK_NAME_SIZE 64 - -/* - * The current sample rate and clock source; read/write. Whether a clock - * source or sample rate is supported is device-specific; the internal clock - * source is always available. Low/mid/high = up to 48/96/192 kHz. This - * register can be changed even while streams are running. - */ -#define GLOBAL_CLOCK_SELECT 0x04c -#define CLOCK_SOURCE_MASK 0x000000ff -#define CLOCK_SOURCE_AES1 0x00000000 -#define CLOCK_SOURCE_AES2 0x00000001 -#define CLOCK_SOURCE_AES3 0x00000002 -#define CLOCK_SOURCE_AES4 0x00000003 -#define CLOCK_SOURCE_AES_ANY 0x00000004 -#define CLOCK_SOURCE_ADAT 0x00000005 -#define CLOCK_SOURCE_TDIF 0x00000006 -#define CLOCK_SOURCE_WC 0x00000007 -#define CLOCK_SOURCE_ARX1 0x00000008 -#define CLOCK_SOURCE_ARX2 0x00000009 -#define CLOCK_SOURCE_ARX3 0x0000000a -#define CLOCK_SOURCE_ARX4 0x0000000b -#define CLOCK_SOURCE_INTERNAL 0x0000000c -#define CLOCK_RATE_MASK 0x0000ff00 -#define CLOCK_RATE_32000 0x00000000 -#define CLOCK_RATE_44100 0x00000100 -#define CLOCK_RATE_48000 0x00000200 -#define CLOCK_RATE_88200 0x00000300 -#define CLOCK_RATE_96000 0x00000400 -#define CLOCK_RATE_176400 0x00000500 -#define CLOCK_RATE_192000 0x00000600 -#define CLOCK_RATE_ANY_LOW 0x00000700 -#define CLOCK_RATE_ANY_MID 0x00000800 -#define CLOCK_RATE_ANY_HIGH 0x00000900 -#define CLOCK_RATE_NONE 0x00000a00 -#define CLOCK_RATE_SHIFT 8 - -/* - * Enable streaming; read/write. Writing a non-zero value (re)starts all - * streams that have a valid iso channel set; zero stops all streams. The - * streams' parameters must be configured before starting. This register is - * automatically cleared on a bus reset. - */ -#define GLOBAL_ENABLE 0x050 - -/* - * Status of the sample clock; read-only. - */ -#define GLOBAL_STATUS 0x054 -/* The current clock source is locked. */ -#define STATUS_SOURCE_LOCKED 0x00000001 -/* The actual sample rate; CLOCK_RATE_32000-_192000 or _NONE. */ -#define STATUS_NOMINAL_RATE_MASK 0x0000ff00 - -/* - * Status of all clock sources; read-only. - */ -#define GLOBAL_EXTENDED_STATUS 0x058 -/* - * The _LOCKED bits always show the current status; any change generates - * a notification. - */ -#define EXT_STATUS_AES1_LOCKED 0x00000001 -#define EXT_STATUS_AES2_LOCKED 0x00000002 -#define EXT_STATUS_AES3_LOCKED 0x00000004 -#define EXT_STATUS_AES4_LOCKED 0x00000008 -#define EXT_STATUS_ADAT_LOCKED 0x00000010 -#define EXT_STATUS_TDIF_LOCKED 0x00000020 -#define EXT_STATUS_ARX1_LOCKED 0x00000040 -#define EXT_STATUS_ARX2_LOCKED 0x00000080 -#define EXT_STATUS_ARX3_LOCKED 0x00000100 -#define EXT_STATUS_ARX4_LOCKED 0x00000200 -#define EXT_STATUS_WC_LOCKED 0x00000400 -/* - * The _SLIP bits do not generate notifications; a set bit indicates that an - * error occurred since the last time when this register was read with - * a quadlet read transaction. - */ -#define EXT_STATUS_AES1_SLIP 0x00010000 -#define EXT_STATUS_AES2_SLIP 0x00020000 -#define EXT_STATUS_AES3_SLIP 0x00040000 -#define EXT_STATUS_AES4_SLIP 0x00080000 -#define EXT_STATUS_ADAT_SLIP 0x00100000 -#define EXT_STATUS_TDIF_SLIP 0x00200000 -#define EXT_STATUS_ARX1_SLIP 0x00400000 -#define EXT_STATUS_ARX2_SLIP 0x00800000 -#define EXT_STATUS_ARX3_SLIP 0x01000000 -#define EXT_STATUS_ARX4_SLIP 0x02000000 -#define EXT_STATUS_WC_SLIP 0x04000000 - -/* - * The measured rate of the current clock source, in Hz; read-only. - */ -#define GLOBAL_SAMPLE_RATE 0x05c - -/* - * The version of the DICE driver specification that this device conforms to; - * read-only. - */ -#define GLOBAL_VERSION 0x060 - -/* Some old firmware versions do not have the following global registers: */ - -/* - * Supported sample rates and clock sources; read-only. - */ -#define GLOBAL_CLOCK_CAPABILITIES 0x064 -#define CLOCK_CAP_RATE_32000 0x00000001 -#define CLOCK_CAP_RATE_44100 0x00000002 -#define CLOCK_CAP_RATE_48000 0x00000004 -#define CLOCK_CAP_RATE_88200 0x00000008 -#define CLOCK_CAP_RATE_96000 0x00000010 -#define CLOCK_CAP_RATE_176400 0x00000020 -#define CLOCK_CAP_RATE_192000 0x00000040 -#define CLOCK_CAP_SOURCE_AES1 0x00010000 -#define CLOCK_CAP_SOURCE_AES2 0x00020000 -#define CLOCK_CAP_SOURCE_AES3 0x00040000 -#define CLOCK_CAP_SOURCE_AES4 0x00080000 -#define CLOCK_CAP_SOURCE_AES_ANY 0x00100000 -#define CLOCK_CAP_SOURCE_ADAT 0x00200000 -#define CLOCK_CAP_SOURCE_TDIF 0x00400000 -#define CLOCK_CAP_SOURCE_WC 0x00800000 -#define CLOCK_CAP_SOURCE_ARX1 0x01000000 -#define CLOCK_CAP_SOURCE_ARX2 0x02000000 -#define CLOCK_CAP_SOURCE_ARX3 0x04000000 -#define CLOCK_CAP_SOURCE_ARX4 0x08000000 -#define CLOCK_CAP_SOURCE_INTERNAL 0x10000000 - -/* - * Names of all clock sources; read-only. Quadlets are byte-swapped. Names - * are separated with one backslash, the list is terminated with two - * backslashes. Unused clock sources are included. - */ -#define GLOBAL_CLOCK_SOURCE_NAMES 0x068 -#define CLOCK_SOURCE_NAMES_SIZE 256 - -/* - * Capture stream settings. This section includes the number/size registers - * and the registers of all streams. - */ - -/* - * The number of supported capture streams; read-only. - */ -#define TX_NUMBER 0x000 - -/* - * The size of one stream's register block, in quadlets; read-only. The - * registers of the first stream follow immediately afterwards; the registers - * of the following streams are offset by this register's value. - */ -#define TX_SIZE 0x004 - -/* - * The isochronous channel number on which packets are sent, or -1 if the - * stream is not to be used; read/write. - */ -#define TX_ISOCHRONOUS 0x008 - -/* - * The number of audio channels; read-only. There will be one quadlet per - * channel; the first channel is the first quadlet in a data block. - */ -#define TX_NUMBER_AUDIO 0x00c - -/* - * The number of MIDI ports, 0-8; read-only. If > 0, there will be one - * additional quadlet in each data block, following the audio quadlets. - */ -#define TX_NUMBER_MIDI 0x010 - -/* - * The speed at which the packets are sent, SCODE_100-_400; read/write. - */ -#define TX_SPEED 0x014 - -/* - * Names of all audio channels; read-only. Quadlets are byte-swapped. Names - * are separated with one backslash, the list is terminated with two - * backslashes. - */ -#define TX_NAMES 0x018 -#define TX_NAMES_SIZE 256 - -/* - * Audio IEC60958 capabilities; read-only. Bitmask with one bit per audio - * channel. - */ -#define TX_AC3_CAPABILITIES 0x118 - -/* - * Send audio data with IEC60958 label; read/write. Bitmask with one bit per - * audio channel. This register can be changed even while the stream is - * running. - */ -#define TX_AC3_ENABLE 0x11c - -/* - * Playback stream settings. This section includes the number/size registers - * and the registers of all streams. - */ - -/* - * The number of supported playback streams; read-only. - */ -#define RX_NUMBER 0x000 - -/* - * The size of one stream's register block, in quadlets; read-only. The - * registers of the first stream follow immediately afterwards; the registers - * of the following streams are offset by this register's value. - */ -#define RX_SIZE 0x004 - -/* - * The isochronous channel number on which packets are received, or -1 if the - * stream is not to be used; read/write. - */ -#define RX_ISOCHRONOUS 0x008 - -/* - * Index of first quadlet to be interpreted; read/write. If > 0, that many - * quadlets at the beginning of each data block will be ignored, and all the - * audio and MIDI quadlets will follow. - */ -#define RX_SEQ_START 0x00c - -/* - * The number of audio channels; read-only. There will be one quadlet per - * channel. - */ -#define RX_NUMBER_AUDIO 0x010 - -/* - * The number of MIDI ports, 0-8; read-only. If > 0, there will be one - * additional quadlet in each data block, following the audio quadlets. - */ -#define RX_NUMBER_MIDI 0x014 - -/* - * Names of all audio channels; read-only. Quadlets are byte-swapped. Names - * are separated with one backslash, the list is terminated with two - * backslashes. - */ -#define RX_NAMES 0x018 -#define RX_NAMES_SIZE 256 - -/* - * Audio IEC60958 capabilities; read-only. Bitmask with one bit per audio - * channel. - */ -#define RX_AC3_CAPABILITIES 0x118 - -/* - * Receive audio data with IEC60958 label; read/write. Bitmask with one bit - * per audio channel. This register can be changed even while the stream is - * running. - */ -#define RX_AC3_ENABLE 0x11c - -/* - * Extended synchronization information. - * This section can be read completely with a block read request. - */ - -/* - * Current clock source; read-only. - */ -#define EXT_SYNC_CLOCK_SOURCE 0x000 - -/* - * Clock source is locked (boolean); read-only. - */ -#define EXT_SYNC_LOCKED 0x004 - -/* - * Current sample rate (CLOCK_RATE_* >> CLOCK_RATE_SHIFT), _32000-_192000 or - * _NONE; read-only. - */ -#define EXT_SYNC_RATE 0x008 - -/* - * ADAT user data bits; read-only. - */ -#define EXT_SYNC_ADAT_USER_DATA 0x00c -/* The data bits, if available. */ -#define ADAT_USER_DATA_MASK 0x0f -/* The data bits are not available. */ -#define ADAT_USER_DATA_NO_DATA 0x10 - -#endif diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c deleted file mode 100644 index c0aa649..0000000 --- a/sound/firewire/dice.c +++ /dev/null @@ -1,1494 +0,0 @@ -/* - * TC Applied Technologies Digital Interface Communications Engine driver - * - * Copyright (c) Clemens Ladisch <clemens@ladisch.de> - * Licensed under the terms of the GNU General Public License, version 2. - */ - -#include <linux/compat.h> -#include <linux/completion.h> -#include <linux/delay.h> -#include <linux/device.h> -#include <linux/firewire.h> -#include <linux/firewire-constants.h> -#include <linux/jiffies.h> -#include <linux/module.h> -#include <linux/mod_devicetable.h> -#include <linux/mutex.h> -#include <linux/slab.h> -#include <linux/spinlock.h> -#include <linux/wait.h> -#include <sound/control.h> -#include <sound/core.h> -#include <sound/firewire.h> -#include <sound/hwdep.h> -#include <sound/info.h> -#include <sound/initval.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include "amdtp.h" -#include "iso-resources.h" -#include "lib.h" -#include "dice-interface.h" - - -struct dice { - struct snd_card *card; - struct fw_unit *unit; - spinlock_t lock; - struct mutex mutex; - unsigned int global_offset; - unsigned int rx_offset; - unsigned int clock_caps; - unsigned int rx_channels[3]; - unsigned int rx_midi_ports[3]; - struct fw_address_handler notification_handler; - int owner_generation; - int dev_lock_count; /* > 0 driver, < 0 userspace */ - bool dev_lock_changed; - bool global_enabled; - struct completion clock_accepted; - wait_queue_head_t hwdep_wait; - u32 notification_bits; - struct fw_iso_resources resources; - struct amdtp_out_stream stream; -}; - -MODULE_DESCRIPTION("DICE driver"); -MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); -MODULE_LICENSE("GPL v2"); - -static const unsigned int dice_rates[] = { - /* mode 0 */ - [0] = 32000, - [1] = 44100, - [2] = 48000, - /* mode 1 */ - [3] = 88200, - [4] = 96000, - /* mode 2 */ - [5] = 176400, - [6] = 192000, -}; - -static unsigned int rate_to_index(unsigned int rate) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) - if (dice_rates[i] == rate) - return i; - - return 0; -} - -static unsigned int rate_index_to_mode(unsigned int rate_index) -{ - return ((int)rate_index - 1) / 2; -} - -static void dice_lock_changed(struct dice *dice) -{ - dice->dev_lock_changed = true; - wake_up(&dice->hwdep_wait); -} - -static int dice_try_lock(struct dice *dice) -{ - int err; - - spin_lock_irq(&dice->lock); - - if (dice->dev_lock_count < 0) { - err = -EBUSY; - goto out; - } - - if (dice->dev_lock_count++ == 0) - dice_lock_changed(dice); - err = 0; - -out: - spin_unlock_irq(&dice->lock); - - return err; -} - -static void dice_unlock(struct dice *dice) -{ - spin_lock_irq(&dice->lock); - - if (WARN_ON(dice->dev_lock_count <= 0)) - goto out; - - if (--dice->dev_lock_count == 0) - dice_lock_changed(dice); - -out: - spin_unlock_irq(&dice->lock); -} - -static inline u64 global_address(struct dice *dice, unsigned int offset) -{ - return DICE_PRIVATE_SPACE + dice->global_offset + offset; -} - -// TODO: rx index -static inline u64 rx_address(struct dice *dice, unsigned int offset) -{ - return DICE_PRIVATE_SPACE + dice->rx_offset + offset; -} - -static int dice_owner_set(struct dice *dice) -{ - struct fw_device *device = fw_parent_device(dice->unit); - __be64 *buffer; - int err, errors = 0; - - buffer = kmalloc(2 * 8, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - for (;;) { - buffer[0] = cpu_to_be64(OWNER_NO_OWNER); - buffer[1] = cpu_to_be64( - ((u64)device->card->node_id << OWNER_NODE_SHIFT) | - dice->notification_handler.offset); - - dice->owner_generation = device->generation; - smp_rmb(); /* node_id vs. generation */ - err = snd_fw_transaction(dice->unit, - TCODE_LOCK_COMPARE_SWAP, - global_address(dice, GLOBAL_OWNER), - buffer, 2 * 8, - FW_FIXED_GENERATION | - dice->owner_generation); - - if (err == 0) { - if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) { - dev_err(&dice->unit->device, - "device is already in use\n"); - err = -EBUSY; - } - break; - } - if (err != -EAGAIN || ++errors >= 3) - break; - - msleep(20); - } - - kfree(buffer); - - return err; -} - -static int dice_owner_update(struct dice *dice) -{ - struct fw_device *device = fw_parent_device(dice->unit); - __be64 *buffer; - int err; - - if (dice->owner_generation == -1) - return 0; - - buffer = kmalloc(2 * 8, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - buffer[0] = cpu_to_be64(OWNER_NO_OWNER); - buffer[1] = cpu_to_be64( - ((u64)device->card->node_id << OWNER_NODE_SHIFT) | - dice->notification_handler.offset); - - dice->owner_generation = device->generation; - smp_rmb(); /* node_id vs. generation */ - err = snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, - global_address(dice, GLOBAL_OWNER), - buffer, 2 * 8, - FW_FIXED_GENERATION | dice->owner_generation); - - if (err == 0) { - if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) { - dev_err(&dice->unit->device, - "device is already in use\n"); - err = -EBUSY; - } - } else if (err == -EAGAIN) { - err = 0; /* try again later */ - } - - kfree(buffer); - - if (err < 0) - dice->owner_generation = -1; - - return err; -} - -static void dice_owner_clear(struct dice *dice) -{ - struct fw_device *device = fw_parent_device(dice->unit); - __be64 *buffer; - - buffer = kmalloc(2 * 8, GFP_KERNEL); - if (!buffer) - return; - - buffer[0] = cpu_to_be64( - ((u64)device->card->node_id << OWNER_NODE_SHIFT) | - dice->notification_handler.offset); - buffer[1] = cpu_to_be64(OWNER_NO_OWNER); - snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, - global_address(dice, GLOBAL_OWNER), - buffer, 2 * 8, FW_QUIET | - FW_FIXED_GENERATION | dice->owner_generation); - - kfree(buffer); - - dice->owner_generation = -1; -} - -static int dice_enable_set(struct dice *dice) -{ - __be32 value; - int err; - - value = cpu_to_be32(1); - err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, - global_address(dice, GLOBAL_ENABLE), - &value, 4, - FW_FIXED_GENERATION | dice->owner_generation); - if (err < 0) - return err; - - dice->global_enabled = true; - - return 0; -} - -static void dice_enable_clear(struct dice *dice) -{ - __be32 value; - - if (!dice->global_enabled) - return; - - value = 0; - snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, - global_address(dice, GLOBAL_ENABLE), - &value, 4, FW_QUIET | - FW_FIXED_GENERATION | dice->owner_generation); - - dice->global_enabled = false; -} - -static void dice_notification(struct fw_card *card, struct fw_request *request, - int tcode, int destination, int source, - int generation, unsigned long long offset, - void *data, size_t length, void *callback_data) -{ - struct dice *dice = callback_data; - u32 bits; - unsigned long flags; - - if (tcode != TCODE_WRITE_QUADLET_REQUEST) { - fw_send_response(card, request, RCODE_TYPE_ERROR); - return; - } - if ((offset & 3) != 0) { - fw_send_response(card, request, RCODE_ADDRESS_ERROR); - return; - } - - bits = be32_to_cpup(data); - - spin_lock_irqsave(&dice->lock, flags); - dice->notification_bits |= bits; - spin_unlock_irqrestore(&dice->lock, flags); - - fw_send_response(card, request, RCODE_COMPLETE); - - if (bits & NOTIFY_CLOCK_ACCEPTED) - complete(&dice->clock_accepted); - wake_up(&dice->hwdep_wait); -} - -static int dice_rate_constraint(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct dice *dice = rule->private; - const struct snd_interval *channels = - hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS); - struct snd_interval *rate = - hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval allowed_rates = { - .min = UINT_MAX, .max = 0, .integer = 1 - }; - unsigned int i, mode; - - for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) { - mode = rate_index_to_mode(i); - if ((dice->clock_caps & (1 << i)) && - snd_interval_test(channels, dice->rx_channels[mode])) { - allowed_rates.min = min(allowed_rates.min, - dice_rates[i]); - allowed_rates.max = max(allowed_rates.max, - dice_rates[i]); - } - } - - return snd_interval_refine(rate, &allowed_rates); -} - -static int dice_channels_constraint(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct dice *dice = rule->private; - const struct snd_interval *rate = - hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = - hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - struct snd_interval allowed_channels = { - .min = UINT_MAX, .max = 0, .integer = 1 - }; - unsigned int i, mode; - - for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) - if ((dice->clock_caps & (1 << i)) && - snd_interval_test(rate, dice_rates[i])) { - mode = rate_index_to_mode(i); - allowed_channels.min = min(allowed_channels.min, - dice->rx_channels[mode]); - allowed_channels.max = max(allowed_channels.max, - dice->rx_channels[mode]); - } - - return snd_interval_refine(channels, &allowed_channels); -} - -static int dice_open(struct snd_pcm_substream *substream) -{ - static const struct snd_pcm_hardware hardware = { - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_BATCH | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER, - .formats = AMDTP_OUT_PCM_FORMAT_BITS, - .channels_min = UINT_MAX, - .channels_max = 0, - .buffer_bytes_max = 16 * 1024 * 1024, - .period_bytes_min = 1, - .period_bytes_max = UINT_MAX, - .periods_min = 1, - .periods_max = UINT_MAX, - }; - struct dice *dice = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int i; - int err; - - err = dice_try_lock(dice); - if (err < 0) - goto error; - - runtime->hw = hardware; - - for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) - if (dice->clock_caps & (1 << i)) - runtime->hw.rates |= - snd_pcm_rate_to_rate_bit(dice_rates[i]); - snd_pcm_limit_hw_rates(runtime); - - for (i = 0; i < 3; ++i) - if (dice->rx_channels[i]) { - runtime->hw.channels_min = min(runtime->hw.channels_min, - dice->rx_channels[i]); - runtime->hw.channels_max = max(runtime->hw.channels_max, - dice->rx_channels[i]); - } - - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - dice_rate_constraint, dice, - SNDRV_PCM_HW_PARAM_CHANNELS, -1); - if (err < 0) - goto err_lock; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, - dice_channels_constraint, dice, - SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - goto err_lock; - - err = snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32); - if (err < 0) - goto err_lock; - err = snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32); - if (err < 0) - goto err_lock; - - err = snd_pcm_hw_constraint_minmax(runtime, - SNDRV_PCM_HW_PARAM_PERIOD_TIME, - 5000, UINT_MAX); - if (err < 0) - goto err_lock; - - err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); - if (err < 0) - goto err_lock; - - return 0; - -err_lock: - dice_unlock(dice); -error: - return err; -} - -static int dice_close(struct snd_pcm_substream *substream) -{ - struct dice *dice = substream->private_data; - - dice_unlock(dice); - - return 0; -} - -static int dice_stream_start_packets(struct dice *dice) -{ - int err; - - if (amdtp_out_stream_running(&dice->stream)) - return 0; - - err = amdtp_out_stream_start(&dice->stream, dice->resources.channel, - fw_parent_device(dice->unit)->max_speed); - if (err < 0) - return err; - - err = dice_enable_set(dice); - if (err < 0) { - amdtp_out_stream_stop(&dice->stream); - return err; - } - - return 0; -} - -static int dice_stream_start(struct dice *dice) -{ - __be32 channel; - int err; - - if (!dice->resources.allocated) { - err = fw_iso_resources_allocate(&dice->resources, - amdtp_out_stream_get_max_payload(&dice->stream), - fw_parent_device(dice->unit)->max_speed); - if (err < 0) - goto error; - - channel = cpu_to_be32(dice->resources.channel); - err = snd_fw_transaction(dice->unit, - TCODE_WRITE_QUADLET_REQUEST, - rx_address(dice, RX_ISOCHRONOUS), - &channel, 4, 0); - if (err < 0) - goto err_resources; - } - - err = dice_stream_start_packets(dice); - if (err < 0) - goto err_rx_channel; - - return 0; - -err_rx_channel: - channel = cpu_to_be32((u32)-1); - snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, - rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0); -err_resources: - fw_iso_resources_free(&dice->resources); -error: - return err; -} - -static void dice_stream_stop_packets(struct dice *dice) -{ - if (amdtp_out_stream_running(&dice->stream)) { - dice_enable_clear(dice); - amdtp_out_stream_stop(&dice->stream); - } -} - -static void dice_stream_stop(struct dice *dice) -{ - __be32 channel; - - dice_stream_stop_packets(dice); - - if (!dice->resources.allocated) - return; - - channel = cpu_to_be32((u32)-1); - snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, - rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0); - - fw_iso_resources_free(&dice->resources); -} - -static int dice_change_rate(struct dice *dice, unsigned int clock_rate) -{ - __be32 value; - int err; - - reinit_completion(&dice->clock_accepted); - - value = cpu_to_be32(clock_rate | CLOCK_SOURCE_ARX1); - err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, - global_address(dice, GLOBAL_CLOCK_SELECT), - &value, 4, 0); - if (err < 0) - return err; - - if (!wait_for_completion_timeout(&dice->clock_accepted, - msecs_to_jiffies(100))) - dev_warn(&dice->unit->device, "clock change timed out\n"); - - return 0; -} - -static int dice_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - struct dice *dice = substream->private_data; - unsigned int rate_index, mode; - int err; - - mutex_lock(&dice->mutex); - dice_stream_stop(dice); - mutex_unlock(&dice->mutex); - - err = snd_pcm_lib_alloc_vmalloc_buffer(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - - rate_index = rate_to_index(params_rate(hw_params)); - err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT); - if (err < 0) - return err; - - mode = rate_index_to_mode(rate_index); - amdtp_out_stream_set_parameters(&dice->stream, - params_rate(hw_params), - params_channels(hw_params), - dice->rx_midi_ports[mode]); - amdtp_out_stream_set_pcm_format(&dice->stream, - params_format(hw_params)); - - return 0; -} - -static int dice_hw_free(struct snd_pcm_substream *substream) -{ - struct dice *dice = substream->private_data; - - mutex_lock(&dice->mutex); - dice_stream_stop(dice); - mutex_unlock(&dice->mutex); - - return snd_pcm_lib_free_vmalloc_buffer(substream); -} - -static int dice_prepare(struct snd_pcm_substream *substream) -{ - struct dice *dice = substream->private_data; - int err; - - mutex_lock(&dice->mutex); - - if (amdtp_out_streaming_error(&dice->stream)) - dice_stream_stop_packets(dice); - - err = dice_stream_start(dice); - if (err < 0) { - mutex_unlock(&dice->mutex); - return err; - } - - mutex_unlock(&dice->mutex); - - amdtp_out_stream_pcm_prepare(&dice->stream); - - return 0; -} - -static int dice_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct dice *dice = substream->private_data; - struct snd_pcm_substream *pcm; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - pcm = substream; - break; - case SNDRV_PCM_TRIGGER_STOP: - pcm = NULL; - break; - default: - return -EINVAL; - } - amdtp_out_stream_pcm_trigger(&dice->stream, pcm); - - return 0; -} - -static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream) -{ - struct dice *dice = substream->private_data; - - return amdtp_out_stream_pcm_pointer(&dice->stream); -} - -static int dice_create_pcm(struct dice *dice) -{ - static struct snd_pcm_ops ops = { - .open = dice_open, - .close = dice_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = dice_hw_params, - .hw_free = dice_hw_free, - .prepare = dice_prepare, - .trigger = dice_trigger, - .pointer = dice_pointer, - .page = snd_pcm_lib_get_vmalloc_page, - .mmap = snd_pcm_lib_mmap_vmalloc, - }; - struct snd_pcm *pcm; - int err; - - err = snd_pcm_new(dice->card, "DICE", 0, 1, 0, &pcm); - if (err < 0) - return err; - pcm->private_data = dice; - strcpy(pcm->name, dice->card->shortname); - pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->ops = &ops; - - return 0; -} - -static long dice_hwdep_read(struct snd_hwdep *hwdep, char __user *buf, - long count, loff_t *offset) -{ - struct dice *dice = hwdep->private_data; - DEFINE_WAIT(wait); - union snd_firewire_event event; - - spin_lock_irq(&dice->lock); - - while (!dice->dev_lock_changed && dice->notification_bits == 0) { - prepare_to_wait(&dice->hwdep_wait, &wait, TASK_INTERRUPTIBLE); - spin_unlock_irq(&dice->lock); - schedule(); - finish_wait(&dice->hwdep_wait, &wait); - if (signal_pending(current)) - return -ERESTARTSYS; - spin_lock_irq(&dice->lock); - } - - memset(&event, 0, sizeof(event)); - if (dice->dev_lock_changed) { - event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; - event.lock_status.status = dice->dev_lock_count > 0; - dice->dev_lock_changed = false; - - count = min(count, (long)sizeof(event.lock_status)); - } else { - event.dice_notification.type = SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION; - event.dice_notification.notification = dice->notification_bits; - dice->notification_bits = 0; - - count = min(count, (long)sizeof(event.dice_notification)); - } - - spin_unlock_irq(&dice->lock); - - if (copy_to_user(buf, &event, count)) - return -EFAULT; - - return count; -} - -static unsigned int dice_hwdep_poll(struct snd_hwdep *hwdep, struct file *file, - poll_table *wait) -{ - struct dice *dice = hwdep->private_data; - unsigned int events; - - poll_wait(file, &dice->hwdep_wait, wait); - - spin_lock_irq(&dice->lock); - if (dice->dev_lock_changed || dice->notification_bits != 0) - events = POLLIN | POLLRDNORM; - else - events = 0; - spin_unlock_irq(&dice->lock); - - return events; -} - -static int dice_hwdep_get_info(struct dice *dice, void __user *arg) -{ - struct fw_device *dev = fw_parent_device(dice->unit); - struct snd_firewire_get_info info; - - memset(&info, 0, sizeof(info)); - info.type = SNDRV_FIREWIRE_TYPE_DICE; - info.card = dev->card->index; - *(__be32 *)&info.guid[0] = cpu_to_be32(dev->config_rom[3]); - *(__be32 *)&info.guid[4] = cpu_to_be32(dev->config_rom[4]); - strlcpy(info.device_name, dev_name(&dev->device), - sizeof(info.device_name)); - - if (copy_to_user(arg, &info, sizeof(info))) - return -EFAULT; - - return 0; -} - -static int dice_hwdep_lock(struct dice *dice) -{ - int err; - - spin_lock_irq(&dice->lock); - - if (dice->dev_lock_count == 0) { - dice->dev_lock_count = -1; - err = 0; - } else { - err = -EBUSY; - } - - spin_unlock_irq(&dice->lock); - - return err; -} - -static int dice_hwdep_unlock(struct dice *dice) -{ - int err; - - spin_lock_irq(&dice->lock); - - if (dice->dev_lock_count == -1) { - dice->dev_lock_count = 0; - err = 0; - } else { - err = -EBADFD; - } - - spin_unlock_irq(&dice->lock); - - return err; -} - -static int dice_hwdep_release(struct snd_hwdep *hwdep, struct file *file) -{ - struct dice *dice = hwdep->private_data; - - spin_lock_irq(&dice->lock); - if (dice->dev_lock_count == -1) - dice->dev_lock_count = 0; - spin_unlock_irq(&dice->lock); - - return 0; -} - -static int dice_hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct dice *dice = hwdep->private_data; - - switch (cmd) { - case SNDRV_FIREWIRE_IOCTL_GET_INFO: - return dice_hwdep_get_info(dice, (void __user *)arg); - case SNDRV_FIREWIRE_IOCTL_LOCK: - return dice_hwdep_lock(dice); - case SNDRV_FIREWIRE_IOCTL_UNLOCK: - return dice_hwdep_unlock(dice); - default: - return -ENOIOCTLCMD; - } -} - -#ifdef CONFIG_COMPAT -static int dice_hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file, - unsigned int cmd, unsigned long arg) -{ - return dice_hwdep_ioctl(hwdep, file, cmd, - (unsigned long)compat_ptr(arg)); -} -#else -#define dice_hwdep_compat_ioctl NULL -#endif - -static int dice_create_hwdep(struct dice *dice) -{ - static const struct snd_hwdep_ops ops = { - .read = dice_hwdep_read, - .release = dice_hwdep_release, - .poll = dice_hwdep_poll, - .ioctl = dice_hwdep_ioctl, - .ioctl_compat = dice_hwdep_compat_ioctl, - }; - struct snd_hwdep *hwdep; - int err; - - err = snd_hwdep_new(dice->card, "DICE", 0, &hwdep); - if (err < 0) - return err; - strcpy(hwdep->name, "DICE"); - hwdep->iface = SNDRV_HWDEP_IFACE_FW_DICE; - hwdep->ops = ops; - hwdep->private_data = dice; - hwdep->exclusive = true; - - return 0; -} - -static int dice_proc_read_mem(struct dice *dice, void *buffer, - unsigned int offset_q, unsigned int quadlets) -{ - unsigned int i; - int err; - - err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, - DICE_PRIVATE_SPACE + 4 * offset_q, - buffer, 4 * quadlets, 0); - if (err < 0) - return err; - - for (i = 0; i < quadlets; ++i) - be32_to_cpus(&((u32 *)buffer)[i]); - - return 0; -} - -static const char *str_from_array(const char *const strs[], unsigned int count, - unsigned int i) -{ - if (i < count) - return strs[i]; - else - return "(unknown)"; -} - -static void dice_proc_fixup_string(char *s, unsigned int size) -{ - unsigned int i; - - for (i = 0; i < size; i += 4) - cpu_to_le32s((u32 *)(s + i)); - - for (i = 0; i < size - 2; ++i) { - if (s[i] == '\0') - return; - if (s[i] == '\\' && s[i + 1] == '\\') { - s[i + 2] = '\0'; - return; - } - } - s[size - 1] = '\0'; -} - -static void dice_proc_read(struct snd_info_entry *entry, - struct snd_info_buffer *buffer) -{ - static const char *const section_names[5] = { - "global", "tx", "rx", "ext_sync", "unused2" - }; - static const char *const clock_sources[] = { - "aes1", "aes2", "aes3", "aes4", "aes", "adat", "tdif", - "wc", "arx1", "arx2", "arx3", "arx4", "internal" - }; - static const char *const rates[] = { - "32000", "44100", "48000", "88200", "96000", "176400", "192000", - "any low", "any mid", "any high", "none" - }; - struct dice *dice = entry->private_data; - u32 sections[ARRAY_SIZE(section_names) * 2]; - struct { - u32 number; - u32 size; - } tx_rx_header; - union { - struct { - u32 owner_hi, owner_lo; - u32 notification; - char nick_name[NICK_NAME_SIZE]; - u32 clock_select; - u32 enable; - u32 status; - u32 extended_status; - u32 sample_rate; - u32 version; - u32 clock_caps; - char clock_source_names[CLOCK_SOURCE_NAMES_SIZE]; - } global; - struct { - u32 iso; - u32 number_audio; - u32 number_midi; - u32 speed; - char names[TX_NAMES_SIZE]; - u32 ac3_caps; - u32 ac3_enable; - } tx; - struct { - u32 iso; - u32 seq_start; - u32 number_audio; - u32 number_midi; - char names[RX_NAMES_SIZE]; - u32 ac3_caps; - u32 ac3_enable; - } rx; - struct { - u32 clock_source; - u32 locked; - u32 rate; - u32 adat_user_data; - } ext_sync; - } buf; - unsigned int quadlets, stream, i; - - if (dice_proc_read_mem(dice, sections, 0, ARRAY_SIZE(sections)) < 0) - return; - snd_iprintf(buffer, "sections:\n"); - for (i = 0; i < ARRAY_SIZE(section_names); ++i) - snd_iprintf(buffer, " %s: offset %u, size %u\n", - section_names[i], - sections[i * 2], sections[i * 2 + 1]); - - quadlets = min_t(u32, sections[1], sizeof(buf.global) / 4); - if (dice_proc_read_mem(dice, &buf.global, sections[0], quadlets) < 0) - return; - snd_iprintf(buffer, "global:\n"); - snd_iprintf(buffer, " owner: %04x:%04x%08x\n", - buf.global.owner_hi >> 16, - buf.global.owner_hi & 0xffff, buf.global.owner_lo); - snd_iprintf(buffer, " notification: %08x\n", buf.global.notification); - dice_proc_fixup_string(buf.global.nick_name, NICK_NAME_SIZE); - snd_iprintf(buffer, " nick name: %s\n", buf.global.nick_name); - snd_iprintf(buffer, " clock select: %s %s\n", - str_from_array(clock_sources, ARRAY_SIZE(clock_sources), - buf.global.clock_select & CLOCK_SOURCE_MASK), - str_from_array(rates, ARRAY_SIZE(rates), - (buf.global.clock_select & CLOCK_RATE_MASK) - >> CLOCK_RATE_SHIFT)); - snd_iprintf(buffer, " enable: %u\n", buf.global.enable); - snd_iprintf(buffer, " status: %slocked %s\n", - buf.global.status & STATUS_SOURCE_LOCKED ? "" : "un", - str_from_array(rates, ARRAY_SIZE(rates), - (buf.global.status & - STATUS_NOMINAL_RATE_MASK) - >> CLOCK_RATE_SHIFT)); - snd_iprintf(buffer, " ext status: %08x\n", buf.global.extended_status); - snd_iprintf(buffer, " sample rate: %u\n", buf.global.sample_rate); - snd_iprintf(buffer, " version: %u.%u.%u.%u\n", - (buf.global.version >> 24) & 0xff, - (buf.global.version >> 16) & 0xff, - (buf.global.version >> 8) & 0xff, - (buf.global.version >> 0) & 0xff); - if (quadlets >= 90) { - snd_iprintf(buffer, " clock caps:"); - for (i = 0; i <= 6; ++i) - if (buf.global.clock_caps & (1 << i)) - snd_iprintf(buffer, " %s", rates[i]); - for (i = 0; i <= 12; ++i) - if (buf.global.clock_caps & (1 << (16 + i))) - snd_iprintf(buffer, " %s", clock_sources[i]); - snd_iprintf(buffer, "\n"); - dice_proc_fixup_string(buf.global.clock_source_names, - CLOCK_SOURCE_NAMES_SIZE); - snd_iprintf(buffer, " clock source names: %s\n", - buf.global.clock_source_names); - } - - if (dice_proc_read_mem(dice, &tx_rx_header, sections[2], 2) < 0) - return; - quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.tx) / 4); - for (stream = 0; stream < tx_rx_header.number; ++stream) { - if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + - stream * tx_rx_header.size, - quadlets) < 0) - break; - snd_iprintf(buffer, "tx %u:\n", stream); - snd_iprintf(buffer, " iso channel: %d\n", (int)buf.tx.iso); - snd_iprintf(buffer, " audio channels: %u\n", - buf.tx.number_audio); - snd_iprintf(buffer, " midi ports: %u\n", buf.tx.number_midi); - snd_iprintf(buffer, " speed: S%u\n", 100u << buf.tx.speed); - if (quadlets >= 68) { - dice_proc_fixup_string(buf.tx.names, TX_NAMES_SIZE); - snd_iprintf(buffer, " names: %s\n", buf.tx.names); - } - if (quadlets >= 70) { - snd_iprintf(buffer, " ac3 caps: %08x\n", - buf.tx.ac3_caps); - snd_iprintf(buffer, " ac3 enable: %08x\n", - buf.tx.ac3_enable); - } - } - - if (dice_proc_read_mem(dice, &tx_rx_header, sections[4], 2) < 0) - return; - quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.rx) / 4); - for (stream = 0; stream < tx_rx_header.number; ++stream) { - if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + - stream * tx_rx_header.size, - quadlets) < 0) - break; - snd_iprintf(buffer, "rx %u:\n", stream); - snd_iprintf(buffer, " iso channel: %d\n", (int)buf.rx.iso); - snd_iprintf(buffer, " sequence start: %u\n", buf.rx.seq_start); - snd_iprintf(buffer, " audio channels: %u\n", - buf.rx.number_audio); - snd_iprintf(buffer, " midi ports: %u\n", buf.rx.number_midi); - if (quadlets >= 68) { - dice_proc_fixup_string(buf.rx.names, RX_NAMES_SIZE); - snd_iprintf(buffer, " names: %s\n", buf.rx.names); - } - if (quadlets >= 70) { - snd_iprintf(buffer, " ac3 caps: %08x\n", - buf.rx.ac3_caps); - snd_iprintf(buffer, " ac3 enable: %08x\n", - buf.rx.ac3_enable); - } - } - - quadlets = min_t(u32, sections[7], sizeof(buf.ext_sync) / 4); - if (quadlets >= 4) { - if (dice_proc_read_mem(dice, &buf.ext_sync, - sections[6], 4) < 0) - return; - snd_iprintf(buffer, "ext status:\n"); - snd_iprintf(buffer, " clock source: %s\n", - str_from_array(clock_sources, - ARRAY_SIZE(clock_sources), - buf.ext_sync.clock_source)); - snd_iprintf(buffer, " locked: %u\n", buf.ext_sync.locked); - snd_iprintf(buffer, " rate: %s\n", - str_from_array(rates, ARRAY_SIZE(rates), - buf.ext_sync.rate)); - snd_iprintf(buffer, " adat user data: "); - if (buf.ext_sync.adat_user_data & ADAT_USER_DATA_NO_DATA) - snd_iprintf(buffer, "-\n"); - else - snd_iprintf(buffer, "%x\n", - buf.ext_sync.adat_user_data); - } -} - -static void dice_create_proc(struct dice *dice) -{ - struct snd_info_entry *entry; - - if (!snd_card_proc_new(dice->card, "dice", &entry)) - snd_info_set_text_ops(entry, dice, dice_proc_read); -} - -static void dice_card_free(struct snd_card *card) -{ - struct dice *dice = card->private_data; - - amdtp_out_stream_destroy(&dice->stream); - fw_core_remove_address_handler(&dice->notification_handler); - mutex_destroy(&dice->mutex); -} - -#define OUI_WEISS 0x001c6a - -#define DICE_CATEGORY_ID 0x04 -#define WEISS_CATEGORY_ID 0x00 - -static int dice_interface_check(struct fw_unit *unit) -{ - static const int min_values[10] = { - 10, 0x64 / 4, - 10, 0x18 / 4, - 10, 0x18 / 4, - 0, 0, - 0, 0, - }; - struct fw_device *device = fw_parent_device(unit); - struct fw_csr_iterator it; - int key, value, vendor = -1, model = -1, err; - unsigned int category, i; - __be32 pointers[ARRAY_SIZE(min_values)]; - __be32 tx_data[4]; - __be32 version; - - /* - * Check that GUID and unit directory are constructed according to DICE - * rules, i.e., that the specifier ID is the GUID's OUI, and that the - * GUID chip ID consists of the 8-bit category ID, the 10-bit product - * ID, and a 22-bit serial number. - */ - fw_csr_iterator_init(&it, unit->directory); - while (fw_csr_iterator_next(&it, &key, &value)) { - switch (key) { - case CSR_SPECIFIER_ID: - vendor = value; - break; - case CSR_MODEL: - model = value; - break; - } - } - if (vendor == OUI_WEISS) - category = WEISS_CATEGORY_ID; - else - category = DICE_CATEGORY_ID; - if (device->config_rom[3] != ((vendor << 8) | category) || - device->config_rom[4] >> 22 != model) - return -ENODEV; - - /* - * Check that the sub address spaces exist and are located inside the - * private address space. The minimum values are chosen so that all - * minimally required registers are included. - */ - err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST, - DICE_PRIVATE_SPACE, - pointers, sizeof(pointers), 0); - if (err < 0) - return -ENODEV; - for (i = 0; i < ARRAY_SIZE(pointers); ++i) { - value = be32_to_cpu(pointers[i]); - if (value < min_values[i] || value >= 0x40000) - return -ENODEV; - } - - /* We support playback only. Let capture devices be handled by FFADO. */ - err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST, - DICE_PRIVATE_SPACE + - be32_to_cpu(pointers[2]) * 4, - tx_data, sizeof(tx_data), 0); - if (err < 0 || (tx_data[0] && tx_data[3])) - return -ENODEV; - - /* - * Check that the implemented DICE driver specification major version - * number matches. - */ - err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, - DICE_PRIVATE_SPACE + - be32_to_cpu(pointers[0]) * 4 + GLOBAL_VERSION, - &version, 4, 0); - if (err < 0) - return -ENODEV; - if ((version & cpu_to_be32(0xff000000)) != cpu_to_be32(0x01000000)) { - dev_err(&unit->device, - "unknown DICE version: 0x%08x\n", be32_to_cpu(version)); - return -ENODEV; - } - - return 0; -} - -static int highest_supported_mode_rate(struct dice *dice, unsigned int mode) -{ - int i; - - for (i = ARRAY_SIZE(dice_rates) - 1; i >= 0; --i) - if ((dice->clock_caps & (1 << i)) && - rate_index_to_mode(i) == mode) - return i; - - return -1; -} - -static int dice_read_mode_params(struct dice *dice, unsigned int mode) -{ - __be32 values[2]; - int rate_index, err; - - rate_index = highest_supported_mode_rate(dice, mode); - if (rate_index < 0) { - dice->rx_channels[mode] = 0; - dice->rx_midi_ports[mode] = 0; - return 0; - } - - err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT); - if (err < 0) - return err; - - err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, - rx_address(dice, RX_NUMBER_AUDIO), - values, 2 * 4, 0); - if (err < 0) - return err; - - dice->rx_channels[mode] = be32_to_cpu(values[0]); - dice->rx_midi_ports[mode] = be32_to_cpu(values[1]); - - return 0; -} - -static int dice_read_params(struct dice *dice) -{ - __be32 pointers[6]; - __be32 value; - int mode, err; - - err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, - DICE_PRIVATE_SPACE, - pointers, sizeof(pointers), 0); - if (err < 0) - return err; - - dice->global_offset = be32_to_cpu(pointers[0]) * 4; - dice->rx_offset = be32_to_cpu(pointers[4]) * 4; - - /* some very old firmwares don't tell about their clock support */ - if (be32_to_cpu(pointers[1]) * 4 >= GLOBAL_CLOCK_CAPABILITIES + 4) { - err = snd_fw_transaction( - dice->unit, TCODE_READ_QUADLET_REQUEST, - global_address(dice, GLOBAL_CLOCK_CAPABILITIES), - &value, 4, 0); - if (err < 0) - return err; - dice->clock_caps = be32_to_cpu(value); - } else { - /* this should be supported by any device */ - dice->clock_caps = CLOCK_CAP_RATE_44100 | - CLOCK_CAP_RATE_48000 | - CLOCK_CAP_SOURCE_ARX1 | - CLOCK_CAP_SOURCE_INTERNAL; - } - - for (mode = 2; mode >= 0; --mode) { - err = dice_read_mode_params(dice, mode); - if (err < 0) - return err; - } - - return 0; -} - -static void dice_card_strings(struct dice *dice) -{ - struct snd_card *card = dice->card; - struct fw_device *dev = fw_parent_device(dice->unit); - char vendor[32], model[32]; - unsigned int i; - int err; - - strcpy(card->driver, "DICE"); - - strcpy(card->shortname, "DICE"); - BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname)); - err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, - global_address(dice, GLOBAL_NICK_NAME), - card->shortname, sizeof(card->shortname), 0); - if (err >= 0) { - /* DICE strings are returned in "always-wrong" endianness */ - BUILD_BUG_ON(sizeof(card->shortname) % 4 != 0); - for (i = 0; i < sizeof(card->shortname); i += 4) - swab32s((u32 *)&card->shortname[i]); - card->shortname[sizeof(card->shortname) - 1] = '\0'; - } - - strcpy(vendor, "?"); - fw_csr_string(dev->config_rom + 5, CSR_VENDOR, vendor, sizeof(vendor)); - strcpy(model, "?"); - fw_csr_string(dice->unit->directory, CSR_MODEL, model, sizeof(model)); - snprintf(card->longname, sizeof(card->longname), - "%s %s (serial %u) at %s, S%d", - vendor, model, dev->config_rom[4] & 0x3fffff, - dev_name(&dice->unit->device), 100 << dev->max_speed); - - strcpy(card->mixername, "DICE"); -} - -static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) -{ - struct snd_card *card; - struct dice *dice; - __be32 clock_sel; - int err; - - err = dice_interface_check(unit); - if (err < 0) - return err; - - err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*dice), &card); - if (err < 0) - return err; - snd_card_set_dev(card, &unit->device); - - dice = card->private_data; - dice->card = card; - spin_lock_init(&dice->lock); - mutex_init(&dice->mutex); - dice->unit = unit; - init_completion(&dice->clock_accepted); - init_waitqueue_head(&dice->hwdep_wait); - - dice->notification_handler.length = 4; - dice->notification_handler.address_callback = dice_notification; - dice->notification_handler.callback_data = dice; - err = fw_core_add_address_handler(&dice->notification_handler, - &fw_high_memory_region); - if (err < 0) - goto err_mutex; - - err = dice_owner_set(dice); - if (err < 0) - goto err_notification_handler; - - err = dice_read_params(dice); - if (err < 0) - goto err_owner; - - err = fw_iso_resources_init(&dice->resources, unit); - if (err < 0) - goto err_owner; - dice->resources.channels_mask = 0x00000000ffffffffuLL; - - err = amdtp_out_stream_init(&dice->stream, unit, - CIP_BLOCKING | CIP_HI_DUALWIRE); - if (err < 0) - goto err_resources; - - card->private_free = dice_card_free; - - dice_card_strings(dice); - - err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, - global_address(dice, GLOBAL_CLOCK_SELECT), - &clock_sel, 4, 0); - if (err < 0) - goto error; - clock_sel &= cpu_to_be32(~CLOCK_SOURCE_MASK); - clock_sel |= cpu_to_be32(CLOCK_SOURCE_ARX1); - err = snd_fw_transaction(unit, TCODE_WRITE_QUADLET_REQUEST, - global_address(dice, GLOBAL_CLOCK_SELECT), - &clock_sel, 4, 0); - if (err < 0) - goto error; - - err = dice_create_pcm(dice); - if (err < 0) - goto error; - - err = dice_create_hwdep(dice); - if (err < 0) - goto error; - - dice_create_proc(dice); - - err = snd_card_register(card); - if (err < 0) - goto error; - - dev_set_drvdata(&unit->device, dice); - - return 0; - -err_resources: - fw_iso_resources_destroy(&dice->resources); -err_owner: - dice_owner_clear(dice); -err_notification_handler: - fw_core_remove_address_handler(&dice->notification_handler); -err_mutex: - mutex_destroy(&dice->mutex); -error: - snd_card_free(card); - return err; -} - -static void dice_remove(struct fw_unit *unit) -{ - struct dice *dice = dev_get_drvdata(&unit->device); - - amdtp_out_stream_pcm_abort(&dice->stream); - - snd_card_disconnect(dice->card); - - mutex_lock(&dice->mutex); - - dice_stream_stop(dice); - dice_owner_clear(dice); - - mutex_unlock(&dice->mutex); - - snd_card_free_when_closed(dice->card); -} - -static void dice_bus_reset(struct fw_unit *unit) -{ - struct dice *dice = dev_get_drvdata(&unit->device); - - /* - * On a bus reset, the DICE firmware disables streaming and then goes - * off contemplating its own navel for hundreds of milliseconds before - * it can react to any of our attempts to reenable streaming. This - * means that we lose synchronization anyway, so we force our streams - * to stop so that the application can restart them in an orderly - * manner. - */ - amdtp_out_stream_pcm_abort(&dice->stream); - - mutex_lock(&dice->mutex); - - dice->global_enabled = false; - dice_stream_stop_packets(dice); - - dice_owner_update(dice); - - fw_iso_resources_update(&dice->resources); - - mutex_unlock(&dice->mutex); -} - -#define DICE_INTERFACE 0x000001 - -static const struct ieee1394_device_id dice_id_table[] = { - { - .match_flags = IEEE1394_MATCH_VERSION, - .version = DICE_INTERFACE, - }, - { } -}; -MODULE_DEVICE_TABLE(ieee1394, dice_id_table); - -static struct fw_driver dice_driver = { - .driver = { - .owner = THIS_MODULE, - .name = KBUILD_MODNAME, - .bus = &fw_bus_type, - }, - .probe = dice_probe, - .update = dice_bus_reset, - .remove = dice_remove, - .id_table = dice_id_table, -}; - -static int __init alsa_dice_init(void) -{ - return driver_register(&dice_driver.driver); -} - -static void __exit alsa_dice_exit(void) -{ - driver_unregister(&dice_driver.driver); -} - -module_init(alsa_dice_init); -module_exit(alsa_dice_exit); diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c index 860c080..ec578b5 100644 --- a/sound/firewire/fcp.c +++ b/sound/firewire/fcp.c @@ -90,7 +90,7 @@ int fcp_avc_transaction(struct fw_unit *unit, : TCODE_WRITE_BLOCK_REQUEST; ret = snd_fw_transaction(t.unit, tcode, CSR_REGISTER_BASE + CSR_FCP_COMMAND, - (void *)command, command_size, 0); + (void *)command, command_size); if (ret < 0) break; diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index fd42e6b..58a5afe 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -217,7 +217,7 @@ static void isight_packet(struct fw_iso_context *context, u32 cycle, static int isight_connect(struct isight *isight) { - int ch, err; + int ch, err, rcode, errors = 0; __be32 value; retry_after_bus_reset: @@ -230,19 +230,27 @@ retry_after_bus_reset: } value = cpu_to_be32(ch | (isight->device->max_speed << SPEED_SHIFT)); - err = snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, - isight->audio_base + REG_ISO_TX_CONFIG, - &value, 4, FW_FIXED_GENERATION | - isight->resources.generation); - if (err == -EAGAIN) { - fw_iso_resources_free(&isight->resources); - goto retry_after_bus_reset; - } else if (err < 0) { - goto err_resources; + for (;;) { + rcode = fw_run_transaction( + isight->device->card, + TCODE_WRITE_QUADLET_REQUEST, + isight->device->node_id, + isight->resources.generation, + isight->device->max_speed, + isight->audio_base + REG_ISO_TX_CONFIG, + &value, 4); + if (rcode == RCODE_COMPLETE) { + return 0; + } else if (rcode == RCODE_GENERATION) { + fw_iso_resources_free(&isight->resources); + goto retry_after_bus_reset; + } else if (rcode_is_permanent_error(rcode) || ++errors >= 3) { + err = -EIO; + goto err_resources; + } + msleep(5); } - return 0; - err_resources: fw_iso_resources_free(&isight->resources); error: @@ -307,19 +315,17 @@ static int isight_hw_params(struct snd_pcm_substream *substream, static int reg_read(struct isight *isight, int offset, __be32 *value) { return snd_fw_transaction(isight->unit, TCODE_READ_QUADLET_REQUEST, - isight->audio_base + offset, value, 4, 0); + isight->audio_base + offset, value, 4); } static int reg_write(struct isight *isight, int offset, __be32 value) { return snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, - isight->audio_base + offset, &value, 4, 0); + isight->audio_base + offset, &value, 4); } static void isight_stop_streaming(struct isight *isight) { - __be32 value; - if (!isight->context) return; @@ -327,10 +333,7 @@ static void isight_stop_streaming(struct isight *isight) fw_iso_context_destroy(isight->context); isight->context = NULL; fw_iso_resources_free(&isight->resources); - value = 0; - snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, - isight->audio_base + REG_AUDIO_ENABLE, - &value, 4, FW_QUIET); + reg_write(isight, REG_AUDIO_ENABLE, 0); } static int isight_hw_free(struct snd_pcm_substream *substream) diff --git a/sound/firewire/lib.c b/sound/firewire/lib.c index 7409edb..14eb414 100644 --- a/sound/firewire/lib.c +++ b/sound/firewire/lib.c @@ -11,7 +11,7 @@ #include <linux/module.h> #include "lib.h" -#define ERROR_RETRY_DELAY_MS 20 +#define ERROR_RETRY_DELAY_MS 5 /** * snd_fw_transaction - send a request and wait for its completion @@ -20,9 +20,6 @@ * @offset: the address in the target's address space * @buffer: input/output data * @length: length of @buffer - * @flags: use %FW_FIXED_GENERATION and add the generation value to attempt the - * request only in that generation; use %FW_QUIET to suppress error - * messages * * Submits an asynchronous request to the target device, and waits for the * response. The node ID and the current generation are derived from @unit. @@ -30,18 +27,14 @@ * Returns zero on success, or a negative error code. */ int snd_fw_transaction(struct fw_unit *unit, int tcode, - u64 offset, void *buffer, size_t length, - unsigned int flags) + u64 offset, void *buffer, size_t length) { struct fw_device *device = fw_parent_device(unit); int generation, rcode, tries = 0; - generation = flags & FW_GENERATION_MASK; for (;;) { - if (!(flags & FW_FIXED_GENERATION)) { - generation = device->generation; - smp_rmb(); /* node_id vs. generation */ - } + generation = device->generation; + smp_rmb(); /* node_id vs. generation */ rcode = fw_run_transaction(device->card, tcode, device->node_id, generation, device->max_speed, offset, @@ -50,14 +43,9 @@ int snd_fw_transaction(struct fw_unit *unit, int tcode, if (rcode == RCODE_COMPLETE) return 0; - if (rcode == RCODE_GENERATION && (flags & FW_FIXED_GENERATION)) - return -EAGAIN; - if (rcode_is_permanent_error(rcode) || ++tries >= 3) { - if (!(flags & FW_QUIET)) - dev_err(&unit->device, - "transaction failed: %s\n", - fw_rcode_string(rcode)); + dev_err(&unit->device, "transaction failed: %s\n", + fw_rcode_string(rcode)); return -EIO; } diff --git a/sound/firewire/lib.h b/sound/firewire/lib.h index 02cfabc..aef3014 100644 --- a/sound/firewire/lib.h +++ b/sound/firewire/lib.h @@ -6,13 +6,8 @@ struct fw_unit; -#define FW_GENERATION_MASK 0x00ff -#define FW_FIXED_GENERATION 0x0100 -#define FW_QUIET 0x0200 - int snd_fw_transaction(struct fw_unit *unit, int tcode, - u64 offset, void *buffer, size_t length, - unsigned int flags); + u64 offset, void *buffer, size_t length); /* returns true if retrying the transaction would not make sense */ static inline bool rcode_is_permanent_error(int rcode) diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c index 858023c..505fc81 100644 --- a/sound/firewire/scs1x.c +++ b/sound/firewire/scs1x.c @@ -369,7 +369,7 @@ static int scs_init_hss_address(struct scs *scs) data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | scs->hss_handler.offset); err = snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, - HSS1394_ADDRESS, &data, 8, 0); + HSS1394_ADDRESS, &data, 8); if (err < 0) dev_err(&scs->unit->device, "HSS1394 communication failed\n"); @@ -455,16 +455,12 @@ err_card: static void scs_update(struct fw_unit *unit) { struct scs *scs = dev_get_drvdata(&unit->device); - int generation; __be64 data; data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | scs->hss_handler.offset); - generation = fw_parent_device(unit)->generation; - smp_rmb(); /* node_id vs. generation */ snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, - HSS1394_ADDRESS, &data, 8, - FW_FIXED_GENERATION | generation); + HSS1394_ADDRESS, &data, 8); } static void scs_remove(struct fw_unit *unit) diff --git a/sound/firewire/speakers.c b/sound/firewire/speakers.c index cc8bc3a..fe9e6e2 100644 --- a/sound/firewire/speakers.c +++ b/sound/firewire/speakers.c @@ -52,6 +52,7 @@ struct fwspk { struct mutex mutex; struct cmp_connection connection; struct amdtp_out_stream stream; + bool stream_running; bool mute; s16 volume[6]; s16 volume_min; @@ -187,9 +188,10 @@ static int fwspk_close(struct snd_pcm_substream *substream) static void fwspk_stop_stream(struct fwspk *fwspk) { - if (amdtp_out_stream_running(&fwspk->stream)) { + if (fwspk->stream_running) { amdtp_out_stream_stop(&fwspk->stream); cmp_connection_break(&fwspk->connection); + fwspk->stream_running = false; } } @@ -244,10 +246,8 @@ static int fwspk_hw_params(struct snd_pcm_substream *substream, if (err < 0) goto error; - amdtp_out_stream_set_parameters(&fwspk->stream, - params_rate(hw_params), - params_channels(hw_params), - 0); + amdtp_out_stream_set_rate(&fwspk->stream, params_rate(hw_params)); + amdtp_out_stream_set_pcm(&fwspk->stream, params_channels(hw_params)); amdtp_out_stream_set_pcm_format(&fwspk->stream, params_format(hw_params)); @@ -285,7 +285,7 @@ static int fwspk_prepare(struct snd_pcm_substream *substream) if (amdtp_out_streaming_error(&fwspk->stream)) fwspk_stop_stream(fwspk); - if (!amdtp_out_stream_running(&fwspk->stream)) { + if (!fwspk->stream_running) { err = cmp_connection_establish(&fwspk->connection, amdtp_out_stream_get_max_payload(&fwspk->stream)); if (err < 0) @@ -296,6 +296,8 @@ static int fwspk_prepare(struct snd_pcm_substream *substream) fwspk->connection.speed); if (err < 0) goto err_connection; + + fwspk->stream_running = true; } mutex_unlock(&fwspk->mutex); @@ -645,7 +647,7 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit) int err; err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, - OXFORD_FIRMWARE_ID_ADDRESS, &data, 4, 0); + OXFORD_FIRMWARE_ID_ADDRESS, &data, 4); return err >= 0 ? be32_to_cpu(data) : 0; } diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 15ae025..5bf4fca 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -60,7 +60,7 @@ static void reg_dump(struct ak4114 *ak4114) printk(KERN_DEBUG "AK4114 REG DUMP:\n"); for (i = 0; i < 0x20; i++) - printk(KERN_DEBUG "reg[%02x] = %02x (%02x)\n", i, reg_read(ak4114, i), i < ARRAY_SIZE(ak4114->regmap) ? ak4114->regmap[i] : 0); + printk(KERN_DEBUG "reg[%02x] = %02x (%02x)\n", i, reg_read(ak4114, i), i < sizeof(ak4114->regmap) ? ak4114->regmap[i] : 0); } #endif @@ -81,7 +81,7 @@ static int snd_ak4114_dev_free(struct snd_device *device) int snd_ak4114_create(struct snd_card *card, ak4114_read_t *read, ak4114_write_t *write, - const unsigned char pgm[6], const unsigned char txcsb[5], + const unsigned char pgm[7], const unsigned char txcsb[5], void *private_data, struct ak4114 **r_ak4114) { struct ak4114 *chip; @@ -101,7 +101,7 @@ int snd_ak4114_create(struct snd_card *card, chip->private_data = private_data; INIT_DELAYED_WORK(&chip->work, ak4114_stats); - for (reg = 0; reg < 6; reg++) + for (reg = 0; reg < 7; reg++) chip->regmap[reg] = pgm[reg]; for (reg = 0; reg < 5; reg++) chip->txcsb[reg] = txcsb[reg]; @@ -142,7 +142,7 @@ static void ak4114_init_regs(struct ak4114 *chip) /* release reset, but leave powerdown */ reg_write(chip, AK4114_REG_PWRDN, (old | AK4114_RST) & ~AK4114_PWN); udelay(200); - for (reg = 1; reg < 6; reg++) + for (reg = 1; reg < 7; reg++) reg_write(chip, reg, chip->regmap[reg]); for (reg = 0; reg < 5; reg++) reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]); diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index f3735e6..ed726d1 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -583,7 +583,7 @@ static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol, if (idx >= num_names) return -EINVAL; input_names = ak->adc_info[mixer_ch].input_names; - strlcpy(uinfo->value.enumerated.name, input_names[idx], + strncpy(uinfo->value.enumerated.name, input_names[idx], sizeof(uinfo->value.enumerated.name)); return 0; } diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c index ab6b2dc..f84f073 100644 --- a/sound/isa/cmi8328.c +++ b/sound/isa/cmi8328.c @@ -126,7 +126,6 @@ static void snd_cmi8328_cfg_write(u16 port, u8 reg, u8 val) outb(val, port + 3); /* yes, value goes to the same port as index */ } -#ifdef CONFIG_PM static void snd_cmi8328_cfg_save(u16 port, u8 cfg[]) { cfg[0] = snd_cmi8328_cfg_read(port, CFG1); @@ -140,7 +139,6 @@ static void snd_cmi8328_cfg_restore(u16 port, u8 cfg[]) snd_cmi8328_cfg_write(port, CFG2, cfg[1]); snd_cmi8328_cfg_write(port, CFG3, cfg[2]); } -#endif /* CONFIG_PM */ static int snd_cmi8328_mixer(struct snd_wss *chip) { diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 0a90bd6..81aeb93 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -73,11 +73,9 @@ #ifdef MSND_CLASSIC # include "msnd_classic.h" # define LOGNAME "msnd_classic" -# define DEV_NAME "msnd-classic" #else # include "msnd_pinnacle.h" # define LOGNAME "snd_msnd_pinnacle" -# define DEV_NAME "msnd-pinnacle" #endif static void set_default_audio_parameters(struct snd_msnd *chip) @@ -1069,6 +1067,8 @@ static int snd_msnd_isa_remove(struct device *pdev, unsigned int dev) return 0; } +#define DEV_NAME "msnd-pinnacle" + static struct isa_driver snd_msnd_driver = { .match = snd_msnd_isa_match, .probe = snd_msnd_isa_probe, diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 48da227..c1aa21e 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -208,7 +208,6 @@ static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned i switch (cmd) { /* get information */ case SNDRV_SB_CSP_IOCTL_INFO: - memset(&info, 0, sizeof(info)); *info.codec_name = *p->codec_name; info.func_nr = p->func_nr; info.acc_format = p->acc_format; diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index e5db001..a2f87f9 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -1196,7 +1196,7 @@ wavefront_send_multisample (snd_wavefront_t *dev, wavefront_patch_info *header) int num_samples; unsigned char *msample_hdr; - msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL); + msample_hdr = kmalloc(sizeof(WF_MSAMPLE_BYTES), GFP_KERNEL); if (! msample_hdr) return -ENOMEM; diff --git a/sound/mips/ad1843.c b/sound/mips/ad1843.c index 5869075..c624510 100644 --- a/sound/mips/ad1843.c +++ b/sound/mips/ad1843.c @@ -276,7 +276,7 @@ static void ad1843_write_multi(struct snd_ad1843 *ad1843, int argcount, ...) if (reg == -1) reg = fp->reg; else - WARN_ON(reg != fp->reg); + BUG_ON(reg != fp->reg); m = ((1 << fp->nbits) - 1) << fp->lo_bit; mask |= m; bits |= (value << fp->lo_bit) & m; diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c index 0e7254b..c0be085 100644 --- a/sound/oss/sb_ess.c +++ b/sound/oss/sb_ess.c @@ -1544,7 +1544,7 @@ static int ess_has_rec_mixer (int submodel) return 1; default: return 0; - } + }; }; #ifdef FKS_LOGGING diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index b680d03..d2b9d61 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -739,7 +739,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe reg = ad1889_readw(chip, AD_DS_WADA); snd_iprintf(buffer, "Right: %s, -%d dB\n", (reg & AD_DS_WADA_RWAM) ? "mute" : "unmute", - (reg & AD_DS_WADA_RWAA) * 3); + ((reg & AD_DS_WADA_RWAA) >> 8) * 3); reg = ad1889_readw(chip, AD_DS_WAS); snd_iprintf(buffer, "Wave samplerate: %u Hz\n", reg); diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index c6835a3..3dfa12b 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -855,6 +855,7 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec) static void snd_ali_update_ptr(struct snd_ali *codec, int channel) { struct snd_ali_voice *pvoice; + struct snd_pcm_runtime *runtime; struct snd_ali_channel_control *pchregs; unsigned int old, mask; #ifdef ALI_DEBUG @@ -871,6 +872,7 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel) return; pvoice = &codec->synth.voices[channel]; + runtime = pvoice->substream->runtime; udelay(100); spin_lock(&codec->reg_lock); diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 5f2acd3..dc632cd 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -1913,7 +1913,6 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); */ u32 h_control = kcontrol->private_value; - unsigned int idx; u16 band; u16 tuner_bands[HPI_TUNER_BAND_LAST]; u32 num_bands = 0; @@ -1921,10 +1920,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, HPI_TUNER_BAND_LAST); - idx = ucontrol->value.enumerated.item[0]; - if (idx >= ARRAY_SIZE(tuner_bands)) - idx = ARRAY_SIZE(tuner_bands) - 1; - band = tuner_bands[idx]; + band = tuner_bands[ucontrol->value.enumerated.item[0]]; hpi_handle_error(hpi_tuner_set_band(h_control, band)); return 1; @@ -2387,8 +2383,7 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol, struct snd_card_asihpi *asihpi = (struct snd_card_asihpi *)(kcontrol->private_data); struct clk_cache *clkcache = &asihpi->cc; - unsigned int item; - int change; + int change, item; u32 h_control = kcontrol->private_value; change = 1; diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 9fb03b4..b46dc9b 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -671,7 +671,7 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr) return err; break; #endif - } + }; if (VORTEX_PCM_TYPE(pcm) == VORTEX_PCM_SPDIF) { for (i = 0; i < ARRAY_SIZE(snd_vortex_mixer_spdif); i++) { diff --git a/sound/pci/au88x0/au88x0_synth.c b/sound/pci/au88x0/au88x0_synth.c index 922a84b..8bef473 100644 --- a/sound/pci/au88x0/au88x0_synth.c +++ b/sound/pci/au88x0/au88x0_synth.c @@ -219,6 +219,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_RUN(wt), val); return 0xc; + break; case 1: /* param 0 */ /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", @@ -226,6 +227,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_PARM(wt, 0), val); return 0xc; + break; case 2: /* param 1 */ /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", @@ -233,6 +235,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_PARM(wt, 1), val); return 0xc; + break; case 3: /* param 2 */ /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", @@ -240,6 +243,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_PARM(wt, 2), val); return 0xc; + break; case 4: /* param 3 */ /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", @@ -247,6 +251,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_PARM(wt, 3), val); return 0xc; + break; case 6: /* mute */ /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", @@ -254,17 +259,20 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, */ hwwrite(vortex->mmio, WT_MUTE(wt), val); return 0xc; + break; case 0xb: - /* delay */ - /* - printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", - WT_DELAY(wt,0), (int)val); - */ - hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); - hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); - hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); - hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); - return 0xc; + { /* delay */ + /* + printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", + WT_DELAY(wt,0), (int)val); + */ + hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); + hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); + hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); + hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); + return 0xc; + } + break; /* Global WT block parameters */ case 5: /* sramp */ ecx = WT_SRAMP(wt); @@ -283,6 +291,7 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, break; default: return 0; + break; } /* printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 1aef712..c8e1216 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -715,14 +715,14 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97) const struct snd_azf3328 *chip = ac97->private_data; unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); unsigned short reg_val = 0; - bool unsupported = false; + bool unsupported = 0; snd_azf3328_dbgmixer( "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", reg_ac97 ); if (reg_azf & AZF_AC97_REG_UNSUPPORTED) - unsupported = true; + unsupported = 1; else { if (reg_azf & AZF_AC97_REG_REAL_IO_READ) reg_val = snd_azf3328_mixer_inw(chip, @@ -759,7 +759,7 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97) reg_val = azf_emulated_ac97_vendor_id & 0xffff; break; default: - unsupported = true; + unsupported = 1; break; } } @@ -776,14 +776,14 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97, { const struct snd_azf3328 *chip = ac97->private_data; unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); - bool unsupported = false; + bool unsupported = 0; snd_azf3328_dbgmixer( "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n", reg_ac97, val ); if (reg_azf & AZF_AC97_REG_UNSUPPORTED) - unsupported = true; + unsupported = 1; else { if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE) snd_azf3328_mixer_outw( @@ -808,7 +808,7 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97, */ break; default: - unsupported = true; + unsupported = 1; break; } } @@ -1559,7 +1559,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_azf3328_codec_data *codec = runtime->private_data; int result = 0; u16 flags1; - bool previously_muted = false; + bool previously_muted = 0; bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type); snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd); diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index e6a4450..da1cb9c 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -161,13 +161,13 @@ int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) /* drop the original AD1888 HPF control */ memset(&elem, 0, sizeof(elem)); elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - strlcpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); + strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); snd_ctl_remove_id(card, &elem); /* drop the original V_REFOUT control */ memset(&elem, 0, sizeof(elem)); elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - strlcpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); + strncpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); snd_ctl_remove_id(card, &elem); /* add the OLPC-specific controls */ diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 84f86bf..0c00eb4 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -33,7 +33,7 @@ struct daio_rsc_idx { unsigned short right; }; -static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { +struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { [LINEO1] = {.left = 0x00, .right = 0x01}, [LINEO2] = {.left = 0x18, .right = 0x19}, [LINEO3] = {.left = 0x08, .right = 0x09}, @@ -44,7 +44,7 @@ static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { [SPDIFI1] = {.left = 0x95, .right = 0x9d}, }; -static struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { +struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { [LINEO1] = {.left = 0x40, .right = 0x41}, [LINEO2] = {.left = 0x60, .right = 0x61}, [LINEO3] = {.left = 0x50, .right = 0x51}, diff --git a/sound/pci/ctxfi/cthardware.c b/sound/pci/ctxfi/cthardware.c index a689f25..110b8ac 100644 --- a/sound/pci/ctxfi/cthardware.c +++ b/sound/pci/ctxfi/cthardware.c @@ -69,8 +69,7 @@ unsigned int get_field(unsigned int data, unsigned int field) { int i; - if (WARN_ON(!field)) - return 0; + BUG_ON(!field); /* @field should always be greater than 0 */ for (i = 0; !(field & (1 << i)); ) i++; @@ -82,8 +81,7 @@ void set_field(unsigned int *data, unsigned int field, unsigned int value) { int i; - if (WARN_ON(!field)) - return; + BUG_ON(!field); /* @field should always be greater than 0 */ for (i = 0; !(field & (1 << i)); ) i++; diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 1f9c7c4..0275209 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -1182,20 +1182,15 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) u32 *gpr_map; mm_segment_t seg; - err = -ENOMEM; - icode = kzalloc(sizeof(*icode), GFP_KERNEL); - if (!icode) - return err; - - icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, - sizeof(u_int32_t), GFP_KERNEL); - if (!icode->gpr_map) - goto __err_gpr; - controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, - sizeof(*controls), GFP_KERNEL); - if (!controls) - goto __err_ctrls; - + if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || + (icode->gpr_map = (u_int32_t __user *) + kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(*controls), GFP_KERNEL)) == NULL) { + err = -ENOMEM; + goto __err; + } gpr_map = (u32 __force *)icode->gpr_map; icode->tram_data_map = icode->gpr_map + 512; @@ -1746,12 +1741,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) emu->support_tlv = 0; /* clear again */ snd_leave_user(seg); -__err: + __err: kfree(controls); -__err_ctrls: - kfree((void __force *)icode->gpr_map); -__err_gpr: - kfree(icode); + if (icode != NULL) { + kfree((void __force *)icode->gpr_map); + kfree(icode); + } return err; } @@ -1818,26 +1813,18 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) u32 *gpr_map; mm_segment_t seg; - err = -ENOMEM; - icode = kzalloc(sizeof(*icode), GFP_KERNEL); - if (!icode) - return err; - - icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512, - sizeof(u_int32_t), GFP_KERNEL); - if (!icode->gpr_map) - goto __err_gpr; - - controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, - sizeof(struct snd_emu10k1_fx8010_control_gpr), - GFP_KERNEL); - if (!controls) - goto __err_ctrls; - - ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); - if (!ipcm) - goto __err_ipcm; - + if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) + return -ENOMEM; + if ((icode->gpr_map = (u_int32_t __user *) + kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(struct snd_emu10k1_fx8010_control_gpr), + GFP_KERNEL)) == NULL || + (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { + err = -ENOMEM; + goto __err; + } gpr_map = (u32 __force *)icode->gpr_map; icode->tram_data_map = icode->gpr_map + 256; @@ -2376,14 +2363,13 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) snd_leave_user(seg); if (err >= 0) err = snd_emu10k1_ipcm_poke(emu, ipcm); -__err: + __err: kfree(ipcm); -__err_ipcm: kfree(controls); -__err_ctrls: - kfree((void __force *)icode->gpr_map); -__err_gpr: - kfree(icode); + if (icode != NULL) { + kfree((void __force *)icode->gpr_map); + kfree(icode); + } return err; } diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 4cdd9de..8de66cc 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -209,9 +209,8 @@ config SND_HDA_CODEC_CA0132 config SND_HDA_CODEC_CA0132_DSP bool "Support new DSP code for CA0132 codec" - depends on SND_HDA_CODEC_CA0132 + depends on SND_HDA_CODEC_CA0132 && FW_LOADER select SND_HDA_DSP_LOADER - select FW_LOADER help Say Y here to enable the DSP for Creative CA0132 for extended features like equalizer or echo cancellation. diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 853c6a6..48a9d00 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -638,7 +638,7 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, /* don't add channel suffix for Headphone controls */ int idx = get_hp_label_index(codec, nid, cfg->hp_pins, cfg->hp_outs); - if (idx >= 0 && indexp) + if (idx >= 0) *indexp = idx; sfx = ""; } diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 98bce98..63c9909 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c @@ -110,7 +110,6 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, case SND_BELL: if (hz) hz = 1000; - /* fallthru */ case SND_TONE: if (beep->linear_tone) beep->tone = beep_linear_tone(beep, hz); @@ -152,8 +151,10 @@ static int snd_hda_do_attach(struct hda_beep *beep) int err; input_dev = input_allocate_device(); - if (!input_dev) + if (!input_dev) { + printk(KERN_INFO "hda_beep: unable to allocate input device\n"); return -ENOMEM; + } /* setup digital beep device */ input_dev->name = "HDA Digital PCBeep"; diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 69178c4..748c6a9 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -565,7 +565,7 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid, range_val = !!(parm & (1 << (shift-1))); /* ranges */ val = parm & mask; if (val == 0 && null_count++) { /* no second chance */ - snd_printdd("hda_codec: " + snd_printk(KERN_WARNING "hda_codec: " "invalid CONNECT_LIST verb %x[%i]:%x\n", nid, i, parm); return 0; @@ -2579,6 +2579,9 @@ int snd_hda_codec_reset(struct hda_codec *codec) cancel_delayed_work_sync(&codec->jackpoll_work); #ifdef CONFIG_PM cancel_delayed_work_sync(&codec->power_work); + codec->power_on = 0; + codec->power_transition = 0; + codec->power_jiffies = jiffies; flush_workqueue(bus->workq); #endif snd_hda_ctls_clear(codec); @@ -2631,7 +2634,8 @@ static int map_slaves(struct hda_codec *codec, const char * const *slaves, items = codec->mixers.list; for (i = 0; i < codec->mixers.used; i++) { struct snd_kcontrol *sctl = items[i].kctl; - if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) + if (!sctl || !sctl->id.name || + sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) continue; for (s = slaves; *s; s++) { char tmpname[sizeof(sctl->id.name)]; @@ -2658,7 +2662,7 @@ static int check_slave_present(void *data, struct snd_kcontrol *sctl) } /* guess the value corresponding to 0dB */ -static int get_kctl_0dB_offset(struct snd_kcontrol *kctl, int *step_to_check) +static int get_kctl_0dB_offset(struct snd_kcontrol *kctl) { int _tlv[4]; const int *tlv = NULL; @@ -2673,19 +2677,8 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl, int *step_to_check) set_fs(fs); } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) tlv = kctl->tlv.p; - if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) { - int step = tlv[3]; - step &= ~TLV_DB_SCALE_MUTE; - if (!step) - return -1; - if (*step_to_check && *step_to_check != step) { - snd_printk(KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n", - *step_to_check, step); - return -1; - } - *step_to_check = step; - val = -tlv[2] / step; - } + if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) + val = -tlv[2] / tlv[3]; return val; } @@ -2706,7 +2699,7 @@ static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) /* initialize the slave volume with 0dB */ static int init_slave_0dB(void *data, struct snd_kcontrol *slave) { - int offset = get_kctl_0dB_offset(slave, data); + int offset = get_kctl_0dB_offset(slave); if (offset > 0) put_kctl_with_value(slave, offset); return 0; @@ -2767,11 +2760,9 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, /* init with master mute & zero volume */ put_kctl_with_value(kctl, 0); - if (init_slave_vol) { - int step = 0; + if (init_slave_vol) map_slaves(codec, slaves, suffix, - tlv ? init_slave_0dB : init_slave_unmute, &step); - } + tlv ? init_slave_0dB : init_slave_unmute, kctl); if (ctl_ret) *ctl_ret = kctl; @@ -4000,10 +3991,6 @@ static void hda_call_codec_resume(struct hda_codec *codec) * in the resume / power-save sequence */ hda_keep_power_on(codec); - if (codec->pm_down_notified) { - codec->pm_down_notified = 0; - hda_call_pm_notify(codec->bus, true); - } hda_set_power_state(codec, AC_PWRST_D0); restore_shutup_pins(codec); hda_exec_init_verbs(codec); @@ -5408,6 +5395,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, snd_hda_codec_setup_stream(codec, mout->hp_out_nid[i], stream_tag, 0, format); + for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) + if (!mout->no_share_stream && mout->extra_out_nid[i]) + snd_hda_codec_setup_stream(codec, + mout->extra_out_nid[i], + stream_tag, 0, format); /* surrounds */ for (i = 1; i < mout->num_dacs; i++) { @@ -5418,20 +5410,6 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, format); } - - /* extra surrounds */ - for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) { - int ch = 0; - if (!mout->extra_out_nid[i]) - break; - if (chs >= (i + 1) * 2) - ch = i * 2; - else if (!mout->no_share_stream) - break; - snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i], - stream_tag, ch, format); - } - return 0; } EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare); diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 79ca80f..d0d7ac1 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -2,7 +2,6 @@ * Generic routines and proc interface for ELD(EDID Like Data) information * * Copyright(c) 2008 Intel Corporation. - * Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi> * * Authors: * Wu Fengguang <wfg@linux.intel.com> @@ -479,9 +478,10 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a, snd_iprintf(buffer, "sad%d_profile\t\t%d\n", i, a->profile); } -void snd_hdmi_print_eld_info(struct hdmi_eld *eld, - struct snd_info_buffer *buffer) +static void hdmi_print_eld_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { + struct hdmi_eld *eld = entry->private_data; struct parsed_hdmi_eld *e = &eld->info; char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; int i; @@ -500,10 +500,13 @@ void snd_hdmi_print_eld_info(struct hdmi_eld *eld, [4 ... 7] = "reserved" }; + mutex_lock(&eld->lock); snd_iprintf(buffer, "monitor_present\t\t%d\n", eld->monitor_present); snd_iprintf(buffer, "eld_valid\t\t%d\n", eld->eld_valid); - if (!eld->eld_valid) + if (!eld->eld_valid) { + mutex_unlock(&eld->lock); return; + } snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); snd_iprintf(buffer, "connection_type\t\t%s\n", eld_connection_type_names[e->conn_type]); @@ -525,11 +528,13 @@ void snd_hdmi_print_eld_info(struct hdmi_eld *eld, for (i = 0; i < e->sad_count; i++) hdmi_print_sad_info(i, e->sad + i, buffer); + mutex_unlock(&eld->lock); } -void snd_hdmi_write_eld_info(struct hdmi_eld *eld, - struct snd_info_buffer *buffer) +static void hdmi_write_eld_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { + struct hdmi_eld *eld = entry->private_data; struct parsed_hdmi_eld *e = &eld->info; char line[64]; char name[64]; @@ -537,6 +542,7 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, long long val; unsigned int n; + mutex_lock(&eld->lock); while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%s %llx", name, &val) != 2) continue; @@ -588,7 +594,38 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->sad_count = n + 1; } } + mutex_unlock(&eld->lock); +} + + +int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, + int index) +{ + char name[32]; + struct snd_info_entry *entry; + int err; + + snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); + err = snd_card_proc_new(codec->bus->card, name, &entry); + if (err < 0) + return err; + + snd_info_set_text_ops(entry, eld, hdmi_print_eld_info); + entry->c.text.write = hdmi_write_eld_info; + entry->mode |= S_IWUSR; + eld->proc_entry = entry; + + return 0; +} + +void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) +{ + if (!codec->bus->shutdown && eld->proc_entry) { + snd_device_free(codec->bus->card, eld->proc_entry); + eld->proc_entry = NULL; + } } + #endif /* CONFIG_PROC_FS */ /* update PCM info based on ELD */ @@ -634,174 +671,3 @@ void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e, hinfo->maxbps = min(hinfo->maxbps, maxbps); hinfo->channels_max = min(hinfo->channels_max, channels_max); } - - -/* ATI/AMD specific stuff (ELD emulation) */ - -#define ATI_VERB_SET_AUDIO_DESCRIPTOR 0x776 -#define ATI_VERB_SET_SINK_INFO_INDEX 0x780 -#define ATI_VERB_GET_SPEAKER_ALLOCATION 0xf70 -#define ATI_VERB_GET_AUDIO_DESCRIPTOR 0xf76 -#define ATI_VERB_GET_AUDIO_VIDEO_DELAY 0xf7b -#define ATI_VERB_GET_SINK_INFO_INDEX 0xf80 -#define ATI_VERB_GET_SINK_INFO_DATA 0xf81 - -#define ATI_SPKALLOC_SPKALLOC 0x007f -#define ATI_SPKALLOC_TYPE_HDMI 0x0100 -#define ATI_SPKALLOC_TYPE_DISPLAYPORT 0x0200 - -/* first three bytes are just standard SAD */ -#define ATI_AUDIODESC_CHANNELS 0x00000007 -#define ATI_AUDIODESC_RATES 0x0000ff00 -#define ATI_AUDIODESC_LPCM_STEREO_RATES 0xff000000 - -/* in standard HDMI VSDB format */ -#define ATI_DELAY_VIDEO_LATENCY 0x000000ff -#define ATI_DELAY_AUDIO_LATENCY 0x0000ff00 - -enum ati_sink_info_idx { - ATI_INFO_IDX_MANUFACTURER_ID = 0, - ATI_INFO_IDX_PRODUCT_ID = 1, - ATI_INFO_IDX_SINK_DESC_LEN = 2, - ATI_INFO_IDX_PORT_ID_LOW = 3, - ATI_INFO_IDX_PORT_ID_HIGH = 4, - ATI_INFO_IDX_SINK_DESC_FIRST = 5, - ATI_INFO_IDX_SINK_DESC_LAST = 22, /* max len 18 bytes */ -}; - -int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, - unsigned char *buf, int *eld_size, bool rev3_or_later) -{ - int spkalloc, ati_sad, aud_synch; - int sink_desc_len = 0; - int pos, i; - - /* ATI/AMD does not have ELD, emulate it */ - - spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0); - - if (spkalloc <= 0) { - snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n"); - return -EINVAL; - } - - memset(buf, 0, ELD_FIXED_BYTES + ELD_MAX_MNL + ELD_MAX_SAD * 3); - - /* version */ - buf[0] = ELD_VER_CEA_861D << 3; - - /* speaker allocation from EDID */ - buf[7] = spkalloc & ATI_SPKALLOC_SPKALLOC; - - /* is DisplayPort? */ - if (spkalloc & ATI_SPKALLOC_TYPE_DISPLAYPORT) - buf[5] |= 0x04; - - pos = ELD_FIXED_BYTES; - - if (rev3_or_later) { - int sink_info; - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_LOW); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - put_unaligned_le32(sink_info, buf + 8); - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_HIGH); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - put_unaligned_le32(sink_info, buf + 12); - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_MANUFACTURER_ID); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - put_unaligned_le16(sink_info, buf + 16); - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PRODUCT_ID); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - put_unaligned_le16(sink_info, buf + 18); - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_LEN); - sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - - if (sink_desc_len > ELD_MAX_MNL) { - snd_printd(KERN_INFO "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n", - sink_desc_len); - sink_desc_len = ELD_MAX_MNL; - } - - buf[4] |= sink_desc_len; - - for (i = 0; i < sink_desc_len; i++) { - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_FIRST + i); - buf[pos++] = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); - } - } - - for (i = AUDIO_CODING_TYPE_LPCM; i <= AUDIO_CODING_TYPE_WMAPRO; i++) { - if (i == AUDIO_CODING_TYPE_SACD || i == AUDIO_CODING_TYPE_DST) - continue; /* not handled by ATI/AMD */ - - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3); - ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0); - - if (ati_sad <= 0) - continue; - - if (ati_sad & ATI_AUDIODESC_RATES) { - /* format is supported, copy SAD as-is */ - buf[pos++] = (ati_sad & 0x0000ff) >> 0; - buf[pos++] = (ati_sad & 0x00ff00) >> 8; - buf[pos++] = (ati_sad & 0xff0000) >> 16; - } - - if (i == AUDIO_CODING_TYPE_LPCM - && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES) - && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES) >> 16 != (ati_sad & ATI_AUDIODESC_RATES)) { - /* for PCM there is a separate stereo rate mask */ - buf[pos++] = ((ati_sad & 0x000000ff) & ~ATI_AUDIODESC_CHANNELS) | 0x1; - /* rates from the extra byte */ - buf[pos++] = (ati_sad & 0xff000000) >> 24; - buf[pos++] = (ati_sad & 0x00ff0000) >> 16; - } - } - - if (pos == ELD_FIXED_BYTES + sink_desc_len) { - snd_printd(KERN_INFO "HDMI ATI/AMD: no audio descriptors for ELD\n"); - return -EINVAL; - } - - /* - * HDMI VSDB latency format: - * separately for both audio and video: - * 0 field not valid or unknown latency - * [1..251] msecs = (x-1)*2 (max 500ms with x = 251 = 0xfb) - * 255 audio/video not supported - * - * HDA latency format: - * single value indicating video latency relative to audio: - * 0 unknown or 0ms - * [1..250] msecs = x*2 (max 500ms with x = 250 = 0xfa) - * [251..255] reserved - */ - aud_synch = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_VIDEO_DELAY, 0); - if ((aud_synch & ATI_DELAY_VIDEO_LATENCY) && (aud_synch & ATI_DELAY_AUDIO_LATENCY)) { - int video_latency_hdmi = (aud_synch & ATI_DELAY_VIDEO_LATENCY); - int audio_latency_hdmi = (aud_synch & ATI_DELAY_AUDIO_LATENCY) >> 8; - - if (video_latency_hdmi <= 0xfb && audio_latency_hdmi <= 0xfb && - video_latency_hdmi > audio_latency_hdmi) - buf[6] = video_latency_hdmi - audio_latency_hdmi; - /* else unknown/invalid or 0ms or video ahead of audio, so use zero */ - } - - /* SAD count */ - buf[5] |= ((pos - ELD_FIXED_BYTES - sink_desc_len) / 3) << 4; - - /* Baseline ELD block length is 4-byte aligned */ - pos = round_up(pos, 4); - - /* Baseline ELD length (4-byte header is not counted in) */ - buf[2] = (pos - 4) / 4; - - *eld_size = pos; - - return 0; -} diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index c4671d0..b7c89df 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -549,15 +549,11 @@ static hda_nid_t look_for_out_mute_nid(struct hda_codec *codec, static hda_nid_t look_for_out_vol_nid(struct hda_codec *codec, struct nid_path *path) { - struct hda_gen_spec *spec = codec->spec; int i; for (i = path->depth - 1; i >= 0; i--) { - hda_nid_t nid = path->path[i]; - if ((spec->out_vol_mask >> nid) & 1) - continue; - if (nid_has_volume(codec, nid, HDA_OUTPUT)) - return nid; + if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) + return path->path[i]; } return 0; } @@ -796,10 +792,10 @@ static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable) if (spec->own_eapd_ctl || !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)) return; - if (spec->keep_eapd_on && !enable) - return; if (codec->inv_eapd) enable = !enable; + if (spec->keep_eapd_on && !enable) + return; snd_hda_codec_update_cache(codec, pin, 0, AC_VERB_SET_EAPD_BTLENABLE, enable ? 0x02 : 0x00); @@ -2506,8 +2502,12 @@ static int create_out_jack_modes(struct hda_codec *codec, int num_pins, for (i = 0; i < num_pins; i++) { hda_nid_t pin = pins[i]; - if (pin == spec->hp_mic_pin) + if (pin == spec->hp_mic_pin) { + int ret = create_hp_mic_jack_mode(codec, pin); + if (ret < 0) + return ret; continue; + } if (get_out_jack_num_items(codec, pin) > 1) { struct snd_kcontrol_new *knew; char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; @@ -2760,7 +2760,7 @@ static int hp_mic_jack_mode_put(struct snd_kcontrol *kcontrol, val &= ~(AC_PINCTL_VREFEN | PIN_HP); val |= get_vref_idx(vref_caps, idx) | PIN_IN; } else - val = snd_hda_get_default_vref(codec, nid) | PIN_IN; + val = snd_hda_get_default_vref(codec, nid); } snd_hda_set_pin_ctl_cache(codec, nid, val); call_hp_automute(codec, NULL); @@ -2780,6 +2780,9 @@ static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin) struct hda_gen_spec *spec = codec->spec; struct snd_kcontrol_new *knew; + if (get_out_jack_num_items(codec, pin) <= 1 && + get_in_jack_num_items(codec, pin) <= 1) + return 0; /* no need */ knew = snd_hda_gen_add_kctl(spec, "Headphone Mic Jack Mode", &hp_mic_jack_mode_enum); if (!knew) @@ -2808,42 +2811,6 @@ static int add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx) return 0; } -/* return true if either a volume or a mute amp is found for the given - * aamix path; the amp has to be either in the mixer node or its direct leaf - */ -static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid, - hda_nid_t pin, unsigned int *mix_val, - unsigned int *mute_val) -{ - int idx, num_conns; - const hda_nid_t *list; - hda_nid_t nid; - - idx = snd_hda_get_conn_index(codec, mix_nid, pin, true); - if (idx < 0) - return false; - - *mix_val = *mute_val = 0; - if (nid_has_volume(codec, mix_nid, HDA_INPUT)) - *mix_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); - if (nid_has_mute(codec, mix_nid, HDA_INPUT)) - *mute_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); - if (*mix_val && *mute_val) - return true; - - /* check leaf node */ - num_conns = snd_hda_get_conn_list(codec, mix_nid, &list); - if (num_conns < idx) - return false; - nid = list[idx]; - if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT)) - *mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); - if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT)) - *mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); - - return *mix_val || *mute_val; -} - /* create input playback/capture controls for the given pin */ static int new_analog_input(struct hda_codec *codec, int input_idx, hda_nid_t pin, const char *ctlname, int ctlidx, @@ -2851,11 +2818,12 @@ static int new_analog_input(struct hda_codec *codec, int input_idx, { struct hda_gen_spec *spec = codec->spec; struct nid_path *path; - unsigned int mix_val, mute_val; + unsigned int val; int err, idx; - if (!look_for_mix_leaf_ctls(codec, mix_nid, pin, &mix_val, &mute_val)) - return 0; + if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && + !nid_has_mute(codec, mix_nid, HDA_INPUT)) + return 0; /* no need for analog loopback */ path = snd_hda_add_new_path(codec, pin, mix_nid, 0); if (!path) @@ -2864,18 +2832,20 @@ static int new_analog_input(struct hda_codec *codec, int input_idx, spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); idx = path->idx[path->depth - 1]; - if (mix_val) { - err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, mix_val); + if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { + val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); + err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, val); if (err < 0) return err; - path->ctls[NID_PATH_VOL_CTL] = mix_val; + path->ctls[NID_PATH_VOL_CTL] = val; } - if (mute_val) { - err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, mute_val); + if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { + val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); + err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, val); if (err < 0) return err; - path->ctls[NID_PATH_MUTE_CTL] = mute_val; + path->ctls[NID_PATH_MUTE_CTL] = val; } path->active = true; @@ -4409,17 +4379,6 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, if (err < 0) return err; - /* create "Headphone Mic Jack Mode" if no input selection is - * available (or user specifies add_jack_modes hint) - */ - if (spec->hp_mic_pin && - (spec->auto_mic || spec->input_mux.num_items == 1 || - spec->add_jack_modes)) { - err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin); - if (err < 0) - return err; - } - if (spec->add_jack_modes) { if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { err = create_out_jack_modes(codec, cfg->line_outs, diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 7e45cb4..48d4402 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h @@ -242,9 +242,6 @@ struct hda_gen_spec { /* additional mute flags (only effective with auto_mute_via_amp=1) */ u64 mute_bits; - /* bitmask for skipping volume controls */ - u64 out_vol_mask; - /* badness tables for output path evaluations */ const struct badness_table *main_out_badness; const struct badness_table *extra_out_badness; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 27aa140..6e61a01 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -169,7 +169,6 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," "{Intel, PPT}," "{Intel, LPT}," "{Intel, LPT_LP}," - "{Intel, WPT_LP}," "{Intel, HPT}," "{Intel, PBG}," "{Intel, SCH}," @@ -569,7 +568,6 @@ enum { AZX_DRIVER_ICH, AZX_DRIVER_PCH, AZX_DRIVER_SCH, - AZX_DRIVER_HDMI, AZX_DRIVER_ATI, AZX_DRIVER_ATIHDMI, AZX_DRIVER_ATIHDMI_NS, @@ -614,11 +612,6 @@ enum { #define AZX_DCAPS_INTEL_PCH \ (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME) -#define AZX_DCAPS_INTEL_HASWELL \ - (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \ - AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \ - AZX_DCAPS_I915_POWERWELL) - /* quirks for ATI SB / AMD Hudson */ #define AZX_DCAPS_PRESET_ATI_SB \ (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \ @@ -649,7 +642,6 @@ static char *driver_short_names[] = { [AZX_DRIVER_ICH] = "HDA Intel", [AZX_DRIVER_PCH] = "HDA Intel PCH", [AZX_DRIVER_SCH] = "HDA Intel MID", - [AZX_DRIVER_HDMI] = "HDA Intel HDMI", [AZX_DRIVER_ATI] = "HDA ATI SB", [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI", @@ -914,12 +906,12 @@ static void azx_update_rirb(struct azx *chip) chip->rirb.res[addr] = res; smp_wmb(); chip->rirb.cmds[addr]--; - } else if (printk_ratelimit()) { - snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, last cmd=%#08x\n", + } else + snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, " + "last cmd=%#08x\n", pci_name(chip->pci), res, res_ex, chip->last_cmd[addr]); - } } } @@ -3876,8 +3868,7 @@ static int azx_probe(struct pci_dev *pci, } dev++; - if (chip->disabled) - complete_all(&chip->probe_wait); + complete_all(&chip->probe_wait); return 0; out_free: @@ -3954,10 +3945,10 @@ static int azx_probe_continue(struct azx *chip) if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) || chip->use_vga_switcheroo) pm_runtime_put_noidle(&pci->dev); + return 0; + out_free: - if (err < 0) - chip->init_failed = 1; - complete_all(&chip->probe_wait); + chip->init_failed = 1; return err; } @@ -3994,16 +3985,16 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { /* Lynx Point-LP */ { PCI_DEVICE(0x8086, 0x9c21), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, - /* Wildcat Point-LP */ - { PCI_DEVICE(0x8086, 0x9ca0), - .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, /* Haswell */ { PCI_DEVICE(0x8086, 0x0a0c), - .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0c0c), - .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0d0c), - .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, /* 5 Series/3400 */ { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, @@ -4083,22 +4074,6 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa50), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa58), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa60), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa68), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa80), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa88), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa90), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, - { PCI_DEVICE(0x1002, 0xaa98), - .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, { PCI_DEVICE(0x1002, 0x9902), .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, { PCI_DEVICE(0x1002, 0xaaa0), diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index afe5944..05b3e3e 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -286,7 +286,7 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) jack = codec->jacktbl.list; for (i = 0; i < codec->jacktbl.used; i++, jack++) if (jack->nid) { - if (!jack->kctl || jack->block_report) + if (!jack->kctl) continue; state = get_jack_plug_state(jack->pin_sense); snd_kctl_jack_report(codec->bus->card, jack->kctl, state); diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index 46e1ea8..379420c 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h @@ -28,7 +28,6 @@ struct hda_jack_tbl { unsigned int jack_detect:1; /* capable of jack-detection? */ unsigned int jack_dirty:1; /* needs to update? */ unsigned int phantom_jack:1; /* a fixed, always present port? */ - unsigned int block_report:1; /* in a transitional state - do not report to userspace */ hda_nid_t gating_jack; /* valid when gating jack plugged */ hda_nid_t gated_jack; /* gated is dependent on this jack */ struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index d398b64..2e7493e 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -428,7 +428,6 @@ enum { HDA_FIXUP_ACT_PROBE, HDA_FIXUP_ACT_INIT, HDA_FIXUP_ACT_BUILD, - HDA_FIXUP_ACT_FREE, }; int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list); @@ -752,6 +751,10 @@ struct hdmi_eld { int eld_size; char eld_buffer[ELD_MAX_SIZE]; struct parsed_hdmi_eld info; + struct mutex lock; +#ifdef CONFIG_PROC_FS + struct snd_info_entry *proc_entry; +#endif }; int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); @@ -763,15 +766,21 @@ void snd_hdmi_show_eld(struct parsed_hdmi_eld *e); void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e, struct hda_pcm_stream *hinfo); -int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, - unsigned char *buf, int *eld_size, - bool rev3_or_later); - #ifdef CONFIG_PROC_FS -void snd_hdmi_print_eld_info(struct hdmi_eld *eld, - struct snd_info_buffer *buffer); -void snd_hdmi_write_eld_info(struct hdmi_eld *eld, - struct snd_info_buffer *buffer); +int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, + int index); +void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld); +#else +static inline int snd_hda_eld_proc_new(struct hda_codec *codec, + struct hdmi_eld *eld, + int index) +{ + return 0; +} +static inline void snd_hda_eld_proc_free(struct hda_codec *codec, + struct hdmi_eld *eld) +{ +} #endif #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index cac015b..2aa2f57 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -139,20 +139,6 @@ static int ad198x_suspend(struct hda_codec *codec) } #endif -/* follow EAPD via vmaster hook */ -static void ad_vmaster_eapd_hook(void *private_data, int enabled) -{ - struct hda_codec *codec = private_data; - struct ad198x_spec *spec = codec->spec; - - if (!spec->eapd_nid) - return; - if (codec->inv_eapd) - enabled = !enabled; - snd_hda_codec_update_cache(codec, spec->eapd_nid, 0, - AC_VERB_SET_EAPD_BTLENABLE, - enabled ? 0x02 : 0x00); -} /* * Automatic parse of I/O pins from the BIOS configuration @@ -233,14 +219,8 @@ static int alloc_ad_spec(struct hda_codec *codec) static void ad_fixup_inv_jack_detect(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - struct ad198x_spec *spec = codec->spec; - - if (action == HDA_FIXUP_ACT_PRE_PROBE) { + if (action == HDA_FIXUP_ACT_PRE_PROBE) codec->inv_jack_detect = 1; - spec->gen.keep_eapd_on = 1; - spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; - spec->eapd_nid = 0x1b; - } } enum { @@ -361,9 +341,6 @@ static int patch_ad1986a(struct hda_codec *codec) */ spec->gen.multiout.no_share_stream = 1; - /* AD1986A can't manage the dynamic pin on/off smoothly */ - spec->gen.auto_mute_via_amp = 1; - snd_hda_pick_fixup(codec, ad1986a_fixup_models, ad1986a_fixup_tbl, ad1986a_fixups); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); @@ -488,6 +465,19 @@ static int patch_ad1983(struct hda_codec *codec) * AD1981 HD specific */ +/* follow EAPD via vmaster hook */ +static void ad_vmaster_eapd_hook(void *private_data, int enabled) +{ + struct hda_codec *codec = private_data; + struct ad198x_spec *spec = codec->spec; + + if (!spec->eapd_nid) + return; + snd_hda_codec_update_cache(codec, spec->eapd_nid, 0, + AC_VERB_SET_EAPD_BTLENABLE, + enabled ? 0x02 : 0x00); +} + static void ad1981_fixup_hp_eapd(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -967,7 +957,6 @@ static void ad1884_fixup_hp_eapd(struct hda_codec *codec, switch (action) { case HDA_FIXUP_ACT_PRE_PROBE: spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook; - spec->gen.own_eapd_ctl = 1; snd_hda_sequence_write_cache(codec, gpio_init_verbs); break; case HDA_FIXUP_ACT_PROBE: @@ -984,11 +973,8 @@ static void ad1884_fixup_thinkpad(struct hda_codec *codec, { struct ad198x_spec *spec = codec->spec; - if (action == HDA_FIXUP_ACT_PRE_PROBE) { + if (action == HDA_FIXUP_ACT_PRE_PROBE) spec->gen.keep_eapd_on = 1; - spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; - spec->eapd_nid = 0x12; - } } /* set magic COEFs for dmic */ diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 54d1479..6e9876f 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -759,7 +759,7 @@ struct ca0132_spec { /* * CA0132 codec access */ -static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, +unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, unsigned int verb, unsigned int parm, unsigned int *res) { unsigned int response; diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index fc492ac..18d9725 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -47,10 +47,6 @@ struct cs_spec { unsigned int spdif_present:1; unsigned int sense_b:1; hda_nid_t vendor_nid; - - /* for MBP SPDIF control */ - int (*spdif_sw_put)(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); }; /* available models with CS420x */ @@ -335,21 +331,10 @@ static int cs_init(struct hda_codec *codec) return 0; } -static int cs_build_controls(struct hda_codec *codec) -{ - int err; - - err = snd_hda_gen_build_controls(codec); - if (err < 0) - return err; - snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); - return 0; -} - #define cs_free snd_hda_gen_free static const struct hda_codec_ops cs_patch_ops = { - .build_controls = cs_build_controls, + .build_controls = snd_hda_gen_build_controls, .build_pcms = snd_hda_gen_build_pcms, .init = cs_init, .free = cs_free, @@ -612,27 +597,18 @@ static int patch_cs420x(struct hda_codec *codec) * Its layout is no longer compatible with CS4206/CS4207 */ enum { - CS4208_MAC_AUTO, CS4208_MBA6, - CS4208_MBP11, CS4208_GPIO0, }; static const struct hda_model_fixup cs4208_models[] = { { .id = CS4208_GPIO0, .name = "gpio0" }, { .id = CS4208_MBA6, .name = "mba6" }, - { .id = CS4208_MBP11, .name = "mbp11" }, {} }; static const struct snd_pci_quirk cs4208_fixup_tbl[] = { - SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_MAC_AUTO), - {} /* terminator */ -}; - -/* codec SSID matching */ -static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] = { - SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11), + /* codec SSID */ SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6), SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6), {} /* terminator */ @@ -650,50 +626,6 @@ static void cs4208_fixup_gpio0(struct hda_codec *codec, } } -static const struct hda_fixup cs4208_fixups[]; - -/* remap the fixup from codec SSID and apply it */ -static void cs4208_fixup_mac(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - if (action != HDA_FIXUP_ACT_PRE_PROBE) - return; - snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups); - if (codec->fixup_id < 0 || codec->fixup_id == CS4208_MAC_AUTO) - codec->fixup_id = CS4208_GPIO0; /* default fixup */ - snd_hda_apply_fixup(codec, action); -} - -static int cs4208_spdif_sw_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct cs_spec *spec = codec->spec; - hda_nid_t pin = spec->gen.autocfg.dig_out_pins[0]; - int pinctl = ucontrol->value.integer.value[0] ? PIN_OUT : 0; - - snd_hda_set_pin_ctl_cache(codec, pin, pinctl); - return spec->spdif_sw_put(kcontrol, ucontrol); -} - -/* hook the SPDIF switch */ -static void cs4208_fixup_spdif_switch(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - if (action == HDA_FIXUP_ACT_BUILD) { - struct cs_spec *spec = codec->spec; - struct snd_kcontrol *kctl; - - if (!spec->gen.autocfg.dig_out_pins[0]) - return; - kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch"); - if (!kctl) - return; - spec->spdif_sw_put = kctl->put; - kctl->put = cs4208_spdif_sw_put; - } -} - static const struct hda_fixup cs4208_fixups[] = { [CS4208_MBA6] = { .type = HDA_FIXUP_PINS, @@ -701,20 +633,10 @@ static const struct hda_fixup cs4208_fixups[] = { .chained = true, .chain_id = CS4208_GPIO0, }, - [CS4208_MBP11] = { - .type = HDA_FIXUP_FUNC, - .v.func = cs4208_fixup_spdif_switch, - .chained = true, - .chain_id = CS4208_GPIO0, - }, [CS4208_GPIO0] = { .type = HDA_FIXUP_FUNC, .v.func = cs4208_fixup_gpio0, }, - [CS4208_MAC_AUTO] = { - .type = HDA_FIXUP_FUNC, - .v.func = cs4208_fixup_mac, - }, }; /* correct the 0dB offset of input pins */ @@ -738,8 +660,6 @@ static int patch_cs4208(struct hda_codec *codec) return -ENOMEM; spec->gen.automute_hook = cs_automute; - /* exclude NID 0x10 (HP) from output volumes due to different steps */ - spec->gen.out_vol_mask = 1ULL << 0x10; snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl, cs4208_fixups); diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 1f2717f..ec68eae 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3208,17 +3208,11 @@ static int cx_auto_init(struct hda_codec *codec) return 0; } -static void cx_auto_free(struct hda_codec *codec) -{ - snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); - snd_hda_gen_free(codec); -} - static const struct hda_codec_ops cx_auto_patch_ops = { .build_controls = cx_auto_build_controls, .build_pcms = snd_hda_gen_build_pcms, .init = cx_auto_init, - .free = cx_auto_free, + .free = snd_hda_gen_free, .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .check_power_status = snd_hda_gen_check_power_status, @@ -3238,106 +3232,8 @@ enum { CXT_FIXUP_HEADPHONE_MIC_PIN, CXT_FIXUP_HEADPHONE_MIC, CXT_FIXUP_GPIO1, - CXT_FIXUP_THINKPAD_ACPI, }; -#if IS_ENABLED(CONFIG_THINKPAD_ACPI) - -#include <linux/thinkpad_acpi.h> -#include <acpi/acpi.h> - -static int (*led_set_func)(int, bool); - -static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context, - void **rv) -{ - bool *found = context; - *found = true; - return AE_OK; -} - -static bool is_thinkpad(struct hda_codec *codec) -{ - bool found = false; - if (codec->subsystem_id >> 16 != 0x17aa) - return false; - if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found) - return true; - found = false; - return ACPI_SUCCESS(acpi_get_devices("IBM0068", acpi_check_cb, &found, NULL)) && found; -} - -static void update_tpacpi_mute_led(void *private_data, int enabled) -{ - struct hda_codec *codec = private_data; - struct conexant_spec *spec = codec->spec; - - if (spec->dynamic_eapd) - cx_auto_vmaster_hook(private_data, enabled); - - if (led_set_func) - led_set_func(TPACPI_LED_MUTE, !enabled); -} - -static void update_tpacpi_micmute_led(struct hda_codec *codec, - struct snd_ctl_elem_value *ucontrol) -{ - if (!ucontrol || !led_set_func) - return; - if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) { - /* TODO: How do I verify if it's a mono or stereo here? */ - bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]; - led_set_func(TPACPI_LED_MICMUTE, !val); - } -} - -static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - struct conexant_spec *spec = codec->spec; - - bool removefunc = false; - - if (action == HDA_FIXUP_ACT_PROBE) { - if (!is_thinkpad(codec)) - return; - if (!led_set_func) - led_set_func = symbol_request(tpacpi_led_set); - if (!led_set_func) { - snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n"); - return; - } - - removefunc = true; - if (led_set_func(TPACPI_LED_MUTE, false) >= 0) { - spec->gen.vmaster_mute.hook = update_tpacpi_mute_led; - removefunc = false; - } - if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { - if (spec->gen.num_adc_nids > 1) - snd_printdd("Skipping micmute LED control due to several ADCs"); - else { - spec->gen.cap_sync_hook = update_tpacpi_micmute_led; - removefunc = false; - } - } - } - - if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) { - symbol_put(tpacpi_led_set); - led_set_func = NULL; - } -} - -#else - -static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ -} - -#endif - static void cxt_fixup_stereo_dmic(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -3448,8 +3344,6 @@ static const struct hda_fixup cxt_fixups[] = { [CXT_PINCFG_LENOVO_TP410] = { .type = HDA_FIXUP_PINS, .v.pins = cxt_pincfg_lenovo_tp410, - .chained = true, - .chain_id = CXT_FIXUP_THINKPAD_ACPI, }, [CXT_PINCFG_LEMOTE_A1004] = { .type = HDA_FIXUP_PINS, @@ -3491,10 +3385,6 @@ static const struct hda_fixup cxt_fixups[] = { { } }, }, - [CXT_FIXUP_THINKPAD_ACPI] = { - .type = HDA_FIXUP_FUNC, - .v.func = cxt_fixup_thinkpad_acpi, - }, }; static const struct snd_pci_quirk cxt5051_fixups[] = { @@ -3516,7 +3406,6 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { 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), - SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), {} @@ -3618,7 +3507,7 @@ static int patch_conexant_auto(struct hda_codec *codec) return 0; error: - cx_auto_free(codec); + snd_hda_gen_free(codec); return err; } @@ -3679,8 +3568,6 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = { .patch = patch_conexant_auto }, { .id = 0x14f15115, .name = "CX20757", .patch = patch_conexant_auto }, - { .id = 0x14f151d7, .name = "CX20952", - .patch = patch_conexant_auto }, {} /* terminator */ }; @@ -3707,7 +3594,6 @@ MODULE_ALIAS("snd-hda-codec-id:14f15111"); MODULE_ALIAS("snd-hda-codec-id:14f15113"); MODULE_ALIAS("snd-hda-codec-id:14f15114"); MODULE_ALIAS("snd-hda-codec-id:14f15115"); -MODULE_ALIAS("snd-hda-codec-id:14f151d7"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Conexant HD-audio codec"); diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index c4a66ef..50173d4 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -6,7 +6,6 @@ * Copyright (c) 2006 ATI Technologies Inc. * Copyright (c) 2008 NVIDIA Corp. All rights reserved. * Copyright (c) 2008 Wei Ni <wni@nvidia.com> - * Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi> * * Authors: * Wu Fengguang <wfg@linux.intel.com> @@ -46,7 +45,6 @@ module_param(static_hdmi_pcm, bool, 0644); MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); #define is_haswell(codec) ((codec)->vendor_id == 0x80862807) -#define is_valleyview(codec) ((codec)->vendor_id == 0x80862882) struct hdmi_spec_per_cvt { hda_nid_t cvt_nid; @@ -65,11 +63,9 @@ struct hdmi_spec_per_pin { hda_nid_t pin_nid; int num_mux_nids; hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; - hda_nid_t cvt_nid; struct hda_codec *codec; struct hdmi_eld sink_eld; - struct mutex lock; struct delayed_work work; struct snd_kcontrol *eld_ctl; int repoll_count; @@ -79,42 +75,6 @@ struct hdmi_spec_per_pin { bool chmap_set; /* channel-map override by ALSA API? */ unsigned char chmap[8]; /* ALSA API channel-map */ char pcm_name[8]; /* filled in build_pcm callbacks */ -#ifdef CONFIG_PROC_FS - struct snd_info_entry *proc_entry; -#endif -}; - -struct cea_channel_speaker_allocation; - -/* operations used by generic code that can be overridden by patches */ -struct hdmi_ops { - int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid, - unsigned char *buf, int *eld_size); - - /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */ - int (*pin_get_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid, - int asp_slot); - int (*pin_set_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid, - int asp_slot, int channel); - - void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid, - int ca, int active_channels, int conn_type); - - /* enable/disable HBR (HD passthrough) */ - int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr); - - int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid, - hda_nid_t pin_nid, u32 stream_tag, int format); - - /* Helpers for producing the channel map TLVs. These can be overridden - * for devices that have non-standard mapping requirements. */ - int (*chmap_cea_alloc_validate_get_type)(struct cea_channel_speaker_allocation *cap, - int channels); - void (*cea_alloc_to_tlv_chmap)(struct cea_channel_speaker_allocation *cap, - unsigned int *chmap, int channels); - - /* check that the user-given chmap is supported */ - int (*chmap_validate)(int ca, int channels, unsigned char *chmap); }; struct hdmi_spec { @@ -128,9 +88,8 @@ struct hdmi_spec { unsigned int channels_max; /* max over all cvts */ struct hdmi_eld temp_eld; - struct hdmi_ops ops; /* - * Non-generic VIA/NVIDIA specific + * Non-generic ATI/NVIDIA specific */ struct hda_multi_out multiout; struct hda_pcm_stream pcm_playback; @@ -389,19 +348,17 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hdmi_spec *spec = codec->spec; - struct hdmi_spec_per_pin *per_pin; struct hdmi_eld *eld; int pin_idx; uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; pin_idx = kcontrol->private_value; - per_pin = get_pin(spec, pin_idx); - eld = &per_pin->sink_eld; + eld = &get_pin(spec, pin_idx)->sink_eld; - mutex_lock(&per_pin->lock); + mutex_lock(&eld->lock); uinfo->count = eld->eld_valid ? eld->eld_size : 0; - mutex_unlock(&per_pin->lock); + mutex_unlock(&eld->lock); return 0; } @@ -411,17 +368,15 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hdmi_spec *spec = codec->spec; - struct hdmi_spec_per_pin *per_pin; struct hdmi_eld *eld; int pin_idx; pin_idx = kcontrol->private_value; - per_pin = get_pin(spec, pin_idx); - eld = &per_pin->sink_eld; + eld = &get_pin(spec, pin_idx)->sink_eld; - mutex_lock(&per_pin->lock); + mutex_lock(&eld->lock); if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { - mutex_unlock(&per_pin->lock); + mutex_unlock(&eld->lock); snd_BUG(); return -EINVAL; } @@ -431,7 +386,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, if (eld->eld_valid) memcpy(ucontrol->value.bytes.data, eld->eld_buffer, eld->eld_size); - mutex_unlock(&per_pin->lock); + mutex_unlock(&eld->lock); return 0; } @@ -522,68 +477,6 @@ static void hdmi_set_channel_count(struct hda_codec *codec, AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); } -/* - * ELD proc files - */ - -#ifdef CONFIG_PROC_FS -static void print_eld_info(struct snd_info_entry *entry, - struct snd_info_buffer *buffer) -{ - struct hdmi_spec_per_pin *per_pin = entry->private_data; - - mutex_lock(&per_pin->lock); - snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer); - mutex_unlock(&per_pin->lock); -} - -static void write_eld_info(struct snd_info_entry *entry, - struct snd_info_buffer *buffer) -{ - struct hdmi_spec_per_pin *per_pin = entry->private_data; - - mutex_lock(&per_pin->lock); - snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); - mutex_unlock(&per_pin->lock); -} - -static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index) -{ - char name[32]; - struct hda_codec *codec = per_pin->codec; - struct snd_info_entry *entry; - int err; - - snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); - err = snd_card_proc_new(codec->bus->card, name, &entry); - if (err < 0) - return err; - - snd_info_set_text_ops(entry, per_pin, print_eld_info); - entry->c.text.write = write_eld_info; - entry->mode |= S_IWUSR; - per_pin->proc_entry = entry; - - return 0; -} - -static void eld_proc_free(struct hdmi_spec_per_pin *per_pin) -{ - if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { - snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry); - per_pin->proc_entry = NULL; - } -} -#else -static inline int eld_proc_new(struct hdmi_spec_per_pin *per_pin, - int index) -{ - return 0; -} -static inline void eld_proc_free(struct hdmi_spec_per_pin *per_pin) -{ -} -#endif /* * Channel mapping routines @@ -684,91 +577,74 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec, hda_nid_t pin_nid) { #ifdef CONFIG_SND_DEBUG_VERBOSE - struct hdmi_spec *spec = codec->spec; int i; - int channel; + int slot; for (i = 0; i < 8; i++) { - channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i); + slot = snd_hda_codec_read(codec, pin_nid, 0, + AC_VERB_GET_HDMI_CHAN_SLOT, i); printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", - channel, i); + slot >> 4, slot & 0xf); } #endif } + static void hdmi_std_setup_channel_mapping(struct hda_codec *codec, hda_nid_t pin_nid, bool non_pcm, int ca) { - struct hdmi_spec *spec = codec->spec; - struct cea_channel_speaker_allocation *ch_alloc; int i; int err; int order; int non_pcm_mapping[8]; order = get_channel_allocation_order(ca); - ch_alloc = &channel_allocations[order]; if (hdmi_channel_mapping[ca][1] == 0) { - int hdmi_slot = 0; - /* fill actual channel mappings in ALSA channel (i) order */ - for (i = 0; i < ch_alloc->channels; i++) { - while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8)) - hdmi_slot++; /* skip zero slots */ - - hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++; - } - /* fill the rest of the slots with ALSA channel 0xf */ - for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) - if (!ch_alloc->speakers[7 - hdmi_slot]) - hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot; + 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 < ch_alloc->channels; i++) - non_pcm_mapping[i] = (i << 4) | i; + 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 << 4) | i; + non_pcm_mapping[i] = 0xf | (i << 4); } for (i = 0; i < 8; i++) { - int slotsetup = non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]; - int hdmi_slot = slotsetup & 0x0f; - int channel = (slotsetup & 0xf0) >> 4; - err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel); + err = snd_hda_codec_write(codec, pin_nid, 0, + AC_VERB_SET_HDMI_CHAN_SLOT, + non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]); if (err) { snd_printdd(KERN_NOTICE "HDMI: channel mapping failed\n"); break; } } + + 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, FL }, - { SNDRV_CHMAP_FR, FR }, - { SNDRV_CHMAP_RL, RL }, - { SNDRV_CHMAP_RR, RR }, - { SNDRV_CHMAP_LFE, LFE }, - { SNDRV_CHMAP_FC, FC }, - { SNDRV_CHMAP_RLC, RLC }, - { SNDRV_CHMAP_RRC, RRC }, - { SNDRV_CHMAP_RC, RC }, - { SNDRV_CHMAP_FLC, FLC }, - { SNDRV_CHMAP_FRC, FRC }, - { SNDRV_CHMAP_TFL, FLH }, - { SNDRV_CHMAP_TFR, FRH }, - { SNDRV_CHMAP_FLW, FLW }, - { SNDRV_CHMAP_FRW, FRW }, - { SNDRV_CHMAP_TC, TC }, - { SNDRV_CHMAP_TFC, FCH }, + { 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 */ }; @@ -784,19 +660,25 @@ static int to_spk_mask(unsigned char c) } /* from ALSA API channel position to CEA slot */ -static int to_cea_slot(int ordered_ca, unsigned char pos) +static int to_cea_slot(unsigned char c) { - int mask = to_spk_mask(pos); - int i; - - if (mask) { - for (i = 0; i < 8; i++) { - if (channel_allocations[ordered_ca].speakers[7 - i] == mask) - return i; - } + struct channel_map_table *t = map_tables; + for (; t->map; t++) { + if (t->map == c) + return t->cea_slot; } + return 0x0f; +} - return -1; +/* 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 */ @@ -810,14 +692,6 @@ static int spk_to_chmap(int spk) return 0; } -/* from CEA slot to ALSA API channel position */ -static int from_cea_slot(int ordered_ca, unsigned char slot) -{ - int mask = channel_allocations[ordered_ca].speakers[7 - slot]; - - return spk_to_chmap(mask); -} - /* get the CA index corresponding to the given ALSA API channel map */ static int hdmi_manual_channel_allocation(int chs, unsigned char *map) { @@ -844,29 +718,18 @@ static int hdmi_manual_channel_allocation(int chs, unsigned char *map) /* 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 ca) + int chs, unsigned char *map) { - struct hdmi_spec *spec = codec->spec; - int ordered_ca = get_channel_allocation_order(ca); - int alsa_pos, hdmi_slot; - int assignments[8] = {[0 ... 7] = 0xf}; - - for (alsa_pos = 0; alsa_pos < chs; alsa_pos++) { - - hdmi_slot = to_cea_slot(ordered_ca, map[alsa_pos]); - - if (hdmi_slot < 0) - continue; /* unassigned channel */ - - assignments[hdmi_slot] = alsa_pos; - } - - for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) { - int err; - - err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, - assignments[hdmi_slot]); + 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; } @@ -877,10 +740,9 @@ static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, static void hdmi_setup_fake_chmap(unsigned char *map, int ca) { int i; - int ordered_ca = get_channel_allocation_order(ca); for (i = 0; i < 8; i++) { - if (i < channel_allocations[ordered_ca].channels) - map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f); + if (i < channel_allocations[ca].channels) + map[i] = from_cea_slot((hdmi_channel_mapping[ca][i] >> 4) & 0x0f); else map[i] = 0; } @@ -893,29 +755,11 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, { if (!non_pcm && chmap_set) { hdmi_manual_setup_channel_mapping(codec, pin_nid, - channels, map, ca); + channels, map); } else { hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca); hdmi_setup_fake_chmap(map, ca); } - - hdmi_debug_channel_mapping(codec, pin_nid); -} - -static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, - int asp_slot, int channel) -{ - return snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_HDMI_CHAN_SLOT, - (channel << 4) | asp_slot); -} - -static int hdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, - int asp_slot) -{ - return (snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_HDMI_CHAN_SLOT, - asp_slot) & 0xf0) >> 4; } /* @@ -1039,64 +883,15 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, return true; } -static void hdmi_pin_setup_infoframe(struct hda_codec *codec, - hda_nid_t pin_nid, - int ca, int active_channels, - int conn_type) -{ - union audio_infoframe ai; - - if (conn_type == 0) { /* HDMI */ - struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; - - hdmi_ai->type = 0x84; - hdmi_ai->ver = 0x01; - hdmi_ai->len = 0x0a; - hdmi_ai->CC02_CT47 = active_channels - 1; - hdmi_ai->CA = ca; - hdmi_checksum_audio_infoframe(hdmi_ai); - } else if (conn_type == 1) { /* DisplayPort */ - struct dp_audio_infoframe *dp_ai = &ai.dp; - - dp_ai->type = 0x84; - dp_ai->len = 0x1b; - dp_ai->ver = 0x11 << 2; - dp_ai->CC02_CT47 = active_channels - 1; - dp_ai->CA = ca; - } else { - snd_printd("HDMI: unknown connection type at pin %d\n", - pin_nid); - return; - } - - /* - * sizeof(ai) is used instead of sizeof(*hdmi_ai) or - * sizeof(*dp_ai) to avoid partial match/update problems when - * the user switches between HDMI/DP monitors. - */ - if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, - sizeof(ai))) { - snd_printdd("hdmi_pin_setup_infoframe: " - "pin=%d channels=%d ca=0x%02x\n", - pin_nid, - active_channels, ca); - 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); - } -} - static void hdmi_setup_audio_infoframe(struct hda_codec *codec, struct hdmi_spec_per_pin *per_pin, bool non_pcm) { - struct hdmi_spec *spec = codec->spec; hda_nid_t pin_nid = per_pin->pin_nid; int channels = per_pin->channels; - int active_channels; struct hdmi_eld *eld; - int ca, ordered_ca; + int ca; + union audio_infoframe ai; if (!channels) return; @@ -1117,10 +912,29 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, if (ca < 0) ca = 0; - ordered_ca = get_channel_allocation_order(ca); - active_channels = channel_allocations[ordered_ca].channels; + memset(&ai, 0, sizeof(ai)); + if (eld->info.conn_type == 0) { /* HDMI */ + struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; + + hdmi_ai->type = 0x84; + hdmi_ai->ver = 0x01; + hdmi_ai->len = 0x0a; + hdmi_ai->CC02_CT47 = channels - 1; + hdmi_ai->CA = ca; + hdmi_checksum_audio_infoframe(hdmi_ai); + } else if (eld->info.conn_type == 1) { /* DisplayPort */ + struct dp_audio_infoframe *dp_ai = &ai.dp; - hdmi_set_channel_count(codec, per_pin->cvt_nid, active_channels); + dp_ai->type = 0x84; + dp_ai->len = 0x1b; + dp_ai->ver = 0x11 << 2; + dp_ai->CC02_CT47 = channels - 1; + dp_ai->CA = ca; + } else { + snd_printd("HDMI: unknown connection type at pin %d\n", + pin_nid); + return; + } /* * always configure channel mapping, it may have been changed by the @@ -1130,46 +944,59 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, channels, per_pin->chmap, per_pin->chmap_set); - spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels, - eld->info.conn_type); + /* + * sizeof(ai) is used instead of sizeof(*hdmi_ai) or + * sizeof(*dp_ai) to avoid partial match/update problems when + * the user switches between HDMI/DP monitors. + */ + if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, + sizeof(ai))) { + snd_printdd("hdmi_setup_audio_infoframe: " + "pin=%d channels=%d\n", + pin_nid, + channels); + 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); + } per_pin->non_pcm = non_pcm; } + /* * Unsolicited events */ -static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll); - -static void jack_callback(struct hda_codec *codec, struct hda_jack_tbl *jack) -{ - struct hdmi_spec *spec = codec->spec; - int pin_idx = pin_nid_to_pin_index(spec, jack->nid); - if (pin_idx < 0) - return; - - if (hdmi_present_sense(get_pin(spec, pin_idx), 1)) - snd_hda_jack_report_sync(codec); -} +static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll); static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) { + struct hdmi_spec *spec = codec->spec; int tag = res >> AC_UNSOL_RES_TAG_SHIFT; + int pin_nid; + int pin_idx; struct hda_jack_tbl *jack; int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT; jack = snd_hda_jack_tbl_get_from_tag(codec, tag); if (!jack) return; + pin_nid = jack->nid; jack->jack_dirty = 1; _snd_printd(SND_PR_VERBOSE, "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", - codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), + codec->addr, pin_nid, dev_entry, !!(res & AC_UNSOL_RES_IA), !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV)); - jack_callback(codec, jack); + pin_idx = pin_nid_to_pin_index(spec, pin_nid); + if (pin_idx < 0) + return; + + hdmi_present_sense(get_pin(spec, pin_idx), 1); + snd_hda_jack_report_sync(codec); } static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) @@ -1240,25 +1067,26 @@ static void haswell_verify_D0(struct hda_codec *codec, #define is_hbr_format(format) \ ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7) -static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, - bool hbr) +static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, + hda_nid_t pin_nid, u32 stream_tag, int format) { - int pinctl, new_pinctl; + int pinctl; + int new_pinctl = 0; + + if (is_haswell(codec)) + haswell_verify_D0(codec, cvt_nid, pin_nid); if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { pinctl = snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - if (pinctl < 0) - return hbr ? -EINVAL : 0; - new_pinctl = pinctl & ~AC_PINCTL_EPT; - if (hbr) + if (is_hbr_format(format)) new_pinctl |= AC_PINCTL_EPT_HBR; else new_pinctl |= AC_PINCTL_EPT_NATIVE; - snd_printdd("hdmi_pin_hbr_setup: " + snd_printdd("hdmi_setup_stream: " "NID=0x%x, %spinctl=0x%x\n", pin_nid, pinctl == new_pinctl ? "" : "new-", @@ -1268,26 +1096,11 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_pinctl); - } else if (hbr) - return -EINVAL; - - return 0; -} - -static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, - hda_nid_t pin_nid, u32 stream_tag, int format) -{ - struct hdmi_spec *spec = codec->spec; - int err; - if (is_haswell(codec)) - haswell_verify_D0(codec, cvt_nid, pin_nid); - - err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); - - if (err) { + } + if (is_hbr_format(format) && !new_pinctl) { snd_printdd("hdmi_setup_stream: HBR is not supported\n"); - return err; + return -EINVAL; } snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); @@ -1333,16 +1146,7 @@ static int hdmi_choose_cvt(struct hda_codec *codec, return 0; } -/* Intel HDMI workaround to fix audio routing issue: - * For some Intel display codecs, pins share the same connection list. - * So a conveter can be selected by multiple pins and playback on any of these - * pins will generate sound on the external display, because audio flows from - * the same converter to the display pipeline. Also muting one pin may make - * other pins have no sound output. - * So this function assures that an assigned converter for a pin is not selected - * by any other pins. - */ -static void intel_not_share_assigned_cvt(struct hda_codec *codec, +static void haswell_config_cvts(struct hda_codec *codec, hda_nid_t pin_nid, int mux_idx) { struct hdmi_spec *spec = codec->spec; @@ -1413,7 +1217,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, per_cvt = get_cvt(spec, cvt_idx); /* Claim converter */ per_cvt->assigned = 1; - per_pin->cvt_nid = per_cvt->cvt_nid; hinfo->nid = per_cvt->cvt_nid; snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, @@ -1421,8 +1224,8 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, mux_idx); /* configure unused pins to choose other converters */ - if (is_haswell(codec) || is_valleyview(codec)) - intel_not_share_assigned_cvt(codec, per_pin->pin_nid, mux_idx); + if (is_haswell(codec)) + haswell_config_cvts(codec, per_pin->pin_nid, mux_idx); snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid); @@ -1480,9 +1283,8 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) return 0; } -static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) +static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) { - struct hda_jack_tbl *jack; struct hda_codec *codec = per_pin->codec; struct hdmi_spec *spec = codec->spec; struct hdmi_eld *eld = &spec->temp_eld; @@ -1499,9 +1301,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) int present = snd_hda_pin_sense(codec, pin_nid); bool update_eld = false; bool eld_changed = false; - bool ret; - mutex_lock(&per_pin->lock); pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); if (pin_eld->monitor_present) eld->eld_valid = !!(present & AC_PINSENSE_ELDV); @@ -1513,7 +1313,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); if (eld->eld_valid) { - if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, + if (snd_hdmi_get_eld(codec, pin_nid, eld->eld_buffer, &eld->eld_size) < 0) eld->eld_valid = false; else { @@ -1531,10 +1331,11 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) queue_delayed_work(codec->bus->workq, &per_pin->work, msecs_to_jiffies(300)); - goto unlock; + return; } } + mutex_lock(&pin_eld->lock); if (pin_eld->eld_valid && !eld->eld_valid) { update_eld = true; eld_changed = true; @@ -1551,29 +1352,20 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) pin_eld->eld_size = eld->eld_size; pin_eld->info = eld->info; - /* - * Re-setup pin and infoframe. This is needed e.g. when - * - sink is first plugged-in (infoframe is not set up if !monitor_present) - * - transcoder can change during stream playback on Haswell + /* Haswell-specific workaround: re-setup when the transcoder is + * changed during the stream playback */ - if (eld->eld_valid && !old_eld_valid && per_pin->setup) + if (is_haswell(codec) && + eld->eld_valid && !old_eld_valid && per_pin->setup) hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); } + mutex_unlock(&pin_eld->lock); if (eld_changed) snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, &per_pin->eld_ctl->id); - unlock: - ret = !repoll || !pin_eld->monitor_present || pin_eld->eld_valid; - - jack = snd_hda_jack_tbl_get(codec, pin_nid); - if (jack) - jack->block_report = !ret; - - mutex_unlock(&per_pin->lock); - return ret; } static void hdmi_repoll_eld(struct work_struct *work) @@ -1584,8 +1376,7 @@ static void hdmi_repoll_eld(struct work_struct *work) if (per_pin->repoll_count++ > 6) per_pin->repoll_count = 0; - if (hdmi_present_sense(per_pin, per_pin->repoll_count)) - snd_hda_jack_report_sync(per_pin->codec); + hdmi_present_sense(per_pin, per_pin->repoll_count); } static void intel_haswell_fixup_connect_list(struct hda_codec *codec, @@ -1745,14 +1536,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, bool non_pcm; non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); - mutex_lock(&per_pin->lock); per_pin->channels = substream->runtime->channels; per_pin->setup = true; + hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels); + hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); - mutex_unlock(&per_pin->lock); - return spec->ops.setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); + return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); } static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, @@ -1788,14 +1579,11 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, per_pin = get_pin(spec, pin_idx); snd_hda_spdif_ctls_unassign(codec, pin_idx); - - mutex_lock(&per_pin->lock); per_pin->chmap_set = false; memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); per_pin->setup = false; per_pin->channels = 0; - mutex_unlock(&per_pin->lock); } return 0; @@ -1824,40 +1612,14 @@ static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol, return 0; } -static int hdmi_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, - int channels) -{ - /* If the speaker allocation matches the channel count, it is OK.*/ - if (cap->channels != channels) - return -1; - - /* all channels are remappable freely */ - return SNDRV_CTL_TLVT_CHMAP_VAR; -} - -static void hdmi_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap, - unsigned int *chmap, int channels) -{ - int count = 0; - int c; - - for (c = 7; c >= 0; c--) { - int spk = cap->speakers[c]; - if (!spk) - continue; - - chmap[count++] = spk_to_chmap(spk); - } - - WARN_ON(count != channels); -} - 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; @@ -1868,19 +1630,18 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, size -= 8; dst = tlv + 2; for (chs = 2; chs <= spec->channels_max; chs++) { - int i; + 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; - int type = spec->ops.chmap_cea_alloc_validate_get_type(cap, chs); - unsigned int tlv_chmap[8]; - - if (type < 0) + if (cap->channels != chs) + continue; + if (cap->spk_mask & ~valid_mask) continue; if (size < 8) return -ENOMEM; - if (put_user(type, dst) || + if (put_user(SNDRV_CTL_TLVT_CHMAP_VAR, dst) || put_user(chs_bytes, dst + 1)) return -EFAULT; dst += 2; @@ -1890,10 +1651,14 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, return -ENOMEM; size -= chs_bytes; count += chs_bytes; - spec->ops.cea_alloc_to_tlv_chmap(cap, tlv_chmap, chs); - if (copy_to_user(dst, tlv_chmap, chs_bytes)) - return -EFAULT; - dst += chs; + 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)) @@ -1927,7 +1692,7 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, unsigned int ctl_idx; struct snd_pcm_substream *substream; unsigned char chmap[8]; - int i, err, ca, prepared = 0; + int i, ca, prepared = 0; ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); substream = snd_pcm_chmap_substream(info, ctl_idx); @@ -1951,17 +1716,10 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap); if (ca < 0) return -EINVAL; - if (spec->ops.chmap_validate) { - err = spec->ops.chmap_validate(ca, ARRAY_SIZE(chmap), chmap); - if (err) - return err; - } - mutex_lock(&per_pin->lock); per_pin->chmap_set = true; memcpy(per_pin->chmap, chmap, sizeof(chmap)); if (prepared) hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); - mutex_unlock(&per_pin->lock); return 0; } @@ -2078,11 +1836,12 @@ static int generic_hdmi_init_per_pins(struct hda_codec *codec) for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); + struct hdmi_eld *eld = &per_pin->sink_eld; per_pin->codec = codec; - mutex_init(&per_pin->lock); + mutex_init(&eld->lock); INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); - eld_proc_new(per_pin, pin_idx); + snd_hda_eld_proc_new(codec, eld, pin_idx); } return 0; } @@ -2097,8 +1856,7 @@ static int generic_hdmi_init(struct hda_codec *codec) hda_nid_t pin_nid = per_pin->pin_nid; hdmi_init_pin(codec, pin_nid); - snd_hda_jack_detect_enable_callback(codec, pin_nid, pin_nid, - codec->jackpoll_interval > 0 ? jack_callback : NULL); + snd_hda_jack_detect_enable(codec, pin_nid, pin_nid); } return 0; } @@ -2124,9 +1882,10 @@ static void generic_hdmi_free(struct hda_codec *codec) for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); + struct hdmi_eld *eld = &per_pin->sink_eld; cancel_delayed_work(&per_pin->work); - eld_proc_free(per_pin); + snd_hda_eld_proc_free(codec, eld); } flush_workqueue(codec->bus->workq); @@ -2163,17 +1922,6 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = { #endif }; -static const struct hdmi_ops generic_standard_hdmi_ops = { - .pin_get_eld = snd_hdmi_get_eld, - .pin_get_slot_channel = hdmi_pin_get_slot_channel, - .pin_set_slot_channel = hdmi_pin_set_slot_channel, - .pin_setup_infoframe = hdmi_pin_setup_infoframe, - .pin_hbr_setup = hdmi_pin_hbr_setup, - .setup_stream = hdmi_setup_stream, - .chmap_cea_alloc_validate_get_type = hdmi_chmap_cea_alloc_validate_get_type, - .cea_alloc_to_tlv_chmap = hdmi_cea_alloc_to_tlv_chmap, -}; - static void intel_haswell_fixup_connect_list(struct hda_codec *codec, hda_nid_t nid) @@ -2256,7 +2004,6 @@ static int patch_generic_hdmi(struct hda_codec *codec) if (spec == NULL) return -ENOMEM; - spec->ops = generic_standard_hdmi_ops; codec->spec = spec; hdmi_array_init(spec, 4); @@ -2812,398 +2559,49 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) } /* - * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on: - * - 0x10de0015 - * - 0x10de0040 - */ -static int nvhdmi_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, - int channels) -{ - if (cap->ca_index == 0x00 && channels == 2) - return SNDRV_CTL_TLVT_CHMAP_FIXED; - - return hdmi_chmap_cea_alloc_validate_get_type(cap, channels); -} - -static int nvhdmi_chmap_validate(int ca, int chs, unsigned char *map) -{ - if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) - return -EINVAL; - - return 0; -} - -static int patch_nvhdmi(struct hda_codec *codec) -{ - struct hdmi_spec *spec; - int err; - - err = patch_generic_hdmi(codec); - if (err) - return err; - - spec = codec->spec; - - spec->ops.chmap_cea_alloc_validate_get_type = - nvhdmi_chmap_cea_alloc_validate_get_type; - spec->ops.chmap_validate = nvhdmi_chmap_validate; - - return 0; -} - -/* - * ATI/AMD-specific implementations + * ATI-specific implementations + * + * FIXME: we may omit the whole this and use the generic code once after + * it's confirmed to work. */ -#define is_amdhdmi_rev3_or_later(codec) \ - ((codec)->vendor_id == 0x1002aa01 && ((codec)->revision_id & 0xff00) >= 0x0300) -#define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) - -/* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */ -#define ATI_VERB_SET_CHANNEL_ALLOCATION 0x771 -#define ATI_VERB_SET_DOWNMIX_INFO 0x772 -#define ATI_VERB_SET_MULTICHANNEL_01 0x777 -#define ATI_VERB_SET_MULTICHANNEL_23 0x778 -#define ATI_VERB_SET_MULTICHANNEL_45 0x779 -#define ATI_VERB_SET_MULTICHANNEL_67 0x77a -#define ATI_VERB_SET_HBR_CONTROL 0x77c -#define ATI_VERB_SET_MULTICHANNEL_1 0x785 -#define ATI_VERB_SET_MULTICHANNEL_3 0x786 -#define ATI_VERB_SET_MULTICHANNEL_5 0x787 -#define ATI_VERB_SET_MULTICHANNEL_7 0x788 -#define ATI_VERB_SET_MULTICHANNEL_MODE 0x789 -#define ATI_VERB_GET_CHANNEL_ALLOCATION 0xf71 -#define ATI_VERB_GET_DOWNMIX_INFO 0xf72 -#define ATI_VERB_GET_MULTICHANNEL_01 0xf77 -#define ATI_VERB_GET_MULTICHANNEL_23 0xf78 -#define ATI_VERB_GET_MULTICHANNEL_45 0xf79 -#define ATI_VERB_GET_MULTICHANNEL_67 0xf7a -#define ATI_VERB_GET_HBR_CONTROL 0xf7c -#define ATI_VERB_GET_MULTICHANNEL_1 0xf85 -#define ATI_VERB_GET_MULTICHANNEL_3 0xf86 -#define ATI_VERB_GET_MULTICHANNEL_5 0xf87 -#define ATI_VERB_GET_MULTICHANNEL_7 0xf88 -#define ATI_VERB_GET_MULTICHANNEL_MODE 0xf89 - -/* AMD specific HDA cvt verbs */ -#define ATI_VERB_SET_RAMP_RATE 0x770 -#define ATI_VERB_GET_RAMP_RATE 0xf70 - -#define ATI_OUT_ENABLE 0x1 - -#define ATI_MULTICHANNEL_MODE_PAIRED 0 -#define ATI_MULTICHANNEL_MODE_SINGLE 1 - -#define ATI_HBR_CAPABLE 0x01 -#define ATI_HBR_ENABLE 0x10 - -static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, - unsigned char *buf, int *eld_size) -{ - /* call hda_eld.c ATI/AMD-specific function */ - return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, - is_amdhdmi_rev3_or_later(codec)); -} - -static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, - int active_channels, int conn_type) -{ - snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); -} - -static int atihdmi_paired_swap_fc_lfe(int pos) -{ - /* - * ATI/AMD have automatic FC/LFE swap built-in - * when in pairwise mapping mode. - */ - - switch (pos) { - /* see channel_allocations[].speakers[] */ - case 2: return 3; - case 3: return 2; - default: break; - } - - return pos; -} +#define ATIHDMI_CVT_NID 0x02 /* audio converter */ +#define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */ -static int atihdmi_paired_chmap_validate(int ca, int chs, unsigned char *map) -{ - struct cea_channel_speaker_allocation *cap; - int i, j; - - /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ - - cap = &channel_allocations[get_channel_allocation_order(ca)]; - for (i = 0; i < chs; ++i) { - int mask = to_spk_mask(map[i]); - bool ok = false; - bool companion_ok = false; - - if (!mask) - continue; - - for (j = 0 + i % 2; j < 8; j += 2) { - int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); - if (cap->speakers[chan_idx] == mask) { - /* channel is in a supported position */ - ok = true; - - if (i % 2 == 0 && i + 1 < chs) { - /* even channel, check the odd companion */ - int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); - int comp_mask_req = to_spk_mask(map[i+1]); - int comp_mask_act = cap->speakers[comp_chan_idx]; - - if (comp_mask_req == comp_mask_act) - companion_ok = true; - else - return -EINVAL; - } - break; - } - } - - if (!ok) - return -EINVAL; - - if (companion_ok) - i++; /* companion channel already checked */ - } - - return 0; -} - -static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, - int hdmi_slot, int stream_channel) -{ - int verb; - int ati_channel_setup = 0; - - if (hdmi_slot > 7) - return -EINVAL; - - if (!has_amd_full_remap_support(codec)) { - hdmi_slot = atihdmi_paired_swap_fc_lfe(hdmi_slot); - - /* In case this is an odd slot but without stream channel, do not - * disable the slot since the corresponding even slot could have a - * channel. In case neither have a channel, the slot pair will be - * disabled when this function is called for the even slot. */ - if (hdmi_slot % 2 != 0 && stream_channel == 0xf) - return 0; - - hdmi_slot -= hdmi_slot % 2; - - if (stream_channel != 0xf) - stream_channel -= stream_channel % 2; - } - - verb = ATI_VERB_SET_MULTICHANNEL_01 + hdmi_slot/2 + (hdmi_slot % 2) * 0x00e; - - /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ - - if (stream_channel != 0xf) - ati_channel_setup = (stream_channel << 4) | ATI_OUT_ENABLE; - - return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); -} - -static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, - int asp_slot) -{ - bool was_odd = false; - int ati_asp_slot = asp_slot; - int verb; - int ati_channel_setup; - - if (asp_slot > 7) - return -EINVAL; - - if (!has_amd_full_remap_support(codec)) { - ati_asp_slot = atihdmi_paired_swap_fc_lfe(asp_slot); - if (ati_asp_slot % 2 != 0) { - ati_asp_slot -= 1; - was_odd = true; - } - } - - verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e; - - ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); - - if (!(ati_channel_setup & ATI_OUT_ENABLE)) - return 0xf; - - return ((ati_channel_setup & 0xf0) >> 4) + !!was_odd; -} - -static int atihdmi_paired_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, - int channels) -{ - int c; - - /* - * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so - * we need to take that into account (a single channel may take 2 - * channel slots if we need to carry a silent channel next to it). - * On Rev3+ AMD codecs this function is not used. - */ - int chanpairs = 0; - - /* We only produce even-numbered channel count TLVs */ - if ((channels % 2) != 0) - return -1; - - for (c = 0; c < 7; c += 2) { - if (cap->speakers[c] || cap->speakers[c+1]) - chanpairs++; - } - - if (chanpairs * 2 != channels) - return -1; - - return SNDRV_CTL_TLVT_CHMAP_PAIRED; -} - -static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap, - unsigned int *chmap, int channels) -{ - /* produce paired maps for pre-rev3 ATI/AMD codecs */ - int count = 0; - int c; - - for (c = 7; c >= 0; c--) { - int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); - int spk = cap->speakers[chan]; - if (!spk) { - /* add N/A channel if the companion channel is occupied */ - if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) - chmap[count++] = SNDRV_CHMAP_NA; - - continue; - } - - chmap[count++] = spk_to_chmap(spk); - } - - WARN_ON(count != channels); -} - -static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, - bool hbr) -{ - int hbr_ctl, hbr_ctl_new; - - hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); - if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) { - if (hbr) - hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE; - else - hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE; - - snd_printdd("atihdmi_pin_hbr_setup: " - "NID=0x%x, %shbr-ctl=0x%x\n", - pin_nid, - hbr_ctl == hbr_ctl_new ? "" : "new-", - hbr_ctl_new); - - if (hbr_ctl != hbr_ctl_new) - snd_hda_codec_write(codec, pin_nid, 0, - ATI_VERB_SET_HBR_CONTROL, - hbr_ctl_new); - - } else if (hbr) - return -EINVAL; - - return 0; -} - -static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, - hda_nid_t pin_nid, u32 stream_tag, int format) -{ - - if (is_amdhdmi_rev3_or_later(codec)) { - int ramp_rate = 180; /* default as per AMD spec */ - /* disable ramp-up/down for non-pcm as per AMD spec */ - if (format & AC_FMT_TYPE_NON_PCM) - ramp_rate = 0; - - snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); - } - - return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); -} - - -static int atihdmi_init(struct hda_codec *codec) +static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) { struct hdmi_spec *spec = codec->spec; - int pin_idx, err; - - err = generic_hdmi_init(codec); + struct hdmi_spec_per_cvt *per_cvt = get_cvt(spec, 0); + int chans = substream->runtime->channels; + int i, err; - if (err) + err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format, + substream); + if (err < 0) return err; - - for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { - struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); - - /* make sure downmix information in infoframe is zero */ - snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); - - /* enable channel-wise remap mode if supported */ - if (has_amd_full_remap_support(codec)) - snd_hda_codec_write(codec, per_pin->pin_nid, 0, - ATI_VERB_SET_MULTICHANNEL_MODE, - ATI_MULTICHANNEL_MODE_SINGLE); + snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, + AC_VERB_SET_CVT_CHAN_COUNT, chans - 1); + /* FIXME: XXX */ + for (i = 0; i < chans; i++) { + snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, + AC_VERB_SET_HDMI_CHAN_SLOT, + (i << 4) | i); } - return 0; } static int patch_atihdmi(struct hda_codec *codec) { struct hdmi_spec *spec; - struct hdmi_spec_per_cvt *per_cvt; - int err, cvt_idx; - - err = patch_generic_hdmi(codec); - - if (err) + int err = patch_simple_hdmi(codec, ATIHDMI_CVT_NID, ATIHDMI_PIN_NID); + if (err < 0) return err; - - codec->patch_ops.init = atihdmi_init; - spec = codec->spec; - - spec->ops.pin_get_eld = atihdmi_pin_get_eld; - spec->ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; - spec->ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; - spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; - spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; - spec->ops.setup_stream = atihdmi_setup_stream; - - if (!has_amd_full_remap_support(codec)) { - /* override to ATI/AMD-specific versions with pairwise mapping */ - spec->ops.chmap_cea_alloc_validate_get_type = - atihdmi_paired_chmap_cea_alloc_validate_get_type; - spec->ops.cea_alloc_to_tlv_chmap = atihdmi_paired_cea_alloc_to_tlv_chmap; - spec->ops.chmap_validate = atihdmi_paired_chmap_validate; - } - - /* ATI/AMD converters do not advertise all of their capabilities */ - for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { - per_cvt = get_cvt(spec, cvt_idx); - per_cvt->channels_max = max(per_cvt->channels_max, 8u); - per_cvt->rates |= SUPPORTED_RATES; - per_cvt->formats |= SUPPORTED_FORMATS; - per_cvt->maxbps = max(per_cvt->maxbps, 24u); - } - - spec->channels_max = max(spec->channels_max, 8u); - + spec->pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare; return 0; } @@ -3223,7 +2621,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, -{ .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, +{ .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_generic_hdmi }, { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi }, { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi }, { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi }, @@ -3232,30 +2630,30 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, -{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi }, -{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_nvhdmi }, +{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_generic_hdmi }, /* 17 is known to be absent */ -{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi }, -{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi }, +{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi }, { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, @@ -3271,7 +2669,6 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi }, { .id = 0x80862807, .name = "Haswell HDMI", .patch = patch_generic_hdmi }, { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi }, -{ .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi }, { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, {} /* terminator */ }; @@ -3326,7 +2723,6 @@ MODULE_ALIAS("snd-hda-codec-id:80862805"); MODULE_ALIAS("snd-hda-codec-id:80862806"); MODULE_ALIAS("snd-hda-codec-id:80862807"); MODULE_ALIAS("snd-hda-codec-id:80862880"); -MODULE_ALIAS("snd-hda-codec-id:80862882"); MODULE_ALIAS("snd-hda-codec-id:808629fb"); MODULE_LICENSE("GPL"); diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c5ea483..8ad5543 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -554,6 +554,8 @@ do_sku: nid = portd; else if (tmp == 3) nid = porti; + else + return 1; if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins, spec->gen.autocfg.line_outs)) return 1; @@ -577,35 +579,26 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) /* * COEF access helper functions */ - -static int alc_read_coefex_idx(struct hda_codec *codec, - hda_nid_t nid, - unsigned int coef_idx) +static int alc_read_coef_idx(struct hda_codec *codec, + unsigned int coef_idx) { unsigned int val; - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, coef_idx); - val = snd_hda_codec_read(codec, nid, 0, + val = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); return val; } -#define alc_read_coef_idx(codec, coef_idx) \ - alc_read_coefex_idx(codec, 0x20, coef_idx) - -static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, - unsigned int coef_idx, +static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, unsigned int coef_val) { - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, coef_idx); - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, coef_val); } -#define alc_write_coef_idx(codec, coef_idx, coef_val) \ - alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) - /* a special bypass for COEF 0; read the cached value at the second time */ static unsigned int alc_get_coef0(struct hda_codec *codec) { @@ -838,11 +831,7 @@ static inline void alc_shutup(struct hda_codec *codec) snd_hda_shutup_pins(codec); } -static void alc_free(struct hda_codec *codec) -{ - snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); - snd_hda_gen_free(codec); -} +#define alc_free snd_hda_gen_free #ifdef CONFIG_PM static void alc_power_eapd(struct hda_codec *codec) @@ -1054,7 +1043,6 @@ enum { ALC880_FIXUP_UNIWILL, ALC880_FIXUP_UNIWILL_DIG, ALC880_FIXUP_Z71V, - ALC880_FIXUP_ASUS_W5A, ALC880_FIXUP_3ST_BASE, ALC880_FIXUP_3ST, ALC880_FIXUP_3ST_DIG, @@ -1225,26 +1213,6 @@ static const struct hda_fixup alc880_fixups[] = { { } } }, - [ALC880_FIXUP_ASUS_W5A] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - /* set up the whole pins as BIOS is utterly broken */ - { 0x14, 0x0121411f }, /* HP */ - { 0x15, 0x411111f0 }, /* N/A */ - { 0x16, 0x411111f0 }, /* N/A */ - { 0x17, 0x411111f0 }, /* N/A */ - { 0x18, 0x90a60160 }, /* mic */ - { 0x19, 0x411111f0 }, /* N/A */ - { 0x1a, 0x411111f0 }, /* N/A */ - { 0x1b, 0x411111f0 }, /* N/A */ - { 0x1c, 0x411111f0 }, /* N/A */ - { 0x1d, 0x411111f0 }, /* N/A */ - { 0x1e, 0xb743111e }, /* SPDIF out */ - { } - }, - .chained = true, - .chain_id = ALC880_FIXUP_GPIO1, - }, [ALC880_FIXUP_3ST_BASE] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) { @@ -1366,7 +1334,6 @@ static const struct hda_fixup alc880_fixups[] = { static const struct snd_pci_quirk alc880_fixup_tbl[] = { SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), - SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A), SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), @@ -1512,7 +1479,6 @@ enum { ALC260_FIXUP_KN1, ALC260_FIXUP_FSC_S7020, ALC260_FIXUP_FSC_S7020_JWSE, - ALC260_FIXUP_VAIO_PINS, }; static void alc260_gpio1_automute(struct hda_codec *codec) @@ -1653,24 +1619,6 @@ static const struct hda_fixup alc260_fixups[] = { .chained = true, .chain_id = ALC260_FIXUP_FSC_S7020, }, - [ALC260_FIXUP_VAIO_PINS] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - /* Pin configs are missing completely on some VAIOs */ - { 0x0f, 0x01211020 }, - { 0x10, 0x0001003f }, - { 0x11, 0x411111f0 }, - { 0x12, 0x01a15930 }, - { 0x13, 0x411111f0 }, - { 0x14, 0x411111f0 }, - { 0x15, 0x411111f0 }, - { 0x16, 0x411111f0 }, - { 0x17, 0x411111f0 }, - { 0x18, 0x411111f0 }, - { 0x19, 0x411111f0 }, - { } - } - }, }; static const struct snd_pci_quirk alc260_fixup_tbl[] = { @@ -1679,8 +1627,6 @@ static const struct snd_pci_quirk alc260_fixup_tbl[] = { SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), - SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS), - SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F), SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020), SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), @@ -1780,11 +1726,8 @@ enum { ALC889_FIXUP_DAC_ROUTE, ALC889_FIXUP_MBP_VREF, ALC889_FIXUP_IMAC91_VREF, - ALC889_FIXUP_MBA21_VREF, ALC882_FIXUP_INV_DMIC, ALC882_FIXUP_NO_PRIMARY_HP, - ALC887_FIXUP_ASUS_BASS, - ALC887_FIXUP_BASS_CHMAP, }; static void alc889_fixup_coef(struct hda_codec *codec, @@ -1885,13 +1828,17 @@ static void alc889_fixup_mbp_vref(struct hda_codec *codec, } } -static void alc889_fixup_mac_pins(struct hda_codec *codec, - const hda_nid_t *nids, int num_nids) +/* Set VREF on speaker pins on imac91 */ +static void alc889_fixup_imac91_vref(struct hda_codec *codec, + const struct hda_fixup *fix, int action) { struct alc_spec *spec = codec->spec; + static hda_nid_t nids[2] = { 0x18, 0x1a }; int i; - for (i = 0; i < num_nids; i++) { + if (action != HDA_FIXUP_ACT_INIT) + return; + for (i = 0; i < ARRAY_SIZE(nids); i++) { unsigned int val; val = snd_hda_codec_get_pin_target(codec, nids[i]); val |= AC_PINCTL_VREF_50; @@ -1900,26 +1847,6 @@ static void alc889_fixup_mac_pins(struct hda_codec *codec, spec->gen.keep_vref_in_automute = 1; } -/* Set VREF on speaker pins on imac91 */ -static void alc889_fixup_imac91_vref(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - static hda_nid_t nids[2] = { 0x18, 0x1a }; - - if (action == HDA_FIXUP_ACT_INIT) - alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); -} - -/* Set VREF on speaker pins on mba21 */ -static void alc889_fixup_mba21_vref(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - static hda_nid_t nids[2] = { 0x18, 0x19 }; - - if (action == HDA_FIXUP_ACT_INIT) - alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); -} - /* Don't take HP output as primary * Strangely, the speaker output doesn't work on Vaio Z and some Vaio * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05 @@ -1934,9 +1861,6 @@ static void alc882_fixup_no_primary_hp(struct hda_codec *codec, } } -static void alc_fixup_bass_chmap(struct hda_codec *codec, - const struct hda_fixup *fix, int action); - static const struct hda_fixup alc882_fixups[] = { [ALC882_FIXUP_ABIT_AW9D_MAX] = { .type = HDA_FIXUP_PINS, @@ -2119,12 +2043,6 @@ static const struct hda_fixup alc882_fixups[] = { .chained = true, .chain_id = ALC882_FIXUP_GPIO1, }, - [ALC889_FIXUP_MBA21_VREF] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc889_fixup_mba21_vref, - .chained = true, - .chain_id = ALC889_FIXUP_MBP_VREF, - }, [ALC882_FIXUP_INV_DMIC] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_inv_dmic_0x12, @@ -2133,19 +2051,6 @@ static const struct hda_fixup alc882_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc882_fixup_no_primary_hp, }, - [ALC887_FIXUP_ASUS_BASS] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - {0x16, 0x99130130}, /* bass speaker */ - {} - }, - .chained = true, - .chain_id = ALC887_FIXUP_BASS_CHMAP, - }, - [ALC887_FIXUP_BASS_CHMAP] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc_fixup_bass_chmap, - }, }; static const struct snd_pci_quirk alc882_fixup_tbl[] = { @@ -2179,7 +2084,6 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), - SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), @@ -2195,7 +2099,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), - SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF), + SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), @@ -2484,7 +2388,6 @@ static const struct hda_verb alc268_beep_init_verbs[] = { enum { ALC268_FIXUP_INV_DMIC, ALC268_FIXUP_HP_EAPD, - ALC268_FIXUP_SPDIF, }; static const struct hda_fixup alc268_fixups[] = { @@ -2499,13 +2402,6 @@ static const struct hda_fixup alc268_fixups[] = { {} } }, - [ALC268_FIXUP_SPDIF] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - { 0x1e, 0x014b1180 }, /* enable SPDIF out */ - {} - } - }, }; static const struct hda_model_fixup alc268_fixup_models[] = { @@ -2515,7 +2411,6 @@ static const struct hda_model_fixup alc268_fixup_models[] = { }; static const struct snd_pci_quirk alc268_fixup_tbl[] = { - SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF), SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC), /* below is codec SSID since multiple Toshiba laptops have the * same PCI SSID 1179:ff00 @@ -2644,9 +2539,7 @@ enum { ALC269_TYPE_ALC282, ALC269_TYPE_ALC283, ALC269_TYPE_ALC284, - ALC269_TYPE_ALC285, ALC269_TYPE_ALC286, - ALC269_TYPE_ALC255, }; /* @@ -2665,7 +2558,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec) case ALC269_TYPE_ALC269VC: case ALC269_TYPE_ALC280: case ALC269_TYPE_ALC284: - case ALC269_TYPE_ALC285: ssids = alc269va_ssids; break; case ALC269_TYPE_ALC269VB: @@ -2673,7 +2565,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec) case ALC269_TYPE_ALC282: case ALC269_TYPE_ALC283: case ALC269_TYPE_ALC286: - case ALC269_TYPE_ALC255: ssids = alc269_ssids; break; default: @@ -2761,7 +2652,7 @@ static void alc283_shutup(struct hda_codec *codec) AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); if (hp_pin_sense) - msleep(100); + msleep(85); snd_hda_codec_write(codec, hp_pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); @@ -2770,7 +2661,7 @@ static void alc283_shutup(struct hda_codec *codec) alc_write_coef_idx(codec, 0x46, val | (3 << 12)); if (hp_pin_sense) - msleep(100); + msleep(85); snd_hda_shutup_pins(codec); alc_write_coef_idx(codec, 0x43, 0x9614); } @@ -3053,23 +2944,6 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); } -/* Make sure the led works even in runtime suspend */ -static unsigned int led_power_filter(struct hda_codec *codec, - hda_nid_t nid, - unsigned int power_state) -{ - struct alc_spec *spec = codec->spec; - - if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid) - return power_state; - - /* Set pin ctl again, it might have just been set to 0 */ - snd_hda_set_pin_ctl(codec, nid, - snd_hda_codec_get_pin_target(codec, nid)); - - return AC_PWRST_D0; -} - static void alc269_fixup_hp_mute_led(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -3089,7 +2963,6 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec, spec->mute_led_nid = pin - 0x0a + 0x18; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum = 1; - codec->power_filter = led_power_filter; snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid, spec->mute_led_polarity); break; @@ -3105,7 +2978,6 @@ static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec, spec->mute_led_nid = 0x18; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum = 1; - codec->power_filter = led_power_filter; } } @@ -3118,7 +2990,6 @@ static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec, spec->mute_led_nid = 0x19; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum = 1; - codec->power_filter = led_power_filter; } } @@ -3181,19 +3052,6 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) int val; switch (codec->vendor_id) { - case 0x10ec0255: - /* LDO and MISC control */ - alc_write_coef_idx(codec, 0x1b, 0x0c0b); - /* UAJ function set to menual mode */ - alc_write_coef_idx(codec, 0x45, 0xd089); - /* Direct Drive HP Amp control(Set to verb control)*/ - val = alc_read_coefex_idx(codec, 0x57, 0x05); - alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14)); - /* Set MIC2 Vref gate with HP */ - alc_write_coef_idx(codec, 0x06, 0x6104); - /* Direct Drive HP Amp control */ - alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x1b, 0x0c0b); alc_write_coef_idx(codec, 0x45, 0xc429); @@ -3225,14 +3083,6 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, int val; switch (codec->vendor_id) { - case 0x10ec0255: - alc_write_coef_idx(codec, 0x45, 0xc489); - snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); - alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); - /* Set MIC2 Vref gate to normal */ - alc_write_coef_idx(codec, 0x06, 0x6100); - snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x45, 0xc429); snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); @@ -3264,12 +3114,6 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, static void alc_headset_mode_default(struct hda_codec *codec) { switch (codec->vendor_id) { - case 0x10ec0255: - alc_write_coef_idx(codec, 0x45, 0xc089); - alc_write_coef_idx(codec, 0x45, 0xc489); - alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); - alc_write_coef_idx(codec, 0x49, 0x0049); - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x06, 0x2100); alc_write_coef_idx(codec, 0x32, 0x4ea3); @@ -3293,12 +3137,6 @@ static void alc_headset_mode_default(struct hda_codec *codec) static void alc_headset_mode_ctia(struct hda_codec *codec) { switch (codec->vendor_id) { - case 0x10ec0255: - /* Set to CTIA type */ - alc_write_coef_idx(codec, 0x45, 0xd489); - alc_write_coef_idx(codec, 0x1b, 0x0c2b); - alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x45, 0xd429); alc_write_coef_idx(codec, 0x1b, 0x0c2b); @@ -3310,7 +3148,6 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) alc_write_coef_idx(codec, 0x18, 0x7388); break; case 0x10ec0668: - alc_write_coef_idx(codec, 0x11, 0x0001); alc_write_coef_idx(codec, 0x15, 0x0d60); alc_write_coef_idx(codec, 0xc3, 0x0000); break; @@ -3322,12 +3159,6 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) static void alc_headset_mode_omtp(struct hda_codec *codec) { switch (codec->vendor_id) { - case 0x10ec0255: - /* Set to OMTP Type */ - alc_write_coef_idx(codec, 0x45, 0xe489); - alc_write_coef_idx(codec, 0x1b, 0x0c2b); - alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x45, 0xe429); alc_write_coef_idx(codec, 0x1b, 0x0c2b); @@ -3339,7 +3170,6 @@ static void alc_headset_mode_omtp(struct hda_codec *codec) alc_write_coef_idx(codec, 0x18, 0x7388); break; case 0x10ec0668: - alc_write_coef_idx(codec, 0x11, 0x0001); alc_write_coef_idx(codec, 0x15, 0x0d50); alc_write_coef_idx(codec, 0xc3, 0x0000); break; @@ -3354,15 +3184,6 @@ static void alc_determine_headset_type(struct hda_codec *codec) struct alc_spec *spec = codec->spec; switch (codec->vendor_id) { - case 0x10ec0255: - /* combo jack auto switch control(Check type)*/ - alc_write_coef_idx(codec, 0x45, 0xd089); - /* combo jack auto switch control(Vref conteol) */ - alc_write_coef_idx(codec, 0x49, 0x0149); - msleep(300); - val = alc_read_coef_idx(codec, 0x46); - is_ctia = (val & 0x0070) == 0x0070; - break; case 0x10ec0283: alc_write_coef_idx(codec, 0x45, 0xd029); msleep(300); @@ -3409,10 +3230,8 @@ static void alc_update_headset_mode(struct hda_codec *codec) else new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; - if (new_headset_mode == spec->current_headset_mode) { - snd_hda_gen_update_outputs(codec); + if (new_headset_mode == spec->current_headset_mode) return; - } switch (new_headset_mode) { case ALC_HEADSET_MODE_UNPLUGGED: @@ -3458,7 +3277,7 @@ static void alc_update_headset_mode_hook(struct hda_codec *codec, static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack) { struct alc_spec *spec = codec->spec; - spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN; + spec->current_headset_type = ALC_HEADSET_MODE_UNKNOWN; snd_hda_gen_hp_automute(codec, jack); } @@ -3511,21 +3330,6 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, alc_fixup_headset_mode(codec, fix, action); } -static void alc_fixup_headset_mode_alc255(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - if (action == HDA_FIXUP_ACT_PRE_PROBE) { - /* Set to iphone type */ - alc_write_coef_idx(codec, 0x1b, 0x880b); - alc_write_coef_idx(codec, 0x45, 0xd089); - alc_write_coef_idx(codec, 0x1b, 0x080b); - alc_write_coef_idx(codec, 0x46, 0x0004); - alc_write_coef_idx(codec, 0x1b, 0x0c0b); - msleep(30); - } - alc_fixup_headset_mode(codec, fix, action); -} - static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -3625,27 +3429,12 @@ static void alc283_hp_automute_hook(struct hda_codec *codec, vref); } -static void alc283_fixup_chromebook(struct hda_codec *codec, - const struct hda_fixup *fix, int action) +static void alc283_chromebook_caps(struct hda_codec *codec) { - struct alc_spec *spec = codec->spec; - int val; - - switch (action) { - case HDA_FIXUP_ACT_PRE_PROBE: - snd_hda_override_wcaps(codec, 0x03, 0); - /* Disable AA-loopback as it causes white noise */ - spec->gen.mixer_nid = 0; - break; - case HDA_FIXUP_ACT_INIT: - /* Enable Line1 input control by verb */ - val = alc_read_coef_idx(codec, 0x1a); - alc_write_coef_idx(codec, 0x1a, val | (1 << 4)); - break; - } + snd_hda_override_wcaps(codec, 0x03, 0); } -static void alc283_fixup_sense_combo_jack(struct hda_codec *codec, +static void alc283_fixup_chromebook(struct hda_codec *codec, const struct hda_fixup *fix, int action) { struct alc_spec *spec = codec->spec; @@ -3653,13 +3442,15 @@ static void alc283_fixup_sense_combo_jack(struct hda_codec *codec, switch (action) { case HDA_FIXUP_ACT_PRE_PROBE: + alc283_chromebook_caps(codec); spec->gen.hp_automute_hook = alc283_hp_automute_hook; - break; - case HDA_FIXUP_ACT_INIT: /* MIC2-VREF control */ /* Set to manual mode */ val = alc_read_coef_idx(codec, 0x06); alc_write_coef_idx(codec, 0x06, val & ~0x000c); + /* Enable Line1 input control by verb */ + val = alc_read_coef_idx(codec, 0x1a); + alc_write_coef_idx(codec, 0x1a, val | (1 << 4)); break; } } @@ -3723,96 +3514,6 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec, snd_hda_override_wcaps(codec, 0x03, 0); } -#if IS_ENABLED(CONFIG_THINKPAD_ACPI) - -#include <linux/thinkpad_acpi.h> -#include <acpi/acpi.h> - -static int (*led_set_func)(int, bool); - -static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context, - void **rv) -{ - bool *found = context; - *found = true; - return AE_OK; -} - -static bool is_thinkpad(struct hda_codec *codec) -{ - bool found = false; - if (codec->subsystem_id >> 16 != 0x17aa) - return false; - if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found) - return true; - found = false; - return ACPI_SUCCESS(acpi_get_devices("IBM0068", acpi_check_cb, &found, NULL)) && found; -} - -static void update_tpacpi_mute_led(void *private_data, int enabled) -{ - if (led_set_func) - led_set_func(TPACPI_LED_MUTE, !enabled); -} - -static void update_tpacpi_micmute_led(struct hda_codec *codec, - struct snd_ctl_elem_value *ucontrol) -{ - if (!ucontrol || !led_set_func) - return; - if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) { - /* TODO: How do I verify if it's a mono or stereo here? */ - bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]; - led_set_func(TPACPI_LED_MICMUTE, !val); - } -} - -static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - struct alc_spec *spec = codec->spec; - bool removefunc = false; - - if (action == HDA_FIXUP_ACT_PROBE) { - if (!is_thinkpad(codec)) - return; - if (!led_set_func) - led_set_func = symbol_request(tpacpi_led_set); - if (!led_set_func) { - snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n"); - return; - } - - removefunc = true; - if (led_set_func(TPACPI_LED_MUTE, false) >= 0) { - spec->gen.vmaster_mute.hook = update_tpacpi_mute_led; - removefunc = false; - } - if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { - if (spec->gen.num_adc_nids > 1) - snd_printdd("Skipping micmute LED control due to several ADCs"); - else { - spec->gen.cap_sync_hook = update_tpacpi_micmute_led; - removefunc = false; - } - } - } - - if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) { - symbol_put(tpacpi_led_set); - led_set_func = NULL; - } -} - -#else - -static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ -} - -#endif - enum { ALC269_FIXUP_SONY_VAIO, ALC275_FIXUP_SONY_VAIO_GPIO2, @@ -3851,17 +3552,11 @@ enum { ALC271_FIXUP_HP_GATE_MIC_JACK, ALC269_FIXUP_ACER_AC700, ALC269_FIXUP_LIMIT_INT_MIC_BOOST, - ALC269VB_FIXUP_ASUS_ZENBOOK, - ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED, ALC269VB_FIXUP_ORDISSIMO_EVE2, ALC283_FIXUP_CHROME_BOOK, - ALC283_FIXUP_SENSE_COMBO_JACK, ALC282_FIXUP_ASUS_TX300, ALC283_FIXUP_INT_MIC, ALC290_FIXUP_MONO_SPEAKERS, - ALC269_FIXUP_THINKPAD_ACPI, - ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, - ALC255_FIXUP_HEADSET_MODE, }; static const struct hda_fixup alc269_fixups[] = { @@ -4021,8 +3716,6 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_pincfg_no_hp_to_lineout, - .chained = true, - .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS, @@ -4127,20 +3820,6 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_limit_int_mic_boost, - .chained = true, - .chain_id = ALC269_FIXUP_THINKPAD_ACPI, - }, - [ALC269VB_FIXUP_ASUS_ZENBOOK] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc269_fixup_limit_int_mic_boost, - .chained = true, - .chain_id = ALC269VB_FIXUP_DMIC, - }, - [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc269_fixup_limit_int_mic_boost, - .chained = true, - .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1, }, [ALC269VB_FIXUP_ORDISSIMO_EVE2] = { .type = HDA_FIXUP_PINS, @@ -4155,12 +3834,6 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc283_fixup_chromebook, }, - [ALC283_FIXUP_SENSE_COMBO_JACK] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc283_fixup_sense_combo_jack, - .chained = true, - .chain_id = ALC283_FIXUP_CHROME_BOOK, - }, [ALC282_FIXUP_ASUS_TX300] = { .type = HDA_FIXUP_FUNC, .v.func = alc282_fixup_asus_tx300, @@ -4181,24 +3854,6 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, }, - [ALC269_FIXUP_THINKPAD_ACPI] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc_fixup_thinkpad_acpi, - }, - [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ - { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ - { } - }, - .chained = true, - .chain_id = ALC255_FIXUP_HEADSET_MODE - }, - [ALC255_FIXUP_HEADSET_MODE] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc_fixup_headset_mode_alc255, - }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -4240,24 +3895,20 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS), - SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS), - SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), - SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), + SND_PCI_QUIRK(0x103c, 0x21ed, "HP Falco Chromebook", ALC283_FIXUP_CHROME_BOOK), SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), - SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK), - SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK), + 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, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), @@ -4294,7 +3945,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), - SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI), SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ #if 0 @@ -4359,8 +4009,6 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"}, - {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-chrome"}, - {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"}, {} }; @@ -4477,16 +4125,9 @@ static int patch_alc269(struct hda_codec *codec) case 0x10ec0292: spec->codec_variant = ALC269_TYPE_ALC284; break; - case 0x10ec0285: - case 0x10ec0293: - spec->codec_variant = ALC269_TYPE_ALC285; - break; case 0x10ec0286: spec->codec_variant = ALC269_TYPE_ALC286; break; - case 0x10ec0255: - spec->codec_variant = ALC269_TYPE_ALC255; - break; } if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { @@ -4536,7 +4177,6 @@ enum { ALC861_FIXUP_AMP_VREF_0F, ALC861_FIXUP_NO_JACK_DETECT, ALC861_FIXUP_ASUS_A6RP, - ALC660_FIXUP_ASUS_W7J, }; /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ @@ -4586,22 +4226,10 @@ static const struct hda_fixup alc861_fixups[] = { .v.func = alc861_fixup_asus_amp_vref_0f, .chained = true, .chain_id = ALC861_FIXUP_NO_JACK_DETECT, - }, - [ALC660_FIXUP_ASUS_W7J] = { - .type = HDA_FIXUP_VERBS, - .v.verbs = (const struct hda_verb[]) { - /* ASUS W7J needs a magic pin setup on unused NID 0x10 - * for enabling outputs - */ - {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, - { } - }, } }; static const struct snd_pci_quirk alc861_fixup_tbl[] = { - SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J), - SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J), SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), @@ -4787,25 +4415,6 @@ static void alc272_fixup_mario(struct hda_codec *codec, "hda_codec: failed to override amp caps for NID 0x2\n"); } -static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = { - { .channels = 2, - .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, - { .channels = 4, - .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, - SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */ - { } -}; - -/* override the 2.1 chmap */ -static void alc_fixup_bass_chmap(struct hda_codec *codec, - const struct hda_fixup *fix, int action) -{ - if (action == HDA_FIXUP_ACT_BUILD) { - struct alc_spec *spec = codec->spec; - spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps; - } -} - enum { ALC662_FIXUP_ASPIRE, ALC662_FIXUP_IDEAPAD, @@ -4826,9 +4435,6 @@ enum { ALC662_FIXUP_INV_DMIC, ALC668_FIXUP_DELL_MIC_NO_PRESENCE, ALC668_FIXUP_HEADSET_MODE, - ALC662_FIXUP_BASS_CHMAP, - ALC662_FIXUP_BASS_1A, - ALC662_FIXUP_BASS_1A_CHMAP, }; static const struct hda_fixup alc662_fixups[] = { @@ -5003,25 +4609,6 @@ static const struct hda_fixup alc662_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_headset_mode_alc668, }, - [ALC662_FIXUP_BASS_CHMAP] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc_fixup_bass_chmap, - .chained = true, - .chain_id = ALC662_FIXUP_ASUS_MODE4 - }, - [ALC662_FIXUP_BASS_1A] = { - .type = HDA_FIXUP_PINS, - .v.pins = (const struct hda_pintbl[]) { - {0x1a, 0x80106111}, /* bass speaker */ - {} - }, - }, - [ALC662_FIXUP_BASS_1A_CHMAP] = { - .type = HDA_FIXUP_FUNC, - .v.func = alc_fixup_bass_chmap, - .chained = true, - .chain_id = ALC662_FIXUP_BASS_1A, - }, }; static const struct snd_pci_quirk alc662_fixup_tbl[] = { @@ -5034,12 +4621,9 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), - SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP), - SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP), - SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_CHMAP), + SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4), + SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_ASUS_MODE4), SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), @@ -5200,7 +4784,6 @@ static int patch_alc662(struct hda_codec *codec) case 0x10ec0272: case 0x10ec0663: case 0x10ec0665: - case 0x10ec0668: set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); break; case 0x10ec0273: @@ -5258,9 +4841,7 @@ static int patch_alc680(struct hda_codec *codec) */ static const struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, - { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 }, { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 }, - { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 }, { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, @@ -5274,11 +4855,9 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, - { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 }, { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, - { .id = 0x10ec0293, .name = "ALC293", .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 088a5af..fba0cef 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -100,7 +100,6 @@ enum { STAC_92HD83XXX_HEADSET_JACK, STAC_92HD83XXX_HP, STAC_HP_ENVY_BASS, - STAC_HP_BNB13_EQ, STAC_92HD83XXX_MODELS }; @@ -2092,11 +2091,8 @@ static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec, { struct sigmatel_spec *spec = codec->spec; - if (action == HDA_FIXUP_ACT_PRE_PROBE) { + if (action == HDA_FIXUP_ACT_PRE_PROBE) spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ - /* resetting controller clears GPIO, so we need to keep on */ - codec->bus->power_keep_link_on = 1; - } } static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, @@ -2108,434 +2104,6 @@ static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, spec->headset_jack = 1; } -static const struct hda_verb hp_bnb13_eq_verbs[] = { - /* 44.1KHz base */ - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x68 }, - { 0x22, 0x7A8, 0x17 }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x68 }, - { 0x22, 0x7AB, 0x17 }, - { 0x22, 0x7AC, 0x00 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x83 }, - { 0x22, 0x7A7, 0x2F }, - { 0x22, 0x7A8, 0xD1 }, - { 0x22, 0x7A9, 0x83 }, - { 0x22, 0x7AA, 0x2F }, - { 0x22, 0x7AB, 0xD1 }, - { 0x22, 0x7AC, 0x01 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x68 }, - { 0x22, 0x7A8, 0x17 }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x68 }, - { 0x22, 0x7AB, 0x17 }, - { 0x22, 0x7AC, 0x02 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x7C }, - { 0x22, 0x7A7, 0xC6 }, - { 0x22, 0x7A8, 0x0C }, - { 0x22, 0x7A9, 0x7C }, - { 0x22, 0x7AA, 0xC6 }, - { 0x22, 0x7AB, 0x0C }, - { 0x22, 0x7AC, 0x03 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC3 }, - { 0x22, 0x7A7, 0x25 }, - { 0x22, 0x7A8, 0xAF }, - { 0x22, 0x7A9, 0xC3 }, - { 0x22, 0x7AA, 0x25 }, - { 0x22, 0x7AB, 0xAF }, - { 0x22, 0x7AC, 0x04 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x85 }, - { 0x22, 0x7A8, 0x73 }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x85 }, - { 0x22, 0x7AB, 0x73 }, - { 0x22, 0x7AC, 0x05 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x85 }, - { 0x22, 0x7A7, 0x39 }, - { 0x22, 0x7A8, 0xC7 }, - { 0x22, 0x7A9, 0x85 }, - { 0x22, 0x7AA, 0x39 }, - { 0x22, 0x7AB, 0xC7 }, - { 0x22, 0x7AC, 0x06 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3C }, - { 0x22, 0x7A7, 0x90 }, - { 0x22, 0x7A8, 0xB0 }, - { 0x22, 0x7A9, 0x3C }, - { 0x22, 0x7AA, 0x90 }, - { 0x22, 0x7AB, 0xB0 }, - { 0x22, 0x7AC, 0x07 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x7A }, - { 0x22, 0x7A7, 0xC6 }, - { 0x22, 0x7A8, 0x39 }, - { 0x22, 0x7A9, 0x7A }, - { 0x22, 0x7AA, 0xC6 }, - { 0x22, 0x7AB, 0x39 }, - { 0x22, 0x7AC, 0x08 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC4 }, - { 0x22, 0x7A7, 0xE9 }, - { 0x22, 0x7A8, 0xDC }, - { 0x22, 0x7A9, 0xC4 }, - { 0x22, 0x7AA, 0xE9 }, - { 0x22, 0x7AB, 0xDC }, - { 0x22, 0x7AC, 0x09 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3D }, - { 0x22, 0x7A7, 0xE1 }, - { 0x22, 0x7A8, 0x0D }, - { 0x22, 0x7A9, 0x3D }, - { 0x22, 0x7AA, 0xE1 }, - { 0x22, 0x7AB, 0x0D }, - { 0x22, 0x7AC, 0x0A }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x89 }, - { 0x22, 0x7A7, 0xB6 }, - { 0x22, 0x7A8, 0xEB }, - { 0x22, 0x7A9, 0x89 }, - { 0x22, 0x7AA, 0xB6 }, - { 0x22, 0x7AB, 0xEB }, - { 0x22, 0x7AC, 0x0B }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x39 }, - { 0x22, 0x7A7, 0x9D }, - { 0x22, 0x7A8, 0xFE }, - { 0x22, 0x7A9, 0x39 }, - { 0x22, 0x7AA, 0x9D }, - { 0x22, 0x7AB, 0xFE }, - { 0x22, 0x7AC, 0x0C }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x76 }, - { 0x22, 0x7A7, 0x49 }, - { 0x22, 0x7A8, 0x15 }, - { 0x22, 0x7A9, 0x76 }, - { 0x22, 0x7AA, 0x49 }, - { 0x22, 0x7AB, 0x15 }, - { 0x22, 0x7AC, 0x0D }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC8 }, - { 0x22, 0x7A7, 0x80 }, - { 0x22, 0x7A8, 0xF5 }, - { 0x22, 0x7A9, 0xC8 }, - { 0x22, 0x7AA, 0x80 }, - { 0x22, 0x7AB, 0xF5 }, - { 0x22, 0x7AC, 0x0E }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x0F }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x90 }, - { 0x22, 0x7A7, 0x68 }, - { 0x22, 0x7A8, 0xF1 }, - { 0x22, 0x7A9, 0x90 }, - { 0x22, 0x7AA, 0x68 }, - { 0x22, 0x7AB, 0xF1 }, - { 0x22, 0x7AC, 0x10 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x34 }, - { 0x22, 0x7A7, 0x47 }, - { 0x22, 0x7A8, 0x6C }, - { 0x22, 0x7A9, 0x34 }, - { 0x22, 0x7AA, 0x47 }, - { 0x22, 0x7AB, 0x6C }, - { 0x22, 0x7AC, 0x11 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x6F }, - { 0x22, 0x7A7, 0x97 }, - { 0x22, 0x7A8, 0x0F }, - { 0x22, 0x7A9, 0x6F }, - { 0x22, 0x7AA, 0x97 }, - { 0x22, 0x7AB, 0x0F }, - { 0x22, 0x7AC, 0x12 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xCB }, - { 0x22, 0x7A7, 0xB8 }, - { 0x22, 0x7A8, 0x94 }, - { 0x22, 0x7A9, 0xCB }, - { 0x22, 0x7AA, 0xB8 }, - { 0x22, 0x7AB, 0x94 }, - { 0x22, 0x7AC, 0x13 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x14 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x95 }, - { 0x22, 0x7A7, 0x76 }, - { 0x22, 0x7A8, 0x5B }, - { 0x22, 0x7A9, 0x95 }, - { 0x22, 0x7AA, 0x76 }, - { 0x22, 0x7AB, 0x5B }, - { 0x22, 0x7AC, 0x15 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x31 }, - { 0x22, 0x7A7, 0xAC }, - { 0x22, 0x7A8, 0x31 }, - { 0x22, 0x7A9, 0x31 }, - { 0x22, 0x7AA, 0xAC }, - { 0x22, 0x7AB, 0x31 }, - { 0x22, 0x7AC, 0x16 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x6A }, - { 0x22, 0x7A7, 0x89 }, - { 0x22, 0x7A8, 0xA5 }, - { 0x22, 0x7A9, 0x6A }, - { 0x22, 0x7AA, 0x89 }, - { 0x22, 0x7AB, 0xA5 }, - { 0x22, 0x7AC, 0x17 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xCE }, - { 0x22, 0x7A7, 0x53 }, - { 0x22, 0x7A8, 0xCF }, - { 0x22, 0x7A9, 0xCE }, - { 0x22, 0x7AA, 0x53 }, - { 0x22, 0x7AB, 0xCF }, - { 0x22, 0x7AC, 0x18 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x19 }, - { 0x22, 0x7AD, 0x80 }, - /* 48KHz base */ - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x88 }, - { 0x22, 0x7A8, 0xDC }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x88 }, - { 0x22, 0x7AB, 0xDC }, - { 0x22, 0x7AC, 0x1A }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x82 }, - { 0x22, 0x7A7, 0xEE }, - { 0x22, 0x7A8, 0x46 }, - { 0x22, 0x7A9, 0x82 }, - { 0x22, 0x7AA, 0xEE }, - { 0x22, 0x7AB, 0x46 }, - { 0x22, 0x7AC, 0x1B }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x88 }, - { 0x22, 0x7A8, 0xDC }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x88 }, - { 0x22, 0x7AB, 0xDC }, - { 0x22, 0x7AC, 0x1C }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x7D }, - { 0x22, 0x7A7, 0x09 }, - { 0x22, 0x7A8, 0x28 }, - { 0x22, 0x7A9, 0x7D }, - { 0x22, 0x7AA, 0x09 }, - { 0x22, 0x7AB, 0x28 }, - { 0x22, 0x7AC, 0x1D }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC2 }, - { 0x22, 0x7A7, 0xE5 }, - { 0x22, 0x7A8, 0xB4 }, - { 0x22, 0x7A9, 0xC2 }, - { 0x22, 0x7AA, 0xE5 }, - { 0x22, 0x7AB, 0xB4 }, - { 0x22, 0x7AC, 0x1E }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0xA3 }, - { 0x22, 0x7A8, 0x1F }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0xA3 }, - { 0x22, 0x7AB, 0x1F }, - { 0x22, 0x7AC, 0x1F }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x84 }, - { 0x22, 0x7A7, 0xCA }, - { 0x22, 0x7A8, 0xF1 }, - { 0x22, 0x7A9, 0x84 }, - { 0x22, 0x7AA, 0xCA }, - { 0x22, 0x7AB, 0xF1 }, - { 0x22, 0x7AC, 0x20 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3C }, - { 0x22, 0x7A7, 0xD5 }, - { 0x22, 0x7A8, 0x9C }, - { 0x22, 0x7A9, 0x3C }, - { 0x22, 0x7AA, 0xD5 }, - { 0x22, 0x7AB, 0x9C }, - { 0x22, 0x7AC, 0x21 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x7B }, - { 0x22, 0x7A7, 0x35 }, - { 0x22, 0x7A8, 0x0F }, - { 0x22, 0x7A9, 0x7B }, - { 0x22, 0x7AA, 0x35 }, - { 0x22, 0x7AB, 0x0F }, - { 0x22, 0x7AC, 0x22 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC4 }, - { 0x22, 0x7A7, 0x87 }, - { 0x22, 0x7A8, 0x45 }, - { 0x22, 0x7A9, 0xC4 }, - { 0x22, 0x7AA, 0x87 }, - { 0x22, 0x7AB, 0x45 }, - { 0x22, 0x7AC, 0x23 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3E }, - { 0x22, 0x7A7, 0x0A }, - { 0x22, 0x7A8, 0x78 }, - { 0x22, 0x7A9, 0x3E }, - { 0x22, 0x7AA, 0x0A }, - { 0x22, 0x7AB, 0x78 }, - { 0x22, 0x7AC, 0x24 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x88 }, - { 0x22, 0x7A7, 0xE2 }, - { 0x22, 0x7A8, 0x05 }, - { 0x22, 0x7A9, 0x88 }, - { 0x22, 0x7AA, 0xE2 }, - { 0x22, 0x7AB, 0x05 }, - { 0x22, 0x7AC, 0x25 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x3A }, - { 0x22, 0x7A7, 0x1A }, - { 0x22, 0x7A8, 0xA3 }, - { 0x22, 0x7A9, 0x3A }, - { 0x22, 0x7AA, 0x1A }, - { 0x22, 0x7AB, 0xA3 }, - { 0x22, 0x7AC, 0x26 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x77 }, - { 0x22, 0x7A7, 0x1D }, - { 0x22, 0x7A8, 0xFB }, - { 0x22, 0x7A9, 0x77 }, - { 0x22, 0x7AA, 0x1D }, - { 0x22, 0x7AB, 0xFB }, - { 0x22, 0x7AC, 0x27 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xC7 }, - { 0x22, 0x7A7, 0xDA }, - { 0x22, 0x7A8, 0xE5 }, - { 0x22, 0x7A9, 0xC7 }, - { 0x22, 0x7AA, 0xDA }, - { 0x22, 0x7AB, 0xE5 }, - { 0x22, 0x7AC, 0x28 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x29 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x8E }, - { 0x22, 0x7A7, 0xD7 }, - { 0x22, 0x7A8, 0x22 }, - { 0x22, 0x7A9, 0x8E }, - { 0x22, 0x7AA, 0xD7 }, - { 0x22, 0x7AB, 0x22 }, - { 0x22, 0x7AC, 0x2A }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x35 }, - { 0x22, 0x7A7, 0x26 }, - { 0x22, 0x7A8, 0xC6 }, - { 0x22, 0x7A9, 0x35 }, - { 0x22, 0x7AA, 0x26 }, - { 0x22, 0x7AB, 0xC6 }, - { 0x22, 0x7AC, 0x2B }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x71 }, - { 0x22, 0x7A7, 0x28 }, - { 0x22, 0x7A8, 0xDE }, - { 0x22, 0x7A9, 0x71 }, - { 0x22, 0x7AA, 0x28 }, - { 0x22, 0x7AB, 0xDE }, - { 0x22, 0x7AC, 0x2C }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xCA }, - { 0x22, 0x7A7, 0xD9 }, - { 0x22, 0x7A8, 0x3A }, - { 0x22, 0x7A9, 0xCA }, - { 0x22, 0x7AA, 0xD9 }, - { 0x22, 0x7AB, 0x3A }, - { 0x22, 0x7AC, 0x2D }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x2E }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x93 }, - { 0x22, 0x7A7, 0x5E }, - { 0x22, 0x7A8, 0xD8 }, - { 0x22, 0x7A9, 0x93 }, - { 0x22, 0x7AA, 0x5E }, - { 0x22, 0x7AB, 0xD8 }, - { 0x22, 0x7AC, 0x2F }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x32 }, - { 0x22, 0x7A7, 0xB7 }, - { 0x22, 0x7A8, 0xB1 }, - { 0x22, 0x7A9, 0x32 }, - { 0x22, 0x7AA, 0xB7 }, - { 0x22, 0x7AB, 0xB1 }, - { 0x22, 0x7AC, 0x30 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x6C }, - { 0x22, 0x7A7, 0xA1 }, - { 0x22, 0x7A8, 0x28 }, - { 0x22, 0x7A9, 0x6C }, - { 0x22, 0x7AA, 0xA1 }, - { 0x22, 0x7AB, 0x28 }, - { 0x22, 0x7AC, 0x31 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0xCD }, - { 0x22, 0x7A7, 0x48 }, - { 0x22, 0x7A8, 0x4F }, - { 0x22, 0x7A9, 0xCD }, - { 0x22, 0x7AA, 0x48 }, - { 0x22, 0x7AB, 0x4F }, - { 0x22, 0x7AC, 0x32 }, - { 0x22, 0x7AD, 0x80 }, - { 0x22, 0x7A6, 0x40 }, - { 0x22, 0x7A7, 0x00 }, - { 0x22, 0x7A8, 0x00 }, - { 0x22, 0x7A9, 0x40 }, - { 0x22, 0x7AA, 0x00 }, - { 0x22, 0x7AB, 0x00 }, - { 0x22, 0x7AC, 0x33 }, - { 0x22, 0x7AD, 0x80 }, - /* common */ - { 0x22, 0x782, 0xC1 }, - { 0x22, 0x771, 0x2C }, - { 0x22, 0x772, 0x2C }, - { 0x22, 0x788, 0x04 }, - { 0x01, 0x7B0, 0x08 }, - {} -}; - static const struct hda_fixup stac92hd83xxx_fixups[] = { [STAC_92HD83XXX_REF] = { .type = HDA_FIXUP_PINS, @@ -2604,12 +2172,6 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = { {} }, }, - [STAC_HP_BNB13_EQ] = { - .type = HDA_FIXUP_VERBS, - .v.verbs = hp_bnb13_eq_verbs, - .chained = true, - .chain_id = STAC_92HD83XXX_HP_MIC_LED, - }, }; static const struct hda_model_fixup stac92hd83xxx_models[] = { @@ -2625,7 +2187,6 @@ static const struct hda_model_fixup stac92hd83xxx_models[] = { { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" }, { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" }, { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" }, - { .id = STAC_HP_BNB13_EQ, .name = "hp-bnb13-eq" }, {} }; @@ -2672,101 +2233,7 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = { SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888, "HP Envy Spectre", STAC_HP_ENVY_BASS), SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, - "HP Folio", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18F8, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1909, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x190A, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1940, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1941, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1942, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1943, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1944, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1945, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1946, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1948, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1949, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194A, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194B, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194C, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194E, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194F, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1950, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1951, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195A, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195B, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195C, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1991, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2103, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2104, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2105, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2106, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2107, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2108, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2109, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210A, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210B, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211C, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211D, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211E, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211F, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2120, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2121, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2122, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2123, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213E, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213F, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2140, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B2, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B3, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B5, - "HP bNB13", STAC_HP_BNB13_EQ), - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B6, - "HP bNB13", STAC_HP_BNB13_EQ), + "HP Folio", STAC_92HD83XXX_HP_MIC_LED), SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x1900, "HP", STAC_92HD83XXX_HP_MIC_LED), SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2000, diff --git a/sound/pci/ice1712/psc724.c b/sound/pci/ice1712/psc724.c index 4019cf2..302ac6d 100644 --- a/sound/pci/ice1712/psc724.c +++ b/sound/pci/ice1712/psc724.c @@ -203,12 +203,12 @@ static void psc724_set_jack_state(struct snd_ice1712 *ice, bool hp_connected) /* notify about master speaker mute change */ memset(&elem_id, 0, sizeof(elem_id)); elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - strlcpy(elem_id.name, "Master Speakers Playback Switch", + strncpy(elem_id.name, "Master Speakers Playback Switch", sizeof(elem_id.name)); kctl = snd_ctl_find_id(ice->card, &elem_id); snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); /* and headphone mute change */ - strlcpy(elem_id.name, spec->wm8776.ctl[WM8776_CTL_HP_SW].name, + strncpy(elem_id.name, spec->wm8776.ctl[WM8776_CTL_HP_SW].name, sizeof(elem_id.name)); kctl = snd_ctl_find_id(ice->card, &elem_id); snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index 71c6003..975e035 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -203,7 +203,6 @@ static const char * const ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS", #define AK4620_DEEMVOL_REG 0x03 #define AK4620_SMUTE (1<<7) -#ifdef CONFIG_PROC_FS /* * Conversion from int value to its binary form. Used for debugging. * The output buffer must be allocated prior to calling the function. @@ -228,7 +227,6 @@ static char *get_binary(char *buffer, int value) buffer[pos] = '\0'; return buffer; } -#endif /* CONFIG_PROC_FS */ /* * Initial setup of the conversion array GPIO <-> rate diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c index 21b373b..e473f8a 100644 --- a/sound/pci/ice1712/wm8766.c +++ b/sound/pci/ice1712/wm8766.c @@ -253,8 +253,7 @@ static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol, } if (wm->ctl[n].flags & WM8766_FLAG_INVERT) { val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); - if (wm->ctl[n].flags & WM8766_FLAG_STEREO) - val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); + val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); } ucontrol->value.integer.value[0] = val1; if (wm->ctl[n].flags & WM8766_FLAG_STEREO) diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c index e66c0da..a3c05fe 100644 --- a/sound/pci/ice1712/wm8776.c +++ b/sound/pci/ice1712/wm8776.c @@ -52,7 +52,7 @@ static void snd_wm8776_activate_ctl(struct snd_wm8776 *wm, unsigned int index_offset; memset(&elem_id, 0, sizeof(elem_id)); - strlcpy(elem_id.name, ctl_name, sizeof(elem_id.name)); + strncpy(elem_id.name, ctl_name, sizeof(elem_id.name)); elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; kctl = snd_ctl_find_id(card, &elem_id); if (!kctl) @@ -526,8 +526,7 @@ static int snd_wm8776_ctl_get(struct snd_kcontrol *kcontrol, } if (wm->ctl[n].flags & WM8776_FLAG_INVERT) { val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); - if (wm->ctl[n].flags & WM8776_FLAG_STEREO) - val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); + val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); } ucontrol->value.integer.value[0] = val1; if (wm->ctl[n].flags & WM8776_FLAG_STEREO) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 08d8733..59c8aae 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1541,16 +1541,17 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, snd_dma_pci_data(chip->pci), rec->prealloc_size, rec->prealloc_max_size); - if (rec->playback_ops && - rec->playback_ops->open == snd_intel8x0_playback_open) { + if (rec->ac97_idx == ICHD_PCMOUT && rec->playback_ops) { struct snd_pcm_chmap *chmap; int chs = 2; - if (chip->multi8) - chs = 8; - else if (chip->multi6) - chs = 6; - else if (chip->multi4) - chs = 4; + 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); diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index 0568540..7307d97 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c @@ -463,7 +463,7 @@ static int lola_parse_tree(struct lola *chip) err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val); if (err < 0) { - printk(KERN_ERR SFX "Can't read FUNCTION_TYPE\n"); + printk(KERN_ERR SFX "Can't read FUNCTION_TYPE for 0x%x\n", nid); return err; } if (val != 1) { diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 5fcaaa6..3230e57 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -453,8 +453,8 @@ static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream) lower_32_bits(buf), upper_32_bits(buf), &buffer_index); - snd_printdd(LXP "starting: buffer index %x on 0x%lx (%d bytes)\n", - buffer_index, (unsigned long)buf, period_bytes); + snd_printdd(LXP "starting: buffer index %x on %p (%d bytes)\n", + buffer_index, (void *)buf, period_bytes); buf += period_bytes; } diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 626ecad..633c860 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -1191,8 +1191,8 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip, unpack_pointer(buf, &buf_lo, &buf_hi); err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi, &buffer_index); - snd_printdd(LXP "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n", - buffer_index, (unsigned long)buf, period_bytes); + snd_printdd(LXP "interrupt: gave buffer index %x on %p (%d bytes)\n", + buffer_index, (void *)buf, period_bytes); lx_stream->frame_pos = next_pos; spin_unlock_irqrestore(&chip->lock, flags); diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 0236363..bb9ebc5 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -350,8 +350,9 @@ snd_rme96_playback_copy(struct snd_pcm_substream *substream, struct rme96 *rme96 = snd_pcm_substream_chip(substream); count <<= rme96->playback_frlog; pos <<= rme96->playback_frlog; - return copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src, - count); + copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src, + count); + return 0; } static int @@ -364,8 +365,9 @@ snd_rme96_capture_copy(struct snd_pcm_substream *substream, struct rme96 *rme96 = snd_pcm_substream_chip(substream); count <<= rme96->capture_frlog; pos <<= rme96->capture_frlog; - return copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos, - count); + copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos, + count); + return 0; } /* diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index e98dc00..3cde55b 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -3996,6 +3996,7 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) return 1; } return 0; + break; case AES32: status = hdspm_read(hdspm, HDSPM_statusRegister); if (status & HDSPM_tcoLockAes) { @@ -4005,6 +4006,9 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) return 1; } return 0; + + break; + case RayDAT: case AIO: status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); @@ -4014,6 +4018,7 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) if (status & 0x4000000) return 1; /* Lock */ return 0; /* No signal */ + break; default: break; @@ -6400,7 +6405,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, memset(&hdspm_version, 0, sizeof(hdspm_version)); hdspm_version.card_type = hdspm->io_type; - strlcpy(hdspm_version.cardname, hdspm->card_name, + strncpy(hdspm_version.cardname, hdspm->card_name, sizeof(hdspm_version.cardname)); hdspm_version.serial = hdspm->serial; hdspm_version.firmware_rev = hdspm->firmware_rev; diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index 0d1c27e..01aecc2 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -65,7 +65,7 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter) * already bound. If not it means binding failed, and then there * is no point in keeping the device instantiated. */ - if (!keywest_ctx->client->dev.driver) { + if (!keywest_ctx->client->driver) { i2c_unregister_device(keywest_ctx->client); keywest_ctx->client = NULL; return -ENODEV; @@ -76,7 +76,7 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter) * This is safe because i2c-core holds the core_lock mutex for us. */ list_add_tail(&keywest_ctx->client->detected, - &to_i2c_driver(keywest_ctx->client->dev.driver)->clients); + &keywest_ctx->client->driver->clients); return 0; } diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 7a43c0c..c93fbbb 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -28,8 +28,6 @@ #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/dma-mapping.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> #include <sound/core.h> #include "pmac.h" #include <sound/pcm_params.h> diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index ebb76f2..8c7dcbe 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -933,10 +933,8 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev) int i, ret; u64 lpar_addr, lpar_size; - if (WARN_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1))) - return -ENODEV; - if (WARN_ON(dev->match_id != PS3_MATCH_ID_SOUND)) - return -ENODEV; + BUG_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1)); + BUG_ON(dev->match_id != PS3_MATCH_ID_SOUND); the_card.ps3_dev = dev; diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index b9ffc17..b23354a 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -31,7 +31,6 @@ #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/string.h> -#include <linux/of_irq.h> #include <sound/core.h> #include <asm/io.h> #include <asm/irq.h> diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 8b9e701..61a64d2 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,5 +1,5 @@ snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o -snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o +snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) snd-soc-core-objs += soc-generic-dmaengine-pcm.o diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c index 8ae3fa5..3109db7 100644 --- a/sound/soc/atmel/atmel-pcm.c +++ b/sound/soc/atmel/atmel-pcm.c @@ -50,7 +50,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, buf->area = dma_alloc_coherent(pcm->card->dev, size, &buf->addr, GFP_KERNEL); pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", - (void *)buf->area, (void *)(long)buf->addr, size); + (void *)buf->area, (void *)buf->addr, size); if (!buf->area) return -ENOMEM; @@ -68,15 +68,18 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(atmel_pcm_mmap); +static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32); + int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &atmel_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n"); diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 8697ced..bb53dea 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -777,7 +777,7 @@ static int asoc_ssc_init(struct device *dev) if (ret) { dev_err(dev, "Could not register PCM: %d\n", ret); goto err_unregister_dai; - } + }; return 0; diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c index b4e3690..7222380 100644 --- a/sound/soc/atmel/atmel_wm8904.c +++ b/sound/soc/atmel/atmel_wm8904.c @@ -12,6 +12,7 @@ #include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/pinctrl/consumer.h> #include <sound/soc.h> @@ -154,8 +155,15 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev) struct snd_soc_card *card = &atmel_asoc_wm8904_card; struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; struct clk *clk_src; + struct pinctrl *pinctrl; int id, ret; + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); + if (IS_ERR(pinctrl)) { + dev_err(&pdev->dev, "failed to request pinctrl\n"); + return PTR_ERR(pinctrl); + } + card->dev = &pdev->dev; ret = atmel_asoc_wm8904_dt_init(pdev); if (ret) { diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index f15bff1..802717e 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -37,7 +37,6 @@ #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/i2c.h> -#include <linux/of.h> #include <linux/atmel-ssc.h> diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c index 1b37228..992ae38 100644 --- a/sound/soc/atmel/sam9x5_wm8731.c +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -97,8 +97,6 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) goto out; } - snd_soc_card_set_drvdata(card, priv); - card->dev = &pdev->dev; card->owner = THIS_MODULE; card->dai_link = dai; diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 1d4c676..53f8408 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -415,16 +415,19 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm) } } +static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32); + static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; pr_debug("%s enter\n", __func__); - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &bf5xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = bf5xx_pcm_preallocate_dma_buffer(pcm, diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 2a5b434..9cb4a80 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -323,16 +323,18 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { .silence = bf5xx_pcm_silence, }; +static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32); + static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; size_t size = bf5xx_pcm_hardware.buffer_bytes_max; - int ret; pr_debug("%s enter\n", __func__); - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &bf5xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, card->dev, size, size); diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c index 39d7748..9a174fc 100644 --- a/sound/soc/blackfin/bf5xx-i2s.c +++ b/sound/soc/blackfin/bf5xx-i2s.c @@ -121,7 +121,6 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, bf5xx_i2s->tcr2 |= 7; bf5xx_i2s->rcr2 |= 7; sport_handle->wdsize = 1; - break; case SNDRV_PCM_FORMAT_S16_LE: bf5xx_i2s->tcr2 |= 15; bf5xx_i2s->rcr2 |= 15; diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index 9dfa124..6953512 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c @@ -179,9 +179,8 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) struct dmasg *desc, temp_desc; unsigned long flags; - if (WARN_ON(!sport->dummy_rx_desc) || - WARN_ON(sport->curr_rx_desc == sport->dummy_rx_desc)) - return -EINVAL; + BUG_ON(sport->dummy_rx_desc == NULL); + BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); /* Maybe the dummy buffer descriptor ring is damaged */ sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; @@ -251,9 +250,8 @@ int sport_rx_start(struct sport_device *sport) return -EBUSY; if (sport->tx_run) { /* tx is running, rx is not running */ - if (WARN_ON(!sport->dma_rx_desc) || - WARN_ON(sport->curr_rx_desc != sport->dummy_rx_desc)) - return -EINVAL; + BUG_ON(sport->dma_rx_desc == NULL); + BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); local_irq_save(flags); while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - sizeof(struct dmasg)) != sport->dummy_rx_desc) @@ -300,9 +298,8 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) struct dmasg *desc, temp_desc; unsigned long flags; - if (WARN_ON(!sport->dummy_tx_desc) || - WARN_ON(sport->curr_tx_desc == sport->dummy_tx_desc)) - return -EINVAL; + BUG_ON(sport->dummy_tx_desc == NULL); + BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; @@ -334,9 +331,8 @@ int sport_tx_start(struct sport_device *sport) if (sport->tx_run) return -EBUSY; if (sport->rx_run) { - if (WARN_ON(!sport->dma_tx_desc) || - WARN_ON(sport->curr_tx_desc != sport->dummy_tx_desc)) - return -EINVAL; + BUG_ON(sport->dma_tx_desc == NULL); + BUG_ON(sport->curr_tx_desc != sport->dummy_tx_desc); /* Hook the normal buffer descriptor */ local_irq_save(flags); while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - @@ -771,8 +767,7 @@ static irqreturn_t err_handler(int irq, void *dev_id) int sport_set_rx_callback(struct sport_device *sport, void (*rx_callback)(void *), void *rx_data) { - if (WARN_ON(!rx_callback)) - return -EINVAL; + BUG_ON(rx_callback == NULL); sport->rx_callback = rx_callback; sport->rx_data = rx_data; @@ -783,8 +778,7 @@ EXPORT_SYMBOL(sport_set_rx_callback); int sport_set_tx_callback(struct sport_device *sport, void (*tx_callback)(void *), void *tx_data) { - if (WARN_ON(!tx_callback)) - return -EINVAL; + BUG_ON(tx_callback == NULL); sport->tx_callback = tx_callback; sport->tx_data = tx_data; @@ -795,8 +789,7 @@ EXPORT_SYMBOL(sport_set_tx_callback); int sport_set_err_callback(struct sport_device *sport, void (*err_callback)(void *), void *err_data) { - if (WARN_ON(!err_callback)) - return -EINVAL; + BUG_ON(err_callback == NULL); sport->err_callback = err_callback; sport->err_data = err_data; @@ -863,8 +856,7 @@ struct sport_device *sport_init(struct platform_device *pdev, param.wdsize = wdsize; param.dummy_count = dummy_count; - if (WARN_ON(param.wdsize == 0 || param.dummy_count == 0)) - return NULL; + BUG_ON(param.wdsize == 0 || param.dummy_count == 0); ret = sport_config_pdev(pdev, ¶m); if (ret) diff --git a/sound/soc/cirrus/Kconfig b/sound/soc/cirrus/Kconfig index 06f938d..2c20f01 100644 --- a/sound/soc/cirrus/Kconfig +++ b/sound/soc/cirrus/Kconfig @@ -1,6 +1,6 @@ config SND_EP93XX_SOC tristate "SoC Audio support for the Cirrus Logic EP93xx series" - depends on (ARCH_EP93XX || COMPILE_TEST) && SND_SOC + depends on ARCH_EP93XX && SND_SOC select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y or M if you want to add support for codecs attached to diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c index cfe517e..0e9f56e 100644 --- a/sound/soc/cirrus/ep93xx-pcm.c +++ b/sound/soc/cirrus/ep93xx-pcm.c @@ -57,22 +57,9 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) return false; } -static struct dma_chan *ep93xx_compat_request_channel( - struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) -{ - struct snd_dmaengine_dai_dma_data *dma_data; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter, - dma_data); -} - static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { .pcm_hardware = &ep93xx_pcm_hardware, .compat_filter_fn = ep93xx_pcm_dma_filter, - .compat_request_channel = ep93xx_compat_request_channel, .prealloc_buffer_size = 131072, }; diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 75d0ad5..259d1ac 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -16,7 +16,6 @@ #include <linux/mfd/88pm860x.h> #include <linux/slab.h> #include <linux/delay.h> -#include <linux/regmap.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -141,7 +140,6 @@ struct pm860x_priv { unsigned int filter; struct snd_soc_codec *codec; struct i2c_client *i2c; - struct regmap *regmap; struct pm860x_chip *chip; struct pm860x_det det; @@ -271,6 +269,48 @@ static struct st_gain st_table[] = { { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, }; +static int pm860x_volatile(unsigned int reg) +{ + BUG_ON(reg >= REG_CACHE_SIZE); + + switch (reg) { + case PM860X_AUDIO_SUPPLIES_2: + return 1; + } + + return 0; +} + +static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec, + unsigned int reg) +{ + unsigned char *cache = codec->reg_cache; + + BUG_ON(reg >= REG_CACHE_SIZE); + + if (pm860x_volatile(reg)) + return cache[reg]; + + reg += REG_CACHE_BASE; + + return pm860x_reg_read(codec->control_data, reg); +} + +static int pm860x_write_reg_cache(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) +{ + unsigned char *cache = codec->reg_cache; + + BUG_ON(reg >= REG_CACHE_SIZE); + + if (!pm860x_volatile(reg)) + cache[reg] = (unsigned char)value; + + reg += REG_CACHE_BASE; + + return pm860x_reg_write(codec->control_data, reg, value); +} + static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -1129,7 +1169,6 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pm860x_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); int data; switch (level) { @@ -1143,17 +1182,17 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec, if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { /* Enable Audio PLL & Audio section */ data = AUDIO_PLL | AUDIO_SECTION_ON; - pm860x_reg_write(pm860x->i2c, REG_MISC2, data); + pm860x_reg_write(codec->control_data, REG_MISC2, data); udelay(300); data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON; - pm860x_reg_write(pm860x->i2c, REG_MISC2, data); + pm860x_reg_write(codec->control_data, REG_MISC2, data); } break; case SND_SOC_BIAS_OFF: data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON; - pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0); + pm860x_set_bits(codec->control_data, REG_MISC2, data, 0); break; } codec->dapm.bias_level = level; @@ -1283,17 +1322,17 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec, pm860x->det.lo_shrt = lo_shrt; if (det & SND_JACK_HEADPHONE) - pm860x_set_bits(pm860x->i2c, REG_HS_DET, + pm860x_set_bits(codec->control_data, REG_HS_DET, EN_HS_DET, EN_HS_DET); /* headset short detect */ if (hs_shrt) { data = CLR_SHORT_HS2 | CLR_SHORT_HS1; - pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); + pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); } /* Lineout short detect */ if (lo_shrt) { data = CLR_SHORT_LO2 | CLR_SHORT_LO1; - pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); + pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); } /* sync status */ @@ -1311,7 +1350,7 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec, pm860x->det.mic_det = det; if (det & SND_JACK_MICROPHONE) - pm860x_set_bits(pm860x->i2c, REG_MIC_DET, + pm860x_set_bits(codec->control_data, REG_MIC_DET, MICDET_MASK, MICDET_MASK); /* sync status */ @@ -1327,7 +1366,7 @@ static int pm860x_probe(struct snd_soc_codec *codec) pm860x->codec = codec; - codec->control_data = pm860x->regmap; + codec->control_data = pm860x->i2c; for (i = 0; i < 4; i++) { ret = request_threaded_irq(pm860x->irq[i], NULL, @@ -1341,6 +1380,14 @@ static int pm860x_probe(struct snd_soc_codec *codec) pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + ret = pm860x_bulk_read(codec->control_data, REG_CACHE_BASE, + REG_CACHE_SIZE, codec->reg_cache); + if (ret < 0) { + dev_err(codec->dev, "Failed to fill register cache: %d\n", + ret); + goto out; + } + return 0; out: @@ -1363,6 +1410,10 @@ static int pm860x_remove(struct snd_soc_codec *codec) static struct snd_soc_codec_driver soc_codec_dev_pm860x = { .probe = pm860x_probe, .remove = pm860x_remove, + .read = pm860x_read_reg_cache, + .write = pm860x_write_reg_cache, + .reg_cache_size = REG_CACHE_SIZE, + .reg_word_size = sizeof(u8), .set_bias_level = pm860x_set_bias_level, .controls = pm860x_snd_controls, @@ -1388,8 +1439,6 @@ static int pm860x_codec_probe(struct platform_device *pdev) pm860x->chip = chip; pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; - pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap - : chip->regmap_companion; platform_set_drvdata(pdev, pm860x); for (i = 0; i < 4; i++) { diff --git a/sound/soc/codecs/88pm860x-codec.h b/sound/soc/codecs/88pm860x-codec.h index f7282f4..3364ba4 100644 --- a/sound/soc/codecs/88pm860x-codec.h +++ b/sound/soc/codecs/88pm860x-codec.h @@ -12,66 +12,67 @@ #ifndef __88PM860X_H #define __88PM860X_H -#define PM860X_PCM_IFACE_1 0xb0 -#define PM860X_PCM_IFACE_2 0xb1 -#define PM860X_PCM_IFACE_3 0xb2 -#define PM860X_PCM_RATE 0xb3 -#define PM860X_EC_PATH 0xb4 -#define PM860X_SIDETONE_L_GAIN 0xb5 -#define PM860X_SIDETONE_R_GAIN 0xb6 -#define PM860X_SIDETONE_SHIFT 0xb7 -#define PM860X_ADC_OFFSET_1 0xb8 -#define PM860X_ADC_OFFSET_2 0xb9 -#define PM860X_DMIC_DELAY 0xba +/* The offset of these registers are 0xb0 */ +#define PM860X_PCM_IFACE_1 0x00 +#define PM860X_PCM_IFACE_2 0x01 +#define PM860X_PCM_IFACE_3 0x02 +#define PM860X_PCM_RATE 0x03 +#define PM860X_EC_PATH 0x04 +#define PM860X_SIDETONE_L_GAIN 0x05 +#define PM860X_SIDETONE_R_GAIN 0x06 +#define PM860X_SIDETONE_SHIFT 0x07 +#define PM860X_ADC_OFFSET_1 0x08 +#define PM860X_ADC_OFFSET_2 0x09 +#define PM860X_DMIC_DELAY 0x0a -#define PM860X_I2S_IFACE_1 0xbb -#define PM860X_I2S_IFACE_2 0xbc -#define PM860X_I2S_IFACE_3 0xbd -#define PM860X_I2S_IFACE_4 0xbe -#define PM860X_EQUALIZER_N0_1 0xbf -#define PM860X_EQUALIZER_N0_2 0xc0 -#define PM860X_EQUALIZER_N1_1 0xc1 -#define PM860X_EQUALIZER_N1_2 0xc2 -#define PM860X_EQUALIZER_D1_1 0xc3 -#define PM860X_EQUALIZER_D1_2 0xc4 -#define PM860X_LOFI_GAIN_LEFT 0xc5 -#define PM860X_LOFI_GAIN_RIGHT 0xc6 -#define PM860X_HIFIL_GAIN_LEFT 0xc7 -#define PM860X_HIFIL_GAIN_RIGHT 0xc8 -#define PM860X_HIFIR_GAIN_LEFT 0xc9 -#define PM860X_HIFIR_GAIN_RIGHT 0xca -#define PM860X_DAC_OFFSET 0xcb -#define PM860X_OFFSET_LEFT_1 0xcc -#define PM860X_OFFSET_LEFT_2 0xcd -#define PM860X_OFFSET_RIGHT_1 0xce -#define PM860X_OFFSET_RIGHT_2 0xcf -#define PM860X_ADC_ANA_1 0xd0 -#define PM860X_ADC_ANA_2 0xd1 -#define PM860X_ADC_ANA_3 0xd2 -#define PM860X_ADC_ANA_4 0xd3 -#define PM860X_ANA_TO_ANA 0xd4 -#define PM860X_HS1_CTRL 0xd5 -#define PM860X_HS2_CTRL 0xd6 -#define PM860X_LO1_CTRL 0xd7 -#define PM860X_LO2_CTRL 0xd8 -#define PM860X_EAR_CTRL_1 0xd9 -#define PM860X_EAR_CTRL_2 0xda -#define PM860X_AUDIO_SUPPLIES_1 0xdb -#define PM860X_AUDIO_SUPPLIES_2 0xdc -#define PM860X_ADC_EN_1 0xdd -#define PM860X_ADC_EN_2 0xde -#define PM860X_DAC_EN_1 0xdf -#define PM860X_DAC_EN_2 0xe1 -#define PM860X_AUDIO_CAL_1 0xe2 -#define PM860X_AUDIO_CAL_2 0xe3 -#define PM860X_AUDIO_CAL_3 0xe4 -#define PM860X_AUDIO_CAL_4 0xe5 -#define PM860X_AUDIO_CAL_5 0xe6 -#define PM860X_ANA_INPUT_SEL_1 0xe7 -#define PM860X_ANA_INPUT_SEL_2 0xe8 +#define PM860X_I2S_IFACE_1 0x0b +#define PM860X_I2S_IFACE_2 0x0c +#define PM860X_I2S_IFACE_3 0x0d +#define PM860X_I2S_IFACE_4 0x0e +#define PM860X_EQUALIZER_N0_1 0x0f +#define PM860X_EQUALIZER_N0_2 0x10 +#define PM860X_EQUALIZER_N1_1 0x11 +#define PM860X_EQUALIZER_N1_2 0x12 +#define PM860X_EQUALIZER_D1_1 0x13 +#define PM860X_EQUALIZER_D1_2 0x14 +#define PM860X_LOFI_GAIN_LEFT 0x15 +#define PM860X_LOFI_GAIN_RIGHT 0x16 +#define PM860X_HIFIL_GAIN_LEFT 0x17 +#define PM860X_HIFIL_GAIN_RIGHT 0x18 +#define PM860X_HIFIR_GAIN_LEFT 0x19 +#define PM860X_HIFIR_GAIN_RIGHT 0x1a +#define PM860X_DAC_OFFSET 0x1b +#define PM860X_OFFSET_LEFT_1 0x1c +#define PM860X_OFFSET_LEFT_2 0x1d +#define PM860X_OFFSET_RIGHT_1 0x1e +#define PM860X_OFFSET_RIGHT_2 0x1f +#define PM860X_ADC_ANA_1 0x20 +#define PM860X_ADC_ANA_2 0x21 +#define PM860X_ADC_ANA_3 0x22 +#define PM860X_ADC_ANA_4 0x23 +#define PM860X_ANA_TO_ANA 0x24 +#define PM860X_HS1_CTRL 0x25 +#define PM860X_HS2_CTRL 0x26 +#define PM860X_LO1_CTRL 0x27 +#define PM860X_LO2_CTRL 0x28 +#define PM860X_EAR_CTRL_1 0x29 +#define PM860X_EAR_CTRL_2 0x2a +#define PM860X_AUDIO_SUPPLIES_1 0x2b +#define PM860X_AUDIO_SUPPLIES_2 0x2c +#define PM860X_ADC_EN_1 0x2d +#define PM860X_ADC_EN_2 0x2e +#define PM860X_DAC_EN_1 0x2f +#define PM860X_DAC_EN_2 0x31 +#define PM860X_AUDIO_CAL_1 0x32 +#define PM860X_AUDIO_CAL_2 0x33 +#define PM860X_AUDIO_CAL_3 0x34 +#define PM860X_AUDIO_CAL_4 0x35 +#define PM860X_AUDIO_CAL_5 0x36 +#define PM860X_ANA_INPUT_SEL_1 0x37 +#define PM860X_ANA_INPUT_SEL_2 0x38 -#define PM860X_PCM_IFACE_4 0xe9 -#define PM860X_I2S_IFACE_5 0xea +#define PM860X_PCM_IFACE_4 0x39 +#define PM860X_I2S_IFACE_5 0x3a #define PM860X_SHORTS 0x3b #define PM860X_PLL_ADJ_1 0x3c diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 1ad92cb..80555d7 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -2312,17 +2312,17 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, case 0: break; case 1: - slot = ffs(tx_mask); + slot = find_first_bit((unsigned long *)&tx_mask, 32); snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); break; case 2: - slot = ffs(tx_mask); + slot = find_first_bit((unsigned long *)&tx_mask, 32); snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); - slot = fls(tx_mask); + slot = find_next_bit((unsigned long *)&tx_mask, 32, slot + 1); snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); break; @@ -2353,18 +2353,18 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, case 0: break; case 1: - slot = ffs(rx_mask); + slot = find_first_bit((unsigned long *)&rx_mask, 32); snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); break; case 2: - slot = ffs(rx_mask); + slot = find_first_bit((unsigned long *)&rx_mask, 32); snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); - slot = fls(rx_mask); + slot = find_next_bit((unsigned long *)&rx_mask, 32, slot + 1); snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), @@ -2532,10 +2532,12 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) } /* Override HW-defaults */ - snd_soc_write(codec, AB8500_ANACONF5, - BIT(AB8500_ANACONF5_HSAUTOEN)); - snd_soc_write(codec, AB8500_SHORTCIRCONF, - BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); + ab8500_codec_write_reg(codec, + AB8500_ANACONF5, + BIT(AB8500_ANACONF5_HSAUTOEN)); + ab8500_codec_write_reg(codec, + AB8500_SHORTCIRCONF, + BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); /* Add filter controls */ status = snd_soc_add_codec_controls(codec, ab8500_filter_controls, @@ -2586,8 +2588,6 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) /* Create driver private-data struct */ drvdata = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_codec_drvdata), GFP_KERNEL); - if (!drvdata) - return -ENOMEM; drvdata->sid_status = SID_UNCONFIGURED; drvdata->anc_status = ANC_UNCONFIGURED; dev_set_drvdata(&pdev->dev, drvdata); @@ -2606,7 +2606,7 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) static int ab8500_codec_driver_remove(struct platform_device *pdev) { - dev_dbg(&pdev->dev, "%s Enter.\n", __func__); + dev_info(&pdev->dev, "%s Enter.\n", __func__); snd_soc_unregister_codec(&pdev->dev); diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 59654b1..1aa10dd 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -32,7 +32,6 @@ struct adau1373_dai { }; struct adau1373 { - struct regmap *regmap; struct adau1373_dai dais[3]; }; @@ -74,6 +73,7 @@ struct adau1373 { #define ADAU1373_PLL_CTRL4(x) (0x2c + (x) * 7) #define ADAU1373_PLL_CTRL5(x) (0x2d + (x) * 7) #define ADAU1373_PLL_CTRL6(x) (0x2e + (x) * 7) +#define ADAU1373_PLL_CTRL7(x) (0x2f + (x) * 7) #define ADAU1373_HEADDECT 0x36 #define ADAU1373_ADC_DAC_STATUS 0x37 #define ADAU1373_ADC_CTRL 0x3c @@ -152,172 +152,37 @@ struct adau1373 { #define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4 #define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2 -static const struct reg_default adau1373_reg_defaults[] = { - { ADAU1373_INPUT_MODE, 0x00 }, - { ADAU1373_AINL_CTRL(0), 0x00 }, - { ADAU1373_AINR_CTRL(0), 0x00 }, - { ADAU1373_AINL_CTRL(1), 0x00 }, - { ADAU1373_AINR_CTRL(1), 0x00 }, - { ADAU1373_AINL_CTRL(2), 0x00 }, - { ADAU1373_AINR_CTRL(2), 0x00 }, - { ADAU1373_AINL_CTRL(3), 0x00 }, - { ADAU1373_AINR_CTRL(3), 0x00 }, - { ADAU1373_LLINE_OUT(0), 0x00 }, - { ADAU1373_RLINE_OUT(0), 0x00 }, - { ADAU1373_LLINE_OUT(1), 0x00 }, - { ADAU1373_RLINE_OUT(1), 0x00 }, - { ADAU1373_LSPK_OUT, 0x00 }, - { ADAU1373_RSPK_OUT, 0x00 }, - { ADAU1373_LHP_OUT, 0x00 }, - { ADAU1373_RHP_OUT, 0x00 }, - { ADAU1373_ADC_GAIN, 0x00 }, - { ADAU1373_LADC_MIXER, 0x00 }, - { ADAU1373_RADC_MIXER, 0x00 }, - { ADAU1373_LLINE1_MIX, 0x00 }, - { ADAU1373_RLINE1_MIX, 0x00 }, - { ADAU1373_LLINE2_MIX, 0x00 }, - { ADAU1373_RLINE2_MIX, 0x00 }, - { ADAU1373_LSPK_MIX, 0x00 }, - { ADAU1373_RSPK_MIX, 0x00 }, - { ADAU1373_LHP_MIX, 0x00 }, - { ADAU1373_RHP_MIX, 0x00 }, - { ADAU1373_EP_MIX, 0x00 }, - { ADAU1373_HP_CTRL, 0x00 }, - { ADAU1373_HP_CTRL2, 0x00 }, - { ADAU1373_LS_CTRL, 0x00 }, - { ADAU1373_EP_CTRL, 0x00 }, - { ADAU1373_MICBIAS_CTRL1, 0x00 }, - { ADAU1373_MICBIAS_CTRL2, 0x00 }, - { ADAU1373_OUTPUT_CTRL, 0x00 }, - { ADAU1373_PWDN_CTRL1, 0x00 }, - { ADAU1373_PWDN_CTRL2, 0x00 }, - { ADAU1373_PWDN_CTRL3, 0x00 }, - { ADAU1373_DPLL_CTRL(0), 0x00 }, - { ADAU1373_PLL_CTRL1(0), 0x00 }, - { ADAU1373_PLL_CTRL2(0), 0x00 }, - { ADAU1373_PLL_CTRL3(0), 0x00 }, - { ADAU1373_PLL_CTRL4(0), 0x00 }, - { ADAU1373_PLL_CTRL5(0), 0x00 }, - { ADAU1373_PLL_CTRL6(0), 0x02 }, - { ADAU1373_DPLL_CTRL(1), 0x00 }, - { ADAU1373_PLL_CTRL1(1), 0x00 }, - { ADAU1373_PLL_CTRL2(1), 0x00 }, - { ADAU1373_PLL_CTRL3(1), 0x00 }, - { ADAU1373_PLL_CTRL4(1), 0x00 }, - { ADAU1373_PLL_CTRL5(1), 0x00 }, - { ADAU1373_PLL_CTRL6(1), 0x02 }, - { ADAU1373_HEADDECT, 0x00 }, - { ADAU1373_ADC_CTRL, 0x00 }, - { ADAU1373_CLK_SRC_DIV(0), 0x00 }, - { ADAU1373_CLK_SRC_DIV(1), 0x00 }, - { ADAU1373_DAI(0), 0x0a }, - { ADAU1373_DAI(1), 0x0a }, - { ADAU1373_DAI(2), 0x0a }, - { ADAU1373_BCLKDIV(0), 0x00 }, - { ADAU1373_BCLKDIV(1), 0x00 }, - { ADAU1373_BCLKDIV(2), 0x00 }, - { ADAU1373_SRC_RATIOA(0), 0x00 }, - { ADAU1373_SRC_RATIOB(0), 0x00 }, - { ADAU1373_SRC_RATIOA(1), 0x00 }, - { ADAU1373_SRC_RATIOB(1), 0x00 }, - { ADAU1373_SRC_RATIOA(2), 0x00 }, - { ADAU1373_SRC_RATIOB(2), 0x00 }, - { ADAU1373_DEEMP_CTRL, 0x00 }, - { ADAU1373_SRC_DAI_CTRL(0), 0x08 }, - { ADAU1373_SRC_DAI_CTRL(1), 0x08 }, - { ADAU1373_SRC_DAI_CTRL(2), 0x08 }, - { ADAU1373_DIN_MIX_CTRL(0), 0x00 }, - { ADAU1373_DIN_MIX_CTRL(1), 0x00 }, - { ADAU1373_DIN_MIX_CTRL(2), 0x00 }, - { ADAU1373_DIN_MIX_CTRL(3), 0x00 }, - { ADAU1373_DIN_MIX_CTRL(4), 0x00 }, - { ADAU1373_DOUT_MIX_CTRL(0), 0x00 }, - { ADAU1373_DOUT_MIX_CTRL(1), 0x00 }, - { ADAU1373_DOUT_MIX_CTRL(2), 0x00 }, - { ADAU1373_DOUT_MIX_CTRL(3), 0x00 }, - { ADAU1373_DOUT_MIX_CTRL(4), 0x00 }, - { ADAU1373_DAI_PBL_VOL(0), 0x00 }, - { ADAU1373_DAI_PBR_VOL(0), 0x00 }, - { ADAU1373_DAI_PBL_VOL(1), 0x00 }, - { ADAU1373_DAI_PBR_VOL(1), 0x00 }, - { ADAU1373_DAI_PBL_VOL(2), 0x00 }, - { ADAU1373_DAI_PBR_VOL(2), 0x00 }, - { ADAU1373_DAI_RECL_VOL(0), 0x00 }, - { ADAU1373_DAI_RECR_VOL(0), 0x00 }, - { ADAU1373_DAI_RECL_VOL(1), 0x00 }, - { ADAU1373_DAI_RECR_VOL(1), 0x00 }, - { ADAU1373_DAI_RECL_VOL(2), 0x00 }, - { ADAU1373_DAI_RECR_VOL(2), 0x00 }, - { ADAU1373_DAC1_PBL_VOL, 0x00 }, - { ADAU1373_DAC1_PBR_VOL, 0x00 }, - { ADAU1373_DAC2_PBL_VOL, 0x00 }, - { ADAU1373_DAC2_PBR_VOL, 0x00 }, - { ADAU1373_ADC_RECL_VOL, 0x00 }, - { ADAU1373_ADC_RECR_VOL, 0x00 }, - { ADAU1373_DMIC_RECL_VOL, 0x00 }, - { ADAU1373_DMIC_RECR_VOL, 0x00 }, - { ADAU1373_VOL_GAIN1, 0x00 }, - { ADAU1373_VOL_GAIN2, 0x00 }, - { ADAU1373_VOL_GAIN3, 0x00 }, - { ADAU1373_HPF_CTRL, 0x00 }, - { ADAU1373_BASS1, 0x00 }, - { ADAU1373_BASS2, 0x00 }, - { ADAU1373_DRC(0) + 0x0, 0x78 }, - { ADAU1373_DRC(0) + 0x1, 0x18 }, - { ADAU1373_DRC(0) + 0x2, 0x00 }, - { ADAU1373_DRC(0) + 0x3, 0x00 }, - { ADAU1373_DRC(0) + 0x4, 0x00 }, - { ADAU1373_DRC(0) + 0x5, 0xc0 }, - { ADAU1373_DRC(0) + 0x6, 0x00 }, - { ADAU1373_DRC(0) + 0x7, 0x00 }, - { ADAU1373_DRC(0) + 0x8, 0x00 }, - { ADAU1373_DRC(0) + 0x9, 0xc0 }, - { ADAU1373_DRC(0) + 0xa, 0x88 }, - { ADAU1373_DRC(0) + 0xb, 0x7a }, - { ADAU1373_DRC(0) + 0xc, 0xdf }, - { ADAU1373_DRC(0) + 0xd, 0x20 }, - { ADAU1373_DRC(0) + 0xe, 0x00 }, - { ADAU1373_DRC(0) + 0xf, 0x00 }, - { ADAU1373_DRC(1) + 0x0, 0x78 }, - { ADAU1373_DRC(1) + 0x1, 0x18 }, - { ADAU1373_DRC(1) + 0x2, 0x00 }, - { ADAU1373_DRC(1) + 0x3, 0x00 }, - { ADAU1373_DRC(1) + 0x4, 0x00 }, - { ADAU1373_DRC(1) + 0x5, 0xc0 }, - { ADAU1373_DRC(1) + 0x6, 0x00 }, - { ADAU1373_DRC(1) + 0x7, 0x00 }, - { ADAU1373_DRC(1) + 0x8, 0x00 }, - { ADAU1373_DRC(1) + 0x9, 0xc0 }, - { ADAU1373_DRC(1) + 0xa, 0x88 }, - { ADAU1373_DRC(1) + 0xb, 0x7a }, - { ADAU1373_DRC(1) + 0xc, 0xdf }, - { ADAU1373_DRC(1) + 0xd, 0x20 }, - { ADAU1373_DRC(1) + 0xe, 0x00 }, - { ADAU1373_DRC(1) + 0xf, 0x00 }, - { ADAU1373_DRC(2) + 0x0, 0x78 }, - { ADAU1373_DRC(2) + 0x1, 0x18 }, - { ADAU1373_DRC(2) + 0x2, 0x00 }, - { ADAU1373_DRC(2) + 0x3, 0x00 }, - { ADAU1373_DRC(2) + 0x4, 0x00 }, - { ADAU1373_DRC(2) + 0x5, 0xc0 }, - { ADAU1373_DRC(2) + 0x6, 0x00 }, - { ADAU1373_DRC(2) + 0x7, 0x00 }, - { ADAU1373_DRC(2) + 0x8, 0x00 }, - { ADAU1373_DRC(2) + 0x9, 0xc0 }, - { ADAU1373_DRC(2) + 0xa, 0x88 }, - { ADAU1373_DRC(2) + 0xb, 0x7a }, - { ADAU1373_DRC(2) + 0xc, 0xdf }, - { ADAU1373_DRC(2) + 0xd, 0x20 }, - { ADAU1373_DRC(2) + 0xe, 0x00 }, - { ADAU1373_DRC(2) + 0xf, 0x00 }, - { ADAU1373_3D_CTRL1, 0x00 }, - { ADAU1373_3D_CTRL2, 0x00 }, - { ADAU1373_FDSP_SEL1, 0x00 }, - { ADAU1373_FDSP_SEL2, 0x00 }, - { ADAU1373_FDSP_SEL2, 0x00 }, - { ADAU1373_FDSP_SEL4, 0x00 }, - { ADAU1373_DIGMICCTRL, 0x00 }, - { ADAU1373_DIGEN, 0x00 }, +static const uint8_t adau1373_default_regs[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x30 */ + 0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, /* 0x40 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, /* 0x50 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x80 */ + 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, + 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x90 */ + 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, + 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0xa0 */ + 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, /* 0xe0 */ + 0x00, 0x1f, 0x0f, 0x00, 0x00, }; static const unsigned int adau1373_out_tlv[] = { @@ -553,7 +418,6 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); unsigned int pll_id = w->name[3] - '1'; unsigned int val; @@ -562,7 +426,7 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w, else val = 0; - regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), + snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), ADAU1373_PLL_CTRL6_PLL_EN, val); if (SND_SOC_DAPM_EVENT_ON(event)) @@ -1074,7 +938,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream, adau1373_dai->enable_src = (div != 0); - regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), + snd_soc_update_bits(codec, ADAU1373_BCLKDIV(dai->id), ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK, (div << 2) | ADAU1373_BCLKDIV_64); @@ -1095,7 +959,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - return regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), + return snd_soc_update_bits(codec, ADAU1373_DAI(dai->id), ADAU1373_DAI_WLEN_MASK, ctrl); } @@ -1152,7 +1016,7 @@ static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), + snd_soc_update_bits(codec, ADAU1373_DAI(dai->id), ~ADAU1373_DAI_WLEN_MASK, ctrl); return 0; @@ -1175,7 +1039,7 @@ static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai, adau1373_dai->sysclk = freq; adau1373_dai->clk_src = clk_id; - regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), + snd_soc_update_bits(dai->codec, ADAU1373_BCLKDIV(dai->id), ADAU1373_BCLKDIV_SOURCE, clk_id << 5); return 0; @@ -1256,7 +1120,6 @@ static struct snd_soc_dai_driver adau1373_dai_driver[] = { static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); unsigned int dpll_div = 0; unsigned int x, r, n, m, i, j, mode; @@ -1324,36 +1187,36 @@ static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, if (dpll_div) { dpll_div = 11 - dpll_div; - regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), + snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), ADAU1373_PLL_CTRL6_DPLL_BYPASS, 0); } else { - regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), + snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), ADAU1373_PLL_CTRL6_DPLL_BYPASS, ADAU1373_PLL_CTRL6_DPLL_BYPASS); } - regmap_write(adau1373->regmap, ADAU1373_DPLL_CTRL(pll_id), + snd_soc_write(codec, ADAU1373_DPLL_CTRL(pll_id), (source << 4) | dpll_div); - regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff); - regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL2(pll_id), m & 0xff); - regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff); - regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL4(pll_id), n & 0xff); - regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL5(pll_id), + snd_soc_write(codec, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff); + snd_soc_write(codec, ADAU1373_PLL_CTRL2(pll_id), m & 0xff); + snd_soc_write(codec, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff); + snd_soc_write(codec, ADAU1373_PLL_CTRL4(pll_id), n & 0xff); + snd_soc_write(codec, ADAU1373_PLL_CTRL5(pll_id), (r << 3) | (x << 1) | mode); /* Set sysclk to pll_rate / 4 */ - regmap_update_bits(adau1373->regmap, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09); + snd_soc_update_bits(codec, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09); return 0; } -static void adau1373_load_drc_settings(struct adau1373 *adau1373, +static void adau1373_load_drc_settings(struct snd_soc_codec *codec, unsigned int nr, uint8_t *drc) { unsigned int i; for (i = 0; i < ADAU1373_DRC_SIZE; ++i) - regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]); + snd_soc_write(codec, ADAU1373_DRC(nr) + i, drc[i]); } static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) @@ -1372,14 +1235,13 @@ static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) static int adau1373_probe(struct snd_soc_codec *codec) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); struct adau1373_platform_data *pdata = codec->dev->platform_data; bool lineout_differential = false; unsigned int val; int ret; int i; - ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); if (ret) { dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); return ret; @@ -1394,7 +1256,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) return -EINVAL; for (i = 0; i < pdata->num_drc; ++i) { - adau1373_load_drc_settings(adau1373, i, + adau1373_load_drc_settings(codec, i, pdata->drc_setting[i]); } @@ -1406,18 +1268,18 @@ static int adau1373_probe(struct snd_soc_codec *codec) if (pdata->input_differential[i]) val |= BIT(i); } - regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val); + snd_soc_write(codec, ADAU1373_INPUT_MODE, val); val = 0; if (pdata->lineout_differential) val |= ADAU1373_OUTPUT_CTRL_LDIFF; if (pdata->lineout_ground_sense) val |= ADAU1373_OUTPUT_CTRL_LNFBEN; - regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val); + snd_soc_write(codec, ADAU1373_OUTPUT_CTRL, val); lineout_differential = pdata->lineout_differential; - regmap_write(adau1373->regmap, ADAU1373_EP_CTRL, + snd_soc_write(codec, ADAU1373_EP_CTRL, (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); } @@ -1427,7 +1289,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) ARRAY_SIZE(adau1373_lineout2_controls)); } - regmap_write(adau1373->regmap, ADAU1373_ADC_CTRL, + snd_soc_write(codec, ADAU1373_ADC_CTRL, ADAU1373_ADC_CTRL_RESET_FORCE | ADAU1373_ADC_CTRL_PEAK_DETECT); return 0; @@ -1436,19 +1298,17 @@ static int adau1373_probe(struct snd_soc_codec *codec) static int adau1373_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); - switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, + snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3, ADAU1373_PWDN_CTRL3_PWR_EN, ADAU1373_PWDN_CTRL3_PWR_EN); break; case SND_SOC_BIAS_OFF: - regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, + snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3, ADAU1373_PWDN_CTRL3_PWR_EN, 0); break; } @@ -1464,49 +1324,17 @@ static int adau1373_remove(struct snd_soc_codec *codec) static int adau1373_suspend(struct snd_soc_codec *codec) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF); - regcache_cache_only(adau1373->regmap, true); - - return ret; + return adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF); } static int adau1373_resume(struct snd_soc_codec *codec) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); - - regcache_cache_only(adau1373->regmap, false); adau1373_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - regcache_sync(adau1373->regmap); + snd_soc_cache_sync(codec); return 0; } -static bool adau1373_register_volatile(struct device *dev, unsigned int reg) -{ - switch (reg) { - case ADAU1373_SOFT_RESET: - case ADAU1373_ADC_DAC_STATUS: - return true; - default: - return false; - } -} - -static const struct regmap_config adau1373_regmap_config = { - .val_bits = 8, - .reg_bits = 8, - - .volatile_reg = adau1373_register_volatile, - .max_register = ADAU1373_SOFT_RESET, - - .cache_type = REGCACHE_RBTREE, - .reg_defaults = adau1373_reg_defaults, - .num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults), -}; - static struct snd_soc_codec_driver adau1373_codec_driver = { .probe = adau1373_probe, .remove = adau1373_remove, @@ -1514,6 +1342,9 @@ static struct snd_soc_codec_driver adau1373_codec_driver = { .resume = adau1373_resume, .set_bias_level = adau1373_set_bias_level, .idle_bias_off = true, + .reg_cache_size = ARRAY_SIZE(adau1373_default_regs), + .reg_cache_default = adau1373_default_regs, + .reg_word_size = sizeof(uint8_t), .set_pll = adau1373_set_pll, @@ -1535,13 +1366,6 @@ static int adau1373_i2c_probe(struct i2c_client *client, if (!adau1373) return -ENOMEM; - adau1373->regmap = devm_regmap_init_i2c(client, - &adau1373_regmap_config); - if (IS_ERR(adau1373->regmap)) - return PTR_ERR(adau1373->regmap); - - regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00); - dev_set_drvdata(&client->dev, adau1373); ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver, diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 14a7c16..15b012d0 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -115,34 +115,22 @@ #define ADAV80X_PLL_OUTE_SYSCLKPD(x) BIT(2 - (x)) -static struct reg_default adav80x_reg_defaults[] = { - { ADAV80X_PLAYBACK_CTRL, 0x01 }, - { ADAV80X_AUX_IN_CTRL, 0x01 }, - { ADAV80X_REC_CTRL, 0x02 }, - { ADAV80X_AUX_OUT_CTRL, 0x01 }, - { ADAV80X_DPATH_CTRL1, 0xc0 }, - { ADAV80X_DPATH_CTRL2, 0x11 }, - { ADAV80X_DAC_CTRL1, 0x00 }, - { ADAV80X_DAC_CTRL2, 0x00 }, - { ADAV80X_DAC_CTRL3, 0x00 }, - { ADAV80X_DAC_L_VOL, 0xff }, - { ADAV80X_DAC_R_VOL, 0xff }, - { ADAV80X_PGA_L_VOL, 0x00 }, - { ADAV80X_PGA_R_VOL, 0x00 }, - { ADAV80X_ADC_CTRL1, 0x00 }, - { ADAV80X_ADC_CTRL2, 0x00 }, - { ADAV80X_ADC_L_VOL, 0xff }, - { ADAV80X_ADC_R_VOL, 0xff }, - { ADAV80X_PLL_CTRL1, 0x00 }, - { ADAV80X_PLL_CTRL2, 0x00 }, - { ADAV80X_ICLK_CTRL1, 0x00 }, - { ADAV80X_ICLK_CTRL2, 0x00 }, - { ADAV80X_PLL_CLK_SRC, 0x00 }, - { ADAV80X_PLL_OUTE, 0x00 }, +static u8 adav80x_default_regs[] = { + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x01, 0x80, 0x26, 0x00, 0x00, + 0x02, 0x40, 0x20, 0x00, 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0x92, 0xb1, 0x37, + 0x48, 0xd2, 0xfb, 0xca, 0xd2, 0x15, 0xe8, 0x29, 0xb9, 0x6a, 0xda, 0x2b, + 0xb7, 0xc0, 0x11, 0x65, 0x5c, 0xf6, 0xff, 0x8d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, + 0x00, 0xe8, 0x46, 0xe1, 0x5b, 0xd3, 0x43, 0x77, 0x93, 0xa7, 0x44, 0xee, + 0x32, 0x12, 0xc0, 0x11, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, }; struct adav80x { - struct regmap *regmap; + enum snd_soc_control_type control_type; enum adav80x_clk_src clk_src; unsigned int sysclk; @@ -310,7 +298,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec) val = ADAV80X_DAC_CTRL2_DEEMPH_NONE; } - return regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2, + return snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2, ADAV80X_DAC_CTRL2_DEEMPH_MASK, val); } @@ -406,11 +394,10 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0], + snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0], ADAV80X_CAPTURE_MODE_MASK | ADAV80X_CAPTURE_MODE_MASTER, capture); - regmap_write(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1], - playback); + snd_soc_write(codec, adav80x_port_ctrl_regs[dai->id][1], playback); adav80x->dai_fmt[dai->id] = fmt & SND_SOC_DAIFMT_FORMAT_MASK; @@ -420,7 +407,6 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int adav80x_set_adc_clock(struct snd_soc_codec *codec, unsigned int sample_rate) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int val; if (sample_rate <= 48000) @@ -428,7 +414,7 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec, else val = ADAV80X_ADC_CTRL1_MODULATOR_64FS; - regmap_update_bits(adav80x->regmap, ADAV80X_ADC_CTRL1, + snd_soc_update_bits(codec, ADAV80X_ADC_CTRL1, ADAV80X_ADC_CTRL1_MODULATOR_MASK, val); return 0; @@ -437,7 +423,6 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec, static int adav80x_set_dac_clock(struct snd_soc_codec *codec, unsigned int sample_rate) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int val; if (sample_rate <= 48000) @@ -445,7 +430,7 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec, else val = ADAV80X_DAC_CTRL2_DIV2 | ADAV80X_DAC_CTRL2_INTERPOL_128FS; - regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2, + snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2, ADAV80X_DAC_CTRL2_DIV_MASK | ADAV80X_DAC_CTRL2_INTERPOL_MASK, val); @@ -455,7 +440,6 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec, static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, struct snd_soc_dai *dai, snd_pcm_format_t format) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int val; switch (format) { @@ -475,7 +459,7 @@ static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, return -EINVAL; } - regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0], + snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0], ADAV80X_CAPTURE_WORD_LEN_MASK, val); return 0; @@ -507,7 +491,7 @@ static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec, return -EINVAL; } - regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1], + snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][1], ADAV80X_PLAYBACK_MODE_MASK, val); return 0; @@ -570,10 +554,8 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec, ADAV80X_ICLK_CTRL1_ICLK2_SRC(clk_id); iclk_ctrl2 = ADAV80X_ICLK_CTRL2_ICLK1_SRC(clk_id); - regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL1, - iclk_ctrl1); - regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2, - iclk_ctrl2); + snd_soc_write(codec, ADAV80X_ICLK_CTRL1, iclk_ctrl1); + snd_soc_write(codec, ADAV80X_ICLK_CTRL2, iclk_ctrl2); snd_soc_dapm_sync(&codec->dapm); } @@ -593,12 +575,10 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec, mask = ADAV80X_PLL_OUTE_SYSCLKPD(clk_id); if (freq == 0) { - regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE, - mask, mask); + snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, mask); adav80x->sysclk_pd[clk_id] = true; } else { - regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE, - mask, 0); + snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, 0); adav80x->sysclk_pd[clk_id] = false; } @@ -670,9 +650,9 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, return -EINVAL; } - regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL1, - ADAV80X_PLL_CTRL1_PLLDIV, pll_ctrl1); - regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL2, + snd_soc_update_bits(codec, ADAV80X_PLL_CTRL1, ADAV80X_PLL_CTRL1_PLLDIV, + pll_ctrl1); + snd_soc_update_bits(codec, ADAV80X_PLL_CTRL2, ADAV80X_PLL_CTRL2_PLL_MASK(pll_id), pll_ctrl2); if (source != adav80x->pll_src) { @@ -681,7 +661,7 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, else pll_src = ADAV80X_PLL_CLK_SRC_PLL_XIN(pll_id); - regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CLK_SRC, + snd_soc_update_bits(codec, ADAV80X_PLL_CLK_SRC, ADAV80X_PLL_CLK_SRC_PLL_MASK(pll_id), pll_src); adav80x->pll_src = source; @@ -695,7 +675,6 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, static int adav80x_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int mask = ADAV80X_DAC_CTRL1_PD; switch (level) { @@ -704,12 +683,10 @@ static int adav80x_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask, - 0x00); + snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, 0x00); break; case SND_SOC_BIAS_OFF: - regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask, - mask); + snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, mask); break; } @@ -803,7 +780,7 @@ static int adav80x_probe(struct snd_soc_codec *codec) int ret; struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); - ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 7, 9, adav80x->control_type); if (ret) { dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); return ret; @@ -814,31 +791,23 @@ static int adav80x_probe(struct snd_soc_codec *codec) snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2"); /* Power down S/PDIF receiver, since it is currently not supported */ - regmap_write(adav80x->regmap, ADAV80X_PLL_OUTE, 0x20); + snd_soc_write(codec, ADAV80X_PLL_OUTE, 0x20); /* Disable DAC zero flag */ - regmap_write(adav80x->regmap, ADAV80X_DAC_CTRL3, 0x6); + snd_soc_write(codec, ADAV80X_DAC_CTRL3, 0x6); return adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); } static int adav80x_suspend(struct snd_soc_codec *codec) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF); - regcache_cache_only(adav80x->regmap, true); - - return ret; + return adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF); } static int adav80x_resume(struct snd_soc_codec *codec) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); - - regcache_cache_only(adav80x->regmap, false); adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - regcache_sync(adav80x->regmap); + codec->cache_sync = 1; + snd_soc_cache_sync(codec); return 0; } @@ -858,6 +827,10 @@ static struct snd_soc_codec_driver adav80x_codec_driver = { .set_pll = adav80x_set_pll, .set_sysclk = adav80x_set_sysclk, + .reg_word_size = sizeof(u8), + .reg_cache_size = ARRAY_SIZE(adav80x_default_regs), + .reg_cache_default = adav80x_default_regs, + .controls = adav80x_controls, .num_controls = ARRAY_SIZE(adav80x_controls), .dapm_widgets = adav80x_dapm_widgets, @@ -866,21 +839,18 @@ static struct snd_soc_codec_driver adav80x_codec_driver = { .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes), }; -static int adav80x_bus_probe(struct device *dev, struct regmap *regmap) +static int adav80x_bus_probe(struct device *dev, + enum snd_soc_control_type control_type) { struct adav80x *adav80x; int ret; - if (IS_ERR(regmap)) - return PTR_ERR(regmap); - adav80x = kzalloc(sizeof(*adav80x), GFP_KERNEL); if (!adav80x) return -ENOMEM; - dev_set_drvdata(dev, adav80x); - adav80x->regmap = regmap; + adav80x->control_type = control_type; ret = snd_soc_register_codec(dev, &adav80x_codec_driver, adav80x_dais, ARRAY_SIZE(adav80x_dais)); @@ -898,19 +868,6 @@ static int adav80x_bus_remove(struct device *dev) } #if defined(CONFIG_SPI_MASTER) -static const struct regmap_config adav80x_spi_regmap_config = { - .val_bits = 8, - .pad_bits = 1, - .reg_bits = 7, - .read_flag_mask = 0x01, - - .max_register = ADAV80X_PLL_OUTE, - - .cache_type = REGCACHE_RBTREE, - .reg_defaults = adav80x_reg_defaults, - .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults), -}; - static const struct spi_device_id adav80x_spi_id[] = { { "adav801", 0 }, { } @@ -919,8 +876,7 @@ MODULE_DEVICE_TABLE(spi, adav80x_spi_id); static int adav80x_spi_probe(struct spi_device *spi) { - return adav80x_bus_probe(&spi->dev, - devm_regmap_init_spi(spi, &adav80x_spi_regmap_config)); + return adav80x_bus_probe(&spi->dev, SND_SOC_SPI); } static int adav80x_spi_remove(struct spi_device *spi) @@ -940,18 +896,6 @@ static struct spi_driver adav80x_spi_driver = { #endif #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -static const struct regmap_config adav80x_i2c_regmap_config = { - .val_bits = 8, - .pad_bits = 1, - .reg_bits = 7, - - .max_register = ADAV80X_PLL_OUTE, - - .cache_type = REGCACHE_RBTREE, - .reg_defaults = adav80x_reg_defaults, - .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults), -}; - static const struct i2c_device_id adav80x_i2c_id[] = { { "adav803", 0 }, { } @@ -961,8 +905,7 @@ MODULE_DEVICE_TABLE(i2c, adav80x_i2c_id); static int adav80x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - return adav80x_bus_probe(&client->dev, - devm_regmap_init_i2c(client, &adav80x_i2c_regmap_config)); + return adav80x_bus_probe(&client->dev, SND_SOC_I2C); } static int adav80x_i2c_remove(struct i2c_client *client) diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index b4819dc..71059c0 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c @@ -45,6 +45,8 @@ #define AK4104_TX_TXE (1 << 0) #define AK4104_TX_V (1 << 1) +#define DRV_NAME "ak4104-codec" + struct ak4104_private { struct regmap *regmap; }; @@ -289,19 +291,12 @@ static const struct of_device_id ak4104_of_match[] = { }; MODULE_DEVICE_TABLE(of, ak4104_of_match); -static const struct spi_device_id ak4104_id_table[] = { - { "ak4104", 0 }, - { } -}; -MODULE_DEVICE_TABLE(spi, ak4104_id_table); - static struct spi_driver ak4104_spi_driver = { .driver = { - .name = "ak4104", + .name = DRV_NAME, .owner = THIS_MODULE, .of_match_table = ak4104_of_match, }, - .id_table = ak4104_id_table, .probe = ak4104_spi_probe, .remove = ak4104_spi_remove, }; diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 49cc5f6..5f9af1f 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -328,7 +328,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ak4641->playback_fs = rate; ak4641_set_deemph(codec); - } + }; return 0; } diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 090d499..2d03787 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -257,7 +257,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p94. */ - snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); + snd_soc_write(codec, SG_SL1, PMMP | MGAIN0); snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); snd_soc_write(codec, ALC_CTL1, ALC | LMTH0); snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL); @@ -352,6 +352,7 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) */ default: return -EINVAL; + break; } snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); @@ -404,6 +405,7 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, break; default: return -EINVAL; + break; } snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate); diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index 19e9f22..f2e62e4 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -614,7 +614,7 @@ struct _pll_div { }; /* Note : pll code from original alc5632 driver. Not sure of how good it is */ -/* useful only for master mode */ +/* usefull only for master mode */ static const struct _pll_div codec_master_pll_div[] = { { 2048000, 8192000, 0x0ea0}, diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index fea9910..657808b 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -1477,25 +1477,21 @@ static void arizona_enable_fll(struct arizona_fll *fll, { struct arizona *arizona = fll->arizona; int ret; - bool use_sync = false; /* * If we have both REFCLK and SYNCCLK then enable both, * otherwise apply the SYNCCLK settings to REFCLK. */ - if (fll->ref_src >= 0 && fll->ref_freq && - fll->ref_src != fll->sync_src) { + if (fll->ref_src >= 0 && fll->ref_src != fll->sync_src) { regmap_update_bits(arizona->regmap, fll->base + 5, ARIZONA_FLL1_OUTDIV_MASK, ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, false); - if (fll->sync_src >= 0) { + if (fll->sync_src >= 0) arizona_apply_fll(arizona, fll->base + 0x10, sync, fll->sync_src, true); - use_sync = true; - } } else if (fll->sync_src >= 0) { regmap_update_bits(arizona->regmap, fll->base + 5, ARIZONA_FLL1_OUTDIV_MASK, @@ -1515,7 +1511,7 @@ static void arizona_enable_fll(struct arizona_fll *fll, * Increase the bandwidth if we're not using a low frequency * sync source. */ - if (use_sync && fll->sync_freq > 100000) + if (fll->sync_src >= 0 && fll->sync_freq > 100000) regmap_update_bits(arizona->regmap, fll->base + 0x17, ARIZONA_FLL1_SYNC_BW, 0); else @@ -1529,10 +1525,9 @@ static void arizona_enable_fll(struct arizona_fll *fll, try_wait_for_completion(&fll->ok); regmap_update_bits(arizona->regmap, fll->base + 1, - ARIZONA_FLL1_FREERUN, 0); - regmap_update_bits(arizona->regmap, fll->base + 1, ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); - if (use_sync) + if (fll->ref_src >= 0 && fll->sync_src >= 0 && + fll->ref_src != fll->sync_src) regmap_update_bits(arizona->regmap, fll->base + 0x11, ARIZONA_FLL1_SYNC_ENA, ARIZONA_FLL1_SYNC_ENA); @@ -1548,8 +1543,6 @@ static void arizona_disable_fll(struct arizona_fll *fll) struct arizona *arizona = fll->arizona; bool change; - regmap_update_bits(arizona->regmap, fll->base + 1, - ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN); regmap_update_bits_check(arizona->regmap, fll->base + 1, ARIZONA_FLL1_ENA, 0, &change); regmap_update_bits(arizona->regmap, fll->base + 0x11, @@ -1568,12 +1561,10 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, if (fll->ref_src == source && fll->ref_freq == Fref) return 0; - if (fll->fout) { - if (Fref > 0) { - ret = arizona_calc_fll(fll, &ref, Fref, fll->fout); - if (ret != 0) - return ret; - } + if (fll->fout && Fref > 0) { + ret = arizona_calc_fll(fll, &ref, Fref, fll->fout); + if (ret != 0) + return ret; if (fll->sync_src >= 0) { ret = arizona_calc_fll(fll, &sync, fll->sync_freq, diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 43737a27..23316c8 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -38,6 +38,24 @@ #include <sound/soc.h> #include <sound/initval.h> +static inline unsigned int cq93vc_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + struct davinci_vc *davinci_vc = codec->control_data; + + return readl(davinci_vc->base + reg); +} + +static inline int cq93vc_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + struct davinci_vc *davinci_vc = codec->control_data; + + writel(value, davinci_vc->base + reg); + + return 0; +} + static const struct snd_kcontrol_new cq93vc_snd_controls[] = { SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0), SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0), @@ -46,15 +64,13 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = { static int cq93vc_mute(struct snd_soc_dai *dai, int mute) { struct snd_soc_codec *codec = dai->codec; - u8 reg; + u8 reg = cq93vc_read(codec, DAVINCI_VC_REG09) & ~DAVINCI_VC_REG09_MUTE; if (mute) - reg = DAVINCI_VC_REG09_MUTE; + cq93vc_write(codec, DAVINCI_VC_REG09, + reg | DAVINCI_VC_REG09_MUTE); else - reg = 0; - - snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE, - reg); + cq93vc_write(codec, DAVINCI_VC_REG09, reg); return 0; } @@ -63,7 +79,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_codec *codec = codec_dai->codec; - struct davinci_vc *davinci_vc = codec->dev->platform_data; + struct davinci_vc *davinci_vc = codec->control_data; switch (freq) { case 22579200: @@ -81,18 +97,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec, { switch (level) { case SND_SOC_BIAS_ON: - snd_soc_write(codec, DAVINCI_VC_REG12, + cq93vc_write(codec, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_ON); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, DAVINCI_VC_REG12, + cq93vc_write(codec, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_OFF); break; case SND_SOC_BIAS_OFF: /* force all power off */ - snd_soc_write(codec, DAVINCI_VC_REG12, + cq93vc_write(codec, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_OFF); break; } @@ -138,9 +154,11 @@ static int cq93vc_probe(struct snd_soc_codec *codec) struct davinci_vc *davinci_vc = codec->dev->platform_data; davinci_vc->cq93vc.codec = codec; - codec->control_data = davinci_vc->regmap; + codec->control_data = davinci_vc; - snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP); + /* Set controls */ + snd_soc_add_codec_controls(codec, cq93vc_snd_controls, + ARRAY_SIZE(cq93vc_snd_controls)); /* Off, with power on */ cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); @@ -156,12 +174,12 @@ static int cq93vc_remove(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { + .read = cq93vc_read, + .write = cq93vc_write, .set_bias_level = cq93vc_set_bias_level, .probe = cq93vc_probe, .remove = cq93vc_remove, .resume = cq93vc_resume, - .controls = cq93vc_snd_controls, - .num_controls = ARRAY_SIZE(cq93vc_snd_controls), }; static int cq93vc_platform_probe(struct platform_device *pdev) diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index f6e9534..a20f1bb 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -25,7 +25,6 @@ #include <linux/gpio.h> #include <linux/i2c.h> #include <linux/spi/spi.h> -#include <linux/of.h> #include <linux/of_device.h> #include <linux/of_gpio.h> #include <sound/pcm.h> diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index 8b427c9..be2ba1b 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c @@ -17,7 +17,6 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> -#include <linux/gpio.h> #include <linux/pm.h> #include <linux/i2c.h> #include <linux/input.h> @@ -1117,6 +1116,40 @@ static int cs42l52_probe(struct snd_soc_codec *codec) cs42l52->sysclk = CS42L52_DEFAULT_CLK; cs42l52->config.format = CS42L52_DEFAULT_FORMAT; + /* Set Platform MICx CFG */ + snd_soc_update_bits(codec, CS42L52_MICA_CTL, + CS42L52_MIC_CTL_TYPE_MASK, + cs42l52->pdata.mica_cfg << + CS42L52_MIC_CTL_TYPE_SHIFT); + + snd_soc_update_bits(codec, CS42L52_MICB_CTL, + CS42L52_MIC_CTL_TYPE_MASK, + cs42l52->pdata.micb_cfg << + CS42L52_MIC_CTL_TYPE_SHIFT); + + /* if Single Ended, Get Mic_Select */ + if (cs42l52->pdata.mica_cfg) + snd_soc_update_bits(codec, CS42L52_MICA_CTL, + CS42L52_MIC_CTL_MIC_SEL_MASK, + cs42l52->pdata.mica_sel << + CS42L52_MIC_CTL_MIC_SEL_SHIFT); + if (cs42l52->pdata.micb_cfg) + snd_soc_update_bits(codec, CS42L52_MICB_CTL, + CS42L52_MIC_CTL_MIC_SEL_MASK, + cs42l52->pdata.micb_sel << + CS42L52_MIC_CTL_MIC_SEL_SHIFT); + + /* Set Platform Charge Pump Freq */ + snd_soc_update_bits(codec, CS42L52_CHARGE_PUMP, + CS42L52_CHARGE_PUMP_MASK, + cs42l52->pdata.chgfreq << + CS42L52_CHARGE_PUMP_SHIFT); + + /* Set Platform Bias Level */ + snd_soc_update_bits(codec, CS42L52_IFACE_CTL2, + CS42L52_IFACE_CTL2_BIAS_LVL, + cs42l52->pdata.micbias_lvl); + return ret; } @@ -1172,7 +1205,6 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs42l52_private *cs42l52; - struct cs42l52_platform_data *pdata = dev_get_platdata(&i2c_client->dev); int ret; unsigned int devid = 0; unsigned int reg; @@ -1190,23 +1222,12 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, return ret; } - if (pdata) - cs42l52->pdata = *pdata; - - if (cs42l52->pdata.reset_gpio) { - ret = gpio_request_one(cs42l52->pdata.reset_gpio, - GPIOF_OUT_INIT_HIGH, "CS42L52 /RST"); - if (ret < 0) { - dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", - cs42l52->pdata.reset_gpio, ret); - return ret; - } - gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 0); - gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 1); - } - i2c_set_clientdata(i2c_client, cs42l52); + if (dev_get_platdata(&i2c_client->dev)) + memcpy(&cs42l52->pdata, dev_get_platdata(&i2c_client->dev), + sizeof(cs42l52->pdata)); + ret = regmap_register_patch(cs42l52->regmap, cs42l52_threshold_patch, ARRAY_SIZE(cs42l52_threshold_patch)); if (ret != 0) @@ -1223,43 +1244,7 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, return ret; } - dev_info(&i2c_client->dev, "Cirrus Logic CS42L52, Revision: %02X\n", - reg & 0xFF); - - /* Set Platform Data */ - if (cs42l52->pdata.mica_cfg) - regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, - CS42L52_MIC_CTL_TYPE_MASK, - cs42l52->pdata.mica_cfg << - CS42L52_MIC_CTL_TYPE_SHIFT); - - if (cs42l52->pdata.micb_cfg) - regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, - CS42L52_MIC_CTL_TYPE_MASK, - cs42l52->pdata.micb_cfg << - CS42L52_MIC_CTL_TYPE_SHIFT); - - if (cs42l52->pdata.mica_sel) - regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, - CS42L52_MIC_CTL_MIC_SEL_MASK, - cs42l52->pdata.mica_sel << - CS42L52_MIC_CTL_MIC_SEL_SHIFT); - if (cs42l52->pdata.micb_sel) - regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, - CS42L52_MIC_CTL_MIC_SEL_MASK, - cs42l52->pdata.micb_sel << - CS42L52_MIC_CTL_MIC_SEL_SHIFT); - - if (cs42l52->pdata.chgfreq) - regmap_update_bits(cs42l52->regmap, CS42L52_CHARGE_PUMP, - CS42L52_CHARGE_PUMP_MASK, - cs42l52->pdata.chgfreq << - CS42L52_CHARGE_PUMP_SHIFT); - - if (cs42l52->pdata.micbias_lvl) - regmap_update_bits(cs42l52->regmap, CS42L52_IFACE_CTL2, - CS42L52_IFACE_CTL2_BIAS_LVL, - cs42l52->pdata.micbias_lvl); + regcache_cache_only(cs42l52->regmap, true); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs42l52, &cs42l52_dai, 1); diff --git a/sound/soc/codecs/cs42l52.h b/sound/soc/codecs/cs42l52.h index 6fb8f00..4277012 100644 --- a/sound/soc/codecs/cs42l52.h +++ b/sound/soc/codecs/cs42l52.h @@ -179,7 +179,7 @@ #define CS42L52_MICB_CTL 0x11 #define CS42L52_MIC_CTL_MIC_SEL_MASK 0xBF #define CS42L52_MIC_CTL_MIC_SEL_SHIFT 6 -#define CS42L52_MIC_CTL_TYPE_MASK 0x20 +#define CS42L52_MIC_CTL_TYPE_MASK 0xDF #define CS42L52_MIC_CTL_TYPE_SHIFT 5 @@ -269,6 +269,6 @@ #define CS42L52_FIX_BITS1 0x3E #define CS42L52_FIX_BITS2 0x47 -#define CS42L52_MAX_REGISTER 0x47 +#define CS42L52_MAX_REGISTER 0x34 #endif diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index 549d5d6..3b20c86 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c @@ -17,7 +17,6 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> -#include <linux/of_gpio.h> #include <linux/pm.h> #include <linux/i2c.h> #include <linux/regmap.h> @@ -29,7 +28,6 @@ #include <sound/soc-dapm.h> #include <sound/initval.h> #include <sound/tlv.h> -#include <sound/cs42l73.h> #include "cs42l73.h" struct sp_config { @@ -37,7 +35,6 @@ struct sp_config { u32 srate; }; struct cs42l73_private { - struct cs42l73_platform_data pdata; struct sp_config config[3]; struct regmap *regmap; u32 sysclk; @@ -313,6 +310,15 @@ static const struct soc_enum ng_delay_enum = SOC_ENUM_SINGLE(CS42L73_NGCAB, 0, ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text); +static const char * const charge_pump_freq_text[] = { + "0", "1", "2", "3", "4", + "5", "6", "7", "8", "9", + "10", "11", "12", "13", "14", "15" }; + +static const struct soc_enum charge_pump_enum = + SOC_ENUM_SINGLE(CS42L73_CPFCHC, 4, + ARRAY_SIZE(charge_pump_freq_text), charge_pump_freq_text); + static const char * const cs42l73_mono_mix_texts[] = { "Left", "Right", "Mono Mix"}; @@ -505,6 +511,8 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = { SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0), SOC_ENUM("NG Delay", ng_delay_enum), + SOC_ENUM("Charge Pump Frequency", charge_pump_enum), + SOC_DOUBLE_R_TLV("XSP-IP Volume", CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1, attn_tlv), @@ -1047,11 +1055,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - mmcc |= CS42L73_MS_MASTER; + mmcc |= MS_MASTER; break; case SND_SOC_DAIFMT_CBS_CFS: - mmcc &= ~CS42L73_MS_MASTER; + mmcc &= ~MS_MASTER; break; default: @@ -1063,11 +1071,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) switch (format) { case SND_SOC_DAIFMT_I2S: - spc &= ~CS42L73_SPDIF_PCM; + spc &= ~SPDIF_PCM; break; case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_B: - if (mmcc & CS42L73_MS_MASTER) { + if (mmcc & MS_MASTER) { dev_err(codec->dev, "PCM format in slave mode only\n"); return -EINVAL; @@ -1077,25 +1085,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) "PCM format is not supported on ASP port\n"); return -EINVAL; } - spc |= CS42L73_SPDIF_PCM; + spc |= SPDIF_PCM; break; default: return -EINVAL; } - if (spc & CS42L73_SPDIF_PCM) { + if (spc & SPDIF_PCM) { /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */ - spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER); + spc &= ~(PCM_MODE_MASK | PCM_BIT_ORDER); switch (format) { case SND_SOC_DAIFMT_DSP_B: if (inv == SND_SOC_DAIFMT_IB_IF) - spc |= CS42L73_PCM_MODE0; + spc |= PCM_MODE0; if (inv == SND_SOC_DAIFMT_IB_NF) - spc |= CS42L73_PCM_MODE1; + spc |= PCM_MODE1; break; case SND_SOC_DAIFMT_DSP_A: if (inv == SND_SOC_DAIFMT_IB_IF) - spc |= CS42L73_PCM_MODE1; + spc |= PCM_MODE1; break; default: return -EINVAL; @@ -1155,7 +1163,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, int mclk_coeff; int srate = params_rate(params); - if (priv->config[id].mmcc & CS42L73_MS_MASTER) { + if (priv->config[id].mmcc & MS_MASTER) { /* CS42L73 Master */ /* MCLK -> srate */ mclk_coeff = @@ -1174,13 +1182,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, priv->config[id].spc &= 0xFC; /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */ if (priv->mclk >= 6400000) - priv->config[id].spc |= CS42L73_MCK_SCLK_64FS; + priv->config[id].spc |= MCK_SCLK_64FS; else - priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK; + priv->config[id].spc |= MCK_SCLK_MCLK; } else { /* CS42L73 Slave */ priv->config[id].spc &= 0xFC; - priv->config[id].spc |= CS42L73_MCK_SCLK_64FS; + priv->config[id].spc |= MCK_SCLK_64FS; } /* Update ASRCs */ priv->config[id].srate = srate; @@ -1200,8 +1208,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0); - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0); + snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 0); + snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 0); break; case SND_SOC_BIAS_PREPARE: @@ -1212,11 +1220,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, regcache_cache_only(cs42l73->regmap, false); regcache_sync(cs42l73->regmap); } - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); + snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); + snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); if (cs42l73->shutdwn_delay > 0) { mdelay(cs42l73->shutdwn_delay); cs42l73->shutdwn_delay = 0; @@ -1225,7 +1233,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, * down. */ } - snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1); + snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 1); break; } codec->dapm.bias_level = level; @@ -1359,16 +1367,11 @@ static int cs42l73_probe(struct snd_soc_codec *codec) return ret; } - cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + regcache_cache_only(cs42l73->regmap, true); - /* Set Charge Pump Frequency */ - if (cs42l73->pdata.chgfreq) - snd_soc_update_bits(codec, CS42L73_CPFCHC, - CS42L73_CHARGEPUMP_MASK, - cs42l73->pdata.chgfreq << 4); + cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - /* MCLK1 as master clk */ - cs42l73->mclksel = CS42L73_CLKID_MCLK1; + cs42l73->mclksel = CS42L73_CLKID_MCLK1; /* MCLK1 as master clk */ cs42l73->mclk = 0; return ret; @@ -1412,11 +1415,9 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs42l73_private *cs42l73; - struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev); int ret; unsigned int devid = 0; unsigned int reg; - u32 val32; cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), GFP_KERNEL); @@ -1425,49 +1426,14 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, return -ENOMEM; } + i2c_set_clientdata(i2c_client, cs42l73); + cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); if (IS_ERR(cs42l73->regmap)) { ret = PTR_ERR(cs42l73->regmap); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); return ret; } - - if (pdata) { - cs42l73->pdata = *pdata; - } else { - pdata = devm_kzalloc(&i2c_client->dev, - sizeof(struct cs42l73_platform_data), - GFP_KERNEL); - if (!pdata) { - dev_err(&i2c_client->dev, "could not allocate pdata\n"); - return -ENOMEM; - } - if (i2c_client->dev.of_node) { - if (of_property_read_u32(i2c_client->dev.of_node, - "chgfreq", &val32) >= 0) - pdata->chgfreq = val32; - } - pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, - "reset-gpio", 0); - cs42l73->pdata = *pdata; - } - - i2c_set_clientdata(i2c_client, cs42l73); - - if (cs42l73->pdata.reset_gpio) { - ret = gpio_request_one(cs42l73->pdata.reset_gpio, - GPIOF_OUT_INIT_HIGH, "CS42L73 /RST"); - if (ret < 0) { - dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", - cs42l73->pdata.reset_gpio, ret); - return ret; - } - gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0); - gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1); - } - - regcache_cache_bypass(cs42l73->regmap, true); - /* initialize codec */ ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, ®); devid = (reg & 0xFF) << 12; @@ -1478,6 +1444,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, ®); devid |= (reg & 0xF0) >> 4; + if (devid != CS42L73_DEVID) { ret = -ENODEV; dev_err(&i2c_client->dev, @@ -1495,7 +1462,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, dev_info(&i2c_client->dev, "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); - regcache_cache_bypass(cs42l73->regmap, false); + regcache_cache_only(cs42l73->regmap, true); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs42l73, cs42l73_dai, @@ -1511,12 +1478,6 @@ static int cs42l73_i2c_remove(struct i2c_client *client) return 0; } -static const struct of_device_id cs42l73_of_match[] = { - { .compatible = "cirrus,cs42l73", }, - {}, -}; -MODULE_DEVICE_TABLE(of, cs42l73_of_match); - static const struct i2c_device_id cs42l73_id[] = { {"cs42l73", 0}, {} @@ -1528,7 +1489,6 @@ static struct i2c_driver cs42l73_i2c_driver = { .driver = { .name = "cs42l73", .owner = THIS_MODULE, - .of_match_table = cs42l73_of_match, }, .id_table = cs42l73_id, .probe = cs42l73_i2c_probe, diff --git a/sound/soc/codecs/cs42l73.h b/sound/soc/codecs/cs42l73.h index 4574618..f30a4c4 100644 --- a/sound/soc/codecs/cs42l73.h +++ b/sound/soc/codecs/cs42l73.h @@ -128,60 +128,59 @@ /* Bitfield Definitions */ /* CS42L73_PWRCTL1 */ -#define CS42L73_PDN_ADCB (1 << 7) -#define CS42L73_PDN_DMICB (1 << 6) -#define CS42L73_PDN_ADCA (1 << 5) -#define CS42L73_PDN_DMICA (1 << 4) -#define CS42L73_PDN_LDO (1 << 2) -#define CS42L73_DISCHG_FILT (1 << 1) -#define CS42L73_PDN (1 << 0) +#define PDN_ADCB (1 << 7) +#define PDN_DMICB (1 << 6) +#define PDN_ADCA (1 << 5) +#define PDN_DMICA (1 << 4) +#define PDN_LDO (1 << 2) +#define DISCHG_FILT (1 << 1) +#define PDN (1 << 0) /* CS42L73_PWRCTL2 */ -#define CS42L73_PDN_MIC2_BIAS (1 << 7) -#define CS42L73_PDN_MIC1_BIAS (1 << 6) -#define CS42L73_PDN_VSP (1 << 4) -#define CS42L73_PDN_ASP_SDOUT (1 << 3) -#define CS42L73_PDN_ASP_SDIN (1 << 2) -#define CS42L73_PDN_XSP_SDOUT (1 << 1) -#define CS42L73_PDN_XSP_SDIN (1 << 0) +#define PDN_MIC2_BIAS (1 << 7) +#define PDN_MIC1_BIAS (1 << 6) +#define PDN_VSP (1 << 4) +#define PDN_ASP_SDOUT (1 << 3) +#define PDN_ASP_SDIN (1 << 2) +#define PDN_XSP_SDOUT (1 << 1) +#define PDN_XSP_SDIN (1 << 0) /* CS42L73_PWRCTL3 */ -#define CS42L73_PDN_THMS (1 << 5) -#define CS42L73_PDN_SPKLO (1 << 4) -#define CS42L73_PDN_EAR (1 << 3) -#define CS42L73_PDN_SPK (1 << 2) -#define CS42L73_PDN_LO (1 << 1) -#define CS42L73_PDN_HP (1 << 0) +#define PDN_THMS (1 << 5) +#define PDN_SPKLO (1 << 4) +#define PDN_EAR (1 << 3) +#define PDN_SPK (1 << 2) +#define PDN_LO (1 << 1) +#define PDN_HP (1 << 0) /* Thermal Overload Detect. Requires interrupt ... */ -#define CS42L73_THMOVLD_150C 0 -#define CS42L73_THMOVLD_132C 1 -#define CS42L73_THMOVLD_115C 2 -#define CS42L73_THMOVLD_098C 3 +#define THMOVLD_150C 0 +#define THMOVLD_132C 1 +#define THMOVLD_115C 2 +#define THMOVLD_098C 3 -#define CS42L73_CHARGEPUMP_MASK (0xF0) /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */ -#define CS42L73_SP_3ST (1 << 7) -#define CS42L73_SPDIF_I2S (0 << 6) -#define CS42L73_SPDIF_PCM (1 << 6) -#define CS42L73_PCM_MODE0 (0 << 4) -#define CS42L73_PCM_MODE1 (1 << 4) -#define CS42L73_PCM_MODE2 (2 << 4) -#define CS42L73_PCM_MODE_MASK (3 << 4) -#define CS42L73_PCM_BIT_ORDER (1 << 3) -#define CS42L73_MCK_SCLK_64FS (0 << 0) -#define CS42L73_MCK_SCLK_MCLK (2 << 0) -#define CS42L73_MCK_SCLK_PREMCLK (3 << 0) +#define SP_3ST (1 << 7) +#define SPDIF_I2S (0 << 6) +#define SPDIF_PCM (1 << 6) +#define PCM_MODE0 (0 << 4) +#define PCM_MODE1 (1 << 4) +#define PCM_MODE2 (2 << 4) +#define PCM_MODE_MASK (3 << 4) +#define PCM_BIT_ORDER (1 << 3) +#define MCK_SCLK_64FS (0 << 0) +#define MCK_SCLK_MCLK (2 << 0) +#define MCK_SCLK_PREMCLK (3 << 0) /* CS42L73_xSPMMCC */ -#define CS42L73_MS_MASTER (1 << 7) +#define MS_MASTER (1 << 7) /* CS42L73_DMMCC */ -#define CS42L73_MCLKDIS (1 << 0) -#define CS42L73_MCLKSEL_MCLK2 (1 << 4) -#define CS42L73_MCLKSEL_MCLK1 (0 << 4) +#define MCLKDIS (1 << 0) +#define MCLKSEL_MCLK2 (1 << 4) +#define MCLKSEL_MCLK1 (0 << 4) /* CS42L73 MCLK derived from MCLK1 or MCLK2 */ #define CS42L73_CLKID_MCLK1 0 @@ -195,26 +194,28 @@ #define CS42L73_VSP 2 /* IS1, IM1 */ -#define CS42L73_MIC2_SDET (1 << 6) -#define CS42L73_THMOVLD (1 << 4) -#define CS42L73_DIGMIXOVFL (1 << 3) -#define CS42L73_IPBOVFL (1 << 1) -#define CS42L73_IPAOVFL (1 << 0) +#define MIC2_SDET (1 << 6) +#define THMOVLD (1 << 4) +#define DIGMIXOVFL (1 << 3) +#define IPBOVFL (1 << 1) +#define IPAOVFL (1 << 0) /* Analog Softramp */ -#define CS42L73_ANLGOSFT (1 << 0) +#define ANLGOSFT (1 << 0) /* HP A/B Analog Mute */ -#define CS42L73_HPA_MUTE (1 << 7) +#define HPA_MUTE (1 << 7) /* LO A/B Analog Mute */ -#define CS42L73_LOA_MUTE (1 << 7) +#define LOA_MUTE (1 << 7) /* Digital Mute */ -#define CS42L73_HLAD_MUTE (1 << 0) -#define CS42L73_HLBD_MUTE (1 << 1) -#define CS42L73_SPKD_MUTE (1 << 2) -#define CS42L73_ESLD_MUTE (1 << 3) +#define HLAD_MUTE (1 << 0) +#define HLBD_MUTE (1 << 1) +#define SPKD_MUTE (1 << 2) +#define ESLD_MUTE (1 << 3) /* Misc defines for codec */ +#define CS42L73_RESET_GPIO 143 + #define CS42L73_DEVID 0x00042A73 #define CS42L73_MCLKX_MIN 5644800 #define CS42L73_MCLKX_MAX 38400000 diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 53d7dab..566a367 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -15,7 +15,6 @@ #include <linux/delay.h> #include <linux/pm.h> #include <linux/i2c.h> -#include <linux/regmap.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -39,223 +38,294 @@ struct max98088_cdata { }; struct max98088_priv { - struct regmap *regmap; - enum max98088_type devtype; - struct max98088_pdata *pdata; - unsigned int sysclk; - struct max98088_cdata dai[2]; - int eq_textcnt; - const char **eq_texts; - struct soc_enum eq_enum; - u8 ina_state; - u8 inb_state; - unsigned int ex_mode; - unsigned int digmic; - unsigned int mic1pre; - unsigned int mic2pre; - unsigned int extmic_mode; + enum max98088_type devtype; + struct max98088_pdata *pdata; + unsigned int sysclk; + struct max98088_cdata dai[2]; + int eq_textcnt; + const char **eq_texts; + struct soc_enum eq_enum; + u8 ina_state; + u8 inb_state; + unsigned int ex_mode; + unsigned int digmic; + unsigned int mic1pre; + unsigned int mic2pre; + unsigned int extmic_mode; }; -static const struct reg_default max98088_reg[] = { - { 0xf, 0x00 }, /* 0F interrupt enable */ - - { 0x10, 0x00 }, /* 10 master clock */ - { 0x11, 0x00 }, /* 11 DAI1 clock mode */ - { 0x12, 0x00 }, /* 12 DAI1 clock control */ - { 0x13, 0x00 }, /* 13 DAI1 clock control */ - { 0x14, 0x00 }, /* 14 DAI1 format */ - { 0x15, 0x00 }, /* 15 DAI1 clock */ - { 0x16, 0x00 }, /* 16 DAI1 config */ - { 0x17, 0x00 }, /* 17 DAI1 TDM */ - { 0x18, 0x00 }, /* 18 DAI1 filters */ - { 0x19, 0x00 }, /* 19 DAI2 clock mode */ - { 0x1a, 0x00 }, /* 1A DAI2 clock control */ - { 0x1b, 0x00 }, /* 1B DAI2 clock control */ - { 0x1c, 0x00 }, /* 1C DAI2 format */ - { 0x1d, 0x00 }, /* 1D DAI2 clock */ - { 0x1e, 0x00 }, /* 1E DAI2 config */ - { 0x1f, 0x00 }, /* 1F DAI2 TDM */ - - { 0x20, 0x00 }, /* 20 DAI2 filters */ - { 0x21, 0x00 }, /* 21 data config */ - { 0x22, 0x00 }, /* 22 DAC mixer */ - { 0x23, 0x00 }, /* 23 left ADC mixer */ - { 0x24, 0x00 }, /* 24 right ADC mixer */ - { 0x25, 0x00 }, /* 25 left HP mixer */ - { 0x26, 0x00 }, /* 26 right HP mixer */ - { 0x27, 0x00 }, /* 27 HP control */ - { 0x28, 0x00 }, /* 28 left REC mixer */ - { 0x29, 0x00 }, /* 29 right REC mixer */ - { 0x2a, 0x00 }, /* 2A REC control */ - { 0x2b, 0x00 }, /* 2B left SPK mixer */ - { 0x2c, 0x00 }, /* 2C right SPK mixer */ - { 0x2d, 0x00 }, /* 2D SPK control */ - { 0x2e, 0x00 }, /* 2E sidetone */ - { 0x2f, 0x00 }, /* 2F DAI1 playback level */ - - { 0x30, 0x00 }, /* 30 DAI1 playback level */ - { 0x31, 0x00 }, /* 31 DAI2 playback level */ - { 0x32, 0x00 }, /* 32 DAI2 playbakc level */ - { 0x33, 0x00 }, /* 33 left ADC level */ - { 0x34, 0x00 }, /* 34 right ADC level */ - { 0x35, 0x00 }, /* 35 MIC1 level */ - { 0x36, 0x00 }, /* 36 MIC2 level */ - { 0x37, 0x00 }, /* 37 INA level */ - { 0x38, 0x00 }, /* 38 INB level */ - { 0x39, 0x00 }, /* 39 left HP volume */ - { 0x3a, 0x00 }, /* 3A right HP volume */ - { 0x3b, 0x00 }, /* 3B left REC volume */ - { 0x3c, 0x00 }, /* 3C right REC volume */ - { 0x3d, 0x00 }, /* 3D left SPK volume */ - { 0x3e, 0x00 }, /* 3E right SPK volume */ - { 0x3f, 0x00 }, /* 3F MIC config */ - - { 0x40, 0x00 }, /* 40 MIC threshold */ - { 0x41, 0x00 }, /* 41 excursion limiter filter */ - { 0x42, 0x00 }, /* 42 excursion limiter threshold */ - { 0x43, 0x00 }, /* 43 ALC */ - { 0x44, 0x00 }, /* 44 power limiter threshold */ - { 0x45, 0x00 }, /* 45 power limiter config */ - { 0x46, 0x00 }, /* 46 distortion limiter config */ - { 0x47, 0x00 }, /* 47 audio input */ - { 0x48, 0x00 }, /* 48 microphone */ - { 0x49, 0x00 }, /* 49 level control */ - { 0x4a, 0x00 }, /* 4A bypass switches */ - { 0x4b, 0x00 }, /* 4B jack detect */ - { 0x4c, 0x00 }, /* 4C input enable */ - { 0x4d, 0x00 }, /* 4D output enable */ - { 0x4e, 0xF0 }, /* 4E bias control */ - { 0x4f, 0x00 }, /* 4F DAC power */ - - { 0x50, 0x0F }, /* 50 DAC power */ - { 0x51, 0x00 }, /* 51 system */ - { 0x52, 0x00 }, /* 52 DAI1 EQ1 */ - { 0x53, 0x00 }, /* 53 DAI1 EQ1 */ - { 0x54, 0x00 }, /* 54 DAI1 EQ1 */ - { 0x55, 0x00 }, /* 55 DAI1 EQ1 */ - { 0x56, 0x00 }, /* 56 DAI1 EQ1 */ - { 0x57, 0x00 }, /* 57 DAI1 EQ1 */ - { 0x58, 0x00 }, /* 58 DAI1 EQ1 */ - { 0x59, 0x00 }, /* 59 DAI1 EQ1 */ - { 0x5a, 0x00 }, /* 5A DAI1 EQ1 */ - { 0x5b, 0x00 }, /* 5B DAI1 EQ1 */ - { 0x5c, 0x00 }, /* 5C DAI1 EQ2 */ - { 0x5d, 0x00 }, /* 5D DAI1 EQ2 */ - { 0x5e, 0x00 }, /* 5E DAI1 EQ2 */ - { 0x5f, 0x00 }, /* 5F DAI1 EQ2 */ - - { 0x60, 0x00 }, /* 60 DAI1 EQ2 */ - { 0x61, 0x00 }, /* 61 DAI1 EQ2 */ - { 0x62, 0x00 }, /* 62 DAI1 EQ2 */ - { 0x63, 0x00 }, /* 63 DAI1 EQ2 */ - { 0x64, 0x00 }, /* 64 DAI1 EQ2 */ - { 0x65, 0x00 }, /* 65 DAI1 EQ2 */ - { 0x66, 0x00 }, /* 66 DAI1 EQ3 */ - { 0x67, 0x00 }, /* 67 DAI1 EQ3 */ - { 0x68, 0x00 }, /* 68 DAI1 EQ3 */ - { 0x69, 0x00 }, /* 69 DAI1 EQ3 */ - { 0x6a, 0x00 }, /* 6A DAI1 EQ3 */ - { 0x6b, 0x00 }, /* 6B DAI1 EQ3 */ - { 0x6c, 0x00 }, /* 6C DAI1 EQ3 */ - { 0x6d, 0x00 }, /* 6D DAI1 EQ3 */ - { 0x6e, 0x00 }, /* 6E DAI1 EQ3 */ - { 0x6f, 0x00 }, /* 6F DAI1 EQ3 */ - - { 0x70, 0x00 }, /* 70 DAI1 EQ4 */ - { 0x71, 0x00 }, /* 71 DAI1 EQ4 */ - { 0x72, 0x00 }, /* 72 DAI1 EQ4 */ - { 0x73, 0x00 }, /* 73 DAI1 EQ4 */ - { 0x74, 0x00 }, /* 74 DAI1 EQ4 */ - { 0x75, 0x00 }, /* 75 DAI1 EQ4 */ - { 0x76, 0x00 }, /* 76 DAI1 EQ4 */ - { 0x77, 0x00 }, /* 77 DAI1 EQ4 */ - { 0x78, 0x00 }, /* 78 DAI1 EQ4 */ - { 0x79, 0x00 }, /* 79 DAI1 EQ4 */ - { 0x7a, 0x00 }, /* 7A DAI1 EQ5 */ - { 0x7b, 0x00 }, /* 7B DAI1 EQ5 */ - { 0x7c, 0x00 }, /* 7C DAI1 EQ5 */ - { 0x7d, 0x00 }, /* 7D DAI1 EQ5 */ - { 0x7e, 0x00 }, /* 7E DAI1 EQ5 */ - { 0x7f, 0x00 }, /* 7F DAI1 EQ5 */ - - { 0x80, 0x00 }, /* 80 DAI1 EQ5 */ - { 0x81, 0x00 }, /* 81 DAI1 EQ5 */ - { 0x82, 0x00 }, /* 82 DAI1 EQ5 */ - { 0x83, 0x00 }, /* 83 DAI1 EQ5 */ - { 0x84, 0x00 }, /* 84 DAI2 EQ1 */ - { 0x85, 0x00 }, /* 85 DAI2 EQ1 */ - { 0x86, 0x00 }, /* 86 DAI2 EQ1 */ - { 0x87, 0x00 }, /* 87 DAI2 EQ1 */ - { 0x88, 0x00 }, /* 88 DAI2 EQ1 */ - { 0x89, 0x00 }, /* 89 DAI2 EQ1 */ - { 0x8a, 0x00 }, /* 8A DAI2 EQ1 */ - { 0x8b, 0x00 }, /* 8B DAI2 EQ1 */ - { 0x8c, 0x00 }, /* 8C DAI2 EQ1 */ - { 0x8d, 0x00 }, /* 8D DAI2 EQ1 */ - { 0x8e, 0x00 }, /* 8E DAI2 EQ2 */ - { 0x8f, 0x00 }, /* 8F DAI2 EQ2 */ - - { 0x90, 0x00 }, /* 90 DAI2 EQ2 */ - { 0x91, 0x00 }, /* 91 DAI2 EQ2 */ - { 0x92, 0x00 }, /* 92 DAI2 EQ2 */ - { 0x93, 0x00 }, /* 93 DAI2 EQ2 */ - { 0x94, 0x00 }, /* 94 DAI2 EQ2 */ - { 0x95, 0x00 }, /* 95 DAI2 EQ2 */ - { 0x96, 0x00 }, /* 96 DAI2 EQ2 */ - { 0x97, 0x00 }, /* 97 DAI2 EQ2 */ - { 0x98, 0x00 }, /* 98 DAI2 EQ3 */ - { 0x99, 0x00 }, /* 99 DAI2 EQ3 */ - { 0x9a, 0x00 }, /* 9A DAI2 EQ3 */ - { 0x9b, 0x00 }, /* 9B DAI2 EQ3 */ - { 0x9c, 0x00 }, /* 9C DAI2 EQ3 */ - { 0x9d, 0x00 }, /* 9D DAI2 EQ3 */ - { 0x9e, 0x00 }, /* 9E DAI2 EQ3 */ - { 0x9f, 0x00 }, /* 9F DAI2 EQ3 */ - - { 0xa0, 0x00 }, /* A0 DAI2 EQ3 */ - { 0xa1, 0x00 }, /* A1 DAI2 EQ3 */ - { 0xa2, 0x00 }, /* A2 DAI2 EQ4 */ - { 0xa3, 0x00 }, /* A3 DAI2 EQ4 */ - { 0xa4, 0x00 }, /* A4 DAI2 EQ4 */ - { 0xa5, 0x00 }, /* A5 DAI2 EQ4 */ - { 0xa6, 0x00 }, /* A6 DAI2 EQ4 */ - { 0xa7, 0x00 }, /* A7 DAI2 EQ4 */ - { 0xa8, 0x00 }, /* A8 DAI2 EQ4 */ - { 0xa9, 0x00 }, /* A9 DAI2 EQ4 */ - { 0xaa, 0x00 }, /* AA DAI2 EQ4 */ - { 0xab, 0x00 }, /* AB DAI2 EQ4 */ - { 0xac, 0x00 }, /* AC DAI2 EQ5 */ - { 0xad, 0x00 }, /* AD DAI2 EQ5 */ - { 0xae, 0x00 }, /* AE DAI2 EQ5 */ - { 0xaf, 0x00 }, /* AF DAI2 EQ5 */ - - { 0xb0, 0x00 }, /* B0 DAI2 EQ5 */ - { 0xb1, 0x00 }, /* B1 DAI2 EQ5 */ - { 0xb2, 0x00 }, /* B2 DAI2 EQ5 */ - { 0xb3, 0x00 }, /* B3 DAI2 EQ5 */ - { 0xb4, 0x00 }, /* B4 DAI2 EQ5 */ - { 0xb5, 0x00 }, /* B5 DAI2 EQ5 */ - { 0xb6, 0x00 }, /* B6 DAI1 biquad */ - { 0xb7, 0x00 }, /* B7 DAI1 biquad */ - { 0xb8 ,0x00 }, /* B8 DAI1 biquad */ - { 0xb9, 0x00 }, /* B9 DAI1 biquad */ - { 0xba, 0x00 }, /* BA DAI1 biquad */ - { 0xbb, 0x00 }, /* BB DAI1 biquad */ - { 0xbc, 0x00 }, /* BC DAI1 biquad */ - { 0xbd, 0x00 }, /* BD DAI1 biquad */ - { 0xbe, 0x00 }, /* BE DAI1 biquad */ - { 0xbf, 0x00 }, /* BF DAI1 biquad */ - - { 0xc0, 0x00 }, /* C0 DAI2 biquad */ - { 0xc1, 0x00 }, /* C1 DAI2 biquad */ - { 0xc2, 0x00 }, /* C2 DAI2 biquad */ - { 0xc3, 0x00 }, /* C3 DAI2 biquad */ - { 0xc4, 0x00 }, /* C4 DAI2 biquad */ - { 0xc5, 0x00 }, /* C5 DAI2 biquad */ - { 0xc6, 0x00 }, /* C6 DAI2 biquad */ - { 0xc7, 0x00 }, /* C7 DAI2 biquad */ - { 0xc8, 0x00 }, /* C8 DAI2 biquad */ - { 0xc9, 0x00 }, /* C9 DAI2 biquad */ +static const u8 max98088_reg[M98088_REG_CNT] = { + 0x00, /* 00 IRQ status */ + 0x00, /* 01 MIC status */ + 0x00, /* 02 jack status */ + 0x00, /* 03 battery voltage */ + 0x00, /* 04 */ + 0x00, /* 05 */ + 0x00, /* 06 */ + 0x00, /* 07 */ + 0x00, /* 08 */ + 0x00, /* 09 */ + 0x00, /* 0A */ + 0x00, /* 0B */ + 0x00, /* 0C */ + 0x00, /* 0D */ + 0x00, /* 0E */ + 0x00, /* 0F interrupt enable */ + + 0x00, /* 10 master clock */ + 0x00, /* 11 DAI1 clock mode */ + 0x00, /* 12 DAI1 clock control */ + 0x00, /* 13 DAI1 clock control */ + 0x00, /* 14 DAI1 format */ + 0x00, /* 15 DAI1 clock */ + 0x00, /* 16 DAI1 config */ + 0x00, /* 17 DAI1 TDM */ + 0x00, /* 18 DAI1 filters */ + 0x00, /* 19 DAI2 clock mode */ + 0x00, /* 1A DAI2 clock control */ + 0x00, /* 1B DAI2 clock control */ + 0x00, /* 1C DAI2 format */ + 0x00, /* 1D DAI2 clock */ + 0x00, /* 1E DAI2 config */ + 0x00, /* 1F DAI2 TDM */ + + 0x00, /* 20 DAI2 filters */ + 0x00, /* 21 data config */ + 0x00, /* 22 DAC mixer */ + 0x00, /* 23 left ADC mixer */ + 0x00, /* 24 right ADC mixer */ + 0x00, /* 25 left HP mixer */ + 0x00, /* 26 right HP mixer */ + 0x00, /* 27 HP control */ + 0x00, /* 28 left REC mixer */ + 0x00, /* 29 right REC mixer */ + 0x00, /* 2A REC control */ + 0x00, /* 2B left SPK mixer */ + 0x00, /* 2C right SPK mixer */ + 0x00, /* 2D SPK control */ + 0x00, /* 2E sidetone */ + 0x00, /* 2F DAI1 playback level */ + + 0x00, /* 30 DAI1 playback level */ + 0x00, /* 31 DAI2 playback level */ + 0x00, /* 32 DAI2 playbakc level */ + 0x00, /* 33 left ADC level */ + 0x00, /* 34 right ADC level */ + 0x00, /* 35 MIC1 level */ + 0x00, /* 36 MIC2 level */ + 0x00, /* 37 INA level */ + 0x00, /* 38 INB level */ + 0x00, /* 39 left HP volume */ + 0x00, /* 3A right HP volume */ + 0x00, /* 3B left REC volume */ + 0x00, /* 3C right REC volume */ + 0x00, /* 3D left SPK volume */ + 0x00, /* 3E right SPK volume */ + 0x00, /* 3F MIC config */ + + 0x00, /* 40 MIC threshold */ + 0x00, /* 41 excursion limiter filter */ + 0x00, /* 42 excursion limiter threshold */ + 0x00, /* 43 ALC */ + 0x00, /* 44 power limiter threshold */ + 0x00, /* 45 power limiter config */ + 0x00, /* 46 distortion limiter config */ + 0x00, /* 47 audio input */ + 0x00, /* 48 microphone */ + 0x00, /* 49 level control */ + 0x00, /* 4A bypass switches */ + 0x00, /* 4B jack detect */ + 0x00, /* 4C input enable */ + 0x00, /* 4D output enable */ + 0xF0, /* 4E bias control */ + 0x00, /* 4F DAC power */ + + 0x0F, /* 50 DAC power */ + 0x00, /* 51 system */ + 0x00, /* 52 DAI1 EQ1 */ + 0x00, /* 53 DAI1 EQ1 */ + 0x00, /* 54 DAI1 EQ1 */ + 0x00, /* 55 DAI1 EQ1 */ + 0x00, /* 56 DAI1 EQ1 */ + 0x00, /* 57 DAI1 EQ1 */ + 0x00, /* 58 DAI1 EQ1 */ + 0x00, /* 59 DAI1 EQ1 */ + 0x00, /* 5A DAI1 EQ1 */ + 0x00, /* 5B DAI1 EQ1 */ + 0x00, /* 5C DAI1 EQ2 */ + 0x00, /* 5D DAI1 EQ2 */ + 0x00, /* 5E DAI1 EQ2 */ + 0x00, /* 5F DAI1 EQ2 */ + + 0x00, /* 60 DAI1 EQ2 */ + 0x00, /* 61 DAI1 EQ2 */ + 0x00, /* 62 DAI1 EQ2 */ + 0x00, /* 63 DAI1 EQ2 */ + 0x00, /* 64 DAI1 EQ2 */ + 0x00, /* 65 DAI1 EQ2 */ + 0x00, /* 66 DAI1 EQ3 */ + 0x00, /* 67 DAI1 EQ3 */ + 0x00, /* 68 DAI1 EQ3 */ + 0x00, /* 69 DAI1 EQ3 */ + 0x00, /* 6A DAI1 EQ3 */ + 0x00, /* 6B DAI1 EQ3 */ + 0x00, /* 6C DAI1 EQ3 */ + 0x00, /* 6D DAI1 EQ3 */ + 0x00, /* 6E DAI1 EQ3 */ + 0x00, /* 6F DAI1 EQ3 */ + + 0x00, /* 70 DAI1 EQ4 */ + 0x00, /* 71 DAI1 EQ4 */ + 0x00, /* 72 DAI1 EQ4 */ + 0x00, /* 73 DAI1 EQ4 */ + 0x00, /* 74 DAI1 EQ4 */ + 0x00, /* 75 DAI1 EQ4 */ + 0x00, /* 76 DAI1 EQ4 */ + 0x00, /* 77 DAI1 EQ4 */ + 0x00, /* 78 DAI1 EQ4 */ + 0x00, /* 79 DAI1 EQ4 */ + 0x00, /* 7A DAI1 EQ5 */ + 0x00, /* 7B DAI1 EQ5 */ + 0x00, /* 7C DAI1 EQ5 */ + 0x00, /* 7D DAI1 EQ5 */ + 0x00, /* 7E DAI1 EQ5 */ + 0x00, /* 7F DAI1 EQ5 */ + + 0x00, /* 80 DAI1 EQ5 */ + 0x00, /* 81 DAI1 EQ5 */ + 0x00, /* 82 DAI1 EQ5 */ + 0x00, /* 83 DAI1 EQ5 */ + 0x00, /* 84 DAI2 EQ1 */ + 0x00, /* 85 DAI2 EQ1 */ + 0x00, /* 86 DAI2 EQ1 */ + 0x00, /* 87 DAI2 EQ1 */ + 0x00, /* 88 DAI2 EQ1 */ + 0x00, /* 89 DAI2 EQ1 */ + 0x00, /* 8A DAI2 EQ1 */ + 0x00, /* 8B DAI2 EQ1 */ + 0x00, /* 8C DAI2 EQ1 */ + 0x00, /* 8D DAI2 EQ1 */ + 0x00, /* 8E DAI2 EQ2 */ + 0x00, /* 8F DAI2 EQ2 */ + + 0x00, /* 90 DAI2 EQ2 */ + 0x00, /* 91 DAI2 EQ2 */ + 0x00, /* 92 DAI2 EQ2 */ + 0x00, /* 93 DAI2 EQ2 */ + 0x00, /* 94 DAI2 EQ2 */ + 0x00, /* 95 DAI2 EQ2 */ + 0x00, /* 96 DAI2 EQ2 */ + 0x00, /* 97 DAI2 EQ2 */ + 0x00, /* 98 DAI2 EQ3 */ + 0x00, /* 99 DAI2 EQ3 */ + 0x00, /* 9A DAI2 EQ3 */ + 0x00, /* 9B DAI2 EQ3 */ + 0x00, /* 9C DAI2 EQ3 */ + 0x00, /* 9D DAI2 EQ3 */ + 0x00, /* 9E DAI2 EQ3 */ + 0x00, /* 9F DAI2 EQ3 */ + + 0x00, /* A0 DAI2 EQ3 */ + 0x00, /* A1 DAI2 EQ3 */ + 0x00, /* A2 DAI2 EQ4 */ + 0x00, /* A3 DAI2 EQ4 */ + 0x00, /* A4 DAI2 EQ4 */ + 0x00, /* A5 DAI2 EQ4 */ + 0x00, /* A6 DAI2 EQ4 */ + 0x00, /* A7 DAI2 EQ4 */ + 0x00, /* A8 DAI2 EQ4 */ + 0x00, /* A9 DAI2 EQ4 */ + 0x00, /* AA DAI2 EQ4 */ + 0x00, /* AB DAI2 EQ4 */ + 0x00, /* AC DAI2 EQ5 */ + 0x00, /* AD DAI2 EQ5 */ + 0x00, /* AE DAI2 EQ5 */ + 0x00, /* AF DAI2 EQ5 */ + + 0x00, /* B0 DAI2 EQ5 */ + 0x00, /* B1 DAI2 EQ5 */ + 0x00, /* B2 DAI2 EQ5 */ + 0x00, /* B3 DAI2 EQ5 */ + 0x00, /* B4 DAI2 EQ5 */ + 0x00, /* B5 DAI2 EQ5 */ + 0x00, /* B6 DAI1 biquad */ + 0x00, /* B7 DAI1 biquad */ + 0x00, /* B8 DAI1 biquad */ + 0x00, /* B9 DAI1 biquad */ + 0x00, /* BA DAI1 biquad */ + 0x00, /* BB DAI1 biquad */ + 0x00, /* BC DAI1 biquad */ + 0x00, /* BD DAI1 biquad */ + 0x00, /* BE DAI1 biquad */ + 0x00, /* BF DAI1 biquad */ + + 0x00, /* C0 DAI2 biquad */ + 0x00, /* C1 DAI2 biquad */ + 0x00, /* C2 DAI2 biquad */ + 0x00, /* C3 DAI2 biquad */ + 0x00, /* C4 DAI2 biquad */ + 0x00, /* C5 DAI2 biquad */ + 0x00, /* C6 DAI2 biquad */ + 0x00, /* C7 DAI2 biquad */ + 0x00, /* C8 DAI2 biquad */ + 0x00, /* C9 DAI2 biquad */ + 0x00, /* CA */ + 0x00, /* CB */ + 0x00, /* CC */ + 0x00, /* CD */ + 0x00, /* CE */ + 0x00, /* CF */ + + 0x00, /* D0 */ + 0x00, /* D1 */ + 0x00, /* D2 */ + 0x00, /* D3 */ + 0x00, /* D4 */ + 0x00, /* D5 */ + 0x00, /* D6 */ + 0x00, /* D7 */ + 0x00, /* D8 */ + 0x00, /* D9 */ + 0x00, /* DA */ + 0x70, /* DB */ + 0x00, /* DC */ + 0x00, /* DD */ + 0x00, /* DE */ + 0x00, /* DF */ + + 0x00, /* E0 */ + 0x00, /* E1 */ + 0x00, /* E2 */ + 0x00, /* E3 */ + 0x00, /* E4 */ + 0x00, /* E5 */ + 0x00, /* E6 */ + 0x00, /* E7 */ + 0x00, /* E8 */ + 0x00, /* E9 */ + 0x00, /* EA */ + 0x00, /* EB */ + 0x00, /* EC */ + 0x00, /* ED */ + 0x00, /* EE */ + 0x00, /* EF */ + + 0x00, /* F0 */ + 0x00, /* F1 */ + 0x00, /* F2 */ + 0x00, /* F3 */ + 0x00, /* F4 */ + 0x00, /* F5 */ + 0x00, /* F6 */ + 0x00, /* F7 */ + 0x00, /* F8 */ + 0x00, /* F9 */ + 0x00, /* FA */ + 0x00, /* FB */ + 0x00, /* FC */ + 0x00, /* FD */ + 0x00, /* FE */ + 0x00, /* FF */ }; static struct { @@ -536,28 +606,11 @@ static struct { { 0xFF, 0x00, 1 }, /* FF */ }; -static bool max98088_readable_register(struct device *dev, unsigned int reg) -{ - return max98088_access[reg].readable; -} - -static bool max98088_volatile_register(struct device *dev, unsigned int reg) +static int max98088_volatile_register(struct snd_soc_codec *codec, unsigned int reg) { return max98088_access[reg].vol; } -static const struct regmap_config max98088_regmap = { - .reg_bits = 8, - .val_bits = 8, - - .readable_reg = max98088_readable_register, - .volatile_reg = max98088_volatile_register, - .max_register = 0xff, - - .reg_defaults = max98088_reg, - .num_reg_defaults = ARRAY_SIZE(max98088_reg), - .cache_type = REGCACHE_RBTREE, -}; /* * Load equalizer DSP coefficient configurations registers @@ -568,9 +621,8 @@ static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, unsigned int eq_reg; unsigned int i; - if (WARN_ON(band > 4) || - WARN_ON(dai > 1)) - return; + BUG_ON(band > 4); + BUG_ON(dai > 1); /* Load the base register address */ eq_reg = dai ? M98088_REG_84_DAI2_EQ_BASE : M98088_REG_52_DAI1_EQ_BASE; @@ -910,8 +962,7 @@ static int max98088_line_pga(struct snd_soc_dapm_widget *w, struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); u8 *state; - if (WARN_ON(!(channel == 1 || channel == 2))) - return -EINVAL; + BUG_ON(!((channel == 1) || (channel == 2))); switch (line) { case LINE_INA: @@ -1559,34 +1610,58 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute) return 0; } +static void max98088_sync_cache(struct snd_soc_codec *codec) +{ + u8 *reg_cache = codec->reg_cache; + int i; + + if (!codec->cache_sync) + return; + + codec->cache_only = 0; + + /* write back cached values if they're writeable and + * different from the hardware default. + */ + for (i = 1; i < codec->driver->reg_cache_size; i++) { + if (!max98088_access[i].writable) + continue; + + if (reg_cache[i] == max98088_reg[i]) + continue; + + snd_soc_write(codec, i, reg_cache[i]); + } + + codec->cache_sync = 0; +} + static int max98088_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); - - switch (level) { - case SND_SOC_BIAS_ON: - break; - - case SND_SOC_BIAS_PREPARE: - break; - - case SND_SOC_BIAS_STANDBY: - if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) - regcache_sync(max98088->regmap); - - snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, - M98088_MBEN, M98088_MBEN); - break; - - case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, - M98088_MBEN, 0); - regcache_mark_dirty(max98088->regmap); - break; - } - codec->dapm.bias_level = level; - return 0; + switch (level) { + case SND_SOC_BIAS_ON: + break; + + case SND_SOC_BIAS_PREPARE: + break; + + case SND_SOC_BIAS_STANDBY: + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) + max98088_sync_cache(codec); + + snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, + M98088_MBEN, M98088_MBEN); + break; + + case SND_SOC_BIAS_OFF: + snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, + M98088_MBEN, 0); + codec->cache_sync = 1; + break; + } + codec->dapm.bias_level = level; + return 0; } #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000 @@ -1913,9 +1988,9 @@ static int max98088_probe(struct snd_soc_codec *codec) struct max98088_cdata *cdata; int ret = 0; - regcache_mark_dirty(max98088->regmap); + codec->cache_sync = 1; - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; @@ -1973,6 +2048,9 @@ static int max98088_probe(struct snd_soc_codec *codec) max98088_handle_pdata(codec); + snd_soc_add_codec_controls(codec, max98088_snd_controls, + ARRAY_SIZE(max98088_snd_controls)); + err_access: return ret; } @@ -1988,13 +2066,15 @@ static int max98088_remove(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_dev_max98088 = { - .probe = max98088_probe, - .remove = max98088_remove, - .suspend = max98088_suspend, - .resume = max98088_resume, - .set_bias_level = max98088_set_bias_level, - .controls = max98088_snd_controls, - .num_controls = ARRAY_SIZE(max98088_snd_controls), + .probe = max98088_probe, + .remove = max98088_remove, + .suspend = max98088_suspend, + .resume = max98088_resume, + .set_bias_level = max98088_set_bias_level, + .reg_cache_size = ARRAY_SIZE(max98088_reg), + .reg_word_size = sizeof(u8), + .reg_cache_default = max98088_reg, + .volatile_register = max98088_volatile_register, .dapm_widgets = max98088_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets), .dapm_routes = max98088_audio_map, @@ -2002,7 +2082,7 @@ static struct snd_soc_codec_driver soc_codec_dev_max98088 = { }; static int max98088_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct max98088_priv *max98088; int ret; @@ -2012,10 +2092,6 @@ static int max98088_i2c_probe(struct i2c_client *i2c, if (max98088 == NULL) return -ENOMEM; - max98088->regmap = devm_regmap_init_i2c(i2c, &max98088_regmap); - if (IS_ERR(max98088->regmap)) - return PTR_ERR(max98088->regmap); - max98088->devtype = id->driver_data; i2c_set_clientdata(i2c, max98088); diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 6724431..8dbcacd 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -39,7 +39,6 @@ struct max98095_cdata { }; struct max98095_priv { - struct regmap *regmap; enum max98095_type devtype; struct max98095_pdata *pdata; unsigned int sysclk; @@ -57,145 +56,263 @@ struct max98095_priv { struct snd_soc_jack *mic_jack; }; -static const struct reg_default max98095_reg_def[] = { - { 0xf, 0x00 }, /* 0F */ - { 0x10, 0x00 }, /* 10 */ - { 0x11, 0x00 }, /* 11 */ - { 0x12, 0x00 }, /* 12 */ - { 0x13, 0x00 }, /* 13 */ - { 0x14, 0x00 }, /* 14 */ - { 0x15, 0x00 }, /* 15 */ - { 0x16, 0x00 }, /* 16 */ - { 0x17, 0x00 }, /* 17 */ - { 0x18, 0x00 }, /* 18 */ - { 0x19, 0x00 }, /* 19 */ - { 0x1a, 0x00 }, /* 1A */ - { 0x1b, 0x00 }, /* 1B */ - { 0x1c, 0x00 }, /* 1C */ - { 0x1d, 0x00 }, /* 1D */ - { 0x1e, 0x00 }, /* 1E */ - { 0x1f, 0x00 }, /* 1F */ - { 0x20, 0x00 }, /* 20 */ - { 0x21, 0x00 }, /* 21 */ - { 0x22, 0x00 }, /* 22 */ - { 0x23, 0x00 }, /* 23 */ - { 0x24, 0x00 }, /* 24 */ - { 0x25, 0x00 }, /* 25 */ - { 0x26, 0x00 }, /* 26 */ - { 0x27, 0x00 }, /* 27 */ - { 0x28, 0x00 }, /* 28 */ - { 0x29, 0x00 }, /* 29 */ - { 0x2a, 0x00 }, /* 2A */ - { 0x2b, 0x00 }, /* 2B */ - { 0x2c, 0x00 }, /* 2C */ - { 0x2d, 0x00 }, /* 2D */ - { 0x2e, 0x00 }, /* 2E */ - { 0x2f, 0x00 }, /* 2F */ - { 0x30, 0x00 }, /* 30 */ - { 0x31, 0x00 }, /* 31 */ - { 0x32, 0x00 }, /* 32 */ - { 0x33, 0x00 }, /* 33 */ - { 0x34, 0x00 }, /* 34 */ - { 0x35, 0x00 }, /* 35 */ - { 0x36, 0x00 }, /* 36 */ - { 0x37, 0x00 }, /* 37 */ - { 0x38, 0x00 }, /* 38 */ - { 0x39, 0x00 }, /* 39 */ - { 0x3a, 0x00 }, /* 3A */ - { 0x3b, 0x00 }, /* 3B */ - { 0x3c, 0x00 }, /* 3C */ - { 0x3d, 0x00 }, /* 3D */ - { 0x3e, 0x00 }, /* 3E */ - { 0x3f, 0x00 }, /* 3F */ - { 0x40, 0x00 }, /* 40 */ - { 0x41, 0x00 }, /* 41 */ - { 0x42, 0x00 }, /* 42 */ - { 0x43, 0x00 }, /* 43 */ - { 0x44, 0x00 }, /* 44 */ - { 0x45, 0x00 }, /* 45 */ - { 0x46, 0x00 }, /* 46 */ - { 0x47, 0x00 }, /* 47 */ - { 0x48, 0x00 }, /* 48 */ - { 0x49, 0x00 }, /* 49 */ - { 0x4a, 0x00 }, /* 4A */ - { 0x4b, 0x00 }, /* 4B */ - { 0x4c, 0x00 }, /* 4C */ - { 0x4d, 0x00 }, /* 4D */ - { 0x4e, 0x00 }, /* 4E */ - { 0x4f, 0x00 }, /* 4F */ - { 0x50, 0x00 }, /* 50 */ - { 0x51, 0x00 }, /* 51 */ - { 0x52, 0x00 }, /* 52 */ - { 0x53, 0x00 }, /* 53 */ - { 0x54, 0x00 }, /* 54 */ - { 0x55, 0x00 }, /* 55 */ - { 0x56, 0x00 }, /* 56 */ - { 0x57, 0x00 }, /* 57 */ - { 0x58, 0x00 }, /* 58 */ - { 0x59, 0x00 }, /* 59 */ - { 0x5a, 0x00 }, /* 5A */ - { 0x5b, 0x00 }, /* 5B */ - { 0x5c, 0x00 }, /* 5C */ - { 0x5d, 0x00 }, /* 5D */ - { 0x5e, 0x00 }, /* 5E */ - { 0x5f, 0x00 }, /* 5F */ - { 0x60, 0x00 }, /* 60 */ - { 0x61, 0x00 }, /* 61 */ - { 0x62, 0x00 }, /* 62 */ - { 0x63, 0x00 }, /* 63 */ - { 0x64, 0x00 }, /* 64 */ - { 0x65, 0x00 }, /* 65 */ - { 0x66, 0x00 }, /* 66 */ - { 0x67, 0x00 }, /* 67 */ - { 0x68, 0x00 }, /* 68 */ - { 0x69, 0x00 }, /* 69 */ - { 0x6a, 0x00 }, /* 6A */ - { 0x6b, 0x00 }, /* 6B */ - { 0x6c, 0x00 }, /* 6C */ - { 0x6d, 0x00 }, /* 6D */ - { 0x6e, 0x00 }, /* 6E */ - { 0x6f, 0x00 }, /* 6F */ - { 0x70, 0x00 }, /* 70 */ - { 0x71, 0x00 }, /* 71 */ - { 0x72, 0x00 }, /* 72 */ - { 0x73, 0x00 }, /* 73 */ - { 0x74, 0x00 }, /* 74 */ - { 0x75, 0x00 }, /* 75 */ - { 0x76, 0x00 }, /* 76 */ - { 0x77, 0x00 }, /* 77 */ - { 0x78, 0x00 }, /* 78 */ - { 0x79, 0x00 }, /* 79 */ - { 0x7a, 0x00 }, /* 7A */ - { 0x7b, 0x00 }, /* 7B */ - { 0x7c, 0x00 }, /* 7C */ - { 0x7d, 0x00 }, /* 7D */ - { 0x7e, 0x00 }, /* 7E */ - { 0x7f, 0x00 }, /* 7F */ - { 0x80, 0x00 }, /* 80 */ - { 0x81, 0x00 }, /* 81 */ - { 0x82, 0x00 }, /* 82 */ - { 0x83, 0x00 }, /* 83 */ - { 0x84, 0x00 }, /* 84 */ - { 0x85, 0x00 }, /* 85 */ - { 0x86, 0x00 }, /* 86 */ - { 0x87, 0x00 }, /* 87 */ - { 0x88, 0x00 }, /* 88 */ - { 0x89, 0x00 }, /* 89 */ - { 0x8a, 0x00 }, /* 8A */ - { 0x8b, 0x00 }, /* 8B */ - { 0x8c, 0x00 }, /* 8C */ - { 0x8d, 0x00 }, /* 8D */ - { 0x8e, 0x00 }, /* 8E */ - { 0x8f, 0x00 }, /* 8F */ - { 0x90, 0x00 }, /* 90 */ - { 0x91, 0x00 }, /* 91 */ - { 0x92, 0x30 }, /* 92 */ - { 0x93, 0xF0 }, /* 93 */ - { 0x94, 0x00 }, /* 94 */ - { 0x95, 0x00 }, /* 95 */ - { 0x96, 0x3F }, /* 96 */ - { 0x97, 0x00 }, /* 97 */ - { 0xff, 0x00 }, /* FF */ +static const u8 max98095_reg_def[M98095_REG_CNT] = { + 0x00, /* 00 */ + 0x00, /* 01 */ + 0x00, /* 02 */ + 0x00, /* 03 */ + 0x00, /* 04 */ + 0x00, /* 05 */ + 0x00, /* 06 */ + 0x00, /* 07 */ + 0x00, /* 08 */ + 0x00, /* 09 */ + 0x00, /* 0A */ + 0x00, /* 0B */ + 0x00, /* 0C */ + 0x00, /* 0D */ + 0x00, /* 0E */ + 0x00, /* 0F */ + 0x00, /* 10 */ + 0x00, /* 11 */ + 0x00, /* 12 */ + 0x00, /* 13 */ + 0x00, /* 14 */ + 0x00, /* 15 */ + 0x00, /* 16 */ + 0x00, /* 17 */ + 0x00, /* 18 */ + 0x00, /* 19 */ + 0x00, /* 1A */ + 0x00, /* 1B */ + 0x00, /* 1C */ + 0x00, /* 1D */ + 0x00, /* 1E */ + 0x00, /* 1F */ + 0x00, /* 20 */ + 0x00, /* 21 */ + 0x00, /* 22 */ + 0x00, /* 23 */ + 0x00, /* 24 */ + 0x00, /* 25 */ + 0x00, /* 26 */ + 0x00, /* 27 */ + 0x00, /* 28 */ + 0x00, /* 29 */ + 0x00, /* 2A */ + 0x00, /* 2B */ + 0x00, /* 2C */ + 0x00, /* 2D */ + 0x00, /* 2E */ + 0x00, /* 2F */ + 0x00, /* 30 */ + 0x00, /* 31 */ + 0x00, /* 32 */ + 0x00, /* 33 */ + 0x00, /* 34 */ + 0x00, /* 35 */ + 0x00, /* 36 */ + 0x00, /* 37 */ + 0x00, /* 38 */ + 0x00, /* 39 */ + 0x00, /* 3A */ + 0x00, /* 3B */ + 0x00, /* 3C */ + 0x00, /* 3D */ + 0x00, /* 3E */ + 0x00, /* 3F */ + 0x00, /* 40 */ + 0x00, /* 41 */ + 0x00, /* 42 */ + 0x00, /* 43 */ + 0x00, /* 44 */ + 0x00, /* 45 */ + 0x00, /* 46 */ + 0x00, /* 47 */ + 0x00, /* 48 */ + 0x00, /* 49 */ + 0x00, /* 4A */ + 0x00, /* 4B */ + 0x00, /* 4C */ + 0x00, /* 4D */ + 0x00, /* 4E */ + 0x00, /* 4F */ + 0x00, /* 50 */ + 0x00, /* 51 */ + 0x00, /* 52 */ + 0x00, /* 53 */ + 0x00, /* 54 */ + 0x00, /* 55 */ + 0x00, /* 56 */ + 0x00, /* 57 */ + 0x00, /* 58 */ + 0x00, /* 59 */ + 0x00, /* 5A */ + 0x00, /* 5B */ + 0x00, /* 5C */ + 0x00, /* 5D */ + 0x00, /* 5E */ + 0x00, /* 5F */ + 0x00, /* 60 */ + 0x00, /* 61 */ + 0x00, /* 62 */ + 0x00, /* 63 */ + 0x00, /* 64 */ + 0x00, /* 65 */ + 0x00, /* 66 */ + 0x00, /* 67 */ + 0x00, /* 68 */ + 0x00, /* 69 */ + 0x00, /* 6A */ + 0x00, /* 6B */ + 0x00, /* 6C */ + 0x00, /* 6D */ + 0x00, /* 6E */ + 0x00, /* 6F */ + 0x00, /* 70 */ + 0x00, /* 71 */ + 0x00, /* 72 */ + 0x00, /* 73 */ + 0x00, /* 74 */ + 0x00, /* 75 */ + 0x00, /* 76 */ + 0x00, /* 77 */ + 0x00, /* 78 */ + 0x00, /* 79 */ + 0x00, /* 7A */ + 0x00, /* 7B */ + 0x00, /* 7C */ + 0x00, /* 7D */ + 0x00, /* 7E */ + 0x00, /* 7F */ + 0x00, /* 80 */ + 0x00, /* 81 */ + 0x00, /* 82 */ + 0x00, /* 83 */ + 0x00, /* 84 */ + 0x00, /* 85 */ + 0x00, /* 86 */ + 0x00, /* 87 */ + 0x00, /* 88 */ + 0x00, /* 89 */ + 0x00, /* 8A */ + 0x00, /* 8B */ + 0x00, /* 8C */ + 0x00, /* 8D */ + 0x00, /* 8E */ + 0x00, /* 8F */ + 0x00, /* 90 */ + 0x00, /* 91 */ + 0x30, /* 92 */ + 0xF0, /* 93 */ + 0x00, /* 94 */ + 0x00, /* 95 */ + 0x3F, /* 96 */ + 0x00, /* 97 */ + 0x00, /* 98 */ + 0x00, /* 99 */ + 0x00, /* 9A */ + 0x00, /* 9B */ + 0x00, /* 9C */ + 0x00, /* 9D */ + 0x00, /* 9E */ + 0x00, /* 9F */ + 0x00, /* A0 */ + 0x00, /* A1 */ + 0x00, /* A2 */ + 0x00, /* A3 */ + 0x00, /* A4 */ + 0x00, /* A5 */ + 0x00, /* A6 */ + 0x00, /* A7 */ + 0x00, /* A8 */ + 0x00, /* A9 */ + 0x00, /* AA */ + 0x00, /* AB */ + 0x00, /* AC */ + 0x00, /* AD */ + 0x00, /* AE */ + 0x00, /* AF */ + 0x00, /* B0 */ + 0x00, /* B1 */ + 0x00, /* B2 */ + 0x00, /* B3 */ + 0x00, /* B4 */ + 0x00, /* B5 */ + 0x00, /* B6 */ + 0x00, /* B7 */ + 0x00, /* B8 */ + 0x00, /* B9 */ + 0x00, /* BA */ + 0x00, /* BB */ + 0x00, /* BC */ + 0x00, /* BD */ + 0x00, /* BE */ + 0x00, /* BF */ + 0x00, /* C0 */ + 0x00, /* C1 */ + 0x00, /* C2 */ + 0x00, /* C3 */ + 0x00, /* C4 */ + 0x00, /* C5 */ + 0x00, /* C6 */ + 0x00, /* C7 */ + 0x00, /* C8 */ + 0x00, /* C9 */ + 0x00, /* CA */ + 0x00, /* CB */ + 0x00, /* CC */ + 0x00, /* CD */ + 0x00, /* CE */ + 0x00, /* CF */ + 0x00, /* D0 */ + 0x00, /* D1 */ + 0x00, /* D2 */ + 0x00, /* D3 */ + 0x00, /* D4 */ + 0x00, /* D5 */ + 0x00, /* D6 */ + 0x00, /* D7 */ + 0x00, /* D8 */ + 0x00, /* D9 */ + 0x00, /* DA */ + 0x00, /* DB */ + 0x00, /* DC */ + 0x00, /* DD */ + 0x00, /* DE */ + 0x00, /* DF */ + 0x00, /* E0 */ + 0x00, /* E1 */ + 0x00, /* E2 */ + 0x00, /* E3 */ + 0x00, /* E4 */ + 0x00, /* E5 */ + 0x00, /* E6 */ + 0x00, /* E7 */ + 0x00, /* E8 */ + 0x00, /* E9 */ + 0x00, /* EA */ + 0x00, /* EB */ + 0x00, /* EC */ + 0x00, /* ED */ + 0x00, /* EE */ + 0x00, /* EF */ + 0x00, /* F0 */ + 0x00, /* F1 */ + 0x00, /* F2 */ + 0x00, /* F3 */ + 0x00, /* F4 */ + 0x00, /* F5 */ + 0x00, /* F6 */ + 0x00, /* F7 */ + 0x00, /* F8 */ + 0x00, /* F9 */ + 0x00, /* FA */ + 0x00, /* FB */ + 0x00, /* FC */ + 0x00, /* FD */ + 0x00, /* FE */ + 0x00, /* FF */ }; static struct { @@ -460,14 +577,14 @@ static struct { { 0xFF, 0x00 }, /* FF */ }; -static bool max98095_readable(struct device *dev, unsigned int reg) +static int max98095_readable(struct snd_soc_codec *codec, unsigned int reg) { if (reg >= M98095_REG_CNT) return 0; return max98095_access[reg].readable != 0; } -static bool max98095_volatile(struct device *dev, unsigned int reg) +static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg) { if (reg > M98095_REG_MAX_CACHED) return 1; @@ -494,18 +611,22 @@ static bool max98095_volatile(struct device *dev, unsigned int reg) return 0; } -static const struct regmap_config max98095_regmap = { - .reg_bits = 8, - .val_bits = 8, +/* + * Filter coefficients are in a separate register segment + * and they share the address space of the normal registers. + * The coefficient registers do not need or share the cache. + */ +static int max98095_hw_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + int ret; - .reg_defaults = max98095_reg_def, - .num_reg_defaults = ARRAY_SIZE(max98095_reg_def), - .max_register = M98095_0FF_REV_ID, - .cache_type = REGCACHE_RBTREE, + codec->cache_bypass = 1; + ret = snd_soc_write(codec, reg, value); + codec->cache_bypass = 0; - .readable_reg = max98095_readable, - .volatile_reg = max98095_volatile, -}; + return ret ? -EIO : 0; +} /* * Load equalizer DSP coefficient configurations registers @@ -516,9 +637,8 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, unsigned int eq_reg; unsigned int i; - if (WARN_ON(band > 4) || - WARN_ON(dai > 1)) - return; + BUG_ON(band > 4); + BUG_ON(dai > 1); /* Load the base register address */ eq_reg = dai ? M98095_142_DAI2_EQ_BASE : M98095_110_DAI1_EQ_BASE; @@ -528,8 +648,8 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, /* Step through the registers and coefs */ for (i = 0; i < M98095_COEFS_PER_BAND; i++) { - snd_soc_write(codec, eq_reg++, M98095_BYTE1(coefs[i])); - snd_soc_write(codec, eq_reg++, M98095_BYTE0(coefs[i])); + max98095_hw_write(codec, eq_reg++, M98095_BYTE1(coefs[i])); + max98095_hw_write(codec, eq_reg++, M98095_BYTE0(coefs[i])); } } @@ -542,9 +662,8 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, unsigned int bq_reg; unsigned int i; - if (WARN_ON(band > 1) || - WARN_ON(dai > 1)) - return; + BUG_ON(band > 1); + BUG_ON(dai > 1); /* Load the base register address */ bq_reg = dai ? M98095_17E_DAI2_BQ_BASE : M98095_174_DAI1_BQ_BASE; @@ -554,8 +673,8 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, /* Step through the registers and coefs */ for (i = 0; i < M98095_COEFS_PER_BAND; i++) { - snd_soc_write(codec, bq_reg++, M98095_BYTE1(coefs[i])); - snd_soc_write(codec, bq_reg++, M98095_BYTE0(coefs[i])); + max98095_hw_write(codec, bq_reg++, M98095_BYTE1(coefs[i])); + max98095_hw_write(codec, bq_reg++, M98095_BYTE0(coefs[i])); } } @@ -892,8 +1011,7 @@ static int max98095_line_pga(struct snd_soc_dapm_widget *w, struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); u8 *state; - if (WARN_ON(!(channel == 1 || channel == 2))) - return -EINVAL; + BUG_ON(!((channel == 1) || (channel == 2))); state = &max98095->lin_state; @@ -1167,6 +1285,14 @@ static const struct snd_soc_dapm_route max98095_audio_map[] = { {"MIC2 Input", NULL, "MIC2"}, }; +static int max98095_add_widgets(struct snd_soc_codec *codec) +{ + snd_soc_add_codec_controls(codec, max98095_snd_controls, + ARRAY_SIZE(max98095_snd_controls)); + + return 0; +} + /* codec mclk clock divider coefficients */ static const struct { u32 rate; @@ -1622,7 +1748,6 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, static int max98095_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); int ret; switch (level) { @@ -1634,7 +1759,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_STANDBY: if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { - ret = regcache_sync(max98095->regmap); + ret = snd_soc_cache_sync(codec); if (ret != 0) { dev_err(codec->dev, "Failed to sync cache: %d\n", ret); @@ -1649,7 +1774,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_OFF: snd_soc_update_bits(codec, M98095_090_PWR_EN_IN, M98095_MBEN, 0); - regcache_mark_dirty(max98095->regmap); + codec->cache_sync = 1; break; } codec->dapm.bias_level = level; @@ -1743,8 +1868,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, int fs, best, best_val, i; int regmask, regsave; - if (WARN_ON(channel > 1)) - return -EINVAL; + BUG_ON(channel > 1); if (!pdata || !max98095->eq_textcnt) return 0; @@ -2217,7 +2341,7 @@ static int max98095_reset(struct snd_soc_codec *codec) /* Reset to hardware default for registers, as there is not * a soft reset hardware control register */ for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) { - ret = snd_soc_write(codec, i, snd_soc_read(codec, i)); + ret = snd_soc_write(codec, i, max98095_reg_def[i]); if (ret < 0) { dev_err(codec->dev, "Failed to reset: %d\n", ret); return ret; @@ -2234,7 +2358,7 @@ static int max98095_probe(struct snd_soc_codec *codec) struct i2c_client *client; int ret = 0; - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; @@ -2323,6 +2447,8 @@ static int max98095_probe(struct snd_soc_codec *codec) snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_SHDNRUN, M98095_SHDNRUN); + max98095_add_widgets(codec); + return 0; err_irq: @@ -2354,8 +2480,11 @@ static struct snd_soc_codec_driver soc_codec_dev_max98095 = { .suspend = max98095_suspend, .resume = max98095_resume, .set_bias_level = max98095_set_bias_level, - .controls = max98095_snd_controls, - .num_controls = ARRAY_SIZE(max98095_snd_controls), + .reg_cache_size = ARRAY_SIZE(max98095_reg_def), + .reg_word_size = sizeof(u8), + .reg_cache_default = max98095_reg_def, + .readable_register = max98095_readable, + .volatile_register = max98095_volatile, .dapm_widgets = max98095_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets), .dapm_routes = max98095_audio_map, @@ -2373,13 +2502,6 @@ static int max98095_i2c_probe(struct i2c_client *i2c, if (max98095 == NULL) return -ENOMEM; - max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap); - if (IS_ERR(max98095->regmap)) { - ret = PTR_ERR(max98095->regmap); - dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); - return ret; - } - max98095->devtype = id->driver_data; i2c_set_clientdata(i2c, max98095); max98095->pdata = i2c->dev.platform_data; diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index c5dd617..58c38a5 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -18,7 +18,6 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/i2c.h> -#include <linux/regmap.h> #include <linux/slab.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -28,26 +27,18 @@ #include "max9850.h" struct max9850_priv { - struct regmap *regmap; unsigned int sysclk; }; /* max9850 register cache */ -static const struct reg_default max9850_reg[] = { - { 2, 0x0c }, - { 3, 0x00 }, - { 4, 0x00 }, - { 5, 0x00 }, - { 6, 0x00 }, - { 7, 0x00 }, - { 8, 0x00 }, - { 9, 0x00 }, - { 10, 0x00 }, +static const u8 max9850_reg[MAX9850_CACHEREGNUM] = { + 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* these registers are not used at the moment but provided for the sake of * completeness */ -static bool max9850_volatile_register(struct device *dev, unsigned int reg) +static int max9850_volatile_register(struct snd_soc_codec *codec, + unsigned int reg) { switch (reg) { case MAX9850_STATUSA: @@ -58,15 +49,6 @@ static bool max9850_volatile_register(struct device *dev, unsigned int reg) } } -static const struct regmap_config max9850_regmap = { - .reg_bits = 8, - .val_bits = 8, - - .max_register = MAX9850_DIGITAL_AUDIO, - .volatile_reg = max9850_volatile_register, - .cache_type = REGCACHE_RBTREE, -}; - static const unsigned int max9850_tlv[] = { TLV_DB_RANGE_HEAD(4), 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), @@ -243,7 +225,6 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int max9850_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); int ret; switch (level) { @@ -253,7 +234,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { - ret = regcache_sync(max9850->regmap); + ret = snd_soc_cache_sync(codec); if (ret) { dev_err(codec->dev, "Failed to sync cache: %d\n", ret); @@ -314,7 +295,7 @@ static int max9850_probe(struct snd_soc_codec *codec) { int ret; - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); if (ret < 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; @@ -335,6 +316,10 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = { .suspend = max9850_suspend, .resume = max9850_resume, .set_bias_level = max9850_set_bias_level, + .reg_cache_size = ARRAY_SIZE(max9850_reg), + .reg_word_size = sizeof(u8), + .reg_cache_default = max9850_reg, + .volatile_register = max9850_volatile_register, .controls = max9850_controls, .num_controls = ARRAY_SIZE(max9850_controls), @@ -355,10 +340,6 @@ static int max9850_i2c_probe(struct i2c_client *i2c, if (max9850 == NULL) return -ENOMEM; - max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap); - if (IS_ERR(max9850->regmap)) - return PTR_ERR(max9850->regmap); - i2c_set_clientdata(i2c, max9850); ret = snd_soc_register_codec(&i2c->dev, diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index bae6016..ea141e1 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -30,10 +30,16 @@ #include <sound/soc.h> #include <sound/initval.h> #include <sound/soc-dapm.h> -#include <linux/regmap.h> #include "mc13783.h" +#define MC13783_AUDIO_RX0 36 +#define MC13783_AUDIO_RX1 37 +#define MC13783_AUDIO_TX 38 +#define MC13783_SSI_NETWORK 39 +#define MC13783_AUDIO_CODEC 40 +#define MC13783_AUDIO_DAC 41 + #define AUDIO_RX0_ALSPEN (1 << 5) #define AUDIO_RX0_ALSPSEL (1 << 7) #define AUDIO_RX0_ADDCDC (1 << 21) @@ -89,12 +95,45 @@ struct mc13783_priv { struct mc13xxx *mc13xxx; - struct regmap *regmap; enum mc13783_ssi_port adc_ssi_port; enum mc13783_ssi_port dac_ssi_port; }; +static unsigned int mc13783_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + unsigned int value = 0; + + mc13xxx_lock(priv->mc13xxx); + + mc13xxx_reg_read(priv->mc13xxx, reg, &value); + + mc13xxx_unlock(priv->mc13xxx); + + return value; +} + +static int mc13783_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) +{ + struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + int ret; + + mc13xxx_lock(priv->mc13xxx); + + ret = mc13xxx_reg_write(priv->mc13xxx, reg, value); + + /* include errata fix for spi audio problems */ + if (reg == MC13783_AUDIO_CODEC || reg == MC13783_AUDIO_DAC) + ret = mc13xxx_reg_write(priv->mc13xxx, reg, value); + + mc13xxx_unlock(priv->mc13xxx); + + return ret; +} + /* Mapping between sample rates and register value */ static unsigned int mc13783_rates[] = { 8000, 11025, 12000, 16000, @@ -343,7 +382,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, break; default: return -EINVAL; - } + }; snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); @@ -427,29 +466,6 @@ static const struct snd_kcontrol_new right_input_mux = static const struct snd_kcontrol_new samp_ctl = SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0); -static const char * const speaker_amp_source_text[] = { - "CODEC", "Right" -}; -static const SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4, - speaker_amp_source_text); -static const struct snd_kcontrol_new speaker_amp_source_mux = - SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source); - -static const char * const headset_amp_source_text[] = { - "CODEC", "Mixer" -}; - -static const SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11, - headset_amp_source_text); -static const struct snd_kcontrol_new headset_amp_source_mux = - SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source); - -static const struct snd_kcontrol_new cdcout_ctl = - SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 18, 1, 0); - -static const struct snd_kcontrol_new adc_bypass_ctl = - SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_CODEC, 16, 1, 0); - static const struct snd_kcontrol_new lamp_ctl = SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0); @@ -487,22 +503,12 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { SND_SOC_DAPM_VIRT_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0, &right_input_mux), - SND_SOC_DAPM_MUX("Speaker Amp Source MUX", SND_SOC_NOPM, 0, 0, - &speaker_amp_source_mux), - - SND_SOC_DAPM_MUX("Headset Amp Source MUX", SND_SOC_NOPM, 0, 0, - &headset_amp_source_mux), - SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0), SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0), - SND_SOC_DAPM_PGA("Voice CODEC PGA", MC13783_AUDIO_RX1, 0, 0, NULL, 0), - SND_SOC_DAPM_SWITCH("Voice CODEC Bypass", MC13783_AUDIO_CODEC, 16, 0, - &adc_bypass_ctl), - /* Output */ SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0), @@ -510,15 +516,10 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { SND_SOC_DAPM_OUTPUT("RXOUTR"), SND_SOC_DAPM_OUTPUT("HSL"), SND_SOC_DAPM_OUTPUT("HSR"), - SND_SOC_DAPM_OUTPUT("LSPL"), SND_SOC_DAPM_OUTPUT("LSP"), SND_SOC_DAPM_OUTPUT("SP"), - SND_SOC_DAPM_OUTPUT("CDCOUT"), - SND_SOC_DAPM_SWITCH("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 0, - &cdcout_ctl), - SND_SOC_DAPM_SWITCH("Speaker Amp Switch", MC13783_AUDIO_RX0, 3, 0, - &samp_ctl), + SND_SOC_DAPM_SWITCH("Speaker Amp", MC13783_AUDIO_RX0, 3, 0, &samp_ctl), SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl), SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0, &hlamp_ctl), @@ -553,28 +554,20 @@ static struct snd_soc_dapm_route mc13783_routes[] = { { "ADC", NULL, "PGA Right Input"}, { "ADC", NULL, "ADC_Reset"}, - { "Voice CODEC PGA", "Voice CODEC Bypass", "ADC" }, - - { "Speaker Amp Source MUX", "CODEC", "Voice CODEC PGA"}, - { "Speaker Amp Source MUX", "Right", "DAC PGA"}, - - { "Headset Amp Source MUX", "CODEC", "Voice CODEC PGA"}, - { "Headset Amp Source MUX", "Mixer", "DAC PGA"}, - /* Output */ { "HSL", NULL, "Headset Amp Left" }, { "HSR", NULL, "Headset Amp Right"}, { "RXOUTL", NULL, "Line out Amp Left"}, { "RXOUTR", NULL, "Line out Amp Right"}, - { "SP", "Speaker Amp Switch", "Speaker Amp Source MUX"}, - { "LSP", "Loudspeaker Amp", "Speaker Amp Source MUX"}, - { "HSL", "Headset Amp Left", "Headset Amp Source MUX"}, - { "HSR", "Headset Amp Right", "Headset Amp Source MUX"}, + { "SP", NULL, "Speaker Amp"}, + { "Speaker Amp", NULL, "DAC PGA"}, + { "LSP", NULL, "DAC PGA"}, + { "Headset Amp Left", NULL, "DAC PGA"}, + { "Headset Amp Right", NULL, "DAC PGA"}, { "Line out Amp Left", NULL, "DAC PGA"}, { "Line out Amp Right", NULL, "DAC PGA"}, { "DAC PGA", NULL, "DAC"}, { "DAC", NULL, "DAC_E"}, - { "CDCOUT", "CDCOUT Switch", "Voice CODEC PGA"}, }; static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix", @@ -587,39 +580,15 @@ static const struct soc_enum mc13783_enum_3d_mixer = static struct snd_kcontrol_new mc13783_control_list[] = { SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0), SOC_SINGLE("PCM Playback Volume", MC13783_AUDIO_RX1, 6, 15, 0), - SOC_SINGLE("PCM Playback Switch", MC13783_AUDIO_RX1, 5, 1, 0), SOC_DOUBLE("PCM Capture Volume", MC13783_AUDIO_TX, 19, 14, 31, 0), SOC_ENUM("3D Control", mc13783_enum_3d_mixer), - - SOC_SINGLE("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 1, 0), - SOC_SINGLE("Earpiece Amp Switch", MC13783_AUDIO_RX0, 3, 1, 0), - SOC_DOUBLE("Headset Amp Switch", MC13783_AUDIO_RX0, 10, 9, 1, 0), - SOC_DOUBLE("Line out Amp Switch", MC13783_AUDIO_RX0, 16, 15, 1, 0), - - SOC_SINGLE("PCM Capture Mixin Switch", MC13783_AUDIO_RX0, 22, 1, 0), - SOC_SINGLE("Line in Capture Mixin Switch", MC13783_AUDIO_RX0, 23, 1, 0), - - SOC_SINGLE("CODEC Capture Volume", MC13783_AUDIO_RX1, 1, 15, 0), - SOC_SINGLE("CODEC Capture Mixin Switch", MC13783_AUDIO_RX0, 21, 1, 0), - - SOC_SINGLE("Line in Capture Volume", MC13783_AUDIO_RX1, 12, 15, 0), - SOC_SINGLE("Line in Capture Switch", MC13783_AUDIO_RX1, 10, 1, 0), - - SOC_SINGLE("MC1 Capture Bias Switch", MC13783_AUDIO_TX, 0, 1, 0), - SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0), }; static int mc13783_probe(struct snd_soc_codec *codec) { struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); - int ret; - codec->control_data = dev_get_regmap(codec->dev->parent, NULL); - ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP); - if (ret != 0) { - dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); - return ret; - } + mc13xxx_lock(priv->mc13xxx); /* these are the reset values */ mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); @@ -643,6 +612,8 @@ static int mc13783_probe(struct snd_soc_codec *codec) mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC, 0, AUDIO_SSI_SEL); + mc13xxx_unlock(priv->mc13xxx); + return 0; } @@ -650,9 +621,13 @@ static int mc13783_remove(struct snd_soc_codec *codec) { struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + mc13xxx_lock(priv->mc13xxx); + /* Make sure VAUDIOON is off */ mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0); + mc13xxx_unlock(priv->mc13xxx); + return 0; } @@ -742,6 +717,8 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { .probe = mc13783_probe, .remove = mc13783_remove, + .read = mc13783_read, + .write = mc13783_write, .controls = mc13783_control_list, .num_controls = ARRAY_SIZE(mc13783_control_list), .dapm_widgets = mc13783_dapm_widgets, diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index 185fa3b..2611882 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -342,8 +342,6 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); int i = get_coeff(priv->mclk, params_rate(hw_params)); - if (i < 0) - return i; priv->substream = substream; priv->rate = params_rate(hw_params); diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index 73f9c36..c91eba5 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -21,7 +21,6 @@ #include <linux/gpio.h> #include <linux/i2c.h> #include <linux/regmap.h> -#include <linux/of.h> #include <linux/of_device.h> #include <linux/of_gpio.h> #include <sound/pcm.h> diff --git a/sound/soc/codecs/pcm1792a.c b/sound/soc/codecs/pcm1792a.c index 7146653..7613181 100644 --- a/sound/soc/codecs/pcm1792a.c +++ b/sound/soc/codecs/pcm1792a.c @@ -28,7 +28,6 @@ #include <sound/initval.h> #include <sound/soc.h> #include <sound/tlv.h> -#include <linux/of.h> #include <linux/of_device.h> #include "pcm1792a.h" diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index a3fb411..c26a8f8 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -21,7 +21,6 @@ #include <linux/of_gpio.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> -#include <linux/acpi.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -927,7 +926,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, return 0; } -static void hp_amp_power_on(struct snd_soc_codec *codec) +void hp_amp_power_on(struct snd_soc_codec *codec) { struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); @@ -1604,14 +1603,13 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_codec *codec = rtd->codec; struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); - unsigned int val_len = 0, val_clk, mask_clk; - int dai_sel, pre_div, bclk_ms, frame_size; + unsigned int val_len = 0, val_clk, mask_clk, dai_sel; + int pre_div, bclk_ms, frame_size; rt5640->lrck[dai->id] = params_rate(params); pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", - rt5640->lrck[dai->id], dai->id); + dev_err(codec->dev, "Unsupported clock setting\n"); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); @@ -1675,8 +1673,7 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct snd_soc_codec *codec = dai->codec; struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); - unsigned int reg_val = 0; - int dai_sel; + unsigned int reg_val = 0, dai_sel; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -1980,20 +1977,13 @@ static int rt5640_suspend(struct snd_soc_codec *codec) rt5640_reset(codec); regcache_cache_only(rt5640->regmap, true); regcache_mark_dirty(rt5640->regmap); - if (gpio_is_valid(rt5640->pdata.ldo1_en)) - gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 0); return 0; } static int rt5640_resume(struct snd_soc_codec *codec) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); - - if (gpio_is_valid(rt5640->pdata.ldo1_en)) { - gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1); - msleep(400); - } + rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; } @@ -2090,14 +2080,6 @@ static const struct i2c_device_id rt5640_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); -#ifdef CONFIG_ACPI -static struct acpi_device_id rt5640_acpi_match[] = { - { "INT33CA", 0 }, - { }, -}; -MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); -#endif - static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) { rt5640->pdata.in1_diff = of_property_read_bool(np, @@ -2217,7 +2199,6 @@ static struct i2c_driver rt5640_i2c_driver = { .driver = { .name = "rt5640", .owner = THIS_MODULE, - .acpi_match_table = ACPI_PTR(rt5640_acpi_match), }, .probe = rt5640_i2c_probe, .remove = rt5640_i2c_remove, diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 52e7cb0..38f3b10 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -60,6 +60,48 @@ enum si476x_pcm_format { SI476X_PCM_FORMAT_S24_LE = 6, }; +static unsigned int si476x_codec_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + int err; + unsigned int val; + struct si476x_core *core = codec->control_data; + + si476x_core_lock(core); + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, true); + + err = regmap_read(core->regmap, reg, &val); + + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, false); + si476x_core_unlock(core); + + if (err < 0) + return err; + + return val; +} + +static int si476x_codec_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int val) +{ + int err; + struct si476x_core *core = codec->control_data; + + si476x_core_lock(core); + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, true); + + err = regmap_write(core->regmap, reg, val); + + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, false); + si476x_core_unlock(core); + + return err; +} + static const struct snd_soc_dapm_widget si476x_dapm_widgets[] = { SND_SOC_DAPM_OUTPUT("LOUT"), SND_SOC_DAPM_OUTPUT("ROUT"), @@ -73,7 +115,6 @@ static const struct snd_soc_dapm_route si476x_dapm_routes[] = { static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct si476x_core *core = i2c_mfd_cell_to_core(codec_dai->dev); int err; u16 format = 0; @@ -137,14 +178,9 @@ static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - si476x_core_lock(core); - err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK, format); - - si476x_core_unlock(core); - if (err < 0) { dev_err(codec_dai->codec->dev, "Failed to set output format\n"); return err; @@ -157,7 +193,6 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev); int rate, width, err; rate = params_rate(params); @@ -183,13 +218,11 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - si476x_core_lock(core); - err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, rate); if (err < 0) { dev_err(dai->codec->dev, "Failed to set sample rate\n"); - goto out; + return err; } err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, @@ -198,18 +231,15 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT)); if (err < 0) { dev_err(dai->codec->dev, "Failed to set output width\n"); - goto out; + return err; } -out: - si476x_core_unlock(core); - - return err; + return 0; } static int si476x_codec_probe(struct snd_soc_codec *codec) { - codec->control_data = dev_get_regmap(codec->dev->parent, NULL); + codec->control_data = i2c_mfd_cell_to_core(codec->dev); return 0; } @@ -238,6 +268,8 @@ static struct snd_soc_dai_driver si476x_dai = { static struct snd_soc_codec_driver soc_codec_dev_si476x = { .probe = si476x_codec_probe, + .read = si476x_codec_read, + .write = si476x_codec_write, .dapm_widgets = si476x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), .dapm_routes = si476x_dapm_routes, diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 13045f2..dba26e63 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c @@ -164,27 +164,29 @@ static unsigned int sn95031_get_mic_bias(struct snd_soc_codec *codec) } /*end - adc helper functions */ -static int sn95031_read(void *ctx, unsigned int reg, unsigned int *val) +static inline unsigned int sn95031_read(struct snd_soc_codec *codec, + unsigned int reg) { u8 value = 0; int ret; ret = intel_scu_ipc_ioread8(reg, &value); - if (ret == 0) - *val = value; + if (ret) + pr_err("read of %x failed, err %d\n", reg, ret); + return value; - return ret; } -static int sn95031_write(void *ctx, unsigned int reg, unsigned int value) +static inline int sn95031_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) { - return intel_scu_ipc_iowrite8(reg, value); -} + int ret; -static const struct regmap_config sn95031_regmap = { - .reg_read = sn95031_read, - .reg_write = sn95031_write, -}; + ret = intel_scu_ipc_iowrite8(reg, value); + if (ret) + pr_err("write of %x failed, err %d\n", reg, ret); + return ret; +} static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, enum snd_soc_bias_level level) @@ -825,8 +827,6 @@ static int sn95031_codec_probe(struct snd_soc_codec *codec) { pr_debug("codec_probe called\n"); - snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); - /* PCM interface config * This sets the pcm rx slot conguration to max 6 slots * for max 4 dais (2 stereo and 2 mono) @@ -886,6 +886,8 @@ static int sn95031_codec_remove(struct snd_soc_codec *codec) static struct snd_soc_codec_driver sn95031_codec = { .probe = sn95031_codec_probe, .remove = sn95031_codec_remove, + .read = sn95031_read, + .write = sn95031_write, .set_bias_level = sn95031_set_vaud_bias, .idle_bias_off = true, .dapm_widgets = sn95031_dapm_widgets, @@ -896,14 +898,7 @@ static struct snd_soc_codec_driver sn95031_codec = { static int sn95031_device_probe(struct platform_device *pdev) { - struct regmap *regmap; - pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev)); - - regmap = devm_regmap_init(&pdev->dev, NULL, NULL, &sn95031_regmap); - if (IS_ERR(regmap)) - return PTR_ERR(regmap); - return snd_soc_register_codec(&pdev->dev, &sn95031_codec, sn95031_dais, ARRAY_SIZE(sn95031_dais)); } diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index a895a5e..6d31d88 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -37,7 +37,6 @@ #include <linux/i2c.h> #include <linux/regmap.h> #include <linux/spi/spi.h> -#include <linux/of.h> #include <linux/of_device.h> #include <linux/of_gpio.h> #include <sound/pcm.h> @@ -245,8 +244,6 @@ struct tas5086_private { unsigned int mclk, sclk; unsigned int format; bool deemph; - unsigned int charge_period; - unsigned int pwm_start_mid_z; /* Current sample rate for de-emphasis control */ int rate; /* GPIO driving Reset pin, if any */ @@ -432,7 +429,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, default: dev_err(codec->dev, "Invalid bit width\n"); return -EINVAL; - } + }; ret = regmap_write(priv->regmap, TAS5086_SERIAL_DATA_IF, val); if (ret < 0) @@ -459,75 +456,6 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) return regmap_write(priv->regmap, TAS5086_SOFT_MUTE, val); } -static void tas5086_reset(struct tas5086_private *priv) -{ - if (gpio_is_valid(priv->gpio_nreset)) { - /* Reset codec - minimum assertion time is 400ns */ - gpio_direction_output(priv->gpio_nreset, 0); - udelay(1); - gpio_set_value(priv->gpio_nreset, 1); - - /* Codec needs ~15ms to wake up */ - msleep(15); - } -} - -/* charge period values in microseconds */ -static const int tas5086_charge_period[] = { - 13000, 16900, 23400, 31200, 41600, 54600, 72800, 96200, - 130000, 156000, 234000, 312000, 416000, 546000, 728000, 962000, - 1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000, -}; - -static int tas5086_init(struct device *dev, struct tas5086_private *priv) -{ - int ret, i; - - /* - * If any of the channels is configured to start in Mid-Z mode, - * configure 'part 1' of the PWM starts to use Mid-Z, and tell - * all configured mid-z channels to start start under 'part 1'. - */ - if (priv->pwm_start_mid_z) - regmap_write(priv->regmap, TAS5086_PWM_START, - TAS5086_PWM_START_MIDZ_FOR_START_1 | - priv->pwm_start_mid_z); - - /* lookup and set split-capacitor charge period */ - if (priv->charge_period == 0) { - regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0); - } else { - i = index_in_array(tas5086_charge_period, - ARRAY_SIZE(tas5086_charge_period), - priv->charge_period); - if (i >= 0) - regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, - i + 0x08); - else - dev_warn(dev, - "Invalid split-cap charge period of %d ns.\n", - priv->charge_period); - } - - /* enable factory trim */ - ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00); - if (ret < 0) - return ret; - - /* start all channels */ - ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20); - if (ret < 0) - return ret; - - /* mute all channels for now */ - ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE, - TAS5086_SOFT_MUTE_ALL); - if (ret < 0) - return ret; - - return 0; -} - /* TAS5086 controls */ static const DECLARE_TLV_DB_SCALE(tas5086_dac_tlv, -10350, 50, 1); @@ -763,39 +691,14 @@ static struct snd_soc_dai_driver tas5086_dai = { }; #ifdef CONFIG_PM -static int tas5086_soc_suspend(struct snd_soc_codec *codec) -{ - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - /* Shut down all channels */ - ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x60); - if (ret < 0) - return ret; - - return 0; -} - static int tas5086_soc_resume(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - tas5086_reset(priv); - regcache_mark_dirty(priv->regmap); - - ret = tas5086_init(codec->dev, priv); - if (ret < 0) - return ret; - - ret = regcache_sync(priv->regmap); - if (ret < 0) - return ret; - return 0; + /* Restore codec state */ + return regcache_sync(priv->regmap); } #else -#define tas5086_soc_suspend NULL #define tas5086_soc_resume NULL #endif /* CONFIG_PM */ @@ -807,19 +710,23 @@ static const struct of_device_id tas5086_dt_ids[] = { MODULE_DEVICE_TABLE(of, tas5086_dt_ids); #endif +/* charge period values in microseconds */ +static const int tas5086_charge_period[] = { + 13000, 16900, 23400, 31200, 41600, 54600, 72800, 96200, + 130000, 156000, 234000, 312000, 416000, 546000, 728000, 962000, + 1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000, +}; + static int tas5086_probe(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + int charge_period = 1300000; /* hardware default is 1300 ms */ + u8 pwm_start_mid_z = 0; int i, ret; - priv->pwm_start_mid_z = 0; - priv->charge_period = 1300000; /* hardware default is 1300 ms */ - if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { struct device_node *of_node = codec->dev->of_node; - - of_property_read_u32(of_node, "ti,charge-period", - &priv->charge_period); + of_property_read_u32(of_node, "ti,charge-period", &charge_period); for (i = 0; i < 6; i++) { char name[25]; @@ -828,11 +735,43 @@ static int tas5086_probe(struct snd_soc_codec *codec) "ti,mid-z-channel-%d", i + 1); if (of_get_property(of_node, name, NULL) != NULL) - priv->pwm_start_mid_z |= 1 << i; + pwm_start_mid_z |= 1 << i; } } - ret = tas5086_init(codec->dev, priv); + /* + * If any of the channels is configured to start in Mid-Z mode, + * configure 'part 1' of the PWM starts to use Mid-Z, and tell + * all configured mid-z channels to start start under 'part 1'. + */ + if (pwm_start_mid_z) + regmap_write(priv->regmap, TAS5086_PWM_START, + TAS5086_PWM_START_MIDZ_FOR_START_1 | + pwm_start_mid_z); + + /* lookup and set split-capacitor charge period */ + if (charge_period == 0) { + regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0); + } else { + i = index_in_array(tas5086_charge_period, + ARRAY_SIZE(tas5086_charge_period), + charge_period); + if (i >= 0) + regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, + i + 0x08); + else + dev_warn(codec->dev, + "Invalid split-cap charge period of %d ns.\n", + charge_period); + } + + /* enable factory trim */ + ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00); + if (ret < 0) + return ret; + + /* start all channels */ + ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20); if (ret < 0) return ret; @@ -841,6 +780,12 @@ static int tas5086_probe(struct snd_soc_codec *codec) if (ret < 0) return ret; + /* mute all channels for now */ + ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE, + TAS5086_SOFT_MUTE_ALL); + if (ret < 0) + return ret; + return 0; } @@ -858,7 +803,6 @@ static int tas5086_remove(struct snd_soc_codec *codec) static struct snd_soc_codec_driver soc_codec_dev_tas5086 = { .probe = tas5086_probe, .remove = tas5086_remove, - .suspend = tas5086_soc_suspend, .resume = tas5086_soc_resume, .controls = tas5086_controls, .num_controls = ARRAY_SIZE(tas5086_controls), @@ -918,8 +862,17 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) gpio_nreset = -EINVAL; + if (gpio_is_valid(gpio_nreset)) { + /* Reset codec - minimum assertion time is 400ns */ + gpio_direction_output(gpio_nreset, 0); + udelay(1); + gpio_set_value(gpio_nreset, 1); + + /* Codec needs ~15ms to wake up */ + msleep(15); + } + priv->gpio_nreset = gpio_nreset; - tas5086_reset(priv); /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 5d430cc..31762eb 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -24,7 +24,6 @@ #include <linux/delay.h> #include <linux/pm.h> #include <linux/i2c.h> -#include <linux/regmap.h> #include <linux/slab.h> #include <sound/core.h> #include <sound/pcm.h> @@ -38,27 +37,11 @@ /* * AIC23 register cache */ -static const struct reg_default tlv320aic23_reg[] = { - { 0, 0x0097 }, - { 1, 0x0097 }, - { 2, 0x00F9 }, - { 3, 0x00F9 }, - { 4, 0x001A }, - { 5, 0x0004 }, - { 6, 0x0007 }, - { 7, 0x0001 }, - { 8, 0x0020 }, - { 9, 0x0000 }, -}; - -static const struct regmap_config tlv320aic23_regmap = { - .reg_bits = 7, - .val_bits = 9, - - .max_register = TLV320AIC23_RESET, - .reg_defaults = tlv320aic23_reg, - .num_reg_defaults = ARRAY_SIZE(tlv320aic23_reg), - .cache_type = REGCACHE_RBTREE, +static const u16 tlv320aic23_reg[] = { + 0x0097, 0x0097, 0x00F9, 0x00F9, /* 0 */ + 0x001A, 0x0004, 0x0007, 0x0001, /* 4 */ + 0x0020, 0x0000, 0x0000, 0x0000, /* 8 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */ }; static const char *rec_src_text[] = { "Line", "Mic" }; @@ -188,7 +171,7 @@ static const struct snd_soc_dapm_route tlv320aic23_intercon[] = { /* AIC23 driver data */ struct aic23 { - struct regmap *regmap; + enum snd_soc_control_type control_type; int mclk; int requested_adc; int requested_dac; @@ -549,9 +532,7 @@ static int tlv320aic23_suspend(struct snd_soc_codec *codec) static int tlv320aic23_resume(struct snd_soc_codec *codec) { - struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); - regcache_mark_dirty(aic23->regmap); - regcache_sync(aic23->regmap); + snd_soc_cache_sync(codec); tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; @@ -559,9 +540,10 @@ static int tlv320aic23_resume(struct snd_soc_codec *codec) static int tlv320aic23_probe(struct snd_soc_codec *codec) { + struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); int ret; - ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 7, 9, aic23->control_type); if (ret < 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; @@ -570,6 +552,16 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec) /* Reset codec */ snd_soc_write(codec, TLV320AIC23_RESET, 0); + /* Write the register default value to cache for reserved registers, + * so the write to the these registers are suppressed by the cache + * restore code when it skips writes of default registers. + */ + snd_soc_cache_write(codec, 0x0A, 0); + snd_soc_cache_write(codec, 0x0B, 0); + snd_soc_cache_write(codec, 0x0C, 0); + snd_soc_cache_write(codec, 0x0D, 0); + snd_soc_cache_write(codec, 0x0E, 0); + /* power on device */ tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); @@ -594,6 +586,9 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec) snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1); + snd_soc_add_codec_controls(codec, tlv320aic23_snd_controls, + ARRAY_SIZE(tlv320aic23_snd_controls)); + return 0; } @@ -604,19 +599,21 @@ static int tlv320aic23_remove(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { + .reg_cache_size = ARRAY_SIZE(tlv320aic23_reg), + .reg_word_size = sizeof(u16), + .reg_cache_default = tlv320aic23_reg, .probe = tlv320aic23_probe, .remove = tlv320aic23_remove, .suspend = tlv320aic23_suspend, .resume = tlv320aic23_resume, .set_bias_level = tlv320aic23_set_bias_level, - .controls = tlv320aic23_snd_controls, - .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), .dapm_widgets = tlv320aic23_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), .dapm_routes = tlv320aic23_intercon, .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), }; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) /* * If the i2c layer weren't so broken, we could pass this kind of data * around @@ -634,11 +631,8 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c, if (aic23 == NULL) return -ENOMEM; - aic23->regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap); - if (IS_ERR(aic23->regmap)) - return PTR_ERR(aic23->regmap); - i2c_set_clientdata(i2c, aic23); + aic23->control_type = SND_SOC_I2C; ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tlv320aic23, &tlv320aic23_dai, 1); @@ -666,7 +660,29 @@ static struct i2c_driver tlv320aic23_i2c_driver = { .id_table = tlv320aic23_id, }; -module_i2c_driver(tlv320aic23_i2c_driver); +#endif + +static int __init tlv320aic23_modinit(void) +{ + int ret; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + ret = i2c_add_driver(&tlv320aic23_i2c_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register TLV320AIC23 I2C driver: %d\n", + ret); + } +#endif + return ret; +} +module_init(tlv320aic23_modinit); + +static void __exit tlv320aic23_exit(void) +{ +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&tlv320aic23_i2c_driver); +#endif +} +module_exit(tlv320aic23_exit); MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver"); MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>"); diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 94a658f..7b8f3d9 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -29,7 +29,6 @@ MODULE_LICENSE("GPL"); /* AIC26 driver private data */ struct aic26 { struct spi_device *spi; - struct regmap *regmap; struct snd_soc_codec *codec; int master; int datfm; @@ -41,6 +40,85 @@ struct aic26 { int keyclick_len; }; +/* --------------------------------------------------------------------- + * Register access routines + */ +static unsigned int aic26_reg_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + u16 *cache = codec->reg_cache; + u16 cmd, value; + u8 buffer[2]; + int rc; + + if (reg >= AIC26_NUM_REGS) { + WARN_ON_ONCE(1); + return 0; + } + + /* Do SPI transfer; first 16bits are command; remaining is + * register contents */ + cmd = AIC26_READ_COMMAND_WORD(reg); + buffer[0] = (cmd >> 8) & 0xff; + buffer[1] = cmd & 0xff; + rc = spi_write_then_read(aic26->spi, buffer, 2, buffer, 2); + if (rc) { + dev_err(&aic26->spi->dev, "AIC26 reg read error\n"); + return -EIO; + } + value = (buffer[0] << 8) | buffer[1]; + + /* Update the cache before returning with the value */ + cache[reg] = value; + return value; +} + +static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec, + unsigned int reg) +{ + u16 *cache = codec->reg_cache; + + if (reg >= AIC26_NUM_REGS) { + WARN_ON_ONCE(1); + return 0; + } + + return cache[reg]; +} + +static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + u16 *cache = codec->reg_cache; + u16 cmd; + u8 buffer[4]; + int rc; + + if (reg >= AIC26_NUM_REGS) { + WARN_ON_ONCE(1); + return -EINVAL; + } + + /* Do SPI transfer; first 16bits are command; remaining is data + * to write into register */ + cmd = AIC26_WRITE_COMMAND_WORD(reg); + buffer[0] = (cmd >> 8) & 0xff; + buffer[1] = cmd & 0xff; + buffer[2] = value >> 8; + buffer[3] = value; + rc = spi_write(aic26->spi, buffer, 4); + if (rc) { + dev_err(&aic26->spi->dev, "AIC26 reg read error\n"); + return -EIO; + } + + /* update cache before returning */ + cache[reg] = value; + return 0; +} + static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = { SND_SOC_DAPM_INPUT("MICIN"), SND_SOC_DAPM_INPUT("AUX"), @@ -117,15 +195,19 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); /* Audio Control 3 (master mode, fsref rate) */ + reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3); + reg &= ~0xf800; if (aic26->master) - reg = 0x0800; + reg |= 0x0800; if (fsref == 48000) - reg = 0x2000; - snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); + reg |= 0x2000; + snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); /* Audio Control 1 (FSref divisor) */ - reg = wlen | aic26->datfm | (divisor << 3) | divisor; - snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); + reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); + reg &= ~0x0fff; + reg |= wlen | aic26->datfm | (divisor << 3) | divisor; + snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg); return 0; } @@ -137,16 +219,16 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) { struct snd_soc_codec *codec = dai->codec; struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); - u16 reg; + u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN); dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", dai, mute); if (mute) - reg = 0x8080; + reg |= 0x8080; else - reg = 0; - snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); + reg &= ~0x8080; + snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg); return 0; } @@ -264,7 +346,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, struct aic26 *aic26 = dev_get_drvdata(dev); int val, amp, freq, len; - val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); + val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); amp = (val >> 12) & 0x7; freq = (125 << ((val >> 8) & 0x7)) >> 1; len = 2 * (1 + ((val >> 4) & 0xf)); @@ -278,9 +360,11 @@ static ssize_t aic26_keyclick_set(struct device *dev, const char *buf, size_t count) { struct aic26 *aic26 = dev_get_drvdata(dev); + int val; - snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, - 0x8000, 0x800); + val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); + val |= 0x8000; + snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); return count; } @@ -293,9 +377,7 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); static int aic26_probe(struct snd_soc_codec *codec) { struct aic26 *aic26 = dev_get_drvdata(codec->dev); - int ret, reg; - - snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); + int ret, err, i, reg; aic26->codec = codec; @@ -311,30 +393,37 @@ static int aic26_probe(struct snd_soc_codec *codec) reg |= 0x0800; /* set master mode */ snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); + /* Fill register cache */ + for (i = 0; i < codec->driver->reg_cache_size; i++) + snd_soc_read(codec, i); + /* Register the sysfs files for debugging */ /* Create SysFS files */ ret = device_create_file(codec->dev, &dev_attr_keyclick); if (ret) dev_info(codec->dev, "error creating sysfs files\n"); + /* register controls */ + dev_dbg(codec->dev, "Registering controls\n"); + err = snd_soc_add_codec_controls(codec, aic26_snd_controls, + ARRAY_SIZE(aic26_snd_controls)); + WARN_ON(err < 0); + return 0; } static struct snd_soc_codec_driver aic26_soc_codec_dev = { .probe = aic26_probe, - .controls = aic26_snd_controls, - .num_controls = ARRAY_SIZE(aic26_snd_controls), + .read = aic26_reg_read, + .write = aic26_reg_write, + .reg_cache_size = AIC26_NUM_REGS, + .reg_word_size = sizeof(u16), .dapm_widgets = tlv320aic26_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), .dapm_routes = tlv320aic26_dapm_routes, .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), }; -static const struct regmap_config aic26_regmap = { - .reg_bits = 16, - .val_bits = 16, -}; - /* --------------------------------------------------------------------- * SPI device portion of driver: probe and release routines and SPI * driver registration. @@ -351,10 +440,6 @@ static int aic26_spi_probe(struct spi_device *spi) if (!aic26) return -ENOMEM; - aic26->regmap = devm_regmap_init_spi(spi, &aic26_regmap); - if (IS_ERR(aic26->regmap)) - return PTR_ERR(aic26->regmap); - /* Initialize the driver data */ aic26->spi = spi; dev_set_drvdata(&spi->dev, aic26); diff --git a/sound/soc/codecs/tlv320aic26.h b/sound/soc/codecs/tlv320aic26.h index 629b85e..67f19c3 100644 --- a/sound/soc/codecs/tlv320aic26.h +++ b/sound/soc/codecs/tlv320aic26.h @@ -9,7 +9,10 @@ #define _TLV320AIC16_H_ /* AIC26 Registers */ -#define AIC26_PAGE_ADDR(page, offset) ((page << 11) | offset << 5) +#define AIC26_READ_COMMAND_WORD(addr) ((1 << 15) | (addr << 5)) +#define AIC26_WRITE_COMMAND_WORD(addr) ((0 << 15) | (addr << 5)) +#define AIC26_PAGE_ADDR(page, offset) ((page << 6) | offset) +#define AIC26_NUM_REGS AIC26_PAGE_ADDR(3, 0) /* Page 0: Auxiliary data registers */ #define AIC26_REG_BAT1 AIC26_PAGE_ADDR(0, 0x05) diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 18cdcca..2ed57d4 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -60,8 +60,9 @@ struct aic32x4_rate_divs { }; struct aic32x4_priv { - struct regmap *regmap; u32 sysclk; + u8 page_no; + void *control_data; u32 power_cfg; u32 micpga_routing; bool swapdacs; @@ -261,25 +262,67 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"Right ADC", NULL, "Right Input Mixer"}, }; -static const struct regmap_range_cfg aic32x4_regmap_pages[] = { - { - .selector_reg = 0, - .selector_mask = 0xff, - .window_start = 0, - .window_len = 128, - .range_min = AIC32X4_PAGE1, - .range_max = AIC32X4_PAGE1 + 127, - }, -}; +static inline int aic32x4_change_page(struct snd_soc_codec *codec, + unsigned int new_page) +{ + struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + u8 data[2]; + int ret; -static const struct regmap_config aic32x4_regmap = { - .reg_bits = 8, - .val_bits = 8, + data[0] = 0x00; + data[1] = new_page & 0xff; - .max_register = AIC32X4_RMICPGAVOL, - .ranges = aic32x4_regmap_pages, - .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages), -}; + ret = codec->hw_write(codec->control_data, data, 2); + if (ret == 2) { + aic32x4->page_no = new_page; + return 0; + } else { + return ret; + } +} + +static int aic32x4_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int val) +{ + struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + unsigned int page = reg / 128; + unsigned int fixed_reg = reg % 128; + u8 data[2]; + int ret; + + /* A write to AIC32X4_PSEL is really a non-explicit page change */ + if (reg == AIC32X4_PSEL) + return aic32x4_change_page(codec, val); + + if (aic32x4->page_no != page) { + ret = aic32x4_change_page(codec, page); + if (ret != 0) + return ret; + } + + data[0] = fixed_reg & 0xff; + data[1] = val & 0xff; + + if (codec->hw_write(codec->control_data, data, 2) == 2) + return 0; + else + return -EIO; +} + +static unsigned int aic32x4_read(struct snd_soc_codec *codec, unsigned int reg) +{ + struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + unsigned int page = reg / 128; + unsigned int fixed_reg = reg % 128; + int ret; + + if (aic32x4->page_no != page) { + ret = aic32x4_change_page(codec, page); + if (ret != 0) + return ret; + } + return i2c_smbus_read_byte_data(codec->control_data, fixed_reg & 0xff); +} static inline int aic32x4_get_divs(int mclk, int rate) { @@ -574,10 +617,16 @@ static int aic32x4_probe(struct snd_soc_codec *codec) { struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); u32 tmp_reg; + int ret; - snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); + codec->hw_write = (hw_write_t) i2c_master_send; + codec->control_data = aic32x4->control_data; if (aic32x4->rstn_gpio >= 0) { + ret = devm_gpio_request_one(codec->dev, aic32x4->rstn_gpio, + GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn"); + if (ret != 0) + return ret; ndelay(10); gpio_set_value(aic32x4->rstn_gpio, 1); } @@ -643,6 +692,8 @@ static int aic32x4_remove(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { + .read = aic32x4_read, + .write = aic32x4_write, .probe = aic32x4_probe, .remove = aic32x4_remove, .suspend = aic32x4_suspend, @@ -669,10 +720,7 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c, if (aic32x4 == NULL) return -ENOMEM; - aic32x4->regmap = devm_regmap_init_i2c(i2c, &aic32x4_regmap); - if (IS_ERR(aic32x4->regmap)) - return PTR_ERR(aic32x4->regmap); - + aic32x4->control_data = i2c; i2c_set_clientdata(i2c, aic32x4); if (pdata) { @@ -687,13 +735,6 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c, aic32x4->rstn_gpio = -1; } - if (aic32x4->rstn_gpio >= 0) { - ret = devm_gpio_request_one(&i2c->dev, aic32x4->rstn_gpio, - GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn"); - if (ret != 0) - return ret; - } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_aic32x4, &aic32x4_dai, 1); return ret; diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 546d16b..64ad84d 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -40,7 +40,6 @@ #include <linux/i2c.h> #include <linux/gpio.h> #include <linux/regulator/consumer.h> -#include <linux/of.h> #include <linux/of_gpio.h> #include <linux/slab.h> #include <sound/core.h> @@ -73,9 +72,9 @@ struct aic3x_disable_nb { /* codec private data */ struct aic3x_priv { struct snd_soc_codec *codec; - struct regmap *regmap; struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; struct aic3x_disable_nb disable_nb[AIC3X_NUM_SUPPLIES]; + enum snd_soc_control_type control_type; struct aic3x_setup_data *setup; unsigned int sysclk; struct list_head list; @@ -91,45 +90,41 @@ struct aic3x_priv { enum aic3x_micbias_voltage micbias_vg; }; -static const struct reg_default aic3x_reg[] = { - { 0, 0x00 }, { 1, 0x00 }, { 2, 0x00 }, { 3, 0x10 }, - { 4, 0x04 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, - { 8, 0x00 }, { 9, 0x00 }, { 10, 0x00 }, { 11, 0x01 }, - { 12, 0x00 }, { 13, 0x00 }, { 14, 0x00 }, { 15, 0x80 }, - { 16, 0x80 }, { 17, 0xff }, { 18, 0xff }, { 19, 0x78 }, - { 20, 0x78 }, { 21, 0x78 }, { 22, 0x78 }, { 23, 0x78 }, - { 24, 0x78 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0xfe }, - { 28, 0x00 }, { 29, 0x00 }, { 30, 0xfe }, { 31, 0x00 }, - { 32, 0x18 }, { 33, 0x18 }, { 34, 0x00 }, { 35, 0x00 }, - { 36, 0x00 }, { 37, 0x00 }, { 38, 0x00 }, { 39, 0x00 }, - { 40, 0x00 }, { 41, 0x00 }, { 42, 0x00 }, { 43, 0x80 }, - { 44, 0x80 }, { 45, 0x00 }, { 46, 0x00 }, { 47, 0x00 }, - { 48, 0x00 }, { 49, 0x00 }, { 50, 0x00 }, { 51, 0x04 }, - { 52, 0x00 }, { 53, 0x00 }, { 54, 0x00 }, { 55, 0x00 }, - { 56, 0x00 }, { 57, 0x00 }, { 58, 0x04 }, { 59, 0x00 }, - { 60, 0x00 }, { 61, 0x00 }, { 62, 0x00 }, { 63, 0x00 }, - { 64, 0x00 }, { 65, 0x04 }, { 66, 0x00 }, { 67, 0x00 }, - { 68, 0x00 }, { 69, 0x00 }, { 70, 0x00 }, { 71, 0x00 }, - { 72, 0x04 }, { 73, 0x00 }, { 74, 0x00 }, { 75, 0x00 }, - { 76, 0x00 }, { 77, 0x00 }, { 78, 0x00 }, { 79, 0x00 }, - { 80, 0x00 }, { 81, 0x00 }, { 82, 0x00 }, { 83, 0x00 }, - { 84, 0x00 }, { 85, 0x00 }, { 86, 0x00 }, { 87, 0x00 }, - { 88, 0x00 }, { 89, 0x00 }, { 90, 0x00 }, { 91, 0x00 }, - { 92, 0x00 }, { 93, 0x00 }, { 94, 0x00 }, { 95, 0x00 }, - { 96, 0x00 }, { 97, 0x00 }, { 98, 0x00 }, { 99, 0x00 }, - { 100, 0x00 }, { 101, 0x00 }, { 102, 0x02 }, { 103, 0x00 }, - { 104, 0x00 }, { 105, 0x00 }, { 106, 0x00 }, { 107, 0x00 }, - { 108, 0x00 }, { 109, 0x00 }, -}; - -static const struct regmap_config aic3x_regmap = { - .reg_bits = 8, - .val_bits = 8, - - .max_register = DAC_ICC_ADJ, - .reg_defaults = aic3x_reg, - .num_reg_defaults = ARRAY_SIZE(aic3x_reg), - .cache_type = REGCACHE_RBTREE, +/* + * AIC3X register cache + * We can't read the AIC3X register space when we are + * using 2 wire for device control, so we cache them instead. + * There is no point in caching the reset register + */ +static const u8 aic3x_reg[AIC3X_CACHEREGNUM] = { + 0x00, 0x00, 0x00, 0x10, /* 0 */ + 0x04, 0x00, 0x00, 0x00, /* 4 */ + 0x00, 0x00, 0x00, 0x01, /* 8 */ + 0x00, 0x00, 0x00, 0x80, /* 12 */ + 0x80, 0xff, 0xff, 0x78, /* 16 */ + 0x78, 0x78, 0x78, 0x78, /* 20 */ + 0x78, 0x00, 0x00, 0xfe, /* 24 */ + 0x00, 0x00, 0xfe, 0x00, /* 28 */ + 0x18, 0x18, 0x00, 0x00, /* 32 */ + 0x00, 0x00, 0x00, 0x00, /* 36 */ + 0x00, 0x00, 0x00, 0x80, /* 40 */ + 0x80, 0x00, 0x00, 0x00, /* 44 */ + 0x00, 0x00, 0x00, 0x04, /* 48 */ + 0x00, 0x00, 0x00, 0x00, /* 52 */ + 0x00, 0x00, 0x04, 0x00, /* 56 */ + 0x00, 0x00, 0x00, 0x00, /* 60 */ + 0x00, 0x04, 0x00, 0x00, /* 64 */ + 0x00, 0x00, 0x00, 0x00, /* 68 */ + 0x04, 0x00, 0x00, 0x00, /* 72 */ + 0x00, 0x00, 0x00, 0x00, /* 76 */ + 0x00, 0x00, 0x00, 0x00, /* 80 */ + 0x00, 0x00, 0x00, 0x00, /* 84 */ + 0x00, 0x00, 0x00, 0x00, /* 88 */ + 0x00, 0x00, 0x00, 0x00, /* 92 */ + 0x00, 0x00, 0x00, 0x00, /* 96 */ + 0x00, 0x00, 0x02, 0x00, /* 100 */ + 0x00, 0x00, 0x00, 0x00, /* 104 */ + 0x00, 0x00, /* 108 */ }; #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \ @@ -833,6 +828,12 @@ static int aic3x_add_widgets(struct snd_soc_codec *codec) struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); struct snd_soc_dapm_context *dapm = &codec->dapm; + snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, + ARRAY_SIZE(aic3x_dapm_widgets)); + + /* set up audio path interconnects */ + snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); + if (aic3x->model == AIC3X_MODEL_3007) { snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, ARRAY_SIZE(aic3007_dapm_widgets)); @@ -1081,6 +1082,29 @@ static int aic3x_set_dai_fmt(struct snd_soc_dai *codec_dai, return 0; } +static int aic3x_init_3007(struct snd_soc_codec *codec) +{ + u8 tmp1, tmp2, *cache = codec->reg_cache; + + /* + * There is no need to cache writes to undocumented page 0xD but + * respective page 0 register cache entries must be preserved + */ + tmp1 = cache[0xD]; + tmp2 = cache[0x8]; + /* Class-D speaker driver init; datasheet p. 46 */ + snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x0D); + snd_soc_write(codec, 0xD, 0x0D); + snd_soc_write(codec, 0x8, 0x5C); + snd_soc_write(codec, 0x8, 0x5D); + snd_soc_write(codec, 0x8, 0x5C); + snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x00); + cache[0xD] = tmp1; + cache[0x8] = tmp2; + + return 0; +} + static int aic3x_regulator_event(struct notifier_block *nb, unsigned long event, void *data) { @@ -1095,7 +1119,7 @@ static int aic3x_regulator_event(struct notifier_block *nb, */ if (gpio_is_valid(aic3x->gpio_reset)) gpio_set_value(aic3x->gpio_reset, 0); - regcache_mark_dirty(aic3x->regmap); + aic3x->codec->cache_sync = 1; } return 0; @@ -1104,7 +1128,8 @@ static int aic3x_regulator_event(struct notifier_block *nb, static int aic3x_set_power(struct snd_soc_codec *codec, int power) { struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); - int ret; + int i, ret; + u8 *cache = codec->reg_cache; if (power) { ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), @@ -1112,6 +1137,12 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) if (ret) goto out; aic3x->power = 1; + /* + * Reset release and cache sync is necessary only if some + * supply was off or if there were cached writes + */ + if (!codec->cache_sync) + goto out; if (gpio_is_valid(aic3x->gpio_reset)) { udelay(1); @@ -1119,8 +1150,12 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) } /* Sync reg_cache with the hardware */ - regcache_cache_only(aic3x->regmap, false); - regcache_sync(aic3x->regmap); + codec->cache_only = 0; + for (i = AIC3X_SAMPLE_RATE_SEL_REG; i < ARRAY_SIZE(aic3x_reg); i++) + snd_soc_write(codec, i, cache[i]); + if (aic3x->model == AIC3X_MODEL_3007) + aic3x_init_3007(codec); + codec->cache_sync = 0; } else { /* * Do soft reset to this codec instance in order to clear @@ -1128,10 +1163,10 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) * remain on */ snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); - regcache_mark_dirty(aic3x->regmap); + codec->cache_sync = 1; aic3x->power = 0; /* HW writes are needless when bias is off */ - regcache_cache_only(aic3x->regmap, true); + codec->cache_only = 1; ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); } @@ -1286,6 +1321,7 @@ static int aic3x_init(struct snd_soc_codec *codec) snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); if (aic3x->model == AIC3X_MODEL_3007) { + aic3x_init_3007(codec); snd_soc_write(codec, CLASSD_CTRL, 0); } @@ -1313,12 +1349,29 @@ static int aic3x_probe(struct snd_soc_codec *codec) INIT_LIST_HEAD(&aic3x->list); aic3x->codec = codec; - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); + ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } + if (gpio_is_valid(aic3x->gpio_reset) && + !aic3x_is_shared_reset(aic3x)) { + ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); + if (ret != 0) + goto err_gpio; + gpio_direction_output(aic3x->gpio_reset, 0); + } + + for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) + aic3x->supplies[i].supply = aic3x_supply_names[i]; + + ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), + aic3x->supplies); + if (ret != 0) { + dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + goto err_get; + } for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; aic3x->disable_nb[i].aic3x = aic3x; @@ -1332,7 +1385,7 @@ static int aic3x_probe(struct snd_soc_codec *codec) } } - regcache_mark_dirty(aic3x->regmap); + codec->cache_only = 1; aic3x_init(codec); if (aic3x->setup) { @@ -1343,6 +1396,8 @@ static int aic3x_probe(struct snd_soc_codec *codec) (aic3x->setup->gpio_func[1] & 0xf) << 4); } + snd_soc_add_codec_controls(codec, aic3x_snd_controls, + ARRAY_SIZE(aic3x_snd_controls)); if (aic3x->model == AIC3X_MODEL_3007) snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); @@ -1373,6 +1428,12 @@ err_notif: while (i--) regulator_unregister_notifier(aic3x->supplies[i].consumer, &aic3x->disable_nb[i].nb); + regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); +err_get: + if (gpio_is_valid(aic3x->gpio_reset) && + !aic3x_is_shared_reset(aic3x)) + gpio_free(aic3x->gpio_reset); +err_gpio: return ret; } @@ -1383,9 +1444,15 @@ static int aic3x_remove(struct snd_soc_codec *codec) aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); list_del(&aic3x->list); + if (gpio_is_valid(aic3x->gpio_reset) && + !aic3x_is_shared_reset(aic3x)) { + gpio_set_value(aic3x->gpio_reset, 0); + gpio_free(aic3x->gpio_reset); + } for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) regulator_unregister_notifier(aic3x->supplies[i].consumer, &aic3x->disable_nb[i].nb); + regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); return 0; } @@ -1393,16 +1460,13 @@ static int aic3x_remove(struct snd_soc_codec *codec) static struct snd_soc_codec_driver soc_codec_dev_aic3x = { .set_bias_level = aic3x_set_bias_level, .idle_bias_off = true, + .reg_cache_size = ARRAY_SIZE(aic3x_reg), + .reg_word_size = sizeof(u8), + .reg_cache_default = aic3x_reg, .probe = aic3x_probe, .remove = aic3x_remove, .suspend = aic3x_suspend, .resume = aic3x_resume, - .controls = aic3x_snd_controls, - .num_controls = ARRAY_SIZE(aic3x_snd_controls), - .dapm_widgets = aic3x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), }; /* @@ -1419,16 +1483,6 @@ static const struct i2c_device_id aic3x_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); -static const struct reg_default aic3007_class_d[] = { - /* Class-D speaker driver init; datasheet p. 46 */ - { AIC3X_PAGE_SELECT, 0x0D }, - { 0xD, 0x0D }, - { 0x8, 0x5C }, - { 0x8, 0x5D }, - { 0x8, 0x5C }, - { AIC3X_PAGE_SELECT, 0x00 }, -}; - /* * If the i2c layer weren't so broken, we could pass this kind of data * around @@ -1440,7 +1494,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, struct aic3x_priv *aic3x; struct aic3x_setup_data *ai3x_setup; struct device_node *np = i2c->dev.of_node; - int ret, i; + int ret; u32 value; aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); @@ -1449,13 +1503,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, return -ENOMEM; } - aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap); - if (IS_ERR(aic3x->regmap)) { - ret = PTR_ERR(aic3x->regmap); - return ret; - } - - regcache_cache_only(aic3x->regmap, true); + aic3x->control_type = SND_SOC_I2C; i2c_set_clientdata(i2c, aic3x); if (pdata) { @@ -1507,54 +1555,14 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, aic3x->model = id->driver_data; - if (gpio_is_valid(aic3x->gpio_reset) && - !aic3x_is_shared_reset(aic3x)) { - ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); - if (ret != 0) - goto err; - gpio_direction_output(aic3x->gpio_reset, 0); - } - - for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) - aic3x->supplies[i].supply = aic3x_supply_names[i]; - - ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies), - aic3x->supplies); - if (ret != 0) { - dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); - goto err_gpio; - } - - if (aic3x->model == AIC3X_MODEL_3007) { - ret = regmap_register_patch(aic3x->regmap, aic3007_class_d, - ARRAY_SIZE(aic3007_class_d)); - if (ret != 0) - dev_err(&i2c->dev, "Failed to init class D: %d\n", - ret); - } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_aic3x, &aic3x_dai, 1); return ret; - -err_gpio: - if (gpio_is_valid(aic3x->gpio_reset) && - !aic3x_is_shared_reset(aic3x)) - gpio_free(aic3x->gpio_reset); -err: - return ret; } static int aic3x_i2c_remove(struct i2c_client *client) { - struct aic3x_priv *aic3x = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - if (gpio_is_valid(aic3x->gpio_reset) && - !aic3x_is_shared_reset(aic3x)) { - gpio_set_value(aic3x->gpio_reset, 0); - gpio_free(aic3x->gpio_reset); - } return 0; } diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index b27c396..c58bee8 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -30,7 +30,6 @@ #include <sound/tpa6130a2-plat.h> #include <sound/soc.h> #include <sound/tlv.h> -#include <linux/of_gpio.h> #include "tpa6130a2.h" @@ -56,8 +55,7 @@ static int tpa6130a2_i2c_read(int reg) struct tpa6130a2_data *data; int val; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); /* If powered off, return the cached value */ @@ -79,8 +77,7 @@ static int tpa6130a2_i2c_write(int reg, u8 value) struct tpa6130a2_data *data; int val = 0; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); if (data->power_state) { @@ -101,8 +98,7 @@ static u8 tpa6130a2_read(int reg) { struct tpa6130a2_data *data; - if (WARN_ON(!tpa6130a2_client)) - return 0; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); return data->regs[reg]; @@ -113,8 +109,7 @@ static int tpa6130a2_initialize(void) struct tpa6130a2_data *data; int i, ret = 0; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); for (i = 1; i < TPA6130A2_REG_VERSION; i++) { @@ -132,8 +127,7 @@ static int tpa6130a2_power(u8 power) u8 val; int ret = 0; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); mutex_lock(&data->mutex); @@ -199,8 +193,7 @@ static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol, unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); mutex_lock(&data->mutex); @@ -230,8 +223,7 @@ static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol, unsigned int val = (ucontrol->value.integer.value[0] & mask); unsigned int val_reg; - if (WARN_ON(!tpa6130a2_client)) - return -EINVAL; + BUG_ON(tpa6130a2_client == NULL); data = i2c_get_clientdata(tpa6130a2_client); if (invert) @@ -372,33 +364,30 @@ static int tpa6130a2_probe(struct i2c_client *client, { struct device *dev; struct tpa6130a2_data *data; - struct tpa6130a2_platform_data *pdata = client->dev.platform_data; - struct device_node *np = client->dev.of_node; + struct tpa6130a2_platform_data *pdata; const char *regulator; int ret; dev = &client->dev; + if (client->dev.platform_data == NULL) { + dev_err(dev, "Platform data not set\n"); + dump_stack(); + return -ENODEV; + } + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (data == NULL) { dev_err(dev, "Can not allocate memory\n"); return -ENOMEM; } - if (pdata) { - data->power_gpio = pdata->power_gpio; - } else if (np) { - data->power_gpio = of_get_named_gpio(np, "power-gpio", 0); - } else { - dev_err(dev, "Platform data not set\n"); - dump_stack(); - return -ENODEV; - } - tpa6130a2_client = client; i2c_set_clientdata(tpa6130a2_client, data); + pdata = client->dev.platform_data; + data->power_gpio = pdata->power_gpio; data->id = id->driver_data; mutex_init(&data->mutex); @@ -477,20 +466,10 @@ static const struct i2c_device_id tpa6130a2_id[] = { }; MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); -#if IS_ENABLED(CONFIG_OF) -static const struct of_device_id tpa6130a2_of_match[] = { - { .compatible = "ti,tpa6130a2", }, - { .compatible = "ti,tpa6140a2" }, - {}, -}; -MODULE_DEVICE_TABLE(of, tpa6130a2_of_match); -#endif - static struct i2c_driver tpa6130a2_i2c_driver = { .driver = { .name = "tpa6130a2", .owner = THIS_MODULE, - .of_match_table = of_match_ptr(tpa6130a2_of_match), }, .probe = tpa6130a2_probe, .remove = tpa6130a2_remove, diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index dfc51bb..1e3884d 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -46,7 +46,13 @@ /* TWL4030 PMBR1 Register GPIO6 mux bits */ #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2) -#define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) +/* Shadow register used by the audio driver */ +#define TWL4030_REG_SW_SHADOW 0x4A +#define TWL4030_CACHEREGNUM (TWL4030_REG_SW_SHADOW + 1) + +/* TWL4030_REG_SW_SHADOW (0x4A) Fields */ +#define TWL4030_HFL_EN 0x01 +#define TWL4030_HFR_EN 0x02 /* * twl4030 register cache & default register settings @@ -126,6 +132,7 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { 0x00, /* REG_VIBRA_PWM_SET (0x47) */ 0x00, /* REG_ANAMIC_GAIN (0x48) */ 0x00, /* REG_MISC_SET_2 (0x49) */ + 0x00, /* REG_SW_SHADOW (0x4A) - Shadow, non HW register */ }; /* codec private data */ @@ -191,41 +198,42 @@ static int twl4030_write(struct snd_soc_codec *codec, int write_to_reg = 0; twl4030_write_reg_cache(codec, reg, value); - /* Decide if the given register can be written */ - switch (reg) { - case TWL4030_REG_EAR_CTL: - if (twl4030->earpiece_enabled) - write_to_reg = 1; - break; - case TWL4030_REG_PREDL_CTL: - if (twl4030->predrivel_enabled) - write_to_reg = 1; - break; - case TWL4030_REG_PREDR_CTL: - if (twl4030->predriver_enabled) - write_to_reg = 1; - break; - case TWL4030_REG_PRECKL_CTL: - if (twl4030->carkitl_enabled) - write_to_reg = 1; - break; - case TWL4030_REG_PRECKR_CTL: - if (twl4030->carkitr_enabled) - write_to_reg = 1; - break; - case TWL4030_REG_HS_GAIN_SET: - if (twl4030->hsl_enabled || twl4030->hsr_enabled) + if (likely(reg < TWL4030_REG_SW_SHADOW)) { + /* Decide if the given register can be written */ + switch (reg) { + case TWL4030_REG_EAR_CTL: + if (twl4030->earpiece_enabled) + write_to_reg = 1; + break; + case TWL4030_REG_PREDL_CTL: + if (twl4030->predrivel_enabled) + write_to_reg = 1; + break; + case TWL4030_REG_PREDR_CTL: + if (twl4030->predriver_enabled) + write_to_reg = 1; + break; + case TWL4030_REG_PRECKL_CTL: + if (twl4030->carkitl_enabled) + write_to_reg = 1; + break; + case TWL4030_REG_PRECKR_CTL: + if (twl4030->carkitr_enabled) + write_to_reg = 1; + break; + case TWL4030_REG_HS_GAIN_SET: + if (twl4030->hsl_enabled || twl4030->hsr_enabled) + write_to_reg = 1; + break; + default: + /* All other register can be written */ write_to_reg = 1; - break; - default: - /* All other register can be written */ - write_to_reg = 1; - break; + break; + } + if (write_to_reg) + return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + value, reg); } - if (write_to_reg) - return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, - value, reg); - return 0; } @@ -524,7 +532,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); /* Handsfree Left virtual mute */ static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = - SOC_DAPM_SINGLE_VIRT("Switch", 1); + SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0); /* Handsfree Right */ static const char *twl4030_handsfreer_texts[] = @@ -540,7 +548,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); /* Handsfree Right virtual mute */ static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = - SOC_DAPM_SINGLE_VIRT("Switch", 1); + SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0); /* Vibra */ /* Vibra audio path selection */ diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index f2f4bcb..3c79dbb 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -54,7 +54,12 @@ enum twl6040_dai_id { #define TWL6040_OUTHF_0dB 0x03 #define TWL6040_OUTHF_M52dB 0x1D -#define TWL6040_CACHEREGNUM (TWL6040_REG_STATUS + 1) +/* Shadow register used by the driver */ +#define TWL6040_REG_SW_SHADOW 0x2F +#define TWL6040_CACHEREGNUM (TWL6040_REG_SW_SHADOW + 1) + +/* TWL6040_REG_SW_SHADOW (0x2F) fields */ +#define TWL6040_EAR_PATH_ENABLE 0x01 struct twl6040_jack_data { struct snd_soc_jack *jack; @@ -130,6 +135,8 @@ static const u8 twl6040_reg[TWL6040_CACHEREGNUM] = { 0x00, /* REG_HFOTRIM 0x2C */ 0x09, /* REG_ACCCTL 0x2D */ 0x00, /* REG_STATUS 0x2E (ro) */ + + 0x00, /* REG_SW_SHADOW 0x2F - Shadow, non HW register */ }; /* List of registers to be restored after power up */ @@ -213,8 +220,12 @@ static int twl6040_read_reg_volatile(struct snd_soc_codec *codec, if (reg >= TWL6040_CACHEREGNUM) return -EIO; - value = twl6040_reg_read(twl6040, reg); - twl6040_write_reg_cache(codec, reg, value); + if (likely(reg < TWL6040_REG_SW_SHADOW)) { + value = twl6040_reg_read(twl6040, reg); + twl6040_write_reg_cache(codec, reg, value); + } else { + value = twl6040_read_reg_cache(codec, reg); + } return value; } @@ -235,7 +246,7 @@ static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec, return priv->dl2_unmuted; default: return 1; - } + }; } /* @@ -250,7 +261,8 @@ static int twl6040_write(struct snd_soc_codec *codec, return -EIO; twl6040_write_reg_cache(codec, reg, value); - if (twl6040_is_path_unmuted(codec, reg)) + if (likely(reg < TWL6040_REG_SW_SHADOW) && + twl6040_is_path_unmuted(codec, reg)) return twl6040_reg_write(twl6040, reg, value); else return 0; @@ -543,7 +555,7 @@ static const struct snd_kcontrol_new hfr_mux_controls = SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]); static const struct snd_kcontrol_new ep_path_enable_control = - SOC_DAPM_SINGLE_VIRT("Switch", 1); + SOC_DAPM_SINGLE("Switch", TWL6040_REG_SW_SHADOW, 0, 1, 0); static const struct snd_kcontrol_new auxl_switch_control = SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 6, 1, 0); @@ -1088,7 +1100,7 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i break; default: break; - } + }; } static int twl6040_digital_mute(struct snd_soc_dai *dai, int mute) diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 71ce315..d5ebcb0 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -372,8 +372,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) offset = 0; dsp = inforec->dsp_target; wm0010->boot_failed = false; - if (WARN_ON(!list_empty(&xfer_list))) - return -EINVAL; + BUG_ON(!list_empty(&xfer_list)); init_completion(&done); /* First record should be INFO */ @@ -794,11 +793,11 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, wm0010->max_spi_freq = 0; } else { for (i = 0; i < ARRAY_SIZE(pll_clock_map); i++) - if (freq >= pll_clock_map[i].max_sysclk) { - wm0010->max_spi_freq = pll_clock_map[i].max_pll_spi_speed; - wm0010->pll_clkctrl1 = pll_clock_map[i].pll_clkctrl1; + if (freq >= pll_clock_map[i].max_sysclk) break; - } + + wm0010->max_spi_freq = pll_clock_map[i].max_pll_spi_speed; + wm0010->pll_clkctrl1 = pll_clock_map[i].pll_clkctrl1; } return 0; diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 8ae5027..7fefd76 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -137,8 +137,7 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) unsigned long rate; int ret; - if (WARN_ON(wm2000->anc_mode != ANC_OFF)) - return -EINVAL; + BUG_ON(wm2000->anc_mode != ANC_OFF); dev_dbg(&i2c->dev, "Beginning power up\n"); @@ -278,8 +277,7 @@ static int wm2000_enter_bypass(struct i2c_client *i2c, int analogue) { struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); - if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE)) - return -EINVAL; + BUG_ON(wm2000->anc_mode != ANC_ACTIVE); if (analogue) { wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, @@ -317,8 +315,7 @@ static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue) { struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); - if (WARN_ON(wm2000->anc_mode != ANC_BYPASS)) - return -EINVAL; + BUG_ON(wm2000->anc_mode != ANC_BYPASS); wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); @@ -352,8 +349,7 @@ static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) { struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); - if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE)) - return -EINVAL; + BUG_ON(wm2000->anc_mode != ANC_ACTIVE); if (analogue) { wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); @@ -396,8 +392,7 @@ static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) { struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); - if (WARN_ON(wm2000->anc_mode != ANC_STANDBY)) - return -EINVAL; + BUG_ON(wm2000->anc_mode != ANC_STANDBY); wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 4cf91de..ac1745d 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -1972,8 +1972,7 @@ static void wm5100_set_detect_mode(struct wm5100_priv *wm5100, int the_mode) { struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode]; - if (WARN_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes))) - return; + BUG_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes)); gpio_set_value_cansleep(wm5100->pdata.hp_pol, mode->hp_pol); regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1, diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index a08e8bf..8bbddc1 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -685,13 +685,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), -SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, +SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, ARIZONA_EQ1_ENA_MASK), -SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, +SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, ARIZONA_EQ2_ENA_MASK), -SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, +SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, ARIZONA_EQ3_ENA_MASK), -SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, +SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, ARIZONA_EQ4_ENA_MASK), SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 99b359e..bbd6438 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -37,47 +37,6 @@ struct wm5110_priv { struct arizona_fll fll[2]; }; -static const struct reg_default wm5110_sysclk_revd_patch[] = { - { 0x3093, 0x1001 }, - { 0x30E3, 0x1301 }, - { 0x3133, 0x1201 }, - { 0x3183, 0x1501 }, - { 0x31D3, 0x1401 }, -}; - -static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); - struct regmap *regmap = codec->control_data; - const struct reg_default *patch = NULL; - int i, patch_size; - - switch (arizona->rev) { - case 3: - patch = wm5110_sysclk_revd_patch; - patch_size = ARRAY_SIZE(wm5110_sysclk_revd_patch); - break; - default: - return 0; - } - - switch (event) { - case SND_SOC_DAPM_POST_PMU: - if (patch) - for (i = 0; i < patch_size; i++) - regmap_write(regmap, patch[i].reg, - patch[i].def); - break; - - default: - break; - } - - return 0; -} - static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0); static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); @@ -142,13 +101,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), -SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, +SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, ARIZONA_EQ1_ENA_MASK), -SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, +SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, ARIZONA_EQ2_ENA_MASK), -SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, +SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, ARIZONA_EQ3_ENA_MASK), -SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, +SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, ARIZONA_EQ4_ENA_MASK), SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, @@ -248,6 +207,19 @@ ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("SPKDAT2L", ARIZONA_OUT6LMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("SPKDAT2R", ARIZONA_OUT6RMIX_INPUT_1_SOURCE), +SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L, + ARIZONA_OUT1_OSR_SHIFT, 1, 0), +SOC_SINGLE("HPOUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L, + ARIZONA_OUT2_OSR_SHIFT, 1, 0), +SOC_SINGLE("HPOUT3 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L, + ARIZONA_OUT3_OSR_SHIFT, 1, 0), +SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L, + ARIZONA_OUT4_OSR_SHIFT, 1, 0), +SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L, + ARIZONA_OUT5_OSR_SHIFT, 1, 0), +SOC_SINGLE("SPKDAT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_6L, + ARIZONA_OUT6_OSR_SHIFT, 1, 0), + SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), SOC_DOUBLE_R("HPOUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, @@ -280,6 +252,18 @@ SOC_DOUBLE_R_TLV("SPKDAT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_6L, ARIZONA_DAC_DIGITAL_VOLUME_6R, ARIZONA_OUT6L_VOL_SHIFT, 0xbf, 0, digital_tlv), +SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L, + ARIZONA_OUTPUT_PATH_CONFIG_1R, + ARIZONA_OUT1L_PGA_VOL_SHIFT, + 0x34, 0x40, 0, ana_tlv), +SOC_DOUBLE_R_RANGE_TLV("HPOUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L, + ARIZONA_OUTPUT_PATH_CONFIG_2R, + ARIZONA_OUT2L_PGA_VOL_SHIFT, + 0x34, 0x40, 0, ana_tlv), +SOC_DOUBLE_R_RANGE_TLV("HPOUT3 Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L, + ARIZONA_OUTPUT_PATH_CONFIG_3R, + ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv), + SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, @@ -416,7 +400,7 @@ static const struct snd_kcontrol_new wm5110_aec_loopback_mux = static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, - 0, wm5110_sysclk_ev, SND_SOC_DAPM_POST_PMU), + 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, @@ -999,36 +983,24 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), - { "AEC Loopback", "HPOUT1L", "OUT1L" }, - { "AEC Loopback", "HPOUT1R", "OUT1R" }, { "HPOUT1L", NULL, "OUT1L" }, { "HPOUT1R", NULL, "OUT1R" }, - { "AEC Loopback", "HPOUT2L", "OUT2L" }, - { "AEC Loopback", "HPOUT2R", "OUT2R" }, { "HPOUT2L", NULL, "OUT2L" }, { "HPOUT2R", NULL, "OUT2R" }, - { "AEC Loopback", "HPOUT3L", "OUT3L" }, - { "AEC Loopback", "HPOUT3R", "OUT3R" }, { "HPOUT3L", NULL, "OUT3L" }, { "HPOUT3R", NULL, "OUT3L" }, - { "AEC Loopback", "SPKOUTL", "OUT4L" }, { "SPKOUTLN", NULL, "OUT4L" }, { "SPKOUTLP", NULL, "OUT4L" }, - { "AEC Loopback", "SPKOUTR", "OUT4R" }, { "SPKOUTRN", NULL, "OUT4R" }, { "SPKOUTRP", NULL, "OUT4R" }, - { "AEC Loopback", "SPKDAT1L", "OUT5L" }, - { "AEC Loopback", "SPKDAT1R", "OUT5R" }, { "SPKDAT1L", NULL, "OUT5L" }, { "SPKDAT1R", NULL, "OUT5R" }, - { "AEC Loopback", "SPKDAT2L", "OUT6L" }, - { "AEC Loopback", "SPKDAT2R", "OUT6R" }, { "SPKDAT2L", NULL, "OUT6L" }, { "SPKDAT2R", NULL, "OUT6R" }, diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index a183dcf..af1318d 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -274,7 +274,7 @@ static int pga_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid shift %d\n", w->shift); + BUG(); return -1; } diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 48dc7d2..d2a0928 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -32,6 +32,13 @@ #include "wm8400.h" +/* Fake register for internal state */ +#define WM8400_INTDRIVBITS (WM8400_REGISTER_COUNT + 1) +#define WM8400_INMIXL_PWR 0 +#define WM8400_AINLMUX_PWR 1 +#define WM8400_INMIXR_PWR 2 +#define WM8400_AINRMUX_PWR 3 + static struct regulator_bulk_data power[] = { { .supply = "I2S1VDD", @@ -67,6 +74,32 @@ struct wm8400_priv { int fll_in, fll_out; }; +static inline unsigned int wm8400_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + + if (reg == WM8400_INTDRIVBITS) + return wm8400->fake_register; + else + return wm8400_reg_read(wm8400->wm8400, reg); +} + +/* + * write to the wm8400 register space + */ +static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + + if (reg == WM8400_INTDRIVBITS) { + wm8400->fake_register = value; + return 0; + } else + return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); +} + static void wm8400_codec_reset(struct snd_soc_codec *codec) { struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); @@ -319,6 +352,32 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, * _DAPM_ Controls */ +static int inmixer_event (struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + u16 reg, fakepower; + + reg = snd_soc_read(w->codec, WM8400_POWER_MANAGEMENT_2); + fakepower = snd_soc_read(w->codec, WM8400_INTDRIVBITS); + + if (fakepower & ((1 << WM8400_INMIXL_PWR) | + (1 << WM8400_AINLMUX_PWR))) { + reg |= WM8400_AINL_ENA; + } else { + reg &= ~WM8400_AINL_ENA; + } + + if (fakepower & ((1 << WM8400_INMIXR_PWR) | + (1 << WM8400_AINRMUX_PWR))) { + reg |= WM8400_AINR_ENA; + } else { + reg &= ~WM8400_AINR_ENA; + } + snd_soc_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); + + return 0; +} + static int outmixer_event (struct snd_soc_dapm_widget *w, struct snd_kcontrol * kcontrol, int event) { @@ -599,26 +658,27 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2, 0, &wm8400_dapm_rin34_pga_controls[0], ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), -SND_SOC_DAPM_SUPPLY("INL", WM8400_POWER_MANAGEMENT_2, WM8400_AINL_ENA_SHIFT, - 0, NULL, 0), -SND_SOC_DAPM_SUPPLY("INR", WM8400_POWER_MANAGEMENT_2, WM8400_AINR_ENA_SHIFT, - 0, NULL, 0), - /* INMIXL */ -SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, +SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0, &wm8400_dapm_inmixl_controls[0], - ARRAY_SIZE(wm8400_dapm_inmixl_controls)), + ARRAY_SIZE(wm8400_dapm_inmixl_controls), + inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), /* AINLMUX */ -SND_SOC_DAPM_MUX("AILNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainlmux_controls), +SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0, + &wm8400_dapm_ainlmux_controls, inmixer_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), /* INMIXR */ -SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, +SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0, &wm8400_dapm_inmixr_controls[0], - ARRAY_SIZE(wm8400_dapm_inmixr_controls)), + ARRAY_SIZE(wm8400_dapm_inmixr_controls), + inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), /* AINRMUX */ -SND_SOC_DAPM_MUX("AIRNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainrmux_controls), +SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0, + &wm8400_dapm_ainrmux_controls, inmixer_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), /* Output Side */ /* DACs */ @@ -729,13 +789,11 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { {"LIN34 PGA", "LIN3 Switch", "LIN3"}, {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, /* INMIXL */ - {"INMIXL", NULL, "INL"}, {"INMIXL", "Record Left Volume", "LOMIX"}, {"INMIXL", "LIN2 Volume", "LIN2"}, {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, /* AILNMUX */ - {"AILNMUX", NULL, "INL"}, {"AILNMUX", "INMIXL Mix", "INMIXL"}, {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, @@ -750,14 +808,12 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { /* RIN34 PGA */ {"RIN34 PGA", "RIN3 Switch", "RIN3"}, {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, - /* INMIXR */ - {"INMIXR", NULL, "INR"}, + /* INMIXL */ {"INMIXR", "Record Right Volume", "ROMIX"}, {"INMIXR", "RIN2 Volume", "RIN2"}, {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, /* AIRNMUX */ - {"AIRNMUX", NULL, "INR"}, {"AIRNMUX", "INMIXR Mix", "INMIXR"}, {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, @@ -1309,12 +1365,9 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) return -ENOMEM; snd_soc_codec_set_drvdata(codec, priv); - priv->wm8400 = wm8400; - codec->control_data = wm8400->regmap; + codec->control_data = priv->wm8400 = wm8400; priv->codec = codec; - snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); - ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { @@ -1361,6 +1414,8 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { .remove = wm8400_codec_remove, .suspend = wm8400_suspend, .resume = wm8400_resume, + .read = snd_soc_read, + .write = wm8400_write, .set_bias_level = wm8400_set_bias_level, .controls = wm8400_snd_controls, diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 08a414b..5e9c40f 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -736,7 +736,7 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, break; default: - WARN(1, "Unknown DAI driver ID\n"); + BUG_ON("Unknown DAI driver ID\n"); return -EINVAL; } diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index bc7472c..456bb8c 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -447,10 +447,10 @@ static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, iface |= 0x0001; break; case SND_SOC_DAIFMT_DSP_A: - iface |= 0x0013; + iface |= 0x0003; break; case SND_SOC_DAIFMT_DSP_B: - iface |= 0x0003; + iface |= 0x0013; break; default: return -EINVAL; diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index 942d58e..f31017e 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -325,8 +325,7 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai, struct snd_soc_codec *codec = dai->codec; struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); - if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk))) - return -EINVAL; + BUG_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk)); wm8776->sysclk[dai->driver->id] = freq; diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 734209e..7c8257c 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -279,8 +279,7 @@ static int wm8900_hp_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid event %d\n", event); - break; + BUG(); } return 0; @@ -692,8 +691,7 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, unsigned int K, Ndiv, Nmod, target; unsigned int div; - if (WARN_ON(!Fout)) - return -EINVAL; + BUG_ON(!Fout); /* The FLL must run at 90-100MHz which is then scaled down to * the output value by FLLCLK_DIV. */ @@ -744,9 +742,8 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, /* Move down to proper range now rounding is done */ fll_div->k = K / 10; - if (WARN_ON(target != Fout * (fll_div->fllclk_div << 2)) || - WARN_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n)) - return -EINVAL; + BUG_ON(target != Fout * (fll_div->fllclk_div << 2)); + BUG_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n); return 0; } diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 3938fb1..4dfa8dc 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -658,8 +658,7 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8904_EQ6, 0, 24, 0, eq_tlv), static int cp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - if (WARN_ON(event != SND_SOC_DAPM_POST_PMU)) - return -EINVAL; + BUG_ON(event != SND_SOC_DAPM_POST_PMU); /* Maximum startup time */ udelay(500); @@ -741,7 +740,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, dcs_r = 3; break; default: - WARN(1, "Invalid reg %d\n", reg); + BUG(); return -EINVAL; } diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index b7488f1..b0710d8 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -348,7 +348,7 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) aif = 1; break; default: - WARN(1, "Invalid path %d\n", path); + BUG(); return; } diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 543c5c2..11d80f3 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -1758,9 +1758,6 @@ SOC_DOUBLE_R_TLV("EQ4 Volume", WM8962_EQ3, WM8962_EQ23, WM8962_EQL_B4_GAIN_SHIFT, 31, 0, eq_tlv), SOC_DOUBLE_R_TLV("EQ5 Volume", WM8962_EQ3, WM8962_EQ23, WM8962_EQL_B5_GAIN_SHIFT, 31, 0, eq_tlv), -SND_SOC_BYTES("EQL Coefficients", WM8962_EQ4, 18), -SND_SOC_BYTES("EQR Coefficients", WM8962_EQ24, 18), - SOC_SINGLE("3D Switch", WM8962_THREED1, 0, 1, 0), SND_SOC_BYTES_MASK("3D Coefficients", WM8962_THREED1, 4, WM8962_THREED_ENA), @@ -1778,11 +1775,6 @@ WM8962_DSP2_ENABLE("HPF2 Switch", WM8962_HPF2_ENA_SHIFT), SND_SOC_BYTES("HPF Coefficients", WM8962_LHPF2, 1), WM8962_DSP2_ENABLE("HD Bass Switch", WM8962_HDBASS_ENA_SHIFT), SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30), - -SOC_DOUBLE("ALC Switch", WM8962_ALC1, WM8962_ALCL_ENA_SHIFT, - WM8962_ALCR_ENA_SHIFT, 1, 0), -SND_SOC_BYTES_MASK("ALC Coefficients", WM8962_ALC1, 4, - WM8962_ALCL_ENA_MASK | WM8962_ALCR_ENA_MASK), }; static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = { @@ -1853,7 +1845,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } @@ -1945,7 +1937,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } @@ -1974,7 +1966,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, reg = WM8962_SPKOUTL_VOLUME; break; default: - WARN(1, "Invalid shift %d\n", w->shift); + BUG(); return -EINVAL; } @@ -1982,7 +1974,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } } @@ -2005,7 +1997,7 @@ static int dsp2_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } @@ -3250,7 +3242,7 @@ static void wm8962_free_beep(struct snd_soc_codec *codec) } #endif -static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) +static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio) { int mask = 0; int val = 0; @@ -3271,8 +3263,8 @@ static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) } if (mask) - regmap_update_bits(wm8962->regmap, WM8962_ANALOGUE_CLOCKING1, - mask, val); + snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1, + mask, val); } #ifdef CONFIG_GPIOLIB @@ -3284,6 +3276,7 @@ static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) { struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); + struct snd_soc_codec *codec = wm8962->codec; /* The WM8962 GPIOs aren't linearly numbered. For simplicity * we export linear numbers and error out if the unsupported @@ -3299,7 +3292,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) return -EINVAL; } - wm8962_set_gpio_mode(wm8962, offset + 1); + wm8962_set_gpio_mode(codec, offset + 1); return 0; } @@ -3383,7 +3376,8 @@ static int wm8962_probe(struct snd_soc_codec *codec) { int ret; struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); - int i; + struct wm8962_pdata *pdata = &wm8962->pdata; + int i, trigger, irq_pol; bool dmicclk, dmicdat; wm8962->codec = codec; @@ -3415,6 +3409,75 @@ static int wm8962_probe(struct snd_soc_codec *codec) } } + /* SYSCLK defaults to on; make sure it is off so we can safely + * write to registers if the device is declocked. + */ + snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0); + + /* Ensure we have soft control over all registers */ + snd_soc_update_bits(codec, WM8962_CLOCKING2, + WM8962_CLKREG_OVD, WM8962_CLKREG_OVD); + + /* Ensure that the oscillator and PLLs are disabled */ + snd_soc_update_bits(codec, WM8962_PLL2, + WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA, + 0); + + /* Apply static configuration for GPIOs */ + for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) + if (pdata->gpio_init[i]) { + wm8962_set_gpio_mode(codec, i + 1); + snd_soc_write(codec, 0x200 + i, + pdata->gpio_init[i] & 0xffff); + } + + + /* Put the speakers into mono mode? */ + if (pdata->spk_mono) + snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_2, + WM8962_SPK_MONO_MASK, WM8962_SPK_MONO); + + /* Micbias setup, detection enable and detection + * threasholds. */ + if (pdata->mic_cfg) + snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, + WM8962_MICDET_ENA | + WM8962_MICDET_THR_MASK | + WM8962_MICSHORT_THR_MASK | + WM8962_MICBIAS_LVL, + pdata->mic_cfg); + + /* Latch volume update bits */ + snd_soc_update_bits(codec, WM8962_LEFT_INPUT_VOLUME, + WM8962_IN_VU, WM8962_IN_VU); + snd_soc_update_bits(codec, WM8962_RIGHT_INPUT_VOLUME, + WM8962_IN_VU, WM8962_IN_VU); + snd_soc_update_bits(codec, WM8962_LEFT_ADC_VOLUME, + WM8962_ADC_VU, WM8962_ADC_VU); + snd_soc_update_bits(codec, WM8962_RIGHT_ADC_VOLUME, + WM8962_ADC_VU, WM8962_ADC_VU); + snd_soc_update_bits(codec, WM8962_LEFT_DAC_VOLUME, + WM8962_DAC_VU, WM8962_DAC_VU); + snd_soc_update_bits(codec, WM8962_RIGHT_DAC_VOLUME, + WM8962_DAC_VU, WM8962_DAC_VU); + snd_soc_update_bits(codec, WM8962_SPKOUTL_VOLUME, + WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); + snd_soc_update_bits(codec, WM8962_SPKOUTR_VOLUME, + WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); + snd_soc_update_bits(codec, WM8962_HPOUTL_VOLUME, + WM8962_HPOUT_VU, WM8962_HPOUT_VU); + snd_soc_update_bits(codec, WM8962_HPOUTR_VOLUME, + WM8962_HPOUT_VU, WM8962_HPOUT_VU); + + /* Stereo control for EQ */ + snd_soc_update_bits(codec, WM8962_EQ1, WM8962_EQ_SHARED_COEFF, 0); + + /* Don't debouce interrupts so we don't need SYSCLK */ + snd_soc_update_bits(codec, WM8962_IRQ_DEBOUNCE, + WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB | + WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB, + 0); + wm8962_add_widgets(codec); /* Save boards having to disable DMIC when not in use */ @@ -3443,6 +3506,36 @@ static int wm8962_probe(struct snd_soc_codec *codec) wm8962_init_beep(codec); wm8962_init_gpio(codec); + if (wm8962->irq) { + if (pdata->irq_active_low) { + trigger = IRQF_TRIGGER_LOW; + irq_pol = WM8962_IRQ_POL; + } else { + trigger = IRQF_TRIGGER_HIGH; + irq_pol = 0; + } + + snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL, + WM8962_IRQ_POL, irq_pol); + + ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq, + trigger | IRQF_ONESHOT, + "wm8962", codec->dev); + if (ret != 0) { + dev_err(codec->dev, "Failed to request IRQ %d: %d\n", + wm8962->irq, ret); + wm8962->irq = 0; + /* Non-fatal */ + } else { + /* Enable some IRQs by default */ + snd_soc_update_bits(codec, + WM8962_INTERRUPT_STATUS_2_MASK, + WM8962_FLL_LOCK_EINT | + WM8962_TEMP_SHUT_EINT | + WM8962_FIFOS_ERR_EINT, 0); + } + } + return 0; } @@ -3451,6 +3544,9 @@ static int wm8962_remove(struct snd_soc_codec *codec) struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); int i; + if (wm8962->irq) + free_irq(wm8962->irq, codec); + cancel_delayed_work_sync(&wm8962->mic_work); wm8962_free_gpio(codec); @@ -3523,7 +3619,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev); struct wm8962_priv *wm8962; unsigned int reg; - int ret, i, irq_pol, trigger; + int ret, i; wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv), GFP_KERNEL); @@ -3608,77 +3704,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, goto err_enable; } - /* SYSCLK defaults to on; make sure it is off so we can safely - * write to registers if the device is declocked. - */ - regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, - WM8962_SYSCLK_ENA, 0); - - /* Ensure we have soft control over all registers */ - regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, - WM8962_CLKREG_OVD, WM8962_CLKREG_OVD); - - /* Ensure that the oscillator and PLLs are disabled */ - regmap_update_bits(wm8962->regmap, WM8962_PLL2, - WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA, - 0); - - /* Apply static configuration for GPIOs */ - for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++) - if (wm8962->pdata.gpio_init[i]) { - wm8962_set_gpio_mode(wm8962, i + 1); - regmap_write(wm8962->regmap, 0x200 + i, - wm8962->pdata.gpio_init[i] & 0xffff); - } - - - /* Put the speakers into mono mode? */ - if (wm8962->pdata.spk_mono) - regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2, - WM8962_SPK_MONO_MASK, WM8962_SPK_MONO); - - /* Micbias setup, detection enable and detection - * threasholds. */ - if (wm8962->pdata.mic_cfg) - regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4, - WM8962_MICDET_ENA | - WM8962_MICDET_THR_MASK | - WM8962_MICSHORT_THR_MASK | - WM8962_MICBIAS_LVL, - wm8962->pdata.mic_cfg); - - /* Latch volume update bits */ - regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME, - WM8962_IN_VU, WM8962_IN_VU); - regmap_update_bits(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, - WM8962_IN_VU, WM8962_IN_VU); - regmap_update_bits(wm8962->regmap, WM8962_LEFT_ADC_VOLUME, - WM8962_ADC_VU, WM8962_ADC_VU); - regmap_update_bits(wm8962->regmap, WM8962_RIGHT_ADC_VOLUME, - WM8962_ADC_VU, WM8962_ADC_VU); - regmap_update_bits(wm8962->regmap, WM8962_LEFT_DAC_VOLUME, - WM8962_DAC_VU, WM8962_DAC_VU); - regmap_update_bits(wm8962->regmap, WM8962_RIGHT_DAC_VOLUME, - WM8962_DAC_VU, WM8962_DAC_VU); - regmap_update_bits(wm8962->regmap, WM8962_SPKOUTL_VOLUME, - WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); - regmap_update_bits(wm8962->regmap, WM8962_SPKOUTR_VOLUME, - WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); - regmap_update_bits(wm8962->regmap, WM8962_HPOUTL_VOLUME, - WM8962_HPOUT_VU, WM8962_HPOUT_VU); - regmap_update_bits(wm8962->regmap, WM8962_HPOUTR_VOLUME, - WM8962_HPOUT_VU, WM8962_HPOUT_VU); - - /* Stereo control for EQ */ - regmap_update_bits(wm8962->regmap, WM8962_EQ1, - WM8962_EQ_SHARED_COEFF, 0); - - /* Don't debouce interrupts so we don't need SYSCLK */ - regmap_update_bits(wm8962->regmap, WM8962_IRQ_DEBOUNCE, - WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB | - WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB, - 0); - if (wm8962->pdata.in4_dc_measure) { ret = regmap_register_patch(wm8962->regmap, wm8962_dc_measure, @@ -3689,37 +3714,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, ret); } - if (wm8962->irq) { - if (wm8962->pdata.irq_active_low) { - trigger = IRQF_TRIGGER_LOW; - irq_pol = WM8962_IRQ_POL; - } else { - trigger = IRQF_TRIGGER_HIGH; - irq_pol = 0; - } - - regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL, - WM8962_IRQ_POL, irq_pol); - - ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL, - wm8962_irq, - trigger | IRQF_ONESHOT, - "wm8962", &i2c->dev); - if (ret != 0) { - dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", - wm8962->irq, ret); - wm8962->irq = 0; - /* Non-fatal */ - } else { - /* Enable some IRQs by default */ - regmap_update_bits(wm8962->regmap, - WM8962_INTERRUPT_STATUS_2_MASK, - WM8962_FLL_LOCK_EINT | - WM8962_TEMP_SHUT_EINT | - WM8962_FIFOS_ERR_EINT, 0); - } - } - pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); @@ -3728,8 +3722,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, if (ret < 0) goto err_enable; - regcache_cache_only(wm8962->regmap, true); - /* The drivers should power up as needed */ regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 4f05fb8..253c88b 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -1259,8 +1259,6 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); - - codec->cache_sync = 1; break; } diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 1a7655b..46fe83d 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -438,8 +438,6 @@ static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); int block = wm8996_get_retune_mobile_block(kcontrol->id.name); - if (block < 0) - return block; ucontrol->value.enumerated.item[0] = wm8996->retune_mobile_cfg[block]; return 0; @@ -610,7 +608,7 @@ static int bg_event(struct snd_soc_dapm_widget *w, wm8996_bg_disable(codec); break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); ret = -EINVAL; } @@ -627,7 +625,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, msleep(5); break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); ret = -EINVAL; } @@ -648,7 +646,7 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w, wm8996->hpout_pending |= w->shift; break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } @@ -769,7 +767,7 @@ static int dcs_start(struct snd_soc_dapm_widget *w, wm8996->dcs_pending |= 1 << w->shift; break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); return -EINVAL; } @@ -1658,7 +1656,7 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) lrclk_rx_reg = WM8996_AIF2_RX_LRCLK_2; break; default: - WARN(1, "Invalid dai id %d\n", dai->id); + BUG(); return -EINVAL; } @@ -1770,7 +1768,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, dsp_shift = WM8996_DSP2_DIV_SHIFT; break; default: - WARN(1, "Invalid dai id %d\n", dai->id); + BUG(); return -EINVAL; } diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 1392bb3..6ec3de3 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -170,13 +170,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), -SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, +SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, ARIZONA_EQ1_ENA_MASK), -SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, +SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, ARIZONA_EQ2_ENA_MASK), -SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, +SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, ARIZONA_EQ3_ENA_MASK), -SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, +SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, ARIZONA_EQ4_ENA_MASK), SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, @@ -887,7 +887,7 @@ static const struct snd_soc_dapm_route wm8997_dapm_routes[] = { ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Mic"), ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), - ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), + ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC2INT2"), ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index acea892..a53e175 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -221,8 +221,7 @@ static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, struct snd_soc_codec *codec = w->codec; u16 status, rate; - if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) - return -EINVAL; + BUG_ON(event != SND_SOC_DAPM_PRE_PMD); /* Gracefully shut down the voice interface. */ status = ac97_read(codec, AC97_EXTENDED_MID) | 0x1000; diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 46ec0e9..b38f350 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -341,8 +341,6 @@ static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region, unsigned int offset) { - if (WARN_ON(!region)) - return offset; switch (region->type) { case WMFW_ADSP1_PM: return region->base + (offset * 3); @@ -355,7 +353,7 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region, case WMFW_ADSP1_ZM: return region->base + (offset * 2); default: - WARN(1, "Unknown memory region type"); + WARN_ON(NULL != "Unknown memory region type"); return offset; } } @@ -398,12 +396,11 @@ static int wm_coeff_write_control(struct snd_kcontrol *kcontrol, ret = regmap_raw_write(adsp->regmap, reg, scratch, ctl->len); if (ret) { - adsp_err(adsp, "Failed to write %zu bytes to %x: %d\n", - ctl->len, reg, ret); + adsp_err(adsp, "Failed to write %zu bytes to %x\n", + ctl->len, reg); kfree(scratch); return ret; } - adsp_dbg(adsp, "Wrote %zu bytes to %x\n", ctl->len, reg); kfree(scratch); @@ -453,12 +450,11 @@ static int wm_coeff_read_control(struct snd_kcontrol *kcontrol, ret = regmap_raw_read(adsp->regmap, reg, scratch, ctl->len); if (ret) { - adsp_err(adsp, "Failed to read %zu bytes from %x: %d\n", - ctl->len, reg, ret); + adsp_err(adsp, "Failed to read %zu bytes from %x\n", + ctl->len, reg); kfree(scratch); return ret; } - adsp_dbg(adsp, "Read %zu bytes from %x\n", ctl->len, reg); memcpy(buf, scratch, ctl->len); kfree(scratch); @@ -572,7 +568,6 @@ static int wm_adsp_load(struct wm_adsp *dsp) file, header->ver); goto out_fw; } - adsp_info(dsp, "Firmware version: %d\n", header->ver); if (header->core != dsp->type) { adsp_err(dsp, "%s: invalid core %d != %d\n", @@ -607,7 +602,7 @@ static int wm_adsp_load(struct wm_adsp *dsp) break; default: - WARN(1, "Unknown DSP type"); + BUG_ON(NULL == "Unknown DSP type"); goto out_fw; } @@ -647,22 +642,27 @@ static int wm_adsp_load(struct wm_adsp *dsp) reg = offset; break; case WMFW_ADSP1_PM: + BUG_ON(!mem); region_name = "PM"; reg = wm_adsp_region_to_reg(mem, offset); break; case WMFW_ADSP1_DM: + BUG_ON(!mem); region_name = "DM"; reg = wm_adsp_region_to_reg(mem, offset); break; case WMFW_ADSP2_XM: + BUG_ON(!mem); region_name = "XM"; reg = wm_adsp_region_to_reg(mem, offset); break; case WMFW_ADSP2_YM: + BUG_ON(!mem); region_name = "YM"; reg = wm_adsp_region_to_reg(mem, offset); break; case WMFW_ADSP1_ZM: + BUG_ON(!mem); region_name = "ZM"; reg = wm_adsp_region_to_reg(mem, offset); break; @@ -689,8 +689,7 @@ static int wm_adsp_load(struct wm_adsp *dsp) &buf_list); if (!buf) { adsp_err(dsp, "Out of memory\n"); - ret = -ENOMEM; - goto out_fw; + return -ENOMEM; } ret = regmap_raw_write_async(regmap, reg, buf->buf, @@ -902,8 +901,10 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) break; } - if (WARN_ON(!mem)) + if (mem == NULL) { + BUG_ON(mem != NULL); return -EINVAL; + } switch (dsp->type) { case WMFW_ADSP1: @@ -997,7 +998,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) break; default: - WARN(1, "Unknown DSP type"); + BUG_ON(NULL == "Unknown DSP type"); return -EINVAL; } @@ -1061,7 +1062,6 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) if (i + 1 < algs) { region->len = be32_to_cpu(adsp1_alg[i + 1].dm); region->len -= be32_to_cpu(adsp1_alg[i].dm); - region->len *= 4; wm_adsp_create_control(dsp, region); } else { adsp_warn(dsp, "Missing length info for region DM with ID %x\n", @@ -1079,7 +1079,6 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) if (i + 1 < algs) { region->len = be32_to_cpu(adsp1_alg[i + 1].zm); region->len -= be32_to_cpu(adsp1_alg[i].zm); - region->len *= 4; wm_adsp_create_control(dsp, region); } else { adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", @@ -1109,7 +1108,6 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) if (i + 1 < algs) { region->len = be32_to_cpu(adsp2_alg[i + 1].xm); region->len -= be32_to_cpu(adsp2_alg[i].xm); - region->len *= 4; wm_adsp_create_control(dsp, region); } else { adsp_warn(dsp, "Missing length info for region XM with ID %x\n", @@ -1127,7 +1125,6 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) if (i + 1 < algs) { region->len = be32_to_cpu(adsp2_alg[i + 1].ym); region->len -= be32_to_cpu(adsp2_alg[i].ym); - region->len *= 4; wm_adsp_create_control(dsp, region); } else { adsp_warn(dsp, "Missing length info for region YM with ID %x\n", @@ -1145,7 +1142,6 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) if (i + 1 < algs) { region->len = be32_to_cpu(adsp2_alg[i + 1].zm); region->len -= be32_to_cpu(adsp2_alg[i].zm); - region->len *= 4; wm_adsp_create_control(dsp, region); } else { adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", @@ -1317,8 +1313,8 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) le32_to_cpu(blk->len)); if (ret != 0) { adsp_err(dsp, - "%s.%d: Failed to write to %x in %s: %d\n", - file, blocks, reg, region_name, ret); + "%s.%d: Failed to write to %x in %s\n", + file, blocks, reg, region_name); } } @@ -1362,7 +1358,6 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_soc_codec *codec = w->codec; struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); struct wm_adsp *dsp = &dsps[w->shift]; - struct wm_adsp_alg_region *alg_region; struct wm_coeff_ctl *ctl; int ret; int val; @@ -1440,14 +1435,6 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, list_for_each_entry(ctl, &dsp->ctl_list, list) ctl->enabled = 0; - - while (!list_empty(&dsp->alg_regions)) { - alg_region = list_first_entry(&dsp->alg_regions, - struct wm_adsp_alg_region, - list); - list_del(&alg_region->list); - kfree(alg_region); - } break; default: diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index b371066..01daf65 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -611,7 +611,7 @@ static int earpiece_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Invalid event %d\n", event); + BUG(); break; } diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index 95970f5..c82f89c 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig @@ -1,10 +1,9 @@ config SND_DAVINCI_SOC - tristate "SoC Audio for the TI DAVINCI or AM33XX chip" - depends on ARCH_DAVINCI || SOC_AM33XX + tristate "SoC Audio for the TI DAVINCI chip" + depends on ARCH_DAVINCI help - Platform driver for daVinci or AM33xx Say Y or M if you want to add support for codecs attached to - the DAVINCI AC97, I2S, or McASP interface. You will also need + the DAVINCI AC97 or I2S interface. You will also need to select the audio interfaces to support below. config SND_DAVINCI_SOC_I2S @@ -16,17 +15,6 @@ config SND_DAVINCI_SOC_MCASP config SND_DAVINCI_SOC_VCIF tristate -config SND_AM33XX_SOC_EVM - tristate "SoC Audio for the AM33XX chip based boards" - depends on SND_DAVINCI_SOC && SOC_AM33XX - select SND_SOC_TLV320AIC3X - select SND_DAVINCI_SOC_MCASP - help - Say Y or M if you want to add support for SoC audio on AM33XX - boards using McASP and TLV320AIC3X codec. For example AM335X-EVM, - AM335X-EVMSK, and BeagelBone with AudioCape boards have this - setup. - config SND_DAVINCI_SOC_EVM tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" depends on SND_DAVINCI_SOC diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile index bc81e79..a396ab6 100644 --- a/sound/soc/davinci/Makefile +++ b/sound/soc/davinci/Makefile @@ -13,7 +13,6 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o snd-soc-evm-objs := davinci-evm.o obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o -obj-$(CONFIG_SND_AM33XX_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 623eb5e..fd7c45b 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -16,7 +16,6 @@ #include <linux/platform_device.h> #include <linux/platform_data/edma.h> #include <linux/i2c.h> -#include <linux/of_platform.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> @@ -24,16 +23,10 @@ #include <asm/dma.h> #include <asm/mach-types.h> -#include <linux/edma.h> - #include "davinci-pcm.h" #include "davinci-i2s.h" #include "davinci-mcasp.h" -struct snd_soc_card_drvdata_davinci { - unsigned sysclk; -}; - #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) static int evm_hw_params(struct snd_pcm_substream *substream, @@ -42,11 +35,27 @@ static int evm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_card *soc_card = codec->card; int ret = 0; - unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) - snd_soc_card_get_drvdata(soc_card))->sysclk; + unsigned sysclk; + + /* ASP1 on DM355 EVM is clocked by an external oscillator */ + if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() || + machine_is_davinci_dm365_evm()) + sysclk = 27000000; + + /* ASP0 in DM6446 EVM is clocked by U55, as configured by + * board-dm644x-evm.c using GPIOs from U18. There are six + * options; here we "know" we use a 48 KHz sample rate. + */ + else if (machine_is_davinci_evm()) + sysclk = 12288000; + + else if (machine_is_davinci_da830_evm() || + machine_is_davinci_da850_evm()) + sysclk = 24576000; + + else + return -EINVAL; /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); @@ -124,22 +133,13 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; - struct device_node *np = codec->card->dev->of_node; - int ret; /* Add davinci-evm specific widgets */ snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, ARRAY_SIZE(aic3x_dapm_widgets)); - if (np) { - ret = snd_soc_of_parse_audio_routing(codec->card, - "ti,audio-routing"); - if (ret) - return ret; - } else { - /* Set up davinci-evm specific audio path audio_map */ - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - } + /* Set up davinci-evm specific audio path audio_map */ + snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); /* not connected */ snd_soc_dapm_disable_pin(dapm, "MONO_LOUT"); @@ -243,65 +243,35 @@ static struct snd_soc_dai_link da850_evm_dai = { }; /* davinci dm6446 evm audio machine driver */ -/* - * ASP0 in DM6446 EVM is clocked by U55, as configured by - * board-dm644x-evm.c using GPIOs from U18. There are six - * options; here we "know" we use a 48 KHz sample rate. - */ -static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = { - .sysclk = 12288000, -}; - static struct snd_soc_card dm6446_snd_soc_card_evm = { .name = "DaVinci DM6446 EVM", .owner = THIS_MODULE, .dai_link = &dm6446_evm_dai, .num_links = 1, - .drvdata = &dm6446_snd_soc_card_drvdata, }; /* davinci dm355 evm audio machine driver */ -/* ASP1 on DM355 EVM is clocked by an external oscillator */ -static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = { - .sysclk = 27000000, -}; - static struct snd_soc_card dm355_snd_soc_card_evm = { .name = "DaVinci DM355 EVM", .owner = THIS_MODULE, .dai_link = &dm355_evm_dai, .num_links = 1, - .drvdata = &dm355_snd_soc_card_drvdata, }; /* davinci dm365 evm audio machine driver */ -static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = { - .sysclk = 27000000, -}; - static struct snd_soc_card dm365_snd_soc_card_evm = { .name = "DaVinci DM365 EVM", .owner = THIS_MODULE, .dai_link = &dm365_evm_dai, .num_links = 1, - .drvdata = &dm365_snd_soc_card_drvdata, }; /* davinci dm6467 evm audio machine driver */ -static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = { - .sysclk = 27000000, -}; - static struct snd_soc_card dm6467_snd_soc_card_evm = { .name = "DaVinci DM6467 EVM", .owner = THIS_MODULE, .dai_link = dm6467_evm_dai, .num_links = ARRAY_SIZE(dm6467_evm_dai), - .drvdata = &dm6467_snd_soc_card_drvdata, -}; - -static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = { - .sysclk = 24576000, }; static struct snd_soc_card da830_snd_soc_card = { @@ -309,11 +279,6 @@ static struct snd_soc_card da830_snd_soc_card = { .owner = THIS_MODULE, .dai_link = &da830_evm_dai, .num_links = 1, - .drvdata = &da830_snd_soc_card_drvdata, -}; - -static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = { - .sysclk = 24576000, }; static struct snd_soc_card da850_snd_soc_card = { @@ -321,101 +286,8 @@ static struct snd_soc_card da850_snd_soc_card = { .owner = THIS_MODULE, .dai_link = &da850_evm_dai, .num_links = 1, - .drvdata = &da850_snd_soc_card_drvdata, -}; - -#if defined(CONFIG_OF) - -/* - * The struct is used as place holder. It will be completely - * filled with data from dt node. - */ -static struct snd_soc_dai_link evm_dai_tlv320aic3x = { - .name = "TLV320AIC3X", - .stream_name = "AIC3X", - .codec_dai_name = "tlv320aic3x-hifi", - .ops = &evm_ops, - .init = evm_aic3x_init, -}; - -static const struct of_device_id davinci_evm_dt_ids[] = { - { - .compatible = "ti,da830-evm-audio", - .data = (void *) &evm_dai_tlv320aic3x, - }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, davinci_evm_dt_ids); - -/* davinci evm audio machine driver */ -static struct snd_soc_card evm_soc_card = { - .owner = THIS_MODULE, - .num_links = 1, }; -static int davinci_evm_probe(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - const struct of_device_id *match = - of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); - struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data; - struct snd_soc_card_drvdata_davinci *drvdata = NULL; - int ret = 0; - - evm_soc_card.dai_link = dai; - - dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0); - if (!dai->codec_of_node) - return -EINVAL; - - dai->cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0); - if (!dai->cpu_of_node) - return -EINVAL; - - dai->platform_of_node = dai->cpu_of_node; - - evm_soc_card.dev = &pdev->dev; - ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model"); - if (ret) - return ret; - - drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - - ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk); - if (ret < 0) - return -EINVAL; - - snd_soc_card_set_drvdata(&evm_soc_card, drvdata); - ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card); - - if (ret) - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - - return ret; -} - -static int davinci_evm_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - - snd_soc_unregister_card(card); - - return 0; -} - -static struct platform_driver davinci_evm_driver = { - .probe = davinci_evm_probe, - .remove = davinci_evm_remove, - .driver = { - .name = "davinci_evm", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(davinci_evm_dt_ids), - }, -}; -#endif - static struct platform_device *evm_snd_device; static int __init evm_init(void) @@ -424,15 +296,6 @@ static int __init evm_init(void) int index; int ret; - /* - * If dtb is there, the devices will be created dynamically. - * Only register platfrom driver structure. - */ -#if defined(CONFIG_OF) - if (of_have_populated_dt()) - return platform_driver_register(&davinci_evm_driver); -#endif - if (machine_is_davinci_evm()) { evm_snd_dev_data = &dm6446_snd_soc_card_evm; index = 0; @@ -468,13 +331,6 @@ static int __init evm_init(void) static void __exit evm_exit(void) { -#if defined(CONFIG_OF) - if (of_have_populated_dt()) { - platform_driver_unregister(&davinci_evm_driver); - return; - } -#endif - platform_device_unregister(evm_snd_device); } diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 71e14bb3..32ddb7f 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1001,40 +1001,18 @@ static const struct snd_soc_component_driver davinci_mcasp_component = { .name = "davinci-mcasp", }; -/* Some HW specific values and defaults. The rest is filled in from DT. */ -static struct snd_platform_data dm646x_mcasp_pdata = { - .tx_dma_offset = 0x400, - .rx_dma_offset = 0x400, - .asp_chan_q = EVENTQ_0, - .version = MCASP_VERSION_1, -}; - -static struct snd_platform_data da830_mcasp_pdata = { - .tx_dma_offset = 0x2000, - .rx_dma_offset = 0x2000, - .asp_chan_q = EVENTQ_0, - .version = MCASP_VERSION_2, -}; - -static struct snd_platform_data omap2_mcasp_pdata = { - .tx_dma_offset = 0, - .rx_dma_offset = 0, - .asp_chan_q = EVENTQ_0, - .version = MCASP_VERSION_3, -}; - static const struct of_device_id mcasp_dt_ids[] = { { .compatible = "ti,dm646x-mcasp-audio", - .data = &dm646x_mcasp_pdata, + .data = (void *)MCASP_VERSION_1, }, { .compatible = "ti,da830-mcasp-audio", - .data = &da830_mcasp_pdata, + .data = (void *)MCASP_VERSION_2, }, { - .compatible = "ti,am33xx-mcasp-audio", - .data = &omap2_mcasp_pdata, + .compatible = "ti,omap2-mcasp-audio", + .data = (void *)MCASP_VERSION_3, }, { /* sentinel */ } }; @@ -1047,9 +1025,9 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( struct snd_platform_data *pdata = NULL; const struct of_device_id *match = of_match_device(mcasp_dt_ids, &pdev->dev); - struct of_phandle_args dma_spec; const u32 *of_serial_dir32; + u8 *of_serial_dir; u32 val; int i, ret = 0; @@ -1057,13 +1035,20 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( pdata = pdev->dev.platform_data; return pdata; } else if (match) { - pdata = (struct snd_platform_data *) match->data; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + ret = -ENOMEM; + goto nodata; + } } else { /* control shouldn't reach here. something is wrong */ ret = -EINVAL; goto nodata; } + if (match->data) + pdata->version = (u8)((int)match->data); + ret = of_property_read_u32(np, "op-mode", &val); if (ret >= 0) pdata->op_mode = val; @@ -1080,46 +1065,35 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( pdata->tdm_slots = val; } + ret = of_property_read_u32(np, "num-serializer", &val); + if (ret >= 0) + pdata->num_serializer = val; + of_serial_dir32 = of_get_property(np, "serial-dir", &val); val /= sizeof(u32); + if (val != pdata->num_serializer) { + dev_err(&pdev->dev, + "num-serializer(%d) != serial-dir size(%d)\n", + pdata->num_serializer, val); + ret = -EINVAL; + goto nodata; + } + if (of_serial_dir32) { - u8 *of_serial_dir = devm_kzalloc(&pdev->dev, - (sizeof(*of_serial_dir) * val), - GFP_KERNEL); + of_serial_dir = devm_kzalloc(&pdev->dev, + (sizeof(*of_serial_dir) * val), + GFP_KERNEL); if (!of_serial_dir) { ret = -ENOMEM; goto nodata; } - for (i = 0; i < val; i++) + for (i = 0; i < pdata->num_serializer; i++) of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]); - pdata->num_serializer = val; pdata->serial_dir = of_serial_dir; } - ret = of_property_match_string(np, "dma-names", "tx"); - if (ret < 0) - goto nodata; - - ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, - &dma_spec); - if (ret < 0) - goto nodata; - - pdata->tx_dma_channel = dma_spec.args[0]; - - ret = of_property_match_string(np, "dma-names", "rx"); - if (ret < 0) - goto nodata; - - ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, - &dma_spec); - if (ret < 0) - goto nodata; - - pdata->rx_dma_channel = dma_spec.args[0]; - ret = of_property_read_u32(np, "tx-num-evt", &val); if (ret >= 0) pdata->txnumevt = val; @@ -1150,7 +1124,7 @@ nodata: static int davinci_mcasp_probe(struct platform_device *pdev) { struct davinci_pcm_dma_params *dma_data; - struct resource *mem, *ioarea, *res, *dat; + struct resource *mem, *ioarea, *res; struct snd_platform_data *pdata; struct davinci_audio_dev *dev; int ret; @@ -1171,15 +1145,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev) return -EINVAL; } - mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { - dev_warn(dev->dev, - "\"mpu\" mem resource not found, using index 0\n"); - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) { - dev_err(&pdev->dev, "no mem resource?\n"); - return -ENODEV; - } + dev_err(&pdev->dev, "no mem resource?\n"); + return -ENODEV; } ioarea = devm_request_mem_region(&pdev->dev, mem->start, @@ -1213,36 +1182,40 @@ static int davinci_mcasp_probe(struct platform_device *pdev) dev->rxnumevt = pdata->rxnumevt; dev->dev = &pdev->dev; - dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); - if (!dat) - dat = mem; - dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; dma_data->asp_chan_q = pdata->asp_chan_q; dma_data->ram_chan_q = pdata->ram_chan_q; dma_data->sram_pool = pdata->sram_pool; dma_data->sram_size = pdata->sram_size_playback; - dma_data->dma_addr = dat->start + pdata->tx_dma_offset; + dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset + + mem->start); + /* first TX, then RX */ res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (res) - dma_data->channel = res->start; - else - dma_data->channel = pdata->tx_dma_channel; + if (!res) { + dev_err(&pdev->dev, "no DMA resource\n"); + ret = -ENODEV; + goto err_release_clk; + } + + dma_data->channel = res->start; dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; dma_data->asp_chan_q = pdata->asp_chan_q; dma_data->ram_chan_q = pdata->ram_chan_q; dma_data->sram_pool = pdata->sram_pool; dma_data->sram_size = pdata->sram_size_capture; - dma_data->dma_addr = dat->start + pdata->rx_dma_offset; + dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset + + mem->start); res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (res) - dma_data->channel = res->start; - else - dma_data->channel = pdata->rx_dma_channel; + if (!res) { + dev_err(&pdev->dev, "no DMA resource\n"); + ret = -ENODEV; + goto err_release_clk; + } + dma_data->channel = res->start; dev_set_drvdata(&pdev->dev, dev); ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, &davinci_mcasp_dai[pdata->op_mode], 1); @@ -1278,51 +1251,12 @@ static int davinci_mcasp_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int davinci_mcasp_suspend(struct device *dev) -{ - struct davinci_audio_dev *a = dev_get_drvdata(dev); - void __iomem *base = a->base; - - a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG); - a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG); - a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG); - a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG); - a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG); - a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG); - a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG); - - return 0; -} - -static int davinci_mcasp_resume(struct device *dev) -{ - struct davinci_audio_dev *a = dev_get_drvdata(dev); - void __iomem *base = a->base; - - mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl); - mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl); - mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt); - mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt); - mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl); - mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl); - mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir); - - return 0; -} -#endif - -SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops, - davinci_mcasp_suspend, - davinci_mcasp_resume); - static struct platform_driver davinci_mcasp_driver = { .probe = davinci_mcasp_probe, .remove = davinci_mcasp_remove, .driver = { .name = "davinci-mcasp", .owner = THIS_MODULE, - .pm = &davinci_mcasp_pm_ops, .of_match_table = mcasp_dt_ids, }, }; @@ -1332,3 +1266,4 @@ module_platform_driver(davinci_mcasp_driver); MODULE_AUTHOR("Steve Chen"); MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface"); MODULE_LICENSE("GPL"); + diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index a2e27e1..a9ac0c1 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -43,18 +43,6 @@ struct davinci_audio_dev { /* McASP FIFO related */ u8 txnumevt; u8 rxnumevt; - -#ifdef CONFIG_PM_SLEEP - struct { - u32 txfmtctl; - u32 rxfmtctl; - u32 txfmt; - u32 rxfmt; - u32 aclkxctl; - u32 aclkrctl; - u32 pdir; - } context; -#endif }; #endif /* DAVINCI_MCASP_H */ diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index fb5d107..8460edc 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -238,7 +238,7 @@ static void davinci_pcm_dma_irq(unsigned link, u16 ch_status, void *data) print_buf_info(prtd->ram_channel, "i ram_channel"); pr_debug("davinci_pcm: link=%d, status=0x%x\n", link, ch_status); - if (unlikely(ch_status != EDMA_DMA_COMPLETE)) + if (unlikely(ch_status != DMA_COMPLETE)) return; if (snd_pcm_running(substream)) { @@ -267,9 +267,10 @@ static int allocate_sram(struct snd_pcm_substream *substream, return 0; ppcm->period_bytes_max = size; - iram_virt = gen_pool_dma_alloc(sram_pool, size, &iram_phys); + iram_virt = (void *)gen_pool_alloc(sram_pool, size); if (!iram_virt) goto exit1; + iram_phys = gen_pool_virt_to_phys(sram_pool, (unsigned)iram_virt); iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL); if (!iram_dma) goto exit2; @@ -843,15 +844,18 @@ static void davinci_pcm_free(struct snd_pcm *pcm) } } +static u64 davinci_pcm_dmamask = DMA_BIT_MASK(32); + static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; int ret; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &davinci_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = davinci_pcm_preallocate_dma_buffer(pcm, diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c index 5983740..9a4a0ca 100644 --- a/sound/soc/fsl/eukrea-tlv320.c +++ b/sound/soc/fsl/eukrea-tlv320.c @@ -42,8 +42,7 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); if (ret) { - dev_err(cpu_dai->dev, - "Failed to set the cpu dai format.\n"); + pr_err("%s: failed set cpu dai format\n", __func__); return ret; } @@ -51,16 +50,14 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); if (ret) { - dev_err(cpu_dai->dev, - "Failed to set the codec format.\n"); + pr_err("%s: failed set codec dai format\n", __func__); return ret; } ret = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, SND_SOC_CLOCK_OUT); if (ret) { - dev_err(cpu_dai->dev, - "Failed to set the codec sysclk.\n"); + pr_err("%s: failed setting codec sysclk\n", __func__); return ret; } snd_soc_dai_set_tdm_slot(cpu_dai, 0xffffffc, 0xffffffc, 2, 0); @@ -68,8 +65,7 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0, SND_SOC_CLOCK_IN); if (ret) { - dev_err(cpu_dai->dev, - "Can't set the IMX_SSP_SYS_CLK CPU system clock.\n"); + pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n"); return ret; } @@ -159,8 +155,7 @@ static struct platform_driver eukrea_tlv320_driver = { .owner = THIS_MODULE, }, .probe = eukrea_tlv320_probe, - .remove = eukrea_tlv320_remove, -}; + .remove = eukrea_tlv320_remove,}; module_platform_driver(eukrea_tlv320_driver); diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index fb9bb9e..9cc5c1f 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -21,8 +21,6 @@ #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/gfp.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> #include <linux/of_platform.h> #include <linux/list.h> #include <linux/slab.h> @@ -300,11 +298,14 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; + static u64 fsl_dma_dmamask = DMA_BIT_MASK(36); int ret; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(36)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &fsl_dma_dmamask; + + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = fsl_dma_dmamask; /* Some codecs have separate DAIs for playback and capture, so we * should allocate a DMA buffer only for the streams that are valid. diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 55193a5..3920c3e 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -963,7 +963,7 @@ static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) @@ -982,7 +982,7 @@ static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static const struct regmap_config fsl_spdif_regmap_config = { @@ -1107,6 +1107,11 @@ static int fsl_spdif_probe(struct platform_device *pdev) /* Get the addresses and IRQ */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (IS_ERR(res)) { + dev_err(&pdev->dev, "could not determine device resources\n"); + return PTR_ERR(res); + } + regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(regs)) return PTR_ERR(regs); @@ -1167,16 +1172,23 @@ static int fsl_spdif_probe(struct platform_device *pdev) /* Register with ASoC */ dev_set_drvdata(&pdev->dev, spdif_priv); - ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component, - &spdif_priv->cpu_dai_drv, 1); + ret = snd_soc_register_component(&pdev->dev, &fsl_spdif_component, + &spdif_priv->cpu_dai_drv, 1); if (ret) { dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); return ret; } ret = imx_pcm_dma_init(pdev); - if (ret) + if (ret) { dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret); + goto error_component; + } + + return ret; + +error_component: + snd_soc_unregister_component(&pdev->dev); return ret; } @@ -1184,6 +1196,7 @@ static int fsl_spdif_probe(struct platform_device *pdev) static int fsl_spdif_remove(struct platform_device *pdev) { imx_pcm_dma_exit(pdev); + snd_soc_unregister_component(&pdev->dev); return 0; } diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 35e2773..6b81d0c 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -469,12 +469,19 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * parameters, then the second stream may be * constrained to the wrong sample rate or size. */ - if (first_runtime->sample_bits) { - snd_pcm_hw_constraint_minmax(substream->runtime, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, + if (!first_runtime->sample_bits) { + dev_err(substream->pcm->card->dev, + "set sample size in %s stream first\n", + substream->stream == + SNDRV_PCM_STREAM_PLAYBACK + ? "capture" : "playback"); + return -EAGAIN; + } + + snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_SAMPLE_BITS, first_runtime->sample_bits, first_runtime->sample_bits); - } } ssi_private->second_stream = substream; @@ -741,7 +748,7 @@ static void fsl_ssi_ac97_init(void) fsl_ssi_setup(fsl_ac97_data); } -static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, +void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct ccsr_ssi *ssi = fsl_ac97_data->ssi; @@ -763,7 +770,7 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, udelay(100); } -static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, +unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct ccsr_ssi *ssi = fsl_ac97_data->ssi; @@ -929,7 +936,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) ssi_private->ssi_phys = res.start; ssi_private->irq = irq_of_parse_and_map(np, 0); - if (!ssi_private->irq) { + if (ssi_private->irq == 0) { dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); return -ENXIO; } @@ -1128,6 +1135,7 @@ static int fsl_ssi_remove(struct platform_device *pdev) if (ssi_private->ssi_on_imx) imx_pcm_dma_exit(pdev); snd_soc_unregister_component(&pdev->dev); + dev_set_drvdata(&pdev->dev, NULL); device_remove_file(&pdev->dev, &ssi_private->dev_attr); if (ssi_private->ssi_on_imx) clk_disable_unprepare(ssi_private->clk); diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index ac86993..d3bf71a 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c @@ -66,10 +66,13 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { ssize_t ret; - char *buf; + char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); int port = (int)file->private_data; u32 pdcr, ptcr; + if (!buf) + return -ENOMEM; + if (audmux_clk) { ret = clk_prepare_enable(audmux_clk); if (ret) @@ -82,10 +85,6 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, if (audmux_clk) clk_disable_unprepare(audmux_clk); - buf = kmalloc(PAGE_SIZE, GFP_KERNEL); - if (!buf) - return -ENOMEM; - ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", pdcr, ptcr); diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c index 79cee78..a2fd732 100644 --- a/sound/soc/fsl/imx-mc13783.c +++ b/sound/soc/fsl/imx-mc13783.c @@ -160,7 +160,6 @@ static struct platform_driver imx_mc13783_audio_driver = { .driver = { .name = "imx_mc13783", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = imx_mc13783_probe, .remove = imx_mc13783_remove diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index aee2307..4dc1296 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c @@ -25,10 +25,12 @@ static bool filter(struct dma_chan *chan, void *param) { + struct snd_dmaengine_dai_dma_data *dma_data = param; + if (!imx_dma_is_general_purpose(chan)) return false; - chan->private = param; + chan->private = dma_data->filter_data; return true; } diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index c75d43b..34043c5 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -39,11 +39,12 @@ struct imx_pcm_runtime_data { unsigned int period; int periods; unsigned long offset; + unsigned long last_offset; + unsigned long size; struct hrtimer hrt; int poll_time_ns; struct snd_pcm_substream *substream; - atomic_t playing; - atomic_t capturing; + atomic_t running; }; static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) @@ -51,9 +52,11 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) struct imx_pcm_runtime_data *iprtd = container_of(hrt, struct imx_pcm_runtime_data, hrt); struct snd_pcm_substream *substream = iprtd->substream; + struct snd_pcm_runtime *runtime = substream->runtime; struct pt_regs regs; + unsigned long delta; - if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing)) + if (!atomic_read(&iprtd->running)) return HRTIMER_NORESTART; get_fiq_regs(®s); @@ -63,7 +66,19 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) else iprtd->offset = regs.ARM_r9 & 0xffff; - snd_pcm_period_elapsed(substream); + /* How much data have we transferred since the last period report? */ + if (iprtd->offset >= iprtd->last_offset) + delta = iprtd->offset - iprtd->last_offset; + else + delta = runtime->buffer_size + iprtd->offset + - iprtd->last_offset; + + /* If we've transferred at least a period then report it and + * reset our poll time */ + if (delta >= iprtd->period) { + snd_pcm_period_elapsed(substream); + iprtd->last_offset = iprtd->offset; + } hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns)); @@ -80,9 +95,11 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct imx_pcm_runtime_data *iprtd = runtime->private_data; + iprtd->size = params_buffer_bytes(params); iprtd->periods = params_periods(params); - iprtd->period = params_period_bytes(params); + iprtd->period = params_period_bytes(params) ; iprtd->offset = 0; + iprtd->last_offset = 0; iprtd->poll_time_ns = 1000000000 / params_rate(params) * params_period_size(params); snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); @@ -107,6 +124,7 @@ static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream) return 0; } +static int fiq_enable; static int imx_pcm_fiq; static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) @@ -118,27 +136,23 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - atomic_set(&iprtd->playing, 1); - else - atomic_set(&iprtd->capturing, 1); + atomic_set(&iprtd->running, 1); hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns), HRTIMER_MODE_REL); - enable_fiq(imx_pcm_fiq); + if (++fiq_enable == 1) + enable_fiq(imx_pcm_fiq); + break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - atomic_set(&iprtd->playing, 0); - else - atomic_set(&iprtd->capturing, 0); - if (!atomic_read(&iprtd->playing) && - !atomic_read(&iprtd->capturing)) + atomic_set(&iprtd->running, 0); + + if (--fiq_enable == 0) disable_fiq(imx_pcm_fiq); - break; + break; default: return -EINVAL; } @@ -186,8 +200,7 @@ static int snd_imx_open(struct snd_pcm_substream *substream) iprtd->substream = substream; - atomic_set(&iprtd->playing, 0); - atomic_set(&iprtd->capturing, 0); + atomic_set(&iprtd->running, 0); hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); iprtd->hrt.function = snd_hrtimer_callback; @@ -259,16 +272,18 @@ static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) return 0; } +static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); + static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; - - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + int ret = 0; + if (!card->dev->dma_mask) + card->dev->dma_mask = &imx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = imx_pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index f2beae7..ca1be1d 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); - ret = devm_snd_soc_register_card(&pdev->dev, &data->card); + ret = snd_soc_register_card(&data->card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto fail; @@ -186,6 +186,7 @@ static int imx_sgtl5000_remove(struct platform_device *pdev) { struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); + snd_soc_unregister_card(&data->card); clk_put(data->codec_clk); return 0; @@ -201,7 +202,6 @@ static struct platform_driver imx_sgtl5000_driver = { .driver = { .name = "imx-sgtl5000", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, .of_match_table = imx_sgtl5000_dt_ids, }, .probe = imx_sgtl5000_probe, diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index 8499d52..816013b 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c @@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) if (ret) goto error_dir; - ret = devm_snd_soc_register_card(&pdev->dev, &data->card); + ret = snd_soc_register_card(&data->card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); goto error_dir; @@ -119,6 +119,8 @@ static int imx_spdif_audio_remove(struct platform_device *pdev) if (data->txdev) platform_device_unregister(data->txdev); + snd_soc_unregister_card(&data->card); + return 0; } diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index f5f248c..57d6941 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -613,6 +613,7 @@ static int imx_ssi_probe(struct platform_device *pdev) failed_pcm: snd_soc_unregister_component(&pdev->dev); failed_register: + release_mem_region(res->start, resource_size(res)); clk_disable_unprepare(ssi->clk); failed_clk: snd_soc_set_ac97_ops(NULL); @@ -622,6 +623,7 @@ failed_clk: static int imx_ssi_remove(struct platform_device *pdev) { + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct imx_ssi *ssi = platform_get_drvdata(pdev); if (!ssi->dma_init) @@ -635,6 +637,7 @@ static int imx_ssi_remove(struct platform_device *pdev) if (ssi->flags & IMX_SSI_USE_AC97) ac97_ssi = NULL; + release_mem_region(res->start, resource_size(res)); clk_disable_unprepare(ssi->clk); snd_soc_set_ac97_ops(NULL); diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c index 61e4885..722afe6 100644 --- a/sound/soc/fsl/imx-wm8962.c +++ b/sound/soc/fsl/imx-wm8962.c @@ -215,7 +215,7 @@ static int imx_wm8962_probe(struct platform_device *pdev) goto fail; } codec_dev = of_find_i2c_device_by_node(codec_np); - if (!codec_dev || !codec_dev->dev.driver) { + if (!codec_dev || !codec_dev->driver) { dev_err(&pdev->dev, "failed to find codec platform device\n"); ret = -EINVAL; goto fail; @@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev) data->card.late_probe = imx_wm8962_late_probe; data->card.set_bias_level = imx_wm8962_set_bias_level; - ret = devm_snd_soc_register_card(&pdev->dev, &data->card); + ret = snd_soc_register_card(&data->card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto clk_fail; @@ -279,7 +279,8 @@ static int imx_wm8962_probe(struct platform_device *pdev) return 0; clk_fail: - clk_disable_unprepare(data->codec_clk); + if (!IS_ERR(data->codec_clk)) + clk_disable_unprepare(data->codec_clk); fail: if (ssi_np) of_node_put(ssi_np); @@ -295,6 +296,7 @@ static int imx_wm8962_remove(struct platform_device *pdev) if (!IS_ERR(data->codec_clk)) clk_disable_unprepare(data->codec_clk); + snd_soc_unregister_card(&data->card); return 0; } @@ -309,7 +311,6 @@ static struct platform_driver imx_wm8962_driver = { .driver = { .name = "imx-wm8962", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, .of_match_table = imx_wm8962_dt_ids, }, .probe = imx_wm8962_probe, diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 71bf2f2..2a847ca 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -10,8 +10,6 @@ #include <linux/of_device.h> #include <linux/dma-mapping.h> #include <linux/slab.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> #include <linux/of_platform.h> #include <sound/soc.h> @@ -301,6 +299,7 @@ static struct snd_pcm_ops psc_dma_ops = { .hw_params = psc_dma_hw_params, }; +static u64 psc_dma_dmamask = DMA_BIT_MASK(32); static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; @@ -308,14 +307,15 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) struct snd_pcm *pcm = rtd->pcm; struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); size_t size = psc_dma_hardware.buffer_bytes_max; - int rc; + int rc = 0; dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", card, dai, pcm); - rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (rc) - return rc; + if (!card->dev->dma_mask) + card->dev->dma_mask = &psc_dma_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 24eafa2..3ef7a0c 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -291,7 +291,7 @@ static int psc_ac97_of_probe(struct platform_device *op) rc = snd_soc_set_ac97_ops(&psc_ac97_ops); if (rc != 0) { - dev_err(&op->dev, "Failed to set AC'97 ops: %d\n", rc); + dev_err(&op->dev, "Failed to set AC'97 ops: %d\n", ret); return rc; } diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index fa756d0..228c52e 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -12,7 +12,6 @@ #include <linux/module.h> #include <linux/interrupt.h> -#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/slab.h> #include <sound/soc.h> diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index f75c3cf..ba59c23 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c @@ -12,7 +12,6 @@ #include <linux/module.h> #include <linux/interrupt.h> -#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/slab.h> #include <sound/soc.h> diff --git a/sound/soc/fsl/p1022_rdk.c b/sound/soc/fsl/p1022_rdk.c index 9d89bb0..f215519 100644 --- a/sound/soc/fsl/p1022_rdk.c +++ b/sound/soc/fsl/p1022_rdk.c @@ -19,7 +19,6 @@ #include <linux/module.h> #include <linux/interrupt.h> -#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/slab.h> #include <sound/soc.h> diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 3665f61..eb43738 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -69,6 +69,7 @@ static int pcm030_fabric_probe(struct platform_device *op) return -ENOMEM; card->dev = &op->dev; + platform_set_drvdata(op, pdata); pdata->card = card; @@ -97,8 +98,6 @@ static int pcm030_fabric_probe(struct platform_device *op) if (ret) dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); - platform_set_drvdata(op, pdata); - return ret; } diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b2fbb70..8c49147 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -27,11 +27,6 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, if (!ret && daifmt) ret = snd_soc_dai_set_fmt(dai, daifmt); - if (ret == -ENOTSUPP) { - dev_dbg(dai->dev, "ASoC: set_fmt is not supported\n"); - ret = 0; - } - if (!ret && set->sysclk) ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c index 1d7ef28..7100592 100644 --- a/sound/soc/jz4740/jz4740-pcm.c +++ b/sound/soc/jz4740/jz4740-pcm.c @@ -297,15 +297,19 @@ static void jz4740_pcm_free(struct snd_pcm *pcm) } } +static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32); + static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; + + if (!card->dev->dma_mask) + card->dev->dma_mask = &jz4740_pcm_dmamask; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = jz4740_pcm_preallocate_dma_buffer(pcm, diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 4af1936..b238434 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -29,7 +29,9 @@ #define KIRKWOOD_FORMATS \ (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S32_LE) + SNDRV_PCM_FMTBIT_S32_LE | \ + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \ + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE) static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) { @@ -57,6 +59,8 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = { .fifo_size = 0, }; +static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32); + static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id) { struct kirkwood_dma_data *priv = dev_id; @@ -157,7 +161,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) * Enable Error interrupts. We're only ack'ing them but * it's useful for diagnostics */ - writel((unsigned int)-1, priv->io + KIRKWOOD_ERR_MASK); + writel((unsigned long)-1, priv->io + KIRKWOOD_ERR_MASK); } dram = mv_mbus_dram_info(); @@ -288,9 +292,10 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd) struct snd_pcm *pcm = rtd->pcm; int ret; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &kirkwood_dma_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = kirkwood_dma_preallocate_dma_buffer(pcm, diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 0b18f65..0f3d73d 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -33,10 +33,6 @@ SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) -#define KIRKWOOD_SPDIF_FORMATS \ - (SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S24_LE) - static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { @@ -107,7 +103,7 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai, { uint32_t clks_ctrl; - if (IS_ERR(priv->extclk)) { + if (rate == 44100 || rate == 48000 || rate == 96000) { /* use internal dco for the supported rates * defined in kirkwood_i2s_dai */ dev_dbg(dai->dev, "%s: dco set rate = %lu\n", @@ -164,11 +160,9 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_FORMAT_S16_LE: i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16; ctl_play = KIRKWOOD_PLAYCTL_SIZE_16_C | - KIRKWOOD_PLAYCTL_I2S_EN | - KIRKWOOD_PLAYCTL_SPDIF_EN; + KIRKWOOD_PLAYCTL_I2S_EN; ctl_rec = KIRKWOOD_RECCTL_SIZE_16_C | - KIRKWOOD_RECCTL_I2S_EN | - KIRKWOOD_RECCTL_SPDIF_EN; + KIRKWOOD_RECCTL_I2S_EN; break; /* * doesn't work... S20_3LE != kirkwood 20bit format ? @@ -184,11 +178,9 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_FORMAT_S24_LE: i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24; ctl_play = KIRKWOOD_PLAYCTL_SIZE_24 | - KIRKWOOD_PLAYCTL_I2S_EN | - KIRKWOOD_PLAYCTL_SPDIF_EN; + KIRKWOOD_PLAYCTL_I2S_EN; ctl_rec = KIRKWOOD_RECCTL_SIZE_24 | - KIRKWOOD_RECCTL_I2S_EN | - KIRKWOOD_RECCTL_SPDIF_EN; + KIRKWOOD_RECCTL_I2S_EN; break; case SNDRV_PCM_FORMAT_S32_LE: i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32; @@ -252,11 +244,6 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_START: /* configure */ ctl = priv->ctl_play; - if (dai->id == 0) - ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN; /* i2s */ - else - ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN; /* spdif */ - value = ctl & ~KIRKWOOD_PLAYCTL_ENABLE_MASK; writel(value, priv->io + KIRKWOOD_PLAYCTL); @@ -271,8 +258,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_STOP: /* stop audio, disable interrupts */ - ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | - KIRKWOOD_PLAYCTL_SPDIF_MUTE; + ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; writel(ctl, priv->io + KIRKWOOD_PLAYCTL); value = readl(priv->io + KIRKWOOD_INT_MASK); @@ -286,15 +272,13 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: - ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | - KIRKWOOD_PLAYCTL_SPDIF_MUTE; + ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; writel(ctl, priv->io + KIRKWOOD_PLAYCTL); break; case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | - KIRKWOOD_PLAYCTL_SPDIF_MUTE); + ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE); writel(ctl, priv->io + KIRKWOOD_PLAYCTL); break; @@ -317,13 +301,7 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_START: /* configure */ ctl = priv->ctl_rec; - if (dai->id == 0) - ctl &= ~KIRKWOOD_RECCTL_SPDIF_EN; /* i2s */ - else - ctl &= ~KIRKWOOD_RECCTL_I2S_EN; /* spdif */ - - value = ctl & ~(KIRKWOOD_RECCTL_I2S_EN | - KIRKWOOD_RECCTL_SPDIF_EN); + value = ctl & ~KIRKWOOD_RECCTL_I2S_EN; writel(value, priv->io + KIRKWOOD_RECCTL); /* enable interrupts */ @@ -383,8 +361,9 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } -static int kirkwood_i2s_init(struct kirkwood_dma_data *priv) +static int kirkwood_i2s_probe(struct snd_soc_dai *dai) { + struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); unsigned long value; unsigned int reg_data; @@ -425,10 +404,9 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { .set_fmt = kirkwood_i2s_set_fmt, }; -static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = { - { - .name = "i2s", - .id = 0, + +static struct snd_soc_dai_driver kirkwood_i2s_dai = { + .probe = kirkwood_i2s_probe, .playback = { .channels_min = 1, .channels_max = 2, @@ -444,32 +422,10 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = { .formats = KIRKWOOD_I2S_FORMATS, }, .ops = &kirkwood_i2s_dai_ops, - }, - { - .name = "spdif", - .id = 1, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, }; -static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { - { - .name = "i2s", - .id = 0, +static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = { + .probe = kirkwood_i2s_probe, .playback = { .channels_min = 1, .channels_max = 2, @@ -487,28 +443,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { .formats = KIRKWOOD_I2S_FORMATS, }, .ops = &kirkwood_i2s_dai_ops, - }, - { - .name = "spdif", - .id = 1, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_192000 | - SNDRV_PCM_RATE_CONTINUOUS | - SNDRV_PCM_RATE_KNOT, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_192000 | - SNDRV_PCM_RATE_CONTINUOUS | - SNDRV_PCM_RATE_KNOT, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, }; static const struct snd_soc_component_driver kirkwood_i2s_component = { @@ -518,7 +452,7 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = { static int kirkwood_i2s_dev_probe(struct platform_device *pdev) { struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; - struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai; + struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai; struct kirkwood_dma_data *priv; struct resource *mem; struct device_node *np = pdev->dev.of_node; @@ -562,17 +496,14 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) return err; priv->extclk = devm_clk_get(&pdev->dev, "extclk"); - if (IS_ERR(priv->extclk)) { - if (PTR_ERR(priv->extclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - } else { + if (!IS_ERR(priv->extclk)) { if (priv->extclk == priv->clk) { devm_clk_put(&pdev->dev, priv->extclk); priv->extclk = ERR_PTR(-EINVAL); } else { dev_info(&pdev->dev, "found external clock\n"); clk_prepare_enable(priv->extclk); - soc_dai = kirkwood_i2s_dai_extclk; + soc_dai = &kirkwood_i2s_dai_extclk; } } @@ -590,7 +521,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) } err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, - soc_dai, 2); + soc_dai, 1); if (err) { dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component; @@ -601,9 +532,6 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); goto err_platform; } - - kirkwood_i2s_init(priv); - return 0; err_platform: snd_soc_unregister_component(&pdev->dev); diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c index 65f2a5b..025be0e 100644 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ b/sound/soc/kirkwood/kirkwood-openrd.c @@ -52,7 +52,7 @@ static struct snd_soc_dai_link openrd_client_dai[] = { { .name = "CS42L51", .stream_name = "CS42L51 HiFi", - .cpu_dai_name = "i2s", + .cpu_dai_name = "mvebu-audio", .platform_name = "mvebu-audio", .codec_dai_name = "cs42l51-hifi", .codec_name = "cs42l51-codec.0-004a", diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index d213832..27545b0 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c @@ -68,7 +68,7 @@ static struct snd_soc_dai_link t5325_dai[] = { { .name = "ALC5621", .stream_name = "ALC5621 HiFi", - .cpu_dai_name = "i2s", + .cpu_dai_name = "mvebu-audio", .platform_name = "mvebu-audio", .codec_dai_name = "alc5621-hifi", .codec_name = "alc562x-codec.0-001a", diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index bf23afb..f8e1ccc 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -123,8 +123,8 @@ /* need to find where they come from */ #define KIRKWOOD_SND_MIN_PERIODS 8 #define KIRKWOOD_SND_MAX_PERIODS 16 -#define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x800 -#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000 +#define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x4000 +#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000 #define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ * KIRKWOOD_SND_MAX_PERIODS) diff --git a/sound/soc/mid-x86/mfld_machine.c b/sound/soc/mid-x86/mfld_machine.c index d3d4c32..ee36384 100644 --- a/sound/soc/mid-x86/mfld_machine.c +++ b/sound/soc/mid-x86/mfld_machine.c @@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) } /* register the soc card */ snd_soc_card_mfld.dev = &pdev->dev; - ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_mfld); + ret_val = snd_soc_register_card(&snd_soc_card_mfld); if (ret_val) { pr_debug("snd_soc_register_card failed %d\n", ret_val); return ret_val; @@ -410,12 +410,20 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) return 0; } +static int snd_mfld_mc_remove(struct platform_device *pdev) +{ + pr_debug("snd_mfld_mc_remove called\n"); + snd_soc_unregister_card(&snd_soc_card_mfld); + return 0; +} + static struct platform_driver snd_mfld_mc_driver = { .driver = { .owner = THIS_MODULE, .name = "msic_audio", }, .probe = snd_mfld_mc_probe, + .remove = snd_mfld_mc_remove, }; module_platform_driver(snd_mfld_mc_driver); diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c index b6b5eb6..392fc0b 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/mid-x86/sst_platform.c @@ -40,8 +40,7 @@ static DEFINE_MUTEX(sst_lock); int sst_register_dsp(struct sst_device *dev) { - if (WARN_ON(!dev)) - return -EINVAL; + BUG_ON(!dev); if (!try_module_get(dev->dev->driver->owner)) return -ENODEV; mutex_lock(&sst_lock); @@ -60,8 +59,7 @@ EXPORT_SYMBOL_GPL(sst_register_dsp); int sst_unregister_dsp(struct sst_device *dev) { - if (WARN_ON(!dev)) - return -EINVAL; + BUG_ON(!dev); if (dev != sst) return -EINVAL; diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 54e622a..b56b8a0 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -494,7 +494,6 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); struct mxs_saif *master_saif; u32 delay; - int ret; master_saif = mxs_saif_get_master(saif); if (!master_saif) @@ -504,37 +503,23 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (saif->state == MXS_SAIF_STATE_RUNNING) - return 0; - dev_dbg(cpu_dai->dev, "start\n"); - ret = clk_enable(master_saif->clk); - if (ret) { - dev_err(saif->dev, "Failed to enable master clock\n"); - return ret; - } + clk_enable(master_saif->clk); + if (!master_saif->mclk_in_use) + __raw_writel(BM_SAIF_CTRL_RUN, + master_saif->base + SAIF_CTRL + MXS_SET_ADDR); /* * If the saif's master is not himself, we also need to enable * itself clk for its internal basic logic to work. */ if (saif != master_saif) { - ret = clk_enable(saif->clk); - if (ret) { - dev_err(saif->dev, "Failed to enable master clock\n"); - clk_disable(master_saif->clk); - return ret; - } - + clk_enable(saif->clk); __raw_writel(BM_SAIF_CTRL_RUN, saif->base + SAIF_CTRL + MXS_SET_ADDR); } - if (!master_saif->mclk_in_use) - __raw_writel(BM_SAIF_CTRL_RUN, - master_saif->base + SAIF_CTRL + MXS_SET_ADDR); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* * write data to saif data register to trigger @@ -558,7 +543,6 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, } master_saif->ongoing = 1; - saif->state = MXS_SAIF_STATE_RUNNING; dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n", __raw_readl(saif->base + SAIF_CTRL), @@ -571,9 +555,6 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (saif->state == MXS_SAIF_STATE_STOPPED) - return 0; - dev_dbg(cpu_dai->dev, "stop\n"); /* wait a while for the current sample to complete */ @@ -594,7 +575,6 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, } master_saif->ongoing = 0; - saif->state = MXS_SAIF_STATE_STOPPED; break; default: @@ -788,8 +768,8 @@ static int mxs_saif_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "failed to init clocks\n"); } - ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component, - &mxs_saif_dai, 1); + ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component, + &mxs_saif_dai, 1); if (ret) { dev_err(&pdev->dev, "register DAI failed\n"); return ret; @@ -798,15 +778,21 @@ static int mxs_saif_probe(struct platform_device *pdev) ret = mxs_pcm_platform_register(&pdev->dev); if (ret) { dev_err(&pdev->dev, "register PCM failed: %d\n", ret); - return ret; + goto failed_pdev_alloc; } return 0; + +failed_pdev_alloc: + snd_soc_unregister_component(&pdev->dev); + + return ret; } static int mxs_saif_remove(struct platform_device *pdev) { mxs_pcm_platform_unregister(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); return 0; } diff --git a/sound/soc/mxs/mxs-saif.h b/sound/soc/mxs/mxs-saif.h index fbaf7ba..53eaa4b 100644 --- a/sound/soc/mxs/mxs-saif.h +++ b/sound/soc/mxs/mxs-saif.h @@ -124,11 +124,6 @@ struct mxs_saif { u32 fifo_underrun; u32 fifo_overrun; - - enum { - MXS_SAIF_STATE_STOPPED, - MXS_SAIF_STATE_RUNNING, - } state; }; extern int mxs_saif_put_mclk(unsigned int saif_id); diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index 61822cc..4bb2737 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c @@ -122,12 +122,14 @@ static struct snd_soc_card mxs_sgtl5000 = { .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), }; -static int mxs_sgtl5000_probe(struct platform_device *pdev) +static int mxs_sgtl5000_probe_dt(struct platform_device *pdev) { - struct snd_soc_card *card = &mxs_sgtl5000; - int ret, i; struct device_node *np = pdev->dev.of_node; struct device_node *saif_np[2], *codec_np; + int i; + + if (!np) + return 1; /* no device tree */ saif_np[0] = of_parse_phandle(np, "saif-controllers", 0); saif_np[1] = of_parse_phandle(np, "saif-controllers", 1); @@ -150,6 +152,18 @@ static int mxs_sgtl5000_probe(struct platform_device *pdev) of_node_put(saif_np[0]); of_node_put(saif_np[1]); + return 0; +} + +static int mxs_sgtl5000_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card = &mxs_sgtl5000; + int ret; + + ret = mxs_sgtl5000_probe_dt(pdev); + if (ret < 0) + return ret; + /* * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). * The Sgtl5000 sysclk is derived from saif0 mclk and it's range diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index f588ee4..c894ff0 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -314,15 +314,16 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } +static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32); static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &nuc900_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, 4 * 1024, (4 * 1024) - 1); diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 3fde9e4..5e8d640 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -100,12 +100,12 @@ static int n810_startup(struct snd_pcm_substream *substream) SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); n810_ext_control(&codec->dapm); - return clk_prepare_enable(sys_clkout2); + return clk_enable(sys_clkout2); } static void n810_shutdown(struct snd_pcm_substream *substream) { - clk_disable_unprepare(sys_clkout2); + clk_disable(sys_clkout2); } static int n810_hw_params(struct snd_pcm_substream *substream, @@ -344,11 +344,8 @@ static int __init n810_soc_init(void) clk_set_parent(sys_clkout2_src, func96m_clk); clk_set_rate(sys_clkout2, 12000000); - if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || - (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) { - err = -EINVAL; - goto err4; - } + BUG_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || + (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0)); gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index cd9ee16..90d2a7c 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -490,9 +490,14 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) mcpdm->dev = &pdev->dev; - return devm_snd_soc_register_component(&pdev->dev, - &omap_mcpdm_component, - &omap_mcpdm_dai, 1); + return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component, + &omap_mcpdm_dai, 1); +} + +static int asoc_mcpdm_remove(struct platform_device *pdev) +{ + snd_soc_unregister_component(&pdev->dev); + return 0; } static const struct of_device_id omap_mcpdm_of_match[] = { @@ -509,6 +514,7 @@ static struct platform_driver asoc_mcpdm_driver = { }, .probe = asoc_mcpdm_probe, + .remove = asoc_mcpdm_remove, }; module_platform_driver(asoc_mcpdm_driver); diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index b8fa986..a11405d 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -156,6 +156,8 @@ static struct snd_pcm_ops omap_pcm_ops = { .mmap = omap_pcm_mmap, }; +static u64 omap_pcm_dmamask = DMA_BIT_MASK(64); + static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) { @@ -200,11 +202,12 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &omap_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(64); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = omap_pcm_preallocate_dma_buffer(pcm, diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index 6a8d6b5..2a9324f 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev) } snd_soc_card_set_drvdata(card, priv); - ret = devm_snd_soc_register_card(&pdev->dev, card); + ret = snd_soc_register_card(card); if (ret) { - dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n", + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); return ret; } @@ -357,6 +357,7 @@ static int omap_twl4030_remove(struct platform_device *pdev) snd_soc_jack_free_gpios(&priv->hs_jack, ARRAY_SIZE(hs_jack_gpios), hs_jack_gpios); + snd_soc_unregister_card(card); return 0; } diff --git a/sound/soc/pxa/brownstone.c b/sound/soc/pxa/brownstone.c index 08acdc2..5b7d969 100644 --- a/sound/soc/pxa/brownstone.c +++ b/sound/soc/pxa/brownstone.c @@ -163,7 +163,6 @@ static struct platform_driver mmp_driver = { .driver = { .name = "brownstone-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = brownstone_probe, .remove = brownstone_remove, diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 1853d41..f4cce1e 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -329,7 +329,6 @@ static struct platform_driver corgi_driver = { .driver = { .name = "corgi-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = corgi_probe, .remove = corgi_remove, diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c index 44b5c09..70d799b 100644 --- a/sound/soc/pxa/e740_wm9705.c +++ b/sound/soc/pxa/e740_wm9705.c @@ -178,7 +178,6 @@ static struct platform_driver e740_driver = { .driver = { .name = "e740-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = e740_probe, .remove = e740_remove, diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c index c34e447..f94d2ab 100644 --- a/sound/soc/pxa/e750_wm9705.c +++ b/sound/soc/pxa/e750_wm9705.c @@ -160,7 +160,6 @@ static struct platform_driver e750_driver = { .driver = { .name = "e750-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = e750_probe, .remove = e750_remove, diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c index 3137f80..8768a64 100644 --- a/sound/soc/pxa/e800_wm9712.c +++ b/sound/soc/pxa/e800_wm9712.c @@ -150,7 +150,6 @@ static struct platform_driver e800_driver = { .driver = { .name = "e800-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = e800_probe, .remove = e800_remove, diff --git a/sound/soc/pxa/imote2.c b/sound/soc/pxa/imote2.c index fd2f4ed..eef1f7b 100644 --- a/sound/soc/pxa/imote2.c +++ b/sound/soc/pxa/imote2.c @@ -91,7 +91,6 @@ static struct platform_driver imote2_driver = { .driver = { .name = "imote2-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = imote2_probe, .remove = imote2_remove, diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index 160c524..bbea778 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -215,7 +215,6 @@ static struct platform_driver mioa701_wm9713_driver = { .driver = { .name = "mioa701-wm9713", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, }; diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 7929e19..8235e23 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -201,9 +201,10 @@ static int mmp_pcm_preallocate_dma_buffer(struct snd_pcm_substream *substream, if (!gpool) return -ENOMEM; - buf->area = gen_pool_dma_alloc(gpool, size, &buf->addr); + buf->area = (unsigned char *)gen_pool_alloc(gpool, size); if (!buf->area) return -ENOMEM; + buf->addr = gen_pool_virt_to_phys(gpool, (unsigned long)buf->area); buf->bytes = size; return 0; } diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 5bf5f1f..41752a5 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) priv->dai_fmt = (unsigned int) -1; platform_set_drvdata(pdev, priv); - return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component, - &mmp_sspa_dai, 1); + return snd_soc_register_component(&pdev->dev, &mmp_sspa_component, + &mmp_sspa_dai, 1); } static int asoc_mmp_sspa_remove(struct platform_device *pdev) @@ -466,6 +466,7 @@ static int asoc_mmp_sspa_remove(struct platform_device *pdev) clk_disable(priv->audio_clk); clk_put(priv->audio_clk); clk_put(priv->sysclk); + snd_soc_unregister_component(&pdev->dev); return 0; } diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 3284c4b..e1ffcdd 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -181,7 +181,6 @@ static struct platform_driver palm27x_wm9712_driver = { .driver = { .name = "palm27x-asoc", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, }; diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index c93e138..fafe463 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -303,7 +303,6 @@ static struct platform_driver poodle_driver = { .driver = { .name = "poodle-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = poodle_probe, .remove = poodle_remove, diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index ae956e3..f1059d9 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -89,6 +89,33 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = { .filter_data = &pxa2xx_ac97_pcm_aux_mic_mono_req, }; +#ifdef CONFIG_PM +static int pxa2xx_ac97_suspend(struct snd_soc_dai *dai) +{ + return pxa2xx_ac97_hw_suspend(); +} + +static int pxa2xx_ac97_resume(struct snd_soc_dai *dai) +{ + return pxa2xx_ac97_hw_resume(); +} + +#else +#define pxa2xx_ac97_suspend NULL +#define pxa2xx_ac97_resume NULL +#endif + +static int pxa2xx_ac97_probe(struct snd_soc_dai *dai) +{ + return pxa2xx_ac97_hw_probe(to_platform_device(dai->dev)); +} + +static int pxa2xx_ac97_remove(struct snd_soc_dai *dai) +{ + pxa2xx_ac97_hw_remove(to_platform_device(dai->dev)); + return 0; +} + static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) @@ -158,6 +185,10 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { { .name = "pxa2xx-ac97", .ac97_control = 1, + .probe = pxa2xx_ac97_probe, + .remove = pxa2xx_ac97_remove, + .suspend = pxa2xx_ac97_suspend, + .resume = pxa2xx_ac97_resume, .playback = { .stream_name = "AC97 Playback", .channels_min = 2, @@ -215,12 +246,6 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev) return -ENXIO; } - ret = pxa2xx_ac97_hw_probe(pdev); - if (ret) { - dev_err(&pdev->dev, "PXA2xx AC97 hw probe error (%d)\n", ret); - return ret; - } - ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops); if (ret != 0) return ret; @@ -237,34 +262,15 @@ static int pxa2xx_ac97_dev_remove(struct platform_device *pdev) { snd_soc_unregister_component(&pdev->dev); snd_soc_set_ac97_ops(NULL); - pxa2xx_ac97_hw_remove(pdev); return 0; } -#ifdef CONFIG_PM_SLEEP -static int pxa2xx_ac97_dev_suspend(struct device *dev) -{ - return pxa2xx_ac97_hw_suspend(); -} - -static int pxa2xx_ac97_dev_resume(struct device *dev) -{ - return pxa2xx_ac97_hw_resume(); -} - -static SIMPLE_DEV_PM_OPS(pxa2xx_ac97_pm_ops, - pxa2xx_ac97_dev_suspend, pxa2xx_ac97_dev_resume); -#endif - static struct platform_driver pxa2xx_ac97_driver = { .probe = pxa2xx_ac97_dev_probe, .remove = pxa2xx_ac97_dev_remove, .driver = { .name = "pxa2xx-ac97", .owner = THIS_MODULE, -#ifdef CONFIG_PM_SLEEP - .pm = &pxa2xx_ac97_pm_ops, -#endif }, }; diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index c0d648d..d5340a0 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -165,8 +165,7 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream, { struct snd_dmaengine_dai_dma_data *dma_data; - if (WARN_ON(IS_ERR(clk_i2s))) - return -EINVAL; + BUG_ON(IS_ERR(clk_i2s)); clk_prepare_enable(clk_i2s); clk_ena = 1; pxa_i2s_wait(); diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index d58b09f..806da27 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -87,15 +87,18 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; +static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32); + static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &pxa2xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index 1d9c2ed..a3fe191 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c @@ -275,7 +275,6 @@ static struct platform_driver tosa_driver = { .driver = { .name = "tosa-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = tosa_probe, .remove = tosa_remove, diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c index 0b535b5..13c9ee0 100644 --- a/sound/soc/pxa/ttc-dkb.c +++ b/sound/soc/pxa/ttc-dkb.c @@ -160,7 +160,6 @@ static struct platform_driver ttc_dkb_driver = { .driver = { .name = "ttc-dkb-audio", .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, }, .probe = ttc_dkb_probe, .remove = ttc_dkb_remove, diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c index d219880..d0740a7 100644 --- a/sound/soc/s6000/s6000-pcm.c +++ b/sound/soc/s6000/s6000-pcm.c @@ -90,8 +90,7 @@ static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream) return; } - if (WARN_ON(period_size & 15)) - return; + BUG_ON(period_size & 15); s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel), src, dst, period_size); @@ -445,6 +444,8 @@ static void s6000_pcm_free(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } +static u64 s6000_pcm_dmamask = DMA_BIT_MASK(32); + static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime) { struct snd_card *card = runtime->card->snd_card; @@ -455,9 +456,10 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime) params = snd_soc_dai_get_dma_data(runtime->cpu_dai, pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); - res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (res) - return res; + if (!card->dev->dma_mask) + card->dev->dma_mask = &s6000_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (params->dma_in) { s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in), diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 37459df..2eea184 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -2,7 +2,7 @@ config SND_SOC_SAMSUNG tristate "ASoC support for Samsung" depends on PLAT_SAMSUNG select S3C64XX_DMA if ARCH_S3C64XX - select S3C24XX_DMA if ARCH_S3C24XX + select S3C2410_DMA if ARCH_S3C24XX help Say Y or M if you want to add support for codecs attached to the Samsung SoCs' Audio interfaces. You will also need to diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c index 350ba23..2acf987 100644 --- a/sound/soc/samsung/ac97.c +++ b/sound/soc/samsung/ac97.c @@ -74,7 +74,7 @@ static void s3c_ac97_activate(struct snd_ac97 *ac97) if (stat == S3C_AC97_GLBSTAT_MAINSTATE_ACTIVE) return; /* Return if already active */ - reinit_completion(&s3c_ac97.done); + INIT_COMPLETION(s3c_ac97.done); ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); ac_glbctrl = S3C_AC97_GLBCTRL_ACLINKON; @@ -103,7 +103,7 @@ static unsigned short s3c_ac97_read(struct snd_ac97 *ac97, s3c_ac97_activate(ac97); - reinit_completion(&s3c_ac97.done); + INIT_COMPLETION(s3c_ac97.done); ac_codec_cmd = readl(s3c_ac97.regs + S3C_AC97_CODEC_CMD); ac_codec_cmd = S3C_AC97_CODEC_CMD_READ | AC_CMD_ADDR(reg); @@ -140,7 +140,7 @@ static void s3c_ac97_write(struct snd_ac97 *ac97, unsigned short reg, s3c_ac97_activate(ac97); - reinit_completion(&s3c_ac97.done); + INIT_COMPLETION(s3c_ac97.done); ac_codec_cmd = readl(s3c_ac97.regs + S3C_AC97_CODEC_CMD); ac_codec_cmd = AC_CMD_ADDR(reg) | AC_CMD_DATA(val); diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c index 84f5d8b..29e2468 100644 --- a/sound/soc/samsung/bells.c +++ b/sound/soc/samsung/bells.c @@ -356,7 +356,6 @@ static struct snd_soc_dapm_widget bells_widgets[] = { static struct snd_soc_dapm_route bells_routes[] = { { "Sub CLK_SYS", NULL, "OPCLK" }, - { "CLKIN", NULL, "OPCLK" }, { "DMIC", NULL, "MICBIAS2" }, { "IN2L", NULL, "DMIC" }, diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index fe2748b..9338d11 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -406,17 +406,20 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm) } } +static u64 dma_mask = DMA_BIT_MASK(32); + static int dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; pr_debug("Entered %s\n", __func__); - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &dma_mask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = preallocate_dma_buffer(pcm, diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index a5cbdb4..b302f3b 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -702,6 +702,13 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, } writel(mod, i2s->addr + I2SMOD); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_dai_set_dma_data(dai, substream, + (void *)&i2s->dma_playback); + else + snd_soc_dai_set_dma_data(dai, substream, + (void *)&i2s->dma_capture); + i2s->frmclk = params_rate(params); return 0; @@ -963,8 +970,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) } clk_prepare_enable(i2s->clk); - snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); - if (other) { other->addr = i2s->addr; other->clk = i2s->clk; @@ -1055,7 +1060,7 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) i2s->i2s_dai_drv.ops = &samsung_i2s_dai_ops; i2s->i2s_dai_drv.suspend = i2s_suspend; i2s->i2s_dai_drv.resume = i2s_resume; - i2s->i2s_dai_drv.playback.channels_min = 1; + i2s->i2s_dai_drv.playback.channels_min = 2; i2s->i2s_dai_drv.playback.channels_max = 2; i2s->i2s_dai_drv.playback.rates = SAMSUNG_I2S_RATES; i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS; @@ -1068,7 +1073,7 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) dev_set_drvdata(&i2s->pdev->dev, i2s); } else { /* Create a new platform_device for Secondary */ i2s->pdev = platform_device_alloc("samsung-i2s-sec", -1); - if (!i2s->pdev) + if (IS_ERR(i2s->pdev)) return NULL; i2s->pdev->dev.parent = &pdev->dev; @@ -1138,9 +1143,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Unable to get drvdata\n"); return -EFAULT; } - devm_snd_soc_register_component(&sec_dai->pdev->dev, - &samsung_i2s_component, - &sec_dai->i2s_dai_drv, 1); + snd_soc_register_component(&sec_dai->pdev->dev, + &samsung_i2s_component, + &sec_dai->i2s_dai_drv, 1); samsung_asoc_dma_platform_register(&pdev->dev); return 0; } @@ -1253,9 +1258,8 @@ static int samsung_i2s_probe(struct platform_device *pdev) goto err; } - devm_snd_soc_register_component(&pri_dai->pdev->dev, - &samsung_i2s_component, - &pri_dai->i2s_dai_drv, 1); + snd_soc_register_component(&pri_dai->pdev->dev, &samsung_i2s_component, + &pri_dai->i2s_dai_drv, 1); pm_runtime_enable(&pdev->dev); @@ -1290,6 +1294,7 @@ static int samsung_i2s_remove(struct platform_device *pdev) i2s->sec_dai = NULL; samsung_asoc_dma_platform_unregister(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); return 0; } diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index e4f318f..ce1e1e1 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -383,15 +383,18 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream) return 0; } +static u64 idma_mask = DMA_BIT_MASK(32); + static int idma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - int ret; + int ret = 0; - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + if (!card->dev->dma_mask) + card->dev->dma_mask = &idma_mask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = DMA_BIT_MASK(32); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = preallocate_idma_buffer(pcm, diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index fefc561..e5e81b1 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c @@ -31,7 +31,11 @@ #undef S3C_IIS_V2_SUPPORTED #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) \ - || defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_CPU_S5PV210) + || defined(CONFIG_CPU_S5PV210) +#define S3C_IIS_V2_SUPPORTED +#endif + +#ifdef CONFIG_PLAT_S3C64XX #define S3C_IIS_V2_SUPPORTED #endif diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index b072bd1..5fd7a05 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c @@ -9,7 +9,6 @@ #include "../codecs/wm8994.h" #include <sound/pcm_params.h> -#include <sound/soc.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h> @@ -194,7 +193,7 @@ static int smdk_audio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, board); - ret = devm_snd_soc_register_card(&pdev->dev, card); + ret = snd_soc_register_card(card); if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret); @@ -202,14 +201,23 @@ static int smdk_audio_probe(struct platform_device *pdev) return ret; } +static int smdk_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; +} + static struct platform_driver smdk_audio_driver = { .driver = { .name = "smdk-audio-wm8894", .owner = THIS_MODULE, .of_match_table = of_match_ptr(samsung_wm8994_of_match), - .pm = &snd_soc_pm_ops, }, .probe = smdk_audio_probe, + .remove = smdk_audio_remove, }; module_platform_driver(smdk_audio_driver); diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index ff60e11..56d8ff6 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig @@ -37,7 +37,7 @@ config SND_SOC_SH4_SIU config SND_SOC_RCAR tristate "R-Car series SRU/SCU/SSIU/SSI support" select SND_SIMPLE_CARD - select REGMAP + select RCAR_CLK_ADG help This option enables R-Car SUR/SCU/SSIU/SSI sound support diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 9430097..d80deb7 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -8,6 +8,7 @@ * for more details. */ #include <linux/sh_clk.h> +#include <mach/clock.h> #include "rsnd.h" #define CLKA 0 @@ -21,7 +22,6 @@ struct rsnd_adg { int rate_of_441khz_div_6; int rate_of_48khz_div_6; - u32 ckr; }; #define for_each_rsnd_clk(pos, adg, i) \ @@ -116,11 +116,6 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate) found_clock: - /* see rsnd_adg_ssi_clk_init() */ - rsnd_mod_bset(mod, SSICKR, 0x00FF0000, adg->ckr); - rsnd_mod_write(mod, BRRA, 0x00000002); /* 1/6 */ - rsnd_mod_write(mod, BRRB, 0x00000002); /* 1/6 */ - /* * This "mod" = "ssi" here. * we can get "ssi id" from mod @@ -187,7 +182,9 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) } } - adg->ckr = ckr; + rsnd_priv_bset(priv, SSICKR, 0x00FF0000, ckr); + rsnd_priv_write(priv, BRRA, 0x00000002); /* 1/6 */ + rsnd_priv_write(priv, BRRB, 0x00000002); /* 1/6 */ } int rsnd_adg_probe(struct platform_device *pdev, diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index b3653d3..a357060 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -94,7 +94,6 @@ * */ #include <linux/pm_runtime.h> -#include <linux/shdma-base.h> #include "rsnd.h" #define RSND_RATES SNDRV_PCM_RATE_8000_96000 @@ -104,9 +103,54 @@ * rsnd_platform functions */ #define rsnd_platform_call(priv, dai, func, param...) \ - (!(priv->info->func) ? 0 : \ + (!(priv->info->func) ? -ENODEV : \ priv->info->func(param)) + +/* + * basic function + */ +u32 rsnd_read(struct rsnd_priv *priv, + struct rsnd_mod *mod, enum rsnd_reg reg) +{ + void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); + + BUG_ON(!base); + + return ioread32(base); +} + +void rsnd_write(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg, u32 data) +{ + void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); + struct device *dev = rsnd_priv_to_dev(priv); + + BUG_ON(!base); + + dev_dbg(dev, "w %p : %08x\n", base, data); + + iowrite32(data, base); +} + +void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, + enum rsnd_reg reg, u32 mask, u32 data) +{ + void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); + struct device *dev = rsnd_priv_to_dev(priv); + u32 val; + + BUG_ON(!base); + + val = ioread32(base); + val &= ~mask; + val |= data & mask; + iowrite32(val, base); + + dev_dbg(dev, "s %p : %08x\n", base, val); +} + /* * rsnd_mod functions */ @@ -200,8 +244,9 @@ static void rsnd_dma_do_work(struct work_struct *work) return; } - dma_async_issue_pending(dma->chan); } + + dma_async_issue_pending(dma->chan); } int rsnd_dma_available(struct rsnd_dma *dma) @@ -209,6 +254,13 @@ int rsnd_dma_available(struct rsnd_dma *dma) return !!dma->chan; } +static bool rsnd_dma_filter(struct dma_chan *chan, void *param) +{ + chan->private = param; + + return true; +} + int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int is_play, int id, int (*inquiry)(struct rsnd_dma *dma, @@ -216,9 +268,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int (*complete)(struct rsnd_dma *dma)) { struct device *dev = rsnd_priv_to_dev(priv); - struct dma_slave_config cfg; dma_cap_mask_t mask; - int ret; if (dma->chan) { dev_err(dev, "it already has dma channel\n"); @@ -228,23 +278,15 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, - (void *)id, dev, - is_play ? "tx" : "rx"); + dma->slave.shdma_slave.slave_id = id; + + dma->chan = dma_request_channel(mask, rsnd_dma_filter, + &dma->slave.shdma_slave); if (!dma->chan) { dev_err(dev, "can't get dma channel\n"); return -EIO; } - cfg.slave_id = id; - cfg.dst_addr = 0; /* use default addr when playback */ - cfg.src_addr = 0; /* use default addr when capture */ - cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; - - ret = dmaengine_slave_config(dma->chan, &cfg); - if (ret < 0) - goto rsnd_dma_init_err; - dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE; dma->priv = priv; dma->inquiry = inquiry; @@ -252,11 +294,6 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, INIT_WORK(&dma->work, rsnd_dma_do_work); return 0; - -rsnd_dma_init_err: - rsnd_dma_quit(priv, dma); - - return ret; } void rsnd_dma_quit(struct rsnd_priv *priv, @@ -287,13 +324,15 @@ int rsnd_dai_connect(struct rsnd_dai *rdai, struct rsnd_mod *mod, struct rsnd_dai_stream *io) { - if (!mod) + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + + if (!mod) { + dev_err(dev, "NULL mod\n"); return -EIO; + } if (!list_empty(&mod->list)) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); - struct device *dev = rsnd_priv_to_dev(priv); - dev_err(dev, "%s%d is not empty\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); @@ -324,9 +363,6 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai) struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) { - if ((id < 0) || (id >= rsnd_dai_nr(priv))) - return NULL; - return priv->rdai + id; } diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 61212ee..babb203 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -11,11 +11,6 @@ #include "rsnd.h" struct rsnd_gen_ops { - int (*probe)(struct platform_device *pdev, - struct rcar_snd_info *info, - struct rsnd_priv *priv); - void (*remove)(struct platform_device *pdev, - struct rsnd_priv *priv); int (*path_init)(struct rsnd_priv *priv, struct rsnd_dai *rdai, struct rsnd_dai_stream *io); @@ -24,97 +19,21 @@ struct rsnd_gen_ops { struct rsnd_dai_stream *io); }; +struct rsnd_gen_reg_map { + int index; /* -1 : not supported */ + u32 offset_id; /* offset of ssi0, ssi1, ssi2... */ + u32 offset_adr; /* offset of SSICR, SSISR, ... */ +}; + struct rsnd_gen { void __iomem *base[RSND_BASE_MAX]; + struct rsnd_gen_reg_map reg_map[RSND_REG_MAX]; struct rsnd_gen_ops *ops; - - struct regmap *regmap; - struct regmap_field *regs[RSND_REG_MAX]; }; #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) -#define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size) \ - [id] = { \ - .reg = (unsigned int)gen->base[reg_id] + offset, \ - .lsb = 0, \ - .msb = 31, \ - .id_size = _id_size, \ - .id_offset = _id_offset, \ - } - -/* - * basic function - */ -static int rsnd_regmap_write32(void *context, const void *_data, size_t count) -{ - struct rsnd_priv *priv = context; - struct device *dev = rsnd_priv_to_dev(priv); - u32 *data = (u32 *)_data; - u32 val = data[1]; - void __iomem *reg = (void *)data[0]; - - iowrite32(val, reg); - - dev_dbg(dev, "w %p : %08x\n", reg, val); - - return 0; -} - -static int rsnd_regmap_read32(void *context, - const void *_data, size_t reg_size, - void *_val, size_t val_size) -{ - struct rsnd_priv *priv = context; - struct device *dev = rsnd_priv_to_dev(priv); - u32 *data = (u32 *)_data; - u32 *val = (u32 *)_val; - void __iomem *reg = (void *)data[0]; - - *val = ioread32(reg); - - dev_dbg(dev, "r %p : %08x\n", reg, *val); - - return 0; -} - -static struct regmap_bus rsnd_regmap_bus = { - .write = rsnd_regmap_write32, - .read = rsnd_regmap_read32, - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, -}; - -u32 rsnd_read(struct rsnd_priv *priv, - struct rsnd_mod *mod, enum rsnd_reg reg) -{ - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); - u32 val; - - regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); - - return val; -} - -void rsnd_write(struct rsnd_priv *priv, - struct rsnd_mod *mod, - enum rsnd_reg reg, u32 data) -{ - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); - - regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); -} - -void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, - enum rsnd_reg reg, u32 mask, u32 data) -{ - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); - - regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), - mask, data); -} - /* * Gen2 * will be filled in the future @@ -179,64 +98,44 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv, return ret; } -/* single address mapping */ -#define RSND_GEN1_S_REG(gen, reg, id, offset) \ - RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) +static struct rsnd_gen_ops rsnd_gen1_ops = { + .path_init = rsnd_gen1_path_init, + .path_exit = rsnd_gen1_path_exit, +}; -/* multi address mapping */ -#define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset) \ - RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9) +#define RSND_GEN1_REG_MAP(g, s, i, oi, oa) \ + do { \ + (g)->reg_map[RSND_REG_##i].index = RSND_GEN1_##s; \ + (g)->reg_map[RSND_REG_##i].offset_id = oi; \ + (g)->reg_map[RSND_REG_##i].offset_adr = oa; \ + } while (0) -static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) +static void rsnd_gen1_reg_map_init(struct rsnd_gen *gen) { - int i; - struct device *dev = rsnd_priv_to_dev(priv); - struct regmap_config regc; - struct reg_field regf[RSND_REG_MAX] = { - RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), - RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), - RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), - RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), - RSND_GEN1_S_REG(gen, SRU, SRC_CTRL, 0xc0), - RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), - RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), - RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), - RSND_GEN1_M_REG(gen, SRU, BUSIF_ADINR, 0x214, 0x40), - - RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), - RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), - RSND_GEN1_S_REG(gen, ADG, SSICKR, 0x08), - RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), - RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), - RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL3, 0x18), - RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL4, 0x1c), - RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL5, 0x20), - - RSND_GEN1_M_REG(gen, SSI, SSICR, 0x00, 0x40), - RSND_GEN1_M_REG(gen, SSI, SSISR, 0x04, 0x40), - RSND_GEN1_M_REG(gen, SSI, SSITDR, 0x08, 0x40), - RSND_GEN1_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), - RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), - }; - - memset(®c, 0, sizeof(regc)); - regc.reg_bits = 32; - regc.val_bits = 32; - - gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); - if (IS_ERR(gen->regmap)) { - dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); - return PTR_ERR(gen->regmap); - } - - for (i = 0; i < RSND_REG_MAX; i++) { - gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); - if (IS_ERR(gen->regs[i])) - return PTR_ERR(gen->regs[i]); - - } - - return 0; + RSND_GEN1_REG_MAP(gen, SRU, SRC_ROUTE_SEL, 0x0, 0x00); + RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL0, 0x0, 0x08); + RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL1, 0x0, 0x0c); + RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL2, 0x0, 0x10); + RSND_GEN1_REG_MAP(gen, SRU, SRC_CTRL, 0x0, 0xc0); + RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE0, 0x0, 0xD0); + RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE1, 0x0, 0xD4); + RSND_GEN1_REG_MAP(gen, SRU, BUSIF_MODE, 0x4, 0x20); + RSND_GEN1_REG_MAP(gen, SRU, BUSIF_ADINR, 0x40, 0x214); + + RSND_GEN1_REG_MAP(gen, ADG, BRRA, 0x0, 0x00); + RSND_GEN1_REG_MAP(gen, ADG, BRRB, 0x0, 0x04); + RSND_GEN1_REG_MAP(gen, ADG, SSICKR, 0x0, 0x08); + RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL0, 0x0, 0x0c); + RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL1, 0x0, 0x10); + RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL3, 0x0, 0x18); + RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL4, 0x0, 0x1c); + RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL5, 0x0, 0x20); + + RSND_GEN1_REG_MAP(gen, SSI, SSICR, 0x40, 0x00); + RSND_GEN1_REG_MAP(gen, SSI, SSISR, 0x40, 0x04); + RSND_GEN1_REG_MAP(gen, SSI, SSITDR, 0x40, 0x08); + RSND_GEN1_REG_MAP(gen, SSI, SSIRDR, 0x40, 0x0c); + RSND_GEN1_REG_MAP(gen, SSI, SSIWSR, 0x40, 0x20); } static int rsnd_gen1_probe(struct platform_device *pdev, @@ -248,7 +147,6 @@ static int rsnd_gen1_probe(struct platform_device *pdev, struct resource *sru_res; struct resource *adg_res; struct resource *ssi_res; - int ret; /* * map address @@ -265,9 +163,8 @@ static int rsnd_gen1_probe(struct platform_device *pdev, IS_ERR(gen->base[RSND_GEN1_SSI])) return -ENODEV; - ret = rsnd_gen1_regmap_init(priv, gen); - if (ret < 0) - return ret; + gen->ops = &rsnd_gen1_ops; + rsnd_gen1_reg_map_init(gen); dev_dbg(dev, "Gen1 device probed\n"); dev_dbg(dev, "SRU : %08x => %p\n", sru_res->start, @@ -286,13 +183,6 @@ static void rsnd_gen1_remove(struct platform_device *pdev, { } -static struct rsnd_gen_ops rsnd_gen1_ops = { - .probe = rsnd_gen1_probe, - .remove = rsnd_gen1_remove, - .path_init = rsnd_gen1_path_init, - .path_exit = rsnd_gen1_path_exit, -}; - /* * Gen */ @@ -314,12 +204,46 @@ int rsnd_gen_path_exit(struct rsnd_priv *priv, return gen->ops->path_exit(priv, rdai, io); } +void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + struct device *dev = rsnd_priv_to_dev(priv); + int index; + u32 offset_id, offset_adr; + + if (reg >= RSND_REG_MAX) { + dev_err(dev, "rsnd_reg reg error\n"); + return NULL; + } + + index = gen->reg_map[reg].index; + offset_id = gen->reg_map[reg].offset_id; + offset_adr = gen->reg_map[reg].offset_adr; + + if (index < 0) { + dev_err(dev, "unsupported reg access %d\n", reg); + return NULL; + } + + if (offset_id && mod) + offset_id *= rsnd_mod_id(mod); + + /* + * index/offset were set on gen1/gen2 + */ + + return gen->base[index] + offset_id + offset_adr; +} + int rsnd_gen_probe(struct platform_device *pdev, struct rcar_snd_info *info, struct rsnd_priv *priv) { struct device *dev = rsnd_priv_to_dev(priv); struct rsnd_gen *gen; + int i; gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); if (!gen) { @@ -327,23 +251,30 @@ int rsnd_gen_probe(struct platform_device *pdev, return -ENOMEM; } - if (rsnd_is_gen1(priv)) - gen->ops = &rsnd_gen1_ops; + priv->gen = gen; - if (!gen->ops) { - dev_err(dev, "unknown generation R-Car sound device\n"); - return -ENODEV; - } + /* + * see + * rsnd_reg_get() + * rsnd_gen_probe() + */ + for (i = 0; i < RSND_REG_MAX; i++) + gen->reg_map[i].index = -1; - priv->gen = gen; + /* + * init each module + */ + if (rsnd_is_gen1(priv)) + return rsnd_gen1_probe(pdev, info, priv); + + dev_err(dev, "unknown generation R-Car sound device\n"); - return gen->ops->probe(pdev, info, priv); + return -ENODEV; } void rsnd_gen_remove(struct platform_device *pdev, struct rsnd_priv *priv) { - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); - - gen->ops->remove(pdev, priv); + if (rsnd_is_gen1(priv)) + rsnd_gen1_remove(pdev, priv); } diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 9e463e5..5dd87f4 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -78,6 +78,10 @@ struct rsnd_dai_stream; #define rsnd_mod_bset(m, r, s, d) \ rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) +#define rsnd_priv_read(p, r) rsnd_read(p, NULL, RSND_REG_##r) +#define rsnd_priv_write(p, r, d) rsnd_write(p, NULL, RSND_REG_##r, d) +#define rsnd_priv_bset(p, r, s, d) rsnd_bset(p, NULL, RSND_REG_##r, s, d) + u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg, u32 data); @@ -281,7 +285,6 @@ int rsnd_scu_probe(struct platform_device *pdev, void rsnd_scu_remove(struct platform_device *pdev, struct rsnd_priv *priv); struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); -bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); #define rsnd_scu_nr(priv) ((priv)->scu_nr) /* diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index fa8fa15..2df2e91 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c @@ -68,7 +68,7 @@ static int rsnd_scu_set_route(struct rsnd_priv *priv, return 0; id = rsnd_mod_id(mod); - if (id < 0 || id >= ARRAY_SIZE(routes)) + if (id < 0 || id > ARRAY_SIZE(routes)) return -EIO; /* @@ -146,26 +146,20 @@ static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, return 0; } -bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod) -{ - struct rsnd_scu *scu = rsnd_mod_to_scu(mod); - u32 flags = rsnd_scu_mode_flags(scu); - - return !!(flags & RSND_SCU_USE_HPBIF); -} - static int rsnd_scu_start(struct rsnd_mod *mod, struct rsnd_dai *rdai, struct rsnd_dai_stream *io) { struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); struct device *dev = rsnd_priv_to_dev(priv); + u32 flags = rsnd_scu_mode_flags(scu); int ret; /* * SCU will be used if it has RSND_SCU_USE_HPBIF flags */ - if (!rsnd_scu_hpbif_is_enable(mod)) { + if (!(flags & RSND_SCU_USE_HPBIF)) { /* it use PIO transter */ dev_dbg(dev, "%s%d is not used\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); @@ -198,8 +192,7 @@ static struct rsnd_mod_ops rsnd_scu_ops = { struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) { - if (WARN_ON(id < 0 || id >= rsnd_scu_nr(priv))) - id = 0; + BUG_ON(id < 0 || id >= rsnd_scu_nr(priv)); return &((struct rsnd_scu *)(priv->scu) + id)->mod; } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 5ac20cd..fae26d3 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -101,30 +101,29 @@ struct rsnd_ssiu { #define rsnd_ssi_to_ssiu(ssi)\ (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1) -static void rsnd_ssi_mode_set(struct rsnd_priv *priv, - struct rsnd_dai *rdai, - struct rsnd_ssi *ssi) +static void rsnd_ssi_mode_init(struct rsnd_priv *priv, + struct rsnd_ssiu *ssiu) { struct device *dev = rsnd_priv_to_dev(priv); - struct rsnd_mod *scu; - struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); - int id = rsnd_mod_id(&ssi->mod); + struct rsnd_ssi *ssi; u32 flags; u32 val; - - scu = rsnd_scu_mod_get(priv, rsnd_mod_id(&ssi->mod)); + int i; /* * SSI_MODE0 */ - - /* see also BUSIF_MODE */ - if (rsnd_scu_hpbif_is_enable(scu)) { - ssiu->ssi_mode0 &= ~(1 << id); - dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", id); - } else { - ssiu->ssi_mode0 |= (1 << id); - dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", id); + ssiu->ssi_mode0 = 0; + for_each_rsnd_ssi(ssi, priv, i) { + flags = rsnd_ssi_mode_flags(ssi); + + /* see also BUSIF_MODE */ + if (!(flags & RSND_SSI_DEPENDENT)) { + ssiu->ssi_mode0 |= (1 << i); + dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", i); + } else { + dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", i); + } } /* @@ -133,7 +132,7 @@ static void rsnd_ssi_mode_set(struct rsnd_priv *priv, #define ssi_parent_set(p, sync, adg, ext) \ do { \ ssi->parent = ssiu->ssi + p; \ - if (rsnd_rdai_is_clk_master(rdai)) \ + if (flags & RSND_SSI_CLK_FROM_ADG) \ val = adg; \ else \ val = ext; \ @@ -141,11 +140,15 @@ static void rsnd_ssi_mode_set(struct rsnd_priv *priv, val |= sync; \ } while (0) - flags = rsnd_ssi_mode_flags(ssi); - if (flags & RSND_SSI_CLK_PIN_SHARE) { + ssiu->ssi_mode1 = 0; + for_each_rsnd_ssi(ssi, priv, i) { + flags = rsnd_ssi_mode_flags(ssi); + + if (!(flags & RSND_SSI_CLK_PIN_SHARE)) + continue; val = 0; - switch (id) { + switch (i) { case 1: ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0)); break; @@ -162,6 +165,11 @@ static void rsnd_ssi_mode_set(struct rsnd_priv *priv, ssiu->ssi_mode1 |= val; } +} + +static void rsnd_ssi_mode_set(struct rsnd_ssi *ssi) +{ + struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0); rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1); @@ -371,7 +379,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, ssi->cr_own = cr; ssi->err = -1; /* ignore 1st error */ - rsnd_ssi_mode_set(priv, rdai, ssi); + rsnd_ssi_mode_set(ssi); dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); @@ -611,8 +619,7 @@ struct rsnd_mod *rsnd_ssi_mod_get_frm_dai(struct rsnd_priv *priv, struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id) { - if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv))) - id = 0; + BUG_ON(id < 0 || id >= rsnd_ssi_nr(priv)); return &(((struct rsnd_ssiu *)(priv->ssiu))->ssi + id)->mod; } @@ -699,6 +706,8 @@ int rsnd_ssi_probe(struct platform_device *pdev, rsnd_mod_init(priv, &ssi->mod, ops, i); } + rsnd_ssi_mode_init(priv, ssiu); + dev_dbg(dev, "ssi probed\n"); return 0; diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index d55babe..9dc24ff 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -543,8 +543,7 @@ static void siu_dai_shutdown(struct snd_pcm_substream *substream, /* Stop the siu if the other stream is not using it */ if (!port_info->play_cap) { /* during stmread or stmwrite ? */ - if (WARN_ON(port_info->playback.rw_flg || port_info->capture.rw_flg)) - return; + BUG_ON(port_info->playback.rw_flg || port_info->capture.rw_flg); siu_dai_spbstop(port_info); siu_dai_stop(port_info); } diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 375dc6d..e72f554 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -11,9 +11,12 @@ * option) any later version. */ +#include <linux/i2c.h> +#include <linux/spi/spi.h> #include <sound/soc.h> +#include <linux/bitmap.h> +#include <linux/rbtree.h> #include <linux/export.h> -#include <linux/slab.h> #include <trace/events/asoc.h> @@ -36,8 +39,7 @@ static bool snd_soc_set_cache_val(void *base, unsigned int idx, break; } default: - WARN(1, "Invalid word_size %d\n", word_size); - break; + BUG(); } return false; } @@ -58,49 +60,132 @@ static unsigned int snd_soc_get_cache_val(const void *base, unsigned int idx, return cache[idx]; } default: - WARN(1, "Invalid word_size %d\n", word_size); - break; + BUG(); } /* unreachable */ return -1; } -int snd_soc_cache_init(struct snd_soc_codec *codec) +static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) { - const struct snd_soc_codec_driver *codec_drv = codec->driver; - size_t reg_size; + int i; + int ret; + const struct snd_soc_codec_driver *codec_drv; + unsigned int val; - reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; + codec_drv = codec->driver; + for (i = 0; i < codec_drv->reg_cache_size; ++i) { + ret = snd_soc_cache_read(codec, i, &val); + if (ret) + return ret; + if (codec->reg_def_copy) + if (snd_soc_get_cache_val(codec->reg_def_copy, + i, codec_drv->reg_word_size) == val) + continue; - mutex_init(&codec->cache_rw_mutex); + WARN_ON(!snd_soc_codec_writable_register(codec, i)); + + ret = snd_soc_write(codec, i, val); + if (ret) + return ret; + dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n", + i, val); + } + return 0; +} + +static int snd_soc_flat_cache_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) +{ + snd_soc_set_cache_val(codec->reg_cache, reg, value, + codec->driver->reg_word_size); + return 0; +} + +static int snd_soc_flat_cache_read(struct snd_soc_codec *codec, + unsigned int reg, unsigned int *value) +{ + *value = snd_soc_get_cache_val(codec->reg_cache, reg, + codec->driver->reg_word_size); + return 0; +} - dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", - codec->name); +static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec) +{ + if (!codec->reg_cache) + return 0; + kfree(codec->reg_cache); + codec->reg_cache = NULL; + return 0; +} - if (codec_drv->reg_cache_default) - codec->reg_cache = kmemdup(codec_drv->reg_cache_default, - reg_size, GFP_KERNEL); +static int snd_soc_flat_cache_init(struct snd_soc_codec *codec) +{ + if (codec->reg_def_copy) + codec->reg_cache = kmemdup(codec->reg_def_copy, + codec->reg_size, GFP_KERNEL); else - codec->reg_cache = kzalloc(reg_size, GFP_KERNEL); + codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL); if (!codec->reg_cache) return -ENOMEM; return 0; } +/* an array of all supported compression types */ +static const struct snd_soc_cache_ops cache_types[] = { + /* Flat *must* be the first entry for fallback */ + { + .id = SND_SOC_FLAT_COMPRESSION, + .name = "flat", + .init = snd_soc_flat_cache_init, + .exit = snd_soc_flat_cache_exit, + .read = snd_soc_flat_cache_read, + .write = snd_soc_flat_cache_write, + .sync = snd_soc_flat_cache_sync + }, +}; + +int snd_soc_cache_init(struct snd_soc_codec *codec) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(cache_types); ++i) + if (cache_types[i].id == codec->compress_type) + break; + + /* Fall back to flat compression */ + if (i == ARRAY_SIZE(cache_types)) { + dev_warn(codec->dev, "ASoC: Could not match compress type: %d\n", + codec->compress_type); + i = 0; + } + + mutex_init(&codec->cache_rw_mutex); + codec->cache_ops = &cache_types[i]; + + if (codec->cache_ops->init) { + if (codec->cache_ops->name) + dev_dbg(codec->dev, "ASoC: Initializing %s cache for %s codec\n", + codec->cache_ops->name, codec->name); + return codec->cache_ops->init(codec); + } + return -ENOSYS; +} + /* * NOTE: keep in mind that this function might be called * multiple times. */ int snd_soc_cache_exit(struct snd_soc_codec *codec) { - dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", - codec->name); - if (!codec->reg_cache) - return 0; - kfree(codec->reg_cache); - codec->reg_cache = NULL; - return 0; + if (codec->cache_ops && codec->cache_ops->exit) { + if (codec->cache_ops->name) + dev_dbg(codec->dev, "ASoC: Destroying %s cache for %s codec\n", + codec->cache_ops->name, codec->name); + return codec->cache_ops->exit(codec); + } + return -ENOSYS; } /** @@ -113,15 +198,18 @@ int snd_soc_cache_exit(struct snd_soc_codec *codec) int snd_soc_cache_read(struct snd_soc_codec *codec, unsigned int reg, unsigned int *value) { - if (!value) - return -EINVAL; + int ret; mutex_lock(&codec->cache_rw_mutex); - *value = snd_soc_get_cache_val(codec->reg_cache, reg, - codec->driver->reg_word_size); - mutex_unlock(&codec->cache_rw_mutex); - return 0; + if (value && codec->cache_ops && codec->cache_ops->read) { + ret = codec->cache_ops->read(codec, reg, value); + mutex_unlock(&codec->cache_rw_mutex); + return ret; + } + + mutex_unlock(&codec->cache_rw_mutex); + return -ENOSYS; } EXPORT_SYMBOL_GPL(snd_soc_cache_read); @@ -135,42 +223,20 @@ EXPORT_SYMBOL_GPL(snd_soc_cache_read); int snd_soc_cache_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - mutex_lock(&codec->cache_rw_mutex); - snd_soc_set_cache_val(codec->reg_cache, reg, value, - codec->driver->reg_word_size); - mutex_unlock(&codec->cache_rw_mutex); - - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_cache_write); - -static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) -{ - int i; int ret; - const struct snd_soc_codec_driver *codec_drv; - unsigned int val; - - codec_drv = codec->driver; - for (i = 0; i < codec_drv->reg_cache_size; ++i) { - ret = snd_soc_cache_read(codec, i, &val); - if (ret) - return ret; - if (codec_drv->reg_cache_default) - if (snd_soc_get_cache_val(codec_drv->reg_cache_default, - i, codec_drv->reg_word_size) == val) - continue; - WARN_ON(!snd_soc_codec_writable_register(codec, i)); + mutex_lock(&codec->cache_rw_mutex); - ret = snd_soc_write(codec, i, val); - if (ret) - return ret; - dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n", - i, val); + if (codec->cache_ops && codec->cache_ops->write) { + ret = codec->cache_ops->write(codec, reg, value); + mutex_unlock(&codec->cache_rw_mutex); + return ret; } - return 0; + + mutex_unlock(&codec->cache_rw_mutex); + return -ENOSYS; } +EXPORT_SYMBOL_GPL(snd_soc_cache_write); /** * snd_soc_cache_sync: Sync the register cache with the hardware. @@ -183,19 +249,92 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) */ int snd_soc_cache_sync(struct snd_soc_codec *codec) { - const char *name = "flat"; int ret; + const char *name; - if (!codec->cache_sync) + if (!codec->cache_sync) { return 0; + } + + if (!codec->cache_ops || !codec->cache_ops->sync) + return -ENOSYS; - dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", - codec->name); + if (codec->cache_ops->name) + name = codec->cache_ops->name; + else + name = "unknown"; + + if (codec->cache_ops->name) + dev_dbg(codec->dev, "ASoC: Syncing %s cache for %s codec\n", + codec->cache_ops->name, codec->name); trace_snd_soc_cache_sync(codec, name, "start"); - ret = snd_soc_flat_cache_sync(codec); + ret = codec->cache_ops->sync(codec); if (!ret) codec->cache_sync = 0; trace_snd_soc_cache_sync(codec, name, "end"); return ret; } EXPORT_SYMBOL_GPL(snd_soc_cache_sync); + +static int snd_soc_get_reg_access_index(struct snd_soc_codec *codec, + unsigned int reg) +{ + const struct snd_soc_codec_driver *codec_drv; + unsigned int min, max, index; + + codec_drv = codec->driver; + min = 0; + max = codec_drv->reg_access_size - 1; + do { + index = (min + max) / 2; + if (codec_drv->reg_access_default[index].reg == reg) + return index; + if (codec_drv->reg_access_default[index].reg < reg) + min = index + 1; + else + max = index; + } while (min <= max); + return -1; +} + +int snd_soc_default_volatile_register(struct snd_soc_codec *codec, + unsigned int reg) +{ + int index; + + if (reg >= codec->driver->reg_cache_size) + return 1; + index = snd_soc_get_reg_access_index(codec, reg); + if (index < 0) + return 0; + return codec->driver->reg_access_default[index].vol; +} +EXPORT_SYMBOL_GPL(snd_soc_default_volatile_register); + +int snd_soc_default_readable_register(struct snd_soc_codec *codec, + unsigned int reg) +{ + int index; + + if (reg >= codec->driver->reg_cache_size) + return 1; + index = snd_soc_get_reg_access_index(codec, reg); + if (index < 0) + return 0; + return codec->driver->reg_access_default[index].read; +} +EXPORT_SYMBOL_GPL(snd_soc_default_readable_register); + +int snd_soc_default_writable_register(struct snd_soc_codec *codec, + unsigned int reg) +{ + int index; + + if (reg >= codec->driver->reg_cache_size) + return 1; + index = snd_soc_get_reg_access_index(codec, reg); + if (index < 0) + return 0; + return codec->driver->reg_access_default[index].write; +} +EXPORT_SYMBOL_GPL(snd_soc_default_writable_register); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a66783e..1a38be0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -662,8 +662,6 @@ int snd_soc_suspend(struct device *dev) codec->cache_sync = 1; if (codec->using_regmap) regcache_mark_dirty(codec->control_data); - /* deactivate pins to sleep state */ - pinctrl_pm_select_sleep_state(codec->dev); break; default: dev_dbg(codec->dev, @@ -681,9 +679,6 @@ int snd_soc_suspend(struct device *dev) if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control) cpu_dai->driver->suspend(cpu_dai); - - /* deactivate pins to sleep state */ - pinctrl_pm_select_sleep_state(cpu_dai->dev); } if (card->suspend_post) @@ -812,16 +807,6 @@ int snd_soc_resume(struct device *dev) if (list_empty(&card->codec_dev_list)) return 0; - /* activate pins from sleep state */ - for (i = 0; i < card->num_rtd; i++) { - struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; - struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; - if (cpu_dai->active) - pinctrl_pm_select_default_state(cpu_dai->dev); - if (codec_dai->active) - pinctrl_pm_select_default_state(codec_dai->dev); - } - /* AC97 devices might have other drivers hanging off them so * need to resume immediately. Other drivers don't have that * problem and may take a substantial amount of time to resume @@ -1604,13 +1589,17 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num) soc_remove_codec(codec); } -static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) +static int snd_soc_init_codec_cache(struct snd_soc_codec *codec, + enum snd_soc_compress_type compress_type) { int ret; if (codec->cache_init) return 0; + /* override the compress_type if necessary */ + if (compress_type && codec->compress_type != compress_type) + codec->compress_type = compress_type; ret = snd_soc_cache_init(codec); if (ret < 0) { dev_err(codec->dev, @@ -1625,6 +1614,8 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) static int snd_soc_instantiate_card(struct snd_soc_card *card) { struct snd_soc_codec *codec; + struct snd_soc_codec_conf *codec_conf; + enum snd_soc_compress_type compress_type; struct snd_soc_dai_link *dai_link; int ret, i, order, dai_fmt; @@ -1648,7 +1639,19 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) list_for_each_entry(codec, &codec_list, list) { if (codec->cache_init) continue; - ret = snd_soc_init_codec_cache(codec); + /* by default we don't override the compress_type */ + compress_type = 0; + /* check to see if we need to override the compress_type */ + for (i = 0; i < card->num_configs; ++i) { + codec_conf = &card->codec_conf[i]; + if (!strcmp(codec->name, codec_conf->dev_name)) { + compress_type = codec_conf->compress_type; + if (compress_type && compress_type + != codec->compress_type) + break; + } + } + ret = snd_soc_init_codec_cache(codec, compress_type); if (ret < 0) goto base_error; } @@ -1944,14 +1947,6 @@ int snd_soc_poweroff(struct device *dev) snd_soc_dapm_shutdown(card); - /* deactivate pins to sleep state */ - for (i = 0; i < card->num_rtd; i++) { - struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; - struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; - pinctrl_pm_select_sleep_state(codec_dai->dev); - pinctrl_pm_select_sleep_state(cpu_dai->dev); - } - return 0; } EXPORT_SYMBOL_GPL(snd_soc_poweroff); @@ -2302,6 +2297,13 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(snd_soc_write); +unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, + unsigned int reg, const void *data, size_t len) +{ + return codec->bulk_write_raw(codec, reg, data, len); +} +EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw); + /** * snd_soc_update_bits - update codec register bits * @codec: audio codec @@ -2574,9 +2576,8 @@ int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, if (uinfo->value.enumerated.item > e->max - 1) uinfo->value.enumerated.item = e->max - 1; - strlcpy(uinfo->value.enumerated.name, - e->texts[uinfo->value.enumerated.item], - sizeof(uinfo->value.enumerated.name)); + strcpy(uinfo->value.enumerated.name, + e->texts[uinfo->value.enumerated.item]); return 0; } EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); @@ -3212,11 +3213,11 @@ int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, break; case 2: ((u16 *)(&ucontrol->value.bytes.data))[0] - &= cpu_to_be16(~params->mask); + &= ~params->mask; break; case 4: ((u32 *)(&ucontrol->value.bytes.data))[0] - &= cpu_to_be32(~params->mask); + &= ~params->mask; break; default: return -EINVAL; @@ -3575,22 +3576,6 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); /** - * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio. - * @dai: DAI - * @ratio Ratio of BCLK to Sample rate. - * - * Configures the DAI for a preset BCLK to sample rate ratio. - */ -int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) -{ - if (dai->driver && dai->driver->ops->set_bclk_ratio) - return dai->driver->ops->set_bclk_ratio(dai, ratio); - else - return -EINVAL; -} -EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio); - -/** * snd_soc_dai_set_fmt - configure DAI hardware audio format. * @dai: DAI * @fmt: SND_SOC_DAIFMT_ format value. @@ -3790,16 +3775,6 @@ int snd_soc_register_card(struct snd_soc_card *card) if (ret != 0) soc_cleanup_card_debugfs(card); - /* deactivate pins to sleep state */ - for (i = 0; i < card->num_rtd; i++) { - struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; - struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); - } - return ret; } EXPORT_SYMBOL_GPL(snd_soc_register_card); @@ -4045,113 +4020,6 @@ static void snd_soc_unregister_dais(struct device *dev, size_t count) } /** - * snd_soc_register_component - Register a component with the ASoC core - * - */ -static int -__snd_soc_register_component(struct device *dev, - struct snd_soc_component *cmpnt, - const struct snd_soc_component_driver *cmpnt_drv, - struct snd_soc_dai_driver *dai_drv, - int num_dai, bool allow_single_dai) -{ - int ret; - - dev_dbg(dev, "component register %s\n", dev_name(dev)); - - if (!cmpnt) { - dev_err(dev, "ASoC: Failed to connecting component\n"); - return -ENOMEM; - } - - cmpnt->name = fmt_single_name(dev, &cmpnt->id); - if (!cmpnt->name) { - dev_err(dev, "ASoC: Failed to simplifying name\n"); - return -ENOMEM; - } - - cmpnt->dev = dev; - cmpnt->driver = cmpnt_drv; - cmpnt->dai_drv = dai_drv; - cmpnt->num_dai = num_dai; - - /* - * snd_soc_register_dai() uses fmt_single_name(), and - * snd_soc_register_dais() uses fmt_multiple_name() - * for dai->name which is used for name based matching - * - * this function is used from cpu/codec. - * allow_single_dai flag can ignore "codec" driver reworking - * since it had been used snd_soc_register_dais(), - */ - if ((1 == num_dai) && allow_single_dai) - ret = snd_soc_register_dai(dev, dai_drv); - else - ret = snd_soc_register_dais(dev, dai_drv, num_dai); - if (ret < 0) { - dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); - goto error_component_name; - } - - mutex_lock(&client_mutex); - list_add(&cmpnt->list, &component_list); - mutex_unlock(&client_mutex); - - dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name); - - return ret; - -error_component_name: - kfree(cmpnt->name); - - return ret; -} - -int snd_soc_register_component(struct device *dev, - const struct snd_soc_component_driver *cmpnt_drv, - struct snd_soc_dai_driver *dai_drv, - int num_dai) -{ - struct snd_soc_component *cmpnt; - - cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL); - if (!cmpnt) { - dev_err(dev, "ASoC: Failed to allocate memory\n"); - return -ENOMEM; - } - - return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, - dai_drv, num_dai, true); -} -EXPORT_SYMBOL_GPL(snd_soc_register_component); - -/** - * snd_soc_unregister_component - Unregister a component from the ASoC core - * - */ -void snd_soc_unregister_component(struct device *dev) -{ - struct snd_soc_component *cmpnt; - - list_for_each_entry(cmpnt, &component_list, list) { - if (dev == cmpnt->dev) - goto found; - } - return; - -found: - snd_soc_unregister_dais(dev, cmpnt->num_dai); - - mutex_lock(&client_mutex); - list_del(&cmpnt->list); - mutex_unlock(&client_mutex); - - dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); - kfree(cmpnt->name); -} -EXPORT_SYMBOL_GPL(snd_soc_unregister_component); - -/** * snd_soc_add_platform - Add a platform to the ASoC core * @dev: The parent device for the platform * @platform: The platform to add @@ -4297,6 +4165,7 @@ int snd_soc_register_codec(struct device *dev, struct snd_soc_dai_driver *dai_drv, int num_dai) { + size_t reg_size; struct snd_soc_codec *codec; int ret, i; @@ -4313,6 +4182,11 @@ int snd_soc_register_codec(struct device *dev, goto fail_codec; } + if (codec_drv->compress_type) + codec->compress_type = codec_drv->compress_type; + else + codec->compress_type = SND_SOC_FLAT_COMPRESSION; + codec->write = codec_drv->write; codec->read = codec_drv->read; codec->volatile_register = codec_drv->volatile_register; @@ -4329,6 +4203,35 @@ int snd_soc_register_codec(struct device *dev, codec->num_dai = num_dai; mutex_init(&codec->mutex); + /* allocate CODEC register cache */ + if (codec_drv->reg_cache_size && codec_drv->reg_word_size) { + reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; + codec->reg_size = reg_size; + /* it is necessary to make a copy of the default register cache + * because in the case of using a compression type that requires + * the default register cache to be marked as the + * kernel might have freed the array by the time we initialize + * the cache. + */ + if (codec_drv->reg_cache_default) { + codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default, + reg_size, GFP_KERNEL); + if (!codec->reg_def_copy) { + ret = -ENOMEM; + goto fail_codec_name; + } + } + } + + if (codec_drv->reg_access_size && codec_drv->reg_access_default) { + if (!codec->volatile_register) + codec->volatile_register = snd_soc_default_volatile_register; + if (!codec->readable_register) + codec->readable_register = snd_soc_default_readable_register; + if (!codec->writable_register) + codec->writable_register = snd_soc_default_writable_register; + } + for (i = 0; i < num_dai; i++) { fixup_codec_formats(&dai_drv[i].playback); fixup_codec_formats(&dai_drv[i].capture); @@ -4338,12 +4241,10 @@ int snd_soc_register_codec(struct device *dev, list_add(&codec->list, &codec_list); mutex_unlock(&client_mutex); - /* register component */ - ret = __snd_soc_register_component(dev, &codec->component, - &codec_drv->component_driver, - dai_drv, num_dai, false); + /* register any DAIs */ + ret = snd_soc_register_dais(dev, dai_drv, num_dai); if (ret < 0) { - dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret); + dev_err(codec->dev, "ASoC: Failed to regster DAIs: %d\n", ret); goto fail_codec_name; } @@ -4378,7 +4279,7 @@ void snd_soc_unregister_codec(struct device *dev) return; found: - snd_soc_unregister_component(dev); + snd_soc_unregister_dais(dev, codec->num_dai); mutex_lock(&client_mutex); list_del(&codec->list); @@ -4387,11 +4288,98 @@ found: dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); snd_soc_cache_exit(codec); + kfree(codec->reg_def_copy); kfree(codec->name); kfree(codec); } EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); + +/** + * snd_soc_register_component - Register a component with the ASoC core + * + */ +int snd_soc_register_component(struct device *dev, + const struct snd_soc_component_driver *cmpnt_drv, + struct snd_soc_dai_driver *dai_drv, + int num_dai) +{ + struct snd_soc_component *cmpnt; + int ret; + + dev_dbg(dev, "component register %s\n", dev_name(dev)); + + cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL); + if (!cmpnt) { + dev_err(dev, "ASoC: Failed to allocate memory\n"); + return -ENOMEM; + } + + cmpnt->name = fmt_single_name(dev, &cmpnt->id); + if (!cmpnt->name) { + dev_err(dev, "ASoC: Failed to simplifying name\n"); + return -ENOMEM; + } + + cmpnt->dev = dev; + cmpnt->driver = cmpnt_drv; + cmpnt->num_dai = num_dai; + + /* + * snd_soc_register_dai() uses fmt_single_name(), and + * snd_soc_register_dais() uses fmt_multiple_name() + * for dai->name which is used for name based matching + */ + if (1 == num_dai) + ret = snd_soc_register_dai(dev, dai_drv); + else + ret = snd_soc_register_dais(dev, dai_drv, num_dai); + if (ret < 0) { + dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); + goto error_component_name; + } + + mutex_lock(&client_mutex); + list_add(&cmpnt->list, &component_list); + mutex_unlock(&client_mutex); + + dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name); + + return ret; + +error_component_name: + kfree(cmpnt->name); + + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_register_component); + +/** + * snd_soc_unregister_component - Unregister a component from the ASoC core + * + */ +void snd_soc_unregister_component(struct device *dev) +{ + struct snd_soc_component *cmpnt; + + list_for_each_entry(cmpnt, &component_list, list) { + if (dev == cmpnt->dev) + goto found; + } + return; + +found: + snd_soc_unregister_dais(dev, cmpnt->num_dai); + + mutex_lock(&client_mutex); + list_del(&cmpnt->list); + mutex_unlock(&client_mutex); + + dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); + kfree(cmpnt->name); +} +EXPORT_SYMBOL_GPL(snd_soc_unregister_component); + /* Retrieve a card's name from device tree */ int snd_soc_of_parse_card_name(struct snd_soc_card *card, const char *propname) @@ -4579,60 +4567,6 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, } EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); -int snd_soc_of_get_dai_name(struct device_node *of_node, - const char **dai_name) -{ - struct snd_soc_component *pos; - struct of_phandle_args args; - int ret; - - ret = of_parse_phandle_with_args(of_node, "sound-dai", - "#sound-dai-cells", 0, &args); - if (ret) - return ret; - - ret = -EPROBE_DEFER; - - mutex_lock(&client_mutex); - list_for_each_entry(pos, &component_list, list) { - if (pos->dev->of_node != args.np) - continue; - - if (pos->driver->of_xlate_dai_name) { - ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name); - } else { - int id = -1; - - switch (args.args_count) { - case 0: - id = 0; /* same as dai_drv[0] */ - break; - case 1: - id = args.args[0]; - break; - default: - /* not supported */ - break; - } - - if (id < 0 || id >= pos->num_dai) { - ret = -EINVAL; - } else { - *dai_name = pos->dai_drv[id].name; - ret = 0; - } - } - - break; - } - mutex_unlock(&client_mutex); - - of_node_put(args.np); - - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); - static int __init snd_soc_init(void) { #ifdef CONFIG_DEBUG_FS diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index dcade13..b2949ae 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -59,31 +59,31 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, /* dapm power sequences - make this per codec in the future */ static int dapm_up_seq[] = { [snd_soc_dapm_pre] = 0, + [snd_soc_dapm_supply] = 1, [snd_soc_dapm_regulator_supply] = 1, [snd_soc_dapm_clock_supply] = 1, - [snd_soc_dapm_supply] = 2, - [snd_soc_dapm_micbias] = 3, + [snd_soc_dapm_micbias] = 2, [snd_soc_dapm_dai_link] = 2, - [snd_soc_dapm_dai_in] = 4, - [snd_soc_dapm_dai_out] = 4, - [snd_soc_dapm_aif_in] = 4, - [snd_soc_dapm_aif_out] = 4, - [snd_soc_dapm_mic] = 5, - [snd_soc_dapm_mux] = 6, - [snd_soc_dapm_virt_mux] = 6, - [snd_soc_dapm_value_mux] = 6, - [snd_soc_dapm_dac] = 7, - [snd_soc_dapm_switch] = 8, - [snd_soc_dapm_mixer] = 8, - [snd_soc_dapm_mixer_named_ctl] = 8, - [snd_soc_dapm_pga] = 9, - [snd_soc_dapm_adc] = 10, - [snd_soc_dapm_out_drv] = 11, - [snd_soc_dapm_hp] = 11, - [snd_soc_dapm_spk] = 11, - [snd_soc_dapm_line] = 11, - [snd_soc_dapm_kcontrol] = 12, - [snd_soc_dapm_post] = 13, + [snd_soc_dapm_dai_in] = 3, + [snd_soc_dapm_dai_out] = 3, + [snd_soc_dapm_aif_in] = 3, + [snd_soc_dapm_aif_out] = 3, + [snd_soc_dapm_mic] = 4, + [snd_soc_dapm_mux] = 5, + [snd_soc_dapm_virt_mux] = 5, + [snd_soc_dapm_value_mux] = 5, + [snd_soc_dapm_dac] = 6, + [snd_soc_dapm_switch] = 7, + [snd_soc_dapm_mixer] = 7, + [snd_soc_dapm_mixer_named_ctl] = 7, + [snd_soc_dapm_pga] = 8, + [snd_soc_dapm_adc] = 9, + [snd_soc_dapm_out_drv] = 10, + [snd_soc_dapm_hp] = 10, + [snd_soc_dapm_spk] = 10, + [snd_soc_dapm_line] = 10, + [snd_soc_dapm_kcontrol] = 11, + [snd_soc_dapm_post] = 12, }; static int dapm_down_seq[] = { @@ -109,10 +109,10 @@ static int dapm_down_seq[] = { [snd_soc_dapm_dai_in] = 10, [snd_soc_dapm_dai_out] = 10, [snd_soc_dapm_dai_link] = 11, + [snd_soc_dapm_clock_supply] = 12, + [snd_soc_dapm_regulator_supply] = 12, [snd_soc_dapm_supply] = 12, - [snd_soc_dapm_clock_supply] = 13, - [snd_soc_dapm_regulator_supply] = 13, - [snd_soc_dapm_post] = 14, + [snd_soc_dapm_post] = 13, }; static void pop_wait(u32 pop_time) @@ -409,12 +409,6 @@ static inline void soc_widget_unlock(struct snd_soc_dapm_widget *w) mutex_unlock(&w->platform->mutex); } -static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) -{ - if (dapm->codec && dapm->codec->using_regmap) - regmap_async_complete(dapm->codec->control_data); -} - static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, unsigned short reg, unsigned int mask, unsigned int value) { @@ -423,9 +417,8 @@ static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, int ret; if (w->codec && w->codec->using_regmap) { - ret = regmap_update_bits_check_async(w->codec->control_data, - reg, mask, value, - &change); + ret = regmap_update_bits_check(w->codec->control_data, + reg, mask, value, &change); if (ret != 0) return ret; } else { @@ -506,22 +499,18 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, int val; struct soc_mixer_control *mc = (struct soc_mixer_control *) w->kcontrol_news[i].private_value; - int reg = mc->reg; + unsigned int reg = mc->reg; unsigned int shift = mc->shift; int max = mc->max; unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; - if (reg != SND_SOC_NOPM) { - val = soc_widget_read(w, reg); - val = (val >> shift) & mask; - if (invert) - val = max - val; - p->connect = !!val; - } else { - p->connect = 0; - } + val = soc_widget_read(w, reg); + val = (val >> shift) & mask; + if (invert) + val = max - val; + p->connect = !!val; } break; case snd_soc_dapm_mux: { @@ -1208,8 +1197,6 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w, { int ret; - soc_dapm_async_complete(w->dapm); - if (SND_SOC_DAPM_EVENT_ON(event)) { if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { ret = regulator_allow_bypass(w->regulator, false); @@ -1243,8 +1230,6 @@ int dapm_clock_event(struct snd_soc_dapm_widget *w, if (!w->clk) return -EIO; - soc_dapm_async_complete(w->dapm); - #ifdef CONFIG_HAVE_CLK if (SND_SOC_DAPM_EVENT_ON(event)) { return clk_prepare_enable(w->clk); @@ -1427,7 +1412,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card, power = 0; break; default: - WARN(1, "Unknown event %d\n", event); + BUG(); return; } @@ -1437,7 +1422,6 @@ static void dapm_seq_check_event(struct snd_soc_card *card, if (w->event && (w->event_flags & event)) { pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", w->name, ev_name); - soc_dapm_async_complete(w->dapm); trace_snd_soc_dapm_widget_event_start(w, event); ret = w->event(w, NULL, event); trace_snd_soc_dapm_widget_event_done(w, event); @@ -1460,7 +1444,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, power_list)->reg; list_for_each_entry(w, pending, power_list) { - WARN_ON(reg != w->reg); + BUG_ON(reg != w->reg); w->power = w->new_power; mask |= w->mask << w->shift; @@ -1510,7 +1494,6 @@ static void dapm_seq_run(struct snd_soc_card *card, struct list_head *list, int event, bool power_up) { struct snd_soc_dapm_widget *w, *n; - struct snd_soc_dapm_context *d; LIST_HEAD(pending); int cur_sort = -1; int cur_subseq = -1; @@ -1541,9 +1524,6 @@ static void dapm_seq_run(struct snd_soc_card *card, cur_subseq); } - if (cur_dapm && w->dapm != cur_dapm) - soc_dapm_async_complete(cur_dapm); - INIT_LIST_HEAD(&pending); cur_sort = -1; cur_subseq = INT_MIN; @@ -1602,10 +1582,6 @@ static void dapm_seq_run(struct snd_soc_card *card, cur_dapm->seq_notifier(cur_dapm, i, cur_subseq); } - - list_for_each_entry(d, &card->dapm_list, list) { - soc_dapm_async_complete(d); - } } static void dapm_widget_update(struct snd_soc_card *card) @@ -1864,7 +1840,6 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) */ switch (w->id) { case snd_soc_dapm_siggen: - case snd_soc_dapm_vmid: break; case snd_soc_dapm_supply: case snd_soc_dapm_regulator_supply: @@ -2026,7 +2001,7 @@ static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf, level = "Off\n"; break; default: - WARN(1, "Unknown bias_level %d\n", dapm->bias_level); + BUG(); level = "Unknown\n"; break; } @@ -2816,7 +2791,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, struct snd_soc_card *card = codec->card; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - int reg = mc->reg; + unsigned int reg = mc->reg; unsigned int shift = mc->shift; int max = mc->max; unsigned int mask = (1 << fls(max)) - 1; @@ -2829,7 +2804,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, kcontrol->id.name); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); - if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) + if (dapm_kcontrol_is_powered(kcontrol)) val = (snd_soc_read(codec, reg) >> shift) & mask; else val = dapm_kcontrol_get_value(kcontrol); @@ -2860,7 +2835,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, struct snd_soc_card *card = codec->card; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - int reg = mc->reg; + unsigned int reg = mc->reg; unsigned int shift = mc->shift; int max = mc->max; unsigned int mask = (1 << fls(max)) - 1; @@ -2882,24 +2857,19 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); - change = dapm_kcontrol_set_value(kcontrol, val); + dapm_kcontrol_set_value(kcontrol, val); - if (reg != SND_SOC_NOPM) { - mask = mask << shift; - val = val << shift; - - change = snd_soc_test_bits(codec, reg, mask, val); - } + mask = mask << shift; + val = val << shift; + change = snd_soc_test_bits(codec, reg, mask, val); if (change) { - if (reg != SND_SOC_NOPM) { - update.kcontrol = kcontrol; - update.reg = reg; - update.mask = mask; - update.val = val; + update.kcontrol = kcontrol; + update.reg = reg; + update.mask = mask; + update.val = val; - card->update = &update; - } + card->update = &update; soc_dapm_mixer_update_power(card, kcontrol, connect); @@ -3359,9 +3329,8 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, u64 fmt; int ret; - if (WARN_ON(!config) || - WARN_ON(list_empty(&w->sources) || list_empty(&w->sinks))) - return -EINVAL; + BUG_ON(!config); + BUG_ON(list_empty(&w->sources) || list_empty(&w->sinks)); /* We only support a single source and sink, pick the first */ source_p = list_first_entry(&w->sources, struct snd_soc_dapm_path, @@ -3369,10 +3338,9 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, sink_p = list_first_entry(&w->sinks, struct snd_soc_dapm_path, list_source); - if (WARN_ON(!source_p || !sink_p) || - WARN_ON(!sink_p->source || !source_p->sink) || - WARN_ON(!source_p->source || !sink_p->sink)) - return -EINVAL; + BUG_ON(!source_p || !sink_p); + BUG_ON(!sink_p->source || !source_p->sink); + BUG_ON(!source_p->source || !sink_p->sink); source = source_p->source->priv; sink = sink_p->sink->priv; @@ -3448,7 +3416,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, break; default: - WARN(1, "Unknown event %d\n", event); + BUG(); return -EINVAL; } diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c deleted file mode 100644 index 3449c1e..0000000 --- a/sound/soc/soc-devres.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * soc-devres.c -- ALSA SoC Audio Layer devres functions - * - * Copyright (C) 2013 Linaro Ltd - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <sound/soc.h> - -static void devm_component_release(struct device *dev, void *res) -{ - snd_soc_unregister_component(*(struct device **)res); -} - -/** - * devm_snd_soc_register_component - resource managed component registration - * @dev: Device used to manage component - * @cmpnt_drv: Component driver - * @dai_drv: DAI driver - * @num_dai: Number of DAIs to register - * - * Register a component with automatic unregistration when the device is - * unregistered. - */ -int devm_snd_soc_register_component(struct device *dev, - const struct snd_soc_component_driver *cmpnt_drv, - struct snd_soc_dai_driver *dai_drv, int num_dai) -{ - struct device **ptr; - int ret; - - ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return -ENOMEM; - - ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai); - if (ret == 0) { - *ptr = dev; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return ret; -} -EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); - -static void devm_card_release(struct device *dev, void *res) -{ - snd_soc_unregister_card(*(struct snd_soc_card **)res); -} - -/** - * devm_snd_soc_register_card - resource managed card registration - * @dev: Device used to manage card - * @card: Card to register - * - * Register a card with automatic unregistration when the device is - * unregistered. - */ -int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) -{ - struct snd_soc_card **ptr; - int ret; - - ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return -ENOMEM; - - ret = snd_soc_register_card(card); - if (ret == 0) { - *ptr = card; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return ret; -} -EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index cbc9c96..e29ec3c 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -25,7 +25,7 @@ #include <sound/dmaengine_pcm.h> struct dmaengine_pcm { - struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; + struct dma_chan *chan[SNDRV_PCM_STREAM_CAPTURE + 1]; const struct snd_dmaengine_pcm_config *config; struct snd_soc_platform platform; unsigned int flags; @@ -36,15 +36,6 @@ static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) return container_of(p, struct dmaengine_pcm, platform); } -static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, - struct snd_pcm_substream *substream) -{ - if (!pcm->chan[substream->stream]) - return NULL; - - return pcm->chan[substream->stream]->device->dev; -} - /** * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback * @substream: PCM substream @@ -84,21 +75,12 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); - int (*prepare_slave_config)(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct dma_slave_config *slave_config); struct dma_slave_config slave_config; int ret; - memset(&slave_config, 0, sizeof(slave_config)); - - if (!pcm->config) - prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; - else - prepare_slave_config = pcm->config->prepare_slave_config; - - if (prepare_slave_config) { - ret = prepare_slave_config(substream, params, &slave_config); + if (pcm->config->prepare_slave_config) { + ret = pcm->config->prepare_slave_config(substream, params, + &slave_config); if (ret) return ret; @@ -110,54 +92,28 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); } -static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) +static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); - struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; - struct snd_dmaengine_dai_dma_data *dma_data; - struct dma_slave_caps dma_caps; - struct snd_pcm_hardware hw; int ret; - if (pcm->config && pcm->config->pcm_hardware) - return snd_soc_set_runtime_hwparams(substream, + ret = snd_soc_set_runtime_hwparams(substream, pcm->config->pcm_hardware); + if (ret) + return ret; - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - memset(&hw, 0, sizeof(hw)); - hw.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED; - hw.periods_min = 2; - hw.periods_max = UINT_MAX; - hw.period_bytes_min = 256; - hw.period_bytes_max = dma_get_max_seg_size(dma_dev); - hw.buffer_bytes_max = SIZE_MAX; - hw.fifo_size = dma_data->fifo_size; - - ret = dma_get_slave_caps(chan, &dma_caps); - if (ret == 0) { - if (dma_caps.cmd_pause) - hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; - } - - return snd_soc_set_runtime_hwparams(substream, &hw); + return snd_dmaengine_pcm_open(substream, chan); } -static int dmaengine_pcm_open(struct snd_pcm_substream *substream) +static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, + struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); - struct dma_chan *chan = pcm->chan[substream->stream]; - int ret; - - ret = dmaengine_pcm_set_runtime_hwparams(substream); - if (ret) - return ret; + if (!pcm->chan[substream->stream]) + return NULL; - return snd_dmaengine_pcm_open(substream, chan); + return pcm->chan[substream->stream]->device->dev; } static void dmaengine_pcm_free(struct snd_pcm *pcm) @@ -170,9 +126,6 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_pcm_substream *substream) { struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); - struct snd_dmaengine_dai_dma_data *dma_data; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0]) return pcm->chan[0]; @@ -181,42 +134,22 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( return pcm->config->compat_request_channel(rtd, substream); return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn, - dma_data->filter_data); + snd_soc_dai_get_dma_data(rtd->cpu_dai, substream)); } static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; - struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; - size_t prealloc_buffer_size; - size_t max_buffer_size; unsigned int i; int ret; - if (config && config->prealloc_buffer_size) { - prealloc_buffer_size = config->prealloc_buffer_size; - max_buffer_size = config->pcm_hardware->buffer_bytes_max; - } else { - prealloc_buffer_size = 512 * 1024; - max_buffer_size = SIZE_MAX; - } - - for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { substream = rtd->pcm->streams[i].substream; if (!substream) continue; - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - if (!pcm->chan[i] && - (pcm->flags & SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) - pcm->chan[i] = dma_request_slave_channel(dev, - dma_data->chan_name); - if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) { pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd, substream); @@ -230,10 +163,10 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } ret = snd_pcm_lib_preallocate_pages(substream, - SNDRV_DMA_TYPE_DEV_IRAM, + SNDRV_DMA_TYPE_DEV, dmaengine_dma_dev(pcm, substream), - prealloc_buffer_size, - max_buffer_size); + config->prealloc_buffer_size, + config->pcm_hardware->buffer_bytes_max); if (ret) goto err_free; } @@ -289,9 +222,7 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, { unsigned int i; - if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | - SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) || - !dev->of_node) + if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_DT) || !dev->of_node) return; if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 4f11d23..122c0c1 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -65,6 +65,31 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) return val; } +/* Primitive bulk write support for soc-cache. The data pointed to by + * `data' needs to already be in the form the hardware expects. Any + * data written through this function will not go through the cache as + * it only handles writing to volatile or out of bounds registers. + * + * This is currently only supported for devices using the regmap API + * wrappers. + */ +static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec, + unsigned int reg, + const void *data, size_t len) +{ + /* To ensure that we don't get out of sync with the cache, check + * whether the base register is volatile or if we've directly asked + * to bypass the cache. Out of bounds registers are considered + * volatile. + */ + if (!codec->cache_bypass + && !snd_soc_codec_volatile_register(codec, reg) + && reg < codec->driver->reg_cache_size) + return -EINVAL; + + return regmap_raw_write(codec->control_data, reg, data, len); +} + /** * snd_soc_codec_set_cache_io: Set up standard I/O functions. * @@ -94,6 +119,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, memset(&config, 0, sizeof(config)); codec->write = hw_write; codec->read = hw_read; + codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; config.reg_bits = addr_bits; config.val_bits = data_bits; diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 23d43da..71358e3 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -65,7 +65,6 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) struct snd_soc_codec *codec; struct snd_soc_dapm_context *dapm; struct snd_soc_jack_pin *pin; - unsigned int sync = 0; int enable; trace_snd_soc_jack_report(jack, mask, status); @@ -93,16 +92,12 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) snd_soc_dapm_enable_pin(dapm, pin->pin); else snd_soc_dapm_disable_pin(dapm, pin->pin); - - /* we need to sync for this case only */ - sync = 1; } /* Report before the DAPM sync to help users updating micbias status */ blocking_notifier_call_chain(&jack->notifier, jack->status, jack); - if (sync) - snd_soc_dapm_sync(dapm); + snd_soc_dapm_sync(dapm); snd_jack_report(jack->jack, jack->status); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 11a90cd..330c9a6 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -19,7 +19,6 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> -#include <linux/pinctrl/consumer.h> #include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/workqueue.h> @@ -148,12 +147,12 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, } } -static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, +static void soc_pcm_init_runtime_hw(struct snd_pcm_hardware *hw, struct snd_soc_pcm_stream *codec_stream, struct snd_soc_pcm_stream *cpu_stream) { - struct snd_pcm_hardware *hw = &runtime->hw; - + hw->rate_min = max(codec_stream->rate_min, cpu_stream->rate_min); + hw->rate_max = max(codec_stream->rate_max, cpu_stream->rate_max); hw->channels_min = max(codec_stream->channels_min, cpu_stream->channels_min); hw->channels_max = min(codec_stream->channels_max, @@ -166,13 +165,6 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, if (cpu_stream->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) hw->rates |= codec_stream->rates; - - snd_pcm_limit_hw_rates(runtime); - - hw->rate_min = max(hw->rate_min, cpu_stream->rate_min); - hw->rate_min = max(hw->rate_min, codec_stream->rate_min); - hw->rate_max = min_not_zero(hw->rate_max, cpu_stream->rate_max); - hw->rate_max = min_not_zero(hw->rate_max, codec_stream->rate_max); } /* @@ -191,8 +183,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver; int ret = 0; - pinctrl_pm_select_default_state(cpu_dai->dev); - pinctrl_pm_select_default_state(codec_dai->dev); pm_runtime_get_sync(cpu_dai->dev); pm_runtime_get_sync(codec_dai->dev); pm_runtime_get_sync(platform->dev); @@ -200,7 +190,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); /* startup the audio subsystem */ - if (cpu_dai->driver->ops && cpu_dai->driver->ops->startup) { + if (cpu_dai->driver->ops->startup) { ret = cpu_dai->driver->ops->startup(substream, cpu_dai); if (ret < 0) { dev_err(cpu_dai->dev, "ASoC: can't open interface" @@ -218,7 +208,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } } - if (codec_dai->driver->ops && codec_dai->driver->ops->startup) { + if (codec_dai->driver->ops->startup) { ret = codec_dai->driver->ops->startup(substream, codec_dai); if (ret < 0) { dev_err(codec_dai->dev, "ASoC: can't open codec" @@ -242,14 +232,15 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) /* Check that the codec and cpu DAIs are compatible */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->playback, + soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->playback, &cpu_dai_drv->playback); } else { - soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->capture, + soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->capture, &cpu_dai_drv->capture); } ret = -EINVAL; + snd_pcm_limit_hw_rates(runtime); if (!runtime->hw.rates) { printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", codec_dai->name, cpu_dai->name); @@ -326,10 +317,6 @@ out: pm_runtime_put(platform->dev); pm_runtime_put(codec_dai->dev); pm_runtime_put(cpu_dai->dev); - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); return ret; } @@ -439,10 +426,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) pm_runtime_put(platform->dev); pm_runtime_put(codec_dai->dev); pm_runtime_put(cpu_dai->dev); - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); return 0; } @@ -480,7 +463,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } } - if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) { + if (codec_dai->driver->ops->prepare) { ret = codec_dai->driver->ops->prepare(substream, codec_dai); if (ret < 0) { dev_err(codec_dai->dev, "ASoC: DAI prepare error: %d\n", @@ -489,7 +472,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } } - if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) { + if (cpu_dai->driver->ops->prepare) { ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); if (ret < 0) { dev_err(cpu_dai->dev, "ASoC: DAI prepare error: %d\n", @@ -540,7 +523,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } } - if (codec_dai->driver->ops && codec_dai->driver->ops->hw_params) { + if (codec_dai->driver->ops->hw_params) { ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); if (ret < 0) { dev_err(codec_dai->dev, "ASoC: can't set %s hw params:" @@ -549,7 +532,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } } - if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_params) { + if (cpu_dai->driver->ops->hw_params) { ret = cpu_dai->driver->ops->hw_params(substream, params, cpu_dai); if (ret < 0) { dev_err(cpu_dai->dev, "ASoC: %s hw params failed: %d\n", @@ -576,11 +559,11 @@ out: return ret; platform_err: - if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) + if (cpu_dai->driver->ops->hw_free) cpu_dai->driver->ops->hw_free(substream, cpu_dai); interface_err: - if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) + if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free(substream, codec_dai); codec_err: @@ -617,10 +600,10 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) platform->driver->ops->hw_free(substream); /* now free hw params for the DAIs */ - if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) + if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free(substream, codec_dai); - if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) + if (cpu_dai->driver->ops->hw_free) cpu_dai->driver->ops->hw_free(substream, cpu_dai); mutex_unlock(&rtd->pcm_mutex); @@ -635,7 +618,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; - if (codec_dai->driver->ops && codec_dai->driver->ops->trigger) { + if (codec_dai->driver->ops->trigger) { ret = codec_dai->driver->ops->trigger(substream, cmd, codec_dai); if (ret < 0) return ret; @@ -647,7 +630,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) return ret; } - if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) { + if (cpu_dai->driver->ops->trigger) { ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai); if (ret < 0) return ret; @@ -664,20 +647,19 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; - if (codec_dai->driver->ops && - codec_dai->driver->ops->bespoke_trigger) { + if (codec_dai->driver->ops->bespoke_trigger) { ret = codec_dai->driver->ops->bespoke_trigger(substream, cmd, codec_dai); if (ret < 0) return ret; } - if (platform->driver->ops && platform->driver->bespoke_trigger) { + if (platform->driver->bespoke_trigger) { ret = platform->driver->bespoke_trigger(substream, cmd); if (ret < 0) return ret; } - if (cpu_dai->driver->ops && cpu_dai->driver->ops->bespoke_trigger) { + if (cpu_dai->driver->ops->bespoke_trigger) { ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai); if (ret < 0) return ret; @@ -702,10 +684,10 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) if (platform->driver->ops && platform->driver->ops->pointer) offset = platform->driver->ops->pointer(substream); - if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay) + if (cpu_dai->driver->ops->delay) delay += cpu_dai->driver->ops->delay(substream, cpu_dai); - if (codec_dai->driver->ops && codec_dai->driver->ops->delay) + if (codec_dai->driver->ops->delay) delay += codec_dai->driver->ops->delay(substream, codec_dai); if (platform->driver->delay) @@ -739,7 +721,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); - dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", + dev_dbg(fe->dev, " connected new DPCM %s path %s %s %s\n", stream ? "capture" : "playback", fe->dai_link->name, stream ? "<-" : "->", be->dai_link->name); @@ -767,7 +749,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, if (dpcm->fe == fe) continue; - dev_dbg(fe->dev, "reparent %s path %s %s %s\n", + dev_dbg(fe->dev, " reparent %s path %s %s %s\n", stream ? "capture" : "playback", dpcm->fe->dai_link->name, stream ? "<-" : "->", dpcm->be->dai_link->name); @@ -791,7 +773,7 @@ static void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) continue; - dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", + dev_dbg(fe->dev, " freed DSP %s path %s %s %s\n", stream ? "capture" : "playback", fe->dai_link->name, stream ? "<-" : "->", dpcm->be->dai_link->name); @@ -1055,12 +1037,6 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) struct snd_pcm_substream *be_substream = snd_soc_dpcm_get_substream(be, stream); - if (!be_substream) { - dev_err(be->dev, "ASoC: no backend %s stream\n", - stream ? "capture" : "playback"); - continue; - } - /* is this op for this BE ? */ if (!snd_soc_dpcm_be_can_update(fe, be, stream)) continue; @@ -1078,8 +1054,7 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) continue; - dev_dbg(be->dev, "ASoC: open %s BE %s\n", - stream ? "capture" : "playback", be->dai_link->name); + dev_dbg(be->dev, "ASoC: open BE %s\n", be->dai_link->name); be_substream->runtime = be->dpcm[stream].runtime; err = soc_pcm_open(be_substream); @@ -1698,7 +1673,7 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; - if (platform->driver->ops && platform->driver->ops->ioctl) + if (platform->driver->ops->ioctl) return platform->driver->ops->ioctl(substream, cmd, arg); return snd_pcm_lib_ioctl(substream, cmd, arg); } @@ -1959,8 +1934,8 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute) dev_dbg(be->dev, "ASoC: BE digital mute %s\n", be->dai_link->name); - if (drv->ops && drv->ops->digital_mute && dai->playback_active) - drv->ops->digital_mute(dai, mute); + if (drv->ops->digital_mute && dai->playback_active) + drv->ops->digital_mute(dai, mute); } return 0; @@ -2141,7 +2116,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) pcm->private_free = platform->driver->pcm_free; out: - dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", codec_dai->name, + dev_info(rtd->card->dev, " %s <-> %s mapping ok\n", codec_dai->name, cpu_dai->name); return ret; } @@ -2249,7 +2224,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params); int snd_soc_platform_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_platform *platform) { - if (platform->driver->ops && platform->driver->ops->trigger) + if (platform->driver->ops->trigger) return platform->driver->ops->trigger(substream, cmd); return 0; } diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 5e63365..29b211e 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -75,11 +75,7 @@ static const struct snd_pcm_hardware dummy_dma_hardware = { static int dummy_dma_open(struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - /* BE's dont need dummy params */ - if (!rtd->dai_link->no_pcm) - snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware); + snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware); return 0; } diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 21a8c95..63acfeb 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c @@ -257,12 +257,20 @@ static int spdif_in_probe(struct platform_device *pdev) return ret; } - return devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, - &spdif_in_dai, 1); + return snd_soc_register_component(&pdev->dev, &spdif_in_component, + &spdif_in_dai, 1); +} + +static int spdif_in_remove(struct platform_device *pdev) +{ + snd_soc_unregister_component(&pdev->dev); + + return 0; } static struct platform_driver spdif_in_driver = { .probe = spdif_in_probe, + .remove = spdif_in_remove, .driver = { .name = "spdif-in", .owner = THIS_MODULE, diff --git a/sound/soc/spear/spdif_out.c b/sound/soc/spear/spdif_out.c index b6ef6f7..2fdf68c 100644 --- a/sound/soc/spear/spdif_out.c +++ b/sound/soc/spear/spdif_out.c @@ -280,6 +280,7 @@ static int spdif_out_probe(struct platform_device *pdev) struct spdif_out_dev *host; struct spear_spdif_platform_data *pdata; struct resource *res; + int ret; host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); if (!host) { @@ -306,8 +307,16 @@ static int spdif_out_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, host); - return devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, - &spdif_out_dai, 1); + ret = snd_soc_register_component(&pdev->dev, &spdif_out_component, + &spdif_out_dai, 1); + return ret; +} + +static int spdif_out_remove(struct platform_device *pdev) +{ + snd_soc_unregister_component(&pdev->dev); + + return 0; } #ifdef CONFIG_PM @@ -348,6 +357,7 @@ static SIMPLE_DEV_PM_OPS(spdif_out_dev_pm_ops, spdif_out_suspend, \ static struct platform_driver spdif_out_driver = { .probe = spdif_out_probe, + .remove = spdif_out_remove, .driver = { .name = "spdif-out", .owner = THIS_MODULE, diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c index 364bf6a..52af7f6 100644 --- a/sound/soc/tegra/tegra20_i2s.c +++ b/sound/soc/tegra/tegra20_i2s.c @@ -297,7 +297,7 @@ static bool tegra20_i2s_wr_rd_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg) @@ -310,7 +310,7 @@ static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg) @@ -321,7 +321,7 @@ static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static const struct regmap_config tegra20_i2s_regmap_config = { diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c index 08bc693..551b3c9 100644 --- a/sound/soc/tegra/tegra20_spdif.c +++ b/sound/soc/tegra/tegra20_spdif.c @@ -213,7 +213,7 @@ static bool tegra20_spdif_wr_rd_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg) @@ -234,7 +234,7 @@ static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg) @@ -247,7 +247,7 @@ static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static const struct regmap_config tegra20_spdif_regmap_config = { diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 3115433..d554d46 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -100,7 +100,6 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, { int channel; u32 reg, val; - struct tegra30_ahub_cif_conf cif_conf; channel = find_first_zero_bit(ahub->rx_usage, TEGRA30_AHUB_CHANNEL_CTRL_COUNT); @@ -124,21 +123,15 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_16; tegra30_apbif_write(reg, val); - cif_conf.threshold = 0; - cif_conf.audio_channels = 2; - cif_conf.client_channels = 2; - cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.expand = 0; - cif_conf.stereo_conv = 0; - cif_conf.replicate = 0; - cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX; - cif_conf.truncate = 0; - cif_conf.mono_conv = 0; - reg = TEGRA30_AHUB_CIF_RX_CTRL + (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE); - ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); + val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | + TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | + TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 | + TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX; + tegra30_apbif_write(reg, val); return 0; } @@ -190,7 +183,6 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, { int channel; u32 reg, val; - struct tegra30_ahub_cif_conf cif_conf; channel = find_first_zero_bit(ahub->tx_usage, TEGRA30_AHUB_CHANNEL_CTRL_COUNT); @@ -214,21 +206,15 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_16; tegra30_apbif_write(reg, val); - cif_conf.threshold = 0; - cif_conf.audio_channels = 2; - cif_conf.client_channels = 2; - cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.expand = 0; - cif_conf.stereo_conv = 0; - cif_conf.replicate = 0; - cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX; - cif_conf.truncate = 0; - cif_conf.mono_conv = 0; - reg = TEGRA30_AHUB_CIF_TX_CTRL + (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE); - ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); + val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | + TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | + TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 | + TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX; + tegra30_apbif_write(reg, val); return 0; } @@ -360,7 +346,7 @@ static bool tegra30_ahub_apbif_wr_rd_reg(struct device *dev, unsigned int reg) return true; default: break; - } + }; if (REG_IN_ARRAY(reg, CHANNEL_CTRL) || REG_IN_ARRAY(reg, CHANNEL_CLEAR) || @@ -395,7 +381,7 @@ static bool tegra30_ahub_apbif_volatile_reg(struct device *dev, return true; default: break; - } + }; if (REG_IN_ARRAY(reg, CHANNEL_CLEAR) || REG_IN_ARRAY(reg, CHANNEL_STATUS) || @@ -451,21 +437,13 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = { static struct tegra30_ahub_soc_data soc_data_tegra30 = { .clk_list_mask = CLK_LIST_MASK_TEGRA30, - .set_audio_cif = tegra30_ahub_set_cif, }; static struct tegra30_ahub_soc_data soc_data_tegra114 = { .clk_list_mask = CLK_LIST_MASK_TEGRA114, - .set_audio_cif = tegra30_ahub_set_cif, -}; - -static struct tegra30_ahub_soc_data soc_data_tegra124 = { - .clk_list_mask = CLK_LIST_MASK_TEGRA114, - .set_audio_cif = tegra124_ahub_set_cif, }; static const struct of_device_id tegra30_ahub_of_match[] = { - { .compatible = "nvidia,tegra124-ahub", .data = &soc_data_tegra124 }, { .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 }, { .compatible = "nvidia,tegra30-ahub", .data = &soc_data_tegra30 }, {}, @@ -519,7 +497,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev) } dev_set_drvdata(&pdev->dev, ahub); - ahub->soc_data = soc_data; ahub->dev = &pdev->dev; ahub->clk_d_audio = clk_get(&pdev->dev, "d_audio"); @@ -692,70 +669,6 @@ static struct platform_driver tegra30_ahub_driver = { }; module_platform_driver(tegra30_ahub_driver); -void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg, - struct tegra30_ahub_cif_conf *conf) -{ - unsigned int value; - - value = (conf->threshold << - TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | - ((conf->audio_channels - 1) << - TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | - ((conf->client_channels - 1) << - TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | - (conf->audio_bits << - TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) | - (conf->client_bits << - TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) | - (conf->expand << - TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) | - (conf->stereo_conv << - TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | - (conf->replicate << - TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) | - (conf->direction << - TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) | - (conf->truncate << - TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) | - (conf->mono_conv << - TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT); - - regmap_write(regmap, reg, value); -} -EXPORT_SYMBOL_GPL(tegra30_ahub_set_cif); - -void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg, - struct tegra30_ahub_cif_conf *conf) -{ - unsigned int value; - - value = (conf->threshold << - TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | - ((conf->audio_channels - 1) << - TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | - ((conf->client_channels - 1) << - TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | - (conf->audio_bits << - TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) | - (conf->client_bits << - TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) | - (conf->expand << - TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) | - (conf->stereo_conv << - TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | - (conf->replicate << - TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) | - (conf->direction << - TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) | - (conf->truncate << - TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) | - (conf->mono_conv << - TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT); - - regmap_write(regmap, reg, value); -} -EXPORT_SYMBOL_GPL(tegra124_ahub_set_cif); - MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); MODULE_DESCRIPTION("Tegra30 AHUB driver"); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index d67321d..09766cd 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h @@ -25,30 +25,16 @@ #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0xf #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) -#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT 24 -#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0x3f -#define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) - /* Channel count minus 1 */ #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 24 #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 7 #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) /* Channel count minus 1 */ -#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 20 -#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 0xf -#define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) - -/* Channel count minus 1 */ #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16 #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 7 #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) -/* Channel count minus 1 */ -#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16 -#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 0xf -#define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) - #define TEGRA30_AUDIOCIF_BITS_4 0 #define TEGRA30_AUDIOCIF_BITS_8 1 #define TEGRA30_AUDIOCIF_BITS_12 2 @@ -100,7 +86,7 @@ #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH1 (TEGRA30_AUDIOCIF_STEREO_CONV_CH1 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_AVG (TEGRA30_AUDIOCIF_STEREO_CONV_AVG << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) -#define TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT 3 +#define TEGRA30_AUDIOCIF_CTRL_REPLICATE 3 #define TEGRA30_AUDIOCIF_DIRECTION_TX 0 #define TEGRA30_AUDIOCIF_DIRECTION_RX 1 @@ -482,30 +468,8 @@ extern int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif, enum tegra30_ahub_txcif txcif); extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif); -struct tegra30_ahub_cif_conf { - unsigned int threshold; - unsigned int audio_channels; - unsigned int client_channels; - unsigned int audio_bits; - unsigned int client_bits; - unsigned int expand; - unsigned int stereo_conv; - unsigned int replicate; - unsigned int direction; - unsigned int truncate; - unsigned int mono_conv; -}; - -void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg, - struct tegra30_ahub_cif_conf *conf); -void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg, - struct tegra30_ahub_cif_conf *conf); - struct tegra30_ahub_soc_data { u32 clk_list_mask; - void (*set_audio_cif)(struct regmap *regmap, - unsigned int reg, - struct tegra30_ahub_cif_conf *conf); /* * FIXME: There are many more differences in HW, such as: * - More APBIF channels. diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index 231a785..47565fd04 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -30,7 +30,6 @@ #include <linux/io.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> @@ -180,7 +179,6 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream, struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); unsigned int mask, val, reg; int ret, sample_size, srate, i2sclock, bitcnt; - struct tegra30_ahub_cif_conf cif_conf; if (params_channels(params) != 2) return -EINVAL; @@ -219,26 +217,21 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream, regmap_write(i2s->regmap, TEGRA30_I2S_TIMING, val); - cif_conf.threshold = 0; - cif_conf.audio_channels = 2; - cif_conf.client_channels = 2; - cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; - cif_conf.expand = 0; - cif_conf.stereo_conv = 0; - cif_conf.replicate = 0; - cif_conf.truncate = 0; - cif_conf.mono_conv = 0; + val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | + (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | + TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | + TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX; + val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX; reg = TEGRA30_I2S_CIF_RX_CTRL; } else { - cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX; + val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX; reg = TEGRA30_I2S_CIF_TX_CTRL; } - i2s->soc_data->set_audio_cif(i2s->regmap, reg, &cif_conf); + regmap_write(i2s->regmap, reg, val); val = (1 << TEGRA30_I2S_OFFSET_RX_DATA_OFFSET_SHIFT) | (1 << TEGRA30_I2S_OFFSET_TX_DATA_OFFSET_SHIFT); @@ -376,7 +369,7 @@ static bool tegra30_i2s_wr_rd_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg) @@ -389,7 +382,7 @@ static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg) return true; default: return false; - } + }; } static const struct regmap_config tegra30_i2s_regmap_config = { @@ -403,24 +396,9 @@ static const struct regmap_config tegra30_i2s_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static const struct tegra30_i2s_soc_data tegra30_i2s_config = { - .set_audio_cif = tegra30_ahub_set_cif, -}; - -static const struct tegra30_i2s_soc_data tegra124_i2s_config = { - .set_audio_cif = tegra124_ahub_set_cif, -}; - -static const struct of_device_id tegra30_i2s_of_match[] = { - { .compatible = "nvidia,tegra124-i2s", .data = &tegra124_i2s_config }, - { .compatible = "nvidia,tegra30-i2s", .data = &tegra30_i2s_config }, - {}, -}; - static int tegra30_i2s_platform_probe(struct platform_device *pdev) { struct tegra30_i2s *i2s; - const struct of_device_id *match; u32 cif_ids[2]; struct resource *mem, *memregion; void __iomem *regs; @@ -434,14 +412,6 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev) } dev_set_drvdata(&pdev->dev, i2s); - match = of_match_device(tegra30_i2s_of_match, &pdev->dev); - if (!match) { - dev_err(&pdev->dev, "Error: No device match found\n"); - ret = -ENODEV; - goto err; - } - i2s->soc_data = (struct tegra30_i2s_soc_data *)match->data; - i2s->dai = tegra30_i2s_dai_template; i2s->dai.name = dev_name(&pdev->dev); @@ -569,6 +539,11 @@ static int tegra30_i2s_resume(struct device *dev) } #endif +static const struct of_device_id tegra30_i2s_of_match[] = { + { .compatible = "nvidia,tegra30-i2s", }, + {}, +}; + static const struct dev_pm_ops tegra30_i2s_pm_ops = { SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, tegra30_i2s_runtime_resume, NULL) diff --git a/sound/soc/tegra/tegra30_i2s.h b/sound/soc/tegra/tegra30_i2s.h index 4d0b0a3..bea23af 100644 --- a/sound/soc/tegra/tegra30_i2s.h +++ b/sound/soc/tegra/tegra30_i2s.h @@ -225,14 +225,7 @@ #define TEGRA30_I2S_LCOEF_COEF_MASK_US 0xffff #define TEGRA30_I2S_LCOEF_COEF_MASK (TEGRA30_I2S_LCOEF_COEF_MASK_US << TEGRA30_I2S_LCOEF_COEF_SHIFT) -struct tegra30_i2s_soc_data { - void (*set_audio_cif)(struct regmap *regmap, - unsigned int reg, - struct tegra30_ahub_cif_conf *conf); -}; - struct tegra30_i2s { - const struct tegra30_i2s_soc_data *soc_data; struct snd_soc_dai_driver dai; int cif_id; struct clk *clk_i2s; diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 1be311c..d173880 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -182,8 +182,6 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30; else if (of_machine_is_compatible("nvidia,tegra114")) data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114; - else if (of_machine_is_compatible("nvidia,tegra124")) - data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA124; else { dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n"); return -EINVAL; diff --git a/sound/soc/tegra/tegra_asoc_utils.h b/sound/soc/tegra/tegra_asoc_utils.h index 9577121..19fdcaf 100644 --- a/sound/soc/tegra/tegra_asoc_utils.h +++ b/sound/soc/tegra/tegra_asoc_utils.h @@ -30,7 +30,6 @@ enum tegra_asoc_utils_soc { TEGRA_ASOC_UTILS_SOC_TEGRA20, TEGRA_ASOC_UTILS_SOC_TEGRA30, TEGRA_ASOC_UTILS_SOC_TEGRA114, - TEGRA_ASOC_UTILS_SOC_TEGRA124, }; struct tegra_asoc_utils_data { diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index 7b2d23b..f056f63 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -56,6 +56,7 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = { static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { .pcm_hardware = &tegra_pcm_hardware, .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .compat_filter_fn = NULL, .prealloc_buffer_size = PAGE_SIZE * 8, }; diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index fbd077f..45a6428 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -115,8 +115,8 @@ static void txx9aclc_dma_complete(void *arg) spin_lock_irqsave(&dmadata->dma_lock, flags); if (dmadata->frag_count >= 0) { dmadata->dmacount--; - if (!WARN_ON(dmadata->dmacount < 0)) - tasklet_schedule(&dmadata->tasklet); + BUG_ON(dmadata->dmacount < 0); + tasklet_schedule(&dmadata->tasklet); } spin_unlock_irqrestore(&dmadata->dma_lock, flags); } @@ -181,10 +181,7 @@ static void txx9aclc_dma_tasklet(unsigned long data) spin_unlock_irqrestore(&dmadata->dma_lock, flags); return; } - if (WARN_ON(dmadata->dmacount >= NR_DMA_CHAIN)) { - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - return; - } + BUG_ON(dmadata->dmacount >= NR_DMA_CHAIN); while (dmadata->dmacount < NR_DMA_CHAIN) { dmadata->dmacount++; spin_unlock_irqrestore(&dmadata->dma_lock, flags); diff --git a/sound/sound_core.c b/sound/sound_core.c index 11e953a..45759f4 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -626,20 +626,31 @@ static int soundcore_open(struct inode *inode, struct file *file) if (s) new_fops = fops_get(s->unit_fops); } - spin_unlock(&sound_loader_lock); if (new_fops) { /* * We rely upon the fact that we can't be unloaded while the - * subdriver is there. + * subdriver is there, so if ->open() is successful we can + * safely drop the reference counter and if it is not we can + * revert to old ->f_op. Ugly, indeed, but that's the cost of + * switching ->f_op in the first place. */ int err = 0; - replace_fops(file, new_fops); + const struct file_operations *old_fops = file->f_op; + file->f_op = new_fops; + spin_unlock(&sound_loader_lock); if (file->f_op->open) err = file->f_op->open(inode,file); + if (err) { + fops_put(file->f_op); + file->f_op = fops_get(old_fops); + } + + fops_put(old_fops); return err; } + spin_unlock(&sound_loader_lock); return -ENODEV; } diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index dbb1b625..54aaad2 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -429,8 +429,7 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, unsigned int period_size = snd_pcm_lib_period_bytes(substream); unsigned int offset = period_size * (*periods_sent); - if (WARN_ON(period_size >= (1 << 24))) - return; + BUG_ON(period_size >= (1 << 24)); if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) @@ -907,24 +906,18 @@ static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; - int ret = 0; spin_lock_irqsave(&chip->lock, flags); chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO); - if (WARN_ON(runtime->period_size > 0xffff + 1)) { - ret = -EINVAL; - goto out; - } + BUG_ON(runtime->period_size > 0xffff + 1); chip->p_periods_sent = 0; - -out: spin_unlock_irqrestore(&chip->lock, flags); - return ret; + return 0; } static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c index 66edc4a..c39c779 100644 --- a/sound/usb/6fire/chip.c +++ b/sound/usb/6fire/chip.c @@ -101,7 +101,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf, usb_set_intfdata(intf, chips[i]); mutex_unlock(®ister_mutex); return 0; - } else if (!devices[i] && regidx < 0) + } else if (regidx < 0) regidx = i; } if (regidx < 0) { diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c index f65fc09..ae6b50f 100644 --- a/sound/usb/caiaq/control.c +++ b/sound/usb/caiaq/control.c @@ -28,7 +28,6 @@ #include "control.h" #define CNT_INTVAL 0x10000 -#define MASCHINE_BANK_SIZE 32 static int control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -106,10 +105,6 @@ static int control_put(struct snd_kcontrol *kcontrol, USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) cmd = EP1_CMD_DIMM_LEDS; - if (cdev->chip.usb_id == - USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) - cmd = EP1_CMD_DIMM_LEDS; - if (pos & CNT_INTVAL) { int i = pos & ~CNT_INTVAL; @@ -126,20 +121,6 @@ static int control_put(struct snd_kcontrol *kcontrol, usb_sndbulkpipe(cdev->chip.dev, 8), cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), &actual_len, 200); - } else if (cdev->chip.usb_id == - USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) { - - int bank = 0; - int offset = 0; - - if (i >= MASCHINE_BANK_SIZE) { - bank = 0x1e; - offset = MASCHINE_BANK_SIZE; - } - - snd_usb_caiaq_send_command_bank(cdev, cmd, bank, - cdev->control_state + offset, - MASCHINE_BANK_SIZE); } else { snd_usb_caiaq_send_command(cdev, cmd, cdev->control_state, sizeof(cdev->control_state)); @@ -509,74 +490,6 @@ static struct caiaq_controller kontrols4_controller[] = { { "LED: FX2: Mode", 133 | CNT_INTVAL }, }; -static struct caiaq_controller maschine_controller[] = { - { "LED: Pad 1", 3 | CNT_INTVAL }, - { "LED: Pad 2", 2 | CNT_INTVAL }, - { "LED: Pad 3", 1 | CNT_INTVAL }, - { "LED: Pad 4", 0 | CNT_INTVAL }, - { "LED: Pad 5", 7 | CNT_INTVAL }, - { "LED: Pad 6", 6 | CNT_INTVAL }, - { "LED: Pad 7", 5 | CNT_INTVAL }, - { "LED: Pad 8", 4 | CNT_INTVAL }, - { "LED: Pad 9", 11 | CNT_INTVAL }, - { "LED: Pad 10", 10 | CNT_INTVAL }, - { "LED: Pad 11", 9 | CNT_INTVAL }, - { "LED: Pad 12", 8 | CNT_INTVAL }, - { "LED: Pad 13", 15 | CNT_INTVAL }, - { "LED: Pad 14", 14 | CNT_INTVAL }, - { "LED: Pad 15", 13 | CNT_INTVAL }, - { "LED: Pad 16", 12 | CNT_INTVAL }, - - { "LED: Mute", 16 | CNT_INTVAL }, - { "LED: Solo", 17 | CNT_INTVAL }, - { "LED: Select", 18 | CNT_INTVAL }, - { "LED: Duplicate", 19 | CNT_INTVAL }, - { "LED: Navigate", 20 | CNT_INTVAL }, - { "LED: Pad Mode", 21 | CNT_INTVAL }, - { "LED: Pattern", 22 | CNT_INTVAL }, - { "LED: Scene", 23 | CNT_INTVAL }, - - { "LED: Shift", 24 | CNT_INTVAL }, - { "LED: Erase", 25 | CNT_INTVAL }, - { "LED: Grid", 26 | CNT_INTVAL }, - { "LED: Right Bottom", 27 | CNT_INTVAL }, - { "LED: Rec", 28 | CNT_INTVAL }, - { "LED: Play", 29 | CNT_INTVAL }, - { "LED: Left Bottom", 32 | CNT_INTVAL }, - { "LED: Restart", 33 | CNT_INTVAL }, - - { "LED: Group A", 41 | CNT_INTVAL }, - { "LED: Group B", 40 | CNT_INTVAL }, - { "LED: Group C", 37 | CNT_INTVAL }, - { "LED: Group D", 36 | CNT_INTVAL }, - { "LED: Group E", 39 | CNT_INTVAL }, - { "LED: Group F", 38 | CNT_INTVAL }, - { "LED: Group G", 35 | CNT_INTVAL }, - { "LED: Group H", 34 | CNT_INTVAL }, - - { "LED: Auto Write", 42 | CNT_INTVAL }, - { "LED: Snap", 43 | CNT_INTVAL }, - { "LED: Right Top", 44 | CNT_INTVAL }, - { "LED: Left Top", 45 | CNT_INTVAL }, - { "LED: Sampling", 46 | CNT_INTVAL }, - { "LED: Browse", 47 | CNT_INTVAL }, - { "LED: Step", 48 | CNT_INTVAL }, - { "LED: Control", 49 | CNT_INTVAL }, - - { "LED: Top Button 1", 57 | CNT_INTVAL }, - { "LED: Top Button 2", 56 | CNT_INTVAL }, - { "LED: Top Button 3", 55 | CNT_INTVAL }, - { "LED: Top Button 4", 54 | CNT_INTVAL }, - { "LED: Top Button 5", 53 | CNT_INTVAL }, - { "LED: Top Button 6", 52 | CNT_INTVAL }, - { "LED: Top Button 7", 51 | CNT_INTVAL }, - { "LED: Top Button 8", 50 | CNT_INTVAL }, - - { "LED: Note Repeat", 58 | CNT_INTVAL }, - - { "Backlight Display", 59 | CNT_INTVAL } -}; - static int add_controls(struct caiaq_controller *c, int num, struct snd_usb_caiaqdev *cdev) { @@ -640,11 +553,6 @@ int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev) ret = add_controls(kontrols4_controller, ARRAY_SIZE(kontrols4_controller), cdev); break; - - case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): - ret = add_controls(maschine_controller, - ARRAY_SIZE(maschine_controller), cdev); - break; } return ret; diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index bc55f70..1a61dd1 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c @@ -235,31 +235,6 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, cdev->ep1_out_buf, len+1, &actual_len, 200); } -int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev, - unsigned char command, - unsigned char bank, - const unsigned char *buffer, - int len) -{ - int actual_len; - struct usb_device *usb_dev = cdev->chip.dev; - - if (!usb_dev) - return -EIO; - - if (len > EP1_BUFSIZE - 2) - len = EP1_BUFSIZE - 2; - - if (buffer && len > 0) - memcpy(cdev->ep1_out_buf+2, buffer, len); - - cdev->ep1_out_buf[0] = command; - cdev->ep1_out_buf[1] = bank; - - return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), - cdev->ep1_out_buf, len+2, &actual_len, 200); -} - int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bpp) { diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index ab0f752..ad102fa 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h @@ -128,10 +128,5 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, unsigned char command, const unsigned char *buffer, int len); -int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev, - unsigned char command, - unsigned char bank, - const unsigned char *buffer, - int len); #endif /* CAIAQ_DEVICE_H */ diff --git a/sound/usb/card.c b/sound/usb/card.c index d979050..64952e2 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -79,6 +79,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card * /* Vendor/product IDs for this card */ static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; +static int nrpacks = 8; /* max. number of packets per urb */ static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ static bool ignore_ctl_error; static bool autoclock = true; @@ -93,6 +94,8 @@ module_param_array(vid, int, NULL, 0444); MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device."); module_param_array(pid, int, NULL, 0444); MODULE_PARM_DESC(pid, "Product ID for the USB audio device."); +module_param(nrpacks, int, 0644); +MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB."); module_param_array(device_setup, int, NULL, 0444); MODULE_PARM_DESC(device_setup, "Specific device setup (if needed)."); module_param(ignore_ctl_error, bool, 0444); @@ -346,7 +349,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, case USB_SPEED_LOW: case USB_SPEED_FULL: case USB_SPEED_HIGH: - case USB_SPEED_WIRELESS: case USB_SPEED_SUPER: break; default: @@ -372,6 +374,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, chip->dev = dev; chip->card = card; chip->setup = device_setup[idx]; + chip->nrpacks = nrpacks; chip->autoclock = autoclock; chip->probing = 1; @@ -751,4 +754,19 @@ static struct usb_driver usb_audio_driver = { .supports_autosuspend = 1, }; -module_usb_driver(usb_audio_driver); +static int __init snd_usb_audio_init(void) +{ + if (nrpacks < 1 || nrpacks > MAX_PACKS) { + printk(KERN_WARNING "invalid nrpacks value.\n"); + return -EINVAL; + } + return usb_register(&usb_audio_driver); +} + +static void __exit snd_usb_audio_cleanup(void) +{ + usb_deregister(&usb_audio_driver); +} + +module_init(snd_usb_audio_init); +module_exit(snd_usb_audio_cleanup); diff --git a/sound/usb/card.h b/sound/usb/card.h index 9867ab8..5ecacaa 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -2,11 +2,11 @@ #define __USBAUDIO_CARD_H #define MAX_NR_RATES 1024 -#define MAX_PACKS 6 /* per URB */ +#define MAX_PACKS 20 #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ -#define MAX_URBS 12 +#define MAX_URBS 8 #define SYNC_URBS 4 /* always four urbs for sync */ -#define MAX_QUEUE 18 /* try not to exceed this queue length, in ms */ +#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */ struct audioformat { struct list_head list; @@ -87,7 +87,6 @@ struct snd_usb_endpoint { unsigned int phase; /* phase accumulator */ unsigned int maxpacksize; /* max packet size in bytes */ unsigned int maxframesize; /* max packet size in frames */ - unsigned int max_urb_frames; /* max URB size in frames */ unsigned int curpacksize; /* current packet size in bytes (for capture) */ unsigned int curframesize; /* current packet size in frames (for capture) */ unsigned int syncmaxsize; /* sync endpoint packet size */ @@ -96,7 +95,7 @@ struct snd_usb_endpoint { unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */ unsigned char silence_value; unsigned int stride; - int iface, altsetting; + int iface, alt_idx; int skip_packets; /* quirks for devices to ignore the first n packets in a stream */ @@ -117,8 +116,6 @@ struct snd_usb_substream { unsigned int channels_max; /* max channels in the all audiofmts */ unsigned int cur_rate; /* current rate (for hw_params callback) */ unsigned int period_bytes; /* current period bytes (for hw_params callback) */ - unsigned int period_frames; /* current frames per period */ - unsigned int buffer_periods; /* current periods per buffer */ unsigned int altset_idx; /* USB data format: index of alternate setting */ unsigned int txfr_quirk:1; /* allow sub-frame alignment */ unsigned int fmt_type; /* USB audio format type (1-3) */ @@ -128,7 +125,6 @@ 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 int frame_limit; /* limits number of packets in URB */ /* data and sync endpoints for this stream */ unsigned int ep_num; /* the endpoint number */ diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 83aabea2..93e970f 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -33,6 +33,7 @@ #include "pcm.h" #include "quirks.h" +#define EP_FLAG_ACTIVATED 0 #define EP_FLAG_RUNNING 1 #define EP_FLAG_STOPPING 2 @@ -425,9 +426,9 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, list_for_each_entry(ep, &chip->ep_list, list) { if (ep->ep_num == ep_num && ep->iface == alts->desc.bInterfaceNumber && - ep->altsetting == alts->desc.bAlternateSetting) { + ep->alt_idx == alts->desc.bAlternateSetting) { snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n", - ep_num, ep->iface, ep->altsetting, ep); + ep_num, ep->iface, ep->alt_idx, ep); goto __exit_unlock; } } @@ -446,7 +447,7 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, ep->type = type; ep->ep_num = ep_num; ep->iface = alts->desc.bInterfaceNumber; - ep->altsetting = alts->desc.bAlternateSetting; + ep->alt_idx = alts->desc.bAlternateSetting; INIT_LIST_HEAD(&ep->ready_playback_urbs); ep_num &= USB_ENDPOINT_NUMBER_MASK; @@ -573,14 +574,11 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, snd_pcm_format_t pcm_format, unsigned int channels, unsigned int period_bytes, - unsigned int frames_per_period, - unsigned int periods_per_buffer, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep) { - unsigned int maxsize, minsize, packs_per_ms, max_packs_per_urb; - unsigned int max_packs_per_period, urbs_per_period, urb_packs; - unsigned int max_urbs, i; + unsigned int maxsize, i, urb_packs, total_packs, packs_per_ms; + int is_playback = usb_pipeout(ep->pipe); int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) { @@ -613,81 +611,58 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, else ep->curpacksize = maxsize; - if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) { + if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) packs_per_ms = 8 >> ep->datainterval; - max_packs_per_urb = MAX_PACKS_HS; - } else { + else packs_per_ms = 1; - max_packs_per_urb = MAX_PACKS; + + if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { + urb_packs = max(ep->chip->nrpacks, 1); + urb_packs = min(urb_packs, (unsigned int) MAX_PACKS); + } else { + urb_packs = 1; } - if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep)) - max_packs_per_urb = min(max_packs_per_urb, - 1U << sync_ep->syncinterval); - max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval); - /* - * Capture endpoints need to use small URBs because there's no way - * to tell in advance where the next period will end, and we don't - * want the next URB to complete much after the period ends. - * - * Playback endpoints with implicit sync much use the same parameters - * as their corresponding capture endpoint. - */ - if (usb_pipein(ep->pipe) || - snd_usb_endpoint_implicit_feedback_sink(ep)) { + urb_packs *= packs_per_ms; - urb_packs = packs_per_ms; - /* - * Wireless devices can poll at a max rate of once per 4ms. - * For dataintervals less than 5, increase the packet count to - * allow the host controller to use bursting to fill in the - * gaps. - */ - if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_WIRELESS) { - int interval = ep->datainterval; - while (interval < 5) { - urb_packs <<= 1; - ++interval; - } - } - /* make capture URBs <= 1 ms and smaller than a period */ - urb_packs = min(max_packs_per_urb, urb_packs); - while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) - urb_packs >>= 1; - ep->nurbs = MAX_URBS; + if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep)) + urb_packs = min(urb_packs, 1U << sync_ep->syncinterval); - /* - * Playback endpoints without implicit sync are adjusted so that - * a period fits as evenly as possible in the smallest number of - * URBs. The total number of URBs is adjusted to the size of the - * ALSA buffer, subject to the MAX_URBS and MAX_QUEUE limits. - */ - } else { + /* decide how many packets to be used */ + if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { + unsigned int minsize, maxpacks; /* determine how small a packet can be */ - minsize = (ep->freqn >> (16 - ep->datainterval)) * - (frame_bits >> 3); + minsize = (ep->freqn >> (16 - ep->datainterval)) + * (frame_bits >> 3); /* with sync from device, assume it can be 12% lower */ if (sync_ep) minsize -= minsize >> 3; minsize = max(minsize, 1u); + total_packs = (period_bytes + minsize - 1) / minsize; + /* we need at least two URBs for queueing */ + if (total_packs < 2) { + total_packs = 2; + } else { + /* and we don't want too long a queue either */ + maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); + total_packs = min(total_packs, maxpacks); + } + } else { + while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) + urb_packs >>= 1; + total_packs = MAX_URBS * urb_packs; + } - /* how many packets will contain an entire ALSA period? */ - max_packs_per_period = DIV_ROUND_UP(period_bytes, minsize); - - /* how many URBs will contain a period? */ - urbs_per_period = DIV_ROUND_UP(max_packs_per_period, - max_packs_per_urb); - /* how many packets are needed in each URB? */ - urb_packs = DIV_ROUND_UP(max_packs_per_period, urbs_per_period); - - /* limit the number of frames in a single URB */ - ep->max_urb_frames = DIV_ROUND_UP(frames_per_period, - urbs_per_period); - - /* try to use enough URBs to contain an entire ALSA buffer */ - max_urbs = min((unsigned) MAX_URBS, - MAX_QUEUE * packs_per_ms / urb_packs); - ep->nurbs = min(max_urbs, urbs_per_period * periods_per_buffer); + ep->nurbs = (total_packs + urb_packs - 1) / urb_packs; + if (ep->nurbs > MAX_URBS) { + /* too much... */ + ep->nurbs = MAX_URBS; + total_packs = MAX_URBS * urb_packs; + } else if (ep->nurbs < 2) { + /* too little - we need at least two packets + * to ensure contiguous playback/capture + */ + ep->nurbs = 2; } /* allocate and initialize data urbs */ @@ -695,7 +670,8 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, struct snd_urb_ctx *u = &ep->urb[i]; u->index = i; u->ep = ep; - u->packets = urb_packs; + u->packets = (i + 1) * total_packs / ep->nurbs + - i * total_packs / ep->nurbs; u->buffer_size = maxsize * u->packets; if (fmt->fmt_type == UAC_FORMAT_TYPE_II) @@ -727,7 +703,8 @@ out_of_memory: /* * configure a sync endpoint */ -static int sync_ep_set_params(struct snd_usb_endpoint *ep) +static int sync_ep_set_params(struct snd_usb_endpoint *ep, + struct audioformat *fmt) { int i; @@ -771,8 +748,6 @@ out_of_memory: * @pcm_format: the audio fomat. * @channels: the number of audio channels. * @period_bytes: the number of bytes in one alsa period. - * @period_frames: the number of frames in one alsa period. - * @buffer_periods: the number of periods in one alsa buffer. * @rate: the frame rate. * @fmt: the USB audio format information * @sync_ep: the sync endpoint to use, if any @@ -785,8 +760,6 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, snd_pcm_format_t pcm_format, unsigned int channels, unsigned int period_bytes, - unsigned int period_frames, - unsigned int buffer_periods, unsigned int rate, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep) @@ -820,11 +793,10 @@ 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, pcm_format, channels, - period_bytes, period_frames, - buffer_periods, fmt, sync_ep); + period_bytes, fmt, sync_ep); break; case SND_USB_ENDPOINT_TYPE_SYNC: - err = sync_ep_set_params(ep); + err = sync_ep_set_params(ep, fmt); break; default: err = -EINVAL; @@ -959,21 +931,28 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep) * * @ep: the endpoint to deactivate * - * If the endpoint is not currently in use, this functions will - * deactivate its associated URBs. + * If the endpoint is not currently in use, this functions will select the + * alternate interface setting 0 for the interface of this endpoint. * * In case of any active users, this functions does nothing. + * + * Returns an error if usb_set_interface() failed, 0 in all other + * cases. */ -void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) +int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) { if (!ep) - return; - - if (ep->use_count != 0) - return; + return -EINVAL; deactivate_urbs(ep, true); wait_clear_urbs(ep); + + if (ep->use_count != 0) + return 0; + + clear_bit(EP_FLAG_ACTIVATED, &ep->flags); + + return 0; } /** diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index 1c7e8ee..2287adf 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h @@ -12,8 +12,6 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, snd_pcm_format_t pcm_format, unsigned int channels, unsigned int period_bytes, - unsigned int period_frames, - unsigned int buffer_periods, unsigned int rate, struct audioformat *fmt, struct snd_usb_endpoint *sync_ep); @@ -22,7 +20,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep); void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep); void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); -void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); +int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); void snd_usb_endpoint_free(struct list_head *head); int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 51ed1ac..6209024 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c @@ -118,7 +118,6 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip, { switch (snd_usb_get_speed(chip->dev)) { case USB_SPEED_HIGH: - case USB_SPEED_WIRELESS: case USB_SPEED_SUPER: if (get_endpoint(alts, 0)->bInterval >= 1 && get_endpoint(alts, 0)->bInterval <= 4) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 44b0ba4..95558ef 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1151,14 +1151,14 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, const char *names_to_check[] = { "Headset", "headset", "Headphone", "headphone", NULL}; const char **s; - bool found = false; + bool found = 0; if (strcmp("Speaker", kctl->id.name)) return; for (s = names_to_check; *s; s++) if (strstr(card->shortname, *s)) { - found = true; + found = 1; break; } diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 3454262..d42a584 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -433,89 +433,6 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, } } -/* EMU0204 */ -static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - static const char *texts[2] = {"1/2", - "3/4" - }; - - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = 2; - if (uinfo->value.enumerated.item > 1) - uinfo->value.enumerated.item = 1; - strcpy(uinfo->value.enumerated.name, - texts[uinfo->value.enumerated.item]); - - return 0; -} - -static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.enumerated.item[0] = kcontrol->private_value; - return 0; -} - -static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); - unsigned int value = ucontrol->value.enumerated.item[0]; - int err, changed; - unsigned char buf[2]; - - if (value > 1) - return -EINVAL; - - buf[0] = 0x01; - buf[1] = value ? 0x02 : 0x01; - - changed = value != kcontrol->private_value; - down_read(&mixer->chip->shutdown_rwsem); - if (mixer->chip->shutdown) { - err = -ENODEV; - goto out; - } - err = snd_usb_ctl_msg(mixer->chip->dev, - usb_sndctrlpipe(mixer->chip->dev, 0), UAC_SET_CUR, - USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, - 0x0400, 0x0e00, buf, 2); - out: - up_read(&mixer->chip->shutdown_rwsem); - if (err < 0) - return err; - kcontrol->private_value = value; - return changed; -} - - -static struct snd_kcontrol_new snd_emu0204_controls[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Front Jack Channels", - .info = snd_emu0204_ch_switch_info, - .get = snd_emu0204_ch_switch_get, - .put = snd_emu0204_ch_switch_put, - .private_value = 0, - }, -}; - -static int snd_emu0204_controls_create(struct usb_mixer_interface *mixer) -{ - int i, err; - - for (i = 0; i < ARRAY_SIZE(snd_emu0204_controls); ++i) { - err = snd_ctl_add(mixer->chip->card, - snd_ctl_new1(&snd_emu0204_controls[i], mixer)); - if (err < 0) - return err; - } - - return 0; -} /* ASUS Xonar U1 / U3 controls */ static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, @@ -1628,13 +1545,6 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) snd_audigy2nx_proc_read); break; - /* EMU0204 */ - case USB_ID(0x041e, 0x3f19): - err = snd_emu0204_controls_create(mixer); - if (err < 0) - break; - break; - case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */ err = snd_c400_create_mixer(mixer); diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index ca3256d..b375d58 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -241,17 +241,16 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) struct snd_usb_endpoint *ep = subs->sync_endpoint; if (subs->data_endpoint->iface != subs->sync_endpoint->iface || - subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) { + subs->data_endpoint->alt_idx != subs->sync_endpoint->alt_idx) { err = usb_set_interface(subs->dev, subs->sync_endpoint->iface, - subs->sync_endpoint->altsetting); + subs->sync_endpoint->alt_idx); if (err < 0) { - clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); snd_printk(KERN_ERR "%d:%d:%d: cannot set interface (%d)\n", subs->dev->devnum, subs->sync_endpoint->iface, - subs->sync_endpoint->altsetting, err); + subs->sync_endpoint->alt_idx, err); return -EIO; } } @@ -283,6 +282,22 @@ static void stop_endpoints(struct snd_usb_substream *subs, bool wait) } } +static int deactivate_endpoints(struct snd_usb_substream *subs) +{ + int reta, retb; + + reta = snd_usb_endpoint_deactivate(subs->sync_endpoint); + retb = snd_usb_endpoint_deactivate(subs->data_endpoint); + + if (reta < 0) + return reta; + + if (retb < 0) + return retb; + + return 0; +} + static int search_roland_implicit_fb(struct usb_device *dev, int ifnum, unsigned int altsetting, struct usb_host_interface **alts, @@ -580,7 +595,6 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) subs->pcm_format, subs->channels, subs->period_bytes, - 0, 0, subs->cur_rate, subs->cur_audiofmt, NULL); @@ -617,7 +631,6 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) subs->pcm_format, sync_fp->channels, sync_period_bytes, - 0, 0, subs->cur_rate, sync_fp, NULL); @@ -640,8 +653,6 @@ static int configure_endpoint(struct snd_usb_substream *subs) subs->pcm_format, subs->channels, subs->period_bytes, - subs->period_frames, - subs->buffer_periods, subs->cur_rate, subs->cur_audiofmt, subs->sync_endpoint); @@ -678,8 +689,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, subs->pcm_format = params_format(hw_params); subs->period_bytes = params_period_bytes(hw_params); - subs->period_frames = params_period_size(hw_params); - subs->buffer_periods = params_periods(hw_params); subs->channels = params_channels(hw_params); subs->cur_rate = params_rate(hw_params); @@ -721,8 +730,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) down_read(&subs->stream->chip->shutdown_rwsem); if (!subs->stream->chip->shutdown) { stop_endpoints(subs, true); - snd_usb_endpoint_deactivate(subs->sync_endpoint); - snd_usb_endpoint_deactivate(subs->data_endpoint); + deactivate_endpoints(subs); } up_read(&subs->stream->chip->shutdown_rwsem); return snd_pcm_lib_free_vmalloc_buffer(substream); @@ -1355,7 +1363,6 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, frames = 0; urb->number_of_packets = 0; spin_lock_irqsave(&subs->lock, flags); - subs->frame_limit += ep->max_urb_frames; for (i = 0; i < ctx->packets; i++) { if (ctx->packet_size[i]) counts = ctx->packet_size[i]; @@ -1370,7 +1377,6 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, subs->transfer_done += counts; if (subs->transfer_done >= runtime->period_size) { subs->transfer_done -= runtime->period_size; - subs->frame_limit = 0; period_elapsed = 1; if (subs->fmt_type == UAC_FORMAT_TYPE_II) { if (subs->transfer_done > 0) { @@ -1393,10 +1399,8 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, break; } } - /* finish at the period boundary or after enough frames */ - if ((period_elapsed || - subs->transfer_done >= subs->frame_limit) && - !snd_usb_endpoint_implicit_feedback_sink(ep)) + if (period_elapsed && + !snd_usb_endpoint_implicit_feedback_sink(subs->data_endpoint)) /* finish at the period boundary */ break; } bytes = frames * ep->stride; diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 2fb71be..c4339f9 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -273,14 +273,16 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, SNDRV_CHMAP_TSL, /* top side left */ SNDRV_CHMAP_TSR, /* top side right */ SNDRV_CHMAP_BC, /* bottom center */ - SNDRV_CHMAP_RLC, /* back left of center */ - SNDRV_CHMAP_RRC, /* back right of center */ + SNDRV_CHMAP_BLC, /* bottom left center */ + SNDRV_CHMAP_BRC, /* bottom right center */ 0 /* terminator */ }; struct snd_pcm_chmap_elem *chmap; const unsigned int *maps; int c; + if (!bits) + return NULL; if (channels > ARRAY_SIZE(chmap->map)) return NULL; @@ -291,19 +293,9 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, maps = protocol == UAC_VERSION_2 ? uac2_maps : uac1_maps; chmap->channels = channels; c = 0; - - if (bits) { - for (; bits && *maps; maps++, bits >>= 1) - if (bits & 1) - chmap->map[c++] = *maps; - } else { - /* If we're missing wChannelConfig, then guess something - to make sure the channel map is not skipped entirely */ - if (channels == 1) - chmap->map[c++] = SNDRV_CHMAP_MONO; - else - for (; c < channels && *maps; maps++) - chmap->map[c++] = *maps; + for (; bits && *maps; maps++, bits >>= 1) { + if (bits & 1) + chmap->map[c++] = *maps; } for (; c < channels; c++) @@ -587,7 +579,6 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) num_channels = as->bNrChannels; format = le32_to_cpu(as->bmFormats); - chconfig = le32_to_cpu(as->bmChannelConfig); /* lookup the terminal associated to this interface * to extract the clock */ @@ -595,8 +586,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) as->bTerminalLink); if (input_term) { clock = input_term->bCSourceID; - if (!chconfig && (num_channels == input_term->bNrChannels)) - chconfig = le32_to_cpu(input_term->bmChannelConfig); + chconfig = le32_to_cpu(input_term->bmChannelConfig); break; } @@ -662,6 +652,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) * (fp->maxpacksize & 0x7ff); fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); fp->clock = clock; + fp->chmap = convert_chmap(num_channels, chconfig, protocol); /* some quirks for attributes here */ @@ -697,16 +688,12 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) /* ok, let's parse further... */ if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) { kfree(fp->rate_table); + kfree(fp->chmap); kfree(fp); fp = NULL; continue; } - /* Create chmap */ - if (fp->channels != num_channels) - chconfig = 0; - fp->chmap = convert_chmap(fp->channels, chconfig, protocol); - snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint); err = snd_usb_add_audio_stream(chip, stream, fp); if (err < 0) { diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 5d2fe05..caabe9b 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -55,6 +55,7 @@ struct snd_usb_audio { struct list_head mixer_list; /* list of mixer interfaces */ int setup; /* from the 'device_setup' module param */ + int nrpacks; /* from the 'nrpacks' module param */ bool autoclock; /* from the 'autoclock' module param */ struct usb_host_interface *ctrl_intf; /* the audio control interface */ |