From patchwork Fri Nov 21 01:54:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oder Chiou X-Patchwork-Id: 5352421 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCAD59F1E1 for ; Fri, 21 Nov 2014 01:55:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C164D2016C for ; Fri, 21 Nov 2014 01:55:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 66CB1201B4 for ; Fri, 21 Nov 2014 01:55:56 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 582C6265AEF; Fri, 21 Nov 2014 02:55:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3D29D265AD2; Fri, 21 Nov 2014 02:55:46 +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 EF324265AD5; Fri, 21 Nov 2014 02:55:44 +0100 (CET) Received: from rtits2.realtek.com (rtits2.realtek.com [60.250.210.242]) by alsa0.perex.cz (Postfix) with ESMTP id 7997E265AD2 for ; Fri, 21 Nov 2014 02:55:30 +0100 (CET) Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.49 with qID sAL1tCFx001620, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas11.realtek.com.tw[172.21.6.12]) by rtits2.realtek.com (8.14.9/2.40/5.63) with ESMTP id sAL1tCFx001620 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Fri, 21 Nov 2014 09:55:13 +0800 Received: from sw-server.rtdomain (172.21.81.164) by RTITCAS11.realtek.com.tw (172.21.6.12) with Microsoft SMTP Server id 14.3.210.2; Fri, 21 Nov 2014 09:55:12 +0800 From: Oder Chiou To: , Date: Fri, 21 Nov 2014 09:54:38 +0800 Message-ID: <1416534878-25279-1-git-send-email-oder_chiou@realtek.com> X-Mailer: git-send-email 1.8.1.1.439.g50a6b54 MIME-Version: 1.0 X-Originating-IP: [172.21.81.164] Cc: Oder Chiou , alsa-devel@alsa-project.org, john.lin@realtek.com, benzh@google.com, anatol@google.com, bardliao@realtek.com, flove@realtek.com Subject: [alsa-devel] [PATCH] ASoC: rt5677: Fix the issue that the private value cannot be accessed 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 X-Virus-Scanned: ClamAV using ClamSMTP Fix the issue that the private value cannot be accessed. Signed-off-by: Oder Chiou --- sound/soc/codecs/rt5677.c | 37 ++++++++++++++++++++++++++++++------- sound/soc/codecs/rt5677.h | 2 +- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index f2211f1..133010d 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4287,6 +4287,7 @@ static int rt5677_probe(struct snd_soc_codec *codec) } mutex_init(&rt5677->dsp_cmd_lock); + mutex_init(&rt5677->dsp_pri_lock); return 0; } @@ -4344,10 +4345,19 @@ static int rt5677_read(void *context, unsigned int reg, unsigned int *val) struct i2c_client *client = context; struct rt5677_priv *rt5677 = i2c_get_clientdata(client); - if (rt5677->is_dsp_mode) - rt5677_dsp_mode_i2c_read(rt5677, reg, val); - else + if (rt5677->is_dsp_mode) { + if (reg > 0xff) { + mutex_lock(&rt5677->dsp_pri_lock); + rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, + reg & 0xff); + rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val); + mutex_unlock(&rt5677->dsp_pri_lock); + } else { + rt5677_dsp_mode_i2c_read(rt5677, reg, val); + } + } else { regmap_read(rt5677->regmap_physical, reg, val); + } return 0; } @@ -4357,10 +4367,20 @@ static int rt5677_write(void *context, unsigned int reg, unsigned int val) struct i2c_client *client = context; struct rt5677_priv *rt5677 = i2c_get_clientdata(client); - if (rt5677->is_dsp_mode) - rt5677_dsp_mode_i2c_write(rt5677, reg, val); - else + if (rt5677->is_dsp_mode) { + if (reg > 0xff) { + mutex_lock(&rt5677->dsp_pri_lock); + rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX, + reg & 0xff); + rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA, + val); + mutex_unlock(&rt5677->dsp_pri_lock); + } else { + rt5677_dsp_mode_i2c_write(rt5677, reg, val); + } + } else { regmap_write(rt5677->regmap_physical, reg, val); + } return 0; } @@ -4495,10 +4515,13 @@ static const struct regmap_config rt5677_regmap_physical = { .reg_bits = 8, .val_bits = 16, - .max_register = RT5677_VENDOR_ID2 + 1, + .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) * + RT5677_PR_SPACING), .readable_reg = rt5677_readable_register, .cache_type = REGCACHE_NONE, + .ranges = rt5677_ranges, + .num_ranges = ARRAY_SIZE(rt5677_ranges), }; static const struct regmap_config rt5677_regmap = { diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index a02f64c..dbd9ffd 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1670,7 +1670,7 @@ struct rt5677_priv { struct rt5677_platform_data pdata; struct regmap *regmap, *regmap_physical; const struct firmware *fw1, *fw2; - struct mutex dsp_cmd_lock; + struct mutex dsp_cmd_lock, dsp_pri_lock; int sysclk; int sysclk_src;