ALSA: firewire-lib: compute extra delay for runtime of PCM substream
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 10 Jan 2023 13:49:33 +0000 (22:49 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 12 Jan 2023 11:14:52 +0000 (12:14 +0100)
commitaf13842cad44eb1feb9da23c7ce5547ecf007694
tree50abfb79ba2a25dc0479c224471d1b19740fbdc5
parent7fc693e474725544e5ee1cabde34d95e544eb708
ALSA: firewire-lib: compute extra delay for runtime of PCM substream

All drivers in ALSA firewire stack have never reported extra delay for
the runtime of PCM substream. There is some reason, but the main reason
is that the meaning of extra delay differs depending on driver design,
especially for the packet-oriented driver.

Here I define the extra delay for the case of IEC 61883-1/6. It is the
number of PCM frames transferred or should be transferred between the
current isochronous cycle and the isochronous cycle to which the latest
isochronous packet arrived (in IR context) or is scheduled (in IT context).

A commit baa914cd81f5 ("firewire: add kernel API to access CYCLE_TIME
register") allow unit drivers to read CYCLE_TIME of 1394 OHCI controller.
It allows the drivers to compute the current isochronous cycle.

Additionally, a commit f0117128879b ("ALSA: firewire-lib: keep history to
process isochronous packet") enables to save the history processing
packets. It allows the driver to estimate the total number of data blocks
in packets arriving shortly, or calculate the total number of data blocks
in scheduled packets.

Now it is ready. This commit implements the computation of the extra delay.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230110134933.322794-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/amdtp-stream.c