Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1178665pxb; Thu, 24 Mar 2022 14:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpk14Sn921F5DhirYtc/pWiIKpVToKDiWV/VX7fHzM27MnK/zElXV5W8qjXIJQSSn41g1P X-Received: by 2002:a50:cc89:0:b0:400:8f82:99e8 with SMTP id q9-20020a50cc89000000b004008f8299e8mr9086785edi.7.1648157275766; Thu, 24 Mar 2022 14:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648157275; cv=none; d=google.com; s=arc-20160816; b=W4SDTtFZEs02l5o0XyzxhDzPtpeQ0MN1x63BhaUVkYC+vDGn3YqNtYfuA9+zmysFaL wrqvapqDGLshzLZx2ebDrnYB+iI4VfVu+2nzXMaKpwUEC6pHgOc/fV2uCrmctfU4C0zA NXpY4ytKCnpusogDsl3aJrzDNSR6MHUsnYcC0weFc7BALfA+0c3Yw4uHGJL7RKGHtgZA FLu6wEoEQ0mUI2YyI3d9zaiRxtC5XFBGF2s7UAvsCPjknx82aIieRPBIwlIBuTErUdhC +YVowkNOYFxZYxAsbOKiQ6aETVDvQ9p226Ul1QC8lWTCwQDueiMwsPfIklMdzTk+tUfQ Ep/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nIB3th2eDT9w2yNRatnzx2oU8kEvU3EDp3NLz8GBO7U=; b=A3Hph6OQ8Vl+aUzR9s+xB4ZTMMcBD2ma/pFqKqmgyTunTVfBAeL0RxlbeSdJp4WYaE 5KKNz92Nvmh3nzVTTY9ExafDVJ312WL9WbVW6pwTtm0xF3dwwsGNV9wq17ngFQt/huG8 40YBd1EDNUQ9M1Jhd5Otoj5QL92e37fU9nlUAkAMOd9ZM65NG3Y65TGl+Q8KzWv1Jm7F +7DVedSZKWWuNTWywMsDJ1Wncl3h87x5vlH9MukvNGcenRVGEMRkzkLHDauOwisCynAl d9ISG0F1apEM1+uS3efaYqlfP5Pxxn2c1w2CZ8ir4veUbLoKxQ/j3iHgEbVdC4SJ6FwF /mVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u65XJ496; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a50ccd0000000b0041901f9db87si907202edj.127.2022.03.24.14.27.30; Thu, 24 Mar 2022 14:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u65XJ496; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348927AbiCXIfW (ORCPT + 99 others); Thu, 24 Mar 2022 04:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244857AbiCXIfT (ORCPT ); Thu, 24 Mar 2022 04:35:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7B09BB89 for ; Thu, 24 Mar 2022 01:33:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8B0A6CE235C for ; Thu, 24 Mar 2022 08:33:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55D8CC340EC; Thu, 24 Mar 2022 08:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648110823; bh=l7p+lzVuxSNaywoNSXcl3ZMeNQOe1Z3EcdoxDxqSA5A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u65XJ496YyPFCe0kGzD3+E80pvKbjzpOl2ZkXKk1lGHOZnw6J2MXaEIbBd692wc6n Qk5dFHTWg6U2NHJdaws0VjXp/ZYgvOZW0Mc0QxmJdDjIN7nnxxll3XzcLkdbPpvLQV Oaf9O7fqP0e9SBygVx7gFJp1aIBSCNK72NvjHfbk= Date: Thu, 24 Mar 2022 09:33:40 +0100 From: Greg Kroah-Hartman To: Oh Eomji Cc: Jaroslav Kysela , Takashi Iwai , open list , alsa-devel@alsa-project.org, Leon Romanovsky , Pavel Skripkin , JaeHun Jung Subject: Re: [PATCH v1 1/3] sound: usb: Add vendor's hooking interface Message-ID: References: <1648109444-196321-1-git-send-email-eomji.oh@samsung.com> <1648109444-196321-2-git-send-email-eomji.oh@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1648109444-196321-2-git-send-email-eomji.oh@samsung.com> X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Oh Eomji > --- > 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