Takashi Sakamoto [Mon, 7 Jun 2021 08:12:43 +0000 (17:12 +0900)]
ALSA: fireworks: 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-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 7 Jun 2021 08:12:42 +0000 (17:12 +0900)]
ALSA: bebob: 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-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 6 Jun 2021 04:34:09 +0000 (13:34 +0900)]
ALSA: firewire-motu: add support for hybrid model of MOTU Ultralite mk3
This commit adds support for the hybrid model of MOTU Ultralite mk3 with
alpha connector, which is already discontinued. The hardware specification
of the model is the same as the one of FireWire-only model.
$ cd linux-firewire-utils
$ python3 src/crpp < /sys/bus/firewire/devices/fw1/config_rom
ROM header and bus information block
-----------------------------------------------------------------
400
04101573 bus_info_length 4, crc_length 16, crc 5491
404
31333934 bus_name "1394"
408
20ff7000 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 255, max_rec 7 (256)
40c
0001f200 company_id 0001f2 |
410
000a059c device_id
00000a059c | EUI-64
0001f200000a059c
root directory
-----------------------------------------------------------------
414
0004ef04 directory_length 4, crc 61188
418
030001f2 vendor
41c
0c0083c0 node capabilities per IEEE 1394
420
d1000002 --> unit directory at 428
424
8d000005 --> eui-64 leaf at 438
unit directory at 428
-----------------------------------------------------------------
428
0003f00b directory_length 3, crc 61451
42c
120001f2 specifier id
430
13000030 version
434
17103800 model
eui-64 leaf at 438
-----------------------------------------------------------------
438
0002d89c leaf_length 2, crc 55452
43c
0001f200 company_id 0001f2 |
440
000a059c device_id
00000a059c | EUI-64
0001f200000a059c
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210606043409.40019-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sun, 6 Jun 2021 02:56:51 +0000 (11:56 +0900)]
ALSA: firewire-lib: remove useless operations for kernel preemption
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>
Dan Carpenter [Sat, 5 Jun 2021 12:46:39 +0000 (15:46 +0300)]
ALSA: firewire-lib: fix error codes for allocation failure
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>
Werner Sembach [Fri, 4 Jun 2021 14:02:07 +0000 (16:02 +0200)]
ALSA: hda/realtek: Change device names for quirks to barebone names
Change the name string of several devices needing quirks to the Clevo-barebone
ones. Also make the names follow the same pattern for multiple Clevo names
referring to the same mainboard.
Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
Link: https://lore.kernel.org/r/20210604140207.8023-1-wse@tuxedocomputers.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Yang Yingliang [Thu, 3 Jun 2021 14:32:03 +0000 (22:32 +0800)]
ALSA: firewire-motu: fix error return code in snd_motu_stream_reserve_duplex()
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.
Fixes:
e50dfac81f73 ("ALSA: firewire-motu: cache event ticks in source packet header per data block")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210603143203.582017-1-yangyingliang@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 1 Jun 2021 16:24:57 +0000 (18:24 +0200)]
ALSA: usb-audio: Reduce latency at playback start
USB-audio driver behaves a bit strangely for the playback stream --
namely, it starts sending silent packets at PCM prepare state while
the actual data is submitted at first when the trigger START is kicked
off. This is a workaround for the behavior where URBs are processed
too quickly at the beginning. That is, if we start submitting URBs at
trigger START, the first few URBs will be immediately completed, and
this would result in the immediate period-elapsed calls right after
the start, which may confuse applications.
OTOH, submitting the data after silent URBs would, of course, result
in a certain delay of the actual data processing, and this is rather
more serious problem on modern systems, in practice.
This patch tries to revert the workaround and lets the URB submission
starting at PCM trigger for the playback again. As far as I've tested
with various backends (native ALSA, PA, JACK, PW), I haven't seen any
problems (famous last words :)
Note that the capture stream handling needs no such workaround, since
the capture is driven per received URB.
Link: https://lore.kernel.org/r/20210601162457.4877-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 1 Jun 2021 16:24:56 +0000 (18:24 +0200)]
ALSA: usb-audio: Factor out DSD bitrev copy function
Just minor code refactoring. Like DOP DSD code, it can be better in a
separate function for code readability.
Link: https://lore.kernel.org/r/20210601162457.4877-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 1 Jun 2021 16:24:55 +0000 (18:24 +0200)]
ALSA: usb-audio: Refactoring delay account code
The PCM delay accounting in USB-audio driver is a bit complex to
follow, and this is an attempt to improve the readability and provide
some potential fix.
Basically, the PCM position delay is calculated from two factors: the
in-flight data on URBs and the USB frame counter. For the playback
stream, we advance the hwptr already at submitting URBs. Those
"in-flight" data amount is now tracked, and this is used as the base
value for the PCM delay correction. The in-flight data is decreased
again at URB completion in return. For the capture stream, OTOH,
there is no in-flight data, hence the delay base is zero.
The USB frame counter is used in addition for correcting the current
position. The reference frame counter is updated at each submission
and receiving time, and the difference from the current counter value
is taken into account.
In this patch, each in-flight data bytes is recorded in the new
snd_usb_ctx.queued field, and the total in-flight amount is tracked in
snd_usb_substream.inflight_bytes field, as the replacement of
last_delay field.
Note that updating the hwptr after URB completion doesn't work for
PulseAudio who tries to scratch the buffer on the fly; USB-audio is
basically a double-buffer implementation, hence the scratching the
buffer can't work for the already submitted data. So we always update
hwptr beforehand. It's not ideal, but the delay account should give
enough correctness.
Link: https://lore.kernel.org/r/20210601162457.4877-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 1 Jun 2021 16:24:54 +0000 (18:24 +0200)]
ALSA: usb-audio: Pre-calculate buffer byte size
There are a bunch of lines calculating the buffer size in bytes at
each time. Keep the value in subs->buffer_bytes and use it
consistently for the code simplicity.
Link: https://lore.kernel.org/r/20210601162457.4877-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 1 Jun 2021 16:24:53 +0000 (18:24 +0200)]
ALSA: usb-audio: Make snd_usb_pcm_delay() static
It's a local function, let's make it static.
Link: https://lore.kernel.org/r/20210601162457.4877-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 Jun 2021 01:34:06 +0000 (10:34 +0900)]
ALSA: firewire-motu: sequence replay for source packet header
This commit takes ALSA firewire-motu driver to perform sequence replay for
media clock recovery.
Unlike the other types of device, the devices in MOTU FireWire series
require two levels of sequence replay; the sequence of the number of
data blocks per packet and the sequence of source packet header per data
block. The former is already cached by ALSA IEC 61883-1/6 packet streaming
engine and ready to be replayed. The latter is also cached by ALSA
firewire-motu driver itself with a previous patch. This commit takes
the driver to replay both of them from the caches.
The sequence replay is tested with below models:
* 828 mkII
* Traveler
* UltraLite
* 828 mk3 FireWire
* 828 mk3 Hybrid (except for high sampling transfer frequency
* UltraLite mk3 FireWire
* 4pre
* AudioExpress
Unfortunately, below models still don't generate better sound, requires
more work:
* 8pre
* 828 mk3 Hybrid at high sampling transfer frequency
As long as I know, MOTU protocol version 1 requires extra care of the
format of data block, thus below models are not supported yet in this
time:
* 828
* 896
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210602013406.26442-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 Jun 2021 01:34:05 +0000 (10:34 +0900)]
ALSA: firewire-motu: cache event ticks in source packet header per data block
The devices in MOTU FireWire series put source packet header (SPH) into
each data block of tx packet for presentation time of event. The format
of timestamp is compliant to IEC 61883-1, with cycle and offset fields
without sec field of 32 bit cycle time.
This commit takes ALSA firewire-motu driver to cache the presentation
time as offset from cycle in which the packet is transferred.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210602013406.26442-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Wed, 2 Jun 2021 01:34:04 +0000 (10:34 +0900)]
ALSA: firewire-motu: use macro for magic numbers relevant to IEC 61883-1
ALSA firewire-motu driver has some magic numbers from IEC 61883-1 to
operates source packet header (SPH). This commit replaces them with
macros.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210602013406.26442-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 1 Jun 2021 08:17:53 +0000 (17:17 +0900)]
ALSA: bebob: perform sequence replay for media clock recovery
This commit takes ALSA bebob driver to perform sequence replay for media
clock recovery.
Many users have reported discontinuity of data block counter field of CIP
header in tx packet from the devices based on BeBoB ASICs. In the worst
case, the device corrupts not to respond to any transaction, then generate
bus-reset voluntarily for recovery. The sequence replay for media clock
recovery is expected to suppress most of the problems.
In the beginning of packet streaming, the device transfers NODATA packets
for a while, then multiplexes any event and syt information. ALSA
IEC 61883-1/6 packet streaming engine has implementation for it to drop
the initial NODATA packets. It starts sequence replay when detecting any
event multiplexed to tx packets.
The sequence replay is tested with below models:
* Focusrite Saffire
* Focusrite Saffire LE
* Focusrite Saffire Pro 10 I/O
* Focusrite Saffire Pro 26 I/O
* M-Audio FireWire Solo
* M-Audio FireWire Audiophile
* M-Audio Ozonic
* M-Audio FireWire 410
* M-Audio FireWire 1814
* Edirol FA-66
* ESI Quatafire 610
* Apogee Ensemble
* Phonic Firefly 202
* Behringer F-Control Audio 610
Unfortunately, below models doesn't generate sound. This seems regression
introduced recent few years:
* Stanton Final Scratch ScratchAmp at middle sampling transfer frequency
* Yamaha GO44
* Yamaha GO46
* Terratec Phase x24
As I reported, below model has quirk of discontinuity:
* M-Audio ProFire Lightbridge
DM1000/DM1100 ASICs in BeBoB solution are known to have bugs at switch of
sampling transfer frequency between low/middle/high rates. The switch
generates the similar problems about which I mention in the above. Some
vendors customizes firmware so that the switch of frequency is done in
vendor-specific registers, then restrict users to switch the frequency.
For example of Focusrite Saffire Pro 10 i/o and 26 i/o, users allows to
switch the frequency within the three steps; e.g. 44.1/48.0 kHz are
available at low step. Between the steps, extra operation is required and
it always generates bus-reset.
Another example of Edirol FA-66, users are prohibited to switch the
frequency by software. It's done by hardware switch and power-off.
I note that the sequence replay is not a solution for the ASIC bugs. Users
need to disconnect the device corrupted by the bug, then reconnect it to
refresh state machine inner the ASIC.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210601081753.9191-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 1 Jun 2021 08:17:52 +0000 (17:17 +0900)]
ALSA: dice: perform sequence replay for media clock recovery
This commit takes ALSA dice driver to perform sequence replay for media
clock recovery.
Unlike the other types of device, DICE-based devices interpret the value
of syt field of CIP header in rx packets as presentation time for audio
playback, thus it's required for driver to compute value for outgoing
packet adequate to the device. It's done by media clock recovery by
handling tx packets.
The device starts packet transmission immediately at operation to
GLOBAL_ENABLE thus on-the-fly mode is not required.
DICE ASICs supports several pairs of isochronous packet streams.
Actually, maximum two pairs of streams are supported by devices.
We have three cases regarding to the number of streams:
1. a pair of streams
2. two tx packet streams and one rx packet streams
3. one tx packet streams and two rx packet streams
4. two pair of streams
The decision of playback timing is slightly different in the four cases.
In the case 1, sequence replay in the pair results in suitable playback
timing.
In the case 2, sequence replay from the first tx packet stream to rx
packet stream results in suitable playback timing.
In the case 3, sequence replay from tx packet stream to all of rx packet
stream results in suitable playback timing. Furthermore, the cycle to
start receiving packets should be the same between all rx packet streams.
In the case 4, sequence replay in each pair results in suitable playback
timing. Furthermore, the cycle to start receiving packets should be the
same between all rx packet streams.
The sequence replay is tested with below models:
* For case 1:
* TC Electronic Konnekt 24d (DiceII)
* TC Electronic Konnekt 8 (DiceII)
* TC Electronic Konnekt Live (DiceII)
* TC Electronic Impact Twin (DiceII)
* TC Electronic Digital Konnekt X32 (DiceII)
* TC Electronic Desktop Konnekt 6 (TCD2220)
* Solid State Logic Duende Classic (DiceII)
* Solid State Logic Duende Mini (DiceII)
* PreSonus FireStudio Project (TCD2210)
* PreSonus FireStudio Mobile (TCD2210)
* Lexicon I-ONIX FW810s (TCD2220)
* Avid Mbox 3 Pro (TCD2220)
* For case 2 (but case 1 depends on sampling transfer frequency):
* Alesis iO 26 (DiceII)
* Alesis iO 14 (DiceII)
* Alesis MultiMix 12 FireWire (DiceII)
* Focusrite Saffire Pro 26 (TCD2220)
* For case 3 (but case 1 depends on sampling transfer frequency):
* M-Audio Profire 610 (TCD2220)
* Loud Technology Mackie Onyx Blackbird (TCD2210)
* For case 4:
* TC Electronic Studio Konnekt 48 (DiceII + TCD2220)
* PreSonus FireStudio (DiceII)
* M-Audio Profire 2626 (TCD2220)
* Focusrite Liquid Saffire 56 (TCD2220)
* Focusrite Saffire Pro 40 (TCD2220)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210601081753.9191-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 1 Jun 2021 08:17:51 +0000 (17:17 +0900)]
ALSA: dice: wait just for NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation
NOTIFY_CLOCK_ACCEPTED notification is always generated as a result of
GLOBAL_CLOCK_SELECT operation, however NOTIFY_LOCK_CHG notification
doesn't, as long as the selected clock is already configured. In the case,
ALSA dice driver waits so long. It's inconvenient for some devices to lock
to the sequence of value in syt field of CIP header in rx packets.
This commit wait just for NOTIFY_CLOCK_ACCEPTED notification by reverting
changes partially done by two commits below:
* commit
fbeac84dbe9e ("ALSA: dice: old firmware optimization for Dice notification")
* commit
aec045b80d79 ("ALSA: dice: change notification mask to detect lock status change")
I note that the successful lock to the sequence of value in syt field of
CIP header in rx packets results in NOTIFY_EXT_STATUS notification, then
EXT_STATUS_ARX1_LOCKED bit stands in GLOBAL_EXTENDED_STATUS register.
The notification can occur enough after receiving the batch of rx packets.
When the sequence doesn't include value in syt field of CIP header in rx
packets adequate to the device, the notification occurs again and the bit
is off.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210601081753.9191-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 31 May 2021 02:51:03 +0000 (11:51 +0900)]
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>
Takashi Sakamoto [Mon, 31 May 2021 02:51:02 +0000 (11:51 +0900)]
ALSA: firewire-tascam: perform sequence replay for media clock recovery
This commit takes ALSA firewire-tascam driver to perform sequence replay
for media clock recovery.
The protocol specific to Tascam FireWire series is not compliant to
IEC 61883-1/6 in terms of syt field of CIP. The protocol doesn't use
presentation time in received CIP for playback timing. The sequence of
the number of data blocks per packet is important for media clock
recovery.
Although the devices in Tascam FireWire series transfer packets
regardless of receiving packets, the tx packets includes no events
in the beginning of streaming. It takes so long to multiplex any event
into the packet after receiving the sequence of packets. As long as I
experienced, it takes several thousands of isochronous cycle. Furthermore,
just after changing sampling transmission frequency, it stops multiplexing
event at once, then starts multiplexing again.
The sequence replay is tested with below models:
* FW-1884
* FW-1804
* FW-1082
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 31 May 2021 02:51:01 +0000 (11:51 +0900)]
ALSA: firewire-digi00x: perform sequence replay for media clock recovery
This commit takes ALSA firewire-digi00x driver to perform sequence replay
for media clock recovery.
All of models in Digidesign digi00x family don't transfer isochronous
packets till receiving isochronous packets. The on-the-fly mode is used
for the purpose. They don't interpret presentation time expressed in syt
field of received CIP, therefore the sequence of the number of data blocks
per packet is important for media clock recovery.
The sequence replay is tested with below models:
* Digidesign Digi 002
* Digidesign Digi 002 Rack
* Digidesign Digi 003
* Digidesign Digi 003 Rack
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 31 May 2021 02:51:00 +0000 (11:51 +0900)]
ALSA: oxfw: perform sequence replay for media clock recovery
This commit takes ALSA oxfw driver to perform sequence replay for media
clock recovery. Unfortunately, OXFW970 ASIC and its firmware has a quirk
called jumbo payload which skips several isochronous cycles for packet
transmission, thus the sequence replay is just adopted to OXFW971 ASIC.
As well as Fireworks, OXFW ASICs also ignores presentation time against
the way in IEC 61883-1/6.
The sequence replay is tested with below models:
* Tascam FireOne
* Stanton Magnetics SCS.1m
* Apogee Duet FireWire
For below models, the sequence replay is tested to be disabled:
* Griffin FireWave
* Behringer F-Control Audio 202
* Loud Technology Tapco Link.FireWire 4x6
* Loud Technology Mackie Onyx Satellite
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 31 May 2021 02:50:59 +0000 (11:50 +0900)]
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>
Takashi Sakamoto [Mon, 31 May 2021 02:50:58 +0000 (11:50 +0900)]
ALSA: fireworks: delete SYTMATCH clock source
In the design of Fireworks board module, the device does't adjust its
media clock voluntarily by the sequence of presentation time expressed in
syt field of CIP header of received packet.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Shaokun Zhang [Sat, 29 May 2021 09:02:06 +0000 (17:02 +0800)]
ALSA: usb-audio: Remove the repeated declaration
Function 'snd_usb_endpoint_suspend' is declared twice, so remove the
repeated declaration.
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
Link: https://lore.kernel.org/r/1622278926-63857-1-git-send-email-zhangshaokun@hisilicon.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
YueHaibing [Wed, 26 May 2021 12:18:28 +0000 (20:18 +0800)]
ALSA: core: use DEVICE_ATTR_*() macro
Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20210526121828.8460-1-yuehaibing@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Thu, 27 May 2021 12:32:53 +0000 (21:32 +0900)]
ALSA: firewire-lib: support NO_PERIOD_WAKEUP in ALSA PCM runtime
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>
Takashi Sakamoto [Thu, 27 May 2021 12:26:11 +0000 (21:26 +0900)]
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>
Takashi Sakamoto [Thu, 27 May 2021 12:26:10 +0000 (21:26 +0900)]
ALSA: firewire-lib: replay sequence of incoming packets for outgoing packets
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>
Takashi Sakamoto [Thu, 27 May 2021 12:26:09 +0000 (21:26 +0900)]
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>
Colin Ian King [Wed, 26 May 2021 16:06:16 +0000 (17:06 +0100)]
ALSA: hda/ca0132: Make a const array static, makes object smaller
Don't populate the const array dsp_dma_stream_ids the stack but instead
make it static. Makes the object code smaller by 21 bytes.
Before:
text data bss dec hex filename
189012 70376 192 259580 3f5fc ./sound/pci/hda/patch_ca0132.o
After:
text data bss dec hex filename
188927 70440 192 259559 3f5e7 ./sound/pci/hda/patch_ca0132.o
(gcc version 10.3.0)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210526160616.3764119-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pierre-Louis Bossart [Wed, 26 May 2021 19:29:57 +0000 (14:29 -0500)]
ALSA: pci: lx6464es: remove useless self-comparison
Sparse throws the following warning:
sound/pci/lx6464es/lx_core.c:677:34: error: self-comparison always
evaluates to false
This comparison and error message make no sense, let's remove them.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210526192957.449515-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pierre-Louis Bossart [Wed, 26 May 2021 19:29:56 +0000 (14:29 -0500)]
ALSA: drivers: opl3: fix useless self-comparison
Sparse throws the following warning:
sound/drivers/opl3/opl3_midi.c:183:60: error: self-comparison always
evaluates to false
This is likely a 16+ year old confusion between vp2 and vp.
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210526192957.449515-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
zuoqilin [Thu, 27 May 2021 03:04:45 +0000 (11:04 +0800)]
sound/oss/dmasound: Remove superfluous "break"
Remove superfluous "break", as there is a "return" before them.
Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Link: https://lore.kernel.org/r/20210527030445.1201-1-zuoqilin1@163.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
YueHaibing [Sun, 23 May 2021 07:11:09 +0000 (15:11 +0800)]
ALSA: control_led - use DEVICE_ATTR_*() macro
Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210523071109.28940-1-yuehaibing@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
YueHaibing [Mon, 24 May 2021 12:00:07 +0000 (20:00 +0800)]
ALSA: pcm: use DEVICE_ATTR_RO macro
Use DEVICE_ATTR_RO() helper instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20210524120007.39728-1-yuehaibing@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Yufen Yu [Mon, 24 May 2021 09:38:11 +0000 (05:38 -0400)]
ALSA: ac97: fix PM reference leak in ac97_bus_remove()
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Link: https://lore.kernel.org/r/20210524093811.612302-1-yuyufen@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
zuoqilin [Mon, 24 May 2021 07:00:28 +0000 (15:00 +0800)]
sound/oss/dmasound: Remove superfluous "break"
Remove superfluous "break", as there is a "return" before them.
Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Link: https://lore.kernel.org/r/20210524070028.45-1-zuoqilin1@163.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 24 May 2021 03:13:46 +0000 (12:13 +0900)]
ALSA: bebob: distinguish M-Audio ProFire Lightbridge quirk
In former commit, ALSA IEC 61883-1/6 packet streaming engine drops
initial tx packets till the packet includes any event. This allows ALSA
bebob driver not to give option to skip initial packet since the engine
does drop the initial packet.
However, M-Audio ProFire Lightbridge has a quirk to stop packet
transmission after start multiplexing event to the packet. After several
thousands cycles, it restart packet transmission again.
This commit specializes the usage of initial skip option for the model.
Additionally, this commit expands timeout enough to wait processing
content of tx packet.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210524031346.50539-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 24 May 2021 03:13:45 +0000 (12:13 +0900)]
ALSA: bebob: cancel switching connection order
The order to establish connection seems to be meaningless.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210524031346.50539-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 24 May 2021 03:13:44 +0000 (12:13 +0900)]
ALSA: firewire-lib: obsolete callbacked member
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>
Takashi Sakamoto [Mon, 24 May 2021 03:13:43 +0000 (12:13 +0900)]
ALSA: firewire-lib: drop initial NODATA or empty packet
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>
Takashi Iwai [Tue, 25 May 2021 06:50:03 +0000 (08:50 +0200)]
Merge branch 'topic/pci-rescan-prep-v2' into for-next
Pull PCI rescan prep work.
Link: https://lore.kernel.org/r/20210523090920.15345-1-tiwai@suse.de
Takashi Iwai [Sun, 23 May 2021 09:09:20 +0000 (11:09 +0200)]
ALSA: pcm: Block the release until the system resume finishes
The normal PCM operations are already blocked during the card power
off state in the PCM common ioctl handler, but the release isn't
covered. As the PCM stream release may also access the hardware,
let's block the release until the card power turns on.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210523090920.15345-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Sun, 23 May 2021 09:09:19 +0000 (11:09 +0200)]
ALSA: Drop superfluous argument from snd_power_wait()
The power_state argument of snd_power_wait() is superfluous, receiving
only SNDRV_POWER_STATE_D0. Let's drop it in all callers for
simplicity.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210523090920.15345-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Sun, 23 May 2021 09:09:18 +0000 (11:09 +0200)]
ALSA: control: Minor optimization for SNDRV_CTL_IOCTL_POWER_STATE
Long long time ago, before the proper PM framework was introduced, it
was still possible to reach SNDRV_CTL_IOCTL_POWER ioctl during the
power off state. This ioctl existed as a main control for the suspend
resume state in the past, but the feature was already dropped along
with the standard PM framework. Now the read part,
SNDRV_IOCTL_POWER_STATE ioctl, returns practically always D0, and we
can do some minor optimization there.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210523090920.15345-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Sun, 23 May 2021 09:09:17 +0000 (11:09 +0200)]
ALSA: control: Drop superfluous snd_power_wait() calls
Now we have more fine-grained power controls in each kcontrol ops, the
coarse checks of snd_power_wait() in a few control ioctls became
superfluous. Let's drop them.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210523090920.15345-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Sun, 23 May 2021 09:09:16 +0000 (11:09 +0200)]
ALSA: control: Track in-flight control read/write/tlv accesses
Although the power state check is performed in various places (e.g. at
the entrance of quite a few ioctls), there can be still some pending
tasks that already went into the ioctl handler or other ops, and those
may access the hardware even after the power state check. For
example, kcontrol access ioctl paths that call info/get/put callbacks
may update the hardware registers. If a system wants to assure the
free from such hw access (like the case of PCI rescan feature we're
going to implement in future), this situation must be avoided, and we
have to sync such in-flight tasks finishing beforehand.
For that purpose, this patch introduces a few new things in core code:
- A refcount, power_ref, and a wait queue, power_ref_sleep, to the
card object
- A few new helpers, snd_power_ref(), snd_power_unref(),
snd_power_ref_and_wait(), and snd_power_sync_ref()
In the code paths that call kctl info/read/write/tlv ops, we check the
power state with the newly introduced snd_power_ref_and_wait(). This
function also takes the card.power_ref refcount for tracking this
in-flight task. Once after the access finishes, snd_power_unref() is
called to released the refcount in return. So the driver can sync via
snd_power_sync_ref() assuring that all in-flight tasks have been
finished.
As of this patch, snd_power_sync_ref() is called only at
snd_card_disconnect(), but it'll be used in other places in future.
Note that atomic_t is used for power_ref intentionally instead of
refcount_t. It's because of the design of refcount_t type; refcount_t
cannot be zero-based, and it cannot do dec_and_test() call for
multiple times, hence it's not suitable for our purpose.
Also, this patch changes snd_power_wait() to accept only
SNDRV_CTL_POWER_D0, which is the only value that makes sense.
In later patch, the snd_power_wait() calls will be cleaned up.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210523090920.15345-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Sun, 23 May 2021 09:09:15 +0000 (11:09 +0200)]
ALSA: core: Use READ_ONCE() / WRITE_ONCE() for power state change
We need proper barriers to handle the power state change of the card
from different CPUs.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210523090920.15345-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Sat, 22 May 2021 01:33:03 +0000 (10:33 +0900)]
ALSA: firewire-lib: code refactoring for transfer delay
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>
Takashi Sakamoto [Sat, 22 May 2021 01:33:02 +0000 (10:33 +0900)]
ALSA: firewire-lib: code refactoring for generation of data block sequence
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>
Takashi Sakamoto [Sat, 22 May 2021 01:33:01 +0000 (10:33 +0900)]
ALSA: firewire-lib: code refactoring for generation of syt sequence
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>
Takashi Sakamoto [Sat, 22 May 2021 01:33:00 +0000 (10:33 +0900)]
ALSA: firewire-lib: code refactoring for generation of packet descriptors
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>
Takashi Sakamoto [Sat, 22 May 2021 01:32:59 +0000 (10:32 +0900)]
ALSA: firewire-lib: pool sequence of packet in IT context independently
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>
Takashi Sakamoto [Sat, 22 May 2021 01:32:58 +0000 (10:32 +0900)]
ALSA: firewire-lib: add flag to unaware of syt in CIP header
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>
Takashi Sakamoto [Thu, 20 May 2021 13:04:09 +0000 (22:04 +0900)]
ALSA: firewire-lib: Fix uninitialized variable err issue
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>
Takashi Iwai [Thu, 20 May 2021 12:37:42 +0000 (14:37 +0200)]
ALSA: usb-audio: Fix uninitialized variable at __uac_clock_find_source()
The cur variable indicating the currently selected clock source can be
theoretically used as uninitialized after the recent commit
481f17c41803 ("ALSA: usb-audio: Handle error for the current selector
gracefully"). For addressing it, initialize it before use.
Also, one place seems setting 0 to a wrong variable ret, instead of
cur; otherwise it makes little sense. Since the initialization is
done beforehand, we can get rid of this line, too.
Fixes:
481f17c41803 ("ALSA: usb-audio: Handle error for the current selector gracefully")
Reported-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/4b261d68-f53f-240d-2d8a-2f88b337849d@canonical.com
Link: https://lore.kernel.org/r/s5hfsyhh97t.wl-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Thu, 20 May 2021 04:01:54 +0000 (13:01 +0900)]
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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:53 +0000 (13:01 +0900)]
ALSA: firewire-lib: start processing content of packet at the same cycle in 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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:52 +0000 (13:01 +0900)]
ALSA: firewire-lib: code refactoring to start several IT/IR contexts
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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:51 +0000 (13:01 +0900)]
ALSA: firewire-lib: skip initial packets instead of scheduling IR context
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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:50 +0000 (13:01 +0900)]
ALSA: firewire-lib: start processing content of packet at the same cycle in 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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:49 +0000 (13:01 +0900)]
ALSA: firewire-lib: code refactoring for selection of IT context header length
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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:48 +0000 (13:01 +0900)]
ALSA: firewire-lib: code refactoring for calculation of context payload
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>
Takashi Sakamoto [Thu, 20 May 2021 04:01:47 +0000 (13:01 +0900)]
ALSA: firewire-lib: code refactoring for size of CIP header
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>
Takashi Iwai [Wed, 19 May 2021 14:24:37 +0000 (16:24 +0200)]
Merge branch 'topic/firewire' into for-next
Takashi Iwai [Tue, 18 May 2021 15:21:12 +0000 (17:21 +0200)]
ALSA: usb-audio: Handle error for the current selector gracefully
Currently we bail out when the device returns an error or an invalid
value for the current clock selector value via
uac_clock_selector_get_val(). But it's possible that the device is
really uninitialized and waits for the setup of the proper route at
first.
For handling such a case, this patch lets the driver dealing with the
error or the invalid error more gracefully, choosing the clock source
automatically instead.
Link: https://lore.kernel.org/r/20210518152112.8016-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 18 May 2021 15:21:11 +0000 (17:21 +0200)]
ALSA: usb-audio: Refactoring UAC2/3 clock setup code
This patch just does refactoring of the UAC2/3 clock setup code.
There should be no functional changes. The major changes are:
* Provide union objects for pointing both UAC2 and UAC3 objects
* Unify clock source, selector and multiplier helper functions
* Unify __uac_clock_find_source() to deal with both UAC2 and UAC3
equally
Link: https://lore.kernel.org/r/20210518152112.8016-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Colin Ian King [Wed, 19 May 2021 10:54:24 +0000 (11:54 +0100)]
ALSA: rawmidi: fix incorrect array bounds check on clock_names
The array bounds check on clock_names is currently checking the size
of the entire array rather than the number of elements in the array
leading to a potential array bounds read error. Fix this by using
the ARRAY_SIZE macro instead of sizeof.
Addresses-Coverity: ("Out-of-bounds read")
Fixes:
08fdced60ca0 ("ALSA: rawmidi: Add framing mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210519105424.55221-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 13:00:47 +0000 (22:00 +0900)]
ALSA: firewire-lib: insert descriptor for skipped cycle
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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:46 +0000 (22:00 +0900)]
ALSA: firewire-lib: check cycle continuity
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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:45 +0000 (22:00 +0900)]
ALSA: firewire-lib: code refactoring for check of CIP header about payload size
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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:44 +0000 (22:00 +0900)]
ALSA: firewire-lib: code refactoring for parser of IR context header
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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:43 +0000 (22:00 +0900)]
ALSA: firewire-lib: code refactoring for helper function to compute OHCI 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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:42 +0000 (22:00 +0900)]
ALSA: firewire-lib: code refactoring for sequence descriptor'
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>
Takashi Sakamoto [Tue, 18 May 2021 13:00:41 +0000 (22:00 +0900)]
ALSA: firewire-lib: handle the case that empty isochronous packet payload for CIP
Two quadlets are at least included in isochronous packet payload for
Common Isochronous Packet (CIP) format in IEC 61883-1. However, it's
better to equip ALSA IEC 61883-1/6 packet streaming engine for contrary
packet.
This commit handles isochronous cycle to process such packet so that the
cycle is skipped.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518130048.146596-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 13:00:40 +0000 (22:00 +0900)]
ALSA: firewire-lib: code refactoring to refer the same frame count per period in domain structure
The number of PCM frame per period is common between PCM substreams
handled in AMDTP stream in AMDTP domain.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518130048.146596-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 18 May 2021 10:25:24 +0000 (12:25 +0200)]
Merge branch 'topic/firewire' into for-next
Takashi Sakamoto [Tue, 18 May 2021 08:45:57 +0000 (17:45 +0900)]
ALSA: oxfw: add quirk flag for blocking transmission method
Stanton SCS.1m and Apogee Duet FireWire use blocking transmission method
unlike the other models.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-12-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:56 +0000 (17:45 +0900)]
ALSA: oxfw: code refactoring for wrong_dbs quirk
A new entry is added to the quirk enumeration for wrong_dbs quirk to
obsolete structure member.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-11-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:55 +0000 (17:45 +0900)]
ALSA: firewire-lib: code refactoring for jumbo payload quirk
A new macro is added to describe the maximum number of cycles to accept
cycle skip by jumbo payload quirk.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-10-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:54 +0000 (17:45 +0900)]
ALSA: oxfw: code refactoring for jumbo-payload quirk in OXFW970
This commit adds enumeration to describe quirks of OXFW ASICs.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-9-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:53 +0000 (17:45 +0900)]
ALSA: oxfw: add comment for the type of ASICs
ALSA OXFW supports two types of ASICS; OXFW970 and OXFW971. The former
is known to have a quirk we call 'jumbo payload' that some isochronous
cycles are skipped to transfer isochronous packets during handling
asynchronous transaction. The quirk seems to correspond to firmware
initially delivered by Oxford Semiconductor since the quirk is not
confirmed for Mackie Onyx Satellite in which the revised firmware is
available. The quirk is not confirmed in the latter.
This commit adds code comment to describe the quirk.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-8-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:52 +0000 (17:45 +0900)]
ALSA: oxfw: add explicit device entry for Loud Technologies Mackie Onyx Sattelite
Loud Technologies Mackie Onyx Satellite is identified as the model with
OXFW970 ASIC.
This commit adds explicit entry for the model.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:51 +0000 (17:45 +0900)]
ALSA: oxfw: add explicit device entry for Loud Technologies Tapco Link.FireWire 4x6
Loud Technologies Tapco Link.FireWire 4x6 is identified as the model
with OXFW970 ASIC.
This commit adds explicit entry for the model.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:50 +0000 (17:45 +0900)]
ALSA: oxfw: code refactoring to detect mackie models
This commit changes condition statement to call mackie models detection
just for the device entry. Additionally, comment is added for Onyx 1640i.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:49 +0000 (17:45 +0900)]
ALSA: oxfw: code refactoring for existent device entry with specifier_id and version
All of the devices known to be based on OXFW ASICs have the same layout
of configuration ROM, in which unit directory includes vendor, model,
specifier_id and version immediate values. Especially, the pair of
specifier_id and version is fixed to represent AV/C general protocol.
This commit refactors device entries to fulfil with these 4 elements.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:48 +0000 (17:45 +0900)]
ALSA: firewire-lib/motu: use int type for the value of bitwise OR with enumerator-constant
It brings some inconvenience in practice to use enumerated type for
variable to which bitwise OR with enumerator constant is assigned.
This commit replaces declarations of enumerated type with int type.
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 08:45:47 +0000 (17:45 +0900)]
Revert "ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro"
This reverts commit
0edabdfe89581669609eaac5f6a8d0ae6fe95e7f.
I've explained that optional FireWire card for d.2 is also built-in to
d.2 Pro, however it's wrong. The optional card uses DM1000 ASIC and has
'Mackie DJ Mixer' in its model name of configuration ROM. On the other
hand, built-in FireWire card for d.2 Pro and d.4 Pro uses OXFW971 ASIC
and has 'd.Pro' in its model name according to manuals and user
experiences. The former card is not the card for d.2 Pro. They are similar
in appearance but different internally.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518084557.102681-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 01:26:12 +0000 (10:26 +0900)]
ALSA: dice: fix stream format for TC Electronic Konnekt Live at high sampling transfer frequency
At high sampling transfer frequency, TC Electronic Konnekt Live
transfers/receives 6 audio data frames in multi bit linear audio data
channel of data block in CIP payload. Current hard-coded stream format
is wrong.
Cc: <stable@vger.kernel.org>
Fixes:
f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518012612.37268-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Tue, 18 May 2021 01:25:10 +0000 (10:25 +0900)]
ALSA: dice: disable double_pcm_frames mode for M-Audio Profire 610, 2626 and Avid M-Box 3 Pro
ALSA dice driver detects jumbo payload at high sampling transfer frequency
for below models:
* Avid M-Box 3 Pro
* M-Audio Profire 610
* M-Audio Profire 2626
Although many DICE-based devices have a quirk at high sampling transfer
frequency to multiplex double number of PCM frames into data block than
the number in IEC 61883-1/6, the above devices are just compliant to
IEC 61883-1/6.
This commit disables the mode of double_pcm_frames for the models.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210518012510.37126-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:45 +0000 (15:15 +0200)]
ALSA: usx2y: Nuke pcm_list
It's nowhere actually used.
Link: https://lore.kernel.org/r/20210517131545.27252-12-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:44 +0000 (15:15 +0200)]
ALSA: usx2y: Cleanup probe and disconnect callbacks
Minor code refactoring by merging the superfluous function calls.
The functions were split in the past for covering pre-history USB
driver code, but this is utterly useless.
Link: https://lore.kernel.org/r/20210517131545.27252-11-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:43 +0000 (15:15 +0200)]
ALSA: usx2y: Don't call free_pages_exact() with NULL address
Unlike some other functions, we can't pass NULL pointer to
free_pages_exact(). Add a proper NULL check for avoiding possible
Oops.
Link: https://lore.kernel.org/r/20210517131545.27252-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:42 +0000 (15:15 +0200)]
ALSA: usx2y: Fix shmem initialization
Currently us428ctls_shmem pages are allocated dynamically upon the
mmap call, but this is quite racy. Since the shared memory itself is
mandatory for the mmap, let's allocate it at the beginning of the card
initialization. Also, fix the initialization of the wait queue, too.
Link: https://lore.kernel.org/r/20210517131545.27252-9-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:41 +0000 (15:15 +0200)]
ALSA: usxy2: Fix potential doubly allocations
The PCM shmem pages are allocated in snd_usx2y_usbpcm_prepare().
Theoretically the prepare callback may be called simultaneously for
both playback and capture, hence this allocation can be racy.
Make sure that the allocation is performed exclusively by extending
the pcm_mutex lock to cover the allocation code, too.
Link: https://lore.kernel.org/r/20210517131545.27252-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:40 +0000 (15:15 +0200)]
ALSA: usx2y: Fix potential memory leaks
Theoretically the initialization functions in usx2y drivers may be
called multiple times as the driver gets initialized via hwpdep
ioctl. Meanwhile, those functions including memory allocations don't
check whether they are called twice, and they forget the old
resources, which would lead to memory leaks.
This patch adds the sanity checks about the doubly initializations to
give kernel WARNING, and returns an error in such a case. Also, each
allocation assures to release the resources at its error path
properly.
Link: https://lore.kernel.org/r/20210517131545.27252-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:39 +0000 (15:15 +0200)]
ALSA: usx2y: Avoid self-killing
The initialization os usx2y driver is multi-staged, and the PCM and
other device creations are done after the DSP is loaded and
initialized. Upon the initialization, when an error happens, the
driver tries to call snd_card_free(). But this is dangerous, and in
general, the driver cannot kill itself during its operation.
Hence better to drop the snd_card_free() call from there.
Link: https://lore.kernel.org/r/20210517131545.27252-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:38 +0000 (15:15 +0200)]
ALSA: usx2y: Fix potential leaks of uninitialized memory
usx2y drivers may expose the allocated pages via mmap, but it performs
zero-clear only for the struct size, not aligned with the page size.
This leaves out some uninitialized trailing bytes.
This patch fixes the clearance to cover all memory that are exposed to
user-space.
Link: https://lore.kernel.org/r/20210517131545.27252-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 17 May 2021 13:15:37 +0000 (15:15 +0200)]
ALSA: usx2y: Coding style fixes
This patch fixes various trivial coding-style issues in usx2y code,
such as:
* the assginments in if condition
* comparison order with constants
* NULL / zero checks
* unsigned -> unsigned int
* addition of braces in control blocks
* debug print with function names
* move local variables in block into function head
* reduction of too nested indentations
No functional changes.
Link: https://lore.kernel.org/r/20210517131545.27252-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>