History log of /linux-master/sound/firewire/fireworks/fireworks_stream.c
Revision Date Author Comments
# 0ca37273 11-Nov-2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: add support for Loud Onyx 1200f quirk

Loud Technologies shipped Onyx 1200f 2008 in its Mackie brand and
already discontinued. The model uses component of Fireworks board
module as its communication and DSP function.

The latest firmware (v4.6.0) has a quirk that tx packet includes wrong
value (0x1f) in its dbs field at middle and higher sampling transfer
frequency. It brings ALSA fireworks driver discontinuity of data block
counter.

This commit fixes it by assuming it as a quirk of firmware version
4.6.0.

$ cd linux-firewire-tools/src
$ python crpp < /sys/bus/firewire/devices/fw1/config_rom
ROM header and bus information block
-----------------------------------------------------------------
400 0404b9ef bus_info_length 4, crc_length 4, crc 47599
404 31333934 bus_name "1394"
408 e064a212 irmc 1, cmc 1, isc 1, bmc 0, pmc 0, cyc_clk_acc 100,
max_rec 10 (2048), max_rom 2, gen 1, spd 2 (S400)
40c 000ff209 company_id 000ff2 |
410 62550ce0 device_id 0962550ce0 | EUI-64 000ff20962550ce0

root directory
-----------------------------------------------------------------
414 0008088e directory_length 8, crc 2190
418 03000ff2 vendor
41c 8100000f --> descriptor leaf at 458
420 1701200f model
424 81000018 --> descriptor leaf at 484
428 0c008380 node capabilities
42c 8d000003 --> eui-64 leaf at 438
430 d1000005 --> unit directory at 444
434 08000ff2 (immediate value)

eui-64 leaf at 438
-----------------------------------------------------------------
438 000281ae leaf_length 2, crc 33198
43c 000ff209 company_id 000ff2 |
440 62550ce0 device_id 0962550ce0 | EUI-64 000ff20962550ce0

unit directory at 444
-----------------------------------------------------------------
444 00045d94 directory_length 4, crc 23956
448 1200a02d specifier id: 1394 TA
44c 13010000 version
450 1701200f model
454 8100000c --> descriptor leaf at 484

descriptor leaf at 458
-----------------------------------------------------------------
458 000a199d leaf_length 10, crc 6557
45c 00000000 textual descriptor
460 00000000 minimal ASCII
464 4d61636b "Mack"
468 69650000 "ie"
46c 00000000
470 00000000
474 00000000
478 00000000
47c 00000000
480 00000000

descriptor leaf at 484
-----------------------------------------------------------------
484 000a0964 leaf_length 10, crc 2404
488 00000000 textual descriptor
48c 00000000 minimal ASCII
490 4f6e7978 "Onyx"
494 20313230 " 120"
498 30460000 "0F"
49c 00000000
4a0 00000000
4a4 00000000
4a8 00000000
4ac 00000000

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20211111103015.7498-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a105f642 30-May-2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: perform sequence replay for media clock recovery

Echo Digital Audio Corporation had US patent US7599388B2 titled as
'System and method for high-bandwidth serial bus data transfer'. In the
patent, dual-banked shared memory is used to deliver data between
serial bus transmission and processor in FIFO way. The patent seems to be
used for Fireworks board module. The mechanism is not compliant to
synchronization based on presentation time expressed in syt field
of CIP header. Fireworks board module takes care of the sequence of
the number of data blocks per packet and just ignores the value of syt
field.

This commit takes fireworks driver to performs sequence replay for media
clock recovery. As long as I tested, Audiofire 2 and 4 have a quirk to
skip an isochronous cycle several thousands after starting packet
transmission.

The sequence replay is tested with below models:
* Loud Technology Mackie 400f
* Echo Audio Audiofire 12 (DSP model)
* Echo Audio Audiofire 12 (FPGA model)
* Echo Audio Audiofire 8 (DSP model)
* Echo Audio Audiofire 8 (FPGA model)
* Echo Audio Audiofire Pre8
* Echo Audio Audiofire 4
* Echo Audio Audiofire 2

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2f21a177 27-May-2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: transfer rx packets on-the-fly when replaying

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>


# f9e5ecdf 27-May-2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: add replay target to cache sequence of packet

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>


# bdaedca7 19-May-2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: change waking up timing to process packets

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>


# acfedcbe 18-Oct-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: postpone to start IR context

Some devices have a quirk to postpone transmission of isoc packet for
several dozen or hundred isoc cycles since configured to transmit.
Furthermore, some devices have a quirk to transmit isoc packet with
discontinued data of its header.

In 1394 OHCI specification, software allows to start isoc context with
certain isoc cycle. Linux firewire subsystem has kernel API to use it
as well.

This commit uses the functionality of 1394 OHCI controller to handle
the quirks. At present, this feature is convenient to ALSA bebob and
fireface driver. As a result, some devices can be safely handled, as
long as I know:
- MAudio FireWire solo
- MAudio ProFire Lightbridge
- MAudio FireWire 410
- Roland FA-66

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191018061911.24909-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 659c6af5 17-Oct-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: share PCM buffer size for both direction

This commit allows ALSA fireworks driver to share PCM buffer size for
both capture and playback PCM substream. When AMDTP domain starts for
one of the PCM substream, buffer size of the PCM substream is stores
to AMDTP domain structure. Some AMDTP streams have already run with the
buffer size when another PCM substream starts, therefore the PCM
substream has a constraint to its buffer size.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191017155424.885-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a0e02331 17-Oct-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: use variable size of queue for isoc packets instead of fixed size

The number of packets in packet buffer has been fixed number (=48) since
first commit of ALSA IEC 61883-1/6 packet streaming engine.

This commit allows the engine to use variable number of packets in the
buffer. The size is calculated by a parameter in AMDTP domain structure
surely to store the number of events in the packets of buffer. Although
the value of parameter is expected to come from 'period size' parameter
of PCM substream, at present 48 is still used.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191017155424.885-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dd20e68a 07-Oct-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: register the size of PCM period to AMDTP domain

This commit is a preparation to share the size of PCM period between
PCM substreams on AMDTP streams in the same domain. At this time,
the size of PCM period in PCM substream which starts AMDTP streams in the
same domain is recorded.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191007110532.30270-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# db40eeb2 04-Aug-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: support AMDTP domain

This commit adds AMDTP domain support for ALSA fireworks driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7eb7b18e 04-Aug-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: code refactoring for bus reset handler

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 94491c17 04-Aug-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: code refactoring for initialization/destruction of AMDTP streams

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 588f2e2c 21-Jul-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: obsolete ctx_data.tx.first_dbc with CIP_UNALIGHED_DBC flag

Recent firmware for Fireworks board module have a quirk to start
transmission of CIP with non-zero value for its data block counter.
In current implementation of ALSA firewire stack, the quirk is handled
by 'struct amdtp_stream.ctx_data.tx.first_dbc' with value 0x02. However,
the value comes from reverse engineering. It's better to handle this
quirk without the explicit value.

In a process to parse CIP header, the quirk of data block counter
affects decision of sequence index in sequence-multiplexed data channel;
i.e. MIDI conformant data channel. In Fireworks, the index is decided
by the number of data blocks from top of the same CIP, thus the value
of data block counter is useless.

This commit adds CIP_UNALIGHED_DBC flag and obsoletes the explicit
value for this quirk.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a9679dd3 18-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: ensure to release isochronous resources in pcm.hw_params callback

When stopping packet streaming in reserve function for duplex streams,
isochronous resources should be released.

Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7bc93821 15-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection

In current implementation, establishment connection corresponds to
allocation of isochronous resources. Although this is an ideal
implementation of CMP described in IEC 61883-1, it's not enough
efficient to recover PCM substream multiplexed in packet streaming.
The packet streaming can always restart on the same allocated
isochronous resources even if the previous packet streaming
corrupted.

