Commit cf54d47c authored by Takashi Iwai's avatar Takashi Iwai

Merge branch 'fix/asoc' into for-linus

parents 88d68602 bda63586
...@@ -14,13 +14,34 @@ ...@@ -14,13 +14,34 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/sigma.h> #include <linux/sigma.h>
/* Return: 0==OK, <0==error, =1 ==no more actions */ static size_t sigma_action_size(struct sigma_action *sa)
{
size_t payload = 0;
switch (sa->instr) {
case SIGMA_ACTION_WRITEXBYTES:
case SIGMA_ACTION_WRITESINGLE:
case SIGMA_ACTION_WRITESAFELOAD:
payload = sigma_action_len(sa);
break;
default:
break;
}
payload = ALIGN(payload, 2);
return payload + sizeof(struct sigma_action);
}
/*
* Returns a negative error value in case of an error, 0 if processing of
* the firmware should be stopped after this action, 1 otherwise.
*/
static int static int
process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw) process_sigma_action(struct i2c_client *client, struct sigma_action *sa)
{ {
struct sigma_action *sa = (void *)(ssfw->fw->data + ssfw->pos);
size_t len = sigma_action_len(sa); size_t len = sigma_action_len(sa);
int ret = 0; int ret;
pr_debug("%s: instr:%i addr:%#x len:%zu\n", __func__, pr_debug("%s: instr:%i addr:%#x len:%zu\n", __func__,
sa->instr, sa->addr, len); sa->instr, sa->addr, len);
...@@ -29,44 +50,50 @@ process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw) ...@@ -29,44 +50,50 @@ process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw)
case SIGMA_ACTION_WRITEXBYTES: case SIGMA_ACTION_WRITEXBYTES:
case SIGMA_ACTION_WRITESINGLE: case SIGMA_ACTION_WRITESINGLE:
case SIGMA_ACTION_WRITESAFELOAD: case SIGMA_ACTION_WRITESAFELOAD:
if (ssfw->fw->size < ssfw->pos + len)
return -EINVAL;
ret = i2c_master_send(client, (void *)&sa->addr, len); ret = i2c_master_send(client, (void *)&sa->addr, len);
if (ret < 0) if (ret < 0)
return -EINVAL; return -EINVAL;
break; break;
case SIGMA_ACTION_DELAY: case SIGMA_ACTION_DELAY:
ret = 0;
udelay(len); udelay(len);
len = 0; len = 0;
break; break;
case SIGMA_ACTION_END: case SIGMA_ACTION_END:
return 1; return 0;
default: default:
return -EINVAL; return -EINVAL;
} }
/* when arrive here ret=0 or sent data */ return 1;
ssfw->pos += sigma_action_size(sa, len);
return ssfw->pos == ssfw->fw->size;
} }
static int static int
process_sigma_actions(struct i2c_client *client, struct sigma_firmware *ssfw) process_sigma_actions(struct i2c_client *client, struct sigma_firmware *ssfw)
{ {
pr_debug("%s: processing %p\n", __func__, ssfw); struct sigma_action *sa;
size_t size;
int ret;
while (ssfw->pos + sizeof(*sa) <= ssfw->fw->size) {
sa = (struct sigma_action *)(ssfw->fw->data + ssfw->pos);
size = sigma_action_size(sa);
ssfw->pos += size;
if (ssfw->pos > ssfw->fw->size || size == 0)
break;
ret = process_sigma_action(client, sa);
while (1) {
int ret = process_sigma_action(client, ssfw);
pr_debug("%s: action returned %i\n", __func__, ret); pr_debug("%s: action returned %i\n", __func__, ret);
if (ret == 1)
return 0; if (ret <= 0)
else if (ret)
return ret; return ret;
} }
if (ssfw->pos != ssfw->fw->size)
return -EINVAL;
return 0;
} }
int process_sigma_firmware(struct i2c_client *client, const char *name) int process_sigma_firmware(struct i2c_client *client, const char *name)
...@@ -89,16 +116,24 @@ int process_sigma_firmware(struct i2c_client *client, const char *name) ...@@ -89,16 +116,24 @@ int process_sigma_firmware(struct i2c_client *client, const char *name)
/* then verify the header */ /* then verify the header */
ret = -EINVAL; ret = -EINVAL;
if (fw->size < sizeof(*ssfw_head))
/*
* Reject too small or unreasonable large files. The upper limit has been
* chosen a bit arbitrarily, but it should be enough for all practical
* purposes and having the limit makes it easier to avoid integer
* overflows later in the loading process.
*/
if (fw->size < sizeof(*ssfw_head) || fw->size >= 0x4000000)
goto done; goto done;
ssfw_head = (void *)fw->data; ssfw_head = (void *)fw->data;
if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic))) if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic)))
goto done; goto done;
crc = crc32(0, fw->data, fw->size); crc = crc32(0, fw->data + sizeof(*ssfw_head),
fw->size - sizeof(*ssfw_head));
pr_debug("%s: crc=%x\n", __func__, crc); pr_debug("%s: crc=%x\n", __func__, crc);
if (crc != ssfw_head->crc) if (crc != le32_to_cpu(ssfw_head->crc))
goto done; goto done;
ssfw.pos = sizeof(*ssfw_head); ssfw.pos = sizeof(*ssfw_head);
......
...@@ -24,7 +24,7 @@ struct sigma_firmware { ...@@ -24,7 +24,7 @@ struct sigma_firmware {
struct sigma_firmware_header { struct sigma_firmware_header {
unsigned char magic[7]; unsigned char magic[7];
u8 version; u8 version;
u32 crc; __le32 crc;
}; };
enum { enum {
...@@ -40,19 +40,14 @@ enum { ...@@ -40,19 +40,14 @@ enum {
struct sigma_action { struct sigma_action {
u8 instr; u8 instr;
u8 len_hi; u8 len_hi;
u16 len; __le16 len;
u16 addr; __be16 addr;
unsigned char payload[]; unsigned char payload[];
}; };
static inline u32 sigma_action_len(struct sigma_action *sa) static inline u32 sigma_action_len(struct sigma_action *sa)
{ {
return (sa->len_hi << 16) | sa->len; return (sa->len_hi << 16) | le16_to_cpu(sa->len);
}
static inline size_t sigma_action_size(struct sigma_action *sa, u32 payload_len)
{
return sizeof(*sa) + payload_len + (payload_len % 2);
} }
extern int process_sigma_firmware(struct i2c_client *client, const char *name); extern int process_sigma_firmware(struct i2c_client *client, const char *name);
......
config SND_ATMEL_SOC config SND_ATMEL_SOC
tristate "SoC Audio for the Atmel System-on-Chip" tristate "SoC Audio for the Atmel System-on-Chip"
depends on ARCH_AT91 || AVR32 depends on ARCH_AT91
help help
Say Y or M if you want to add support for codecs attached to Say Y or M if you want to add support for codecs attached to
the ATMEL SSC interface. You will also need the ATMEL SSC interface. You will also need
...@@ -24,25 +24,6 @@ config SND_AT91_SOC_SAM9G20_WM8731 ...@@ -24,25 +24,6 @@ config SND_AT91_SOC_SAM9G20_WM8731
Say Y if you want to add support for SoC audio on WM8731-based Say Y if you want to add support for SoC audio on WM8731-based
AT91sam9g20 evaluation board. AT91sam9g20 evaluation board.
config SND_AT32_SOC_PLAYPAQ
tristate "SoC Audio support for PlayPaq with WM8510"
depends on SND_ATMEL_SOC && BOARD_PLAYPAQ && AT91_PROGRAMMABLE_CLOCKS
select SND_ATMEL_SOC_SSC
select SND_SOC_WM8510
help
Say Y or M here if you want to add support for SoC audio
on the LRS PlayPaq.
config SND_AT32_SOC_PLAYPAQ_SLAVE
bool "Run CODEC on PlayPaq in slave mode"
depends on SND_AT32_SOC_PLAYPAQ
default n
help
Say Y if you want to run with the AT32 SSC generating the BCLK
and FRAME signals on the PlayPaq. Unless you want to play
with the AT32 as the SSC master, you probably want to say N here,
as this will give you better sound quality.
config SND_AT91_SOC_AFEB9260 config SND_AT91_SOC_AFEB9260
tristate "SoC Audio support for AFEB9260 board" tristate "SoC Audio support for AFEB9260 board"
depends on ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC depends on ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC
......
...@@ -8,9 +8,5 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o ...@@ -8,9 +8,5 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
# AT91 Machine Support # AT91 Machine Support
snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
# AT32 Machine Support
snd-soc-playpaq-objs := playpaq_wm8510.o
obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
This diff is collapsed.
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#define AD1836_ADC_CTRL2 13 #define AD1836_ADC_CTRL2 13
#define AD1836_ADC_WORD_LEN_MASK 0x30 #define AD1836_ADC_WORD_LEN_MASK 0x30
#define AD1836_ADC_WORD_OFFSET 5 #define AD1836_ADC_WORD_OFFSET 4
#define AD1836_ADC_SERFMT_MASK (7 << 6) #define AD1836_ADC_SERFMT_MASK (7 << 6)
#define AD1836_ADC_SERFMT_PCK256 (0x4 << 6) #define AD1836_ADC_SERFMT_PCK256 (0x4 << 6)
#define AD1836_ADC_SERFMT_PCK128 (0x5 << 6) #define AD1836_ADC_SERFMT_PCK128 (0x5 << 6)
......
...@@ -601,7 +601,6 @@ static int cs4270_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg) ...@@ -601,7 +601,6 @@ static int cs4270_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg)
static int cs4270_soc_resume(struct snd_soc_codec *codec) static int cs4270_soc_resume(struct snd_soc_codec *codec)
{ {
struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
struct i2c_client *i2c_client = to_i2c_client(codec->dev);
int reg; int reg;
regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
...@@ -612,14 +611,7 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec) ...@@ -612,14 +611,7 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec)
ndelay(500); ndelay(500);
/* first restore the entire register cache ... */ /* first restore the entire register cache ... */
for (reg = CS4270_FIRSTREG; reg <= CS4270_LASTREG; reg++) { snd_soc_cache_sync(codec);
u8 val = snd_soc_read(codec, reg);
if (i2c_smbus_write_byte_data(i2c_client, reg, val)) {
dev_err(codec->dev, "i2c write failed\n");
return -EIO;
}
}
/* ... then disable the power-down bits */ /* ... then disable the power-down bits */
reg = snd_soc_read(codec, CS4270_PWRCTL); reg = snd_soc_read(codec, CS4270_PWRCTL);
......
...@@ -555,7 +555,7 @@ static int cs42l51_probe(struct snd_soc_codec *codec) ...@@ -555,7 +555,7 @@ static int cs42l51_probe(struct snd_soc_codec *codec)
static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { static struct snd_soc_codec_driver soc_codec_device_cs42l51 = {
.probe = cs42l51_probe, .probe = cs42l51_probe,
.reg_cache_size = CS42L51_NUMREGS, .reg_cache_size = CS42L51_NUMREGS + 1,
.reg_word_size = sizeof(u8), .reg_word_size = sizeof(u8),
}; };
......
...@@ -106,13 +106,13 @@ static int max9877_set_2reg(struct snd_kcontrol *kcontrol, ...@@ -106,13 +106,13 @@ static int max9877_set_2reg(struct snd_kcontrol *kcontrol,
unsigned int mask = mc->max; unsigned int mask = mc->max;
unsigned int val = (ucontrol->value.integer.value[0] & mask); unsigned int val = (ucontrol->value.integer.value[0] & mask);
unsigned int val2 = (ucontrol->value.integer.value[1] & mask); unsigned int val2 = (ucontrol->value.integer.value[1] & mask);
unsigned int change = 1; unsigned int change = 0;
if (((max9877_regs[reg] >> shift) & mask) == val) if (((max9877_regs[reg] >> shift) & mask) != val)
change = 0; change = 1;
if (((max9877_regs[reg2] >> shift) & mask) == val2) if (((max9877_regs[reg2] >> shift) & mask) != val2)
change = 0; change = 1;
if (change) { if (change) {
max9877_regs[reg] &= ~(mask << shift); max9877_regs[reg] &= ~(mask << shift);
......
...@@ -2357,6 +2357,11 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2357,6 +2357,11 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT; bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT;
lrclk = bclk_rate / params_rate(params); lrclk = bclk_rate / params_rate(params);
if (!lrclk) {
dev_err(dai->dev, "Unable to generate LRCLK from %dHz BCLK\n",
bclk_rate);
return -EINVAL;
}
dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
lrclk, bclk_rate / lrclk); lrclk, bclk_rate / lrclk);
...@@ -3178,6 +3183,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -3178,6 +3183,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
switch (wm8994->revision) { switch (wm8994->revision) {
case 0: case 0:
case 1: case 1:
case 2:
case 3:
wm8994->hubs.dcs_codes_l = -9; wm8994->hubs.dcs_codes_l = -9;
wm8994->hubs.dcs_codes_r = -5; wm8994->hubs.dcs_codes_r = -5;
break; break;
......
...@@ -392,7 +392,8 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ...@@ -392,7 +392,8 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
} }
if (strcasecmp(sprop, "i2s-slave") == 0) { if (strcasecmp(sprop, "i2s-slave") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_I2S; machine_data->dai_format =
SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
...@@ -409,31 +410,38 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ...@@ -409,31 +410,38 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
} }
machine_data->clk_frequency = be32_to_cpup(iprop); machine_data->clk_frequency = be32_to_cpup(iprop);
} else if (strcasecmp(sprop, "i2s-master") == 0) { } else if (strcasecmp(sprop, "i2s-master") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_I2S; machine_data->dai_format =
SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
} else if (strcasecmp(sprop, "lj-slave") == 0) { } else if (strcasecmp(sprop, "lj-slave") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; machine_data->dai_format =
SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM;
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
} else if (strcasecmp(sprop, "lj-master") == 0) { } else if (strcasecmp(sprop, "lj-master") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; machine_data->dai_format =
SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBS_CFS;
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
} else if (strcasecmp(sprop, "rj-slave") == 0) { } else if (strcasecmp(sprop, "rj-slave") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; machine_data->dai_format =
SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBM_CFM;
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
} else if (strcasecmp(sprop, "rj-master") == 0) { } else if (strcasecmp(sprop, "rj-master") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; machine_data->dai_format =
SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBS_CFS;
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
} else if (strcasecmp(sprop, "ac97-slave") == 0) { } else if (strcasecmp(sprop, "ac97-slave") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_AC97; machine_data->dai_format =
SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBM_CFM;
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
} else if (strcasecmp(sprop, "ac97-master") == 0) { } else if (strcasecmp(sprop, "ac97-master") == 0) {
machine_data->dai_format = SND_SOC_DAIFMT_AC97; machine_data->dai_format =
SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBS_CFS;
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
} else { } else {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "../codecs/wm8994.h" #include "../codecs/wm8994.h"
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <linux/module.h>
/* /*
* Default CFG switch settings to use this driver: * Default CFG switch settings to use this driver:
......
...@@ -191,7 +191,7 @@ static int speyside_late_probe(struct snd_soc_card *card) ...@@ -191,7 +191,7 @@ static int speyside_late_probe(struct snd_soc_card *card)
snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic"); snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic");
snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC"); snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC");
snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC"); snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC");
snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); snd_soc_dapm_ignore_suspend(&card->dapm, "Main Speaker");
snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output"); snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output");
snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input"); snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input");
......
...@@ -709,6 +709,12 @@ int snd_soc_resume(struct device *dev) ...@@ -709,6 +709,12 @@ int snd_soc_resume(struct device *dev)
struct snd_soc_card *card = dev_get_drvdata(dev); struct snd_soc_card *card = dev_get_drvdata(dev);
int i, ac97_control = 0; int i, ac97_control = 0;
/* If the initialization of this soc device failed, there is no codec
* associated with it. Just bail out in this case.
*/
if (list_empty(&card->codec_dev_list))
return 0;
/* AC97 devices might have other drivers hanging off them so /* AC97 devices might have other drivers hanging off them so
* need to resume immediately. Other drivers don't have that * need to resume immediately. Other drivers don't have that
* problem and may take a substantial amount of time to resume * problem and may take a substantial amount of time to resume
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment