Commit 43f6c8d9 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Minor code refactoring for Intel HDMI codec parsers

No functional change, just a slight reduction of lines.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent fcc88d91
...@@ -2503,19 +2503,41 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec, ...@@ -2503,19 +2503,41 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec,
} }
} }
/* Intel Haswell and onwards; audio component with eld notifier */ /* precondition and allocation for Intel codecs */
static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) static int alloc_intel_hdmi(struct hda_codec *codec)
{ {
struct hdmi_spec *spec; /* requires i915 binding */
int err;
/* HSW+ requires i915 binding */
if (!codec->bus->core.audio_component) { if (!codec->bus->core.audio_component) {
codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n");
return -ENODEV; return -ENODEV;
} }
err = alloc_generic_hdmi(codec); return alloc_generic_hdmi(codec);
}
/* parse and post-process for Intel codecs */
static int parse_intel_hdmi(struct hda_codec *codec)
{
int err;
err = hdmi_parse_codec(codec);
if (err < 0) {
generic_spec_free(codec);
return err;
}
generic_hdmi_init_per_pins(codec);
register_i915_notifier(codec);
return 0;
}
/* Intel Haswell and onwards; audio component with eld notifier */
static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid)
{
struct hdmi_spec *spec;
int err;
err = alloc_intel_hdmi(codec);
if (err < 0) if (err < 0)
return err; return err;
spec = codec->spec; spec = codec->spec;
...@@ -2539,15 +2561,7 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) ...@@ -2539,15 +2561,7 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid)
spec->ops.setup_stream = i915_hsw_setup_stream; spec->ops.setup_stream = i915_hsw_setup_stream;
spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup;
err = hdmi_parse_codec(codec); return parse_intel_hdmi(codec);
if (err < 0) {
generic_spec_free(codec);
return err;
}
generic_hdmi_init_per_pins(codec);
register_i915_notifier(codec);
return 0;
} }
static int patch_i915_hsw_hdmi(struct hda_codec *codec) static int patch_i915_hsw_hdmi(struct hda_codec *codec)
...@@ -2566,13 +2580,7 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec) ...@@ -2566,13 +2580,7 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec)
struct hdmi_spec *spec; struct hdmi_spec *spec;
int err; int err;
/* requires i915 binding */ err = alloc_intel_hdmi(codec);
if (!codec->bus->core.audio_component) {
codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n");
return -ENODEV;
}
err = alloc_generic_hdmi(codec);
if (err < 0) if (err < 0)
return err; return err;
spec = codec->spec; spec = codec->spec;
...@@ -2587,45 +2595,18 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec) ...@@ -2587,45 +2595,18 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec)
spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup;
err = hdmi_parse_codec(codec); return parse_intel_hdmi(codec);
if (err < 0) {
generic_spec_free(codec);
return err;
}
generic_hdmi_init_per_pins(codec);
register_i915_notifier(codec);
return 0;
} }
/* Intel IronLake, SandyBridge and IvyBridge; with eld notifier */ /* Intel IronLake, SandyBridge and IvyBridge; with eld notifier */
static int patch_i915_cpt_hdmi(struct hda_codec *codec) static int patch_i915_cpt_hdmi(struct hda_codec *codec)
{ {
struct hdmi_spec *spec;
int err; int err;
/* requires i915 binding */ err = alloc_intel_hdmi(codec);
if (!codec->bus->core.audio_component) {
codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n");
return -ENODEV;
}
err = alloc_generic_hdmi(codec);
if (err < 0) if (err < 0)
return err; return err;
spec = codec->spec; return parse_intel_hdmi(codec);
err = hdmi_parse_codec(codec);
if (err < 0)
goto error;
generic_hdmi_init_per_pins(codec);
register_i915_notifier(codec);
return 0;
error:
generic_spec_free(codec);
return err;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment