On Thu, Mar 24, 2022 at 09:34:22AM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 24, 2022 at 05:10:43PM +0900, Oh Eomji wrote: > > When a new interface is connected or removed, the call-back functions > > are called to transmit a command to the hardware. > > > > Signed-off-by: Oh Eomji <eomji.oh@xxxxxxxxxxx> > > --- > > sound/usb/pcm.c | 37 +++++++++++++++++++++++++++++++++++++ > > sound/usb/stream.c | 2 ++ > > 2 files changed, 39 insertions(+) > > > > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > > index cec6e91a..4bae4ba 100644 > > --- a/sound/usb/pcm.c > > +++ b/sound/usb/pcm.c > > @@ -144,6 +144,8 @@ find_format(struct list_head *fmt_list_head, snd_pcm_format_t format, > > found = fp; > > cur_attr = attr; > > } > > + > > + snd_vendor_set_pcm_binterval(fp, found, &cur_attr, &attr); > > } > > return found; > > } > > @@ -434,6 +436,7 @@ static int configure_endpoints(struct snd_usb_audio *chip, > > struct snd_usb_substream *subs) > > { > > int err; > > + struct usb_interface *iface; > > > > if (subs->data_endpoint->need_setup) { > > /* stop any running stream beforehand */ > > @@ -442,6 +445,13 @@ static int configure_endpoints(struct snd_usb_audio *chip, > > err = snd_usb_endpoint_configure(chip, subs->data_endpoint); > > if (err < 0) > > return err; > > + > > + iface = usb_ifnum_to_if(chip->dev, subs->data_endpoint->iface); > > + err = snd_vendor_set_pcm_intf(iface, subs->data_endpoint->iface, > > + subs->data_endpoint->altsetting, subs->direction); > > + if (err < 0) > > + return err; > > + > > snd_usb_set_format_quirk(subs, subs->cur_audiofmt); > > } > > > > @@ -616,8 +626,18 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > > struct snd_pcm_runtime *runtime = substream->runtime; > > struct snd_usb_substream *subs = runtime->private_data; > > struct snd_usb_audio *chip = subs->stream->chip; > > + struct snd_usb_endpoint *ep = subs->data_endpoint; > > int ret; > > > > + ret = snd_vendor_set_pcm_buf(subs->dev, subs->cur_audiofmt->iface); > > + if (ret) > > + return ret; > > + > > + if (!subs->cur_audiofmt) { > > + dev_err(&subs->dev->dev, "no format is specified\n"); > > + return -ENXIO; > > + } > > + > > ret = snd_usb_lock_shutdown(chip); > > if (ret < 0) > > return ret; > > @@ -630,6 +650,13 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > > if (ret < 0) > > goto unlock; > > > > + if (snd_vendor_get_ops()) { > > + ret = snd_vendor_set_rate(ep->cur_audiofmt->iface, > > + ep->cur_rate, ep->cur_audiofmt->altsetting); > > + if (!ret) > > + goto unlock; > > + } > > + > > /* reset the pointer */ > > subs->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size); > > subs->inflight_bytes = 0; > > @@ -1104,6 +1131,11 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream) > > struct snd_usb_substream *subs = &as->substream[direction]; > > int ret; > > > > + ret = snd_vendor_set_pcm_connection(subs->dev, SOUND_PCM_OPEN, > > + direction); > > + if (ret) > > + return ret; > > + > > runtime->hw = snd_usb_hardware; > > /* need an explicit sync to catch applptr update in low-latency mode */ > > if (direction == SNDRV_PCM_STREAM_PLAYBACK && > > @@ -1137,6 +1169,11 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream) > > struct snd_usb_substream *subs = &as->substream[direction]; > > int ret; > > > > + ret = snd_vendor_set_pcm_connection(subs->dev, SOUND_PCM_CLOSE, > > + direction); > > + if (ret) > > + return ret; > > + > > snd_media_stop_pipeline(subs); > > > > if (!snd_usb_lock_shutdown(subs->stream->chip)) { > > diff --git a/sound/usb/stream.c b/sound/usb/stream.c > > index ceb93d7..26ca696 100644 > > --- a/sound/usb/stream.c > > +++ b/sound/usb/stream.c > > @@ -1227,6 +1227,8 @@ static int __snd_usb_parse_audio_interface(struct snd_usb_audio *chip, > > snd_usb_init_pitch(chip, fp); > > snd_usb_init_sample_rate(chip, fp, fp->rate_max); > > usb_set_interface(chip->dev, iface_no, altno); > > + if (protocol > UAC_VERSION_1) > > Why the protocol check? That's not documented in your changelog > anywhere :( > > Hi, In kernel 5.10, set_interface is performed when the protocol is more than UAC_VERSION_1 in the snd_usb_init_sample_rate function. There was an issue here, so there is a history of adding to perform snd_vendor_set_interface when the protocol is more than UAC_VERSION_1. But I don't think I need this in kerenel 5.15, so I'll delete it. Thanks, Eomji Oh