From patchwork Sat Feb 13 18:47:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 8300631 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0533A9F399 for ; Sat, 13 Feb 2016 18:47:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CC1B2041E for ; Sat, 13 Feb 2016 18:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B6A42041F for ; Sat, 13 Feb 2016 18:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751223AbcBMSry (ORCPT ); Sat, 13 Feb 2016 13:47:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36547 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbcBMSry (ORCPT ); Sat, 13 Feb 2016 13:47:54 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 29CF5C0C2344 for ; Sat, 13 Feb 2016 18:47:54 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-4-73.ams2.redhat.com [10.36.4.73]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1DIlejR011443; Sat, 13 Feb 2016 13:47:52 -0500 From: Hans de Goede To: Linux Media Mailing List Cc: Hans de Goede Subject: [PATCH tvtime 06/17] mute: Delay unmute on signal lock to give msp3400 time to sync Date: Sat, 13 Feb 2016 19:47:27 +0100 Message-Id: <1455389258-13470-6-git-send-email-hdegoede@redhat.com> In-Reply-To: <1455389258-13470-1-git-send-email-hdegoede@redhat.com> References: <1455389258-13470-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Delay unmute on signal lock, this fixes a loud plop sound on changing channels on cards with a msp3400 stereo sound decoder. Signed-off-by: Hans de Goede --- src/videoinput.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/videoinput.c b/src/videoinput.c index 0af6ab7..f66a35e 100644 --- a/src/videoinput.c +++ b/src/videoinput.c @@ -123,6 +123,12 @@ int videoinput_get_time_per_field( int norm ) } } +static int videoinput_get_unmute_delay( int norm ) +{ + /* The msp3400 needs some time before it provides stable audio */ + return 400000 / videoinput_get_time_per_field( norm ); +} + typedef struct capture_buffer_s { struct v4l2_buffer vidbuf; @@ -158,6 +164,7 @@ struct videoinput_s int hasaudio; int audiomode; int change_muted; + int change_muted_delay; int user_muted; int hw_muted; @@ -360,6 +367,7 @@ videoinput_t *videoinput_new( config_t *cfg, int norm, int verbose, vidin->signal_recover_wait = 0; vidin->signal_acquire_wait = 0; vidin->change_muted = 1; + vidin->change_muted_delay = videoinput_get_unmute_delay( norm ); vidin->user_muted = user_muted; vidin->hw_muted = 1; vidin->hasaudio = 1; @@ -752,6 +760,7 @@ void videoinput_set_tuner_freq( videoinput_t *vidin, int freqKHz ) } vidin->change_muted = 1; + vidin->change_muted_delay = videoinput_get_unmute_delay( vidin->norm ); videoinput_do_mute( vidin ); vidin->cur_tuner_state = TUNER_STATE_SIGNAL_DETECTED; vidin->signal_acquire_wait = SIGNAL_ACQUIRE_DELAY; @@ -921,7 +930,7 @@ int videoinput_check_for_signal( videoinput_t *vidin, int check_freq_present ) vidin->cur_tuner_state = TUNER_STATE_HAS_SIGNAL; } default: - if( vidin->change_muted ) { + if( vidin->change_muted && --vidin->change_muted_delay == 0 ) { vidin->change_muted = 0; videoinput_do_mute( vidin ); } @@ -934,6 +943,7 @@ int videoinput_check_for_signal( videoinput_t *vidin, int check_freq_present ) vidin->cur_tuner_state = TUNER_STATE_SIGNAL_LOST; vidin->signal_recover_wait = SIGNAL_RECOVER_DELAY; vidin->change_muted = 1; + vidin->change_muted_delay = videoinput_get_unmute_delay( vidin->norm ); videoinput_do_mute( vidin ); case TUNER_STATE_SIGNAL_LOST: if( vidin->signal_recover_wait ) {