This commit splits allocation of isochronous resources from
establishment of connection so that CMP runs with allocated
isochronous resources.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5ad84072 12-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: don't set XRUN in stop streaming

When stopping packet streaming, no need to stop PCM substream with XRUN
state. This commit suppresses it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 206cf896 12-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: configure stream parameters in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

This commit splits out an operation to configure stream parameters into
pcm.hw_params callback. In pcm.prepare callback, establishing
connections and start isochronous contexts.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3d725066 12-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: configure sampling transfer frequency in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

At present, several operations are done in pcm.prepare callback. To
reduce load of the callback, This commit splits out an operation to
set sampling transfer frequency in pcm.hw_params callback.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1dc59210 12-Jun-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: unify substream counter

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

It's inconvenient to handle two isochronous context separately
each other. This commit unifies the counters to handle the two
at the same time.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# da607e19 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 345

Based on 1 normalized pattern(s):

licensed under the terms of the gnu general public license version 2

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 88 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000437.521539229@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d3d10a4a 21-May-2019 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: use union for directional parameters

Some parameters of struct amdtp_stream is dependent on direction.

This commit uses union for such parameters to distinguish from
common parameters.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e2eb31d7 02-Jan-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: fix asymmetric API call at unit removal

ALSA fireworks driver has a bug not to call an API to destroy
'cmp_connection' structure for input direction. Currently this causes no
issues because it just destroys 'mutex' structure, while it's better to
fix it for future work.

Fix: d23c2cc4485d ("ALSA: fireworks/bebob/dice/oxfw: allow stream destructor after releasing runtime")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# eb4a378f 09-May-2016 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: drop reuse of incoming packet parameter for ougoing packet parameter

On Fireworks board module of Echo Audio, TSB43Cx43A (IceLynx Micro, iCEM)
is used to process payload of isochronous packets. There's an public
document of this chip[1]. This document is for firmware programmers to
transfer/receive AMDTP with IEC60958 data format, however in clause 2.5,
2.6 and 2.7, we can see system design to utilize the sequence of value in
SYT field of CIP header. In clause 2.3, we can see the specification of
Audio Master Clock (MCLK) from iCEM.

Well, this clock is actually not used for sampling clock. This can be
confirmed when corresponding driver transfer random value as the sequence
of SYT field. Even if in this case, the unit generates proper sound.

Additionally, in unique command set for this board module, the format
of CIP is changed; for IEC 61883-6 mode which we use, and for Windows
Operating System. In the latter mode, the whole 32 bit field in second CIP
header from Windows driver is used to represent counter of packets (NO-DATA
code is still used for packets without data blocks). If the master clock
was physically used by DSP on the board module, the Windows driver must
have transferred correct sequence of SYT field.

Furthermore, as long as seeing capacities of AudioFire2, AudioFire4,
AudioFire8, AudioFirePre8 and AudioFire12, these models don't support
SYT-Match clock source.

Summary, we have no need to relate incoming/outgoing packets. This commit
drops reusing SYT sequence of incoming packets for outgoing packets.

[1] Using TSB43Cx43A: S/PDIF over 1394 (2003, Texus Instruments
Incorporated)
http://www.ti.com/analog/docs/litabsmultiplefilelist.tsp?literatureNumber=slla148&docCategoryId=1&familyId=361

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 99d73559 20-Feb-2016 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: serialize transactions to update connections at bus reset

In IEC 61883-1, at bus-reset, applications can continue isochronous
streaming by updating connections. In ALSA fireworks driver, the
operation is executed in 'update' handler for bus driver.

The connection resources are also changed in process contexts of PCM/MIDI
applications. Therefore, bus-reset handling has race condition
against connection. Current ALSA fireworks driver has a bug for the
condition.

