Merge tag 'asoc-v5.7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
authorTakashi Iwai <tiwai@suse.de>
Mon, 30 Mar 2020 11:43:00 +0000 (13:43 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 30 Mar 2020 11:43:00 +0000 (13:43 +0200)
ASoC: Updates for v5.7

This is a very big update for the core since Morimoto-san has been
rather busy continuing his refactorings to clean up a lot of the cruft
that we have accumilated over the years.  We've also gained several new
drivers, including initial (but still not complete) parts of the Intel
SoundWire support.

 - Lots of refactorings to modernize the code from Morimoto-san.
 - Conversion of SND_SOC_ALL_CODECS to use imply from Geert Uytterhoeven.
 - Continued refactoring and fixing of the Intel support.
 - Soundwire and more advanced clocking support for Realtek RT5682.
 - Support for amlogic GX, Meson 8, Meson 8B and T9015 DAC, Broadcom
   DSL/PON, Ingenic JZ4760 and JZ4770, Realtek RL6231, and TI TAS2563 and
   TLV320ADCX140.

1  2 
include/sound/pcm.h
sound/core/pcm_dmaengine.c
sound/core/pcm_misc.c

diff --combined include/sound/pcm.h
index 31a4b300e4c9af269a6add491941b5dca6f79297,f7a95b7111007e81f2659fbf29402293bc5127fa..2ba5df2c9e235737726cc14f13d9bffa2c3e6555
@@@ -644,6 -644,11 +644,11 @@@ void snd_pcm_stream_unlock_irqrestore(s
  #define snd_pcm_group_for_each_entry(s, substream) \
        list_for_each_entry(s, &substream->group->substreams, link_list)
  
+ #define for_each_pcm_streams(stream)                  \
+       for (stream  = SNDRV_PCM_STREAM_PLAYBACK;       \
+            stream <= SNDRV_PCM_STREAM_LAST;           \
+            stream++)
  /**
   * snd_pcm_running - Check whether the substream is in a running state
   * @substream: substream to check
@@@ -1122,7 -1127,14 +1127,14 @@@ snd_pcm_kernel_readv(struct snd_pcm_sub
        return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
  }
  
- int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
+ int snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw);
+ static inline int
+ snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
+ {
+       return snd_pcm_hw_limit_rates(&runtime->hw);
+ }
  unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
  unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
  unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
@@@ -1415,15 -1427,6 +1427,15 @@@ static inline u64 pcm_format_to_bits(sn
        return 1ULL << (__force int) pcm_format;
  }
  
 +/**
 + * pcm_for_each_format - helper to iterate for each format type
 + * @f: the iterator variable in snd_pcm_format_t type
 + */
 +#define pcm_for_each_format(f)                                                \
 +      for ((f) = SNDRV_PCM_FORMAT_FIRST;                              \
 +           (__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST;    \
 +           (f) = (__force snd_pcm_format_t)((__force int)(f) + 1))
 +
  /* printk helpers */
  #define pcm_err(pcm, fmt, args...) \
        dev_err((pcm)->card->dev, fmt, ##args)
index b37c70864b5791e5109e87bd0cb566de8e0e371c,9d4f48cfe47f123aa0cb456dfda3571ed78161ac..4d059ff2b2e4facaae4d7191665bbf6e7795db8c
@@@ -240,6 -240,7 +240,7 @@@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_poi
  snd_pcm_uframes_t snd_dmaengine_pcm_pointer(struct snd_pcm_substream *substream)
  {
        struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        struct dma_tx_state state;
        enum dma_status status;
        unsigned int buf_size;
                buf_size = snd_pcm_lib_buffer_bytes(substream);
                if (state.residue > 0 && state.residue <= buf_size)
                        pos = buf_size - state.residue;
+               runtime->delay = bytes_to_frames(runtime,
+                                                state.in_flight_bytes);
        }
  
-       return bytes_to_frames(substream->runtime, pos);
+       return bytes_to_frames(runtime, pos);
  }
  EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_pointer);
  
@@@ -426,7 -430,7 +430,7 @@@ int snd_dmaengine_pcm_refine_runtime_hw
                 * default assumption is that it supports 1, 2 and 4 bytes
                 * widths.
                 */
 -              for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) {
 +              pcm_for_each_format(i) {
                        int bits = snd_pcm_format_physical_width(i);
  
                        /*
diff --combined sound/core/pcm_misc.c
index cf3e8c26e00ad4d880a4fe2f1fe85b59896b848e,5dd2e53359002788c02d5b1413f085ec39d5b4d2..257d412eac5ddb618074e662ad2b0346e19c12e1
@@@ -42,11 -42,6 +42,11 @@@ struct pcm_format_data 
  /* we do lots of calculations on snd_pcm_format_t; shut up sparse */
  #define INT   __force int
  
 +static bool valid_format(snd_pcm_format_t format)
 +{
 +      return (INT)format >= 0 && (INT)format <= (INT)SNDRV_PCM_FORMAT_LAST;
 +}
 +
  static const struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
        [SNDRV_PCM_FORMAT_S8] = {
                .width = 8, .phys = 8, .le = -1, .signd = 1,
  int snd_pcm_format_signed(snd_pcm_format_t format)
  {
        int val;
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return -EINVAL;
        if ((val = pcm_formats[(INT)format].signd) < 0)
                return -EINVAL;
@@@ -312,7 -307,7 +312,7 @@@ EXPORT_SYMBOL(snd_pcm_format_linear)
  int snd_pcm_format_little_endian(snd_pcm_format_t format)
  {
        int val;
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return -EINVAL;
        if ((val = pcm_formats[(INT)format].le) < 0)
                return -EINVAL;
@@@ -348,7 -343,7 +348,7 @@@ EXPORT_SYMBOL(snd_pcm_format_big_endian
  int snd_pcm_format_width(snd_pcm_format_t format)
  {
        int val;
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return -EINVAL;
        if ((val = pcm_formats[(INT)format].width) == 0)
                return -EINVAL;
@@@ -366,7 -361,7 +366,7 @@@ EXPORT_SYMBOL(snd_pcm_format_width)
  int snd_pcm_format_physical_width(snd_pcm_format_t format)
  {
        int val;
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return -EINVAL;
        if ((val = pcm_formats[(INT)format].phys) == 0)
                return -EINVAL;
@@@ -399,7 -394,7 +399,7 @@@ EXPORT_SYMBOL(snd_pcm_format_size)
   */
  const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format)
  {
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return NULL;
        if (! pcm_formats[(INT)format].phys)
                return NULL;
@@@ -423,7 -418,7 +423,7 @@@ int snd_pcm_format_set_silence(snd_pcm_
        unsigned char *dst;
        const unsigned char *pat;
  
 -      if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
 +      if (!valid_format(format))
                return -EINVAL;
        if (samples == 0)
                return 0;
  EXPORT_SYMBOL(snd_pcm_format_set_silence);
  
  /**
-  * snd_pcm_limit_hw_rates - determine rate_min/rate_max fields
-  * @runtime: the runtime instance
+  * snd_pcm_hw_limit_rates - determine rate_min/rate_max fields
+  * @hw: the pcm hw instance
   *
   * Determines the rate_min and rate_max fields from the rates bits of
-  * the given runtime->hw.
+  * the given hw.
   *
   * Return: Zero if successful.
   */
- int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
+ int snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw)
  {
        int i;
        for (i = 0; i < (int)snd_pcm_known_rates.count; i++) {
-               if (runtime->hw.rates & (1 << i)) {
-                       runtime->hw.rate_min = snd_pcm_known_rates.list[i];
+               if (hw->rates & (1 << i)) {
+                       hw->rate_min = snd_pcm_known_rates.list[i];
                        break;
                }
        }
        for (i = (int)snd_pcm_known_rates.count - 1; i >= 0; i--) {
-               if (runtime->hw.rates & (1 << i)) {
-                       runtime->hw.rate_max = snd_pcm_known_rates.list[i];
+               if (hw->rates & (1 << i)) {
+                       hw->rate_max = snd_pcm_known_rates.list[i];
                        break;
                }
        }
        return 0;
  }
- EXPORT_SYMBOL(snd_pcm_limit_hw_rates);
+ EXPORT_SYMBOL(snd_pcm_hw_limit_rates);
  
  /**
   * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit