Commit Graph

126 Commits

Author SHA1 Message Date
Takashi Sakamoto a64db0b9df ALSA: fireface: make read-only const array for model names static
It is preferable not to populate the constant array for constant strings
on the stack.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230627235406.289970-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-28 11:42:55 +02:00
Takashi Sakamoto 81c2943507 ALSA: firewire: use 'GPL' string for module license contributed by Takashi Sakamoto
In MODULE_LICENSE macro, "GPL" string obsoletes "GPL v2" string by a
commit bf7fbeeae6 ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2"
bogosity").

This commit uses the preferable expression.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230611144445.221529-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-12 14:38:58 +02:00
Takashi Sakamoto 0d9eb7ed95 ALSA: fireface: add field for the number of messages copied to user space
Current structure includes no field to express the number of messages
copied to user space, thus user space application needs to information
out of the structure to parse the content of structure.

This commit adds a field to express the number of messages copied to user
space since It is more preferable to use self-contained structure.

Kees Cook proposed an idea of annotation for bound of flexible arrays
in his future improvement for flexible-length array in kernel. The
additional field for message count is suitable to the idea as well.

Reference: https://people.kernel.org/kees/bounded-flexible-arrays-in-c
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230202133708.163936-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-02-04 09:35:17 +01:00
Dan Carpenter 81c254a65c ALSA: fireface: fix locking bug in ff400_copy_msg_to_user()
The ff400_copy_msg_to_user() function drops the spin lock to call
copy_to_user().  However, if the copy_to_user() fails, then it must
take the lock again before returning.  Failure to take the lock leads
to a double unlock in the caller, hwdep_read().

