Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/adau', 'asoc/topic/adau700…
Browse files Browse the repository at this point in the history
…2', 'asoc/topic/adsp', 'asoc/topic/ak4613' and 'asoc/topic/ak4642' into asoc-next
  • Loading branch information
broonie committed Jul 24, 2016
6 parents a39fbe0 + 5d76de6 + a0d3546 + 6facd2d + f9ae17b + a2ebd58 commit 72a04d6
Show file tree
Hide file tree
Showing 24 changed files with 555 additions and 140 deletions.
8 changes: 8 additions & 0 deletions Documentation/devicetree/bindings/sound/adi,adau17x1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ Required properties:
- reg: The i2c address. Value depends on the state of ADDR0
and ADDR1, as wired in hardware.

Optional properties:
- clock-names: If provided must be "mclk".
- clocks: phandle + clock-specifiers for the clock that provides
the audio master clock for the device.

Examples:
#include <dt-bindings/sound/adau17x1.h>

i2c_bus {
adau1361@38 {
compatible = "adi,adau1761";
reg = <0x38>;

clock-names = "mclk";
clocks = <&audio_clock>;
};
};
19 changes: 19 additions & 0 deletions Documentation/devicetree/bindings/sound/adi,adau7002.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Analog Devices ADAU7002 Stereo PDM-to-I2S/TDM Converter

Required properties:

- compatible: Must be "adi,adau7002"

Optional properties:

- IOVDD-supply: Phandle and specifier for the power supply providing the IOVDD
supply as covered in Documentation/devicetree/bindings/regulator/regulator.txt

If this property is not present it is assumed that the supply pin is
hardwired to always on.

Example:
adau7002: pdm-to-i2s {
compatible = "adi,adau7002";
IOVDD-supply = <&supply>;
};
10 changes: 10 additions & 0 deletions include/linux/mfd/arizona/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define _WM_ARIZONA_CORE_H

#include <linux/interrupt.h>
#include <linux/notifier.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/mfd/arizona/pdata.h>
Expand Down Expand Up @@ -148,8 +149,17 @@ struct arizona {
uint16_t dac_comp_coeff;
uint8_t dac_comp_enabled;
struct mutex dac_comp_lock;

struct blocking_notifier_head notifier;
};

static inline int arizona_call_notifiers(struct arizona *arizona,
unsigned long event,
void *data)
{
return blocking_notifier_call_chain(&arizona->notifier, event, data);
}

int arizona_clk32k_enable(struct arizona *arizona);
int arizona_clk32k_disable(struct arizona *arizona);