This commit fixes the bug, by expand critical section with mutex. As a
result, connection updating operation in bus-reset handler and connection
changing operation in process context are serialized.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4d2c50a0 14-Nov-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: change type of substream counter from atomic_t to unsigned int

The counter is incremented/decremented in critical section protected with
mutex. Therefore, no need to use atomic_t.

This commit changes the type to unsigned int.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ea54a374 14-Nov-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: move mutex from function callees to callers

Currently, critical section is protected by mutex in functions of
fireworks_stream.c. Callers increments/decrements substreams counter
before calling the functions. Moving mutex to the callers code allows
to change type of the substeram counter from atomic_t to unsigned int.

This commit is a preparation for obsoleting usage of atomic_t for
substream counter.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 51c29fd2 18-Sep-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: rename parameter setting function for AM824 with FDF field

The value of FDF field in CIP header is protocol-dependent. Thus, it's
better to allow data block processing layer to decide the value in any
timing.

In AM824 data format, the value of FDF field in CIP header indicates
N-flag and Nominal Sampling Frequency Code (sfc). The N-flag is for
switching 'Clock-based rate control mode' and 'Command-based rate control
mode'. In our implementation, 'Clock-based rate control mode' is just
supported. Therefore, When sampling transfer frequency is decided, then
the FDF can be set.

This commit replaces 'amdtp_stream_set_parameters' with
'amdtp_am824_set_parameters' to set the FDF. This is the same timing
to decide the ration between the number of data blocks and the number of
PCM frames.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5955815e 18-Sep-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: add data block processing layer for AM824 format

This commit adds data block processing layer for AM824 format. The new
layer initializes streaming layer with its value for fmt field.

Currently, most implementation of data block processing still remains
streaming layer. In later commits, these codes will be moved to the layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 27ec83b5 18-Sep-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: add an argument for Dice's dual wire mode

In IEC 61883-6, one data block represents one event. In ALSA, the event is
one PCM frame. Therefore, when processing one data block, current
implementation counts one PCM frame.

On the other hand, Dice platform has a quirk called as 'dual wire' at
higher sampling rate. In detail, see comment of commit 6eb6c81eee2a
("ALSA: dice: Split stream functionality into a file").

Currently, to handle this quirk, AMDTP stream structure has a
'double_pcm_frames' member. When this is enabled, two PCM frames are
counted. Each driver set this flag by accessing the structure member
directly.

In future commit, some members related to AM824 data block will be moved
to specific structure, to separate packet streaming layer and data block
processing layer. The access will be limited by opaque pointer.

For this reason, this commit adds an argument into
amdtp_stream_set_parameter() to set the flag.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 547e631c 18-Sep-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: firewire-lib: return error code when amdtp_stream_set_parameters() detects error

Currently, amdtp_stream_set_parameters() returns no error even if wrong
arguments are given. This is not good for streaming layer because drivers
can continue processing ignoring capability of streaming layer.

This commit changes this function to return error code.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 18f5ed36 04-Aug-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: add support for recent firmware quirk

Fireworks uses TSB43CB43(IceLynx-Micro) as its IEC 61883-1/6 interface.
This chip includes ARM7 core, and loads and runs program. The firmware
is stored in on-board memory and loaded every powering-on from it.

Echo Audio ships several versions of firmwares for each model. These
firmwares have each quirk and the quirk changes a sequence of packets.

As long as I investigated, AudioFire2/AudioFire4/AudioFirePre8 have a
quirk to transfer a first packet with 0x02 in its dbc field. This causes
ALSA Fireworks driver to detect discontinuity. In this case, firmware
version 5.7.0, 5.7.3 and 5.8.0 are used.

Payload CIP CIP
quadlets header1 header2
02 00050002 90ffffff <-
42 0005000a 90013000
42 00050012 90014400
42 0005001a 90015800
02 0005001a 90ffffff
42 00050022 90019000
42 0005002a 9001a400
42 00050032 9001b800
02 00050032 90ffffff
42 0005003a 9001d000
42 00050042 9001e400
42 0005004a 9001f800
02 0005004a 90ffffff
(AudioFire2 with firmware version 5.7.)

