Merge remote-tracking branch 'asoc/topic/core' into for-tiwai
authorMark Brown <broonie@linaro.org>
Thu, 16 Jan 2014 12:42:53 +0000 (12:42 +0000)
committerMark Brown <broonie@linaro.org>
Thu, 16 Jan 2014 12:42:53 +0000 (12:42 +0000)
1  2 
sound/soc/soc-core.c
sound/soc/soc-pcm.c

diff --combined sound/soc/soc-core.c
@@@ -3212,11 -3212,11 +3212,11 @@@ int snd_soc_bytes_get(struct snd_kcontr
                        break;
                case 2:
                        ((u16 *)(&ucontrol->value.bytes.data))[0]
 -                              &= ~params->mask;
 +                              &= cpu_to_be16(~params->mask);
                        break;
                case 4:
                        ((u32 *)(&ucontrol->value.bytes.data))[0]
 -                              &= ~params->mask;
 +                              &= cpu_to_be32(~params->mask);
                        break;
                default:
                        return -EINVAL;
@@@ -3484,7 -3484,7 +3484,7 @@@ int snd_soc_dai_set_sysclk(struct snd_s
                return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0,
                                                      freq, dir);
        else
-               return -EINVAL;
+               return -ENOTSUPP;
  }
  EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
  
@@@ -3505,7 -3505,7 +3505,7 @@@ int snd_soc_codec_set_sysclk(struct snd
                return codec->driver->set_sysclk(codec, clk_id, source,
                                                 freq, dir);
        else
-               return -EINVAL;
+               return -ENOTSUPP;
  }
  EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk);
  
diff --combined sound/soc/soc-pcm.c
@@@ -230,12 -230,12 +230,12 @@@ static void soc_pcm_apply_msb(struct sn
        }
  }
  
 -static void soc_pcm_init_runtime_hw(struct snd_pcm_hardware *hw,
 +static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
        struct snd_soc_pcm_stream *codec_stream,
        struct snd_soc_pcm_stream *cpu_stream)
  {
 -      hw->rate_min = max(codec_stream->rate_min, cpu_stream->rate_min);
 -      hw->rate_max = max(codec_stream->rate_max, cpu_stream->rate_max);
 +      struct snd_pcm_hardware *hw = &runtime->hw;
 +
        hw->channels_min = max(codec_stream->channels_min,
                cpu_stream->channels_min);
        hw->channels_max = min(codec_stream->channels_max,
        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);
  }
  
  /*
@@@ -324,10 -317,10 +324,10 @@@ static int soc_pcm_open(struct snd_pcm_
  
        /* Check that the codec and cpu DAIs are compatible */
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 -              soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->playback,
 +              soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->playback,
                        &cpu_dai_drv->playback);
        } else {
 -              soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->capture,
 +              soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->capture,
                        &cpu_dai_drv->capture);
        }
  
                runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
  
        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);
@@@ -691,7 -685,7 +691,7 @@@ static int soc_pcm_hw_free(struct snd_p
        struct snd_soc_platform *platform = rtd->platform;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
 -      struct snd_soc_codec *codec = rtd->codec;
 +      bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
  
        mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
  
        }
  
        /* apply codec digital mute */
 -      if (!codec->active)
 +      if ((playback && codec_dai->playback_active == 1) ||
 +          (!playback && codec_dai->capture_active == 1))
                snd_soc_dai_digital_mute(codec_dai, 1, substream->stream);
  
        /* free any machine hw params */
@@@ -776,7 -769,7 +776,7 @@@ static int soc_pcm_bespoke_trigger(stru
                        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;
@@@ -1235,6 -1228,20 +1235,20 @@@ unwind
        return err;
  }
  
+ static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
+       struct snd_soc_pcm_stream *stream)
+ {
+       runtime->hw.rate_min = stream->rate_min;
+       runtime->hw.rate_max = stream->rate_max;
+       runtime->hw.channels_min = stream->channels_min;
+       runtime->hw.channels_max = stream->channels_max;
+       if (runtime->hw.formats)
+               runtime->hw.formats &= stream->formats;
+       else
+               runtime->hw.formats = stream->formats;
+       runtime->hw.rates = stream->rates;
+ }
  static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
  {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver;
  
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               runtime->hw.rate_min = cpu_dai_drv->playback.rate_min;
-               runtime->hw.rate_max = cpu_dai_drv->playback.rate_max;
-               runtime->hw.channels_min = cpu_dai_drv->playback.channels_min;
-               runtime->hw.channels_max = cpu_dai_drv->playback.channels_max;
-               runtime->hw.formats &= cpu_dai_drv->playback.formats;
-               runtime->hw.rates = cpu_dai_drv->playback.rates;
-       } else {
-               runtime->hw.rate_min = cpu_dai_drv->capture.rate_min;
-               runtime->hw.rate_max = cpu_dai_drv->capture.rate_max;
-               runtime->hw.channels_min = cpu_dai_drv->capture.channels_min;
-               runtime->hw.channels_max = cpu_dai_drv->capture.channels_max;
-               runtime->hw.formats &= cpu_dai_drv->capture.formats;
-               runtime->hw.rates = cpu_dai_drv->capture.rates;
-       }
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback);
+       else
+               dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture);
  }
  
  static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)