Expand Down
5 changes: 5 additions & 0 deletions include/sound/compress_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct snd_compr_runtime {
* @ops: pointer to DSP callbacks
* @runtime: pointer to runtime structure
* @device: device pointer
* @error_work: delayed work used when closing the stream due to an error
* @direction: stream direction, playback/recording
* @metadata_set: metadata set flag, true when set
* @next_track: has userspace signal next track transition, true when set
Expand All @@ -78,6 +79,7 @@ struct snd_compr_stream {
struct snd_compr_ops *ops;
struct snd_compr_runtime *runtime;
struct snd_compr *device;
struct delayed_work error_work;
enum snd_compr_direction direction;
bool metadata_set;
bool next_track;
Expand Down Expand Up @@ -187,4 +189,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
wake_up(&stream->runtime->sleep);
}

int snd_compr_stop_error(struct snd_compr_stream *stream,
snd_pcm_state_t state);

#endif
67 changes: 65 additions & 2 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ struct snd_compr_file {
struct snd_compr_stream stream;
};

static void error_delayed_work(struct work_struct *work);

/*
* a note on stream states used:
* we use following states in the compressed core
Expand Down Expand Up @@ -123,6 +125,9 @@ static int snd_compr_open(struct inode *inode, struct file *f)
snd_card_unref(compr->card);
return -ENOMEM;
}

INIT_DELAYED_WORK(&data->stream.error_work, error_delayed_work);

data->stream.ops = compr->ops;
data->stream.direction = dirn;
data->stream.private_data = compr->private_data;
Expand Down Expand Up @@ -153,6 +158,8 @@ static int snd_compr_free(struct inode *inode, struct file *f)
struct snd_compr_file *data = f->private_data;
struct snd_compr_runtime *runtime = data->stream.runtime;

cancel_delayed_work_sync(&data->stream.error_work);

switch (runtime->state) {
case SNDRV_PCM_STATE_RUNNING:
case SNDRV_PCM_STATE_DRAINING:
Expand Down Expand Up @@ -237,6 +244,15 @@ snd_compr_ioctl_avail(struct snd_compr_stream *stream, unsigned long arg)
avail = snd_compr_calc_avail(stream, &ioctl_avail);
ioctl_avail.avail = avail;

switch (stream->runtime->state) {
case SNDRV_PCM_STATE_OPEN:
return -EBADFD;
case SNDRV_PCM_STATE_XRUN:
return -EPIPE;
default:
break;
}

if (copy_to_user((__u64 __user *)arg,
&ioctl_avail, sizeof(ioctl_avail)))
return -EFAULT;
Expand Down Expand Up @@ -346,11 +362,13 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf,
switch (stream->runtime->state) {
case SNDRV_PCM_STATE_OPEN:
case SNDRV_PCM_STATE_PREPARED:
case SNDRV_PCM_STATE_XRUN:
case SNDRV_PCM_STATE_SUSPENDED:
case SNDRV_PCM_STATE_DISCONNECTED:
retval = -EBADFD;
goto out;
case SNDRV_PCM_STATE_XRUN:
retval = -EPIPE;
goto out;
}

avail = snd_compr_get_avail(stream);
Expand Down Expand Up @@ -399,10 +417,16 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait)
stream = &data->stream;

mutex_lock(&stream->device->lock);
if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {

switch (stream->runtime->state) {
case SNDRV_PCM_STATE_OPEN:
case SNDRV_PCM_STATE_XRUN:
retval = snd_compr_get_poll(stream) | POLLERR;
goto out;
default:
break;
}

poll_wait(f, &stream->runtime->sleep, wait);

avail = snd_compr_get_avail(stream);
Expand Down Expand Up @@ -697,6 +721,45 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
return retval;
}

static void error_delayed_work(struct work_struct *work)
{
struct snd_compr_stream *stream;

stream = container_of(work, struct snd_compr_stream, error_work.work);

mutex_lock(&stream->device->lock);

stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
wake_up(&stream->runtime->sleep);

mutex_unlock(&stream->device->lock);
}

/*
* snd_compr_stop_error: Report a fatal error on a stream
* @stream: pointer to stream
* @state: state to transition the stream to
*
* Stop the stream and set its state.
*
* Should be called with compressed device lock held.
*/
int snd_compr_stop_error(struct snd_compr_stream *stream,
snd_pcm_state_t state)
{
if (stream->runtime->state == state)
return 0;

stream->runtime->state = state;

pr_debug("Changing state to: %d\n", state);

queue_delayed_work(system_power_efficient_wq, &stream->error_work, 0);

return 0;
}
EXPORT_SYMBOL_GPL(snd_compr_stop_error);

static int snd_compress_wait_for_drain(struct snd_compr_stream *stream)
{
int ret;
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_ADAU1977_SPI if SPI_MASTER
select SND_SOC_ADAU1977_I2C if I2C
select SND_SOC_ADAU1701 if I2C
select SND_SOC_ADAU7002
select SND_SOC_ADS117X
select SND_SOC_AK4104 if SPI_MASTER
select SND_SOC_AK4535 if I2C
Expand Down Expand Up @@ -269,8 +270,12 @@ config SND_SOC_AD1980
config SND_SOC_AD73311
tristate

config SND_SOC_ADAU_UTILS
tristate

config SND_SOC_ADAU1373
tristate
select SND_SOC_ADAU_UTILS

config SND_SOC_ADAU1701
tristate "Analog Devices ADAU1701 CODEC"
Expand All @@ -280,6 +285,7 @@ config SND_SOC_ADAU1701
config SND_SOC_ADAU17X1
tristate
select SND_SOC_SIGMADSP_REGMAP
select SND_SOC_ADAU_UTILS

config SND_SOC_ADAU1761
tristate
Expand Down Expand Up @@ -322,6 +328,9 @@ config SND_SOC_ADAU1977_I2C
select SND_SOC_ADAU1977
select REGMAP_I2C

config SND_SOC_ADAU7002
tristate "Analog Devices ADAU7002 Stereo PDM-to-I2S/TDM Converter"

config SND_SOC_ADAV80X
tristate

Expand Down
4 changes: 4 additions & 0 deletions sound/soc/codecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ snd-soc-ad193x-spi-objs := ad193x-spi.o
snd-soc-ad193x-i2c-objs := ad193x-i2c.o
snd-soc-ad1980-objs := ad1980.o
snd-soc-ad73311-objs := ad73311.o
snd-soc-adau-utils-objs := adau-utils.o
snd-soc-adau1373-objs := adau1373.o
snd-soc-adau1701-objs := adau1701.o
snd-soc-adau17x1-objs := adau17x1.o
Expand All @@ -19,6 +20,7 @@ snd-soc-adau1781-spi-objs := adau1781-spi.o
snd-soc-adau1977-objs := adau1977.o
snd-soc-adau1977-spi-objs := adau1977-spi.o
snd-soc-adau1977-i2c-objs := adau1977-i2c.o
snd-soc-adau7002-objs := adau7002.o
snd-soc-adav80x-objs := adav80x.o
snd-soc-adav801-objs := adav801.o
snd-soc-adav803-objs := adav803.o
Expand Down Expand Up @@ -220,6 +222,7 @@ obj-$(CONFIG_SND_SOC_AD193X_SPI) += snd-soc-ad193x-spi.o
obj-$(CONFIG_SND_SOC_AD193X_I2C) += snd-soc-ad193x-i2c.o
obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o
obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
obj-$(CONFIG_SND_SOC_ADAU_UTILS) += snd-soc-adau-utils.o
obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o
obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o
obj-$(CONFIG_SND_SOC_ADAU17X1) += snd-soc-adau17x1.o
Expand All @@ -232,6 +235,7 @@ obj-$(CONFIG_SND_SOC_ADAU1781_SPI) += snd-soc-adau1781-spi.o
obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o
obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o
obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o
obj-$(CONFIG_SND_SOC_ADAU7002) += snd-soc-adau7002.o
obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o
obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o
obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o
Expand Down
61 changes: 61 additions & 0 deletions sound/soc/codecs/adau-utils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Shared helper functions for devices from the ADAU family
*
* Copyright 2011-2016 Analog Devices Inc.
* Author: Lars-Peter Clausen <[email protected]>
*
* Licensed under the GPL-2 or later.
*/

#include <linux/gcd.h>
#include <linux/kernel.h>
#include <linux/module.h>

#include "adau-utils.h"

int adau_calc_pll_cfg(unsigned int freq_in, unsigned int freq_out,
uint8_t regs[5])
{
unsigned int r, n, m, i, j;
unsigned int div;

if (!freq_out) {
r = 0;
n = 0;
m = 0;
div = 0;
} else {
if (freq_out % freq_in != 0) {
div = DIV_ROUND_UP(freq_in, 13500000);
freq_in /= div;
r = freq_out / freq_in;
i = freq_out % freq_in;
j = gcd(i, freq_in);
n = i / j;
m = freq_in / j;
div--;
} else {
r = freq_out / freq_in;
n = 0;
m = 0;
div = 0;
}
if (n > 0xffff || m > 0xffff || div > 3 || r > 8 || r < 2)
return -EINVAL;
}

regs[0] = m >> 8;
regs[1] = m & 0xff;
regs[2] = n >> 8;
regs[3] = n & 0xff;
regs[4] = (r << 3) | (div << 1);
if (m != 0)
regs[4] |= 1; /* Fractional mode */

return 0;
}
EXPORT_SYMBOL_GPL(adau_calc_pll_cfg);

MODULE_DESCRIPTION("ASoC ADAU audio CODECs shared helper functions");
MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");
MODULE_LICENSE("GPL v2");
7 changes: 7 additions & 0 deletions sound/soc/codecs/adau-utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef SOUND_SOC_CODECS_ADAU_PLL_H
#define SOUND_SOC_CODECS_ADAU_PLL_H

int adau_calc_pll_cfg(unsigned int freq_in, unsigned int freq_out,
uint8_t regs[5]);

#endif
Loading

0 comments on commit 72a04d6

Please sign in to comment.