public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Oh Eomji <eomji.oh@samsung.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	open list <linux-kernel@vger.kernel.org>,
	alsa-devel@alsa-project.org, Leon Romanovsky <leon@kernel.org>,
	Pavel Skripkin <paskripkin@gmail.com>,
	JaeHun Jung <jh0801.jung@samsung.com>
Subject: Re: [PATCH v1 1/3] sound: usb: Add vendor's hooking interface
Date: Thu, 24 Mar 2022 09:33:40 +0100	[thread overview]
Message-ID: <Yjws5IhAqos5LDM+@kroah.com> (raw)
In-Reply-To: <1648109444-196321-2-git-send-email-eomji.oh@samsung.com>

On Thu, Mar 24, 2022 at 05:10:42PM +0900, Oh Eomji wrote:
> In mobile, a co-processor can be used with USB audio to improve power
> consumption.  To support this type of hardware, hooks need to be added
> to the USB audio subsystem to be able to call into the hardware when
> needed.
> 
> The main operation of the call-backs are:
>   - Initialize the co-processor by transmitting data when initializing.
>   - Change the co-processor setting value through the interface
>     function.
>   - Configure sampling rate
>   - pcm open/close
>   - other housekeeping
> 
> Known issues:
>   - This only supports one set of callback hooks, meaning that this only
>     works if there is one type of USB controller in the system.  This
>     should be changed to be a per-host-controller interface instead of
>     one global set of callbacks.
> 
> Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
> Signed-off-by: Oh Eomji <eomji.oh@samsung.com>
> ---
>  sound/usb/card.c     | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  sound/usb/card.h     |  20 +++++++++
>  sound/usb/usbaudio.h |  45 +++++++++++++++++++
>  3 files changed, 184 insertions(+)
> 
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 3769622..bd59311 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -117,6 +117,117 @@ MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (default: no)
>  static DEFINE_MUTEX(register_mutex);
>  static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
>  static struct usb_driver usb_audio_driver;
> +static struct snd_usb_audio_vendor_ops *usb_vendor_ops;
> +
> +int snd_vendor_set_ops(struct snd_usb_audio_vendor_ops *ops)
> +{
> +	if ((!ops->connect) ||
> +	    (!ops->disconnect) ||
> +	    (!ops->set_interface) ||
> +	    (!ops->set_rate) ||
> +	    (!ops->set_pcm_buf) ||
> +	    (!ops->set_pcm_intf) ||
> +	    (!ops->set_pcm_connection) ||
> +	    (!ops->set_pcm_binterval) ||
> +	    (!ops->usb_add_ctls))
> +		return -EINVAL;
> +
> +	usb_vendor_ops = ops;
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_vendor_set_ops);
> +
> +struct snd_usb_audio_vendor_ops *snd_vendor_get_ops(void)
> +{
> +	return usb_vendor_ops;
> +}

This is the function you need to fix up, and add proper reference
counting to, in order to solve your "this breaks with multiple USB
controllers" problem.  So this really should not be all that difficult
of a task.  Why has it taken years to do so?

thanks,

greg k-h

  parent reply	other threads:[~2022-03-24  8:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220324081208epcas2p41916730b7e386f24e5548fac53e5bc41@epcas2p4.samsung.com>
2022-03-24  8:10 ` [PATCH v1 0/3] Exynos Usb Audio Offloading Support Oh Eomji
2022-03-24  8:10   ` [PATCH v1 1/3] sound: usb: Add vendor's hooking interface Oh Eomji
2022-03-24  8:32     ` Greg Kroah-Hartman
2022-03-25 18:47       ` Krzysztof Kozlowski
2022-03-24  8:33     ` Greg Kroah-Hartman [this message]
2022-03-25  6:44       ` Oh Eomji
2022-03-25  6:51         ` Greg Kroah-Hartman
2022-03-25  8:01     ` Christoph Hellwig
2022-03-24  8:10   ` [PATCH v1 2/3] sound: usb: Calling vendor's call-back function within usb audio operation Oh Eomji
2022-03-24  8:34     ` Greg Kroah-Hartman
2022-03-25  7:13       ` Oh Eomji
2022-03-25  7:33         ` Greg Kroah-Hartman
2022-03-24  8:10   ` [PATCH v1 3/3] sound: usb: Exynos usb audio offloading driver Oh Eomji
2022-03-24  8:41     ` Greg Kroah-Hartman
2022-03-28  6:49       ` Oh Eomji
2022-03-25 18:44     ` Krzysztof Kozlowski
2022-03-28  6:59       ` Oh Eomji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yjws5IhAqos5LDM+@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=eomji.oh@samsung.com \
    --cc=jh0801.jung@samsung.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox