Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10877865rwl; Mon, 2 Jan 2023 09:36:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvT/Ujq5h5vPrUpqkFjAWqrpeY5F6X2wVXK6LwOwpMA+HGmyg0OMH6QH74iJfS53JCdMVrU X-Received: by 2002:a05:6402:5145:b0:475:32d2:7486 with SMTP id n5-20020a056402514500b0047532d27486mr37623934edd.31.1672680980277; Mon, 02 Jan 2023 09:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672680980; cv=none; d=google.com; s=arc-20160816; b=rHR/ZmX2e9WyQNnGB6Bi23Qz3KZ2bfsw8qTh95CKx2EmWDE+DSaAabPt40fTy5qTbe K/Yr/JvMNoCnLKK4CGI4mrrhtnNIi2hK7ZZW6GcQkt9dhZz8NRjByG95+ZWZBeMtM/+F gZRKF5WlcvO1oUZ0UnuDH9yS0jPnZvzlnt81KggBNR986rCPIV7rZ5cWSMklBjAqvBt5 7O9Y3mKaaIBcOZLnqXRfggWGal1rTTwLrwykERnGD8nAbXyLk+EIk7YFXzrJuo0ROR13 RmYrtjW8E/Uy38eEgwIqL3MeRo+Hhw3k2cpsUCXJ8nYBPQjrEVEiIfiCEBhKYCR0FDF1 Iniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=c+p+ZHZvJLaVRQr5NTszckwP5nV6LjSTDHOD89k5qNI=; b=z7MycPCGDTlnFuaRtPAYEgRRlRe4ke473Nd87xVZ75jkZGPNiFWo+j2x8W2phHXABS y1iBr1DBp5ZtCQwY0E00uDFCjhm3bQnDNjsYEkPCSEi4UPT6WEwEFMIxqgelZ45UsuWI /Q99IeCQVrjsTuM8vgTCyN4aJ/SWQo69jovVZwdOun6GerVZsjbWzjG11UvEhfZa91Rp 0mn2O6xpCYQ0ffV0N8Baa/vROW8vFgMDUIzIAJ1yR42ktP8Kd2QZfQyqwrYheQSbwWSq iqNxrp6N2aJ4OHeoLanSiS9gMCXYKJciiMNJ7vmhw18ztypaEe+QVXJqolKjW8yuu6eL dlDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ANkNie0i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tWgOFZcq; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga22-20020a1709070c1600b007acbac0871csi25329174ejc.420.2023.01.02.09.36.06; Mon, 02 Jan 2023 09:36:20 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=ANkNie0i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tWgOFZcq; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234650AbjABR3A (ORCPT + 61 others); Mon, 2 Jan 2023 12:29:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbjABR2m (ORCPT ); Mon, 2 Jan 2023 12:28:42 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B30019F; Mon, 2 Jan 2023 09:28:37 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C7BE6342A7; Mon, 2 Jan 2023 17:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672680515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c+p+ZHZvJLaVRQr5NTszckwP5nV6LjSTDHOD89k5qNI=; b=ANkNie0iEw+MUPgAvLqNXpLtkCUzRqRfOgJpC594NUXYaDxiY0ZToLCCvayH8+/acLOskm WjgRbB9mrM9lwKA6rIRi2W++cSewn6f0kr15VS9qKwvPKpl5O5EPwiARv+2ujwKx5eFeKN 0w6nMhR/x82e6RGCWuEETudE7Id91l4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672680515; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c+p+ZHZvJLaVRQr5NTszckwP5nV6LjSTDHOD89k5qNI=; b=tWgOFZcqs4GLxyLAh3jp6i0EgE7JPjCDyRfptR9lzceBDEYk76L6j/PcrKE6zBOBjdSpj5 1KDBnaRWSnWbIVCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6BE0513427; Mon, 2 Jan 2023 17:28:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6vZjGUMUs2ORIQAAMHmgww (envelope-from ); Mon, 02 Jan 2023 17:28:35 +0000 Date: Mon, 02 Jan 2023 18:28:34 +0100 Message-ID: <87edscsv5p.wl-tiwai@suse.de> From: Takashi Iwai To: Wesley Cheng Cc: , , , , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH 09/14] sound: usb: Introduce QC USB SND offloading support In-Reply-To: <20221223233200.26089-10-quic_wcheng@quicinc.com> References: <20221223233200.26089-1-quic_wcheng@quicinc.com> <20221223233200.26089-10-quic_wcheng@quicinc.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 Sat, 24 Dec 2022 00:31:55 +0100, Wesley Cheng wrote: > > Several Qualcomm SoCs have a dedicated audio DSP, which has the ability to > support USB sound devices. This vendor driver will implement the required > handshaking with the DSP, in order to pass along required resources that > will be utilized by the DSP's USB SW. The communication channel used for > this handshaking will be using the QMI protocol. Required resources > include: > - Allocated secondary event ring address > - EP transfer ring address > - Interrupter number > > The above information will allow for the audio DSP to execute USB transfers > over the USB bus. It will also be able to support devices that have an > implicit feedback and sync endpoint as well. Offloading these data > transfers will allow the main/applications processor to enter lower CPU > power modes, and sustain a longer duration in those modes. > > Signed-off-by: Wesley Cheng Hmm, this must be the main part that works to bypass the normal USB packet handling in USB audio driver but hooks to the own offload one, but there is no description how to take over and manage. A missing "big picture" makes it difficult to understand and review. Also, since both drivers are asynchronous, we may need some proper locking. More on the code change: > +static int snd_interval_refine_set(struct snd_interval *i, unsigned int val) > +{ > + struct snd_interval t; > + > + t.empty = 0; > + t.min = t.max = val; > + t.openmin = t.openmax = 0; > + t.integer = 1; > + return snd_interval_refine(i, &t); > +} > + > +static int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, > + snd_pcm_hw_param_t var, unsigned int val, > + int dir) > +{ > + int changed; > + > + if (hw_is_mask(var)) { > + struct snd_mask *m = hw_param_mask(params, var); > + > + if (val == 0 && dir < 0) { > + changed = -EINVAL; > + snd_mask_none(m); > + } else { > + if (dir > 0) > + val++; > + else if (dir < 0) > + val--; > + changed = snd_mask_refine_set( > + hw_param_mask(params, var), val); > + } > + } else if (hw_is_interval(var)) { > + struct snd_interval *i = hw_param_interval(params, var); > + > + if (val == 0 && dir < 0) { > + changed = -EINVAL; > + snd_interval_none(i); > + } else if (dir == 0) > + changed = snd_interval_refine_set(i, val); > + else { > + struct snd_interval t; > + > + t.openmin = 1; > + t.openmax = 1; > + t.empty = 0; > + t.integer = 0; > + if (dir < 0) { > + t.min = val - 1; > + t.max = val; > + } else { > + t.min = val; > + t.max = val+1; > + } > + changed = snd_interval_refine(i, &t); > + } > + } else > + return -EINVAL; > + if (changed) { > + params->cmask |= 1 << var; > + params->rmask |= 1 << var; > + } > + return changed; > +} Those are taken from sound/core/oss/pcm_oss.c? We may put to the common PCM helper instead of duplication. > +static void disable_audio_stream(struct snd_usb_substream *subs) > +{ > + struct snd_usb_audio *chip = subs->stream->chip; > + > + if (subs->data_endpoint || subs->sync_endpoint) { > + close_endpoints(chip, subs); > + > + mutex_lock(&chip->mutex); > + subs->cur_audiofmt = NULL; > + mutex_unlock(&chip->mutex); > + } > + > + snd_usb_autosuspend(chip); > +} > + > +static int enable_audio_stream(struct snd_usb_substream *subs, > + snd_pcm_format_t pcm_format, > + unsigned int channels, unsigned int cur_rate, > + int datainterval) > +{ > + struct snd_usb_audio *chip = subs->stream->chip; > + struct snd_pcm_hw_params params; > + const struct audioformat *fmt; > + int ret; > + > + _snd_pcm_hw_params_any(¶ms); > + _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, > + pcm_format, 0); > + _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, > + channels, 0); > + _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, > + cur_rate, 0); What about other parameters like period / buffer sizes? > +struct qmi_uaudio_stream_req_msg_v01 { > + u8 enable; > + u32 usb_token; > + u8 audio_format_valid; > + u32 audio_format; > + u8 number_of_ch_valid; > + u32 number_of_ch; > + u8 bit_rate_valid; > + u32 bit_rate; > + u8 xfer_buff_size_valid; > + u32 xfer_buff_size; > + u8 service_interval_valid; > + u32 service_interval; > +}; Are this and the other structs a part of DSP ABI? Or is it a definition only used in kernel? I'm asking because __packed attribute is required for most of ABI definitions with different field types. thanks, Takashi