19 May, 2015

1 commit

  • Currently in snd_pcm_update_hw_ptr0 during interrupt,
    we consider there were double acknowledged interrupts when:
    1. HW reported pointer is smaller than expected, and
    2. Time from last update time (hdelta) is over half a buffer time.

    However, when HW reported pointer is only a few bytes smaller than
    expected, and when hdelta is just a little larger than half a buffer time
    (e.g. ping-pong buffer), it wrongly treats this IRQ as double acknowledged.

    The condition #2 uses jiffies, but jiffies is not high resolution
    since it is integer. We should consider jiffies inaccuracy.

    Signed-off-by: Koro Chen
    Signed-off-by: Takashi Iwai

    Koro Chen
     

21 Feb, 2015

1 commit

  • Introduce more generic .get_time_info to retrieve
    system timestamp and audio timestamp in single routine.
    Backwards compatibility is preserved with same functionality
    as with .wall_clock method (to be removed in following commits
    to avoid breaking git bisect)

    Signed-off-by: Pierre-Louis Bossart
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     

05 Feb, 2015

1 commit

  • …e/sound into for-next

    ASoC: Updates for v3.20

    More updates for v3.20:

    - Lots of refactoring from Lars-Peter Clausen, moving drivers to more
    data driven initialization and rationalizing a lot of DAPM usage.
    - Much improved handling of CDCLK clocks on Samsung I2S controllers.
    - Lots of driver specific cleanups and feature improvements.
    - CODEC support for TI PCM514x and TLV320AIC3104 devices.
    - Board support for Tegra systems with Realtek RT5677.

    Conflicts:
    sound/soc/intel/sst-mfld-platform-pcm.c

    Takashi Iwai
     

29 Jan, 2015

1 commit

  • Add helper functions to allow drivers to specify several disjoint
    ranges for a variable. In particular, there is a codec (PCM512x) that
    has a hole in its supported range of rates, due to PLL and divider
    restrictions.

    This is like snd_pcm_hw_constraint_list(), but for ranges instead of
    points.

    Signed-off-by: Peter Rosin
    Reviewed-by: Lars-Peter Clausen
    Reviewed-by: Takashi Iwai
    Signed-off-by: Mark Brown

    Peter Rosin
     

30 Dec, 2014

2 commits

  • Currently the msbits constraints requires to specify a specific sample
    format width for which the constraint should be applied. But often the
    number of most significant bits is not sample format specific, but rather a
    absolute limit. E.g. the PCM interface might accept 32-bit and 24-bit
    samples, but the DAC has a 16-bit resolution and throws away the LSBs. In
    this case for both 32-bit and 24-bit format msbits should be set to 16. This
    patch extends snd_pcm_hw_constraint_msbits() so that a wildcard constraint
    can be setup that is applied for all formats with a sample width larger than
    the specified msbits. Choosing the wildcard constraint is done by setting
    the sample width parameter of the function to 0.

    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Takashi Iwai

    Lars-Peter Clausen
     
  • If the sound card is made up of discrete components, each with their own
    driver (e.g. like in the ASoC case), we might end up with multiple msbits
    constraint rules installed. Currently this will result in msbits being set
    to whatever the last rule set it to.

    This patch updates the behavior of the rule to choose the minimum (other
    than zero) of all the installed rules.

    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Takashi Iwai

    Lars-Peter Clausen
     

04 Nov, 2014