$ dmesg
snd-fireworks fw1.0: Detect discontinuity of CIP: 00 02

These models, AudioFire8 (since Jul 2009 ) and Gibson Robot Interface
Pack series uses the same ARM binary as their firmware. Thus, this
quirk may be observed among them.

This commit adds a new member for AMDTP structure. This member represents
the value of dbc field in a first AMDTP packet. Drivers can set it with
a preferred value according to model's quirk.

Tested-by: Johannes Oertei <johannes.oertel@uni-due.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c85523d1 04-Aug-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

Revert "ALSA: fireworks: add support for AudioFire2 quirk"

This reverts commit 9c6893e0be38b6ca9a56a854226e51dee0a16a5a.

The fix is superseded by the next commit as a better implementation
for supporting AudioFire2/AudioFire4/AudioFirePre8 quirks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9c6893e0 26-Jul-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: add support for AudioFire2 quirk

Fireworks uses TSB43CB43(IceLynx-Micro) as its IEC 61883-1/6 interface.
This chip includes ARM7 core, and loads and runs program. The firmware
is stored in on-board memory and loaded every powering-on.

Echo Audio ships several versions of firmwares for each model. These
firmwares have each quirk and the quirk changes a sequence of packets.

AudioFire2 has a quirk to transfer a first packet with non-zero in
its dbc field. This causes ALSA Fireworks driver to detect discontinuity.
As long as I investigated, firmware 5.7, 5.7.6 and 5.8 have this quirk.

This commit adds a support for the quirk to handle AudioFire2 packets.
For safe, CIP_SKIP_INIT_DBC_CHECK is applied to all versions of
AudioFire2's firmwares.

02 00050002 90ffffff <-
42 0005000a 90013000
42 00050012 90014400
42 0005001a 90015800
02 0005001a 90ffffff
42 00050022 90019000
42 0005002a 9001a400
42 00050032 9001b800
02 00050032 90ffffff
42 0005003a 9001d000
42 00050042 9001e400
42 0005004a 9001f800
02 0005004a 90ffffff

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dec84316 21-Feb-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/bebob/dice/oxfw: make it possible to shutdown safely

A part of these drivers, especially BeBoB driver, are programmed to wait
some events. Thus the drivers should not destroy any data in .remove()
context.

This commit moves some destructors from 'struct fw_driver.remove()' to
'struct snd_card.private_free()' to shutdown safely.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d23c2cc4 21-Feb-2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/bebob/dice/oxfw: allow stream destructor after releasing runtime

Currently stream destructor in each driver has a problem to be called in
a context in which sound card object is released, because the destructors
call amdtp_stream_pcm_abort() and touch PCM runtime data.

The PCM runtime data is destroyed in application's context with
snd_pcm_close(), on the other hand PCM substream data is destroyed after
sound card object is released, in most case after all of ALSA character
devices are released. When PCM runtime is destroyed and PCM substream is
remained, amdtp_stream_pcm_abort() touches PCM runtime data and causes
Null-pointer-dereference.

This commit changes stream destructors and allows each driver to call
it after releasing runtime.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5c697e5b 25-Nov-2014 Clemens Ladisch <clemens@ladisch.de>

ALSA: firewire-lib: remove rx_blocks_for_midi quirk

There are several devices that expect to receive MIDI data only in the
first eight data blocks of a packet. If the driver restricts the data
rate to the allowed rate (as mandated by the specification, but not yet
implemented by this driver), this happens naturally. Therefore, there
is no reason to ever try to use more data packets with any device.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c6e5e741 04-Jun-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/bebob: Shorten critical section for stream_stop_duplex()

All assignment for local variables in these functions are not related to
critical section.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4a286d55 27-May-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/bebob: Change type of argument for sampling rate

