]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Split azx_codec_create() to two phases
authorTakashi Iwai <tiwai@suse.de>
Thu, 19 Feb 2015 17:12:22 +0000 (18:12 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 19 Feb 2015 20:41:40 +0000 (21:41 +0100)
azx_create_codec() function does actually two things: create a bus and
probe codecs.  For the future work, split this to two logical
functions, azx_bus_create() and azx_probe_codecs().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_controller.c
sound/pci/hda/hda_controller.h
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_tegra.c

index 6fab39133051bcfb5e6bc55a8c8b77489ca28749..2a674525e56f87a5ec619892f9b67124e89af255 100644 (file)
@@ -1829,13 +1829,11 @@ static struct hda_bus_ops bus_ops = {
 #endif
 };
 
-/* Codec initialization */
-int azx_codec_create(struct azx *chip, const char *model,
-                    unsigned int max_slots,
-                    int *power_save_to)
+/* HD-audio bus initialization */
+int azx_bus_create(struct azx *chip, const char *model, int *power_save_to)
 {
        struct hda_bus *bus;
-       int c, codecs, err;
+       int err;
 
        err = snd_hda_bus_new(chip->card, &bus);
        if (err < 0)
@@ -1855,6 +1853,26 @@ int azx_codec_create(struct azx *chip, const char *model,
                bus->needs_damn_long_delay = 1;
        }
 
+       /* AMD chipsets often cause the communication stalls upon certain
+        * sequence like the pin-detection.  It seems that forcing the synced
+        * access works around the stall.  Grrr...
+        */
+       if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
+               dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
+               bus->sync_write = 1;
+               bus->allow_bus_reset = 1;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(azx_bus_create);
+
+/* Probe codecs */
+int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
+{
+       struct hda_bus *bus = chip->bus;
+       int c, codecs, err;
+
        codecs = 0;
        if (!max_slots)
                max_slots = AZX_DEFAULT_CODECS;
@@ -1882,16 +1900,6 @@ int azx_codec_create(struct azx *chip, const char *model,
                }
        }
 
-       /* AMD chipsets often cause the communication stalls upon certain
-        * sequence like the pin-detection.  It seems that forcing the synced
-        * access works around the stall.  Grrr...
-        */
-       if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
-               dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
-               bus->sync_write = 1;
-               bus->allow_bus_reset = 1;
-       }
-
        /* Then create codec instances */
        for (c = 0; c < max_slots; c++) {
                if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
@@ -1910,7 +1918,7 @@ int azx_codec_create(struct azx *chip, const char *model,
        }
        return 0;
 }
-EXPORT_SYMBOL_GPL(azx_codec_create);
+EXPORT_SYMBOL_GPL(azx_probe_codecs);
 
 /* configure each codec instance */
 int azx_codec_configure(struct azx *chip)
index 79808e1a79ac584bee9d89225017f4e22048f445..0d09aa6b49ac8241d2f05c5cb630bb83672d14b5 100644 (file)
@@ -432,9 +432,8 @@ void azx_enter_link_reset(struct azx *chip);
 irqreturn_t azx_interrupt(int irq, void *dev_id);
 
 /* Codec interface */
-int azx_codec_create(struct azx *chip, const char *model,
-                    unsigned int max_slots,
-                    int *power_save_to);
+int azx_bus_create(struct azx *chip, const char *model, int *power_save_to);
+int azx_probe_codecs(struct azx *chip, unsigned int max_slots);
 int azx_codec_configure(struct azx *chip);
 int azx_init_stream(struct azx *chip);
 
index b0a05691abe70ce3ea7202480d1e0ef0f9c437b5..5e00cc4a722f4c447f7c0dac96c694d44d9223e7 100644 (file)
@@ -1893,12 +1893,14 @@ static int azx_probe_continue(struct azx *chip)
 #endif
 
        /* create codec instances */
-       err = azx_codec_create(chip, model[dev],
-                              azx_max_codecs[chip->driver_type],
-                              power_save_addr);
+       err = azx_bus_create(chip, model[dev], power_save_addr);
+       if (err < 0)
+               goto out_free;
 
+       err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]);
        if (err < 0)
                goto out_free;
+
 #ifdef CONFIG_SND_HDA_PATCH_LOADER
        if (chip->fw) {
                err = snd_hda_load_patch(chip->bus, chip->fw->size,
index f305c2a99206dd708169f041ee8e8dc5c03d47be..1bd7a9e040465b26558c1875ab7d6f862f512d53 100644 (file)
@@ -502,7 +502,11 @@ static int hda_tegra_probe(struct platform_device *pdev)
                goto out_free;
 
        /* create codec instances */
-       err = azx_codec_create(chip, NULL, 0, &power_save);
+       err = azx_bus_create(chip, NULL, &power_save);
+       if (err < 0)
+               goto out_free;
+
+       err = azx_probe_codecs(chip, 0);
        if (err < 0)
                goto out_free;