Received: by 10.223.164.202 with SMTP id h10csp3691319wrb; Sat, 25 Nov 2017 14:43:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMbF7/QHeyVrF1rMJrOeYLv2mIltD5XlwCrWFmX9a2FyiWbepf8KZa0jbesnigtDAWVNi6mf X-Received: by 10.99.98.67 with SMTP id w64mr32815639pgb.213.1511649799818; Sat, 25 Nov 2017 14:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511649799; cv=none; d=google.com; s=arc-20160816; b=wPHOjnEa1erzyH6tokpxZ1B3M39d09q22J8Cb7pmV541egaxqQ1YgA4JMTYBJHAhyA v1p781cWTwGN28DAQFyxzYTgzErw34cqxp61n71AjP5FKBlAJfalhNEJj5U3lAHilGq3 32sRCXIyFYmOI9hQWpkSRK8xb8N9Ld+lqEqB2u24hM29VhQ/SkqHbvXnXUJnnjWAWbJW 07ehWIpNIcEmMwFbtZ4AwfwMiSf+1Uu1UVxvnxlJNDpOuNWKWqq6olBr5nl44DjVTt8e qrTVt2/aNNrAMo7Rr4IwEpoVndvpyf/Blw0DDLTg3u4fo94GjRfOUXgVNUTQRBBuxGK6 ck9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :arc-authentication-results; bh=Tvya9qycF4PH2gOBVWYPIbSY+dHSbrwvKgvlQ+01IdA=; b=0gBnkNzY1Kn/Cjvvlm5jfg/LAiADkBcViKupF0vywqSWTOmmyRkDb4+xJsCgdBHfFu +8S+Is6Ak6RtJJYu1mGnPP6s00szl9oNu6ebVH+x/16Ghunr+TzlpplDapLWtDGj937N jUqfzMTWawaQXX3U7MGQj/FFOcVEgkCLOSyjyA36UhaClwixTYLoXpDnlxLyj7D2whDh 2wkKXKMweh1L324XXO8an2ItU+w4Jt3YPhyuJOKp9utZMw6rdjaZRCzY9698STY8Kh5O o/eJ56nU19pjzj+FDzGlsMeHl53y13sT+TGtt7xmNgdvxzTNPjGyEXqbgmpy/Xvq45yG bXTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s25si22666715pfg.318.2017.11.25.14.43.07; Sat, 25 Nov 2017 14:43:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751715AbdKYWmd (ORCPT + 81 others); Sat, 25 Nov 2017 17:42:33 -0500 Received: from saul.pp3345.net ([163.172.111.124]:56622 "EHLO saul.pp3345.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586AbdKYWmc (ORCPT ); Sat, 25 Nov 2017 17:42:32 -0500 X-Greylist: delayed 374 seconds by postgrey-1.27 at vger.kernel.org; Sat, 25 Nov 2017 17:42:31 EST Received: from pp3345-PC.fritz.box (HSI-KBW-37-49-69-114.hsi14.kabel-badenwuerttemberg.de [37.49.69.114]) (Authenticated sender: dev@pp3345.net) by saul.pp3345.net (Postfix) with ESMTPSA id 0EA319A2695; Sat, 25 Nov 2017 22:36:09 +0000 (UTC) From: Yussuf Khalil Cc: Yussuf Khalil , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: ice1724: Fix resume issues with Prodigy 7.1 HiFi Date: Sat, 25 Nov 2017 23:31:08 +0100 Message-Id: <20171125223108.16814-1-dev@pp3345.net> X-Mailer: git-send-email 2.14.3 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two issues after resuming from suspend on the Audiotrak Prodigy 7.1 HiFi: - the output volume is set to 100% - microphone input isn't working anymore This patch fixes these issues by reinitializing both codecs of the device and restoring the previous volumes during resume. Signed-off-by: Yussuf Khalil --- sound/pci/ice1712/prodigy_hifi.c | 131 ++++++++++++++++++++++++++++++--------- 1 file changed, 102 insertions(+), 29 deletions(-) diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 2697402b5195..8dabd4d0211d 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c @@ -965,13 +965,32 @@ static int prodigy_hd2_add_controls(struct snd_ice1712 *ice) return 0; } +static void wm8766_init(struct snd_ice1712 *ice) +{ + static unsigned short wm8766_inits[] = { + WM8766_RESET, 0x0000, + WM8766_DAC_CTRL, 0x0120, + WM8766_INT_CTRL, 0x0022, /* I2S Normal Mode, 24 bit */ + WM8766_DAC_CTRL2, 0x0001, + WM8766_DAC_CTRL3, 0x0080, + WM8766_LDA1, 0x0100, + WM8766_LDA2, 0x0100, + WM8766_LDA3, 0x0100, + WM8766_RDA1, 0x0100, + WM8766_RDA2, 0x0100, + WM8766_RDA3, 0x0100, + WM8766_MUTE1, 0x0000, + WM8766_MUTE2, 0x0000, + }; + unsigned int i; -/* - * initialize the chip - */ -static int prodigy_hifi_init(struct snd_ice1712 *ice) + for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2) + wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i + 1]); +} + +static void wm8776_init(struct snd_ice1712 *ice) { - static unsigned short wm_inits[] = { + static unsigned short wm8776_inits[] = { /* These come first to reduce init pop noise */ WM_ADC_MUX, 0x0003, /* ADC mute */ /* 0x00c0 replaced by 0x0003 */ @@ -982,7 +1001,76 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) WM_POWERDOWN, 0x0008, /* All power-up except HP */ WM_RESET, 0x0000, /* reset */ }; - static unsigned short wm_inits2[] = { + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(wm8776_inits); i += 2) + wm_put(ice, wm8776_inits[i], wm8776_inits[i + 1]); +} + +#ifdef CONFIG_PM_SLEEP +static int prodigy_hifi_resume(struct snd_ice1712 *ice) +{ + static unsigned short wm8776_reinit_registers[] = { + WM_MASTER_CTRL, + WM_DAC_INT, + WM_ADC_INT, + WM_OUT_MUX, + WM_HP_ATTEN_L, + WM_HP_ATTEN_R, + WM_PHASE_SWAP, + WM_DAC_CTRL2, + WM_ADC_ATTEN_L, + WM_ADC_ATTEN_R, + WM_ALC_CTRL1, + WM_ALC_CTRL2, + WM_ALC_CTRL3, + WM_NOISE_GATE, + WM_ADC_MUX, + /* no DAC attenuation here */ + }; + struct prodigy_hifi_spec *spec = ice->spec; + int i, ch; + + mutex_lock(&ice->gpio_mutex); + + /* reinitialize WM8776 and re-apply old register values */ + wm8776_init(ice); + schedule_timeout_uninterruptible(1); + for (i = 0; i < ARRAY_SIZE(wm8776_reinit_registers); i++) + wm_put(ice, wm8776_reinit_registers[i], + wm_get(ice, wm8776_reinit_registers[i])); + + /* reinitialize WM8766 and re-apply volumes for all DACs */ + wm8766_init(ice); + for (ch = 0; ch < 2; ch++) { + wm_set_vol(ice, WM_DAC_ATTEN_L + ch, + spec->vol[2 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA1 + ch, + spec->vol[0 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA2 + ch, + spec->vol[4 + ch], spec->master[ch]); + + wm8766_set_vol(ice, WM8766_LDA3 + ch, + spec->vol[6 + ch], spec->master[ch]); + } + + /* unmute WM8776 DAC */ + wm_put(ice, WM_DAC_MUTE, 0x00); + wm_put(ice, WM_DAC_CTRL1, 0x90); + + mutex_unlock(&ice->gpio_mutex); + return 0; +} +#endif + +/* + * initialize the chip + */ +static int prodigy_hifi_init(struct snd_ice1712 *ice) +{ + static unsigned short wm8776_defaults[] = { WM_MASTER_CTRL, 0x0022, /* 256fs, slave mode */ WM_DAC_INT, 0x0022, /* I2S, normal polarity, 24bit */ WM_ADC_INT, 0x0022, /* I2S, normal polarity, 24bit */ @@ -1010,22 +1098,6 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) WM_DAC_MUTE, 0x0000, /* DAC unmute */ WM_ADC_MUX, 0x0003, /* ADC unmute, both CD/Line On */ }; - static unsigned short wm8766_inits[] = { - WM8766_RESET, 0x0000, - WM8766_DAC_CTRL, 0x0120, - WM8766_INT_CTRL, 0x0022, /* I2S Normal Mode, 24 bit */ - WM8766_DAC_CTRL2, 0x0001, - WM8766_DAC_CTRL3, 0x0080, - WM8766_LDA1, 0x0100, - WM8766_LDA2, 0x0100, - WM8766_LDA3, 0x0100, - WM8766_RDA1, 0x0100, - WM8766_RDA2, 0x0100, - WM8766_RDA3, 0x0100, - WM8766_MUTE1, 0x0000, - WM8766_MUTE2, 0x0000, - }; - struct prodigy_hifi_spec *spec; unsigned int i; @@ -1052,16 +1124,17 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) ice->spec = spec; /* initialize WM8776 codec */ - for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) - wm_put(ice, wm_inits[i], wm_inits[i+1]); + wm8776_init(ice); schedule_timeout_uninterruptible(1); - for (i = 0; i < ARRAY_SIZE(wm_inits2); i += 2) - wm_put(ice, wm_inits2[i], wm_inits2[i+1]); + for (i = 0; i < ARRAY_SIZE(wm8776_defaults); i += 2) + wm_put(ice, wm8776_defaults[i], wm8776_defaults[i + 1]); - /* initialize WM8766 codec */ - for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2) - wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i+1]); + wm8766_init(ice); +#ifdef CONFIG_PM_SLEEP + ice->pm_resume = &prodigy_hifi_resume; + ice->pm_suspend_enabled = 1; +#endif return 0; } -- 2.14.3 From 1584885382045680650@xxx Thu Nov 23 19:14:43 +0000 2017 X-GM-THRID: 1584885382045680650 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread