From patchwork Sun Nov 20 17:36:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 9438561 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 AFC0F60235 for ; Sun, 20 Nov 2016 17:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A419028904 for ; Sun, 20 Nov 2016 17:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FA8289B3; Sun, 20 Nov 2016 17:36:49 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 3C88B28904 for ; Sun, 20 Nov 2016 17:36:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753146AbcKTRgr (ORCPT ); Sun, 20 Nov 2016 12:36:47 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37240 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753032AbcKTRgq (ORCPT ); Sun, 20 Nov 2016 12:36:46 -0500 Received: by mail-wm0-f49.google.com with SMTP id t79so109584042wmt.0 for ; Sun, 20 Nov 2016 09:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2nsfb4zQaVw1ZgEZE1T7aBkFQ8A0UMmjl9lqrF0OBK8=; b=eH3tz2eXxorMWDesxmba/vEBeeAh4rKulnmN574Db1UbS8q0WXQrdnCNq2dRYJN3f8 uqrDqNInH/IdhgoTlIHkQDX8GGryA2jbLyqRr6Dy1SAoCyAzsoy8AL6+XMv7lp4rhN4F /aNn4MgAiddjJraQvnaQs9X7jI1lj/7GvpGlWK4i+yOGuMeehJnb06Az2t46SNMRxhQz SgcVnyXCwGyoyxp2QAW89dHaeXPJbthM/z4HKX6PVZTvcxFJwLJiao9ORdbdaNUVTnap AlH0EtXqLrxnvgcKH29A3FTEXdaHTXuzS8QQV4QgXwUWrL9f09leh/vNn3d7jCxXpMI0 2Q2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2nsfb4zQaVw1ZgEZE1T7aBkFQ8A0UMmjl9lqrF0OBK8=; b=OH9l079GX6HlDYu/qfR6usXGjGcNiO5YDm67BTSyzxMjQjssaGDki7mHcecd+5kpWF wZxu8o2YXPpzaKeKTeW0evAI70db1VDckFGTpsN/SOYoc1rXlslC81Ans/mXEvJzWAV1 BG39SpqnKyP7U1t44SfeBcJ0aNnB8JErHVD9HsVEOQu+8VKf4bblN4c1gyYd1QXT+k0p JAY1bmneOFFBrZ2AFmZXliPN8M9MbGbd7M+wHdqCSr28XqQ6qeNBY26+sA73pmq5bKug MZUjD+3TvVVDFJZE7AC282d8HwLOZhrucMc5j0n7tPpBmHTNaOfd/WSlq2HerQ20566w 6xOQ== X-Gm-Message-State: AKaTC01JXYuAiDAXb4kUVerv7DNcSmGjSRR8wrhs/oV8GioXmeWX7jSQGfbZzVnxe36SjQVPvNkfirDoUWvJyw== X-Received: by 10.28.139.12 with SMTP id n12mr9179539wmd.79.1479663405219; Sun, 20 Nov 2016 09:36:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.157.69 with HTTP; Sun, 20 Nov 2016 09:36:44 -0800 (PST) In-Reply-To: <20161027203454.GA32566@arch-desktop> References: <20161027203454.GA32566@arch-desktop> From: Ezequiel Garcia Date: Sun, 20 Nov 2016 14:36:44 -0300 Message-ID: Subject: Re: [PATCH v2 2/3] stk1160: Check whether to use AC97 codec or internal ADC. To: Marcel Hasler Cc: Mauro Carvalho Chehab , linux-media , Hans Verkuil 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 On 27 October 2016 at 17:34, Marcel Hasler wrote: > Some STK1160-based devices use the chip's internal 8-bit ADC. This is configured through a strap > pin. The value of this and other pins can be read through the POSVA register. If the internal > ADC is used, there's no point trying to setup the unavailable AC97 codec. > > Signed-off-by: Marcel Hasler > --- > drivers/media/usb/stk1160/stk1160-ac97.c | 15 +++++++++++++++ > drivers/media/usb/stk1160/stk1160-core.c | 3 +-- > drivers/media/usb/stk1160/stk1160-reg.h | 3 +++ > 3 files changed, 19 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c > index d3665ce..6dbc39f 100644 > --- a/drivers/media/usb/stk1160/stk1160-ac97.c > +++ b/drivers/media/usb/stk1160/stk1160-ac97.c > @@ -90,8 +90,23 @@ void stk1160_ac97_dump_regs(struct stk1160 *dev) > } > #endif > > +int stk1160_has_ac97(struct stk1160 *dev) > +{ > + u8 value; > + > + stk1160_read_reg(dev, STK1160_POSVA, &value); > + > + /* Bit 2 high means internal ADC */ > + return !(value & 0x04); How about define a macro such as: > +} > + > void stk1160_ac97_setup(struct stk1160 *dev) > { > + if (!stk1160_has_ac97(dev)) { > + stk1160_info("Device uses internal 8-bit ADC, skipping AC97 setup."); > + return; > + } > + > /* Two-step reset AC97 interface and hardware codec */ > stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x94); > stk1160_write_reg(dev, STK1160_AC97CTL_0, 0x8c); > diff --git a/drivers/media/usb/stk1160/stk1160-core.c b/drivers/media/usb/stk1160/stk1160-core.c > index f3c9b8a..c86eb61 100644 > --- a/drivers/media/usb/stk1160/stk1160-core.c > +++ b/drivers/media/usb/stk1160/stk1160-core.c > @@ -20,8 +20,7 @@ > * > * TODO: > * > - * 1. (Try to) detect if we must register ac97 mixer > - * 2. Support stream at lower speed: lower frame rate or lower frame size. > + * 1. Support stream at lower speed: lower frame rate or lower frame size. > * > */ > > diff --git a/drivers/media/usb/stk1160/stk1160-reg.h b/drivers/media/usb/stk1160/stk1160-reg.h > index 81ff3a1..a4ab586 100644 > --- a/drivers/media/usb/stk1160/stk1160-reg.h > +++ b/drivers/media/usb/stk1160/stk1160-reg.h > @@ -26,6 +26,9 @@ > /* Remote Wakup Control */ > #define STK1160_RMCTL 0x00c > > +/* Power-on Strapping Data */ > +#define STK1160_POSVA 0x010 > + > /* > * Decoder Control Register: > * This byte controls capture start/stop > -- > 2.10.1 > diff --git a/drivers/media/usb/stk1160/stk1160-reg.h b/drivers/media/usb/stk1160/stk1160-reg.h index a4ab586fcee1..4922249d7d34 100644 --- a/drivers/media/usb/stk1160/stk1160-reg.h +++ b/drivers/media/usb/stk1160/stk1160-reg.h @@ -28,6 +28,7 @@ /* Power-on Strapping Data */ #define STK1160_POSVA 0x010 +#define STK1160_POSVA_ACSYNC BIT(2) Also, the spec mentions another POSVA bit relevant to audio ACDOUT. Should we check that too?