[alsa-devel] [PATCH 00/18] ALSA: hdac: move hdac helpers to core
Hi Takashi,
Here is the second version which updates the users.
This update was done using coccinelle scripts. I also noticed that the coccinelle is reformaing the change lines, but changes looked good to me so I have kept them, please do let me know if you would like these to be removed.
Subhransu S. Prusty (1): ALSA: hdac: Copy codec helpers to core
Vinod Koul (17): ALSA: hda: move hda beep to use hdac helpers ALSA: hda: move hda_eld to use hdac helpers ALSA: hda: move hda_generic to use hdac helpers ALSA: hda: move hda_hwdep to use hdac helpers ALSA: hda: move hda_jack to use hdac helpers ALSA: hda: move hda_proc to use hdac helpers ALSA: hda: move patch_analog to use hdac helpers ALSA: hda: move patch_ca0132.c to use hdac helpers ALSA: hda: move patch_cirrus to use hdac helpers ALSA: hda: move to use hdac helpers ALSA: hda: move patch_hdmi to use hdac helpers ALSA: hda: move patch_realtek to use hdac helpers ALSA: hda: move patch_si3054 to use hdac helpers ALSA: hda: move patch_sigmatel to use hdac helpers ALSA: hda: move patch_via to use hdac helpers ALSA: hda: move hda_codec to use hdac helpers ALSA: hda: remove the old helpers
include/sound/hdaudio.h | 6 + sound/hda/hdac_device.c | 81 ++++++++++++ sound/pci/hda/hda_beep.c | 4 +- sound/pci/hda/hda_codec.c | 128 +++++++----------- sound/pci/hda/hda_codec.h | 5 - sound/pci/hda/hda_eld.c | 65 +++++++--- sound/pci/hda/hda_generic.c | 9 +- sound/pci/hda/hda_hwdep.c | 4 +- sound/pci/hda/hda_jack.c | 8 +- sound/pci/hda/hda_local.h | 13 -- sound/pci/hda/hda_proc.c | 80 ++++++------ sound/pci/hda/patch_analog.c | 10 +- sound/pci/hda/patch_ca0132.c | 223 ++++++++++++++++---------------- sound/pci/hda/patch_cirrus.c | 52 ++++---- sound/pci/hda/patch_conexant.c | 20 +-- sound/pci/hda/patch_hdmi.c | 285 +++++++++++++++++++++-------------------- sound/pci/hda/patch_realtek.c | 136 +++++++++++--------- sound/pci/hda/patch_si3054.c | 10 +- sound/pci/hda/patch_sigmatel.c | 78 +++++------ sound/pci/hda/patch_via.c | 14 +- 20 files changed, 660 insertions(+), 571 deletions(-)
From: "Subhransu S. Prusty" subhransu.s.prusty@intel.com
The current codec helpers are local to hda code and needs to be moved to core so that other users can use it. The helpers to read/write the codec and to check the power state of widgets is copied
Signed-off-by: Subhransu S. Prusty subhransu.s.prusty@intel.com Signed-off-by: Vinod Koul vinod.koul@intel.com --- include/sound/hdaudio.h | 6 ++++ sound/hda/hdac_device.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 49bc836fcd84..26e956f4b7c6 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -147,6 +147,12 @@ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid, unsigned int format);
+int snd_hdac_codec_read(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm); +int snd_hdac_codec_write(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm); +bool snd_hdac_check_power_state(struct hdac_device *hdac, + hda_nid_t nid, unsigned int target_state); /** * snd_hdac_read_parm - read a codec parameter * @codec: the codec object diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index db96042a497f..b3b0ad289df1 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -952,3 +952,84 @@ bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid, return true; } EXPORT_SYMBOL_GPL(snd_hdac_is_supported_format); + +static unsigned int codec_read(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm) +{ + unsigned int cmd = snd_hdac_make_cmd(hdac, nid, verb, parm); + unsigned int res; + + if (snd_hdac_exec_verb(hdac, cmd, flags, &res)) + return -1; + + return res; +} + +static int codec_write(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm) +{ + unsigned int cmd = snd_hdac_make_cmd(hdac, nid, verb, parm); + + return snd_hdac_exec_verb(hdac, cmd, flags, NULL); +} + +/** + * snd_hdac_codec_read - send a command and get the response + * @hdac: the HDAC device + * @nid: NID to send the command + * @flags: optional bit flags + * @verb: the verb to send + * @parm: the parameter for the verb + * + * Send a single command and read the corresponding response. + * + * Returns the obtained response value, or -1 for an error. + */ +int snd_hdac_codec_read(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm) +{ + return codec_read(hdac, nid, flags, verb, parm); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_read); + +/** + * snd_hdac_codec_write - send a single command without waiting for response + * @hdac: the HDAC device + * @nid: NID to send the command + * @flags: optional bit flags + * @verb: the verb to send + * @parm: the parameter for the verb + * + * Send a single command without waiting for response. + * + * Returns 0 if successful, or a negative error code. + */ +int snd_hdac_codec_write(struct hdac_device *hdac, hda_nid_t nid, + int flags, unsigned int verb, unsigned int parm) +{ + return codec_write(hdac, nid, flags, verb, parm); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_write); + +/* + * snd_hdac_check_power_state: check whether the actual power state matches + * with the target state + * + * @hdac: the HDAC device + * @nid: NID to send the command + * @target_state: target state to check for + * + * Return true if state matches, false if not + */ +bool snd_hdac_check_power_state(struct hdac_device *hdac, + hda_nid_t nid, unsigned int target_state) +{ + unsigned int state = codec_read(hdac, nid, 0, + AC_VERB_GET_POWER_STATE, 0); + + if (state & AC_PWRST_ERROR) + return true; + state = (state >> 4) & 0x0f; + return (state == target_state); +} +EXPORT_SYMBOL_GPL(snd_hdac_check_power_state);
Mover this driver to use newly moved snd_hdac_read/write_codec() APIs.
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_beep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index c397e7da0eac..ecf4a0b4fd63 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c @@ -44,8 +44,8 @@ static void generate_tone(struct hda_beep *beep, int tone) beep->power_hook(beep, true); beep->playing = 1; } - snd_hda_codec_write(codec, beep->nid, 0, - AC_VERB_SET_BEEP_CONTROL, tone); + snd_hdac_codec_write(&codec->core, beep->nid, 0, + AC_VERB_SET_BEEP_CONTROL, tone); if (!tone && beep->playing) { beep->playing = 0; if (beep->power_hook)
Mover this driver to use newly moved snd_hdac_read/write_codec() and snd_hdac_check_power_state APIs.
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_eld.c | 65 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 18 deletions(-)
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 563984dd2562..3df0ef45c93d 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -150,7 +150,7 @@ static unsigned int hdmi_get_eld_data(struct hda_codec *codec, hda_nid_t nid, { unsigned int val;
- val = snd_hda_codec_read(codec, nid, 0, + val = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_HDMI_ELDD, byte_index); #ifdef BE_PARANOID codec_info(codec, "HDMI: ELD data byte %d: 0x%x\n", byte_index, val); @@ -312,7 +312,7 @@ out_fail:
int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid) { - return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, + return snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, AC_DIPSIZE_ELD_BUF); }
@@ -675,7 +675,8 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
/* ATI/AMD does not have ELD, emulate it */
- spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0); + spkalloc = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SPEAKER_ALLOCATION, 0);
if (spkalloc <= 0) { codec_info(codec, "HDMI ATI/AMD: no speaker allocation for ELD\n"); @@ -699,24 +700,44 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, if (rev3_or_later) { int sink_info;
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_LOW); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_PORT_ID_LOW); + sink_info = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0); put_unaligned_le32(sink_info, buf + 8);
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_HIGH); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_PORT_ID_HIGH); + sink_info = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0); put_unaligned_le32(sink_info, buf + 12);
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_MANUFACTURER_ID); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_MANUFACTURER_ID); + sink_info = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0); put_unaligned_le16(sink_info, buf + 16);
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PRODUCT_ID); - sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_PRODUCT_ID); + sink_info = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0); put_unaligned_le16(sink_info, buf + 18);
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_LEN); - sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_SINK_DESC_LEN); + sink_desc_len = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0);
if (sink_desc_len > ELD_MAX_MNL) { codec_info(codec, "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n", @@ -727,8 +748,12 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, buf[4] |= sink_desc_len;
for (i = 0; i < sink_desc_len; i++) { - snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_FIRST + i); - buf[pos++] = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_SINK_INFO_INDEX, + ATI_INFO_IDX_SINK_DESC_FIRST + i); + buf[pos++] = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_SINK_INFO_DATA, + 0); } }
@@ -736,8 +761,11 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, if (i == AUDIO_CODING_TYPE_SACD || i == AUDIO_CODING_TYPE_DST) continue; /* not handled by ATI/AMD */
- snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3); - ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3); + ati_sad = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_AUDIO_DESCRIPTOR, + 0);
if (ati_sad <= 0) continue; @@ -778,7 +806,8 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, * [1..250] msecs = x*2 (max 500ms with x = 250 = 0xfa) * [251..255] reserved */ - aud_synch = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_VIDEO_DELAY, 0); + aud_synch = snd_hdac_codec_read(&codec->core, nid, 0, + ATI_VERB_GET_AUDIO_VIDEO_DELAY, 0); if ((aud_synch & ATI_DELAY_VIDEO_LATENCY) && (aud_synch & ATI_DELAY_AUDIO_LATENCY)) { int video_latency_hdmi = (aud_synch & ATI_DELAY_VIDEO_LATENCY); int audio_latency_hdmi = (aud_synch & ATI_DELAY_AUDIO_LATENCY) >> 8;
Mover hda_generic to use newly moved snd_hdac_read/write_codec() and snd_hdac_check_power_state APIs.
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_generic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 24f91114a32c..b0ef87f648bc 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -841,9 +841,9 @@ static hda_nid_t path_power_update(struct hda_codec *codec, state = AC_PWRST_D0; else state = AC_PWRST_D3; - if (!snd_hda_check_power_state(codec, nid, state)) { - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_POWER_STATE, state); + if (!snd_hdac_check_power_state(&codec->core, nid, state)) { + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_POWER_STATE, state); changed = nid; /* all known codecs seem to be capable to handl * widgets state even in D3, so far. @@ -865,7 +865,8 @@ static void sync_power_state_change(struct hda_codec *codec, hda_nid_t nid) { if (nid) { msleep(10); - snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); + snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_POWER_STATE, 0); } }
Move hda_hwdep to use newly moved snd_hdac_read_codec() API
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_hwdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 57df06e76968..359d4e54d672 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c @@ -37,8 +37,8 @@ static int verb_write_ioctl(struct hda_codec *codec,
if (get_user(verb, &arg->verb)) return -EFAULT; - res = snd_hda_codec_read(codec, verb >> 24, 0, - (verb >> 8) & 0xffff, verb & 0xff); + res = snd_hdac_codec_read(&codec->core, verb >> 24, 0, + (verb >> 8) & 0xffff, verb & 0xff); if (put_user(res, &arg->res)) return -EFAULT; return 0;
Move hda_jack to use newly moved snd_hdac_read_codec() API
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_jack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 366efbf87d41..e9f458a20a52 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -55,11 +55,11 @@ static u32 read_pin_sense(struct hda_codec *codec, hda_nid_t nid) if (!codec->no_trigger_sense) { pincap = snd_hda_query_pin_caps(codec, nid); if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ - snd_hda_codec_read(codec, nid, 0, - AC_VERB_SET_PIN_SENSE, 0); + snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_SET_PIN_SENSE, 0); } - val = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_SENSE, 0); + val = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_PIN_SENSE, + 0); if (codec->inv_jack_detect) val ^= AC_PINSENSE_PRESENCE; return val;
Move hda_proc to use newly moved snd_hdac_read/write_codec() and snd_hdac_check_power_state APIs.
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_proc.c | 80 +++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 38 deletions(-)
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 033aa84365b9..297e4501fa4c 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -157,14 +157,14 @@ static void print_amp_vals(struct snd_info_buffer *buffer, dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; for (i = 0; i < indices; i++) { snd_iprintf(buffer, " ["); - val = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_AMP_GAIN_MUTE, - AC_AMP_GET_LEFT | dir | i); + val = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_AMP_GAIN_MUTE, + AC_AMP_GET_LEFT | dir | i); snd_iprintf(buffer, "0x%02x", val); if (stereo) { - val = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_AMP_GAIN_MUTE, - AC_AMP_GET_RIGHT | dir | i); + val = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_AMP_GAIN_MUTE, + AC_AMP_GET_RIGHT | dir | i); snd_iprintf(buffer, " 0x%02x", val); } snd_iprintf(buffer, "]"); @@ -374,8 +374,8 @@ static void print_pin_caps(struct snd_info_buffer *buffer, } else *supports_vref = 0; if (caps & AC_PINCAP_EAPD) { - val = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_EAPD_BTLENABLE, 0); + val = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_EAPD_BTLENABLE, 0); snd_iprintf(buffer, " EAPD 0x%x:", val); if (val & AC_EAPDBTL_BALANCED) snd_iprintf(buffer, " BALANCED"); @@ -385,7 +385,8 @@ static void print_pin_caps(struct snd_info_buffer *buffer, snd_iprintf(buffer, " R/L"); snd_iprintf(buffer, "\n"); } - caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); + caps = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_CONFIG_DEFAULT, 0); snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], get_jack_type(caps), @@ -417,8 +418,8 @@ static void print_pin_ctls(struct snd_info_buffer *buffer, { unsigned int pinctls;
- pinctls = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pinctls = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls); if (pinctls & AC_PINCTL_IN_EN) snd_iprintf(buffer, " IN"); @@ -455,8 +456,8 @@ static void print_vol_knob(struct snd_info_buffer *buffer, unsigned int cap = param_read(codec, nid, AC_PAR_VOL_KNB_CAP); snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ", (cap >> 7) & 1, cap & 0x7f); - cap = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); + cap = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); snd_iprintf(buffer, "direct=%d, val=%d\n", (cap >> 7) & 1, cap & 0x7f); } @@ -465,14 +466,14 @@ static void print_audio_io(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid, unsigned int wid_type) { - int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); + int conv = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_CONV, 0); snd_iprintf(buffer, " Converter: stream=%d, channel=%d\n", (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT, conv & AC_CONV_CHANNEL);
if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) { - int sdi = snd_hda_codec_read(codec, nid, 0, + int sdi = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_SDI_SELECT, 0); snd_iprintf(buffer, " SDI-Select: %d\n", sdi & AC_SDI_SELECT); @@ -482,7 +483,7 @@ static void print_audio_io(struct snd_info_buffer *buffer, static void print_digital_conv(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid) { - unsigned int digi1 = snd_hda_codec_read(codec, nid, 0, + unsigned int digi1 = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); unsigned char digi2 = digi1 >> 8; unsigned char digi3 = digi1 >> 16; @@ -538,7 +539,7 @@ static void print_power_state(struct snd_info_buffer *buffer, };
int sup = param_read(codec, nid, AC_PAR_POWER_STATE); - int pwr = snd_hda_codec_read(codec, nid, 0, + int pwr = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_POWER_STATE, 0); if (sup != -1) { int i; @@ -567,7 +568,7 @@ static void print_power_state(struct snd_info_buffer *buffer, static void print_unsol_cap(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid) { - int unsol = snd_hda_codec_read(codec, nid, 0, + int unsol = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0); snd_iprintf(buffer, " Unsolicited: tag=%02x, enabled=%d\n", @@ -598,15 +599,18 @@ static void print_proc_caps(struct snd_info_buffer *buffer,
/* Note: This is racy - another process could run in parallel and change the coef index too. */ - oldindex = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_COEF_INDEX, 0); + oldindex = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_COEF_INDEX, 0); for (i = 0; i < ncoeff; i++) { unsigned int val; - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, i); - 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, i); + val = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_PROC_COEF, 0); snd_iprintf(buffer, " Coeff 0x%02x: 0x%04x\n", i, val); } - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, oldindex); + snd_hdac_codec_write(&codec->core, nid, 0, AC_VERB_SET_COEF_INDEX, + oldindex); }
static void print_conn_list(struct snd_info_buffer *buffer, @@ -622,8 +626,8 @@ static void print_conn_list(struct snd_info_buffer *buffer, wid_type != AC_WID_AUD_MIX && wid_type != AC_WID_VOL_KNB && wid_type != AC_WID_POWER) - curr = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_CONNECT_SEL, 0); + curr = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_CONNECT_SEL, 0); snd_iprintf(buffer, " Connection: %d\n", conn_len); if (conn_len > 0) { snd_iprintf(buffer, " "); @@ -666,18 +670,18 @@ static void print_gpio(struct snd_info_buffer *buffer, max = gpio & AC_GPIO_IO_COUNT; if (!max || max > 8) return; - enable = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_GPIO_MASK, 0); - direction = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_GPIO_DIRECTION, 0); - wake = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_GPIO_WAKE_MASK, 0); - unsol = snd_hda_codec_read(codec, nid, 0, + enable = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_GPIO_MASK, 0); + direction = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_GPIO_DIRECTION, 0); + wake = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_GPIO_WAKE_MASK, 0); + unsol = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0); - sticky = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_GPIO_STICKY_MASK, 0); - data = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_GPIO_DATA, 0); + sticky = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_GPIO_STICKY_MASK, 0); + data = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_GPIO_DATA, 0); for (i = 0; i < max; ++i) snd_iprintf(buffer, " IO[%d]: enable=%d, dir=%d, wake=%d, " @@ -706,8 +710,8 @@ static void print_device_list(struct snd_info_buffer *buffer, if (devlist_len <= 0) return;
- curr = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_DEVICE_SEL, 0); + curr = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_DEVICE_SEL, 0);
for (i = 0; i < devlist_len; i++) { if (i == curr)
Move patch_analog to use newly moved snd_hdac_read/write_codec() APIs.
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_analog.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index c033a4ee6547..1b21a13772dc 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -89,11 +89,13 @@ static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, hda_nid_t hp) { if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD) - snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, - !codec->inv_eapd ? 0x00 : 0x02); + snd_hdac_codec_write(&codec->core, front, 0, + AC_VERB_SET_EAPD_BTLENABLE, + !codec->inv_eapd ? 0x00 : 0x02); if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD) - snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, - !codec->inv_eapd ? 0x00 : 0x02); + snd_hdac_codec_write(&codec->core, hp, 0, + AC_VERB_SET_EAPD_BTLENABLE, + !codec->inv_eapd ? 0x00 : 0x02); }
static void ad198x_power_eapd(struct hda_codec *codec)
Move patch_ca0132.c to use newly moved snd_hdac_read/write_codec() APIs.
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_ca0132.c | 223 ++++++++++++++++++++++--------------------- 1 file changed, 114 insertions(+), 109 deletions(-)
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 186792fe226e..60622c306a6f 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -789,7 +789,7 @@ static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, unsigned int verb, unsigned int parm, unsigned int *res) { unsigned int response; - response = snd_hda_codec_read(codec, nid, 0, verb, parm); + response = snd_hdac_codec_read(&codec->core, nid, 0, verb, parm); *res = response;
return ((response == -1) ? -1 : 0); @@ -823,8 +823,8 @@ static int chipio_send(struct hda_codec *codec,
/* send bits of data specified by reg */ do { - res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, - reg, data); + res = snd_hdac_codec_read(&codec->core, WIDGET_CHIP_CTRL, 0, + reg, data); if (res == VENDOR_STATUS_CHIPIO_OK) return 0; msleep(20); @@ -923,9 +923,8 @@ static int chipio_read_data(struct hda_codec *codec, unsigned int *data)
if (res != -EIO) { /* read data */ - *data = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_HIC_READ_DATA, - 0); + *data = snd_hdac_codec_read(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_HIC_READ_DATA, 0); }
/*If no error encountered, automatically increment the address @@ -1023,8 +1022,8 @@ static void chipio_set_control_flag(struct hda_codec *codec,
flag_bit = (flag_state ? 1 : 0); val = (flag_bit << 7) | (flag_id); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_FLAG_SET, val); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_FLAG_SET, val); }
/* @@ -1038,17 +1037,18 @@ static void chipio_set_control_param(struct hda_codec *codec,
if ((param_id < 32) && (param_val < 8)) { val = (param_val << 5) | (param_id); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PARAM_SET, val); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PARAM_SET, val); } else { mutex_lock(&spec->chipio_mutex); if (chipio_send(codec, VENDOR_CHIPIO_STATUS, 0) == 0) { - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PARAM_EX_ID_SET, - param_id); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PARAM_EX_VALUE_SET, - param_val); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, + 0, VENDOR_CHIPIO_PARAM_EX_ID_SET, + param_id); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, + 0, + VENDOR_CHIPIO_PARAM_EX_VALUE_SET, + param_val); } mutex_unlock(&spec->chipio_mutex); } @@ -1073,18 +1073,18 @@ static void chipio_enable_clocks(struct hda_codec *codec) struct ca0132_spec *spec = codec->spec;
mutex_lock(&spec->chipio_mutex); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_LOW, 0); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_LOW, 5); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PLL_PMU_WRITE, 0x0b); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_LOW, 6); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_LOW, 0); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_LOW, 5); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PLL_PMU_WRITE, 0x0b); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_LOW, 6); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); mutex_unlock(&spec->chipio_mutex); }
@@ -1099,7 +1099,8 @@ static int dspio_send(struct hda_codec *codec, unsigned int reg,
/* send bits of data specified by reg to dsp */ do { - res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, data); + res = snd_hdac_codec_read(&codec->core, WIDGET_DSP_CTRL, 0, + reg, data); if ((res >= 0) && (res != VENDOR_STATUS_DSPIO_BUSY)) return res; msleep(20); @@ -1117,8 +1118,8 @@ static void dspio_write_wait(struct hda_codec *codec) unsigned long timeout = jiffies + msecs_to_jiffies(1000);
do { - status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, - VENDOR_DSPIO_STATUS, 0); + status = snd_hdac_codec_read(&codec->core, WIDGET_DSP_CTRL, 0, + VENDOR_DSPIO_STATUS, 0); if ((status == VENDOR_STATUS_DSPIO_OK) || (status == VENDOR_STATUS_DSPIO_SCP_RESPONSE_QUEUE_EMPTY)) break; @@ -1148,8 +1149,8 @@ static int dspio_write(struct hda_codec *codec, unsigned int scp_data) goto error;
/* OK, now check if the write itself has executed*/ - status = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, - VENDOR_DSPIO_STATUS, 0); + status = snd_hdac_codec_read(&codec->core, WIDGET_DSP_CTRL, 0, + VENDOR_DSPIO_STATUS, 0); error: mutex_unlock(&spec->chipio_mutex);
@@ -1193,8 +1194,8 @@ static int dspio_read(struct hda_codec *codec, unsigned int *data) status == VENDOR_STATUS_DSPIO_SCP_RESPONSE_QUEUE_EMPTY) return -EIO;
- *data = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, - VENDOR_DSPIO_SCP_READ_DATA, 0); + *data = snd_hdac_codec_read(&codec->core, WIDGET_DSP_CTRL, 0, + VENDOR_DSPIO_SCP_READ_DATA, 0);
return 0; } @@ -1951,20 +1952,18 @@ static int dsp_allocate_router_ports(struct hda_codec *codec, val |= (ports_per_channel - 1) << 4; val |= num_chans - 1;
- snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PORT_ALLOC_CONFIG_SET, - val); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PORT_ALLOC_CONFIG_SET, val);
- snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PORT_ALLOC_SET, - MEM_CONNID_DSP); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PORT_ALLOC_SET, MEM_CONNID_DSP);
status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0); if (status < 0) return status;
- res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PORT_ALLOC_GET, 0); + res = snd_hdac_codec_read(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PORT_ALLOC_GET, 0);
*port_map = res;
@@ -1982,9 +1981,8 @@ static int dsp_free_router_ports(struct hda_codec *codec) if (status < 0) return status;
- snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_PORT_FREE_SET, - MEM_CONNID_DSP); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_PORT_FREE_SET, MEM_CONNID_DSP);
status = chipio_send(codec, VENDOR_CHIPIO_STATUS, 0);
@@ -3185,23 +3183,27 @@ static int ca0132_select_out(struct hda_codec *codec) goto exit;
/* Setup EAPD */ - snd_hda_codec_write(codec, spec->out_pins[1], 0, - VENDOR_CHIPIO_EAPD_SEL_SET, 0x02); - snd_hda_codec_write(codec, spec->out_pins[0], 0, - AC_VERB_SET_EAPD_BTLENABLE, 0x00); - snd_hda_codec_write(codec, spec->out_pins[0], 0, - VENDOR_CHIPIO_EAPD_SEL_SET, 0x00); - snd_hda_codec_write(codec, spec->out_pins[0], 0, - AC_VERB_SET_EAPD_BTLENABLE, 0x02); + snd_hdac_codec_write(&codec->core, spec->out_pins[1], 0, + VENDOR_CHIPIO_EAPD_SEL_SET, 0x02); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + AC_VERB_SET_EAPD_BTLENABLE, 0x00); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + VENDOR_CHIPIO_EAPD_SEL_SET, 0x00); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + AC_VERB_SET_EAPD_BTLENABLE, 0x02);
/* disable headphone node */ - pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pin_ctl = snd_hdac_codec_read(&codec->core, spec->out_pins[1], + 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); snd_hda_set_pin_ctl(codec, spec->out_pins[1], pin_ctl & ~PIN_HP); /* enable speaker node */ - pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pin_ctl = snd_hdac_codec_read(&codec->core, spec->out_pins[0], + 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); snd_hda_set_pin_ctl(codec, spec->out_pins[0], pin_ctl | PIN_OUT); } else { @@ -3218,23 +3220,27 @@ static int ca0132_select_out(struct hda_codec *codec) goto exit;
/* Setup EAPD */ - snd_hda_codec_write(codec, spec->out_pins[0], 0, - VENDOR_CHIPIO_EAPD_SEL_SET, 0x00); - snd_hda_codec_write(codec, spec->out_pins[0], 0, - AC_VERB_SET_EAPD_BTLENABLE, 0x00); - snd_hda_codec_write(codec, spec->out_pins[1], 0, - VENDOR_CHIPIO_EAPD_SEL_SET, 0x02); - snd_hda_codec_write(codec, spec->out_pins[0], 0, - AC_VERB_SET_EAPD_BTLENABLE, 0x02); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + VENDOR_CHIPIO_EAPD_SEL_SET, 0x00); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + AC_VERB_SET_EAPD_BTLENABLE, 0x00); + snd_hdac_codec_write(&codec->core, spec->out_pins[1], 0, + VENDOR_CHIPIO_EAPD_SEL_SET, 0x02); + snd_hdac_codec_write(&codec->core, spec->out_pins[0], 0, + AC_VERB_SET_EAPD_BTLENABLE, 0x02);
/* disable speaker*/ - pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pin_ctl = snd_hdac_codec_read(&codec->core, spec->out_pins[0], + 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); snd_hda_set_pin_ctl(codec, spec->out_pins[0], pin_ctl & ~PIN_HP); /* enable headphone*/ - pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pin_ctl = snd_hdac_codec_read(&codec->core, spec->out_pins[1], + 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); snd_hda_set_pin_ctl(codec, spec->out_pins[1], pin_ctl | PIN_HP); } @@ -3476,12 +3482,11 @@ static int ca0132_pe_switch_set(struct hda_codec *codec) static int stop_mic1(struct hda_codec *codec) { struct ca0132_spec *spec = codec->spec; - unsigned int oldval = snd_hda_codec_read(codec, spec->adcs[0], 0, + unsigned int oldval = snd_hdac_codec_read(&codec->core, spec->adcs[0], 0, AC_VERB_GET_CONV, 0); if (oldval != 0) - snd_hda_codec_write(codec, spec->adcs[0], 0, - AC_VERB_SET_CHANNEL_STREAMID, - 0); + snd_hdac_codec_write(&codec->core, spec->adcs[0], 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); return oldval; }
@@ -3491,9 +3496,8 @@ static void resume_mic1(struct hda_codec *codec, unsigned int oldval) struct ca0132_spec *spec = codec->spec; /* Restore the previous stream and channel */ if (oldval != 0) - snd_hda_codec_write(codec, spec->adcs[0], 0, - AC_VERB_SET_CHANNEL_STREAMID, - oldval); + snd_hdac_codec_write(&codec->core, spec->adcs[0], 0, + AC_VERB_SET_CHANNEL_STREAMID, oldval); }
/* @@ -4113,13 +4117,13 @@ static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) if (pin) { snd_hda_set_pin_ctl(codec, pin, PIN_HP); if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) - snd_hda_codec_write(codec, pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, - AMP_OUT_UNMUTE); + snd_hdac_codec_write(&codec->core, pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE); } if (dac && (get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) - snd_hda_codec_write(codec, dac, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO); + snd_hdac_codec_write(&codec->core, dac, 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO); }
static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) @@ -4127,13 +4131,14 @@ static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) if (pin) { snd_hda_set_pin_ctl(codec, pin, PIN_VREF80); if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) - snd_hda_codec_write(codec, pin, 0, - AC_VERB_SET_AMP_GAIN_MUTE, - AMP_IN_UNMUTE(0)); + snd_hdac_codec_write(&codec->core, pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_IN_UNMUTE(0)); } if (adc && (get_wcaps(codec, adc) & AC_WCAP_IN_AMP)) { - snd_hda_codec_write(codec, adc, 0, AC_VERB_SET_AMP_GAIN_MUTE, - AMP_IN_UNMUTE(0)); + snd_hdac_codec_write(&codec->core, adc, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_IN_UNMUTE(0));
/* init to 0 dB and unmute. */ snd_hda_codec_amp_stereo(codec, adc, HDA_INPUT, 0, @@ -4173,8 +4178,8 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable)
val = spec->dmic_ctl; val |= 0x80; - snd_hda_codec_write(codec, spec->input_pins[0], 0, - VENDOR_CHIPIO_DMIC_CTL_SET, val); + snd_hdac_codec_write(&codec->core, spec->input_pins[0], 0, + VENDOR_CHIPIO_DMIC_CTL_SET, val);
if (!(spec->dmic_ctl & 0x20)) chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 1); @@ -4186,8 +4191,8 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable) val = spec->dmic_ctl; /* clear bit7 and bit5 to disable dmic */ val &= 0x5f; - snd_hda_codec_write(codec, spec->input_pins[0], 0, - VENDOR_CHIPIO_DMIC_CTL_SET, val); + snd_hdac_codec_write(&codec->core, spec->input_pins[0], 0, + VENDOR_CHIPIO_DMIC_CTL_SET, val);
if (!(spec->dmic_ctl & 0x20)) chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 0); @@ -4214,8 +4219,8 @@ static void ca0132_init_dmic(struct hda_codec *codec) * Bit 7-4: reserved */ val = 0x01; - snd_hda_codec_write(codec, spec->input_pins[0], 0, - VENDOR_CHIPIO_DMIC_MCLK_SET, val); + snd_hdac_codec_write(&codec->core, spec->input_pins[0], 0, + VENDOR_CHIPIO_DMIC_MCLK_SET, val);
/* Data1 uses MPIO3. Data2 not use * Bit 2-0: Data1 MPIO select @@ -4224,8 +4229,8 @@ static void ca0132_init_dmic(struct hda_codec *codec) * Bit 7: set disable Data2 */ val = 0x83; - snd_hda_codec_write(codec, spec->input_pins[0], 0, - VENDOR_CHIPIO_DMIC_PIN_SET, val); + snd_hdac_codec_write(&codec->core, spec->input_pins[0], 0, + VENDOR_CHIPIO_DMIC_PIN_SET, val);
/* Use Ch-0 and Ch-1. Rate is 48K, mode 1. Disable DMic first. * Bit 3-0: Channel mask @@ -4237,8 +4242,8 @@ static void ca0132_init_dmic(struct hda_codec *codec) val = 0x23; /* keep a copy of dmic ctl val for enable/disable dmic purpuse */ spec->dmic_ctl = val; - snd_hda_codec_write(codec, spec->input_pins[0], 0, - VENDOR_CHIPIO_DMIC_CTL_SET, val); + snd_hdac_codec_write(&codec->core, spec->input_pins[0], 0, + VENDOR_CHIPIO_DMIC_CTL_SET, val); }
/* @@ -4249,18 +4254,18 @@ static void ca0132_init_analog_mic2(struct hda_codec *codec) struct ca0132_spec *spec = codec->spec;
mutex_lock(&spec->chipio_mutex); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x2D); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); - snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, - VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x2D); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); + snd_hdac_codec_write(&codec->core, WIDGET_CHIP_CTRL, 0, + VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); mutex_unlock(&spec->chipio_mutex); }
Move patch_cirrus to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_cirrus.c | 52 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 584a0343ab0c..f07b90bb438f 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -142,9 +142,9 @@ enum { static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) { struct cs_spec *spec = codec->spec; - snd_hda_codec_write(codec, spec->vendor_nid, 0, - AC_VERB_SET_COEF_INDEX, idx); - return snd_hda_codec_read(codec, spec->vendor_nid, 0, + snd_hdac_codec_write(&codec->core, spec->vendor_nid, 0, + AC_VERB_SET_COEF_INDEX, idx); + return snd_hdac_codec_read(&codec->core, spec->vendor_nid, 0, AC_VERB_GET_PROC_COEF, 0); }
@@ -152,10 +152,10 @@ static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, unsigned int coef) { struct cs_spec *spec = codec->spec; - snd_hda_codec_write(codec, spec->vendor_nid, 0, - AC_VERB_SET_COEF_INDEX, idx); - snd_hda_codec_write(codec, spec->vendor_nid, 0, - AC_VERB_SET_PROC_COEF, coef); + snd_hdac_codec_write(&codec->core, spec->vendor_nid, 0, + AC_VERB_SET_COEF_INDEX, idx); + snd_hdac_codec_write(&codec->core, spec->vendor_nid, 0, + AC_VERB_SET_PROC_COEF, coef); }
/* @@ -176,8 +176,8 @@ static void cs_automute(struct hda_codec *codec) if (spec->gpio_eapd_hp || spec->gpio_eapd_speaker) { spec->gpio_data = spec->gen.hp_jack_present ? spec->gpio_eapd_hp : spec->gpio_eapd_speaker; - snd_hda_codec_write(codec, 0x01, 0, - AC_VERB_SET_GPIO_DATA, spec->gpio_data); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DATA, spec->gpio_data); } }
@@ -316,12 +316,13 @@ static int cs_init(struct hda_codec *codec) snd_hda_gen_init(codec);
if (spec->gpio_mask) { - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, - spec->gpio_mask); - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, - spec->gpio_dir); - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, - spec->gpio_data); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_MASK, spec->gpio_mask); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DIRECTION, + spec->gpio_dir); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DATA, spec->gpio_data); }
if (spec->vendor_nid == CS420X_VENDOR_NID) { @@ -1033,12 +1034,13 @@ static int cs421x_init(struct hda_codec *codec) snd_hda_gen_init(codec);
if (spec->gpio_mask) { - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, - spec->gpio_mask); - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, - spec->gpio_dir); - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, - spec->gpio_data); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_MASK, spec->gpio_mask); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DIRECTION, + spec->gpio_dir); + snd_hdac_codec_write(&codec->core, 0x01, 0, + AC_VERB_SET_GPIO_DATA, spec->gpio_data); }
init_input_coef(codec); @@ -1111,10 +1113,10 @@ static int cs421x_suspend(struct hda_codec *codec)
snd_hda_shutup_pins(codec);
- snd_hda_codec_write(codec, CS4210_DAC_NID, 0, - AC_VERB_SET_POWER_STATE, AC_PWRST_D3); - snd_hda_codec_write(codec, CS4210_ADC_NID, 0, - AC_VERB_SET_POWER_STATE, AC_PWRST_D3); + snd_hdac_codec_write(&codec->core, CS4210_DAC_NID, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D3); + snd_hdac_codec_write(&codec->core, CS4210_ADC_NID, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
if (spec->vendor_nid == CS4210_VENDOR_NID) { coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
Move to use newly moved snd_hdac_write_codec() API
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_conexant.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index ca03c40609fc..c6cdfae01cc0 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -147,9 +147,9 @@ static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, int i; for (i = 0; i < num_pins; i++) { if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) - snd_hda_codec_write(codec, pins[i], 0, - AC_VERB_SET_EAPD_BTLENABLE, - on ? 0x02 : 0); + snd_hdac_codec_write(&codec->core, pins[i], 0, + AC_VERB_SET_EAPD_BTLENABLE, + on ? 0x02 : 0); } }
@@ -168,9 +168,9 @@ static void cx_auto_vmaster_hook_mute_led(void *private_data, int enabled) struct hda_codec *codec = private_data; struct conexant_spec *spec = codec->spec;
- snd_hda_codec_write(codec, spec->mute_led_eapd, 0, - AC_VERB_SET_EAPD_BTLENABLE, - enabled ? 0x00 : 0x02); + snd_hdac_codec_write(&codec->core, spec->mute_led_eapd, 0, + AC_VERB_SET_EAPD_BTLENABLE, + enabled ? 0x00 : 0x02); }
static int cx_auto_build_controls(struct hda_codec *codec) @@ -212,8 +212,8 @@ static void cx_auto_reboot_notify(struct hda_codec *codec) cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3); - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_SET_POWER_STATE, AC_PWRST_D3); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D3); }
static void cx_auto_free(struct hda_codec *codec) @@ -367,8 +367,8 @@ static void olpc_xo_update_mic_boost(struct hda_codec *codec) (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT); if (!spec->dc_enable) val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0); - snd_hda_codec_write(codec, 0x17, 0, - AC_VERB_SET_AMP_GAIN_MUTE, val); + snd_hdac_codec_write(&codec->core, 0x17, 0, + AC_VERB_SET_AMP_GAIN_MUTE, val); } }
Move patch_hdmi to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_hdmi.c | 285 +++++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 140 deletions(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index acbfbe087ee8..e82488ddb9d4 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -488,8 +488,8 @@ static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, { int val;
- val = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_HDMI_DIP_INDEX, 0); + val = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_HDMI_DIP_INDEX, 0);
*packet_index = val >> 5; *byte_index = val & 0x1f; @@ -503,13 +503,15 @@ static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
val = (packet_index << 5) | (byte_index & 0x1f);
- snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_HDMI_DIP_INDEX, val); }
static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, unsigned char val) { - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_HDMI_DIP_DATA, val); }
static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) @@ -519,8 +521,9 @@ static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
/* Unmute */ if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) - snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE);
if (spec->dyn_pin_out) /* Disable pin out until stream is active */ @@ -531,13 +534,13 @@ static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) */ pin_out = PIN_OUT;
- snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, pin_out); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, pin_out); }
static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid) { - return 1 + snd_hda_codec_read(codec, cvt_nid, 0, + return 1 + snd_hdac_codec_read(&codec->core, cvt_nid, 0, AC_VERB_GET_CVT_CHAN_COUNT, 0); }
@@ -545,8 +548,8 @@ static void hdmi_set_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid, int chs) { if (chs != hdmi_get_channel_count(codec, cvt_nid)) - snd_hda_codec_write(codec, cvt_nid, 0, - AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); + snd_hdac_codec_write(&codec->core, cvt_nid, 0, + AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); }
/* @@ -932,7 +935,7 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, int asp_slot, int channel) { - return snd_hda_codec_write(codec, pin_nid, 0, + return snd_hdac_codec_write(&codec->core, pin_nid, 0, AC_VERB_SET_HDMI_CHAN_SLOT, (channel << 4) | asp_slot); } @@ -940,7 +943,7 @@ static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, static int hdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, int asp_slot) { - return (snd_hda_codec_read(codec, pin_nid, 0, + return (snd_hdac_codec_read(&codec->core, pin_nid, 0, AC_VERB_GET_HDMI_CHAN_SLOT, asp_slot) & 0xf0) >> 4; } @@ -956,8 +959,8 @@ static void hdmi_start_infoframe_trans(struct hda_codec *codec, hda_nid_t pin_nid) { hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, - AC_DIPXMIT_BEST); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST); }
/* @@ -967,8 +970,8 @@ static void hdmi_stop_infoframe_trans(struct hda_codec *codec, hda_nid_t pin_nid) { hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, - AC_DIPXMIT_DISABLE); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE); }
static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) @@ -981,8 +984,8 @@ static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) codec_dbg(codec, "HDMI: ELD buf size is %d\n", size);
for (i = 0; i < 8; i++) { - size = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_HDMI_DIP_SIZE, i); + size = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_HDMI_DIP_SIZE, i); codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); } #endif @@ -995,8 +998,8 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) int size; int pi, bi; for (i = 0; i < 8; i++) { - size = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_HDMI_DIP_SIZE, i); + size = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_HDMI_DIP_SIZE, i); if (size == 0) continue;
@@ -1051,14 +1054,14 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, u8 val; int i;
- if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) + if (snd_hdac_codec_read(&codec->core, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) != AC_DIPXMIT_BEST) return false;
hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); for (i = 0; i < size; i++) { - val = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_HDMI_DIP_DATA, 0); + val = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_HDMI_DIP_DATA, 0); if (val != dip[i]) return false; } @@ -1130,9 +1133,9 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, return;
if (is_haswell_plus(codec)) - snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_AMP_GAIN_MUTE, - AMP_OUT_UNMUTE); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE);
eld = &per_pin->sink_eld;
@@ -1251,14 +1254,16 @@ static void haswell_verify_D0(struct hda_codec *codec, /* For Haswell, the converter 1/2 may keep in D3 state after bootup, * thus pins could only choose converter 0 for use. Make sure the * converters are in correct power state */ - if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) - snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); + if (!snd_hdac_check_power_state(&codec->core, cvt_nid, AC_PWRST_D0)) + snd_hdac_codec_write(&codec->core, cvt_nid, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
- if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, - AC_PWRST_D0); + if (!snd_hdac_check_power_state(&codec->core, nid, AC_PWRST_D0)) { + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D0); msleep(40); - pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); + pwr = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_POWER_STATE, 0); pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT; codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); } @@ -1278,8 +1283,9 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, int pinctl, new_pinctl;
if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { - pinctl = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pinctl = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0);
if (pinctl < 0) return hbr ? -EINVAL : 0; @@ -1297,9 +1303,9 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, new_pinctl);
if (pinctl != new_pinctl) - snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - new_pinctl); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + new_pinctl); } else if (hbr) return -EINVAL;
@@ -1375,8 +1381,8 @@ static void intel_verify_pin_cvt_connect(struct hda_codec *codec, int mux_idx, curr;
mux_idx = per_pin->mux_idx; - curr = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_CONNECT_SEL, 0); + curr = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_CONNECT_SEL, 0); if (curr != mux_idx) snd_hda_codec_write_cache(codec, pin_nid, 0, AC_VERB_SET_CONNECT_SEL, @@ -1411,8 +1417,8 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec, if (nid == pin_nid) continue;
- curr = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_CONNECT_SEL, 0); + curr = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_CONNECT_SEL, 0); if (curr != mux_idx) continue;
@@ -1816,11 +1822,12 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, mutex_unlock(&per_pin->lock);
if (spec->dyn_pin_out) { - pinctl = snd_hda_codec_read(codec, pin_nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - snd_hda_codec_write(codec, pin_nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - pinctl | PIN_OUT); + pinctl = snd_hdac_codec_read(&codec->core, pin_nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + pinctl | PIN_OUT); }
return spec->ops.setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); @@ -1860,11 +1867,14 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, per_pin = get_pin(spec, pin_idx);
if (spec->dyn_pin_out) { - pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - snd_hda_codec_write(codec, per_pin->pin_nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - pinctl & ~PIN_OUT); + pinctl = snd_hdac_codec_read(&codec->core, + per_pin->pin_nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); + snd_hdac_codec_write(&codec->core, per_pin->pin_nid, + 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + pinctl & ~PIN_OUT); }
snd_hda_spdif_ctls_unassign(codec, pin_idx); @@ -2278,14 +2288,15 @@ static void intel_haswell_enable_all_pins(struct hda_codec *codec, { unsigned int vendor_param;
- vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, - INTEL_GET_VENDOR_VERB, 0); + vendor_param = snd_hdac_codec_read(&codec->core, INTEL_VENDOR_NID, 0, + INTEL_GET_VENDOR_VERB, 0); if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) return;
vendor_param |= INTEL_EN_ALL_PIN_CVTS; - vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, - INTEL_SET_VENDOR_VERB, vendor_param); + vendor_param = snd_hdac_codec_read(&codec->core, INTEL_VENDOR_NID, 0, + INTEL_SET_VENDOR_VERB, + vendor_param); if (vendor_param == -1) return;
@@ -2297,8 +2308,8 @@ static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) { unsigned int vendor_param;
- vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, - INTEL_GET_VENDOR_VERB, 0); + vendor_param = snd_hdac_codec_read(&codec->core, INTEL_VENDOR_NID, 0, + INTEL_GET_VENDOR_VERB, 0); if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) return;
@@ -2320,7 +2331,8 @@ static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, intel_haswell_fixup_enable_dp12(codec); }
- snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); + snd_hdac_codec_read(&codec->core, fg, 0, AC_VERB_SET_POWER_STATE, + power_state); snd_hda_codec_set_power_to_all(codec, fg, power_state); }
@@ -2451,12 +2463,13 @@ static int simple_playback_init(struct hda_codec *codec) struct hdmi_spec_per_pin *per_pin = get_pin(spec, 0); hda_nid_t pin = per_pin->pin_nid;
- snd_hda_codec_write(codec, pin, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + snd_hdac_codec_write(&codec->core, pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); /* some codecs require to unmute the pin */ if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) - snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, - AMP_OUT_UNMUTE); + snd_hdac_codec_write(&codec->core, pin, 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE); snd_hda_jack_detect_enable(codec, pin); return 0; } @@ -2684,12 +2697,12 @@ static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec,
/* Set the audio infoframe channel allocation and checksum fields. The * channel count is computed implicitly by the hardware. */ - snd_hda_codec_write(codec, 0x1, 0, - Nv_VERB_SET_Channel_Allocation, chanmask); + snd_hdac_codec_write(&codec->core, 0x1, 0, + Nv_VERB_SET_Channel_Allocation, chanmask);
- snd_hda_codec_write(codec, 0x1, 0, - Nv_VERB_SET_Info_Frame_Checksum, - (0x71 - chan - chanmask)); + snd_hdac_codec_write(&codec->core, 0x1, 0, + Nv_VERB_SET_Info_Frame_Checksum, + (0x71 - chan - chanmask)); }
static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo, @@ -2699,15 +2712,15 @@ static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo, struct hdmi_spec *spec = codec->spec; int i;
- snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, - 0, AC_VERB_SET_CHANNEL_STREAMID, 0); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); for (i = 0; i < 4; i++) { /* set the stream id */ - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, - AC_VERB_SET_CHANNEL_STREAMID, 0); + snd_hdac_codec_write(&codec->core, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); /* set the stream format */ - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, - AC_VERB_SET_STREAM_FORMAT, 0); + snd_hdac_codec_write(&codec->core, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_STREAM_FORMAT, 0); }
/* The audio hardware sends a channel count of 0x7 (8ch) when all the @@ -2740,32 +2753,27 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_1, - spdif->ctls & ~AC_DIG1_ENABLE & 0xff); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, + 0, AC_VERB_SET_DIGI_CONVERT_1, + spdif->ctls & ~AC_DIG1_ENABLE & 0xff);
/* set the stream id */ - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, - AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, 0, + AC_VERB_SET_CHANNEL_STREAMID, + (stream_tag << 4) | 0x0);
/* set the stream format */ - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, - AC_VERB_SET_STREAM_FORMAT, format); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, 0, + AC_VERB_SET_STREAM_FORMAT, format);
/* turn on again (if needed) */ /* enable and set the channel status audio/data flag */ if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_1, - spdif->ctls & 0xff); - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, + 0, AC_VERB_SET_DIGI_CONVERT_1, + spdif->ctls & 0xff); + snd_hdac_codec_write(&codec->core, nvhdmi_master_con_nid_7x, + 0, AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); }
for (i = 0; i < 4; i++) { @@ -2779,36 +2787,29 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, */ if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_1, - spdif->ctls & ~AC_DIG1_ENABLE & 0xff); + snd_hdac_codec_write(&codec->core, + nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_DIGI_CONVERT_1, + spdif->ctls & ~AC_DIG1_ENABLE & 0xff); /* set the stream id */ - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_CHANNEL_STREAMID, - (stream_tag << 4) | channel_id); + snd_hdac_codec_write(&codec->core, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_CHANNEL_STREAMID, + (stream_tag << 4) | channel_id); /* set the stream format */ - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_STREAM_FORMAT, - format); + snd_hdac_codec_write(&codec->core, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_STREAM_FORMAT, format); /* turn on again (if needed) */ /* enable and set the channel status audio/data flag */ if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_1, - spdif->ctls & 0xff); - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); + snd_hdac_codec_write(&codec->core, + nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_DIGI_CONVERT_1, + spdif->ctls & 0xff); + snd_hdac_codec_write(&codec->core, + nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_DIGI_CONVERT_2, + dataDCC2); } }
@@ -3000,21 +3001,19 @@ static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) unsigned int value;
/* bits [31:30] contain the trigger and valid bits */ - value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, - NVIDIA_GET_SCRATCH0, 0); + value = snd_hdac_codec_read(&codec->core, NVIDIA_AFG_NID, 0, + NVIDIA_GET_SCRATCH0, 0); value = (value >> 24) & 0xff;
/* bits [15:0] are used to store the HDA format */ - snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, - NVIDIA_SET_SCRATCH0_BYTE0, - (format >> 0) & 0xff); - snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, - NVIDIA_SET_SCRATCH0_BYTE1, - (format >> 8) & 0xff); + snd_hdac_codec_write(&codec->core, NVIDIA_AFG_NID, 0, + NVIDIA_SET_SCRATCH0_BYTE0, (format >> 0) & 0xff); + snd_hdac_codec_write(&codec->core, NVIDIA_AFG_NID, 0, + NVIDIA_SET_SCRATCH0_BYTE1, (format >> 8) & 0xff);
/* bits [16:24] are unused */ - snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, - NVIDIA_SET_SCRATCH0_BYTE2, 0); + snd_hdac_codec_write(&codec->core, NVIDIA_AFG_NID, 0, + NVIDIA_SET_SCRATCH0_BYTE2, 0);
/* * Bit 30 signals that the data is valid and hence that HDMI audio can @@ -3032,8 +3031,8 @@ static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) */ value ^= NVIDIA_SCRATCH_TRIGGER;
- snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, - NVIDIA_SET_SCRATCH0_BYTE3, value); + snd_hdac_codec_write(&codec->core, NVIDIA_AFG_NID, 0, + NVIDIA_SET_SCRATCH0_BYTE3, value); }
static int tegra_hdmi_pcm_prepare(struct hda_pcm_stream *hinfo, @@ -3176,7 +3175,8 @@ static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, int active_channels, int conn_type) { - snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + ATI_VERB_SET_CHANNEL_ALLOCATION, ca); }
static int atihdmi_paired_swap_fc_lfe(int pos) @@ -3275,7 +3275,7 @@ static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_n if (stream_channel != 0xf) ati_channel_setup = (stream_channel << 4) | ATI_OUT_ENABLE;
- return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); + return snd_hdac_codec_write(&codec->core, pin_nid, 0, verb, ati_channel_setup); }
static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, @@ -3299,7 +3299,8 @@ static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_n
verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e;
- ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); + ati_channel_setup = snd_hdac_codec_read(&codec->core, pin_nid, 0, + verb, 0);
if (!(ati_channel_setup & ATI_OUT_ENABLE)) return 0xf; @@ -3364,7 +3365,8 @@ static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, { int hbr_ctl, hbr_ctl_new;
- hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); + hbr_ctl = snd_hdac_codec_read(&codec->core, pin_nid, 0, + ATI_VERB_GET_HBR_CONTROL, 0); if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) { if (hbr) hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE; @@ -3378,9 +3380,9 @@ static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, hbr_ctl_new);
if (hbr_ctl != hbr_ctl_new) - snd_hda_codec_write(codec, pin_nid, 0, - ATI_VERB_SET_HBR_CONTROL, - hbr_ctl_new); + snd_hdac_codec_write(&codec->core, pin_nid, 0, + ATI_VERB_SET_HBR_CONTROL, + hbr_ctl_new);
} else if (hbr) return -EINVAL; @@ -3398,7 +3400,8 @@ static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, if (format & AC_FMT_TYPE_NON_PCM) ramp_rate = 0;
- snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); + snd_hdac_codec_write(&codec->core, cvt_nid, 0, + ATI_VERB_SET_RAMP_RATE, ramp_rate); }
return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); @@ -3419,13 +3422,15 @@ static int atihdmi_init(struct hda_codec *codec) struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
/* make sure downmix information in infoframe is zero */ - snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); + snd_hdac_codec_write(&codec->core, per_pin->pin_nid, 0, + ATI_VERB_SET_DOWNMIX_INFO, 0);
/* enable channel-wise remap mode if supported */ if (has_amd_full_remap_support(codec)) - snd_hda_codec_write(codec, per_pin->pin_nid, 0, - ATI_VERB_SET_MULTICHANNEL_MODE, - ATI_MULTICHANNEL_MODE_SINGLE); + snd_hdac_codec_write(&codec->core, per_pin->pin_nid, + 0, + ATI_VERB_SET_MULTICHANNEL_MODE, + ATI_MULTICHANNEL_MODE_SINGLE); }
return 0;
Move patch_realtek to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- 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; }
Move patch_si3054 to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_si3054.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index 5104bebb2286..5c2a3f7e9b6d 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c @@ -75,8 +75,8 @@ #define SI3054_CHIPID_CODEC_ID (1<<12)
/* si3054 codec registers (nodes) access macros */ -#define GET_REG(codec,reg) (snd_hda_codec_read(codec,reg,0,SI3054_VERB_READ_NODE,0)) -#define SET_REG(codec,reg,val) (snd_hda_codec_write(codec,reg,0,SI3054_VERB_WRITE_NODE,val)) +#define GET_REG(codec,reg) (snd_hdac_codec_read(&codec->core,reg,0,SI3054_VERB_READ_NODE,0)) +#define SET_REG(codec,reg,val) (snd_hdac_codec_write(&codec->core,reg,0,SI3054_VERB_WRITE_NODE,val)) #define SET_REG_CACHE(codec,reg,val) \ snd_hda_codec_write_cache(codec,reg,0,SI3054_VERB_WRITE_NODE,val)
@@ -226,8 +226,10 @@ static int si3054_init(struct hda_codec *codec) SI3054_VERB_WRITE_NODE)) return -ENOMEM;
- snd_hda_codec_write(codec, AC_NODE_ROOT, 0, AC_VERB_SET_CODEC_RESET, 0); - snd_hda_codec_write(codec, codec->core.mfg, 0, AC_VERB_SET_STREAM_FORMAT, 0); + snd_hdac_codec_write(&codec->core, AC_NODE_ROOT, 0, + AC_VERB_SET_CODEC_RESET, 0); + snd_hdac_codec_write(&codec->core, codec->core.mfg, 0, + AC_VERB_SET_STREAM_FORMAT, 0); SET_REG(codec, SI3054_LINE_RATE, 9600); SET_REG(codec, SI3054_LINE_LEVEL, SI3054_DTAG_MASK|SI3054_ATAG_MASK); SET_REG(codec, SI3054_EXTENDED_MID, 0);
Move patch_sigmatel to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_sigmatel.c | 78 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 9d947aef2c8b..0fc42761a5d2 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -279,13 +279,13 @@ static void stac_capture_pcm_hook(struct hda_pcm_stream *hinfo, switch (action) { case HDA_GEN_PCM_ACT_OPEN: msleep(40); - snd_hda_codec_write(codec, hinfo->nid, 0, - AC_VERB_SET_POWER_STATE, AC_PWRST_D0); + snd_hdac_codec_write(&codec->core, hinfo->nid, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D0); spec->active_adcs |= (1 << idx); break; case HDA_GEN_PCM_ACT_CLOSE: - snd_hda_codec_write(codec, hinfo->nid, 0, - AC_VERB_SET_POWER_STATE, AC_PWRST_D3); + snd_hdac_codec_write(&codec->core, hinfo->nid, 0, + AC_VERB_SET_POWER_STATE, AC_PWRST_D3); spec->active_adcs &= ~(1 << idx); break; } @@ -304,30 +304,30 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
codec_dbg(codec, "%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
- gpiostate = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_GPIO_DATA, 0); + gpiostate = snd_hdac_codec_read(&codec->core, fg, 0, + AC_VERB_GET_GPIO_DATA, 0); gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
- gpiomask = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_GPIO_MASK, 0); + gpiomask = snd_hdac_codec_read(&codec->core, fg, 0, + AC_VERB_GET_GPIO_MASK, 0); gpiomask |= mask;
- gpiodir = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_GPIO_DIRECTION, 0); + gpiodir = snd_hdac_codec_read(&codec->core, fg, 0, + AC_VERB_GET_GPIO_DIRECTION, 0); gpiodir |= dir_mask;
/* Configure GPIOx as CMOS */ - snd_hda_codec_write(codec, fg, 0, 0x7e7, 0); + snd_hdac_codec_write(&codec->core, fg, 0, 0x7e7, 0);
- snd_hda_codec_write(codec, fg, 0, - AC_VERB_SET_GPIO_MASK, gpiomask); - snd_hda_codec_read(codec, fg, 0, - AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ + snd_hdac_codec_write(&codec->core, fg, 0, AC_VERB_SET_GPIO_MASK, + gpiomask); + snd_hdac_codec_read(&codec->core, fg, 0, AC_VERB_SET_GPIO_DIRECTION, + gpiodir); /* sync */
msleep(1);
- snd_hda_codec_read(codec, fg, 0, - AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ + snd_hdac_codec_read(&codec->core, fg, 0, AC_VERB_SET_GPIO_DATA, + gpiostate); /* sync */ }
/* hook for controlling mic-mute LED GPIO */ @@ -366,8 +366,8 @@ static int stac_vrefout_set(struct hda_codec *codec, int error, pinctl;
codec_dbg(codec, "%s, nid %x ctl %x\n", __func__, nid, new_vref); - pinctl = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + pinctl = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
if (pinctl < 0) return pinctl; @@ -434,7 +434,7 @@ static void stac_update_outputs(struct hda_codec *codec)
if (spec->gpio_mute) spec->gen.master_mute = - !(snd_hda_codec_read(codec, codec->core.afg, 0, + !(snd_hdac_codec_read(&codec->core, codec->core.afg, 0, AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
snd_hda_gen_update_outputs(codec); @@ -478,8 +478,8 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, if (val != spec->power_map_bits) { spec->power_map_bits = val; if (do_write) - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_IDT_SET_POWER_MAP, val); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_IDT_SET_POWER_MAP, val); } }
@@ -510,9 +510,8 @@ static void jack_update_power(struct hda_codec *codec, false); }
- snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_IDT_SET_POWER_MAP, - spec->power_map_bits); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_IDT_SET_POWER_MAP, spec->power_map_bits); }
static void stac_vref_event(struct hda_codec *codec, @@ -520,11 +519,11 @@ static void stac_vref_event(struct hda_codec *codec, { unsigned int data;
- data = snd_hda_codec_read(codec, codec->core.afg, 0, - AC_VERB_GET_GPIO_DATA, 0); + data = snd_hdac_codec_read(&codec->core, codec->core.afg, 0, + AC_VERB_GET_GPIO_DATA, 0); /* toggle VREF state based on GPIOx status */ - snd_hda_codec_write(codec, codec->core.afg, 0, 0x7e0, - !!(data & (1 << event->private_data))); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, 0x7e0, + !!(data & (1 << event->private_data))); }
/* initialize the power map and enable the power event to jacks that @@ -625,8 +624,8 @@ static int stac_aloopback_put(struct snd_kcontrol *kcontrol, /* Only return the bits defined by the shift value of the * first two bytes of the mask */ - dac_mode = snd_hda_codec_read(codec, codec->core.afg, 0, - kcontrol->private_value & 0xFFFF, 0x0); + dac_mode = snd_hdac_codec_read(&codec->core, codec->core.afg, 0, + kcontrol->private_value & 0xFFFF, 0x0); dac_mode >>= spec->aloopback_shift;
if (spec->aloopback & idx_val) { @@ -4331,18 +4330,19 @@ static int stac_init(struct hda_codec *codec)
/* sync the power-map */ if (spec->num_pwrs) - snd_hda_codec_write(codec, codec->core.afg, 0, - AC_VERB_IDT_SET_POWER_MAP, - spec->power_map_bits); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, + AC_VERB_IDT_SET_POWER_MAP, + spec->power_map_bits);
/* power down inactive ADCs */ if (spec->powerdown_adcs) { for (i = 0; i < spec->gen.num_all_adcs; i++) { if (spec->active_adcs & (1 << i)) continue; - snd_hda_codec_write(codec, spec->gen.all_adcs[i], 0, - AC_VERB_SET_POWER_STATE, - AC_PWRST_D3); + snd_hdac_codec_write(&codec->core, + spec->gen.all_adcs[i], 0, + AC_VERB_SET_POWER_STATE, + AC_PWRST_D3); } }
@@ -4369,7 +4369,7 @@ static void stac92hd_proc_hook(struct snd_info_buffer *buffer, { if (nid == codec->core.afg) snd_iprintf(buffer, "Power-Map: 0x%02x\n", - snd_hda_codec_read(codec, nid, 0, + snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_IDT_GET_POWER_MAP, 0)); }
@@ -4378,7 +4378,7 @@ static void analog_loop_proc_hook(struct snd_info_buffer *buffer, unsigned int verb) { snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", - snd_hda_codec_read(codec, codec->core.afg, 0, verb, 0)); + snd_hdac_codec_read(&codec->core, codec->core.afg, 0, verb, 0)); }
/* stac92hd71bxx, stac92hd73xx */
Move patch_via to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/patch_via.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index da5366405eda..81bbc7d48911 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -208,7 +208,7 @@ static void vt1708_stop_hp_work(struct hda_codec *codec) if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs) return; if (spec->hp_work_active) { - snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1); + snd_hdac_codec_write(&codec->core, 0x1, 0, 0xf81, 1); codec->jackpoll_interval = 0; cancel_delayed_work_sync(&codec->jackpoll_work); spec->hp_work_active = false; @@ -223,7 +223,7 @@ static void vt1708_update_hp_work(struct hda_codec *codec) if (spec->vt1708_jack_detect) { if (!spec->hp_work_active) { codec->jackpoll_interval = msecs_to_jiffies(100); - snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0); + snd_hdac_codec_write(&codec->core, 0x1, 0, 0xf81, 0); schedule_delayed_work(&codec->jackpoll_work, 0); spec->hp_work_active = true; } @@ -395,7 +395,7 @@ static void __analog_low_current_mode(struct hda_codec *codec, bool force) return; /* other codecs are not supported */ } /* send verb */ - snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); + snd_hdac_codec_write(&codec->core, codec->core.afg, 0, verb, parm); }
static void analog_low_current_mode(struct hda_codec *codec) @@ -944,8 +944,8 @@ static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol, struct hda_codec *codec = snd_kcontrol_chip(kcontrol); int index = 0;
- index = snd_hda_codec_read(codec, 0x26, 0, - AC_VERB_GET_CONNECT_SEL, 0); + index = snd_hdac_codec_read(&codec->core, 0x26, 0, + AC_VERB_GET_CONNECT_SEL, 0); if (index != -1) *ucontrol->value.integer.value = index;
@@ -959,8 +959,8 @@ static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol, struct via_spec *spec = codec->spec; int index = *ucontrol->value.integer.value;
- snd_hda_codec_write(codec, 0x26, 0, - AC_VERB_SET_CONNECT_SEL, index); + snd_hdac_codec_write(&codec->core, 0x26, 0, AC_VERB_SET_CONNECT_SEL, + index); spec->dmic_enabled = index; return 1; }
Move hda_codec to use newly moved snd_hdac_read/write_codec() APIs
This was done using coccinelle script
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_codec.c | 85 ++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 41 deletions(-)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 37f43a1b34ef..c551dda68803 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -145,7 +145,8 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_write); void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq) { for (; seq->nid; seq++) - snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); + snd_hdac_codec_write(&codec->core, seq->nid, 0, seq->verb, + seq->param); } EXPORT_SYMBOL_GPL(snd_hda_sequence_write);
@@ -445,11 +446,11 @@ static int read_pin_defaults(struct hda_codec *codec) if (!pin) return -ENOMEM; pin->nid = nid; - pin->cfg = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_CONFIG_DEFAULT, 0); - pin->ctrl = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, - 0); + pin->cfg = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_CONFIG_DEFAULT, 0); + pin->ctrl = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); } return 0; } @@ -605,8 +606,8 @@ void snd_hda_shutup_pins(struct hda_codec *codec) for (i = 0; i < codec->init_pins.used; i++) { struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); /* use read here for syncing after issuing each verb */ - 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; } @@ -623,9 +624,9 @@ static void restore_shutup_pins(struct hda_codec *codec) return; for (i = 0; i < codec->init_pins.used; i++) { struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); - snd_hda_codec_write(codec, pin->nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - pin->ctrl); + snd_hdac_codec_write(&codec->core, pin->nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + pin->ctrl); } codec->pins_shutup = 0; } @@ -983,12 +984,13 @@ static void update_pcm_stream_id(struct hda_codec *codec, unsigned int oldval, newval;
if (p->stream_tag != stream_tag || p->channel_id != channel_id) { - oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); + oldval = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_CONV, 0); newval = (stream_tag << 4) | channel_id; if (oldval != newval) - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_CHANNEL_STREAMID, - newval); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_CHANNEL_STREAMID, + newval); p->stream_tag = stream_tag; p->channel_id = channel_id; } @@ -1001,13 +1003,13 @@ static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p, unsigned int oldval;
if (p->format_id != format) { - oldval = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_STREAM_FORMAT, 0); + oldval = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_STREAM_FORMAT, 0); if (oldval != format) { msleep(1); - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_STREAM_FORMAT, - format); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_STREAM_FORMAT, + format); } p->format_id = format; } @@ -1104,10 +1106,11 @@ static void really_cleanup_stream(struct hda_codec *codec, { hda_nid_t nid = q->nid; if (q->stream_tag || q->channel_id) - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); if (q->format_id) - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0 -); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_STREAM_FORMAT, 0); memset(q, 0, sizeof(*q)); q->nid = nid; if (codec->patch_ops.stream_pm) @@ -2812,7 +2815,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) return err; } codec->spdif_in_enable = - snd_hda_codec_read(codec, nid, 0, + snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0) & AC_DIG1_ENABLE; return 0; @@ -2844,8 +2847,8 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, if (state != power_state && power_state == AC_PWRST_D3) continue; } - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, - state); + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_POWER_STATE, state); } } EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all); @@ -2861,8 +2864,8 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec, unsigned int state, actual_state;
for (;;) { - state = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_POWER_STATE, 0); + state = snd_hdac_codec_read(&codec->core, fg, 0, + AC_VERB_GET_POWER_STATE, 0); if (state & AC_PWRST_ERROR) break; actual_state = (state >> 4) & 0x0f; @@ -2894,7 +2897,7 @@ unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, if (power_state == AC_PWRST_D3 && get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN && (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) { - int eapd = snd_hda_codec_read(codec, nid, 0, + int eapd = snd_hdac_codec_read(&codec->core, nid, 0, AC_VERB_GET_EAPD_BTLENABLE, 0); if (eapd & 0x02) return AC_PWRST_D0; @@ -2933,9 +2936,9 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, if (codec->power_filter) state = codec->power_filter(codec, fg, state); if (state == power_state || power_state != AC_PWRST_D3) - snd_hda_codec_read(codec, fg, flags, - AC_VERB_SET_POWER_STATE, - state); + snd_hdac_codec_read(&codec->core, fg, flags, + AC_VERB_SET_POWER_STATE, + state); snd_hda_codec_set_power_to_all(codec, fg, power_state); } state = hda_sync_power_state(codec, fg, power_state); @@ -2965,9 +2968,9 @@ static void sync_power_up_states(struct hda_codec *codec) target = codec->power_filter(codec, nid, AC_PWRST_D0); if (target == AC_PWRST_D0) continue; - if (!snd_hda_check_power_state(codec, nid, target)) - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_POWER_STATE, target); + if (!snd_hdac_check_power_state(&codec->core, nid, target)) + snd_hdac_codec_write(&codec->core, nid, 0, + AC_VERB_SET_POWER_STATE, target); } }
@@ -3630,8 +3633,8 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, bool reset;
spdif = snd_hda_spdif_out_of_nid(codec, nid); - curr_fmt = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_STREAM_FORMAT, 0); + curr_fmt = snd_hdac_codec_read(&codec->core, nid, 0, + AC_VERB_GET_STREAM_FORMAT, 0); reset = codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE) && curr_fmt != format; @@ -3915,8 +3918,8 @@ unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin) { unsigned int pincap; unsigned int oldval; - oldval = snd_hda_codec_read(codec, pin, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + oldval = snd_hdac_codec_read(&codec->core, pin, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); pincap = snd_hda_query_pin_caps(codec, pin); pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; /* Exception: if the default pin setup is vref50, we give it priority */ @@ -3999,7 +4002,7 @@ EXPORT_SYMBOL_GPL(snd_hda_correct_pin_ctl); * It corrects the pin ctl value via snd_hda_correct_pin_ctl(), stores the * value in pin target array via snd_hda_codec_set_pin_target(), then * actually writes the value via either snd_hda_codec_update_cache() or - * snd_hda_codec_write() depending on @cached flag. + * snd_hdac_codec_write() depending on @cached flag. */ int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val, bool cached) @@ -4010,7 +4013,7 @@ int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, return snd_hda_codec_update_cache(codec, pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); else - return snd_hda_codec_write(codec, pin, 0, + return snd_hdac_codec_write(&codec->core, pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); } EXPORT_SYMBOL_GPL(_snd_hda_set_pin_ctl);
Now that all the users are converted to use new hdac helpers, remove the old APIs
Signed-off-by: Vinod Koul vinod.koul@intel.com --- sound/pci/hda/hda_codec.c | 43 ------------------------------------------- sound/pci/hda/hda_codec.h | 5 ----- sound/pci/hda/hda_local.h | 13 ------------- 3 files changed, 61 deletions(-)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index c551dda68803..8d8dfc42dfcf 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -90,49 +90,6 @@ static int codec_exec_verb(struct hdac_device *dev, unsigned int cmd, return err; }
-/** - * snd_hda_codec_read - send a command and get the response - * @codec: the HDA codec - * @nid: NID to send the command - * @flags: optional bit flags - * @verb: the verb to send - * @parm: the parameter for the verb - * - * Send a single command and read the corresponding response. - * - * Returns the obtained response value, or -1 for an error. - */ -unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, - int flags, - unsigned int verb, unsigned int parm) -{ - unsigned int cmd = snd_hdac_make_cmd(&codec->core, nid, verb, parm); - unsigned int res; - if (snd_hdac_exec_verb(&codec->core, cmd, flags, &res)) - return -1; - return res; -} -EXPORT_SYMBOL_GPL(snd_hda_codec_read); - -/** - * snd_hda_codec_write - send a single command without waiting for response - * @codec: the HDA codec - * @nid: NID to send the command - * @flags: optional bit flags - * @verb: the verb to send - * @parm: the parameter for the verb - * - * Send a single command without waiting for response. - * - * Returns 0 if successful, or a negative error code. - */ -int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, - unsigned int verb, unsigned int parm) -{ - unsigned int cmd = snd_hdac_make_cmd(&codec->core, nid, verb, parm); - return snd_hdac_exec_verb(&codec->core, cmd, flags, NULL); -} -EXPORT_SYMBOL_GPL(snd_hda_codec_write);
/** * snd_hda_sequence_write - sequence writes diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 2970413f18a0..cf0261c2d40c 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -309,11 +309,6 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec); /* * low level functions */ -unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, - int flags, - unsigned int verb, unsigned int parm); -int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, - unsigned int verb, unsigned int parm); #define snd_hda_param_read(codec, nid, param) \ snd_hdac_read_parm(&(codec)->core, nid, param) #define snd_hda_get_sub_nodes(codec, nid, start_nid) \ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 4a21c2199e02..82ce77445cfa 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -676,19 +676,6 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec, struct hda_loopback_check *check, hda_nid_t nid);
-/* check whether the actual power state matches with the target state */ -static inline bool -snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid, - unsigned int target_state) -{ - unsigned int state = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_POWER_STATE, 0); - if (state & AC_PWRST_ERROR) - return true; - state = (state >> 4) & 0x0f; - return (state == target_state); -} - unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, hda_nid_t nid, unsigned int power_state);
On Tue, 06 Oct 2015 17:07:37 +0200, Vinod Koul wrote:
Hi Takashi,
Here is the second version which updates the users.
This update was done using coccinelle scripts. I also noticed that the coccinelle is reformaing the change lines, but changes looked good to me so I have kept them, please do let me know if you would like these to be removed.
Erm, sorry, I didn't want to motivate you in that direction. Basically it's better to keep the old API as is for an old driver like HDA since it makes stable kernel backporting much easier. So, what we'd need is a lazier solution, just to replace the old API as a static inline function wrapping the new API. The end result is same, but it's still compatible with older kernels in the source code level.
thanks,
Takashi
Subhransu S. Prusty (1): ALSA: hdac: Copy codec helpers to core
Vinod Koul (17): ALSA: hda: move hda beep to use hdac helpers ALSA: hda: move hda_eld to use hdac helpers ALSA: hda: move hda_generic to use hdac helpers ALSA: hda: move hda_hwdep to use hdac helpers ALSA: hda: move hda_jack to use hdac helpers ALSA: hda: move hda_proc to use hdac helpers ALSA: hda: move patch_analog to use hdac helpers ALSA: hda: move patch_ca0132.c to use hdac helpers ALSA: hda: move patch_cirrus to use hdac helpers ALSA: hda: move to use hdac helpers ALSA: hda: move patch_hdmi to use hdac helpers ALSA: hda: move patch_realtek to use hdac helpers ALSA: hda: move patch_si3054 to use hdac helpers ALSA: hda: move patch_sigmatel to use hdac helpers ALSA: hda: move patch_via to use hdac helpers ALSA: hda: move hda_codec to use hdac helpers ALSA: hda: remove the old helpers
include/sound/hdaudio.h | 6 + sound/hda/hdac_device.c | 81 ++++++++++++ sound/pci/hda/hda_beep.c | 4 +- sound/pci/hda/hda_codec.c | 128 +++++++----------- sound/pci/hda/hda_codec.h | 5 - sound/pci/hda/hda_eld.c | 65 +++++++--- sound/pci/hda/hda_generic.c | 9 +- sound/pci/hda/hda_hwdep.c | 4 +- sound/pci/hda/hda_jack.c | 8 +- sound/pci/hda/hda_local.h | 13 -- sound/pci/hda/hda_proc.c | 80 ++++++------ sound/pci/hda/patch_analog.c | 10 +- sound/pci/hda/patch_ca0132.c | 223 ++++++++++++++++---------------- sound/pci/hda/patch_cirrus.c | 52 ++++---- sound/pci/hda/patch_conexant.c | 20 +-- sound/pci/hda/patch_hdmi.c | 285 +++++++++++++++++++++-------------------- sound/pci/hda/patch_realtek.c | 136 +++++++++++--------- sound/pci/hda/patch_si3054.c | 10 +- sound/pci/hda/patch_sigmatel.c | 78 +++++------ sound/pci/hda/patch_via.c | 14 +- 20 files changed, 660 insertions(+), 571 deletions(-)
-- 2.4.3
On Tue, 2015-10-06 at 20:12 +0200, Takashi Iwai wrote:
On Tue, 06 Oct 2015 17:07:37 +0200, Vinod Koul wrote:
Hi Takashi,
Here is the second version which updates the users.
This update was done using coccinelle scripts. I also noticed that the coccinelle is reformaing the change lines, but changes looked good to me so I have kept them, please do let me know if you would like these to be removed.
Erm, sorry, I didn't want to motivate you in that direction. Basically it's better to keep the old API as is for an old driver like HDA since it makes stable kernel backporting much easier. So, what we'd need is a lazier solution, just to replace the old API as a static inline function wrapping the new API. The end result is same, but it's still compatible with older kernels in the source code level.
Ah ...
Even while doing this I was thinking that we have few wrappers and should update users..
So are you going to hold off update or do it after some point of time
I will send updated one, though I think at some point of time we need to bite this bullet
participants (3)
-
Koul, Vinod
-
Takashi Iwai
-
Vinod Koul