Originally, I intent to this argument given with 'struct snd_pcm_runtime.rate'
or params_rate(). They return value of 'unsigned int'. So 'unsigned int' is
better for the type of this argument.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 594ddced 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: Add hwdep interface

This interface is designed for mixer/control application. To use hwdep
interface, the application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# aa02bb6e 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: Add PCM interface

This commit adds a functionality to capture/playback PCM samples.

When AMDTP stream is already running for PCM or the source of clock is not
internal, available sampling rate is limited at current one.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 53111cdc 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk of data blocks for MIDI in out-stream

Fireworks has a quirk to ignore MIDI messages in data blocks more than 8.
This commit adds a flag for this quirk and codes to skip 8 or more data
blocks to transfer MIDI messages.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b84b1a27 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk to reset data block counter at bus reset

Fireworks has a quirk to reset data block counter at bus reset.

This commit adds a flag of CIP_SKIP_DBC_ZERO_CHECK. This flag has an effect
to skip checking dbc continuity when dbc is zero.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d9cd0065 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk for fixed interval of reported dbc

Fireworks firmware version 5.5 reports fix interval for dbc in each packet.

For example, AudioFire4:
CIP0 CIP1 Payload
00070000 900484FF 72
00070008 9004A8FF 72
00070008 90FFFFFF 02
00070010 9004D0FF 72
00070018 9004C4FF 72
00070020 9004E8FF 72
00070020 90FFFFFF 02
00070028 900410FE 72

The interval of each dbc should be 16 except for empty packet but it's still 8.

This commit adds a flag for this quirk and codes to refer to a fixed value.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 69702239 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk for wrong dbs in tx packets

One of Fireworks firmware, named as 'AudioFire9', seems to transmit
packets with wrong value of dbs. It's always 0x11 but actual size of
data block is different.

This commit adds a flag for this quirk and some codes to calculate
correct size.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c8bdf49b 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk for the meaning of dbc

Fireworks has a quirk for the value of dbc field in transmitted packets.
For Fireworks, dbc means the end of events in current packet. This is out
of specification.

For example, AudioFire4:
CIP0 CIP1 Payload
01070092 90FFFFFF 02
0107009A 9001E17B 3A <-
010700A2 9001F6E5 3A
010700A2 90FFFFFF 02
010700AA 9001104F 3A <-
010700B2 900125B9 3A
010700BA 90013B23 3A
010700BA 90FFFFFF 02
010700C2 9001548E 3A <-
010700CA 900169F8 3A
010700CA 90FFFFFF 02
010700D2 90018362 3A <-
010700DA 900198CC 3A

According to IEC 61883-1/6, a packet following to empty packet has the same
value for its dbc. But for Fireworks, it's incremented and empty packet has
the same value as previous packet in dbc field.

This commit adds a flag for Fireworks and some codes to checking dbc continuity.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7ab56645 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks/firewire-lib: Add a quirk for empty packet with TAG0

Fireworks has a quirk to transmit empty packets with TAG0. This commit
adds handling this quirk for full duplex stream synchronization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 315fd41f 25-Apr-2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: fireworks: Add connection and stream management

Fireworks manages connections by CMP and can transmit/receive AMDTP streams
with a few quirks. This commit adds functionality to start/stop the streams.

Major Fireworks products don't support 'SYT-Match' clock source mode, except
for AudioFire12/8(till 2009 July) with firmware version 1.0. Already in
previous commit, this driver don't support such old firmwares. So this commit
adds support for non 'SYT-Match' clock source modes.

I note that this driver has a short gap for MIDI streams when starting PCM
stream. When AMDTP streams are running only for MIDI data and PCM data is
going to be joined at different sampling rate, then AMDTP streams are
stopped once and started again after changing sampling rate.

Unfortunately, Fireworks is not fully compliant to IEC 61883-1/6. Some commits
following to this commit add these quirks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>