From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>, linux-sound@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>, Takashi Sakamoto <takaswie@kernel.org>
Subject: Re: [PATCH] ALSA: pcm: reinvent the stream synchronization ID API
Date: Mon, 6 May 2024 11:02:39 +0200 [thread overview]
Message-ID: <0f410a6a-f74d-4e3e-ac6a-6564e67bc140@linux.intel.com> (raw)
In-Reply-To: <20240430161012.4011064-1-perex@perex.cz>
On 4/30/2024 6:10 PM, Jaroslav Kysela wrote:
> Until the commit e11f0f90a626 ("ALSA: pcm: remove SNDRV_PCM_IOCTL1_INFO
> internal command"), there was a possibility to pass information
> about the synchronized streams to the user space. The mentioned
> commit removed blindly the appropriate code with an irrelevant comment.
>
> The revert may be appropriate, but since this API was lost for several
> years without any complains, it's time to improve it. The hardware
> parameters may change the used stream clock source (e.g. USB hardware)
> so move this synchronization ID to hw_params as read-only field.
>
> It seems that pipewire can benefit from this API (disable adaptive
> resampling for perfectly synchronized PCM streams) now.
>
> Cc: Takashi Sakamoto <takaswie@kernel.org>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> ---
> include/sound/pcm.h | 9 +++++++++
> include/uapi/sound/asound.h | 8 +++++---
> sound/core/pcm_lib.c | 13 +++++++++++++
> sound/core/pcm_native.c | 6 ++++++
> 4 files changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 210096f124ee..f716e0d0d174 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -93,6 +93,7 @@ struct snd_pcm_ops {
> #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2
> /* 3 is absent slot. */
> #define SNDRV_PCM_IOCTL1_FIFO_SIZE 4
> +#define SNDRV_PCM_IOCTL1_SYNC_ID 5
>
> #define SNDRV_PCM_TRIGGER_STOP 0
> #define SNDRV_PCM_TRIGGER_START 1
> @@ -1565,6 +1566,14 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
> (__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST; \
> (f) = (__force snd_pcm_format_t)((__force int)(f) + 1))
>
> +/**
> + * is sync id (clock id) empty?
> + */
> +static inline bool pcm_sync_empty(union snd_pcm_sync_id *sync)
> +{
> + return sync->id64[0] == 0 && sync->id64[1] == 0;
Can you use SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STREAM_CAPTURE here,
for someone not familiar with ALSA code above will be confusing.
> +}
> +
> /* printk helpers */
> #define pcm_err(pcm, fmt, args...) \
> dev_err((pcm)->card->dev, fmt, ##args)
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 628d46a0da92..13f8a08f3f33 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -142,7 +142,7 @@ struct snd_hwdep_dsp_image {
> * *
> *****************************************************************************/
>
> -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 17)
> +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 18)
>
> typedef unsigned long snd_pcm_uframes_t;
> typedef signed long snd_pcm_sframes_t;
> @@ -334,6 +334,7 @@ union snd_pcm_sync_id {
> unsigned char id[16];
> unsigned short id16[8];
> unsigned int id32[4];
> + __u64 id64[2];
Similarly here, can SNDRV_PCM_STREAM_LAST be used?
next prev parent reply other threads:[~2024-05-06 9:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 16:10 [PATCH] ALSA: pcm: reinvent the stream synchronization ID API Jaroslav Kysela
2024-05-01 11:44 ` Takashi Sakamoto
2024-05-01 14:17 ` Jaroslav Kysela
2024-05-02 7:31 ` Takashi Iwai
2024-05-02 8:02 ` Jaroslav Kysela
2024-05-02 15:27 ` Takashi Iwai
2024-05-02 17:05 ` Jaroslav Kysela
2024-05-06 9:02 ` Amadeusz Sławiński [this message]
2024-05-06 9:12 ` Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f410a6a-f74d-4e3e-ac6a-6564e67bc140@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=takaswie@kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox