From patchwork Tue Oct 6 15:07:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 7335911 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8284D9F32B for ; Tue, 6 Oct 2015 15:19:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39B3C205DC for ; Tue, 6 Oct 2015 15:19:32 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 60DF7205CD for ; Tue, 6 Oct 2015 15:19:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C0BC265979; Tue, 6 Oct 2015 17:19:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 25606265854; Tue, 6 Oct 2015 17:14:14 +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 CF84D265854; Tue, 6 Oct 2015 17:14:12 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 3019726589B for ; Tue, 6 Oct 2015 17:09:50 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 06 Oct 2015 08:08:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,644,1437462000"; d="scan'208";a="804820913" Received: from vkoul-mobl.iind.intel.com ([10.252.23.210]) by fmsmga001.fm.intel.com with ESMTP; 06 Oct 2015 08:08:41 -0700 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Tue, 6 Oct 2015 16:07:50 +0100 Message-Id: <1444144075-28963-14-git-send-email-vinod.koul@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444144075-28963-1-git-send-email-vinod.koul@intel.com> References: <1444144075-28963-1-git-send-email-vinod.koul@intel.com> Cc: liam.r.girdwood@linux.intel.com, tiwai@suse.de, broonie@kernel.org, Vinod Koul , patches.audio@intel.com Subject: [alsa-devel] [PATCH 13/18] ALSA: hda: move patch_realtek to use hdac helpers 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 Move patch_realtek to use newly moved snd_hdac_read/write_codec() APIs This was done using coccinelle script Signed-off-by: Vinod Koul --- sound/pci/hda/patch_realtek.c | 136 +++++++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 63 deletions(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index afec6dc9f91f..30f3978df056 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -133,8 +133,10 @@ static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, { unsigned int val; - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); - val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); + snd_hdac_codec_write(&codec->core, nid, 0, AC_VERB_SET_COEF_INDEX, + coef_idx); + val = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_PROC_COEF, + 0); return val; } @@ -144,8 +146,10 @@ static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, unsigned int coef_idx, unsigned int coef_val) { - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); + snd_hdac_codec_write(&codec->core, nid, 0, AC_VERB_SET_COEF_INDEX, + coef_idx); + snd_hdac_codec_write(&codec->core, nid, 0, AC_VERB_SET_PROC_COEF, + coef_val); } #define alc_write_coef_idx(codec, coef_idx, coef_val) \ @@ -276,8 +280,8 @@ static void alc_update_knob_master(struct hda_codec *codec, uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (!uctl) return; - val = snd_hda_codec_read(codec, jack->tbl->nid, 0, - AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); + val = snd_hdac_codec_read(&codec->core, jack->tbl->nid, 0, + AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); val &= HDA_AMP_VOLMASK; uctl->value.integer.value[0] = val; uctl->value.integer.value[1] = val; @@ -387,8 +391,8 @@ static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) return; if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, - on ? 2 : 0); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_EAPD_BTLENABLE, on ? 2 : 0); } /* turn on/off EAPD controls of the codec */ @@ -1502,8 +1506,8 @@ enum { static void alc260_gpio1_automute(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, - spec->gen.hp_jack_present); + snd_hdac_codec_write(&codec->core, 0x01, 0, AC_VERB_SET_GPIO_DATA, + spec->gen.hp_jack_present); } static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, @@ -1784,32 +1788,32 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) { unsigned int gpiostate, gpiomask, gpiodir; - gpiostate = snd_hda_codec_read(codec, codec->core.afg, 0, - AC_VERB_GET_GPIO_DATA, 0); + gpiostate = snd_hdac_codec_read(&codec->core, codec->core.afg, 0, + AC_VERB_GET_GPIO_DATA, 0); if (!muted) gpiostate |= (1 << pin); else gpiostate &= ~(1 << pin); - gpiomask = snd_hda_codec_read(codec, codec->core.afg, 0, - AC_VERB_GET_GPIO_MASK, 0); + gpiomask = snd_hdac_codec_read(&codec->core, codec->core.afg, 0, + AC_VERB_GET_GPIO_MASK, 0); gpiomask |= (1 << pin); - gpiodir = snd_hda_codec_read(codec, codec->core.afg, 0, - AC_VERB_GET_GPIO_DIRECTION, 0); + gpiodir = snd_hdac_codec_read(&codec->core, codec->core.afg, 0, + AC_VERB_GET_GPIO_DIRECTION, 0); gpiodir |= (1 << pin); - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_SET_GPIO_MASK, gpiomask); - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_SET_GPIO_DIRECTION, gpiodir); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_SET_GPIO_MASK, gpiomask); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_SET_GPIO_DIRECTION, gpiodir); msleep(1); - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_SET_GPIO_DATA, gpiostate); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_SET_GPIO_DATA, gpiostate); } /* set up GPIO at initialization */ @@ -2675,8 +2679,8 @@ static void alc286_shutup(struct hda_codec *codec) struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); /* use read here for syncing after issuing each verb */ if (pin->nid != mic_pin) - snd_hda_codec_read(codec, pin->nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, 0); + snd_hdac_codec_read(&codec->core, pin->nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0); } codec->pins_shutup = 1; } @@ -2758,14 +2762,14 @@ static void alc282_init(struct hda_codec *codec) if (hp_pin_sense) msleep(2); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); if (hp_pin_sense) msleep(85); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); if (hp_pin_sense) msleep(100); @@ -2793,14 +2797,14 @@ static void alc282_shutup(struct hda_codec *codec) if (hp_pin_sense) msleep(2); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); if (hp_pin_sense) msleep(85); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); if (hp_pin_sense) msleep(100); @@ -2875,14 +2879,14 @@ static void alc283_init(struct hda_codec *codec) /* Headphone capless set to high power mode */ alc_write_coef_idx(codec, 0x43, 0x9004); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); if (hp_pin_sense) msleep(85); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); if (hp_pin_sense) msleep(85); @@ -2916,14 +2920,14 @@ static void alc283_shutup(struct hda_codec *codec) /*depop hp during suspend*/ alc_write_coef_idx(codec, 0x06, 0x2100); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); if (hp_pin_sense) msleep(100); - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); alc_update_coef_idx(codec, 0x46, 0, 3 << 12); @@ -2937,19 +2941,23 @@ static void alc283_shutup(struct hda_codec *codec) static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg, unsigned int val) { - snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1); - snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */ - snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */ + snd_hdac_codec_write(&codec->core, 0x51, 0, AC_VERB_SET_COEF_INDEX, + index_reg >> 1); + snd_hdac_codec_write(&codec->core, 0x51, 0, AC_VERB_SET_PROC_COEF, + val & 0xffff); /* LSB */ + snd_hdac_codec_write(&codec->core, 0x51, 0, AC_VERB_SET_PROC_COEF, + val >> 16); /* MSB */ } static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg) { unsigned int val; - snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1); - val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) + snd_hdac_codec_write(&codec->core, 0x51, 0, AC_VERB_SET_COEF_INDEX, + index_reg >> 1); + val = snd_hdac_codec_read(&codec->core, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) & 0xffff; - val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) + val |= snd_hdac_codec_read(&codec->core, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) << 16; return val; } @@ -2991,7 +2999,8 @@ static void alc5505_dsp_init(struct hda_codec *codec) alc5505_coef_set(codec, 0x61b4, 0x04132b02); alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/ alc5505_coef_set(codec, 0x61b8, 0x041f3302); - snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */ + snd_hdac_codec_write(&codec->core, 0x51, 0, AC_VERB_SET_CODEC_RESET, + 0); /* Function reset */ alc5505_coef_set(codec, 0x61b8, 0x041b3302); alc5505_coef_set(codec, 0x61b8, 0x04173302); alc5505_coef_set(codec, 0x61b8, 0x04163302); @@ -3064,8 +3073,8 @@ static int alc269_resume(struct hda_codec *codec) * in the driver. */ if (spec->gpio_led) - snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, - spec->gpio_led); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_SET_GPIO_DATA, spec->gpio_led); if (spec->has_alc5505_dsp) alc5505_dsp_resume(codec); @@ -3171,11 +3180,11 @@ static void alc269_x101_hp_automute_hook(struct hda_codec *codec, vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; msleep(100); - snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, - vref); + snd_hdac_codec_write(&codec->core, 0x18, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, vref); msleep(500); - snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, - vref); + snd_hdac_codec_write(&codec->core, 0x18, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, vref); } static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, @@ -3291,8 +3300,8 @@ static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask, else spec->gpio_led |= mask; if (spec->gpio_led != oldval) - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, - spec->gpio_led); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DATA, spec->gpio_led); } /* turn on/off mute LED via GPIO per vmaster hook */ @@ -4142,8 +4151,8 @@ static void alc288_update_headset_jack_cb(struct hda_codec *codec, alc_update_headset_jack_cb(codec, jack); /* Headset Mic enable or disable, only for Dell Dino */ present = spec->gen.hp_jack_present ? 0x40 : 0; - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, - present); + snd_hdac_codec_write(&codec->core, 0x01, 0, AC_VERB_SET_GPIO_DATA, + present); } static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec, @@ -4212,8 +4221,8 @@ static void alc_shutup_dell_xps13(struct hda_codec *codec) int hp_pin = spec->gen.autocfg.hp_pins[0]; /* Prevent pop noises when headphones are plugged in */ - snd_hda_codec_write(codec, hp_pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + snd_hdac_codec_write(&codec->core, hp_pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); msleep(20); } @@ -4256,7 +4265,8 @@ static void alc_fixup_headset_mode_alc662(struct hda_codec *codec, /* Disable boost for mic-in permanently. (This code is only called from quirks that guarantee that the headphone is at NID 0x1b.) */ - snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000); + snd_hdac_codec_write(&codec->core, 0x1b, 0, + AC_VERB_SET_AMP_GAIN_MUTE, 0x7000); snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP); } else alc_fixup_headset_mode(codec, fix, action); @@ -4355,8 +4365,8 @@ static void alc283_hp_automute_hook(struct hda_codec *codec, vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; msleep(600); - snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, - vref); + snd_hdac_codec_write(&codec->core, 0x19, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, vref); } static void alc283_fixup_chromebook(struct hda_codec *codec, @@ -5742,7 +5752,7 @@ static int patch_alc269(struct hda_codec *codec) break; } - if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { + if (snd_hdac_codec_read(&codec->core, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { spec->has_alc5505_dsp = 1; spec->init_hook = alc5505_dsp_init; }