From patchwork Mon Aug 29 06:23:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subhransu S. Prusty" X-Patchwork-Id: 9304221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEB7B60756 for ; Mon, 29 Aug 2016 17:41:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3BD3288E5 for ; Mon, 29 Aug 2016 17:41:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B851F288E8; Mon, 29 Aug 2016 17:41:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3851288E5 for ; Mon, 29 Aug 2016 17:41:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 337D826785A; Mon, 29 Aug 2016 19:41:26 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 41B052678DB; Mon, 29 Aug 2016 18:43:24 +0200 (CEST) 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 58704266E64; Mon, 29 Aug 2016 18:43:23 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id 4B4F5266E69 for ; Mon, 29 Aug 2016 18:23:45 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP; 28 Aug 2016 23:29:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,595,1464678000"; d="scan'208";a="2203722" Received: from subhransu-desktop.iind.intel.com ([10.223.96.24]) by orsmga004.jf.intel.com with ESMTP; 28 Aug 2016 23:29:27 -0700 From: "Subhransu S. Prusty" To: alsa-devel@alsa-project.org Date: Mon, 29 Aug 2016 11:53:26 +0530 Message-Id: <1472451806-10605-13-git-send-email-subhransu.s.prusty@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1472451806-10605-1-git-send-email-subhransu.s.prusty@intel.com> References: <1472451806-10605-1-git-send-email-subhransu.s.prusty@intel.com> Cc: tiwai@suse.de, lgirdwood@gmail.com, patches.audio@intel.com, broonie@kernel.org, Vinod Koul , "Subhransu S. Prusty" Subject: [alsa-devel] [PATCH 12/12] ASoC: hdac: Add coefficient init callback for RT286 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Subhransu S. Prusty Signed-off-by: Vinod Koul --- sound/soc/codecs/hdac_generic.c | 39 ++++++++++++++++++++++++++++++++------- sound/soc/codecs/hdac_generic.h | 5 +++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/hdac_generic.c b/sound/soc/codecs/hdac_generic.c index 6eb0dc2..cf556ee 100644 --- a/sound/soc/codecs/hdac_generic.c +++ b/sound/soc/codecs/hdac_generic.c @@ -41,6 +41,7 @@ struct hdac_generic_priv { unsigned int num_adcs; unsigned int num_dacs; unsigned int num_dapm_widgets; + struct hdac_generic_vendor_ops *vendor_ops; }; /* @@ -1636,6 +1637,7 @@ static int hdac_generic_dev_probe(struct hdac_ext_device *edev) struct hdac_device *codec = &edev->hdac; struct hdac_generic_priv *hdac_priv; struct snd_soc_dai_driver *codec_dais = NULL; + struct hdac_generic_vendor_ops *ops; int num_dais = 0; int ret = 0; @@ -1676,6 +1678,16 @@ static int hdac_generic_dev_probe(struct hdac_ext_device *edev) return ret; } + /* codec specific init if any */ + ops = (struct hdac_generic_vendor_ops *)edev->id_entry->driver_data; + if (ops && ops->init) { + ret = ops->init(edev); + if (ret < 0) + return ret; + } + + hdac_priv->vendor_ops = ops; + /* ASoC specific initialization */ return snd_soc_register_codec(&codec->dev, &hdac_generic_codec, codec_dais, num_dais); @@ -1687,14 +1699,27 @@ static int hdac_generic_dev_remove(struct hdac_ext_device *edev) return 0; } -/* - * TODO: - * Driver_data will be used to perform any vendor specific init, register - * specific dai ops. - * Driver will implement it's own match function to retrieve driver data. - */ +static void write_def_coeffs(struct hdac_ext_device *edev) +{ + snd_hdac_codec_write(&edev->hdac, 0x20, 0, + AC_VERB_SET_COEF_INDEX, 0x4f); + snd_hdac_codec_write(&edev->hdac, 0x20, 0, + AC_VERB_SET_PROC_COEF, 0x5000); +} + +int hdac_realtek_init(struct hdac_ext_device *edev) +{ + write_def_coeffs(edev); + + return 0; +} + +struct hdac_generic_vendor_ops realtek_ops = { + .init = hdac_realtek_init, +}; + static const struct hda_device_id codec_list[] = { - HDA_CODEC_EXT_ENTRY(0x10ec0286, 0x100002, "ALC286", 0), + HDA_CODEC_EXT_ENTRY(0x10ec0286, 0x100002, "ALC286", &realtek_ops), {} }; MODULE_DEVICE_TABLE(hdaudio, codec_list); diff --git a/sound/soc/codecs/hdac_generic.h b/sound/soc/codecs/hdac_generic.h index 36eafbd..e7cd2e2 100644 --- a/sound/soc/codecs/hdac_generic.h +++ b/sound/soc/codecs/hdac_generic.h @@ -25,6 +25,11 @@ #define AMP_OUT_UNMUTE 0xb000 #define PIN_OUT (AC_PINCTL_OUT_EN) +struct hdac_generic_vendor_ops { + int (*init)(struct hdac_ext_device *edev); + int (*cleanup)(struct hdac_ext_device *edev); +}; + int hdac_generic_machine_control_init(struct snd_soc_dapm_context *dapm, struct snd_soc_codec *codec);