]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - sound/soc/soc-core.c
Merge remote-tracking branch 'asoc/topic/core' into asoc-next
[karo-tx-linux.git] / sound / soc / soc-core.c
index 91d592ff67b7914cdbeec98c24eb3b4c1cb6a364..7365afbc5e18a04bec17d11ec85391aae01eafd4 100644 (file)
@@ -1107,6 +1107,10 @@ static int soc_probe_codec(struct snd_soc_card *card,
                                "ASoC: failed to probe CODEC %d\n", ret);
                        goto err_probe;
                }
+               WARN(codec->dapm.idle_bias_off &&
+                       codec->dapm.bias_level != SND_SOC_BIAS_OFF,
+                       "codec %s can not start from non-off bias"
+                       " with idle_bias_off==1\n", codec->name);
        }
 
        /* If the driver didn't set I/O up try regmap */
@@ -1255,6 +1259,8 @@ static int soc_post_component_init(struct snd_soc_card *card,
        INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
        ret = device_add(rtd->dev);
        if (ret < 0) {
+               /* calling put_device() here to free the rtd->dev */
+               put_device(rtd->dev);
                dev_err(card->dev,
                        "ASoC: failed to register runtime device: %d\n", ret);
                return ret;
@@ -1554,7 +1560,7 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
        /* unregister the rtd device */
        if (rtd->dev_registered) {
                device_remove_file(rtd->dev, &dev_attr_codec_reg);
-               device_del(rtd->dev);
+               device_unregister(rtd->dev);
                rtd->dev_registered = 0;
        }
 
@@ -2917,7 +2923,7 @@ int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
        platform_max = mc->platform_max;
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       uinfo->count = 1;
+       uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
        uinfo->value.integer.min = 0;
        uinfo->value.integer.max = platform_max - min;
 
@@ -2941,12 +2947,14 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
                (struct soc_mixer_control *)kcontrol->private_value;
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
+       unsigned int rreg = mc->rreg;
        unsigned int shift = mc->shift;
        int min = mc->min;
        int max = mc->max;
        unsigned int mask = (1 << fls(max)) - 1;
        unsigned int invert = mc->invert;
        unsigned int val, val_mask;
+       int ret;
 
        val = ((ucontrol->value.integer.value[0] + min) & mask);
        if (invert)
@@ -2954,7 +2962,21 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
        val_mask = mask << shift;
        val = val << shift;
 
-       return snd_soc_update_bits_locked(codec, reg, val_mask, val);
+       ret = snd_soc_update_bits_locked(codec, reg, val_mask, val);
+       if (ret != 0)
+               return ret;
+
+       if (snd_soc_volsw_is_stereo(mc)) {
+               val = ((ucontrol->value.integer.value[1] + min) & mask);
+               if (invert)
+                       val = max - val;
+               val_mask = mask << shift;
+               val = val << shift;
+
+               ret = snd_soc_update_bits_locked(codec, rreg, val_mask, val);
+       }
+
+       return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range);
 
@@ -2974,6 +2996,7 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
                (struct soc_mixer_control *)kcontrol->private_value;
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
+       unsigned int rreg = mc->rreg;
        unsigned int shift = mc->shift;
        int min = mc->min;
        int max = mc->max;
@@ -2988,6 +3011,16 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
        ucontrol->value.integer.value[0] =
                ucontrol->value.integer.value[0] - min;
 
+       if (snd_soc_volsw_is_stereo(mc)) {
+               ucontrol->value.integer.value[1] =
+                       (snd_soc_read(codec, rreg) >> shift) & mask;
+               if (invert)
+                       ucontrol->value.integer.value[1] =
+                               max - ucontrol->value.integer.value[1];
+               ucontrol->value.integer.value[1] =
+                       ucontrol->value.integer.value[1] - min;
+       }
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range);
@@ -3093,9 +3126,12 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
        if (!codec->using_regmap)
                return -EINVAL;
 
-       data = ucontrol->value.bytes.data;
        len = params->num_regs * codec->val_bytes;
 
+       data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA);
+       if (!data)
+               return -ENOMEM;
+
        /*
         * If we've got a mask then we need to preserve the register
         * bits.  We shouldn't modify the incoming data so take a
@@ -3108,10 +3144,6 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
 
                val &= params->mask;
 
-               data = kmemdup(data, len, GFP_KERNEL);
-               if (!data)
-                       return -ENOMEM;
-
                switch (codec->val_bytes) {
                case 1:
                        ((u8 *)data)[0] &= ~params->mask;
@@ -3133,8 +3165,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
        ret = regmap_raw_write(codec->control_data, params->base,
                               data, len);
 
-       if (params->mask)
-               kfree(data);
+       kfree(data);
 
        return ret;
 }
@@ -3511,12 +3542,20 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
  * snd_soc_dai_digital_mute - configure DAI system or master clock.
  * @dai: DAI
  * @mute: mute enable
+ * @direction: stream to mute
  *
  * Mutes the DAI DAC.
  */
-int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute)
+int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
+                            int direction)
 {
-       if (dai->driver && dai->driver->ops->digital_mute)
+       if (!dai->driver)
+               return -ENOTSUPP;
+
+       if (dai->driver->ops->mute_stream)
+               return dai->driver->ops->mute_stream(dai, mute, direction);
+       else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
+                dai->driver->ops->digital_mute)
                return dai->driver->ops->digital_mute(dai, mute);
        else
                return -ENOTSUPP;