mirror of
https://github.com/torvalds/linux
synced 2024-10-10 21:36:41 +00:00
ALSA: hda - Drop hda_bus_template for snd_hda_bus_new()
Instead of copying from the given template, let the caller fills the fields after creation. This simplifies the code after all. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
9fd37810da
commit
ef7449780e
|
@ -861,14 +861,12 @@ static int snd_hda_bus_dev_disconnect(struct snd_device *device)
|
||||||
/**
|
/**
|
||||||
* snd_hda_bus_new - create a HDA bus
|
* snd_hda_bus_new - create a HDA bus
|
||||||
* @card: the card entry
|
* @card: the card entry
|
||||||
* @temp: the template for hda_bus information
|
|
||||||
* @busp: the pointer to store the created bus instance
|
* @busp: the pointer to store the created bus instance
|
||||||
*
|
*
|
||||||
* Returns 0 if successful, or a negative error code.
|
* Returns 0 if successful, or a negative error code.
|
||||||
*/
|
*/
|
||||||
int snd_hda_bus_new(struct snd_card *card,
|
int snd_hda_bus_new(struct snd_card *card,
|
||||||
const struct hda_bus_template *temp,
|
struct hda_bus **busp)
|
||||||
struct hda_bus **busp)
|
|
||||||
{
|
{
|
||||||
struct hda_bus *bus;
|
struct hda_bus *bus;
|
||||||
int err;
|
int err;
|
||||||
|
@ -877,11 +875,6 @@ int snd_hda_bus_new(struct snd_card *card,
|
||||||
.dev_free = snd_hda_bus_dev_free,
|
.dev_free = snd_hda_bus_dev_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (snd_BUG_ON(!temp))
|
|
||||||
return -EINVAL;
|
|
||||||
if (snd_BUG_ON(!temp->ops.command || !temp->ops.get_response))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (busp)
|
if (busp)
|
||||||
*busp = NULL;
|
*busp = NULL;
|
||||||
|
|
||||||
|
@ -892,12 +885,6 @@ int snd_hda_bus_new(struct snd_card *card,
|
||||||
}
|
}
|
||||||
|
|
||||||
bus->card = card;
|
bus->card = card;
|
||||||
bus->private_data = temp->private_data;
|
|
||||||
bus->pci = temp->pci;
|
|
||||||
bus->modelname = temp->modelname;
|
|
||||||
bus->power_save = temp->power_save;
|
|
||||||
bus->ops = temp->ops;
|
|
||||||
|
|
||||||
mutex_init(&bus->cmd_mutex);
|
mutex_init(&bus->cmd_mutex);
|
||||||
mutex_init(&bus->prepare_mutex);
|
mutex_init(&bus->prepare_mutex);
|
||||||
INIT_LIST_HEAD(&bus->codec_list);
|
INIT_LIST_HEAD(&bus->codec_list);
|
||||||
|
|
|
@ -101,15 +101,6 @@ struct hda_bus_ops {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* template to pass to the bus constructor */
|
|
||||||
struct hda_bus_template {
|
|
||||||
void *private_data;
|
|
||||||
struct pci_dev *pci;
|
|
||||||
const char *modelname;
|
|
||||||
int *power_save;
|
|
||||||
struct hda_bus_ops ops;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* codec bus
|
* codec bus
|
||||||
*
|
*
|
||||||
|
@ -119,7 +110,6 @@ struct hda_bus_template {
|
||||||
struct hda_bus {
|
struct hda_bus {
|
||||||
struct snd_card *card;
|
struct snd_card *card;
|
||||||
|
|
||||||
/* copied from template */
|
|
||||||
void *private_data;
|
void *private_data;
|
||||||
struct pci_dev *pci;
|
struct pci_dev *pci;
|
||||||
const char *modelname;
|
const char *modelname;
|
||||||
|
@ -420,8 +410,7 @@ enum {
|
||||||
/*
|
/*
|
||||||
* constructors
|
* constructors
|
||||||
*/
|
*/
|
||||||
int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
|
int snd_hda_bus_new(struct snd_card *card, struct hda_bus **busp);
|
||||||
struct hda_bus **busp);
|
|
||||||
int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
|
int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
|
||||||
struct hda_codec **codecp);
|
struct hda_codec **codecp);
|
||||||
int snd_hda_codec_configure(struct hda_codec *codec);
|
int snd_hda_codec_configure(struct hda_codec *codec);
|
||||||
|
|
|
@ -1815,39 +1815,45 @@ static int get_jackpoll_interval(struct azx *chip)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct hda_bus_ops bus_ops = {
|
||||||
|
.command = azx_send_cmd,
|
||||||
|
.get_response = azx_get_response,
|
||||||
|
.attach_pcm = azx_attach_pcm_stream,
|
||||||
|
.bus_reset = azx_bus_reset,
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
.pm_notify = azx_power_notify,
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_SND_HDA_DSP_LOADER
|
||||||
|
.load_dsp_prepare = azx_load_dsp_prepare,
|
||||||
|
.load_dsp_trigger = azx_load_dsp_trigger,
|
||||||
|
.load_dsp_cleanup = azx_load_dsp_cleanup,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
/* Codec initialization */
|
/* Codec initialization */
|
||||||
int azx_codec_create(struct azx *chip, const char *model,
|
int azx_codec_create(struct azx *chip, const char *model,
|
||||||
unsigned int max_slots,
|
unsigned int max_slots,
|
||||||
int *power_save_to)
|
int *power_save_to)
|
||||||
{
|
{
|
||||||
struct hda_bus_template bus_temp;
|
struct hda_bus *bus;
|
||||||
int c, codecs, err;
|
int c, codecs, err;
|
||||||
|
|
||||||
memset(&bus_temp, 0, sizeof(bus_temp));
|
err = snd_hda_bus_new(chip->card, &bus);
|
||||||
bus_temp.private_data = chip;
|
|
||||||
bus_temp.modelname = model;
|
|
||||||
bus_temp.pci = chip->pci;
|
|
||||||
bus_temp.ops.command = azx_send_cmd;
|
|
||||||
bus_temp.ops.get_response = azx_get_response;
|
|
||||||
bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
|
|
||||||
bus_temp.ops.bus_reset = azx_bus_reset;
|
|
||||||
#ifdef CONFIG_PM
|
|
||||||
bus_temp.power_save = power_save_to;
|
|
||||||
bus_temp.ops.pm_notify = azx_power_notify;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SND_HDA_DSP_LOADER
|
|
||||||
bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare;
|
|
||||||
bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger;
|
|
||||||
bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
chip->bus = bus;
|
||||||
|
bus->private_data = chip;
|
||||||
|
bus->pci = chip->pci;
|
||||||
|
bus->modelname = model;
|
||||||
|
bus->ops = bus_ops;
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
bus->power_save = power_save_to;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
|
if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
|
||||||
dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
|
dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
|
||||||
chip->bus->needs_damn_long_delay = 1;
|
bus->needs_damn_long_delay = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
codecs = 0;
|
codecs = 0;
|
||||||
|
@ -1883,15 +1889,15 @@ int azx_codec_create(struct azx *chip, const char *model,
|
||||||
*/
|
*/
|
||||||
if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
|
if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
|
||||||
dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
|
dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
|
||||||
chip->bus->sync_write = 1;
|
bus->sync_write = 1;
|
||||||
chip->bus->allow_bus_reset = 1;
|
bus->allow_bus_reset = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then create codec instances */
|
/* Then create codec instances */
|
||||||
for (c = 0; c < max_slots; c++) {
|
for (c = 0; c < max_slots; c++) {
|
||||||
if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
|
if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
|
||||||
struct hda_codec *codec;
|
struct hda_codec *codec;
|
||||||
err = snd_hda_codec_new(chip->bus, c, &codec);
|
err = snd_hda_codec_new(bus, c, &codec);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
continue;
|
continue;
|
||||||
codec->jackpoll_interval = get_jackpoll_interval(chip);
|
codec->jackpoll_interval = get_jackpoll_interval(chip);
|
||||||
|
|
Loading…
Reference in a new issue