From patchwork Sun Apr 29 06:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10370475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A06960384 for ; Sun, 29 Apr 2018 06:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED6EF28A44 for ; Sun, 29 Apr 2018 06:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E03F828BE4; Sun, 29 Apr 2018 06:52:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1474228A44 for ; Sun, 29 Apr 2018 06:52:51 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 915AD2678FB; Sun, 29 Apr 2018 08:51:42 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1185726765E; Sun, 29 Apr 2018 08:51:32 +0200 (CEST) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by alsa0.perex.cz (Postfix) with ESMTP id 1D1E2267653 for ; Sun, 29 Apr 2018 08:51:28 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id a11so4438329pfn.9 for ; Sat, 28 Apr 2018 23:51:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BGjpz4R1AXxJgmt4yANeniW2/4pCMblwhhGAAXryq0k=; b=iwjPzht5xW6igeXoOjxNPln3j86GklNbI0ai9tMC20Kmto1wRygfLPgiyWiD3jywuJ CMgDca3x8Z/nSV/EEjeSiaqFTuNpIS62EkkTcJqa7+CYiUNVu4nqxa5InPBMrDFXUa7+ umzhnlONpqdFQp4C1Pzs7eRDWZb6nyAtS4Z3V0xgzC5RwuQWtPuYlDubkRP6JvuSPdyH rPcagSITB2GMqxeDow0aXAOjs1TWFJzS8Xvll8JGClMnDWuzhZiA1SmDx0Dt2ilB2344 gC4qT399vzVJpbCi9cm9qO7boA57UBew8csxbMhLnL7/ujb6TRkRDA7n/SucSqJcSedW YJMg== X-Gm-Message-State: ALQs6tA/StTor7akjCCAO7chvu/1IUU1kQK2lIr3Rto9JKEiXE4Ljl+b Q0LVqApcBZGjOaMXG97u1cE= X-Google-Smtp-Source: AB8JxZrtM6Gc+KApqxlxV8WLeRpKaQQK2+cI4QRlK97VCiHD0JFpycC2xaLf18p2lShk+YHbVnVF7g== X-Received: by 2002:a17:902:8c83:: with SMTP id t3-v6mr4360241plo.357.1524984688182; Sat, 28 Apr 2018 23:51:28 -0700 (PDT) Received: from localhost.localdomain (i196238.dynamic.ppp.asahi-net.or.jp. [61.125.196.238]) by smtp.gmail.com with ESMTPSA id t80sm10985206pfg.0.2018.04.28.23.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Apr 2018 23:51:27 -0700 (PDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 29 Apr 2018 15:50:32 +0900 Message-Id: <20180429065032.13869-14-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180429065032.13869-1-o-takashi@sakamocchi.jp> References: <20180429065032.13869-1-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH v2 13/13] ALSA: dice: remove local frag of force_two_pcms X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP At present, to add PCM substreams for each of available tx/rx streams, this driver uses a condition based on model-name. This is not enough to support unknown models. In former commits, this driver gains cache of stream formats. For models which support protocol extension, all of available steam formats are cached. For known models, hard-coded stream formats are used to generate the cache. For unknown models, stream formats at current mode of sampling transmission frequency is cached. Anyway, at least, the cached formats are used to expose constrains of PCM substreams for userspace applications. Thus, The cached data can be also used to add PCM substreams themselves, instead of the name-based conditions. This commit obsoletes local frag of force_two_pcms. Signed-off-by: Takashi Sakamoto --- sound/firewire/dice/dice-pcm.c | 38 ++++++++------------------------------ sound/firewire/dice/dice.c | 38 -------------------------------------- sound/firewire/dice/dice.h | 2 -- 3 files changed, 8 insertions(+), 70 deletions(-) diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index d0c323e16a39..8e06f7234e82 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -425,40 +425,18 @@ int snd_dice_create_pcm(struct snd_dice *dice) .mmap = snd_pcm_lib_mmap_vmalloc, }; struct snd_pcm *pcm; - unsigned int i, max_capture, max_playback, capture, playback; + unsigned int capture, playback; + int i, j; int err; - /* Check whether PCM substreams are required. */ - if (dice->force_two_pcms) { - max_capture = max_playback = 2; - } else { - int j; - max_capture = max_playback = 0; - for (i = 0; i < MAX_STREAMS; ++i) { - for (j = 0; j < 3; ++j) { - if (dice->tx_pcm_chs[i][j] > 0) { - ++max_capture; - break; - } - } - - for (j = 0; j < 3; ++j) { - if (dice->rx_pcm_chs[i][j] > 0) { - ++max_playback; - break; - } - } - } - } - for (i = 0; i < MAX_STREAMS; i++) { capture = playback = 0; - if (i < max_capture) - capture = 1; - if (i < max_playback) - playback = 1; - if (capture == 0 && playback == 0) - break; + for (j = 0; j < 3; ++j) { + if (dice->tx_pcm_chs[i][j] > 0) + capture = 1; + if (dice->rx_pcm_chs[i][j] > 0) + playback = 1; + } err = snd_pcm_new(dice->card, "DICE", i, playback, capture, &pcm); diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c index 6d55a62ec89e..40f7a32e4893 100644 --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c @@ -24,36 +24,6 @@ MODULE_LICENSE("GPL v2"); #define MODEL_ALESIS_IO_BOTH 0x000001 -/* - * Some models support several isochronous channels, while these streams are not - * always available. In this case, add the model name to this list. - */ -static bool force_two_pcm_support(struct fw_unit *unit) -{ - static const char *const models[] = { - /* TC Electronic models. */ - "StudioKonnekt48", - /* Focusrite models. */ - "SAFFIRE_PRO_40", - "LIQUID_SAFFIRE_56", - "SAFFIRE_PRO_40_1", - }; - char model[32]; - unsigned int i; - int err; - - err = fw_csr_string(unit->directory, CSR_MODEL, model, sizeof(model)); - if (err < 0) - return false; - - for (i = 0; i < ARRAY_SIZE(models); i++) { - if (strcmp(models[i], model) == 0) - break; - } - - return i < ARRAY_SIZE(models); -} - static int check_dice_category(struct fw_unit *unit) { struct fw_device *device = fw_parent_device(unit); @@ -79,11 +49,6 @@ static int check_dice_category(struct fw_unit *unit) } } - if (vendor == OUI_FOCUSRITE || vendor == OUI_TCELECTRONIC) { - if (force_two_pcm_support(unit)) - return 0; - } - if (vendor == OUI_WEISS) category = WEISS_CATEGORY_ID; else if (vendor == OUI_LOUD) @@ -190,9 +155,6 @@ static void do_registration(struct work_struct *work) if (err < 0) return; - if (force_two_pcm_support(dice->unit)) - dice->force_two_pcms = true; - err = snd_dice_transaction_init(dice); if (err < 0) goto error; diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h index 7b1e2396eadc..0f5927e89bc9 100644 --- a/sound/firewire/dice/dice.h +++ b/sound/firewire/dice/dice.h @@ -106,8 +106,6 @@ struct snd_dice { bool global_enabled; struct completion clock_accepted; unsigned int substreams_counter; - - bool force_two_pcms; }; enum snd_dice_addr_type {