summaryrefslogtreecommitdiff
path: root/sound/usb/card.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-11-23 11:53:16 +0300
committerTakashi Iwai <tiwai@suse.de>2020-11-23 17:12:46 +0300
commit5a6c3e11c9c9bc764cd4e2621cdb48cc9afb28a1 (patch)
tree9d38ab512526fb980d1c2faf9719349fb9b788c9 /sound/usb/card.h
parent1865211d6789e8404c75278754f0fa4735165600 (diff)
downloadlinux-5a6c3e11c9c9bc764cd4e2621cdb48cc9afb28a1.tar.xz
ALSA: usb-audio: Add hw constraint for implicit fb sync
In the current code, there is no check at the stream open time whether the endpoint is being already used by others. In the normal operations, this shouldn't happen, but in the case of the implicit feedback mode, it's a common problem with the full duplex operation, because the capture stream is always opened by the playback stream as an implicit sync source. Although we recently introduced the check of such a conflict of parameters at the PCM hw_params time, it doesn't give any hint at the hw_params itself and just gives the error. This isn't quite comfortable, and it caused problems on many applications. This patch attempts to make the parameter handling easier by introducing the strict hw constraint matching with the counterpart stream that is being used. That said, when an implicit feedback playback stream is running before a capture stream is opened, the capture stream carries the PCM hw-constraint to allow only the same sample rate, format, periods and period frames as the running playback stream. If not opened or there is no conflict of endpoints, the behavior remains as same as before. Note that this kind of "weak link" should work for most cases, but this is no concrete solution; e.g. if an application changes the hw params multiple times while another stream is opened, this would lead to inconsistencies. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-11-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/card.h')
-rw-r--r--sound/usb/card.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sound/usb/card.h b/sound/usb/card.h
index 898a283576df..1f61be98a31d 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -114,6 +114,14 @@ struct snd_usb_endpoint {
in a stream */
bool is_implicit_feedback; /* This endpoint is used as implicit feedback */
+ /* for hw constraints */
+ unsigned int cur_rate;
+ snd_pcm_format_t cur_format;
+ unsigned int cur_channels;
+ unsigned int cur_period_frames;
+ unsigned int cur_period_bytes;
+ unsigned int cur_buffer_periods;
+
spinlock_t lock;
struct list_head list;
};
@@ -144,6 +152,7 @@ struct snd_usb_substream {
unsigned int stream_offset_adj; /* Bytes to drop from beginning of stream (for non-compliant devices) */
unsigned int running: 1; /* running status */
+ unsigned int fixed_hw:1; /* fixed hw constraints due to sync EP */
unsigned int hwptr_done; /* processed byte position in the buffer */
unsigned int transfer_done; /* processed frames since last period update */