From patchwork Sun Sep 28 15:58:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 4992121 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 A4A349F1D4 for ; Sun, 28 Sep 2014 16:08:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 962E320270 for ; Sun, 28 Sep 2014 16:08:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 49A6620166 for ; Sun, 28 Sep 2014 16:08:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5B0882605A9; Sun, 28 Sep 2014 18:08:25 +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 82C0B260587; Sun, 28 Sep 2014 18:02:43 +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 B451826068D; Sun, 28 Sep 2014 18:02:42 +0200 (CEST) Received: from smtp301.phy.lolipop.jp (smtp301.phy.lolipop.jp [210.157.22.84]) by alsa0.perex.cz (Postfix) with ESMTP id 9400926057C for ; Sun, 28 Sep 2014 17:59:02 +0200 (CEST) Received: from smtp301.phy.lolipop.lan (HELO smtp301.phy.lolipop.jp) (172.17.1.84) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp301.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Mon, 29 Sep 2014 00:59:01 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp301.phy.lolipop.jp (LOLIPOP-Fsecure); Mon, 29 Sep 2014 00:58:24 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de Date: Mon, 29 Sep 2014 00:58:21 +0900 Message-Id: <1411919903-10981-12-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411919903-10981-1-git-send-email-o-takashi@sakamocchi.jp> References: <1411919903-10981-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 11/13] ALSA: dice: Support for non SYT-Match sampling clock source mode 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 This commit allows another mode. When sampling clock source is SYT-Match mode, devices handle 'presentation timestamp' in received packets and generates sampling clock according to the information. In this case, driver is synchronization master and must transfer correct value in SYT field of each packets in outgoing stream, then the outgoing stream is a master stream. On the other hand, non SYT-Match mode, devices do this. So drivers must pick up the value in SYT field of incoming packets and use the value for outgoing stream. Signed-off-by: Takashi Sakamoto --- sound/firewire/dice/dice-stream.c | 33 +++++++++++++++++++++------------ sound/firewire/dice/dice-transaction.c | 5 ----- sound/firewire/dice/dice.h | 2 -- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index d05178b..85ff927 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -163,9 +163,27 @@ end: static int get_sync_mode(struct snd_dice *dice, enum cip_flags *sync_mode) { - /* Currently, clock source is fixed at SYT-Match mode. */ - *sync_mode = 0; - return 0; + u32 source; + int err; + + err = snd_dice_transaction_get_clock_source(dice, &source); + if (err < 0) + goto end; + + switch (source) { + /* So-called 'SYT Match' modes, sync_to_syt value of packets received */ + case CLOCK_SOURCE_ARX4: /* in 4th stream */ + case CLOCK_SOURCE_ARX3: /* in 3rd stream */ + case CLOCK_SOURCE_ARX2: /* in 2nd stream */ + err = -ENOSYS; + case CLOCK_SOURCE_ARX1: /* in 1st stream */ + *sync_mode = 0; + break; + default: + *sync_mode = CIP_SYNC_TO_DEVICE; + } +end: + return err; } int snd_dice_stream_start_duplex(struct snd_dice *dice, unsigned int rate) @@ -322,15 +340,6 @@ int snd_dice_stream_init_duplex(struct snd_dice *dice) goto end; err = init_stream(dice, &dice->rx_stream); - if (err < 0) - goto end; - - /* Currently, clock source is fixed at SYT-Match mode. */ - err = snd_dice_transaction_set_clock_source(dice, CLOCK_SOURCE_ARX1); - if (err < 0) { - destroy_stream(dice, &dice->rx_stream); - destroy_stream(dice, &dice->tx_stream); - } end: return err; } diff --git a/sound/firewire/dice/dice-transaction.c b/sound/firewire/dice/dice-transaction.c index 3e76219..25bb66b 100644 --- a/sound/firewire/dice/dice-transaction.c +++ b/sound/firewire/dice/dice-transaction.c @@ -131,11 +131,6 @@ int snd_dice_transaction_get_clock_source(struct snd_dice *dice, return err; } -int snd_dice_transaction_set_clock_source(struct snd_dice *dice, - unsigned int source) -{ - return set_clock_info(dice, UINT_MAX, source); -} int snd_dice_transaction_get_rate(struct snd_dice *dice, unsigned int *rate) { diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h index a868485..8ea5cb4 100644 --- a/sound/firewire/dice/dice.h +++ b/sound/firewire/dice/dice.h @@ -152,8 +152,6 @@ static inline int snd_dice_transaction_read_sync(struct snd_dice *dice, buf, len); } -int snd_dice_transaction_set_clock_source(struct snd_dice *dice, - unsigned int source); int snd_dice_transaction_get_clock_source(struct snd_dice *dice, unsigned int *source); int snd_dice_transaction_set_rate(struct snd_dice *dice, unsigned int rate);