Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2288654rwd; Wed, 14 Jun 2023 00:13:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SKsvK9elhCOd6xlxJkpSrDRoXJu7AHO2bU9vmw36mkiizpULQvdLsAMyWQcA3XkMLWWcz X-Received: by 2002:a17:906:dc94:b0:92b:3c78:91fa with SMTP id cs20-20020a170906dc9400b0092b3c7891famr14356731ejc.28.1686726829737; Wed, 14 Jun 2023 00:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686726829; cv=none; d=google.com; s=arc-20160816; b=TssKBJefYMCdILjmih2pWqkE+q/zYpSUERs8ZUo7CccauYU9YAiiF0ggjX5v3zgxjD RuaV3S1Hg4uAWoHQYASBEQhKLOyH5012VgxL/kIki0ZfVA9A+v06lXWxG7nLueToiWNA PXHoLPPkbYP8rWqqFFEKxBV0iZo3ouPGRSabi6zpa3lGUBUb1uKRV5StD4tCGIip2Icc agOF/PvNYLzl7XZHmydx0OYHNfqnL3OpdEEZvG+DXFR/uYx0f1xGWXhwa4IDd43fxMW+ 2F9x+virCn/GFQaoLynL1IGPgwA8kL2ocoRM5V6feeQ9d5zix1oFIyqH3faIVFSkeqkX R0eA== 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=QWE+RkxHjYktQzS7y33JQNdxPH8PUJVU2JWp2e825tg=; b=PU/Kcc+X/tP7gCo3yW24/LONtcamCOLZkoCgHsMkeHOyZzm/Ij3rnpRYMebv8CIFYi HWAtWBdaeOmOAdm3I9kO1aARlkU1HbMkG3DYEISawF5yhq3/Xxx+OeSpFkEMRaGx3rl4 OH4kc6M7PIHXjBvb0Vp9+3TRuZ+t6zePEKLCf7kCN5OkhXpPD+KuR1xBzGLRXwIgsCqu 1xuIrRUiNpRd8SnuL/j2OgiuJ9aLn/BUaMs42JKSVb0r8eZipNt5SMt+WYbJ9REaB474 i8Xh99x369szFP6K0lcFUVRmgpb+QUM5rwS62Kb0raT92ImVzfYrZ6PSSuK4cnztFAkH eKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Xx4BN9hO; dkim=neutral (no key) header.i=@suse.de header.b=XJXfc2uM; 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 u12-20020a1709060b0c00b00977d280d6absi7291919ejg.735.2023.06.14.00.13.25; Wed, 14 Jun 2023 00:13:49 -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=@suse.de header.s=susede2_rsa header.b=Xx4BN9hO; dkim=neutral (no key) header.i=@suse.de header.b=XJXfc2uM; 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 S243342AbjFNHFw (ORCPT + 99 others); Wed, 14 Jun 2023 03:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242890AbjFNHFM (ORCPT ); Wed, 14 Jun 2023 03:05:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6201FCB; Wed, 14 Jun 2023 00:04:57 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id 743121FDE2; Wed, 14 Jun 2023 07:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686726296; 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=QWE+RkxHjYktQzS7y33JQNdxPH8PUJVU2JWp2e825tg=; b=Xx4BN9hOnRqru8ALBeKVfhvqQTU418nvhTIC1SN1HBLXecQScy5svNLbHmQA8ySW5hV01l S9Hp29/RJdCxZSilZnf7vXRfIcTIy1kS2hfmLcAZqNBBVJfBQdXpO+TcbPdALW0qdzkMpr cygUgMQyJynGmCSGwcvOJcRhRZuBK5o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686726296; 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=QWE+RkxHjYktQzS7y33JQNdxPH8PUJVU2JWp2e825tg=; b=XJXfc2uMDX8ipkukt4YIUsbT0bOWBuZRo7reHVKNV6Drjq4c5tnnCTFNMxURFaYXeEwA9A /XaIhfRpO746nRBw== 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 248F81357F; Wed, 14 Jun 2023 07:04:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gdv7B5hmiWSMEAAAMHmgww (envelope-from ); Wed, 14 Jun 2023 07:04:56 +0000 Date: Wed, 14 Jun 2023 09:04:55 +0200 Message-ID: <87edmebk2w.wl-tiwai@suse.de> From: Takashi Iwai To: Srinivas Kandagatla Cc: vkoul@kernel.org, broonie@kernel.org, tiwai@suse.com, corbet@lwn.net, alsa-devel@alsa-project.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, quic_plai@quicinc.com, quic_mohs@quicinc.com Subject: Re: [PATCH v2] ALSA: compress: allow setting codec params after next track In-Reply-To: <20230609150416.24525-1-srinivas.kandagatla@linaro.org> References: <20230609150416.24525-1-srinivas.kandagatla@linaro.org> 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, 09 Jun 2023 17:04:16 +0200, Srinivas Kandagatla wrote: > > For gapless playback it is possible that each track can have different > codec profile with same decoder, for example we have WMA album, > we may have different tracks as WMA v9, WMA v10 and so on > > Or if DSP's like QDSP have abililty to switch decoders on single stream > for each track, then this call could be used to set new codec parameters. > > Existing code does not allow to change this profile while doing gapless > playback. > > Reuse existing SNDRV_COMPRESS_SET_PARAMS to set this new track params along > some additional checks to enforce proper state machine. > > With this new changes now the user can call SNDRV_COMPRESS_SET_PARAMS > anytime after setting next track and additional check in write should > also ensure that params are set before writing new data. > > Signed-off-by: Srinivas Kandagatla > --- > Changes since v1/RFC: > - removed introduction of new IOCTL, as suggested. > - update the state-machine doc. > > .../sound/designs/compress-offload.rst | 52 +++++++++---------- > sound/core/compress_offload.c | 10 ++-- > 2 files changed, 33 insertions(+), 29 deletions(-) > > diff --git a/Documentation/sound/designs/compress-offload.rst b/Documentation/sound/designs/compress-offload.rst > index 935f325dbc77..205cadcabe70 100644 > --- a/Documentation/sound/designs/compress-offload.rst > +++ b/Documentation/sound/designs/compress-offload.rst > @@ -256,32 +256,32 @@ Gapless Playback SM > For Gapless, we move from running state to partial drain and back, along > with setting of meta_data and signalling for next track :: > > - > - +----------+ > - compr_drain_notify() | | > - +------------------------>| RUNNING | > - | | | > - | +----------+ > - | | > - | | > - | | compr_next_track() > - | | > - | V > - | +----------+ > - | | | > - | |NEXT_TRACK| > - | | | > - | +----------+ > - | | > - | | > - | | compr_partial_drain() > - | | > - | V > - | +----------+ > - | | | > - +------------------------ | PARTIAL_ | > - | DRAIN | > - +----------+ > + +----------+ > + compr_drain_notify() | | compr_set_params() iff next-track set. > + +------------------------>| RUNNING |----------------------+ > + | | | | > + | +----------+ | > + | | | > + | | | > + | | compr_next_track() | > + | | V > + | V | > + | +----------+ | > + | | | | > + | |NEXT_TRACK| | > + | | | | > + | +----------+ | > + | | | > + | +----------------------------+ > + | | > + | | compr_partial_drain() > + | | > + | V > + | +----------+ > + | | | > + +------------------------ | PARTIAL_ | > + | DRAIN | > + +----------+ > > Not supported > ============= > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index 243acad89fd3..fe67228e74b3 100644 > --- a/sound/core/compress_offload.c > +++ b/sound/core/compress_offload.c > @@ -294,6 +294,9 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf, > case SNDRV_PCM_STATE_SETUP: > case SNDRV_PCM_STATE_PREPARED: > case SNDRV_PCM_STATE_RUNNING: > + /* Make sure next track params are set before writing new data */ > + if (stream->next_track) > + return -EPERM; Hm, does this logic correctly match with the comment above? Also, this misses the mutex unlock. thanks, Takashi