]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Minor code refactoring for Intel HDMI codec parsers
authorTakashi Iwai <tiwai@suse.de>
Wed, 28 Jun 2017 12:18:29 +0000 (14:18 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jun 2017 14:19:26 +0000 (16:19 +0200)
No functional change, just a slight reduction of lines.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_hdmi.c

index feed8e8de2afa14cad558cc8727ba7bc2592db14..8704ea43381e09b626cf2809bd6cd02f80dea878 100644 (file)
@@ -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);
+       err = alloc_intel_hdmi(codec);
        if (err < 0)
                return err;
-       spec = codec->spec;
-
-       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;
+       return parse_intel_hdmi(codec);
 }
 
 /*