]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - sound/soc/intel/skylake/skl.c
ALSA: hda: Make snd_hdac_display_power() void function
[linux.git] / sound / soc / intel / skylake / skl.c
index 29225623b4b40d1c8fea6822b85b007e57aba690..5c224a0e1c7a11da72f04cd652921aed85cff052 100644 (file)
@@ -37,7 +37,9 @@
 #include "skl.h"
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
 #include "../../../soc/codecs/hdac_hda.h"
+#endif
 
 /*
  * initialize the PCI registers
@@ -309,7 +311,7 @@ static int skl_suspend(struct device *dev)
        struct pci_dev *pci = to_pci_dev(dev);
        struct hdac_bus *bus = pci_get_drvdata(pci);
        struct skl *skl  = bus_to_skl(bus);
-       int ret = 0;
+       int ret;
 
        /*
         * Do not suspend if streams which are marked ignore suspend are
@@ -331,14 +333,10 @@ static int skl_suspend(struct device *dev)
                skl->skl_sst->fw_loaded = false;
        }
 
-       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-               ret = snd_hdac_display_power(bus, false);
-               if (ret < 0)
-                       dev_err(bus->dev,
-                               "Cannot turn OFF display power on i915\n");
-       }
+       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
+               snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
 
-       return ret;
+       return 0;
 }
 
 static int skl_resume(struct device *dev)
@@ -350,14 +348,8 @@ static int skl_resume(struct device *dev)
        int ret;
 
        /* Turned OFF in HDMI codec driver after codec reconfiguration */
-       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-               ret = snd_hdac_display_power(bus, true);
-               if (ret < 0) {
-                       dev_err(bus->dev,
-                               "Cannot turn on display power on i915\n");
-                       return ret;
-               }
-       }
+       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
+               snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
 
        /*
         * resume only when we are not in suspend active, otherwise need to
@@ -658,6 +650,8 @@ static void skl_clock_device_unregister(struct skl *skl)
                platform_device_unregister(skl->clk_dev);
 }
 
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
+
 #define IDISP_INTEL_VENDOR_ID  0x80860000
 
 /*
@@ -676,6 +670,8 @@ static void load_codec_module(struct hda_codec *codec)
 #endif
 }
 
+#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */
+
 /*
  * Probe the given codec address
  */
@@ -685,9 +681,11 @@ static int probe_codec(struct hdac_bus *bus, int addr)
                (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
        unsigned int res = -1;
        struct skl *skl = bus_to_skl(bus);
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
        struct hdac_hda_priv *hda_codec;
-       struct hdac_device *hdev;
        int err;
+#endif
+       struct hdac_device *hdev;
 
        mutex_lock(&bus->cmd_mutex);
        snd_hdac_bus_send_cmd(bus, cmd);
@@ -697,6 +695,7 @@ static int probe_codec(struct hdac_bus *bus, int addr)
                return -EIO;
        dev_dbg(bus->dev, "codec #%d probed OK: %x\n", addr, res);
 
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
        hda_codec = devm_kzalloc(&skl->pci->dev, sizeof(*hda_codec),
                                 GFP_KERNEL);
        if (!hda_codec)
@@ -715,6 +714,13 @@ static int probe_codec(struct hdac_bus *bus, int addr)
                load_codec_module(&hda_codec->codec);
        }
        return 0;
+#else
+       hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL);
+       if (!hdev)
+               return -ENOMEM;
+
+       return snd_hdac_ext_bus_device_init(bus, addr, hdev);
+#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */
 }
 
 /* Codec initialization */
@@ -767,11 +773,9 @@ static int skl_i915_init(struct hdac_bus *bus)
        if (err < 0)
                return err;
 
-       err = snd_hdac_display_power(bus, true);
-       if (err < 0)
-               dev_err(bus->dev, "Cannot turn on display power on i915\n");
+       snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
 
-       return err;
+       return 0;
 }
 
 static void skl_probe_work(struct work_struct *work)
@@ -815,21 +819,15 @@ static void skl_probe_work(struct work_struct *work)
                }
        }
 
-       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-               err = snd_hdac_display_power(bus, false);
-               if (err < 0) {
-                       dev_err(bus->dev, "Cannot turn off display power on i915\n");
-                       skl_machine_device_unregister(skl);
-                       return;
-               }
-       }
-
        /*
         * we are done probing so decrement link counts
         */
        list_for_each_entry(hlink, &bus->hlink_list, list)
                snd_hdac_ext_bus_link_put(bus, hlink);
 
+       if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
+               snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
+
        /* configure PM */
        pm_runtime_put_noidle(bus->dev);
        pm_runtime_allow(bus->dev);
@@ -839,7 +837,7 @@ static void skl_probe_work(struct work_struct *work)
 
 out_err:
        if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
-               err = snd_hdac_display_power(bus, false);
+               snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
 }
 
 /*
@@ -870,7 +868,7 @@ static int skl_create(struct pci_dev *pci,
        hbus = skl_to_hbus(skl);
        bus = skl_to_bus(skl);
 
-#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDA)
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
        ext_ops = snd_soc_hdac_hda_get_ops();
 #endif
        snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, ext_ops);