28 Aug, 2019

1 commit

  • Most of the modern codecs supports 352.8KHz and 384KHz sample rates.
    Currenlty HW params fails to set 352.8Kz and 384KHz sample rate
    as these are not in known rates list.
    Add these new rates to known list to allow them.

    This patch also adds defines in pcm.h so that drivers can use it.

    Signed-off-by: Vidyakumar Athota
    Signed-off-by: Banajit Goswami
    Signed-off-by: Srinivas Kandagatla
    Link: https://lore.kernel.org/r/20190822095653.7200-2-srinivas.kandagatla@linaro.org
    Signed-off-by: Mark Brown

    Vidyakumar Athota
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

14 Mar, 2019

1 commit


08 Feb, 2019

1 commit


24 Jan, 2019

3 commits


23 Jan, 2019

1 commit

  • We have currently two global locks, a rwlock and a rwsem, that are
    used for managing linking the PCM streams. Due to these global locks,
    once when a linked stream is used, the lock granularity suffers a
    lot.

    This patch attempts to eliminate the former global lock for atomic
    ops. The latter rwsem needs remaining because of the loosy way of the
    loop calls in snd_pcm_action_nonatomic(), as well as for avoiding the
    deadlock at linking. However, these are used far rarely, actually
    only by two actions (prepare and reset), where both are no timing
    critical ones. So this can be still seen as a good improvement.

    The basic strategy to eliminate the rwlock is to assure group->lock at
    adding or removing a stream to / from the group. Since we already
    takes the group lock whenever taking the all substream locks under the
    group, this shouldn't be a big problem. The reference to group
    pointer in snd_pcm_substream object is protected by the stream lock
    itself.

    However, there are still pitfalls: a race window at re-locking and the
    lifecycle of group object. The former is a small race window for
    dereferencing the substream group object opened while snd_pcm_action()
    performs re-locking to avoid ABBA deadlocks. This includes the unlink
    of group during that window, too. And the latter is the kfree
    performed after all streams are removed from the group while it's
    still dereferenced.

    For addressing these corner cases, two new tricks are introduced:
    - After re-locking, the group assigned to the stream is checked again;
    if the group is changed, we retry the whole procedure.
    - Introduce a refcount to snd_pcm_group object, so that it's freed
    only when it's empty and really no one refers to it.

    (Some readers might wonder why not RCU for the latter. RCU in this
    case would cost more than refcounting, unfortunately. We take the
    group lock sooner or later, hence the performance improvement by RCU
    would be negligible. Meanwhile, because we need to deal with
    schedulable context depending on the pcm->nonatomic flag, it'll become
    dynamic RCU/SRCU switch, and the grace period may become too long.)

    Along with these changes, there are a significant amount of code
    refactoring. The complex group re-lock & ref code is factored out to
    snd_pcm_stream_group_ref() function, for example.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

21 Jan, 2019

1 commit

  • Make a common helper to re-assign the PCM link using list_move() instead
    of open code with manual list_del() and list_add_tail(). This assures
    the consistency and we can get rid of snd_pcm_group.count field -- its
    purpose is only to check whether the list is singular, and we can know
    it by list_is_singular() call now.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

16 Jan, 2019

2 commits

  • snd_pcm_suspend() is no longer called from outside, so let's make it
    local static. Also drop a superfluous NULL check there.

    Reviewed-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Until now we rely on each driver calling snd_pcm_suspend*() explicitly
    at its own PM handling. However, this can be done far more easily by
    setting the PM ops to each actual snd_pcm device object.

    This patch adds the device_type object for PCM stream and assigns to
    each PCM stream object. The type contains only the PM ops for system
    suspend; we don't need to deal with the resume in general.

    The suspend hook simply calls snd_pcm_suspend_all() for the given PCM
    streams. This implies that the PM order is correctly put, i.e. PCM is
    suspended before the main (or codec) driver, which should be true in
    general. If a special ordering is needed, you'd need to adjust the
    device PM order manually later.

    This patch introduces a new flag, snd_pcm.no_device_suspend, too.
    With this flag set, the PCM device object won't invoke
    snd_pcm_suspend_all() by itself. This is needed for ASoC who wants to
    manage the PM call orders in its serialized way, and the flag is set
    in soc_new_pcm() as default.

    For the non-ASoC world, we can get rid of the manual snd_pcm_suspend
    calls. This will be done in the later patches.

    Reviewed-by: Jaroslav Kysela
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

26 Jul, 2018

1 commit

  • The snd_pcm_lib_read() and snd_pcm_lib_write() inline functions have
    the explicit cast from a user pointer to a kernel pointer, but they
    lacks of __force prefix.

    This fixes sparse warnings like:
    ./include/sound/pcm.h:1093:47: warning: cast removes address space of expression

    Fixes: 68541213720d ("ALSA: pcm: Direct in-kernel read/write support")
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

18 Jul, 2018

1 commit

  • snd_pcm_lib_mmap_vmalloc() was supposed to be implemented with
    somewhat special for vmalloc handling, but in the end, this turned to
    just the default handler, i.e. NULL. As the situation has never
    changed over decades, let's rip it off.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

06 Jul, 2018

1 commit

  • Currently ALSA core blocks userspace for about 10 seconds for PCM R/W IO.
    This needs to be configurable for modern hardware like DSPs where no
    pointer update in milliseconds can indicate terminal DSP errors.

    Add a substream variable to set the wait time in ms. This allows userspace
    and drivers to recover more quickly from terminal DSP errors.

    Signed-off-by: Liam Girdwood
    Signed-off-by: Takashi Iwai

    Liam Girdwood
     

29 Nov, 2017

1 commit

  • This format is similar to existing SNDRV_PCM_FORMAT_{S,U}20_3 that keep
    20-bit PCM samples in 3 bytes, however i.MX6 platform SSI FIFO does not
    allow 3-byte accesses (including DMA) so a 4-byte (more conventional)
    format is needed for it.

    Signed-off-by: Maciej S. Szmigiero
    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Maciej S. Szmigiero
     

27 Jun, 2017

1 commit

  • We have an ioctl to inform the PCM protocol version the running kernel
    supports, but there is no way to know which protocol version the
    user-space can understand. This lack of information caused headaches
    in the past when we tried to extend the ABI. For example, because we
    couldn't guarantee the validity of the reserved bytes, we had to
    introduce a new ioctl SNDRV_PCM_IOCTL_STATUS_EXT for assigning a few
    new fields in the formerly reserved bits. If we could know that it's
    a new alsa-lib, we could assume the availability of the new fields,
    thus we could have reused the existing SNDRV_PCM_IOCTL_STATUS.

    In order to improve the ABI extensibility, this patch adds a new ioctl
    for user-space to inform its supporting protocol version to the
    kernel. By reporting the supported protocol from user-space, the
    kernel can judge which feature should be provided and which not.

    With the addition of the new ioctl, the PCM protocol version is bumped
    to 2.0.14, too. User-space checks the kernel protocol version via
    SNDRV_PCM_INFO_PVERSION, then it sets the supported version back via
    SNDRV_PCM_INFO_USER_PVERSION.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

14 Jun, 2017

2 commits

  • SNDRV_PCM_IOCTL1_GSTATE was firstly introduced in v0.9.0, however never
    be used and the purpose is missing.

    This commit removes the long-abandoned command, bye.

    Signed-off-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Sakamoto
     
  • Drivers can implement 'struct snd_pcm_ops.ioctl' to handle some requests
    from ALSA PCM core. These requests are internal purpose in kernel land.
    Usually common set of operations are used for it.

    SNDRV_PCM_IOCTL1_INFO is one of the requests. According to code comment,
    it has been obsoleted in the old days.

    We can see old releases in ftp.alsa-project.org. The command was firstly
    introduced in v0.5.0 release as SND_PCM_IOCTL1_INFO, to allow drivers to
    fill data of 'struct snd_pcm_channel_info' type. In v0.9.0 release,
    this was obsoleted by the other commands for ioctl(2) such as
    SNDRV_PCM_IOCTL_CHANNEL_INFO.

    This commit removes the long-abandoned command, bye.

    Signed-off-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Sakamoto
     

