sound: usb: usb_audio_qmi_svc: Update endpoint open API to add fixed_rate
Upstream added a new argument to the snd_usb_endpoint_open() API to pass in an argument for if the device only supports a single sampling frequency. This requires the downstream USB QMI driver to check for the same. Change-Id: I843aaf5f84771705d2f4b64cfad27abf0f1c508b Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
This commit is contained in:
parent
19b9311490
commit
c86619667f
@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
@ -1314,6 +1314,34 @@ static int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params,
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *subs)
|
||||
{
|
||||
const struct audioformat *fp;
|
||||
struct snd_usb_audio *chip;
|
||||
int rate = -1;
|
||||
|
||||
if (!subs)
|
||||
return false;
|
||||
chip = subs->stream->chip;
|
||||
if (!(chip->quirk_flags & QUIRK_FLAG_FIXED_RATE))
|
||||
return false;
|
||||
list_for_each_entry(fp, &subs->fmt_list, list) {
|
||||
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
|
||||
return false;
|
||||
if (fp->nr_rates < 1)
|
||||
continue;
|
||||
if (fp->nr_rates > 1)
|
||||
return false;
|
||||
if (rate < 0) {
|
||||
rate = fp->rate_table[0];
|
||||
continue;
|
||||
}
|
||||
if (rate != fp->rate_table[0])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void disable_audio_stream(struct snd_usb_substream *subs)
|
||||
{
|
||||
struct snd_usb_audio *chip = subs->stream->chip;
|
||||
@ -1338,6 +1366,7 @@ static int enable_audio_stream(struct snd_usb_substream *subs,
|
||||
struct snd_pcm_hw_params params;
|
||||
const struct audioformat *fmt;
|
||||
int ret;
|
||||
bool fixed_rate;
|
||||
|
||||
_snd_pcm_hw_params_any(¶ms);
|
||||
_snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT,
|
||||
@ -1364,8 +1393,9 @@ static int enable_audio_stream(struct snd_usb_substream *subs,
|
||||
if (subs->data_endpoint)
|
||||
close_endpoints(chip, subs);
|
||||
|
||||
fixed_rate = snd_usb_pcm_has_fixed_rate(subs);
|
||||
subs->data_endpoint = snd_usb_endpoint_open(chip, fmt,
|
||||
¶ms, false);
|
||||
¶ms, false, fixed_rate);
|
||||
if (!subs->data_endpoint) {
|
||||
uaudio_err("failed to open data endpoint\n");
|
||||
return -EINVAL;
|
||||
@ -1373,7 +1403,7 @@ static int enable_audio_stream(struct snd_usb_substream *subs,
|
||||
|
||||
if (fmt->sync_ep) {
|
||||
subs->sync_endpoint = snd_usb_endpoint_open(chip,
|
||||
fmt, ¶ms, false);
|
||||
fmt, ¶ms, false, fixed_rate);
|
||||
if (!subs->sync_endpoint) {
|
||||
uaudio_err("failed to open sync endpoint\n");
|
||||
return -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user