2 commits

  • ALSA PCM core has a mechanism tracking the PCM hwptr updates for
    analyzing XRUNs. But its log is limited (up to 10) and its log output
    is a kernel message, which is hard to handle.

    In this patch, the hwptr logging is moved to the tracing
    infrastructure instead of its own. Not only the hwptr updates but
    also XRUN and hwptr errors are recorded on the trace log, so that user
    can see such events at the exact timing.

    The new "snd_pcm" entry will appear in the tracing events:
    # ls -F /sys/kernel/debug/tracing/events/snd_pcm
    enable filter hw_ptr_error/ hwptr/ xrun/

    The hwptr is for the regular hwptr update events. An event trace
    looks like:

    aplay-26187 [004] d..3 4012.834761: hwptr: pcmC0D0p/sub0: POS: pos=488, old=0, base=0, period=1024, buf=16384

    "POS" shows the hwptr update by the explicit position update call and
    "IRQ" means the hwptr update by the interrupt,
    i.e. snd_pcm_period_elapsed() call. The "pos" is the passed
    ring-buffer offset by the caller, "old" is the previous hwptr, "base"
    is the hwptr base position, "period" and "buf" are period- and
    buffer-size of the target PCM substream.
    (Note that the hwptr position displayed here isn't the ring-buffer
    offset. It increments up to the PCM position boundary.)

    The XRUN event appears similarly, but without "pos" field.
    The hwptr error events appear with the PCM identifier and its reason
    string, such as "Lost interrupt?".

    The XRUN and hwptr error reports on kernel message are still left, can
    be turned on/off via xrun_debug proc like before. But the bit 3, 4, 5
    and 6 bits of xrun_debug proc are dropped by this patch. Also, along
    with the change, the message strings have been reformatted to be a bit
    more consistent.

    Last but not least, the hwptr reporting is enabled only when
    CONFIG_SND_PCM_XRUN_DEBUG is set.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • While converting to dev_*(), the message showing the invalid PCM
    position was wrongly tagged as if an XRUN although it's actually a
    BUG. This patch corrects the message again.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

06 Oct, 2014

1 commit

  • ASoC: Updates for v3.18

    - More componentisation work from Lars-Peter, this time mainly
    cleaning up the suspend and bias level transition callbacks.
    - Real system support for the Intel drivers and a bunch of fixes and
    enhancements for the associated CODEC drivers, this is going to need
    a lot quirks over time due to the lack of any firmware description of
    the boards.
    - Jack detect support for simple card from Dylan Reid.
    - A bunch of small fixes and enhancements for the Freescale drivers.
    - New drivers for Analog Devices SSM4567, Cirrus Logic CS35L32, Everest
    Semiconductor ES8328 and Freescale cards using the ASRC in newer i.MX
    processors.

    Takashi Iwai
     

22 Sep, 2014

1 commit

  • The calculated frame size was wrong because snd_pcm_format_physical_width()
    actually returns the number of bits, not bytes.

    Use snd_pcm_format_size() instead, which not only returns bytes, but also
    simplifies the calculation.

    Fixes: 8bea869c5e56 ("ALSA: PCM midlevel: improve fifo_size handling")
    Signed-off-by: Clemens Ladisch
    Cc:
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     

08 Sep, 2014

2 commits


16 Apr, 2014

1 commit

  • BugLink: http://bugs.launchpad.net/bugs/1305480

    The kerneloops-daemon scans dmesg for common crash signatures, among
    which is 'BUG:'. The message emitted by the PCM library is really a
    warning, so the most expedient thing to do seems to be to change the
    string.

    Signed-off-by: Tim Gardner
    Signed-off-by: Takashi Iwai

    Tim Gardner
     

13 Mar, 2014

1 commit

  • ASoC: Updates for v3.15

    Quite a busy release for ASoC this time, more on janitorial work than
    exciting new features but welcome nontheless:

    - Lots of cleanups from Takashi for enumerations; the original API for
    these was error prone so he's refactored lots of code to use more
    modern APIs which avoid issues.
    - Elimination of the ASoC level wrappers for I2C and SPI moving us
    closer to converting to regmap completely and avoiding some
    randconfig hassle.
    - Provide both manually and transparently locked DAPM APIs rather than
    a mix of the two fixing some concurrency issues.
    - Start converting CODEC drivers to use separate bus interface drivers
    rather than having them all in one file helping avoid dependency
    issues.
    - DPCM support for Intel Haswell and Bay Trail platforms.
    - Lots of work on improvements for simple-card, DaVinci and the Renesas
    rcar drivers.
    - New drivers for Analog Devices ADAU1977, TI PCM512x and parts of the
    CSR SiRF SoC.

    Takashi Iwai
     

20 Feb, 2014

1 commit


14 Feb, 2014

1 commit


17 Dec, 2013

1 commit

  • When the process is sleeping at the SNDRV_PCM_STATE_PAUSED
    state from the wait_for_avail function, the sleep process will be woken by
    timeout(10 seconds). Even if the sleep process wake up by timeout, by this
    patch, the process will continue with sleep and wait for the other state.

    Signed-off-by: JongHo Kim
    Cc:
    Signed-off-by: Takashi Iwai

    JongHo Kim
     

19 Aug, 2013

1 commit

  • The use of snd_printd_ratelimit() supresses superfluous output from
    printk_ratelimit() when CONFIG_SND_DEBUG is not defined. For example,

    [ 43.753692] snd_pcm_update_hw_ptr0: 26 callbacks suppressed
    [ 48.822131] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
    [ 53.894953] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
    [ 58.997761] snd_pcm_update_hw_ptr0: 25 callbacks suppressed
    [ 64.100952] snd_pcm_update_hw_ptr0: 25 callbacks suppressed

    fills the log even when no debug output is actually produced.

    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Cc: Pierre-Louis Bossart
    Cc: Lars-Peter Clausen
    Cc: Yacine Belkadi
    Signed-off-by: Tim Gardner
    Signed-off-by: Takashi Iwai

    Tim Gardner
     

24 May, 2013

1 commit


12 Mar, 2013

1 commit

  • script/kernel-doc reports the following type of warnings (when run in verbose
    mode):

    Warning(sound/core/init.c:152): No description found for return value of
    'snd_card_create'

    To fix that:
    - add missing descriptions of function return values
    - use "Return:" sections to describe those return values

    Along the way:
    - complete some descriptions
    - fix some typos

    Signed-off-by: Yacine Belkadi
    Signed-off-by: Takashi Iwai

    Yacine Belkadi
     

23 Oct, 2012

2 commits

  • ALSA did not provide any direct means to infer the audio time for A/V
    sync and system/audio time correlations (eg. PulseAudio).
    Applications had to track the number of samples read/written and
    add/subtract the number of samples queued in the ring buffer. This
    accounting led to small errors, typically several samples, due to the
    two-step process. Computing the audio time in the kernel is more
    direct, as all the information is available in the same routines.

    Also add new .audio_wallclock routine to enable fine-grain synchronization
    between monotonic system time and audio hardware time.
    Using the wallclock, if supported in hardware, allows for a
    much better sub-microsecond precision and a common drift tracking for
    all devices sharing the same wall clock (master clock).

    Signed-off-by: Pierre-Louis Bossart
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     
  • Keep track of boundary crossing when hw_ptr
    exceeds boundary limit and wraps-around. This
    will help keep track of total number
    of frames played/received at the kernel level

    Signed-off-by: Pierre-Louis Bossart
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     

13 Sep, 2012

1 commit


11 Sep, 2012

1 commit


07 Sep, 2012

2 commits

  • The VOLATILE flag was added to control elements by
    snd_pcm_add_chmap_ctls() just because I didn't want to have a
    side-effect of "alsactl restore". But now the set operation doesn't
    allow to change the value unless the PCM stream is in PREAPRED state,
    there is no reason to keep this flag. Let's rip it off.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • This patch implements the basic data types for the standard channel
    mapping API handling.

    - The definitions of the channel positions and the new TLV types are
    added in sound/asound.h and sound/tlv.h, so that they can be
    referred from user-space.

    - Introduced a new helper function snd_pcm_add_chmap_ctls() to create
    control elements representing the channel maps for each PCM
    (sub)stream.

    - Some standard pre-defined channel maps are provided for
    convenience.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

05 Jul, 2012

1 commit


23 May, 2012

1 commit


12 May, 2012

1 commit

  • In the PCM read/write loop, the driver calls snd_pcm_update_hw_ptr()
    at each time at the beginning of the loop. Russell King reported that
    this hogs CPU significantly.

    The current code assumes that the pointer callback is very fast and
    cheap, also not too much fine grained. It's not true in all cases.
    When the pointer advances short samples while the read/write copy has
    been performed, the driver updates the hw_ptr and gets avail > 0
    again. Then it tries to read/write these small chunks. This repeats
    until the avail really gets to zero.

    For avoiding this situation, a simple workaround is to call
    snd_pcm_update_hw_ptr() only once at starting the loop, assuming that
    the read/write copy is performed fast enough. If the available count
    becomes short, it goes to snd_pcm_wait_avail() anyway, and this
    processes right.

    Tested-by: Russell King
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

15 Mar, 2012

1 commit


01 Nov, 2011

1 commit


20 Sep, 2011

1 commit


15 Sep, 2011

1 commit

  • wait_for_avail() in pcm_lib.c has a race in it (observed in practice by an
    Intel validation group).

    The function is supposed to return once space in the buffer has become
    available, or if some timeout happens. The entity that creates space (irq
    handler of sound driver and some such) will do a wake up on a waitqueue
    that this function registers for.

    However there are two races in the existing code

    1) If space became available between the caller noticing there was no
    space and this function actually sleeping, the wakeup is missed and the
    timeout condition will happen instead

    2) If a wakeup happened but not sufficient space became available, the
    code will loop again and wait for more space. However, if the second
    wake comes in prior to hitting the schedule_timeout_interruptible(), it
    will be missed, and potentially you'll wait out until the timeout
    happens.

    The fix consists of using more careful setting of the current state (so
    that if a wakeup happens in the main loop window, the schedule_timeout()
    falls through) and by checking for available space prior to going into the
    schedule_timeout() loop, but after being on the waitqueue and having the
    state set to interruptible.

    [tiwai: the following changes have been added to Arjan's original patch:
    - merged akpm's fix for waitqueue adding order into a single patch
    - reduction of duplicated code of avail check
    ]

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Cc:
    Signed-off-by: Takashi Iwai

    Arjan van de Ven
     

24 Jul, 2011

1 commit


26 May, 2011

1 commit

  • When the PCM period size is set larger than 10 seconds, currently the
    PCM core may abort the operation with DMA-error due to the fixed timeout
    for 10 seconds. A similar problem is seen in the drain operation that
    has a fixed timeout of 10 seconds, too.

    This patch fixes the timeout length depending on the period size and
    rate, also including the consideration of no_period_wakeup flag.

    Reported-by: Raymond Yau
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

19 May, 2011

1 commit

  • The xrun_log function was augmented with the in_interrupt parameter whereas the
    empty macro definition used when xrun logging is disabled was not.

    Add a third parameter to the empty macro definition so as to not cause compiler
    errors when xrun logging (CONFIG_SND_PCM_XRUN_DEBUG) is disabled.

    Signed-off-by: Ben Gardiner
    Signed-off-by: Takashi Iwai

    Ben Gardiner
     

18 May, 2011

1 commit

  • When debugging pcm drivers I found the "period" or "hw" prefix printed
    by either XRUN_DEBUG_PERIODUPDATE or XRUN_DEBUG_PERIODUPDATE events,
    respectively to be very useful is observing the interplay between
    interrupt-context updates and syscall-context updates.

    Similarly, when debugging overruns with XRUN_DEBUG_LOG it is useful to
    see the context of the last 10 positions.

    Add an in_interrupt member to hwptr_log_entry which stores the value of
    the in_interrupt parameter of snd_pcm_update_hw_ptr0 when the log entry
    is created. Print a "[Q]" prefix when dumping the log entries if
    in_interrupt was true.

    Signed-off-by: Ben Gardiner
    Signed-off-by: Takashi Iwai

    Ben Gardiner
     

02 Apr, 2011

1 commit

  • When period interrupts are disabled, snd_pcm_update_hw_ptr0() compares
    the current time against the time estimated for the current hardware
    pointer to detect xruns. The somewhat fuzzy threshold in the while loop
    makes it possible that hdelta becomes negative; the comparison being
    done with unsigned types then makes the loop go through the entire 263
    negative range, and, depending on the value, never reach an unsigned
    value that is small enough to stop the loop. Doing this with interrupts
    disabled results in the machine locking up.

    To prevent this, ensure that the loop condition uses signed types for
    both operands so that the comparison is correctly done.

    Many thanks to Kelly Anderson for debugging this.

    Reported-by: Nix
    Reported-by: "Christopher K."
    Reported-and-tested-by: Kelly Anderson
    Signed-off-by: Kelly Anderson
    [cl: remove unneeded casts; use a temp variable]
    Signed-off-by: Clemens Ladisch
    Cc: 2.6.38

    Signed-off-by: Takashi Iwai

    Kelly Anderson
     

13 Jan, 2011

1 commit


21 Dec, 2010

1 commit