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: 2161371 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 47546DFE75 for ; Tue, 19 Feb 2013 04:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932326Ab3BSEAU (ORCPT ); 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 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;