Fixes: acdebd8b4c ("ALSA: fireface: implement message parser for Fireface 400")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/Y8at+W/7OGvEBY8O@kili
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-18 17:49:48 +01:00
Takashi Sakamoto acdebd8b4c ALSA: fireface: implement message parser for Fireface 400
This commit implements message parser for Fireface 400 to pass data of
knob control to user space. The parser has FIFO which can store maximum
32 events without no overrun detection since it doesn't matter to lose
the event.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230112120954.500692-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-13 09:56:39 +01:00
Takashi Sakamoto c31909fa06 ALSA: fireface: add local framework to message parser
This commit adds local framework to message parser. This is preparation
for future work to pass event of knob control for Fireface 400 to user
space.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230112120954.500692-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-13 09:56:37 +01:00
Takashi Sakamoto aed713bfae ALSA: fireface: add helper function to parse MIDI messages transmitted by Fireface 400
This is minor code refactoring to add helper function to parse MIDI message
bytes in quadlet message.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230112120954.500692-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-13 09:56:36 +01:00
Takashi Sakamoto 4bdcb8d28f ALSA: fireface: pick up time stamp for request subaction of asynchronous transaction
The time stamp of isochronous cycle at which asynchronous transaction is
sent is perhaps useful somehow. A commit b2405aa948 ("firewire: add
kernel API to access packet structure in request structure for AR context")
adds kernel API to retrieve the time stamp in inner structure of request
subaction.

This commit changes local framework to handle message delivered by the
asynchronous transaction so that time stamp is picked up by the kernel API.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230112120954.500692-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-13 09:56:35 +01:00
Takashi Sakamoto 50c597c77c ALSA: fireface: rename callback functions
It's cleared that Fireface 400 transmits quadlet message for two purposes
at least; received MIDI messages and notification of knob control
operation. Nevertheless current implementation uses callback function name
just for MIDI messages.

This commit renames the callback functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230112120954.500692-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-13 09:56:33 +01:00
Takashi Sakamoto 7fc693e474 ALSA: firewire-lib: obsolete return value from context payload processing layer
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-12 12:14:50 +01:00
Takashi Sakamoto a36183f69c ALSA: firewire-lib: move parameter for pcm frame multiplier from context 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-12 12:14:49 +01:00
Takashi Sakamoto 0cac60c776 ALSA: firewire-lib: use circular linked list for context payload processing 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-09 17:04:44 +01:00
Takashi Iwai 23cb0767f0 ALSA: firewire: Replace runtime->status->state reference to runtime->state
The recent change in ALSA core allows drivers to get the current PCM
state directly from runtime object.  Replace the calls accordingly.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220926135558.26580-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-09-27 08:47:25 +02:00
Christophe JAILLET 1dd0dd0b1f ALSA: firewire: Remove some left-over license text in sound/firewire
There is already a SPDX-License-Identifier tag, so the corresponding license
text can be removed.

While at it, be more consistent and:
  - add a missing .c (ff-protocol-latter)
  - remove an empty line (motu-protocol-v1)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/2bfe76c7eeb0f5205a1427e280bf8d9da0354a62.1664110649.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-09-27 08:42:18 +02:00
Takashi Sakamoto ee5f0b32ce ALSA: fireface: cease from delayed card registration
The delayed registration of sound card instance brings less benefit than
complication of kobject management. This commit ceases from it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210607081250.13397-9-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-07 17:14:48 +02:00
Takashi Sakamoto dfacca3986 ALSA: fireface: perform sequence replay for media clock recovery
This commit takes ALSA fireface driver to perform sequence replay for
media clock recovery.

The protocol specific to RME Fireface series is not compliant to
IEC 61883-1/6 since it has no CIP header, therefore presentation time
is not used for media clock recovery. The sequence of the number of data
blocks per packet is important.

I note that the device skips an isochronous cycle corresponding to an
empty packet or a NODATA packet in blocking transmission method of
IEC 61883-1/6. For sequence replay, the cycle is handled as receiving an
empty packet. Furthermore, it doesn't start packet transmission till
receiving any packet.

The sequence replay is tested with below models:

* Fireface 400
* Fireface 800
* Fireface 802

I note that it is better to initialize Fireface 400 in advance by
initialization transaction implemented in snd-fireface-ctl-service of
snd-firewire-ctl-services project. You can see whether initialized or
not by HOST LED on the device. Unless, the device often stops packet
transmission even if session starts.

I guess the sequence replay also works well with below models:

* Fireface UFX
* Fireface UCX

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-01 08:19:51 +02:00
Takashi Sakamoto 2f21a17763 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>
2021-05-28 11:06:33 +02:00
Takashi Sakamoto f9e5ecdfc2 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>
2021-05-28 10:44:01 +02:00
Takashi Sakamoto bdaedca74d 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>
2021-05-20 14:01:17 +02:00
Takashi Sakamoto c50bfc8a68 ALSA: fireface: fix to parse sync status register of latter protocol
Fireface UCX, UFX, and FF802 are categorized for latter protocol of the
series. Current support for FF802 (and UFX) includes failure to parse
sync status register and results in EIO.

Further investigation figures out that the content of register differs
depending on models. This commit adds tables specific to FF802 and UFX
to fix it.

Fixes: 062bb452b0 ("ALSA: fireface: add support for RME FireFace 802")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210207154736.229551-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-02-08 15:58:36 +01:00
Dan Carpenter f4514249d6 ALSA: fireface: remove unnecessary condition in hwdep_read()
Smatch complains that "count" is not clamped when "ff->dev_lock_changed"
and it leads to an information leak.  Fortunately, that's not actually
possible and the condition can be deleted.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/YA6n6I8EcNAO5ZFs@mwanda
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-25 14:50:36 +01:00
Takashi Iwai c09e28cd12 Merge branch 'for-linus' into for-next
Back-merge of 5.11 devel branch for more works on USB-audio.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-18 17:39:23 +01:00
Geert Uytterhoeven e7c22eeaff ALSA: fireface: Fix integer overflow in transmit_midi_msg()
As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 1000000000L,
the second multiplication in

    ff->rx_bytes[port] * 8 * NSEC_PER_SEC / 31250

always overflows on 32-bit platforms, truncating the result.  Fix this
by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.

Note that this assumes ff->rx_bytes[port] <= 16777.

Fixes: 1917429578 ("ALSA: fireface: add transaction support")
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20210111130251.361335-2-geert+renesas@glider.be
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-12 14:57:29 +01:00
Joe Perches 75b1a8f9d6 ALSA: Convert strlcpy to strscpy when return value is unused
strlcpy is deprecated.  see: Documentation/process/deprecated.rst

Change the calls that do not use the strlcpy return value to the
preferred strscpy.

Done with cocci script:

@@
expression e1, e2, e3;
@@

-	strlcpy(
+	strscpy(
	e1, e2, e3);

This cocci script leaves the instances where the return value is
used unchanged.

After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.

$ git grep -w strlcpy sound/
sound/usb/card.c:               len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c:      return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c:                      return strlcpy(buf, p->names[index], buflen);

Miscellenea:

o Remove trailing whitespace in conversion of sound/core/hwdep.c

Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-08 09:30:05 +01:00
Takashi Sakamoto 1f65e66832 ALSA: fireface: add support for RME Fireface UFX (untested)
Fireface UFX was shipped by RME GmbH in 2010, and now discontinued.
Although this model has some enhanced feature which Fireface 802
doesn't have (e.g. on-board USB mass storage device class, configuration
interface with color display), the functionality relevant to
packet communication on IEEE 1394 bus seems to be the same as
Fireface 802 (e.g. available number of channels for PCM frame in
each sampling transfer frequency).

With the assumption, this commit adds support for Fireface UFX. In ALSA
fireface driver, these two models are handled as the same one.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:50 +02:00
Takashi Sakamoto 062bb452b0 ALSA: fireface: add support for RME FireFace 802
Fireface 802 was shipped by RME GmbH in 2014. This model supports later
protocol for management of isochronous communication and synchronization
of sampling transmission frequency.

This model consists of below ICs:
 * TI TSB41AB2
 * Xilinx Spartan-6 FPGA XC6SLX16
 * TI TMS320 C6747
 * SMSC USB3250

Especially, this model just supports IEEE 1394a, against its name which
evokes Fireface 800.

This commit adds support for Fireface 802 (tested). Userspace applications
can transfer PCM frames and MIDI messages via ALSA PCM/Rawmidi interface.
I note that 4 channels for ADAt1 and ADAT2 are disabled at higher sampling
transfer frequency since isochronous resources reservation fails due to
bandwidth limitation of IEEE 1394a.

The value read from LATTER_SYNC_STATUS register is slightly different
from the one of Fireface UCX. The higher 4 bits and lower 4 bits are
swapped within the same byte.

Without any assist of userspace application, transmitted MIDI messages
from the device are not going to be processed. For detail, please refer
to my comment in code of latter protocol.

$ python crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  0404ffff  bus_info_length 4, crc_length 4, crc 65535 (should be 26805)
404  31333934  bus_name "1394"
408  20008000  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 8 (512)
40c  000a3504  company_id 000a35     |
410  38077423  device_id 0438077423  | EUI-64 000a350438077423

               root directory
               -----------------------------------------------------------------
414  0005ffff  directory_length 5, crc 65535 (should be 9514)
418  0c0083c0  node capabilities per IEEE 1394
41c  03000a35  vendor
420  8100000b  --> descriptor leaf at 44c
424  8d000007  --> eui-64 leaf at 440
428  d1000001  --> unit directory at 42c

               unit directory at 42c
               -----------------------------------------------------------------
42c  0004ffff  directory_length 4, crc 65535 (should be 45134)
430  12000a35  specifier id
434  13000005  version
438  17101800  model
43c  81000008  --> descriptor leaf at 45c

               eui-64 leaf at 440
               -----------------------------------------------------------------
440  0002ffff  leaf_length 2, crc 65535 (should be 60131)
444  000a3504  company_id 000a35     |
448  38077423  device_id 0438077423  | EUI-64 000a350438077423

               descriptor leaf at 44c
               -----------------------------------------------------------------
44c  0003ffff  leaf_length 3, crc 65535 (should be 469)
450  00000000  textual descriptor
454  00000000  minimal ASCII
458  524d4521  "RME!"

               descriptor leaf at 45c
               -----------------------------------------------------------------
45c  0005ffff  leaf_length 5, crc 65535 (should be 10561)
460  00000000  textual descriptor
464  00000000  minimal ASCII
468  46697265  "Fire"
46c  66616365  "face"
470  20383032  " 802"

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:49 +02:00
Takashi Sakamoto 782222bab8 ALSA: fireface: code refactoring to decide name of sound card
This commit uses enumeration constants as index of table for the
list of name of sound card.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:49 +02:00
Takashi Sakamoto c52f232e11 ALSA: fireface: code refactoring to add enumeration constants for model identification
In RME fireface series, version field of unit directory in configuration
ROM is used to distinguish each model. The value of field is known and
it's better to use enumeration constants for code representation.

This commit adds enumeration constants for model identification.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:48 +02:00
Takashi Sakamoto f4588cc425 ALSA: fireface: start IR context immediately
In the latter models of RME Fireface series, device start to transfer
packets several dozens of milliseconds. On the other hand, ALSA fireface
driver starts IR context 2 milliseconds after the start. This results
in loss to handle incoming packets on the context.

This commit changes to start IR context immediately instead of
postponement. For Fireface 800, this affects nothing because the device
transfer packets 100 milliseconds or so after the start and this is
within wait timeout.

Cc: <stable@vger.kernel.org>
Fixes: acfedcbe1c ("ALSA: firewire-lib: postpone to start IR context")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:47 +02:00
Takashi Sakamoto bbd6aac3ae ALSA: fireface: fix configuration error for nominal sampling transfer frequency
128000 and 192000 are congruence modulo 32000, thus it's wrong to
distinguish them as multiple of 32000 and 48000 by modulo 32000 at
first.

Additionally, used condition statement to detect quadruple speed can
cause missing bit flag.

Furthermore, counter to ensure the configuration is wrong and it
causes false positive.

This commit fixes the above three bugs.

Cc: <stable@vger.kernel.org>
Fixes: 60aec494b3 ("ALSA: fireface: support allocate_resources operation in latter protocol")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-10 12:03:47 +02:00
Takashi Sakamoto 9c0d16ac05 ALSA: firewire: use KBUILD_MODNAME for struct driver.name instead of string
KBUILD_MODNAME is available to name kernel modules according to its object
name. This commit uses the macro instead of string for name field of
struct driver since drivers in ALSA firewire stack have the same name of
each object name.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200306135229.11659-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-03-06 15:54:03 +01:00
Takashi Iwai d45b3aaea2 ALSA: firewire: Drop superfluous ioctl PCM ops
All the PCM ioctl ops of ALSA FireWire drivers do nothing but calling
the default handler.

Now PCM core accepts NULL as the default ioctl ops(*), so let's drop
altogether.

(*) commit fc033cbf6f ("ALSA: pcm: Allow NULL ioctl ops")

Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191210061145.24641-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-11 07:25:27 +01:00
Takashi Iwai 7641d549b1 ALSA: firewire: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.

Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191209192422.23902-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-11 07:24:59 +01:00
Takashi Sakamoto 480136343c ALSA: fireface: fix return value in error path of isochronous resources reservation
Even if isochronous resources reservation fails, error code doesn't return
in pcm.hw_params callback.

Cc: <stable@vger.kernel.org> #5.3+
Fixes: 55162d2bb0 ("ALSA: fireface: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191209151655.GA8090@workstation
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-09 20:06:18 +01:00
Takashi Iwai a3f4f2d5d0 ALSA: firewire: Convert to the common vmalloc memalloc
The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Link: https://lore.kernel.org/r/20191105151856.10785-11-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-06 15:47:42 +01:00
Takashi Sakamoto acfedcbe1c 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>
2019-10-19 09:18:27 +02:00
Takashi Sakamoto e6dcc92fce ALSA: firewire-lib: replace ack callback to flush isoc contexts in AMDTP domain
An isoc context for AMDTP stream is flushed to queue packet
by a call of pcm.ack. This commit extends this for AMDTP
domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191018061911.24909-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-10-19 09:18:22 +02:00
Takashi Sakamoto f890f9a04b ALSA: firewire-lib: replace pointer callback to flush isoc contexts in AMDTP domain
An isoc context for AMDTP stream is flushed to queue packet
by a call of pcm.pointer. This commit extends this for AMDTP
domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191018061911.24909-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-10-19 09:18:20 +02:00
Takashi Sakamoto 4de3eb062e ALSA: fireface: share PCM buffer size for both direction
This commit allows ALSA fireface 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-10-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-10-18 04:35:52 +02:00
Takashi Sakamoto a0e023317e 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>
2019-10-18 04:35:40 +02:00
Takashi Sakamoto 3aac326341 ALSA: fireface: use the same size of period for PCM substreams in AMDTP streams
In current implementation, when opening a PCM substream, it's needed to
check whether the opposite PCM substream runs. This is to assign
effectual constraints (e.g. sampling rate) to opened PCM substream.

The number of PCM substreams on AMDTP streams in domain is recorded in
own structure. Usage of this count is an alternative of the above check.
This is better because the count is incremented in pcm.hw_params earlier
than pcm.trigger.

This commit replaces the check with the substream count and the value for
the size of PCM period. Unlike the other drivers in ALSA firewire stack,
no MIDI substream is multiplexed into AMDTP stream.

I note that Fireface AMDTP protocol has a quirk that tx stream includes
blank isochronous cycle. The packet for blank cycle is equivalent to
empty or NODATA packet in IEC 61883-6, thus the protocol is similar to
blocking transmission method of IEC 61883-6. On the other hand, rx
stream adopts non-blocking transmission method. Although the difference
of transmission method between tx/rx streams precisely brings different
timing for a certain amount of events due to their different calculation
for data blocks per packet, it's possible to approximate enough amount
of events mostly has the same timing. Actually current ALSA IEC 61883-1/6
engine uses large amount of data blocks for each hardware IRQ
(=16 packets).

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191007110532.30270-18-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-10-17 12:02:47 +02:00
Takashi Sakamoto 9d9ff58c2f ALSA: fireface: 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-10-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-10-17 12:02:43 +02:00
Takashi Sakamoto c9a9ce899c ALSA: fireface: support AMDTP domain
This commit adds AMDTP domain support for ALSA fireface driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-05 19:57:28 +02:00
Takashi Sakamoto 42355abb9c ALSA: fireface: code refactoring for initialization/destruction of AMDTP stream
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>
2019-08-05 19:57:22 +02:00
Takashi Sakamoto 9a738ad1b1 ALSA: firewire-lib: process payload of isoc context according to packet descriptors
This commit changes each of data block processing layer so that it
receives list of packet descriptor.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-22 16:05:11 +02:00
Takashi Sakamoto 4731c672c9 ALSA: fireface: code refactoring for FF data block processing layer
This is code refactoring for FF data block processing layer so that
it can receive list of packet descriptor.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-22 16:05:10 +02:00
Takashi Sakamoto d2c104a342 ALSA: firewire-lib: pass packet descriptor to data block processing layer
This commit changes signature of callback function to call data block
processing layer with packet descriptor. At present, the layer is called
per packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-22 16:05:06 +02:00
Takashi Sakamoto 600c8018df ALSA: firewire-lib: pass no syt information to data block processing layer
In a previous commit, the variable passed from packet streaming layer
for syt variable is useless. This commit obsoletes it.

In my future work, the syt information is passed to data block processing
layer by another way.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-22 16:05:01 +02:00
Takashi Sakamoto ab75481202 ALSA: firewire-lib: pass data block counter to data block processing layer
This is a preparation for future commit that 'struct
amdtp_stream.data_block_count' does not represent the value of
data block count for current data block.

However, data block count is required for calculation of sequence index
in sequence-multiplied data channel. Some of data block processing layer
require it; e.g. for AM824 data block.

This commit passes data block count to the processing layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-22 16:04:57 +02:00
Takashi Iwai 3c53c6255d ASoC: Updates for v5.3
This is a very big update, mainly thanks to Morimoto-san's refactoring
 work and some fairly large new drivers.
 
  - Lots more work on moving towards a component based framework from
    Morimoto-san.
  - Support for force disconnecting muxes from Jerome Brunet.
  - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant
    CX2072X, Realtek RT1011 and RT1308.
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl0jGwUTHGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0LD4B/9AkutfS+vznOrk0V0wFb2SUfjwE4Pr
 +z/kAehohAOl/7pg9Dun/lmZYBWMyOM2aYmK81ahEo2DfO+uzwkwjCaXFjGVGwEK
 j7XpWkrIjKnou/z1FeALgVvt+crzdy5iNWC04AbKaP2WHCcI7zvPQIsBta/V0OJt
 lg+j0J7pagnTMcgV1+qJdaASmofy/hpoZ79Gv0PIfGC8hpJ/3mBgcNPCLQrJtD4R
 v+tzvCZNrZVqCanwLf3vouEm1bpWYOpI+Wdmu4u6rY7MhmCj72EJ2zyfdm/qtaxF
 e7whgCyOQFkWe7NgDn0G08aAT6LsaxOtPNr7H8tL8S8sw8425fqeOouV
 =n/HQ
 -----END PGP SIGNATURE-----

Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Updates for v5.3

This is a very big update, mainly thanks to Morimoto-san's refactoring
work and some fairly large new drivers.

 - Lots more work on moving towards a component based framework from
   Morimoto-san.
 - Support for force disconnecting muxes from Jerome Brunet.
 - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant
   CX2072X, Realtek RT1011 and RT1308.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-08 14:45:34 +02:00