From patchwork Fri Nov 2 21:11:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150083 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2542308ljp; Fri, 2 Nov 2018 14:11:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5dRyDTykNtXnRQjVraWo7ODeunDcAVlAf5cwNFsNGslJbiIDU733eOlW5qC7ewY12XQlzIJ X-Received: by 2002:adf:df0a:: with SMTP id y10-v6mr10746472wrl.127.1541193111178; Fri, 02 Nov 2018 14:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541193111; cv=none; d=google.com; s=arc-20160816; b=fQHl1ZAgWXmhzBSty2OJIHzpu5Unf7+97YHt/iaE8aMzLEF6nMz1uj2XFPGOKghGK1 4rT2mi7ufptDgRuDpULTEcS3V+P7plzR3caCKDg0LgkUtqmt8zOaxDE7rc1FMy6KQ4kt gvwyfZOcyx2HFQkZPtxFIoTTuM2cdK1PMhnrb6huquCHCRXajlyO/JKO+CEZ+L9QT0au uKJXRH77W1jZekzfbzNxx6nKOFcjYVME1LVtURhL3DFljUBFmqnraI3Y2fy42CXGKQsa EPXRvos+C0bxC9bRhdLyrE62IJMUPWLgbFMjf4IjJKks4K9GHDAIa75oywloroV5nZ0M ToZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:dkim-signature:delivered-to; bh=pmL1pJjfGY7Tto5lO/emY4dsBqSVc/Wg6K/SZz9h7ko=; b=exU9SMM+cfVU7lGyePv8Y1FkC+0b/u/OvMADOtaivDvO61PZc2SF7LmmVd7tDg6Bpe Y3gR8PZHncYK+nTOYLMVwkskdwlbTocEyggNJvo2U0ckQ5L548kwLingZVk4lPE8DBQF nsP2yB/i8RsrktPUDuQa1WRBt74zfZVX7o2SLsYfa7Yy7qcN0KfPTuDCTT5uedYkFqFK 2zOo1nF+AGYMW/P1rLW0iZAr51Pje0Or1kkF8LJtW+hRQbAUD9/8DySCKJMGwIkEKYyg ag+oazPEbPph/R52s3i3cCYGMM+g3uRrNIn/Gz5s/f5CET570d5lJPflf+qH/uU/AN5u JjEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RtEQt00C; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id y130-v6si20749740wmy.141.2018.11.02.14.11.50; Fri, 02 Nov 2018 14:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RtEQt00C; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5EE382678EE; Fri, 2 Nov 2018 22:11:50 +0100 (CET) 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 41BC82678F3; Fri, 2 Nov 2018 22:11:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by alsa0.perex.cz (Postfix) with ESMTP id A6818267692 for ; Fri, 2 Nov 2018 22:11:44 +0100 (CET) Received: by mail-lf1-f66.google.com with SMTP id p86so2255965lfg.5 for ; Fri, 02 Nov 2018 14:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Osht3xV+yLC3uRaOTVjBrg3kXmxWxnjXA0UgCF8wgdg=; b=RtEQt00CpDAy8GI6E2Ozhyo/fXtBsZnclXD40ElRc+2q8p+K453KmsatHVoDgt3odf 5mzb9lDpTH8Ol1Evx+iAM52vwTJ0BGn6VimBXTyrDeDo2MJNs5UgJ9f1ouh0dBxsOpXX Ba2MHRhQq1Lxhql6r6csg4nntbS3z7J2jkSbw= 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:mime-version :content-transfer-encoding; bh=Osht3xV+yLC3uRaOTVjBrg3kXmxWxnjXA0UgCF8wgdg=; b=C3TTEPqSS6j42NQp1K+B1Q/RyxHeicdN2sPU76PQdi5nZuQ4z7eGDUuRVIw42upYBP aLXLgneNSVmavVU/nhoo6UYntwKM3rSAf88yiIvXnZMBhv9lZE0azx1PfGmGmpItcFZI Np9pZ5CoG1B+7Dr3nXPBDrjzhwCUJMTKHFTL+mXAo7Tylid77AWa0guxtfx9cpehLW6b F4gAdOkZ8ASGLan+dfHNgLIsSWPc9E5DX5xu60dToHzgLK2EY12IX90jFw6FVaDGsaPh saX84KIXmBkBW0UtYGlfNmc+pX649VXfj4EYWH8xPOock95H74Wz0ea2EipACar+6yp0 Ka4g== X-Gm-Message-State: AGRZ1gISaf/fnGmyr49evmaTib3HtL6fbIQ2L0KveKKr6dw/z9XMO/2H k1BMNy7wpMYW2yPc6vQ1eo/SwQ== X-Received: by 2002:a19:5186:: with SMTP id g6mr7502756lfl.143.1541193103230; Fri, 02 Nov 2018 14:11:43 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id v13-v6sm5484801lfb.70.2018.11.02.14.11.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Nov 2018 14:11:41 -0700 (PDT) From: Linus Walleij To: Jaroslav Kysela , Takashi Iwai Date: Fri, 2 Nov 2018 22:11:33 +0100 Message-Id: <20181102211133.6479-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Linus Walleij Subject: [alsa-devel] [PATCH] ALSA: usb-audio: Define registers for CM6206 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The register map for CM6206 is known and we can define what the values written to the different registers actually mean. I tested to print the hex values before/after this change, there is no functional change. Signed-off-by: Linus Walleij --- sound/usb/quirks.c | 129 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 5 deletions(-) -- 2.19.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 8a945ece9869..3d0f09108c98 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -668,15 +669,133 @@ static int snd_usb_cm106_boot_quirk(struct usb_device *dev) } /* - * C-Media CM6206 is based on CM106 with two additional - * registers that are not documented in the data sheet. - * Values here are chosen based on sniffing USB traffic - * under Windows. + * CM6206 registers from the CM6206 datasheet rev 2.1 */ +#define CM6206_REG0_DMA_MASTER BIT(15) +#define CM6206_REG0_SPDIFO_RATE_48K (2 << 12) +#define CM6206_REG0_SPDIFO_RATE_96K (7 << 12) +/* Bit 4 thru 11 is the S/PDIF category code */ +#define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL (0 << 4) +#define CM6206_REG0_SPDIFO_EMPHASIS_CD BIT(3) +#define CM6206_REG0_SPDIFO_COPYRIGHT_NA BIT(2) +#define CM6206_REG0_SPDIFO_NON_AUDIO BIT(1) +#define CM6206_REG0_SPDIFO_PRO_FORMAT BIT(0) + +#define CM6206_REG1_TEST_SEL_CLK BIT(14) +#define CM6206_REG1_PLLBIN_EN BIT(13) +#define CM6206_REG1_SOFT_MUTE_EN BIT(12) +#define CM6206_REG1_GPIO4_OUT BIT(11) +#define CM6206_REG1_GPIO4_OE BIT(10) +#define CM6206_REG1_GPIO3_OUT BIT(9) +#define CM6206_REG1_GPIO3_OE BIT(8) +#define CM6206_REG1_GPIO2_OUT BIT(7) +#define CM6206_REG1_GPIO2_OE BIT(6) +#define CM6206_REG1_GPIO1_OUT BIT(5) +#define CM6206_REG1_GPIO1_OE BIT(4) +#define CM6206_REG1_SPDIFO_INVALID BIT(3) +#define CM6206_REG1_SPDIF_LOOP_EN BIT(2) +#define CM6206_REG1_SPDIFO_DIS BIT(1) +#define CM6206_REG1_SPDIFI_MIX BIT(0) + +#define CM6206_REG2_DRIVER_ON BIT(15) +#define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS (0 << 13) +#define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS (1 << 13) +#define CM6206_REG2_HEADP_SEL_CENTER_SUBW (2 << 13) +#define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS (3 << 13) +#define CM6206_REG2_MUTE_HEADPHONE_RIGHT BIT(12) +#define CM6206_REG2_MUTE_HEADPHONE_LEFT BIT(11) +#define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT BIT(10) +#define CM6206_REG2_MUTE_REAR_SURROUND_LEFT BIT(9) +#define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT BIT(8) +#define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT BIT(7) +#define CM6206_REG2_MUTE_SUBWOOFER BIT(6) +#define CM6206_REG2_MUTE_CENTER BIT(5) +#define CM6206_REG2_MUTE_RIGHT_FRONT BIT(3) +#define CM6206_REG2_MUTE_LEFT_FRONT BIT(3) +#define CM6206_REG2_EN_BTL BIT(2) +#define CM6206_REG2_MCUCLKSEL_1_5_MHZ (0) +#define CM6206_REG2_MCUCLKSEL_3_MHZ (1) +#define CM6206_REG2_MCUCLKSEL_6_MHZ (2) +#define CM6206_REG2_MCUCLKSEL_12_MHZ (3) + +/* Bit 11..13 sets the sensitivity to FLY tuner volume control VP/VD signal */ +#define CM6206_REG3_FLYSPEED_DEFAULT (2 << 11) +#define CM6206_REG3_VRAP25EN BIT(10) +#define CM6206_REG3_MSEL1 BIT(9) +#define CM6206_REG3_SPDIFI_RATE_44_1K BIT(0 << 7) +#define CM6206_REG3_SPDIFI_RATE_48K BIT(2 << 7) +#define CM6206_REG3_SPDIFI_RATE_32K BIT(3 << 7) +#define CM6206_REG3_PINSEL BIT(6) +#define CM6206_REG3_FOE BIT(5) +#define CM6206_REG3_ROE BIT(4) +#define CM6206_REG3_CBOE BIT(3) +#define CM6206_REG3_LOSE BIT(2) +#define CM6206_REG3_HPOE BIT(1) +#define CM6206_REG3_SPDIFI_CANREC BIT(0) + +#define CM6206_REG5_DA_RSTN BIT(13) +#define CM6206_REG5_AD_RSTN BIT(12) +#define CM6206_REG5_SPDIFO_AD2SPDO BIT(12) +#define CM6206_REG5_SPDIFO_SEL_FRONT (0 << 9) +#define CM6206_REG5_SPDIFO_SEL_SIDE_SUR (1 << 9) +#define CM6206_REG5_SPDIFO_SEL_CEN_LFE (2 << 9) +#define CM6206_REG5_SPDIFO_SEL_REAR_SUR (3 << 9) +#define CM6206_REG5_CODECM BIT(8) +#define CM6206_REG5_EN_HPF BIT(7) +#define CM6206_REG5_T_SEL_DSDA4 BIT(6) +#define CM6206_REG5_T_SEL_DSDA3 BIT(5) +#define CM6206_REG5_T_SEL_DSDA2 BIT(4) +#define CM6206_REG5_T_SEL_DSDA1 BIT(3) +#define CM6206_REG5_T_SEL_DSDAD_NORMAL 0 +#define CM6206_REG5_T_SEL_DSDAD_FRONT 4 +#define CM6206_REG5_T_SEL_DSDAD_S_SURROUND 5 +#define CM6206_REG5_T_SEL_DSDAD_CEN_LFE 6 +#define CM6206_REG5_T_SEL_DSDAD_R_SURROUND 7 + static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) { int err = 0, reg; - int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; + int val[] = { + /* + * Values here are chosen based on sniffing USB traffic + * under Windows. + * + * REG0: DAC is master, sample rate 48kHz, no copyright + */ + CM6206_REG0_SPDIFO_RATE_48K | + CM6206_REG0_SPDIFO_COPYRIGHT_NA, + /* + * REG1: PLL binary search enable, soft mute enable. + */ + CM6206_REG1_PLLBIN_EN | + CM6206_REG1_SOFT_MUTE_EN | + /* + * REG2: enable output drivers, + * select front channels to the headphone output, + * then mute the headphone channels, run the MCU + * at 1.5 MHz. + */ + CM6206_REG2_DRIVER_ON | + CM6206_REG2_HEADP_SEL_FRONT_CHANNELS | + CM6206_REG2_MUTE_HEADPHONE_RIGHT | + CM6206_REG2_MUTE_HEADPHONE_LEFT, + /* + * REG3: default flyspeed, set 2.5V mic bias + * enable all line out ports and enable SPDIF + */ + CM6206_REG3_FLYSPEED_DEFAULT | + CM6206_REG3_VRAP25EN | + CM6206_REG3_FOE | + CM6206_REG3_ROE | + CM6206_REG3_CBOE | + CM6206_REG3_LOSE | + CM6206_REG3_HPOE | + CM6206_REG3_SPDIFI_CANREC, + /* REG4 is just a bunch of GPIO lines */ + 0x0000, + /* REG5: de-assert AD/DA reset signals */ + CM6206_REG5_DA_RSTN | + CM6206_REG5_AD_RSTN }; for (reg = 0; reg < ARRAY_SIZE(val); reg++) { err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);