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.
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:
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.
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.
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:
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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>
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.
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.
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.
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.
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.
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.
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.
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
Takashi Iwai [Mon, 17 May 2021 13:15:36 +0000 (15:15 +0200)]
ALSA: usx2y: Fix spaces
This patch corrects merely the spaces in the usx2y code, including the
superfluous trailing space in the debug prints and a slight reformat
of some comment lines. Nothing really touches about the code itself.
Takashi Iwai [Mon, 17 May 2021 13:15:35 +0000 (15:15 +0200)]
ALSA: usx2y: Avoid camelCase
For improving readability, convert camelCase fields, variables and
functions to the plain names with underscore. Also align the macros
to be capital letters.
All done via sed, no functional changes.
Note that you'll still see many coding style issues even after this
patch; the fixes will follow.
This commit adds a new framing mode that frames all MIDI data into
32-byte frames with a timestamp.
The main benefit is that we can get accurate timestamps even if
userspace wakeup and processing is not immediate.
Testing on a Celeron N3150 with this mode has a max jitter of 2.8 ms,
compared to the in-kernel seq implementation which has a max jitter
of 5 ms during idle and much worse when running scheduler stress tests
in parallel.
Takashi Iwai [Sun, 16 May 2021 16:17:55 +0000 (18:17 +0200)]
ALSA: intel8x0: Don't update period unless prepared
The interrupt handler of intel8x0 calls snd_intel8x0_update() whenever
the hardware sets the corresponding status bit for each stream. This
works fine for most cases as long as the hardware behaves properly.
But when the hardware gives a wrong bit set, this leads to a zero-
division Oops, and reportedly, this seems what happened on a VM.
For fixing the crash, this patch adds a internal flag indicating that
the stream is ready to be updated, and check it (as well as the flag
being in suspended) to ignore such spurious update.
YueHaibing [Fri, 14 May 2021 07:05:07 +0000 (15:05 +0800)]
ALSA: gus: Replace unsafe strcpy() with strscpy()
Fix smatch warning:
sound/isa/gus/gus_main.c:396 snd_gus_check_version() error:
strcpy() 'card->longname' too large for 'card->shortname' (80 vs 32)
Even if this is not a real bug since the longest length of card->longname
now is 31, replace strcpy() with strscpy() in order to avoid possible
future mistake.
Jiapeng Chong [Thu, 13 May 2021 11:11:11 +0000 (19:11 +0800)]
ALSA: hda: generic: Remove redundant assignment to dac
Variable dac is set to zero, but this value is never read as it is
overwritten or not used later on, hence it is a redundant assignment
and can be removed.
Clean up the following clang-analyzer warning:
sound/pci/hda/hda_generic.c:1436:4: warning: Value stored to 'dac' is
never read [clang-analyzer-deadcode.DeadStores].
Takashi Sakamoto [Thu, 13 May 2021 12:56:52 +0000 (21:56 +0900)]
ALSA: firewire-lib: fix amdtp_packet tracepoints event for packet_index field
The snd_firewire_lib:amdtp_packet tracepoints event includes index of
packet processed in a context handling. However in IR context, it is not
calculated as expected.
Takashi Sakamoto [Thu, 13 May 2021 12:56:51 +0000 (21:56 +0900)]
ALSA: firewire-lib: fix calculation for size of IR context payload
The quadlets for CIP header is handled as a part of IR context header,
thus it doesn't join in IR context payload. However current calculation
includes the quadlets in IR context payload.
Cc: <stable@vger.kernel.org> Fixes: f11453c7cc01 ("ALSA: firewire-lib: use 16 bytes IR context header to separate CIP header") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210513125652.110249-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Thu, 13 May 2021 12:56:49 +0000 (21:56 +0900)]
ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro
Mackie d.2 has an extension card for IEEE 1394 communication, which uses
BridgeCo DM1000 ASIC. On the other hand, Mackie d.4 Pro has built-in
function for IEEE 1394 communication by Oxford Semiconductor OXFW971,
according to schematic diagram available in Mackie website. Although I
misunderstood that Mackie d.2 Pro would be also a model with OXFW971,
it's wrong. Mackie d.2 Pro is a model which includes the extension card
as factory settings.
This commit fixes entries in Kconfig and comment in ALSA OXFW driver.
Cc: <stable@vger.kernel.org> Fixes: fd6f4b0dc167 ("ALSA: bebob: Add skelton for BeBoB based devices") Fixes: ec4dba5053e1 ("ALSA: oxfw: Add support for Behringer/Mackie devices") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210513125652.110249-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Thu, 13 May 2021 12:56:48 +0000 (21:56 +0900)]
ALSA: dice: fix stream format at middle sampling rate for Alesis iO 26
Alesis iO 26 FireWire has two pairs of digital optical interface. It
delivers PCM frames from the interfaces by second isochronous packet
streaming. Although both of the interfaces are available at 44.1/48.0
kHz, first one of them is only available at 88.2/96.0 kHz. It reduces
the number of PCM samples to 4 in Multi Bit Linear Audio data channel
of data blocks on the second isochronous packet streaming.
This commit fixes hardcoded stream formats.
Cc: <stable@vger.kernel.org> Fixes: 28b208f600a3 ("ALSA: dice: add parameters of stream formats for models produced by Alesis") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20210513125652.110249-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Tue, 11 May 2021 09:05:00 +0000 (11:05 +0200)]
ALSA: usb-audio: Fix potential out-of-bounce access in MIDI EP parser
The recently introduced MIDI endpoint parser code has an access to the
field without the size validation, hence it might lead to
out-of-bounce access. Add the sanity checks for the descriptor
sizes.
Takashi Iwai [Mon, 10 May 2021 15:06:59 +0000 (17:06 +0200)]
ALSA: usb-audio: Validate MS endpoint descriptors
snd_usbmidi_get_ms_info() may access beyond the border when a
malformed descriptor is passed. This patch adds the sanity checks of
the given MS endpoint descriptors, and skips invalid ones.
Linus Torvalds [Sun, 9 May 2021 21:03:33 +0000 (14:03 -0700)]
fbmem: fix horribly incorrect placement of __maybe_unused
Commit b9d79e4ca4ff ("fbmem: Mark proc_fb_seq_ops as __maybe_unused")
places the '__maybe_unused' in an entirely incorrect location between
the "struct" keyword and the structure name.
It's a wonder that gcc accepts that silently, but clang quite reasonably
warns about it:
Linus Torvalds [Sun, 9 May 2021 20:42:39 +0000 (13:42 -0700)]
Merge tag 'drm-next-2021-05-10' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie:
"Bit later than usual, I queued them all up on Friday then promptly
forgot to write the pull request email. This is mainly amdgpu fixes,
with some radeon/msm/fbdev and one i915 gvt fix thrown in.
amdgpu:
- MPO hang workaround
- Fix for concurrent VM flushes on vega/navi
- dcefclk is not adjustable on navi1x and newer
- MST HPD debugfs fix
- Suspend/resumes fixes
- Register VGA clients late in case driver fails to load
- Fix GEM leak in user framebuffer create
- Add support for polaris12 with 32 bit memory interface
- Fix duplicate cursor issue when using overlay
- Fix corruption with tiled surfaces on VCN3
- Add BO size and stride check to fix BO size verification
radeon:
- Fix off-by-one in power state parsing
- Fix possible memory leak in power state parsing
msm:
- NULL ptr dereference fix
fbdev:
- procfs disabled warning fix
i915:
- gvt: Fix a possible division by zero in vgpu display rate
calculation"
* tag 'drm-next-2021-05-10' of git://anongit.freedesktop.org/drm/drm:
drm/amdgpu: Use device specific BO size & stride check.
drm/amdgpu: Init GFX10_ADDR_CONFIG for VCN v3 in DPG mode.
drm/amd/pm: initialize variable
drm/radeon: Avoid power table parsing memory leaks
drm/radeon: Fix off-by-one power_state index heap overwrite
drm/amd/display: Fix two cursor duplication when using overlay
drm/amdgpu: add new MC firmware for Polaris12 32bit ASIC
fbmem: Mark proc_fb_seq_ops as __maybe_unused
drm/msm/dpu: Delete bonkers code
drm/i915/gvt: Prevent divided by zero when calculating refresh rate
amdgpu: fix GEM obj leak in amdgpu_display_user_framebuffer_create
drm/amdgpu: Register VGA clients after init can no longer fail
drm/amdgpu: Handling of amdgpu_device_resume return value for graceful teardown
drm/amdgpu: fix r initial values
drm/amd/display: fix wrong statement in mst hpd debugfs
amdgpu/pm: set pp_dpm_dcefclk to readonly on NAVI10 and newer gpus
amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID
drm/amdgpu: fix concurrent VM flushes on Vega/Navi v2
drm/amd/display: Reject non-zero src_y and src_x for video planes