diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-06-28 08:18:29 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-06-28 10:19:26 -0400 |
commit | 43f6c8d97bbdc05858b3d64e4c683821ce46c2db (patch) | |
tree | 8210ede0fde0e52008358174112b2a0e94ef9ea5 | |
parent | fcc88d91cd36d1343a0ccc09444b21f6b0dad2d8 (diff) |
ALSA: hda - Minor code refactoring for Intel HDMI codec parsers
No functional change, just a slight reduction of lines.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/hda/patch_hdmi.c | 87 |
1 files changed, 34 insertions, 53 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index feed8e8de2af..8704ea43381e 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -2503,19 +2503,41 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec, | |||
2503 | } | 2503 | } |
2504 | } | 2504 | } |
2505 | 2505 | ||
2506 | /* Intel Haswell and onwards; audio component with eld notifier */ | 2506 | /* precondition and allocation for Intel codecs */ |
2507 | static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) | 2507 | static int alloc_intel_hdmi(struct hda_codec *codec) |
2508 | { | 2508 | { |
2509 | struct hdmi_spec *spec; | 2509 | /* requires i915 binding */ |
2510 | int err; | ||
2511 | |||
2512 | /* HSW+ requires i915 binding */ | ||
2513 | if (!codec->bus->core.audio_component) { | 2510 | if (!codec->bus->core.audio_component) { |
2514 | codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); | 2511 | codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); |
2515 | return -ENODEV; | 2512 | return -ENODEV; |
2516 | } | 2513 | } |
2517 | 2514 | ||
2518 | err = alloc_generic_hdmi(codec); | 2515 | return alloc_generic_hdmi(codec); |
2516 | } | ||
2517 | |||
2518 | /* parse and post-process for Intel codecs */ | ||
2519 | static int parse_intel_hdmi(struct hda_codec *codec) | ||
2520 | { | ||
2521 | int err; | ||
2522 | |||
2523 | err = hdmi_parse_codec(codec); | ||
2524 | if (err < 0) { | ||
2525 | generic_spec_free(codec); | ||
2526 | return err; | ||
2527 | } | ||
2528 | |||
2529 | generic_hdmi_init_per_pins(codec); | ||
2530 | register_i915_notifier(codec); | ||
2531 | return 0; | ||
2532 | } | ||
2533 | |||
2534 | /* Intel Haswell and onwards; audio component with eld notifier */ | ||
2535 | static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) | ||
2536 | { | ||
2537 | struct hdmi_spec *spec; | ||
2538 | int err; | ||
2539 | |||
2540 | err = alloc_intel_hdmi(codec); | ||
2519 | if (err < 0) | 2541 | if (err < 0) |
2520 | return err; | 2542 | return err; |
2521 | spec = codec->spec; | 2543 | spec = codec->spec; |
@@ -2539,15 +2561,7 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) | |||
2539 | spec->ops.setup_stream = i915_hsw_setup_stream; | 2561 | spec->ops.setup_stream = i915_hsw_setup_stream; |
2540 | spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; | 2562 | spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; |
2541 | 2563 | ||
2542 | err = hdmi_parse_codec(codec); | 2564 | return parse_intel_hdmi(codec); |
2543 | if (err < 0) { | ||
2544 | generic_spec_free(codec); | ||
2545 | return err; | ||
2546 | } | ||
2547 | |||
2548 | generic_hdmi_init_per_pins(codec); | ||
2549 | register_i915_notifier(codec); | ||
2550 | return 0; | ||
2551 | } | 2565 | } |
2552 | 2566 | ||
2553 | static int patch_i915_hsw_hdmi(struct hda_codec *codec) | 2567 | 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 | struct hdmi_spec *spec; | 2580 | struct hdmi_spec *spec; |
2567 | int err; | 2581 | int err; |
2568 | 2582 | ||
2569 | /* requires i915 binding */ | 2583 | err = alloc_intel_hdmi(codec); |
2570 | if (!codec->bus->core.audio_component) { | ||
2571 | codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); | ||
2572 | return -ENODEV; | ||
2573 | } | ||
2574 | |||
2575 | err = alloc_generic_hdmi(codec); | ||
2576 | if (err < 0) | 2584 | if (err < 0) |
2577 | return err; | 2585 | return err; |
2578 | spec = codec->spec; | 2586 | spec = codec->spec; |
@@ -2587,45 +2595,18 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec) | |||
2587 | 2595 | ||
2588 | spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; | 2596 | spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; |
2589 | 2597 | ||
2590 | err = hdmi_parse_codec(codec); | 2598 | return parse_intel_hdmi(codec); |
2591 | if (err < 0) { | ||
2592 | generic_spec_free(codec); | ||
2593 | return err; | ||
2594 | } | ||
2595 | |||
2596 | generic_hdmi_init_per_pins(codec); | ||
2597 | register_i915_notifier(codec); | ||
2598 | return 0; | ||
2599 | } | 2599 | } |
2600 | 2600 | ||
2601 | /* Intel IronLake, SandyBridge and IvyBridge; with eld notifier */ | 2601 | /* Intel IronLake, SandyBridge and IvyBridge; with eld notifier */ |
2602 | static int patch_i915_cpt_hdmi(struct hda_codec *codec) | 2602 | static int patch_i915_cpt_hdmi(struct hda_codec *codec) |
2603 | { | 2603 | { |
2604 | struct hdmi_spec *spec; | ||
2605 | int err; | 2604 | int err; |
2606 | 2605 | ||
2607 | /* requires i915 binding */ | 2606 | err = alloc_intel_hdmi(codec); |
2608 | if (!codec->bus->core.audio_component) { | ||
2609 | codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); | ||
2610 | return -ENODEV; | ||
2611 | } | ||
2612 | |||
2613 | err = alloc_generic_hdmi(codec); | ||
2614 | if (err < 0) | 2607 | if (err < 0) |
2615 | return err; | 2608 | return err; |
2616 | spec = codec->spec; | 2609 | return parse_intel_hdmi(codec); |
2617 | |||
2618 | err = hdmi_parse_codec(codec); | ||
2619 | if (err < 0) | ||
2620 | goto error; | ||
2621 | |||
2622 | generic_hdmi_init_per_pins(codec); | ||
2623 | register_i915_notifier(codec); | ||
2624 | return 0; | ||
2625 | |||
2626 | error: | ||
2627 | generic_spec_free(codec); | ||
2628 | return err; | ||
2629 | } | 2610 | } |
2630 | 2611 | ||
2631 | /* | 2612 | /* |