From patchwork Sun Nov 27 11:12:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Hasler X-Patchwork-Id: 9448753 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 748206071C for ; Sun, 27 Nov 2016 11:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FECB20748 for ; Sun, 27 Nov 2016 11:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63D472623C; Sun, 27 Nov 2016 11:12:45 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04E3420748 for ; Sun, 27 Nov 2016 11:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753840AbcK0LMm (ORCPT ); Sun, 27 Nov 2016 06:12:42 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:34264 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753640AbcK0LMm (ORCPT ); Sun, 27 Nov 2016 06:12:42 -0500 Received: by mail-wj0-f195.google.com with SMTP id xy5so10599365wjc.1 for ; Sun, 27 Nov 2016 03:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to:user-agent; bh=XTdZizyFtwo4sHcVhDJMXNP9ImQ1/wDx63wKLgYyc74=; b=ZJaNSSCBoWhN+n4MvaBvlZ7XjCeanYldKX04MBRyoJFuUY91NlwhKynSR4nJAMMpIU saq2d/zBhIMd9PxvTDUm3ocNLo0aO+gY8hQ+uWb7fxeL1V/MIr9zev4Mzfwv0BpML5N7 yf/z5o4qr+xqWrgXv2UkPd/EEY83gVFDrqvh/v2+2JrEz7m42JWURJjW9mbAlcl3qDwg gHr76wnCsL0ezl/HDZtFfJA9RQe+4r0KYoUKWIZ5Er/5vImSvF1/9Vx76w4F99BJ4rdG MJKXu6JjxbgnRGxo0ieWQnF6EHZEbSjk5/MZulf2XbektmRbfD4uM6sZ4ZczTBt46PGs iS7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to:user-agent; bh=XTdZizyFtwo4sHcVhDJMXNP9ImQ1/wDx63wKLgYyc74=; b=iXqcHUCiXSSpXx0yGo8UXzT3h2SbcB7qFAdxdJlHIRaSghGo29G6PaxJi0K7xnKhxo J2b4kFUDWxbzhwE40va/l07SGm4/KgnaQwhVhYoumRpP1S0ptD4AMJ96IB+lFr58W/lF +lpSikGLfcJ92FuVtObGBT6mhlT8BEuy1fLBhaqVJ+VUl+KdIk9wfZdcix9zxD8F28j+ 2Xn9cMIGFKr2ZxWppjvFqk6QDtpivAkwgKVCIFdI7hlOm7BF0P47HIrUAyvJTMF3YcYk 3cmqMPfrLeA/5uNRRiVM70GreFiIYz8GrIIYODTGZ57BwC3bqLkblw/UJpchr9oUI25L sAtA== X-Gm-Message-State: AKaTC03UZnixSTX/tEmZp0d8IDSn1HwHSOecqVDYLEB4c/IvSs5sY8JxMtZ0kbYXNcHrTA== X-Received: by 10.194.99.38 with SMTP id en6mr14515238wjb.184.1480245160572; Sun, 27 Nov 2016 03:12:40 -0800 (PST) Received: from arch-desktop ([2a02:908:678:0:728b:cdff:fe7f:6af7]) by smtp.gmail.com with ESMTPSA id j6sm56829231wjk.25.2016.11.27.03.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Nov 2016 03:12:40 -0800 (PST) Date: Sun, 27 Nov 2016 12:12:36 +0100 From: Marcel Hasler To: Ezequiel Garcia , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Subject: [PATCH v3 4/4] stk1160: Give the chip some time to retrieve data from AC97 codec. Message-ID: <20161127111236.GA1691@arch-desktop> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161127110732.GA5338@arch-desktop> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The STK1160 needs some time to transfer data from the AC97 registers into its own. On some systems reading the chip's own registers to soon will return wrong values. The "proper" way to handle this would be to poll STK1160_AC97CTL_0 after every read or write command until the command bit has been cleared, but this may not be worth the hassle. Signed-off-by: Marcel Hasler --- drivers/media/usb/stk1160/stk1160-ac97.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c index 60327af..b39f51b 100644 --- a/drivers/media/usb/stk1160/stk1160-ac97.c +++ b/drivers/media/usb/stk1160/stk1160-ac97.c @@ -23,6 +23,7 @@ * */ +#include #include #include "stk1160.h" @@ -64,6 +65,14 @@ static u16 stk1160_read_ac97(struct stk1160 *dev, u16 reg) */ stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8b); + /* + * Give the chip some time to transfer the data. + * The proper way would be to poll STK1160_AC97CTL_0 + * until the command bit has been cleared, but this + * may not be worth the hassle. + */ + usleep_range(20, 40); + /* Retrieve register value */ stk1160_read_reg(dev, STK1160_AC97_CMD, &vall); stk1160_read_reg(dev, STK1160_AC97_CMD + 1, &valh);