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,
}
}
/* Intel Haswell and onwards; audio component with eld notifier */
static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid)
/* precondition and allocation for Intel codecs */
static int alloc_intel_hdmi(struct hda_codec *codec)
{
struct hdmi_spec *spec;
int err;
/* HSW+ requires i915 binding */
/* requires i915 binding */
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);
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)
return err;
spec = codec->spec;
......@@ -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.pin_cvt_fixup = i915_pin_cvt_fixup;
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;
return parse_intel_hdmi(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)
struct hdmi_spec *spec;
int err;
/* requires i915 binding */
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);
err = alloc_intel_hdmi(codec);
if (err < 0)
return err;
spec = codec->spec;
......@@ -2587,45 +2595,18 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec)
spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup;
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;
return parse_intel_hdmi(codec);
}
/* Intel IronLake, SandyBridge and IvyBridge; with eld notifier */
static int patch_i915_cpt_hdmi(struct hda_codec *codec)
{
struct hdmi_spec *spec;
int err;
/* requires i915 binding */
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)
return err;
spec = codec->spec;
err = hdmi_parse_codec(codec);
err = alloc_intel_hdmi(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;
return parse_intel_hdmi(codec);
}
/*
......
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