From patchwork Sun Apr 25 22:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 12223585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1A6AC433B4 for ; Sun, 25 Apr 2021 22:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C20860FE6 for ; Sun, 25 Apr 2021 22:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbhDYWzK (ORCPT ); Sun, 25 Apr 2021 18:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbhDYWzK (ORCPT ); Sun, 25 Apr 2021 18:55:10 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CDF9C061574 for ; Sun, 25 Apr 2021 15:54:30 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id q10so38852228pgj.2 for ; Sun, 25 Apr 2021 15:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dWeumecOlzaTnNiLr/75eCpPCCfDMWcbNrYIXDgpfzU=; b=QOsTw+jGybkpPfShXgI1yzdlvSRcKYziG5DnLju7iOqRdFytL+e35iGFAQ812rgRrM GaLC3oHsjCMoJpUnCA4yBj6QUijNCc1Kh0qIvPc0DGM6ZYbVfKEoWj4B2wGmdQdZER3I sO497T10PLvxNc432VEXZHj0tYjAi5mD3ts8UtON6jL/hT2JjmvsFWq/D+Z6KH/HNbnV LX7f6iarxHoVjKot0MBpsYpRiRDJzWawtgg/CfdAYooCj2Jiu7pQOwCuAZfVGHy+vwCB 4uFhUSXJAEGDva6KjQeIu3mt6x5vlucLVj/4450HIg6F9S1xnW7cGj7SAEwq1mifN8NC 5GUg== 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:in-reply-to:references; bh=dWeumecOlzaTnNiLr/75eCpPCCfDMWcbNrYIXDgpfzU=; b=ieWwiLWwISu2E/be7xqhHafhluo6N8WmkkrVss5BxF/2j6aa6xhlj03obRiz5ob7ci Z9XlPA6Q0AZ56TyUJopnsTLk1SWZtjVfVZdbB+YYPej+ZXqKPsSd1hlu6dtk9BN/Tou3 ct2mXQtKuP8iWYP+fliQwWPy/6S/9RTTmNBBeXa7jyt0ifJ1GgwzGovW5RdzVnMsQISW HvwK6nYVNuaEWrfAgOxYHBBBZV6Cq3D2JBBrUYAuQAm+eqmRibkGUKoaG575E7eJSMXh w+mzggYxo2uUn2iIeuVGi53yTVm6VgmDldKdbFqfJvleeMwA7xwv+yhnxBv1ksa5cqKd dl7w== X-Gm-Message-State: AOAM5304kf01xoby5VWRKiH7ZJVVQE2SroqjA83k5uuch9JkjS9fCSRQ iLn1IVZzSDL8V35uRN9e0oKMFeqf22MjWA== X-Google-Smtp-Source: ABdhPJw+GmtBGNAWixVMxQo07P07V5FLR12vcCXTQKrmqvjO0YtPIoIJQn8YOUDZKdBj/NgIaRLxqw== X-Received: by 2002:a63:7a4e:: with SMTP id j14mr11132516pgn.18.1619391269970; Sun, 25 Apr 2021 15:54:29 -0700 (PDT) Received: from djbComp.hitronhub.home (S0106ac202ecb0523.gv.shawcable.net. [70.67.120.89]) by smtp.gmail.com with ESMTPSA id s22sm9504207pfe.150.2021.04.25.15.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 15:54:29 -0700 (PDT) From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, Deborah Brouwer Subject: [PATCH v2 1/2] cec-follower: increase precision of Audio Rate Control active sensing Date: Sun, 25 Apr 2021 15:54:06 -0700 Message-Id: <359f2292a67679b5dab5d9d1fda280bc80f34c40.1619389023.git.deborahbrouwer3563@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Measure the interval since the last audio rate control message in nanoseconds instead of seconds. Increasing the precision catches audio rate messages that are late by less than a second. Signed-off-by: Deborah Brouwer --- utils/cec-follower/cec-processing.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp index 93db4059..243c9d09 100644 --- a/utils/cec-follower/cec-processing.cpp +++ b/utils/cec-follower/cec-processing.cpp @@ -29,8 +29,8 @@ /* Time between each polling message sent to a device */ #define POLL_PERIOD 15000 -/* The maximum interval in seconds between audio rate messages as defined in the spec */ -#define MAX_AUD_RATE_MSG_INTERVAL 2 +/* The maximum interval in nanoseconds between audio rate messages as defined in the spec */ +#define MAX_AUD_RATE_MSG_INTERVAL 2000000000 struct cec_enum_values { const char *type_name; @@ -241,7 +241,8 @@ static void aud_rate_msg_interval_check(__u64 ts_new, __u64 ts_old) * turned off the audio rate control. */ if (ts_old) { - unsigned interval = (ts_new - ts_old) / 1000000000; + __u64 interval = ts_new - ts_old; + if (interval > MAX_AUD_RATE_MSG_INTERVAL) { warn("The interval between Audio Rate Control messages was greater\n"); warn("than the Maxiumum Audio Rate Message Interval (2s).\n"); From patchwork Sun Apr 25 22:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 12223587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66FB1C433ED for ; Sun, 25 Apr 2021 22:54:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4243F6134F for ; Sun, 25 Apr 2021 22:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231422AbhDYWzP (ORCPT ); Sun, 25 Apr 2021 18:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbhDYWzP (ORCPT ); Sun, 25 Apr 2021 18:55:15 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B67AC061574 for ; Sun, 25 Apr 2021 15:54:34 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id q10so38852290pgj.2 for ; Sun, 25 Apr 2021 15:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+Pib14yGX41Z5j4qi52XiY8kNCRo5YcvC2plJhDcbf8=; b=p7jh8GTHORWGSRdm4UqTzcZiVQ7NsRjRqPfALZoAU9j7OxJRISix9DFNmis6GVB3ty 2yu8ytf3rDhbZ+sZI6ZEHxsbTKvJvGtcRvDT0Ztw5nEK0kjHUYiWAENFFIcfs4DxJHE4 pZTEPd/LVNt8wyUyvhJJ35Hgg7JvmRAjZpVRC8SmR5oHJbf05i2Qoa+4jK8d+5myBhyA GpRElpCE1ecDcjfhIk1d+97aHAsc56tnAnY8tx4MHhUISFb/zO6B6axKN5JWYR3aDCKu C3mIBoiucFPmvxn1Yv/TDQ+IRaOXDKCaKDRmfj1X9YilC7+75eTLQEv58LrS6oi2Vzok L70g== 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:in-reply-to:references; bh=+Pib14yGX41Z5j4qi52XiY8kNCRo5YcvC2plJhDcbf8=; b=XBw3fUSn2P1f4DnsE3mR1NK7otXlSZ69SDZzlz8tvgz6w6+T88evg0vRRUOOLmcWWi lopYRwZXPNyRRDvWIYWWV+H/7mEzeC6E23yYIj+daTndP10dBkh0Nffce7SIRf4+IB12 juHcvA3N+Ai3ueZTVBFTk8oMew+uIHzOVDCxG0is7Qg55hTVPRrGBph94XrnCHGgwrDh fvXgKnDC/kp0JV7wd0Z+rFFLRhQHemZjrq/xY8V12mL08mup3EFcahbllvofSo7It18/ tFyvF3B+xm5Idv9iIgn/JlY73k52vAt3VraNgxFUA69yiZ43P8Uqde+skfQTDP13SNg6 YjXg== X-Gm-Message-State: AOAM53104vSR83bxugC0tFIwg9BVj45Y+jv2dp9FCwjJ7GNWo+1WWvT8 AKq7k7W75z7I20IxjwU8aunnucOP4oxL3w== X-Google-Smtp-Source: ABdhPJzidb/IWqAL7VDUdGW0x6jD6HmzYW10WsDa0al21U9e2MkzXWyF6VH2nxrDxVEipB2+W0jJcg== X-Received: by 2002:a62:7592:0:b029:254:ebcd:802b with SMTP id q140-20020a6275920000b0290254ebcd802bmr14556049pfc.41.1619391274267; Sun, 25 Apr 2021 15:54:34 -0700 (PDT) Received: from djbComp.hitronhub.home (S0106ac202ecb0523.gv.shawcable.net. [70.67.120.89]) by smtp.gmail.com with ESMTPSA id s22sm9504207pfe.150.2021.04.25.15.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 15:54:33 -0700 (PDT) From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, Deborah Brouwer Subject: [PATCH v2 2/2] cec-follower: detect the cessation of Audio Rate Control messages Date: Sun, 25 Apr 2021 15:54:07 -0700 Message-Id: <03c855c4a2072a4a174415198e2e44932af75fcd.1619389023.git.deborahbrouwer3563@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the controlling device simply stops sending audio rate messages, give the cec-follower the ability to detect that it has not received an audio rate message within 2 seconds as required. The cec-follower will quit the audio rate controlled mode. Eliminate the need to measure an interval between two audio rate messages. Signed-off-by: Deborah Brouwer --- utils/cec-follower/cec-processing.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp index 243c9d09..dd6fd05c 100644 --- a/utils/cec-follower/cec-processing.cpp +++ b/utils/cec-follower/cec-processing.cpp @@ -233,19 +233,22 @@ static __u8 current_power_state(struct node *node) return CEC_OP_POWER_STATUS_TO_STANDBY; } -static void aud_rate_msg_interval_check(__u64 ts_new, __u64 ts_old) +static void aud_rate_msg_interval_check(struct node *node, __u64 ts_new) { /* - * The interval between messages is not relevant if this is the - * first audio rate control message or if the previous message - * turned off the audio rate control. + * The interval since the last audio rate message is not relevant + * unless the Source is currently in audio rate controlled mode. */ + __u64 ts_old = node->state.last_aud_rate_rx_ts; + if (ts_old) { __u64 interval = ts_new - ts_old; if (interval > MAX_AUD_RATE_MSG_INTERVAL) { - warn("The interval between Audio Rate Control messages was greater\n"); + warn("The interval since the last Audio Rate Control message was greater\n"); warn("than the Maxiumum Audio Rate Message Interval (2s).\n"); + warn("Turning off audio rate control.\n"); + node->state.last_aud_rate_rx_ts = 0; } } } @@ -803,7 +806,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) switch (msg.msg[2]) { case CEC_OP_AUD_RATE_OFF: - aud_rate_msg_interval_check(msg.rx_ts, node->state.last_aud_rate_rx_ts); + aud_rate_msg_interval_check(node, msg.rx_ts); node->state.last_aud_rate_rx_ts = 0; return; case CEC_OP_AUD_RATE_WIDE_STD: @@ -812,7 +815,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me) case CEC_OP_AUD_RATE_NARROW_STD: case CEC_OP_AUD_RATE_NARROW_FAST: case CEC_OP_AUD_RATE_NARROW_SLOW: - aud_rate_msg_interval_check(msg.rx_ts, node->state.last_aud_rate_rx_ts); + aud_rate_msg_interval_check(node, msg.rx_ts); node->state.last_aud_rate_rx_ts = msg.rx_ts; return; default: @@ -1034,6 +1037,9 @@ void testProcessing(struct node *node, bool wallclock) node->state.rc_state = NOPRESS; } } + + if (node->has_aud_rate) + aud_rate_msg_interval_check(node, ts_now); } mode = CEC_MODE_INITIATOR; doioctl(node, CEC_S_MODE, &mode);