From patchwork Mon Jul 21 02:10:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 4592651 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 104379F375 for ; Mon, 21 Jul 2014 02:11:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 316C620120 for ; Mon, 21 Jul 2014 02:11:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 557C420115 for ; Mon, 21 Jul 2014 02:11:28 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5E4D126569F; Mon, 21 Jul 2014 04:11:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id BBE54265138; Mon, 21 Jul 2014 04:10:26 +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 8940B2650DA; Mon, 21 Jul 2014 04:10:24 +0200 (CEST) Received: from smtp303.phy.lolipop.jp (smtp303.phy.lolipop.jp [210.157.22.87]) by alsa0.perex.cz (Postfix) with ESMTP id 693862650DA for ; Mon, 21 Jul 2014 04:10:15 +0200 (CEST) Received: from smtp303.phy.lolipop.lan (HELO smtp303.phy.lolipop.jp) (172.17.1.87) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp303.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Mon, 21 Jul 2014 11:10:14 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp303.phy.lolipop.jp (LOLIPOP-Fsecure); Mon, 21 Jul 2014 11:10:07 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Mon, 21 Jul 2014 11:10:01 +0900 Message-Id: <1405908605-8105-3-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405908605-8105-1-git-send-email-o-takashi@sakamocchi.jp> References: <1405831835-26499-1-git-send-email-weiyj_lk@163.com> <1405908605-8105-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, darrena092@gmail.com, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 2/6] bebob: Reducing function callers for simplicity 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 M-Audio Firewire 1814 and ProjectMix I/O change their stream formation according to current digital format for input/output, although drivers cannot recognize current formation by any commands. Thus the drivers need to remember the formations. The special_stream_formation_set() is for this purpose. This function is expected to be called just after current digital formats are changed. The way to change current digital format is to call avc_maudio_set_special_clk() and there is no other ways. For simplicity, this commit make the avc_maudio_set_special_clk() as a sole caller for the special_stream_formation_set(). Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob_maudio.c | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c index 0a33045..83f8d5b 100644 --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c @@ -160,6 +160,35 @@ end: return err; } +static void +special_stream_formation_set(struct snd_bebob *bebob) +{ + static const unsigned int ch_table[2][2][3] = { + /* AMDTP_OUT_STREAM */ + { { 6, 6, 4 }, /* SPDIF */ + { 12, 8, 4 } }, /* ADAT */ + /* AMDTP_IN_STREAM */ + { { 10, 10, 2 }, /* SPDIF */ + { 16, 12, 2 } } /* ADAT */ + }; + struct special_params *params = bebob->maudio_special_quirk; + unsigned int i, max; + + max = SND_BEBOB_STRM_FMT_ENTRIES - 1; + if (!params->is1814) + max -= 2; + + for (i = 0; i < max; i++) { + bebob->tx_stream_formations[i + 1].pcm = + ch_table[AMDTP_IN_STREAM][params->dig_in_fmt][i / 2]; + bebob->tx_stream_formations[i + 1].midi = 1; + + bebob->rx_stream_formations[i + 1].pcm = + ch_table[AMDTP_OUT_STREAM][params->dig_out_fmt][i / 2]; + bebob->rx_stream_formations[i + 1].midi = 1; + } +} + /* * dig_fmt: 0x00:S/PDIF, 0x01:ADAT * clk_lock: 0x00:unlock, 0x01:lock @@ -212,6 +241,8 @@ avc_maudio_set_special_clk(struct snd_bebob *bebob, unsigned int clk_src, params->dig_out_fmt = buf[8]; params->clk_lock = buf[9]; + special_stream_formation_set(bebob); + if (params->ctl_id_sync) snd_ctl_notify(bebob->card, SNDRV_CTL_EVENT_MASK_VALUE, params->ctl_id_sync); @@ -221,34 +252,6 @@ end: kfree(buf); return err; } -static void -special_stream_formation_set(struct snd_bebob *bebob) -{ - static const unsigned int ch_table[2][2][3] = { - /* AMDTP_OUT_STREAM */ - { { 6, 6, 4 }, /* SPDIF */ - { 12, 8, 4 } }, /* ADAT */ - /* AMDTP_IN_STREAM */ - { { 10, 10, 2 }, /* SPDIF */ - { 16, 12, 2 } } /* ADAT */ - }; - struct special_params *params = bebob->maudio_special_quirk; - unsigned int i, max; - - max = SND_BEBOB_STRM_FMT_ENTRIES - 1; - if (!params->is1814) - max -= 2; - - for (i = 0; i < max; i++) { - bebob->tx_stream_formations[i + 1].pcm = - ch_table[AMDTP_IN_STREAM][params->dig_in_fmt][i / 2]; - bebob->tx_stream_formations[i + 1].midi = 1; - - bebob->rx_stream_formations[i + 1].pcm = - ch_table[AMDTP_OUT_STREAM][params->dig_out_fmt][i / 2]; - bebob->rx_stream_formations[i + 1].midi = 1; - } -} static int add_special_controls(struct snd_bebob *bebob); int @@ -280,8 +283,6 @@ snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814) if (err < 0) goto end; - special_stream_formation_set(bebob); - if (params->is1814) { bebob->midi_input_ports = 1; bebob->midi_output_ports = 1; @@ -513,7 +514,6 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl, dev_err(&bebob->unit->device, "fail to set digital input interface: %d\n", err); end: - special_stream_formation_set(bebob); mutex_unlock(&bebob->mutex); return err; }