From patchwork Tue Feb 19 03:59:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 16908 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1U7eNc-0003FP-Cv; Tue, 19 Feb 2013 05:00:32 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp id 1U7eNb-00013A-Bn; Tue, 19 Feb 2013 05:00:32 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932326Ab3BSEAU (ORCPT + 1 other); Mon, 18 Feb 2013 23:00:20 -0500 Received: from mail-da0-f48.google.com ([209.85.210.48]:33620 "EHLO mail-da0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932261Ab3BSEAK (ORCPT ); Mon, 18 Feb 2013 23:00:10 -0500 Received: by mail-da0-f48.google.com with SMTP id v40so2741640dad.35 for ; Mon, 18 Feb 2013 20:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Ho3s9Io4KHDrSvvq/ao705pBEIabFaqoG8bL7qmi9g8=; b=KrPqm4xpYsG4MQk1ASDuOBMJ1Wthz/sPHpxo/51q55D8thWiiEaLNYakLE71T/dGVL QAglnYtlcxIUQcwnOp/16Vh4lY0wexwUA3xSnPtQshD3txS6K5ZCsPVUOqovlRjZVOof Py4fR40wF0qbR9ZTZN43bwWyd/tF8VpoumXCwDEg/TGpDI1c2RHnzY06JsvLUI3dOWFw suwoAFIW6t5oSiN6BrjRdbzg+St6Tj46dWoK8+h44oK9MtnMDSiV2IwCEKjpefane9lm UuJjWGrxFWWVXTIGTPPRCd+bbPTbX2W957gWX+7j/wSlNbX8/4N1UaGbu5zY2rSmPh5A EStA== X-Received: by 10.66.186.164 with SMTP id fl4mr41695798pac.51.1361246409499; Mon, 18 Feb 2013 20:00:09 -0800 (PST) Received: from localhost.localdomain (c-24-19-54-161.hsd1.wa.comcast.net. [24.19.54.161]) by mx.google.com with ESMTPS id 1sm16506432pbg.18.2013.02.18.20.00.07 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Feb 2013 20:00:08 -0800 (PST) From: Andrey Smirnov To: andrew.smirnov@gmail.com Cc: hverkuil@xs4all.nl, broonie@opensource.wolfsonmicro.com, mchehab@redhat.com, sameo@linux.intel.com, perex@perex.cz, tiwai@suse.de, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 6/7] sound/soc/codecs: Convert SI476X codec to use regmap Date: Mon, 18 Feb 2013 19:59:34 -0800 Message-Id: <1361246375-8848-7-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361246375-8848-1-git-send-email-andrew.smirnov@gmail.com> References: <1361246375-8848-1-git-send-email-andrew.smirnov@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2013.2.19.34817 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' From: Andrey Smirnov The latest radio and MFD drivers for SI476X radio chips use regmap API to provide access to the registers and allow for caching of their values when the actual chip is powered off. Convert the codec driver to do the same, so it would not loose the settings when the radio driver powers the chip down. Signed-off-by: Andrey Smirnov --- sound/soc/codecs/si476x.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index f2d61a1..30aebbe 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -45,13 +45,23 @@ static unsigned int si476x_codec_read(struct snd_soc_codec *codec, unsigned int reg) { int err; + unsigned int val; struct si476x_core *core = codec->control_data; si476x_core_lock(core); - err = si476x_core_cmd_get_property(core, reg); + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, true); + + err = regmap_read(core->regmap, reg, &val); + + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, false); si476x_core_unlock(core); - return err; + if (err < 0) + return err; + + return val; } static int si476x_codec_write(struct snd_soc_codec *codec, @@ -61,7 +71,13 @@ static int si476x_codec_write(struct snd_soc_codec *codec, struct si476x_core *core = codec->control_data; si476x_core_lock(core); - err = si476x_core_cmd_set_property(core, reg, val); + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, true); + + err = regmap_write(core->regmap, reg, val); + + if (!si476x_core_is_powered_up(core)) + regcache_cache_only(core->regmap, false); si476x_core_unlock(core); return err;