mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-04 05:37:36 +00:00
ALSA: hda - Create own device struct for each codec
As the HD-audio is treated individually in each codec driver, it's more convenient to assign an own struct device to each codec object. Then we'll be able to use dev_err() more easily for each codec, for example. For achieving it, this patch just creates an object "hdaudioCxDy". It belongs to sound class instead of creating a new bus, just for simplicity, at this stage. No pm ops is implemented in the device struct level but currently it's merely a container. The PCM and hwdep devices are now children of this codec device. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2565c89908
commit
13aeaf6801
4 changed files with 39 additions and 3 deletions
|
@ -1368,7 +1368,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
|
||||||
kfree(codec->modelname);
|
kfree(codec->modelname);
|
||||||
kfree(codec->wcaps);
|
kfree(codec->wcaps);
|
||||||
codec->bus->num_codecs--;
|
codec->bus->num_codecs--;
|
||||||
kfree(codec);
|
put_device(&codec->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
|
static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
|
||||||
|
@ -1377,12 +1377,33 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
|
||||||
static unsigned int hda_set_power_state(struct hda_codec *codec,
|
static unsigned int hda_set_power_state(struct hda_codec *codec,
|
||||||
unsigned int power_state);
|
unsigned int power_state);
|
||||||
|
|
||||||
|
static int snd_hda_codec_dev_register(struct snd_device *device)
|
||||||
|
{
|
||||||
|
struct hda_codec *codec = device->device_data;
|
||||||
|
|
||||||
|
return device_add(&codec->dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int snd_hda_codec_dev_disconnect(struct snd_device *device)
|
||||||
|
{
|
||||||
|
struct hda_codec *codec = device->device_data;
|
||||||
|
|
||||||
|
device_del(&codec->dev);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int snd_hda_codec_dev_free(struct snd_device *device)
|
static int snd_hda_codec_dev_free(struct snd_device *device)
|
||||||
{
|
{
|
||||||
snd_hda_codec_free(device->device_data);
|
snd_hda_codec_free(device->device_data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* just free the container */
|
||||||
|
static void snd_hda_codec_dev_release(struct device *dev)
|
||||||
|
{
|
||||||
|
kfree(container_of(dev, struct hda_codec, dev));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_hda_codec_new - create a HDA codec
|
* snd_hda_codec_new - create a HDA codec
|
||||||
* @bus: the bus to assign
|
* @bus: the bus to assign
|
||||||
|
@ -1400,6 +1421,8 @@ int snd_hda_codec_new(struct hda_bus *bus,
|
||||||
hda_nid_t fg;
|
hda_nid_t fg;
|
||||||
int err;
|
int err;
|
||||||
static struct snd_device_ops dev_ops = {
|
static struct snd_device_ops dev_ops = {
|
||||||
|
.dev_register = snd_hda_codec_dev_register,
|
||||||
|
.dev_disconnect = snd_hda_codec_dev_disconnect,
|
||||||
.dev_free = snd_hda_codec_dev_free,
|
.dev_free = snd_hda_codec_dev_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1420,6 +1443,13 @@ int snd_hda_codec_new(struct hda_bus *bus,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device_initialize(&codec->dev);
|
||||||
|
codec->dev.parent = &bus->card->card_dev;
|
||||||
|
codec->dev.class = sound_class;
|
||||||
|
codec->dev.release = snd_hda_codec_dev_release;
|
||||||
|
dev_set_name(&codec->dev, "hdaudioC%dD%d", bus->card->number,
|
||||||
|
codec_addr);
|
||||||
|
|
||||||
codec->bus = bus;
|
codec->bus = bus;
|
||||||
codec->addr = codec_addr;
|
codec->addr = codec_addr;
|
||||||
mutex_init(&codec->spdif_mutex);
|
mutex_init(&codec->spdif_mutex);
|
||||||
|
@ -1453,8 +1483,8 @@ int snd_hda_codec_new(struct hda_bus *bus,
|
||||||
if (codec->bus->modelname) {
|
if (codec->bus->modelname) {
|
||||||
codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
|
codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
|
||||||
if (!codec->modelname) {
|
if (!codec->modelname) {
|
||||||
snd_hda_codec_free(codec);
|
err = -ENODEV;
|
||||||
return -ENODEV;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,7 @@ struct hda_pcm {
|
||||||
|
|
||||||
/* codec information */
|
/* codec information */
|
||||||
struct hda_codec {
|
struct hda_codec {
|
||||||
|
struct device dev;
|
||||||
struct hda_bus *bus;
|
struct hda_bus *bus;
|
||||||
unsigned int addr; /* codec addr*/
|
unsigned int addr; /* codec addr*/
|
||||||
struct list_head list; /* list point */
|
struct list_head list; /* list point */
|
||||||
|
|
|
@ -155,6 +155,9 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
|
||||||
snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
|
snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
|
||||||
snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
|
snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
|
||||||
|
|
||||||
|
/* link to codec */
|
||||||
|
hwdep->dev = &codec->dev;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2663,6 +2663,8 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
|
||||||
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
|
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
|
||||||
snd_dma_pci_data(chip->pci),
|
snd_dma_pci_data(chip->pci),
|
||||||
size, MAX_PREALLOC_SIZE);
|
size, MAX_PREALLOC_SIZE);
|
||||||
|
/* link to codec */
|
||||||
|
pcm->dev = &codec->dev;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue