Hi Takashi, On 19/09/23 16:09, Takashi Sakamoto wrote:
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.
I'm able to do this from the kernel space, but I wouldn't know how to achieve this in the user-space without switching back and forth between internal and external clock source. Moreover, there seems to be no 'write' handler installed inside 'snd_dice_create_hwdep()'[2], so using 'snd_hwdep_write()' from user-space ALSA is not possible. The only option I see is adding a new control to 'snd_kcontrol_new controls[]'[3], inside 'dice_snd_ctl_construct()'[3] in our AV/C code. But I don't think this is the best solution, in view of the fact the we will be switching to snd-firewire-ctl-services[4] in the near future.
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.
Thanks for explaining this. I have now found the place in the code where you do this[1]. May I ask, what is the reason for this limitation? I don't see any relevant connection between that last used internal sampling rate, and the current external sampling rate. Moreover, the DICE driver is able to see the external sampling rate in real-time. So when the external clock rate is selected and locked, wouldn't it make sense that the device rate followed the external rate automatically, without user-space intervention?
Regards Takashi Sakamoto
Kind regards, Michele Perrone [1]https://github.com/torvalds/linux/blob/v6.6-rc2/sound/firewire/dice/dice-pcm.c#L201 [2]https://github.com/torvalds/linux/blob/v6.6-rc2/sound/firewire/dice/dice-hwdep.c#L167 [3]https://github.com/weiss-engineering/snd-dice/blob/5a95496c0666048bc5bc8c07b3e1d74f392dc9a4/dice-avc.c#L661 [4]https://github.com/alsa-project/snd-firewire-ctl-services