03 Jun, 2017

5 commits

  • Now all materials are ready, let's allow the direct in-kernel
    read/write, i.e. a kernel-space buffer is passed for read or write,
    instead of the normal user-space buffer. This feature is used by OSS
    layer and UAC1 driver, for example.

    The __snd_pcm_lib_xfer() takes in_kernel argument that indicates the
    in-kernel buffer copy. When this flag is set, another transfer code
    is used. It's either via copy_kernel PCM ops or the normal memcpy(),
    depending on the driver setup.

    As external API, snd_pcm_kernel_read(), *_write() and other variants
    are provided.

    That's all. This support is really simple because of the code
    refactoring until now.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Both __snd_pcm_lib_read() and __snd_pcm_write() functions have almost
    the same code to loop over samples. For simplification, this patch
    unifies both as the single helper, __snd_pcm_lib_xfer().

    Other than that, there should be no functional change by this patch.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Make snd_pcm_lib_read() and *_write() static inline functions that
    call the common helper functions directly. This reduces a slight
    amount of codes, and at the same time, it's a preparation for the
    further cleanups / fixes.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Now that all users of old copy and silence ops have been converted to
    the new PCM ops, the old stuff can be retired and go away.

    Reviewed-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • For supporting the explicit in-kernel copy of PCM buffer data, and
    also for further code refactoring, three new PCM ops, copy_user,
    copy_kernel and fill_silence, are introduced. The old copy and
    silence ops will be deprecated and removed later once when all callers
    are converted.

    The copy_kernel ops is the new one, and it's supposed to transfer the
    PCM data from the given kernel buffer to the hardware ring-buffer (or
    vice-versa depending on the stream direction), while the copy_user ops
    is equivalent with the former copy ops, to transfer the data from the
    user-space buffer.

    The major difference of the new copy_* and fill_silence ops from the
    previous ops is that the new ops take bytes instead of frames for size
    and position arguments. It has two merits: first, it allows the
    callback implementation often simpler (just call directly memcpy() &
    co), and second, it may unify the implementations of both interleaved
    and non-interleaved cases, as we'll see in the later patch.

    As of this stage, copy_kernel ops isn't referred yet, but only
    copy_user is used.

    Reviewed-by: Takashi Sakamoto
    Acked-by: Mark Brown
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

26 May, 2017

1 commit

  • Several files are used to construct PCM core module, a.k.a snd-pcm.
    Although available APIs are described in 'include/sound/pcm.h', some of
    them are not exported as symbols in kernel space. Such APIs are just for
    module local usage.

    This commit adds module local header file and move some function prototypes
    into it so that scopes of them are controlled properly and developers
    get no confusion from unavailable symbols.

    Signed-off-by: Takashi Sakamoto
    Signed-off-by: Takashi Iwai

    Takashi Sakamoto
     

17 May, 2017

3 commits


05 Feb, 2017

1 commit


06 Feb, 2016

1 commit


28 Oct, 2015

1 commit

  • The ALSA core does not modify the constraints provided by a driver. Most
    constraint helper functions already take a const pointer to the constraint
    description, the exception at the moment being the ratden and ratnum
    constraints. Make those const as well, this allows a driver to declare them
    as const.

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

    Lars-Peter Clausen
     

23 Oct, 2015

1 commit


22 Oct, 2015

1 commit

  • While there is nothing wrong with the transfer_ack_begin and
    transfer_ack_end callbacks per-se, the last documented user was part of the
    alsa-driver 0.5.12a package, which was released 14 years ago and even
    predates the upstream integration of the ALSA core and has subsequently
    been superseded by newer alsa-driver releases.

    This seems to indicate that there is no need for having these callbacks and
    they are just cruft that can be removed.

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

    Lars-Peter Clausen
     

21 Oct, 2015

1 commit

  • The recommended and most efficient way to constraint a configuration
    parameter to a single value is to set the minimum and maximum allowed
    values to the same value, i.e. calling snd_pcm_hw_constraint_minmax() with
    the same value for min and max.

    It is not necessarily obvious though that this is the approach that should
    be taken and some drivers have come up with other ways of solving this
    problem, e.g. installing a list constraint with a single item. List
    constraints are dynamic constraints though and hence less efficient than
    the static min-max constraint.

    This patch introduces a new helper function called
    snd_pcm_hw_constraint_single() which only takes a single value has the same
    effect as calling snd_pcm_hw_constraint_minmax() with the same values for
    min and max. But it is hopefully semantically more expressive, making it
    clear that this is the preferred way of setting a single value constraint.

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

    Lars-Peter Clausen
     

16 Oct, 2015

1 commit

  • PCM timer is not always used. For embedded device, we need an interface
    to disable it when it is not needed, to shrink the kernel size and
    memory footprint, here add CONFIG_SND_PCM_TIMER for it.

    When both CONFIG_SND_PCM_TIMER and CONFIG_SND_TIMER is unselected,
    about 25KB saving bonus we can get.

    Please be noted that when disabled, those stubs who using pcm timer
    (e.g. dmix, dsnoop & co) may work incorrectlly.

    Suggested-by: Takashi Iwai
    Signed-off-by: Jie Yang
    Signed-off-by: Takashi Iwai

    Jie Yang
     

13 Sep, 2015

1 commit

  • …this structure had been removed

    This structure was added by 4d96eb255c53 ('ALSA: pcm_lib - add possibility
    to log last 10 DMA ring buffer positions') to store PCM pointers
    information of latest 10 pointer movements (=XRUN_LOG_CNT). When
    CONFIG_SND_PCM_XRUN_DEBUG is configured, 'struct snd_pcm_runtime' has
    'hwptr_log' member with a pointer to the structure. When calling
    xrun_log() in pcm_lib.c, the structure was allocated to the pointer.
    When calling snd_pcm_detach_substream() in pcm.c, the allocated pointer
    is released.

    In f5914908a5b7 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints'),
    the pointer logging is replaced with using Linux Kernel Tracepoints. The
    structure was also removed, while it's just declared. The member and kfree
    still remains.

    This commit removes the member and related codes. I think this was
    overlooked because it brings no errors/warnings to C compilers.

    Fixes: f5914908a5b7 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints')
    Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>

    Takashi Sakamoto
     

27 Apr, 2015

2 commits


21 Feb, 2015

3 commits

  • can be removed without breaking git-bisect now

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

    Pierre-Louis Bossart
     
  • 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
     
  • Audio timestamps can be extracted from sample counters, wall clocks,
    PHC clocks (Ethernet AVB), on-demand synchronized snapshots. This
    patch provides the ability to report timestamping capabilities, select
    timestamp types and retrieve timestamp accuracy, if supported.
    Details can be found in Documentations/sound/alsa/timestamping.txt

    This functionality is introduced by reclaiming the reserved_aligned
    field introduced by commit9c7066aef4a5eb8e4063de28f06c508bf6f2963a
    in snd_pcm_status to provide userspace with selection/query capabilities.
    Additional driver_tstamp and audio_tstamp_accuracy fields are also added.

    snd_pcm_mmap_status remains a read-only structure with only
    the audio timestamp value accessible from user space. The selection
    of audio timestamp type is done through snd_pcm_status only

    This commit does not impact ABI and does not impact the default
    behavior. By default audio timestamp is aligned with hw_pointer and
    reports the DMA position. Backwards compatibility is handled by using
    the HDAudio wall clock for playback and the hw_ptr for all other
    cases.

    For timestamp selection a new STATUS_EXT ioctl is introduced with
    read/write parameters. Alsa-lib will be modified to make use of
    STATUS_EXT.

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

    Pierre-Louis Bossart