summaryrefslogtreecommitdiff
path: root/sound/firewire/amdtp-stream.c
AgeCommit message (Collapse)AuthorFilesLines
2024-02-21Merge branch 'for-linus' into for-nextTakashi Iwai1-1/+1
Pull 6.8-rc devel branch. The trivial merge conflict got resolved. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-02-19ALSA: firewire-lib: fix to check cycle continuityTakashi Sakamoto1-1/+1
The local helper function to compare the given pair of cycle count evaluates them. If the left value is less than the right value, the function returns negative value. If the safe cycle is less than the current cycle, it is the case of cycle lost. However, it is not currently handled properly. This commit fixes the bug. Cc: <stable@vger.kernel.org> Fixes: 705794c53b00 ("ALSA: firewire-lib: check cycle continuity") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20240218033026.72577-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-02-19ALSA: firewire-lib: handle quirk to calculate payload quadlets as data block ↵Takashi Sakamoto1-4/+8
counter Miglia Harmony Audio (OXFW970) has a quirk to put the number of accumulated quadlets in CIP payload into the dbc field of CIP header. This commit handles the quirk in the packet processing layer. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20240218074128.95210-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-31ALSA: firewire-lib: fix uninitialized local variableTakashi Sakamoto1-1/+1
The function local variable, curr_cycle_time is declared without initialization. When tracepoints event is not probed, it looks to be used as is. This commit fixes it. Fortunately, the value of local variable is not used unless the event is probed, thus this commit is for better coding. Reported-by: Dan Carpenter <error27@gmail.com> Fixes: fef4e61b0b76 ("ALSA: firewire-lib: extend tracepoints event including CYCLE_TIME of 1394 OHCI") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230130141532.102838-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-12ALSA: firewire-lib: compute extra delay for runtime of PCM substreamTakashi Sakamoto1-2/+81
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>
2023-01-12ALSA: firewire-lib: obsolete return value from context payload processing layerTakashi Sakamoto1-1/+1
This commit obsoletes return value from the context payload processing layer since the multiplier between the data block count and PCM frame count was moved to the packet streaming processing layer. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230110134933.322794-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-12ALSA: firewire-lib: move parameter for pcm frame multiplier from context ↵Takashi Sakamoto1-6/+19
payload processing layer The current implementation delegates the task to calculate the number of processed PCM frames into the context payload processing layer. It looks good as long as frame calculation is done for a single purpose. Nevertheless, another purpose, the computation of extra delay for the runtime of PCM substream, requires frame calculation, too. This commit refactors the current implementation so that the packet stream processing layer is responsible for the calculation of PCM frame, too. The member is moved to stream structure for multiplier between data block count and PCM frame count. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230110134933.322794-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-10ALSA: firewire-lib: extend tracepoints event including CYCLE_TIME of 1394 OHCITakashi Sakamoto1-6/+15
A commit baa914cd81f5 ("firewire: add kernel API to access CYCLE_TIME register") allow unit drivers to read CYCLE_TIME of 1394 OHCI controller. The value expresses monotonic time with 42.195 Mhz resolution and wrapping around every 128 seconds. The controller uses the time to govern isochronous cycle. This commit extends tracepoints event including the value so that event parser can compute gap between current isochronous cycle and the latest isochronous cycle in which packet is processed (in IR context) or scheduled (in IT context). It loses backward compatibility to former format of the tracepoints event. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230109213231.138223-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-09ALSA: firewire-lib: keep history to process isochronous packetTakashi Sakamoto1-7/+13
The history to process isochronous packets is useful when computing gap between current isochronous cycle and the latest isochronous cycle in which packet is processed (in IR context) and scheduled (in IT context). This commit stores the most recent packet descriptors to keep the history. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230109021738.75543-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-09ALSA: firewire-lib: use circular linked list for context payload processing ↵Takashi Sakamoto1-2/+2
layer The list of packet descriptor is passed to context payload processing layer so that each driver can copy PCM frames, MIDI messages, and device specific data between packet payload buffer and intermediate buffer for user space application. The list of packet descriptor was replaced by circular linked list in a previous commit. This commit uses circular linked in context payload processing layer as well. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230109021738.75543-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-09ALSA: firewire-lib: use circular linked list to enumerate packet descriptorsTakashi Sakamoto1-17/+30
Current implementation uses list of packet descriptor as template to schedule isochronous packet. The packet descriptors are operated by position and size, while circular linked list is convenient to enumerate the packet descriptors. This commit utilizes circular linked list for the purpose. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230109021738.75543-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-08ALSA: firewire-lib: code refactoring for cache position in sequence replayTakashi Sakamoto1-7/+9
When sequence replay is enabled for media clock recovery, current implementation refers to cache of sequence descriptors in tx packets, then fulfil sequence descriptors for rx packets. The initialization for rx packets is done before starting packet streaming, while it can be postponed till the cache has enough entries for the replay. This commit refactors for the purpose as well as minor code change for renaming of structure member. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230107023214.29132-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-08ALSA: firewire-lib: code refactoring for cache position in tx packetsTakashi Sakamoto1-16/+14
When sequence replay is enabled for media clock recovery, current implementation caches sequence descriptors from packet descriptors in tx packets. Helper function for the purpose do not necessarily have good readability. This commit refactors relevant functions by renaming structure members, function name, and function local variables. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230107023214.29132-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-08ALSA: firewire-lib: code refactoring for pool position in rx packetsTakashi Sakamoto1-19/+14
When scheduling transmission of rx packets, current implementation fulfils packet descriptors after pooling sequence descriptors. It is for packet queueing. Besides the implementations do not necessarily have good readability. This commit refactors them by adding function local variables and function arguments. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230107023214.29132-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-08ALSA: firewire-lib: code refactoring for helper functions to pool sequence ↵Takashi Sakamoto1-33/+32
in rx packets When scheduling transmission of rx packets, current implementation pools sequence descriptors at first for media clock. Two methods are used for the purpose depending on four cases, while the implementations do not necessarily have good readability. This commit refactors them by adding function pointers and functions arguments. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230107023214.29132-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-25ALSA: firewire-lib: Fix 'amdtp_domain_start()' when no AMDTP_OUT_STREAM ↵Christophe JAILLET1-2/+5
stream is found The intent here is to return an error code if we don't find what we are looking for in the 'list_for_each_entry()' loop. 's' is not NULL if the list is empty or if we scan the complete list. Introduce a new 'found' variable to handle such cases. Fixes: 60dd49298ec5 ("ALSA: firewire-lib: handle several AMDTP streams in callback handler of IRQ target") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-12ALSA: firewire-lib: replace in_interrupt() with in_softirq()Takashi Sakamoto1-3/+3
Tasklet is used to handle isochronous context of 1394 OHCI. The explicit usage of in_softirq() may be preferable than in_interrupt(). Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210611083425.61204-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-10ALSA: firewire-lib: obsolete workqueue for period updateTakashi Sakamoto1-15/+0
The workqueue to notify PCM period elapse is not used anymore. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210610031733.56297-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-10ALSA: firewire-lib: operate for period elapse event in process contextTakashi Sakamoto1-17/+14
All of drivers in ALSA firewire stack processes two chances to process isochronous packets in any isochronous context; in software IRQ context for 1394 OHCI, and in process context of ALSA PCM application. In the process context, callbacks of .pointer and .ack are utilized. The callbacks are done by ALSA PCM core under acquiring lock of PCM substream, In design of ALSA PCM core, call of snd_pcm_period_elapsed() is used for drivers to awaken user processes from waiting for available frames. The function voluntarily acquires lock of PCM substream, therefore it is not called in the process context since it causes dead lock. As a workaround to avoid the dead lock, all of drivers in ALSA firewire stack uses workqueue to delegate the call. A variant of snd_pcm_period_elapsed() without lock acquisition can obsolete the workqueue. An extra care is needed for the callback of .pointer since it's called from snd_pcm_period_elapsed(). The isochronous context in Linux FireWire subsystem is safe mostly for nested call except in software IRQ context. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210610031733.56297-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-08Merge branch 'for-linus' into for-nextTakashi Iwai1-1/+1
2021-06-06ALSA: firewire-lib: remove useless operations for kernel preemptionTakashi Sakamoto1-12/+2
In all of drivers of ALSA firewire stack, the callback of .pointer and .ack in snd_pcm_ops structure is done in acquired spin_lock of PCM substream, therefore already under disabled kernel preemption. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210606025651.29970-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-06ALSA: firewire-lib: fix error codes for allocation failureDan Carpenter1-2/+6
Return -ENOMEM if kcalloc() fails. Currently the code returns success. Fixes: f9e5ecdfc2c2 ("ALSA: firewire-lib: add replay target to cache sequence of packet") Fixes: 6f24bb8a157c ("ALSA: firewire-lib: pool sequence of packet in IT context independently") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/YLtyL4VoArwVLor1@mwanda Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-05ALSA: firewire-lib: fix the context to call snd_pcm_stop_xrun()Takashi Sakamoto1-1/+1
In the workqueue to queue wake-up event, isochronous context is not processed, thus it's useless to check context for the workqueue to switch status of runtime for PCM substream to XRUN. On the other hand, in software IRQ context of 1394 OHCI, it's needed. This commit fixes the bug introduced when tasklet was replaced with workqueue. Cc: <stable@vger.kernel.org> Fixes: 2b3d2987d800 ("ALSA: firewire: Replace tasklet with work") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210605091054.68866-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-28ALSA: firewire-lib: support NO_PERIOD_WAKEUP in ALSA PCM runtimeTakashi Sakamoto1-6/+21
Drivers of ALSA firewire stack can process packets for IT/IR context in process context when the process operates ALSA PCM character device by calling ioctl(2) with some requests. The ioctl requests are: * SNDRV_PCM_IOCTL_HWSYNC * SNDRV_PCM_IOCTL_SYNC_PTR * SNDRV_PCM_IOCTL_REWIND * SNDRV_PCM_IOCTL_FORWARD * SNDRV_PCM_IOCTL_WRITEI_FRAMES * SNDRV_PCM_IOCTL_READI_FRAMES * SNDRV_PCM_IOCTL_WRITEN_FRAMES * SNDRV_PCM_IOCTL_READN_FRAMES This means that general application can process PCM frames apart from hardware IRQ invocation, even if they are programmed by either IRQ-based scheduling model or Timer-based scheduling model. This commit add support for Timer-based scheduling model by allowing PCM runtime to suppress both process wakeup per period and scheduling hardware IRQ. SNDRV_PCM_INFO_BATCH is obsoleted since ALSA IEC 61883-1/6 packet streaming engine can report the number of transferred PCM frames within PCM period boundary. The granularity equals to SYT_INTERVAL in blocking transmission. In non-blocking transmission, it doesn't equal to SYT_INTERVAL but doesn't exceed. This patch is tested with PulseAudio, and --sched-model option of axfer with fix against the issue reported at: * https://lore.kernel.org/alsa-devel/687f9871-7484-1370-04d1-9c968e86f72b@linux.intel.com/#r Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210527123253.174315-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-28ALSA: firewire-lib: transfer rx packets on-the-fly when replayingTakashi Sakamoto1-5/+22
Models in below series start transmission of packet after receiving the sequence of packets: * Digidesign Digi00x family * RME Fireface series Additionally, models in Tascam FireWire series start multiplexing PCM frames into packets enough after receiving packets. It's required to transfer packets on-the-fly for the above models according to nominal sampling transfer frequency before starting sequence replay. This commit allows drivers to decide whether the engine transfers packet on-the-fly or not. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210527122611.173711-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-28ALSA: firewire-lib: replay sequence of incoming packets for outgoing packetsTakashi Sakamoto1-14/+139
ALSA IEC 61883-1/6 packet streaming engine uses pre-computed parameters ideal for nominal sampling transfer frequency (STF) to transfer packets to device since it was added 2011. As a result of user experience for a decade, it is clear that the sequence is not suitable to some actual devices. It takes the devices to generate noise, and causes any type of discontinuity in the series of packet transferred from the device. It's required for the engine to transfer packets according to effective STF. The effective STF is given by media clock recovered by the sequence of packet transferred from the target device. In the previous commit, the sequence is already cached. The media clock recovery can be achieved by analyzing the sequence. In technological world, many ideas are proposed for media clock recovery. However, the small part of them could be actually adopted in our case since floating point arithmetic is not mostly available in Linux kernel land. This commit adopts the simple way from them; sequence replay, which means that the sequence of parameters from incoming packet is used as is to transfer outgoing packets. The media clock is not computed internally, but the sequence of outgoing packet superficially looks to be generated by the media clock. The association between source and destination is decided when starting AMDTP domain. When the target device supports a pair of isochronous packet streams, the tx stream is source and the rx stream is destination. When it supports two pair of streams, each of tx stream is associated to corresponding rx stream in its order. When it supports less number of tx streams than rx streams, the fist tx stream is selected for all of rx streams. When it supports more tx streams than rx streams, the first tx packet is associated to the rx stream. As I noted in previous commit, the sequence of parameters from incoming packet is different between devices, time to time. It is worse idea to replay the sequence of parameters from a device for the sequence of packet to the other devices even if they are in the same category of device. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210527122611.173711-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-28ALSA: firewire-lib: add replay target to cache sequence of packetTakashi Sakamoto1-3/+79
In design of audio and music unit in IEEE 1394 bus, feedback of effective sampling transfer frequency (STF) is delivered by packets transferred from device. The devices supported by ALSA firewire stack are categorized to three groups regarding to it. * Group 1: * Echo Audio Fireworks board module * Oxford Semiconductor OXFW971 ASIC * Digidesign Digi00x family * Tascam FireWire series * RME Fireface series * Group 2: * BridgeCo. DM1000/DM1100/DM1500 ASICs for BeBoB solution * TC Applied Technologies DICE ASICs * Group 3: * Mark of the Unicord FireWire series In group 1, the effective STF is determined by the sequence of the number of events per packet. In group 2, the sequence of presentation timestamp expressed in syt field of CIP header is interpreted as well. In group 3, the presentation timestamp is expressed in source packet header (SPH) of each data block. I note that some models doesn't take care of effective STF with large internal buffer. It's reasonable to name it as group 0: * Group 0 * Oxford Semiconductor OXFW970 ASIC The effective STF is known to be slightly different from nominal STF for all of devices, and to be different between the devices. Furthermore, the effective STF is known to be shifted for long-period transmission. This makes it hard for software to satisfy the effective STF when processing packets to the device. The effective STF is deterministic as a result of analyzing the batch of packet transferred from the device. For the analysis, caching the sequence of parameter in the packet is required. This commit adds an option so that AMDTP domain structure takes AMDTP stream structure to cache the sequence of parameters in packet transferred from the device. The parameters are offset ticks of syt field against the cycle to receive the packet and the number of data blocks per packet. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210527122611.173711-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-25ALSA: firewire-lib: obsolete callbacked memberTakashi Sakamoto1-7/+2
The member of callbacked in AMDTP stream structure is not used anymore. Instead, ready_processing member is used to wake up yielding task of user process. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210524031346.50539-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-25ALSA: firewire-lib: drop initial NODATA or empty packetTakashi Sakamoto1-39/+97
The devices based on BeBoB ASICs or the devices in Tascam FireWire series transfer a batch of NODATA packet or empty packet in the beginning of packet streaming. To avoid processing them, current implementation uses an option to skip processing content of tx packet during some initial cycles. However, the hard-coded number is not enough useful. This commit drops content of packets till the packet includes any event firstly. The function of option is to skip processing content of tx packet with any event after dropping. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210524031346.50539-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: code refactoring for transfer delayTakashi Sakamoto1-16/+8
In later commit, transfer delay is used in both IR and IT contexts. This commit refactors regardless of transfer delay. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: code refactoring for generation of data block sequenceTakashi Sakamoto1-33/+40
This commit dissolves sequence generator in terms of the number of data blocks per packet. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: code refactoring for generation of syt sequenceTakashi Sakamoto1-2/+24
This commit dissolves sequence generator in terms of syt offsets for packet. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: code refactoring for generation of packet descriptorsTakashi Sakamoto1-6/+5
This commit refactors the arguments of helper function to generate the descriptors of packet. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: pool sequence of packet in IT context independentlyTakashi Sakamoto1-89/+61
Current implementation pools the sequence in AMDTP domain. This is convenient regarding to memory usage and computation time, however inconvenient for the devices such that several rx streams are expected to transfer timing information independently. This commit refactors to pool the sequence per rx packet stream. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: add flag to unaware of syt in CIP headerTakashi Sakamoto1-17/+10
Many devices are unaware of syt field in rx CIP for playback timing. This commit adds a flag to cancel processing syt field. Actually, syt calculation is required to decide the number of events per rx packet. The flag put 0xffff to CIP header of rx packet. On the other hand, The value of syt field in CIP header of tx packet is unavailable. The sequence of packet descriptor for tx packet includes 0 for the offset of syt field to avoid computation. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210522013303.49596-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-22ALSA: firewire-lib: Fix uninitialized variable err issueTakashi Sakamoto1-3/+3
The check of error is just done for the case that CIP header is available. This commit moves auto variable into the branch to process CIP header. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: c09010eeb373 ("ALSA: firewire-lib: handle the case that empty isochronous packet payload for CIP") Suggested-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520130409.GA170303@workstation Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: change waking up timing to process packetsTakashi Sakamoto1-6/+10
When starting AMDTP domain, tasks in process context yields running CPU till all of isochronous context get callback, with an assumption that it's OK to process content of packet. However several isochronous cycles are skipped to transfer rx packets, or the content of rx packets are dropped, to manage the timing to start processing the packets. This commit changes the timing for tasks in process context to wake up when processing content of packet is actually ready. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-9-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: start processing content of packet at the same cycle in ↵Takashi Sakamoto1-27/+150
several IT contexts DICE ASICs support several pairs of isochronous packet streaming and expect software to queue packets with the same timing information into the same isochronous cycle. This commit adds structure member to manage the cycle to start processing packet in several IT contexts. The cycle is decided when batch of isochronous cycle is skipped in callback to isochronous context for IRQ target. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-8-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: code refactoring to start several IT/IR contextsTakashi Sakamoto1-23/+14
It's several hundred cycles from starting isochronous contexts and the actual cycle to start processing content of packet. It's useless to start the context for IRQ target apart from the other contexts. This commit refactors helper function to start AMDTP domain in the point. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: skip initial packets instead of scheduling IR contextTakashi Sakamoto1-67/+13
Current implementation of ALSA IEC 61883-1/6 packet streaming engine allows drivers to decide isochronous cycle to start IR context. This option is mainly used to avoid processing the sequence of packet with some quirks; e.g. discontinuity of counter. However, it's inconvenient to fail to continue packet processing when the target device doesn't start transmission of packet till the decided cycle. This commit changes the behaviour. As an alternative to the start cycle for IR context, the cycle count to drop content of packet in the beginning of IR context. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: start processing content of packet at the same cycle in ↵Takashi Sakamoto1-6/+109
several IR contexts DICE ASICs support several pairs of isochronous packet streaming. It's convenient for drivers to process content of the packet in the same cycle timing. This commit adds structure member to manage the cycle to start processing packet in several IR contexts. The cycle is decided in the first callback of the IR contexts. The content of packet is dropped till the cycle. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: code refactoring for selection of IT context header lengthTakashi Sakamoto1-6/+11
This commit refactors regarding to the size of CIP header. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: code refactoring for calculation of context payloadTakashi Sakamoto1-16/+21
It's convenient to calculate the size of context payload apart from the size of isochronous packet payload. This commit adds a helper function for it. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-20ALSA: firewire-lib: code refactoring for size of CIP headerTakashi Sakamoto1-10/+15
Some macros are added to refactor codes related to CIP header. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210520040154.80450-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: insert descriptor for skipped cycleTakashi Sakamoto1-5/+24
This commit fulfils sequence descriptors for skipped cycle when it's one cycle. This is preparation for future integration. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-9-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: check cycle continuityTakashi Sakamoto1-3/+36
Within devices supported by drivers in ALSA firewire stack, OXFW-based devices and Fireface devices are known to skip isochronous cycle for packet transmission. The former is due to the jumbo payload quirk. The latter is due to vendor protocol in which empty packet is not transferred in blocking mode. Although nothing to do just for handling events of the packet, packet continuity is necessarily for media clock recovery. This commit checks whether any cycle is continue or not. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-8-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: code refactoring for check of CIP header about payload sizeTakashi Sakamoto1-6/+4
The size of CIP payload is now passed to helper function to parse CIP header. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: code refactoring for parser of IR context headerTakashi Sakamoto1-12/+10
This commit refactors regarding to function argument for the length of isochronous packet payload. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: code refactoring for helper function to compute OHCI ↵Takashi Sakamoto1-13/+13
1394 cycle Some macros and functions are renamed so that they compute isochronous cycle within maximum count of second in isochronous context of 1394 OHCI. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-18ALSA: firewire-lib: code refactoring for sequence descriptor'Takashi Sakamoto1-18/+18
A internal structure is used to gather parameters relevant to sequence descriptor. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210518130048.146596-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>