From patchwork Fri Aug 4 11:07:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13341748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0B62C001DB for ; Fri, 4 Aug 2023 12:06:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C7CF2832; Fri, 4 Aug 2023 14:05:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C7CF2832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691150775; bh=1X5fY3MikPJO5z8LqNPKHiilBwwDma0I0W6nsOZTLYc=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=dlzN1oyB52ha8UBzdh4on86PmeKcKkA8CMPxjUHW9E8SOmVUXIlRlMPcxvJQoOMG4 HzS9gj8YtpTYKx55F+4+O/rVpeuV1qHxqabd+eddtn3tQ1nIoE8xuKYogw9jliPHoo YLwuZXxJRCfFh40Ao/RyCMShzepocfkt6BgIWOAw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 067A5F80571; Fri, 4 Aug 2023 14:04:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9758BF80588; Fri, 4 Aug 2023 14:04:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B01BF802BE; Fri, 4 Aug 2023 13:08:25 +0200 (CEST) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E450DF8015B for ; Fri, 4 Aug 2023 13:08:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E450DF8015B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Y9v7LWfJ Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b9cb0bb04bso6474331fa.0 for ; Fri, 04 Aug 2023 04:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691147293; x=1691752093; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hfx9po4X2/nHcqp+uRJNh79vQllteYIAEl+4cz19+wo=; b=Y9v7LWfJuu1KFZqRR7L/JeSm0qr+0EnizOFk3RMoGM98ftwdz16Cjpn+F4ULdiDRur xTgSQf4glPExnarUK3ZmhHaCFXJpXfImFPGUHDU4vqWZ3T8EzdbtMBfq5NxSYT0U/pKj SMgs/zEEaPoNZISp8e+Wrlvw/eOwMLOiYgoZN5vcvDuQSUGiyJvRU4Brvj87Z6qIj1y1 UyA5oTF3iI057XiaC0SKF0kMmx7u0EWu73VWSHNhN1oUr/AaGnu7oJ5YKJd2qGDYfBIP JY3TUmGr3tCKXVJ8jNUN5JWJf5o4hHK4xbZd8PBHtLwuzcWkknX2uQyZA5sBky0Ncuzs 7jdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691147293; x=1691752093; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hfx9po4X2/nHcqp+uRJNh79vQllteYIAEl+4cz19+wo=; b=Vu6/oShyGET1IrVw4WtQJ3QCsReVcnY008zyCS6NamD1RWvMledvBGaDQKW4mSiNSz mMc4MJ3J0H0JMg0AuDQEEYz5ib84/xs2NNQxmK/vawYvpWkEvkGwm39Jhnh1S3xx8/Cw 97iyYEHMthXMjbD5mU95VeUU4VbaUj/4IK4262C6flg5aUirOgp74OGkW3VFcUXq/rRq FBVy5UecZDl/eFqB5efJcT5PKFVUJyjYwihOVjAp9MI1n2Gjyc7cxumiIL9b2+LhygHk pWcVlodLjgs3I+qVPZIydijidZ5G8X7M7Vozy5oQi2Nr0bqJ59XLyT7WtFDVz+edOZeu nBGg== X-Gm-Message-State: ABy/qLbu9RvzIKKEHVCHnYKbzDc8dSDLBs439todivSzXScGRoMquecO N9Ie76l5YtvjmjlS5FTQjYs= X-Google-Smtp-Source: APBJJlG6BvJQhivkEuMwuZNLTqLU7d94VTvMiviNYgJs6jIw35Nbsz+MCrc3BEEtpcaS/JLy/GxOBQ== X-Received: by 2002:a05:651c:332:b0:2b7:3a7e:9e89 with SMTP id b18-20020a05651c033200b002b73a7e9e89mr9741571ljp.2.1691147292700; Fri, 04 Aug 2023 04:08:12 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([178.160.196.94]) by smtp.gmail.com with ESMTPSA id bn10-20020a170906c0ca00b00992b0745548sm1149478ejb.152.2023.08.04.04.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 04:08:12 -0700 (PDT) From: Ivan Orlov To: perex@perex.cz, tiwai@suse.com Cc: Ivan Orlov , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] ALSA: pcmtest: Move buffer iterator initialization to prepare callback Date: Fri, 4 Aug 2023 15:07:39 +0400 Message-Id: <20230804110740.9867-1-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-MailFrom: ivan.orlov0322@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: 4IT7Y3MRYRGO7TEX7EIWM5CO5SKKGQLB X-Message-ID-Hash: 4IT7Y3MRYRGO7TEX7EIWM5CO5SKKGQLB X-Mailman-Approved-At: Fri, 04 Aug 2023 12:04:33 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Trigger callback is not the best place for buffer iterator initialization, so move it out to the prepare callback, where it have to be. Minor enhancement: remove blank line. Signed-off-by: Ivan Orlov --- V1 -> V2: - Split changes in the patch into two different patches sound/drivers/pcmtest.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index 08e14b5eb772..dc7c9c758537 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -92,7 +92,6 @@ MODULE_PARM_DESC(inject_trigger_err, "Inject EINVAL error in the 'trigger' callb module_param(inject_open_err, bool, 0600); MODULE_PARM_DESC(inject_open_err, "Inject EBUSY error in the 'open' callback"); - struct pcmtst { struct snd_pcm *pcm; struct snd_card *card; @@ -405,25 +404,9 @@ static int snd_pcmtst_pcm_close(struct snd_pcm_substream *substream) static int snd_pcmtst_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcmtst_buf_iter *v_iter = runtime->private_data; - if (inject_trigger_err) return -EINVAL; - v_iter->sample_bytes = runtime->sample_bits / 8; - v_iter->period_bytes = frames_to_bytes(runtime, runtime->period_size); - if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED || - runtime->access == SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) { - v_iter->chan_block = runtime->dma_bytes / runtime->channels; - v_iter->interleaved = false; - } else { - v_iter->interleaved = true; - } - // We want to record RATE * ch_cnt samples per sec, it is rate * sample_bytes * ch_cnt bytes - v_iter->s_rw_ch = runtime->rate / TIMER_PER_SEC; - v_iter->b_rw = v_iter->s_rw_ch * v_iter->sample_bytes * runtime->channels; - return 0; } @@ -454,8 +437,24 @@ static void pcmtst_pdev_release(struct device *dev) static int snd_pcmtst_pcm_prepare(struct snd_pcm_substream *substream) { + struct snd_pcm_runtime *runtime = substream->runtime; + struct pcmtst_buf_iter *v_iter = runtime->private_data; + if (inject_prepare_err) return -EINVAL; + + v_iter->sample_bytes = samples_to_bytes(runtime, 1); + v_iter->period_bytes = snd_pcm_lib_period_bytes(substream); + v_iter->interleaved = true; + if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED || + runtime->access == SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) { + v_iter->chan_block = snd_pcm_lib_buffer_bytes(substream) / runtime->channels; + v_iter->interleaved = false; + } + // We want to record RATE * ch_cnt samples per sec, it is rate * sample_bytes * ch_cnt bytes + v_iter->s_rw_ch = runtime->rate / TIMER_PER_SEC; + v_iter->b_rw = v_iter->s_rw_ch * v_iter->sample_bytes * runtime->channels; + return 0; } From patchwork Fri Aug 4 11:07:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13341749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E123C001DB for ; Fri, 4 Aug 2023 12:06:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2FA0A210; Fri, 4 Aug 2023 14:05:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2FA0A210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691150783; bh=/3l+NjXIbbuC0DxQ/dtsQSzNW40dtr7StE61YsTd3g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YZZx/JgjPa7nWgWD+O+FZxDJa8jFJzfS0COxEKDP0ugYewPI/NJ/wXIgvywW6LCNb CEvwpVjy/weWVQL+ZcWIafIRawmqg+16bJHaGn7MNcuWJ3L3PdBrAhPzG2uLYWdFnt af/OaBAzlMg4P6DCe1QeisHY1YQFWUGtmPrIfruQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A6D32F805AB; Fri, 4 Aug 2023 14:04:44 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 41B30F805A9; Fri, 4 Aug 2023 14:04:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A7657F8025A; Fri, 4 Aug 2023 13:08:27 +0200 (CEST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A930F8016D for ; Fri, 4 Aug 2023 13:08:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A930F8016D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=sb2OsCJg Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99c4e426714so54858166b.1 for ; Fri, 04 Aug 2023 04:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691147295; x=1691752095; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aIJ0wZyKm1oHflFxZiewsCGjiwbu4yH0OOsxMNtlRQA=; b=sb2OsCJg8rCGJP8ARVMIpqDdFxuEh/lmMRim5Tgv0J7OpP61Zf/j6HcfRydESLJ8kp O5KcX23un2JKdBMXiJVRyPBq2l7pFFBEii1FNpA5/6PuUSIJLYOunL+8cxF1H+rcx1Sq WhryHozOCkNhQKCMpNlz93T28ixJu02X94LB8/VF/cAv8zZShlRk9/vT4w5y2F38xktU eeEGRMzoL4yDny6/fIzJQKewUy7PrBDOdyjkjujfrb0Yr/recHXCPQa2TktcE28y5iW3 MJP3FfG/XM6tYdlm/oLtv6DMEEIagQSh2zgM/SNOQwZIG6rVPWrirP9w0VSu5561y9Y5 wUoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691147295; x=1691752095; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aIJ0wZyKm1oHflFxZiewsCGjiwbu4yH0OOsxMNtlRQA=; b=Iy2rbaAK4+3ImQAwwPM8vAhge6zOavXvvWo059h+L5tGFXFqQzPIvbIVsRdHxMIe15 0XEmBSs6MJXEvU51maV5a94YrRofMD2MXjuZ/d2VyZMtEvNL0vqlzM2GYMGLFl/GmAkF Qw5/bp5PU+oc047D67vcykZKGb3S8FmFv3agXbpt13aovBlOqeK0370qEGbTIWqoWdCq I4FMQHOj9UuZisRKpz+9D3wkZsqv1HPENKIJlKE1jEGoDXkwkP/SfRdinfE833YLJtIh HcYJRUiUpYpVK3SCnc5kLeu7PlvLskyu9sWvVEum9M/Z6TlupVk701s3RRDTKLz8mqUc CfCw== X-Gm-Message-State: AOJu0Yw+GPlb939KsChfFyxU6kkXmuieYhFvEmj9bx1BALczMi8Y1lyn elIUoQ3aXipQBLfFqtxscKI= X-Google-Smtp-Source: APBJJlFn3bAfpeUS7bFYzuP6M36OObpUhU8sV+Ubp+nPBglgSjjoO/M81TcUo5jlFHzdz8R+3q9F4g== X-Received: by 2002:a17:906:51d6:b0:99c:5711:3187 with SMTP id v22-20020a17090651d600b0099c57113187mr4463468ejk.6.1691147295122; Fri, 04 Aug 2023 04:08:15 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([178.160.196.94]) by smtp.gmail.com with ESMTPSA id bn10-20020a170906c0ca00b00992b0745548sm1149478ejb.152.2023.08.04.04.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 04:08:14 -0700 (PDT) From: Ivan Orlov To: perex@perex.cz, tiwai@suse.com Cc: Ivan Orlov , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] ALSA: pcmtest: Remove redundant definitions Date: Fri, 4 Aug 2023 15:07:40 +0400 Message-Id: <20230804110740.9867-2-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804110740.9867-1-ivan.orlov0322@gmail.com> References: <20230804110740.9867-1-ivan.orlov0322@gmail.com> MIME-Version: 1.0 X-MailFrom: ivan.orlov0322@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: ZOOF7GS456RP7ELLAUSMFHZOHEST47IL X-Message-ID-Hash: ZOOF7GS456RP7ELLAUSMFHZOHEST47IL X-Mailman-Approved-At: Fri, 04 Aug 2023 12:04:33 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Remove redundant definitions of DEVNAME and CARD_NAME, as they're not useful. The former is not used anywhere, and the latter is used only in module parameters descriptions. Signed-off-by: Ivan Orlov --- V1 -> V2: - Split changes in the patch into two different patches sound/drivers/pcmtest.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index dc7c9c758537..7f170429eb8f 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -41,8 +41,6 @@ #include #include -#define DEVNAME "pcmtestd" -#define CARD_NAME "pcm-test-card" #define TIMER_PER_SEC 5 #define TIMER_INTERVAL (HZ / TIMER_PER_SEC) #define DELAY_JIFFIES HZ @@ -74,11 +72,11 @@ static u8 ioctl_reset_test; static struct dentry *driver_debug_dir; module_param(index, int, 0444); -MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard"); +MODULE_PARM_DESC(index, "Index value for pcmtest soundcard"); module_param(id, charp, 0444); -MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard"); +MODULE_PARM_DESC(id, "ID string for pcmtest soundcard"); module_param(enable, bool, 0444); -MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); +MODULE_PARM_DESC(enable, "Enable pcmtest soundcard."); module_param(fill_mode, short, 0600); MODULE_PARM_DESC(fill_mode, "Buffer fill mode: rand(0) or pattern(1)"); module_param(inject_delay, int, 0600);