alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Michele Perrone <michele.perrone@weiss.ch>
Cc: Takashi Iwai <tiwai@suse.de>,
	Rolf Anderegg <rolf.anderegg@weiss.ch>,
	alsa-devel@alsa-project.org
Subject: Re: MAN301 external clock issues (Re: [PATCH] ALSA: dice: add stream format parameters for Weiss devices)
Date: Tue, 19 Sep 2023 23:09:16 +0900	[thread overview]
Message-ID: <20230919140916.GA212186@workstation.local> (raw)
In-Reply-To: <eb2cd50f-04c9-47f6-9fb3-c75d7b20a563@weiss.ch>

Hi Michele,

On Mon, Sep 18, 2023 at 03:19:10PM +0200, Michele Perrone wrote:
> Hi Takashi,
> 
> I'm encountering a strange issue when working with our MAN301 device and
> external clock sync. I am currently using our kernel-side AV/C code to
> switch between clock sources[1].
> 
> When I switch to an external clock source, the user-space ALSA code is not
> able to change the clock rate anymore. This means that I cannot switch to
> the external clock rate that the DICE is currently locked onto.
> 
> Here is a practical example / steps to reproduce:
> 
> 1. Set the clock source to internal and the clock rate to an arbitrary
>    value (e.g. 44100) from the user-space. The relevant sections of
>    /proc/asound/card0/firewire/dice will then look like this:
> 
> global:
>   owner: ffc0:000100000000
>   notification: 00000040
>   nick name: Weiss MAN301
>   clock select: internal 44100
>   enable: 0
>   status: locked 44100
>   ext status: 00010001
>   sample rate: 44100
>   version: 1.0.12.0
>   clock caps: 44100 48000 88200 96000 176400 192000 aes1 aes2 aes3 wc
> internal
>   clock source names: AES/EBU (XLR)\S/PDIF (RCA)\S/PDIF
> (TOS)\Unused\Unused\Unused\Unused\Word Clock
> (BNC)\Unused\Unused\Unused\Unused\Internal\\
> 
> ext status:
>   clock source: internal
>   locked: 1
>   rate: 44100
> 
> 2. Set the clock source to external (e.g. aes1) through AV/C command[1]
>    and connect a digital input with a different clock rate (e.g. 48000).
>    Now the two sections of will look like this. You can see that the
>    external source status is "locked".
> 
> global:
>   owner: ffc0:000100000000
>   notification: 00000010
>   nick name: Weiss MAN301
>   clock select: aes1 44100
>   enable: 0
>   status: unlocked 44100
>   ext status: 00010001
>   sample rate: 44100
>   version: 1.0.12.0
>   clock caps: 44100 48000 88200 96000 176400 192000 aes1 aes2 aes3 wc
> internal
>   clock source names: AES/EBU (XLR)\S/PDIF (RCA)\S/PDIF
> (TOS)\Unused\Unused\Unused\Unused\Word Clock
> (BNC)\Unused\Unused\Unused\Unused\Internal\\
> 
> ext status:
>   clock source: aes1
>   locked: 1
>   rate: 48000
> 
> 3. Try to set the clock rate to 48000 from user-space ALSA. This will
>    fail. Only 44100 can be used. Example:
> 
> $ aplay --disable-resample 48000_S32.wav
> Playing WAVE '48000_S32.wav' : Signed 32 bit Little Endian, Rate 48000 Hz,
> Stereo
> Warning: rate is not accurate (requested = 48000Hz, got = 44100Hz)
> 
> 
> The current workaround is going back to the internal clock source, switch
> the clock rate to the one reported in the "ext status" section, and then
> go back to the external clock source. This however does not feel quite
> right.
> 
> I will be very grateful for any suggestion from your side.
 
I programmed ALSA dice driver to behave like that.

The driver configures the target device for sampling rate which ALSA PCM
application expects when the device uses internal source of clock. When
the device is configured to use external source of clock, the driver
adds constrains to ALSA PCM hardware configuration so that the application
works with current sampling rate configured in device.

In your case:

clk src    ext rate   rate in device   appl avail rates
--------- ---------- ---------------- ------------------
Internal       -         44.1 KHz        44.1-192.0 kHz
External    48.0 kHz     44.1 kHz        44.1 kHz

For the case of external source of clock, you need to configure the
sampling rate in device by your hand, by accesing to GLOBAL_CLOCK_SELECT
offset in global section of TCAT protocol.

As a result:

clk src    ext rate   rate in device   appl avail rates
--------- ---------- ---------------- ------------------
Internal       -         44.1 KHz        44.1-192.0 kHz
External    48.0 kHz     48.0 kHz (*)    48.0 kHz

I note that the device's behaviour of the external source scenario
differs depending on models even if the pair of models uses the same
Dice ASIC. I guess that firmware version brings such chaos.

> Thank you and kind regards,
> Michele Perrone
> 
> [1]https://github.com/weiss-engineering/snd-dice/blob/5a95496c0666048bc5bc8c07b3e1d74f392dc9a4/dice-avc.c#L436


Regards

Takashi Sakamoto

  reply	other threads:[~2023-09-19 14:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28  9:16 [PATCH] ALSA: dice: add stream format parameters for Weiss devices Michele Perrone
2023-07-28 13:13 ` Takashi Sakamoto
2023-07-31  8:09   ` Michele Perrone
2023-07-31 14:06     ` Takashi Sakamoto
2023-08-08  8:34       ` Michele Perrone
2023-08-08 15:25         ` Takashi Sakamoto
2023-08-16 13:05           ` ALSA: dice: improve support " Michele Perrone
2023-08-18 13:13             ` Takashi Sakamoto
2023-08-18 13:23               ` Michele Perrone
2023-08-22 13:58             ` Takashi Sakamoto
2023-08-31 13:28               ` Takashi Sakamoto
2023-09-04 16:00                 ` Rolf Anderegg
2023-09-05  1:20                   ` Takashi Sakamoto
2023-09-05  8:57                     ` Rolf Anderegg
2023-09-05 23:54 ` INT203 and DAC1 (Re: [PATCH] ALSA: dice: add stream format parameters for Weiss devices) Takashi Sakamoto
2023-09-16  9:18   ` Michele Perrone
2023-09-17  2:55     ` Takashi Sakamoto
2023-09-18 13:19   ` MAN301 external clock issues " Michele Perrone
2023-09-19 14:09     ` Takashi Sakamoto [this message]
2024-01-21 14:07 ` MAN301 internal routing " Takashi Sakamoto
2024-01-21 14:30   ` Takashi Sakamoto
2024-02-15 12:04     ` Takashi Sakamoto
2024-02-26 16:06   ` Michele Perrone
2024-02-27 23:54     ` Takashi Sakamoto
2024-02-28  8:14       ` Rolf Anderegg
2024-02-28  8:32         ` Rolf Anderegg
2024-02-28 23:28           ` Takashi Sakamoto

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=20230919140916.GA212186@workstation.local \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=michele.perrone@weiss.ch \
    --cc=rolf.anderegg@weiss.ch \
    --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;
as well as URLs for NNTP newsgroup(s).