Skip to content

Commit 96d2bd6

Browse files
committed
ALSA: hda - Split azx_codec_create() to two phases
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>
1 parent b8f28d5 commit 96d2bd6

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

sound/pci/hda/hda_controller.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,13 +1829,11 @@ static struct hda_bus_ops bus_ops = {
18291829
#endif
18301830
};
18311831

1832-
/* Codec initialization */
1833-
int azx_codec_create(struct azx *chip, const char *model,
1834-
unsigned int max_slots,
1835-
int *power_save_to)
1832+
/* HD-audio bus initialization */
1833+
int azx_bus_create(struct azx *chip, const char *model, int *power_save_to)
18361834
{
18371835
struct hda_bus *bus;
1838-
int c, codecs, err;
1836+
int err;
18391837

18401838
err = snd_hda_bus_new(chip->card, &bus);
18411839
if (err < 0)
@@ -1855,6 +1853,26 @@ int azx_codec_create(struct azx *chip, const char *model,
18551853
bus->needs_damn_long_delay = 1;
18561854
}
18571855

1856+
/* AMD chipsets often cause the communication stalls upon certain
1857+
* sequence like the pin-detection. It seems that forcing the synced
1858+
* access works around the stall. Grrr...
1859+
*/
1860+
if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
1861+
dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
1862+
bus->sync_write = 1;
1863+
bus->allow_bus_reset = 1;
1864+
}
1865+
1866+
return 0;
1867+
}
1868+
EXPORT_SYMBOL_GPL(azx_bus_create);
1869+
1870+
/* Probe codecs */
1871+
int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
1872+
{
1873+
struct hda_bus *bus = chip->bus;
1874+
int c, codecs, err;
1875+
18581876
codecs = 0;
18591877
if (!max_slots)
18601878
max_slots = AZX_DEFAULT_CODECS;
@@ -1882,16 +1900,6 @@ int azx_codec_create(struct azx *chip, const char *model,
18821900
}
18831901
}
18841902

1885-
/* AMD chipsets often cause the communication stalls upon certain
1886-
* sequence like the pin-detection. It seems that forcing the synced
1887-
* access works around the stall. Grrr...
1888-
*/
1889-
if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
1890-
dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
1891-
bus->sync_write = 1;
1892-
bus->allow_bus_reset = 1;
1893-
}
1894-
18951903
/* Then create codec instances */
18961904
for (c = 0; c < max_slots; c++) {
18971905
if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
@@ -1910,7 +1918,7 @@ int azx_codec_create(struct azx *chip, const char *model,
19101918
}
19111919
return 0;
19121920
}
1913-
EXPORT_SYMBOL_GPL(azx_codec_create);
1921+
EXPORT_SYMBOL_GPL(azx_probe_codecs);
19141922

19151923
/* configure each codec instance */
19161924
int azx_codec_configure(struct azx *chip)

sound/pci/hda/hda_controller.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,8 @@ void azx_enter_link_reset(struct azx *chip);
432432
irqreturn_t azx_interrupt(int irq, void *dev_id);
433433

434434
/* Codec interface */
435-
int azx_codec_create(struct azx *chip, const char *model,
436-
unsigned int max_slots,
437-
int *power_save_to);
435+
int azx_bus_create(struct azx *chip, const char *model, int *power_save_to);
436+
int azx_probe_codecs(struct azx *chip, unsigned int max_slots);
438437
int azx_codec_configure(struct azx *chip);
439438
int azx_init_stream(struct azx *chip);
440439

sound/pci/hda/hda_intel.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,12 +1893,14 @@ static int azx_probe_continue(struct azx *chip)
18931893
#endif
18941894

18951895
/* create codec instances */
1896-
err = azx_codec_create(chip, model[dev],
1897-
azx_max_codecs[chip->driver_type],
1898-
power_save_addr);
1896+
err = azx_bus_create(chip, model[dev], power_save_addr);
1897+
if (err < 0)
1898+
goto out_free;
18991899

1900+
err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]);
19001901
if (err < 0)
19011902
goto out_free;
1903+
19021904
#ifdef CONFIG_SND_HDA_PATCH_LOADER
19031905
if (chip->fw) {
19041906
err = snd_hda_load_patch(chip->bus, chip->fw->size,

sound/pci/hda/hda_tegra.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,11 @@ static int hda_tegra_probe(struct platform_device *pdev)
502502
goto out_free;
503503

504504
/* create codec instances */
505-
err = azx_codec_create(chip, NULL, 0, &power_save);
505+
err = azx_bus_create(chip, NULL, &power_save);
506+
if (err < 0)
507+
goto out_free;
508+
509+
err = azx_probe_codecs(chip, 0);
506510
if (err < 0)
507511
goto out_free;
508512

0 commit comments

Comments
 (0)