Update of /cvsroot/alsa/alsa-kernel/pci/ac97
In directory sc8-pr-cvs1:/tmp/cvs-serv3064/alsa-kernel/pci/ac97
Modified Files:
ac97_codec.c ac97_local.h ac97_patch.c ac97_proc.c
ak4531_codec.c
Log Message:
- AC97 code
- introduced ac97_bus_t structure
- moved attached codecs to /proc/asound/card?/codec97#? directory
- merged snd_ac97_modem() to snd_ac97_mixer()
- proc cleanups - removed already initialized variables
- enhanced snd_info_set_text_ops() syntax
Index: ac97_codec.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_codec.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- ac97_codec.c 16 Oct 2003 15:13:54 -0000 1.107
+++ ac97_codec.c 23 Oct 2003 14:34:52 -0000 1.108
@@ -271,7 +271,7 @@
{
if (!snd_ac97_valid_reg(ac97, reg))
return;
- ac97->write(ac97, reg, value);
+ ac97->bus->write(ac97, reg, value);
}
/**
@@ -289,7 +289,7 @@
{
if (!snd_ac97_valid_reg(ac97, reg))
return 0;
- return ac97->read(ac97, reg);
+ return ac97->bus->read(ac97, reg);
}
/**
@@ -309,7 +309,7 @@
spin_lock(&ac97->reg_lock);
ac97->regs[reg] = value;
spin_unlock(&ac97->reg_lock);
- ac97->write(ac97, reg, value);
+ ac97->bus->write(ac97, reg, value);
set_bit(reg, ac97->reg_accessed);
}
@@ -336,7 +336,7 @@
if (change) {
ac97->regs[reg] = value;
spin_unlock(&ac97->reg_lock);
- ac97->write(ac97, reg, value);
+ ac97->bus->write(ac97, reg, value);
} else
spin_unlock(&ac97->reg_lock);
return change;
@@ -369,7 +369,7 @@
if (change) {
ac97->regs[reg] = new;
spin_unlock(&ac97->reg_lock);
- ac97->write(ac97, reg, new);
+ ac97->bus->write(ac97, reg, new);
} else
spin_unlock(&ac97->reg_lock);
return change;
@@ -389,11 +389,11 @@
ac97->spec.ad18xx.pcmreg[codec] = new;
spin_unlock(&ac97->reg_lock);
/* select single codec */
- ac97->write(ac97, AC97_AD_SERIAL_CFG,
ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
+ ac97->bus->write(ac97, AC97_AD_SERIAL_CFG,
ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
/* update PCM bits */
- ac97->write(ac97, AC97_PCM, new);
+ ac97->bus->write(ac97, AC97_PCM, new);
/* select all codecs */
- ac97->write(ac97, AC97_AD_SERIAL_CFG, 0x7000);
+ ac97->bus->write(ac97, AC97_AD_SERIAL_CFG, 0x7000);
} else
spin_unlock(&ac97->reg_lock);
up(&ac97->spec.ad18xx.mutex);
@@ -977,9 +977,29 @@
*
*/
+static int snd_ac97_bus_free(ac97_bus_t *bus)
+{
+ if (bus) {
+ snd_ac97_bus_proc_done(bus);
+ if (bus->private_free)
+ bus->private_free(bus);
+ snd_magic_kfree(bus);
+ }
+ return 0;
+}
+
+static int snd_ac97_bus_dev_free(snd_device_t *device)
+{
+ ac97_bus_t *bus = snd_magic_cast(ac97_bus_t, device->device_data, return
-ENXIO);
+ return snd_ac97_bus_free(bus);
+}
+
static int snd_ac97_free(ac97_t *ac97)
{
if (ac97) {
+ snd_ac97_proc_done(ac97);
+ if (ac97->bus)
+ ac97->bus->codec[ac97->num] = NULL;
if (ac97->private_free)
ac97->private_free(ac97);
snd_magic_kfree(ac97);
@@ -1194,7 +1214,7 @@
static int snd_ac97_mixer_build(ac97_t * ac97)
{
- snd_card_t *card = ac97->card;
+ snd_card_t *card = ac97->bus->card;
snd_kcontrol_t *kctl;
int err;
unsigned int idx;
@@ -1501,7 +1521,7 @@
unsigned short val;
unsigned int tmp;
- tmp = ((unsigned int)rate * ac97->clock) / 48000;
+ tmp = ((unsigned int)rate * ac97->bus->clock) / 48000;
snd_ac97_write_cache(ac97, reg, tmp & 0xffff);
val = snd_ac97_read(ac97, reg);
return val == (tmp & 0xffff);
@@ -1606,13 +1626,61 @@
}
/**
- * snd_ac97_mixer - create an AC97 codec component
+ * snd_ac97_bus - create an AC97 bus component
* @card: the card instance
+ * @_bus: the template of AC97 bus, callbacks and
+ * the private data.
+ * @rbus: the pointer to store the new AC97 bus instance.
+ *
+ * Creates an AC97 bus component. An ac97_bus_t instance is newly
+ * allocated and initialized from the template (_bus).
+ *
+ * The template must include the valid callbacks (at least read and
+ * write), the bus number (num), and the private data (private_data).
+ * The other callbacks, wait and reset, are not mandatory.
+ *
+ * The clock is set to 48000. If another clock is needed, set
+ * bus->clock manually.
+ *
+ * The AC97 bus instance is registered as a low-level device, so you don't
+ * have to release it manually.
+ *
+ * Returns zero if successful, or a negative error code on failure.
+ */
+int snd_ac97_bus(snd_card_t * card, ac97_bus_t * _bus, ac97_bus_t ** rbus)
+{
+ int err;
+ ac97_bus_t *bus;
+ static snd_device_ops_t ops = {
+ .dev_free = snd_ac97_bus_dev_free,
+ };
+
+ snd_assert(card != NULL, return -EINVAL);
+ snd_assert(_bus != NULL && rbus != NULL, return -EINVAL);
+ bus = snd_magic_kmalloc(ac97_bus_t, 0, GFP_KERNEL);
+ if (bus == NULL)
+ return -ENOMEM;
+ *bus = *_bus;
+ bus->card = card;
+ if (bus->clock == 0)
+ bus->clock = 48000;
+ snd_ac97_bus_proc_init(bus);
+ if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, bus, &ops)) < 0) {
+ snd_ac97_bus_free(bus);
+ return err;
+ }
+ *rbus = bus;
+ return 0;
+}
+
+/**
+ * snd_ac97_mixer - create an Codec97 component
+ * @bus: the AC97 bus which codec is attached to
* @_ac97: the template of ac97, including index, callbacks and
* the private data.
* @rac97: the pointer to store the new ac97 instance.
*
- * Creates an AC97 codec component. An ac97_t instance is newly
+ * Creates an Codec97 component. An ac97_t instance is newly
* allocated and initialized from the template (_ac97). The codec
* is then initialized by the standard procedure.
*
@@ -1621,21 +1689,16 @@
* data (private_data). The other callbacks, wait and reset, are not
* mandatory.
*
- * The clock is set to 48000. If another clock is needed, reset
- * ac97->clock manually afterwards.
- *
* The ac97 instance is registered as a low-level device, so you don't
* have to release it manually.
*
- * The MCs (Modem Codecs only) are only detected but valid. The PCM driver
- * have to check for MCs using the !ac97_is_audio() function.
- *
* Returns zero if successful, or a negative error code on failure.
*/
-int snd_ac97_mixer(snd_card_t * card, ac97_t * _ac97, ac97_t ** rac97)
+int snd_ac97_mixer(ac97_bus_t * bus, ac97_t * _ac97, ac97_t ** rac97)
{
int err;
ac97_t *ac97;
+ snd_card_t *card;
char name[64];
unsigned long end_time;
unsigned int reg;
@@ -1645,31 +1708,34 @@
snd_assert(rac97 != NULL, return -EINVAL);
*rac97 = NULL;
- snd_assert(card != NULL && _ac97 != NULL, return -EINVAL);
+ snd_assert(bus != NULL && _ac97 != NULL, return -EINVAL);
+ snd_assert(_ac97->num < 4 && bus->codec[_ac97->num] == NULL, return -EINVAL);
+ card = bus->card;
ac97 = snd_magic_kmalloc(ac97_t, 0, GFP_KERNEL);
if (ac97 == NULL)
return -ENOMEM;
*ac97 = *_ac97;
- ac97->card = card;
+ ac97->bus = bus;
+ bus->codec[ac97->num] = ac97;
spin_lock_init(&ac97->reg_lock);
if (ac97->pci) {
pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_VENDOR_ID,
&ac97->subsystem_vendor);
pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_ID,
&ac97->subsystem_device);
}
- if (ac97->reset) {
- ac97->reset(ac97);
+ if (bus->reset) {
+ bus->reset(ac97);
goto __access_ok;
}
snd_ac97_write(ac97, AC97_RESET, 0); /* reset to defaults */
- if (ac97->wait)
- ac97->wait(ac97);
+ if (bus->wait)
+ bus->wait(ac97);
else {
udelay(50);
if (ac97_reset_wait(ac97, HZ/2, 0) < 0 &&
ac97_reset_wait(ac97, HZ/2, 1) < 0) {
- snd_printk("AC'97 %d:%d does not respond - RESET\n",
ac97->num, ac97->addr);
+ snd_printk(KERN_ERR "AC'97 %d does not respond - RESET\n",
ac97->num);
snd_ac97_free(ac97);
return -ENXIO;
}
@@ -1678,7 +1744,7 @@
ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16;
ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2);
if (ac97->id == 0x00000000 || ac97->id == 0xffffffff) {
- snd_printk("AC'97 %d:%d access is not valid [0x%x], removing
mixer.\n", ac97->num, ac97->addr, ac97->id);
+ snd_printk(KERN_ERR "AC'97 %d access is not valid [0x%x], removing
mixer.\n", ac97->num, ac97->id);
snd_ac97_free(ac97);
return -EIO;
}
@@ -1698,7 +1764,7 @@
}
/* test for AC'97 */
- if (! (ac97->scaps & AC97_SCAP_AUDIO)) {
+ if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO) && !(ac97->scaps & AC97_SCAP_AUDIO))
{
/* test if we can write to the record gain volume register */
snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a06);
if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a06)
@@ -1712,13 +1778,22 @@
}
/* test for MC'97 */
- ac97->ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
- if (ac97->ext_mid == 0xffff) /* invalid combination */
- ac97->ext_mid = 0;
- if (ac97->ext_mid & 1)
- ac97->scaps |= AC97_SCAP_MODEM;
+ if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM) && !(ac97->scaps & AC97_SCAP_MODEM))
{
+ ac97->ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
+ if (ac97->ext_mid == 0xffff) /* invalid combination */
+ ac97->ext_mid = 0;
+ if (ac97->ext_mid & 1)
+ ac97->scaps |= AC97_SCAP_MODEM;
+ }
+
+ if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) {
+ if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM)))
+ snd_printk(KERN_ERR "AC'97 %d access error (not audio or modem
codec)\n", ac97->num, ac97->id);
+ snd_ac97_free(ac97);
+ return -EACCES;
+ }
- if (ac97->reset) // FIXME: always skipping?
+ if (bus->reset) // FIXME: always skipping?
goto __ready_ok;
/* FIXME: add powerdown control */
@@ -1737,12 +1812,43 @@
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ/10);
} while (time_after_eq(end_time, jiffies));
- snd_printk("AC'97 %d:%d analog subsections not ready\n", ac97->num,
ac97->addr);
+ snd_printk(KERN_ERR "AC'97 %d analog subsections not ready\n",
ac97->num);
}
+ /* FIXME: add powerdown control */
+ if (ac97_is_modem(ac97)) {
+ unsigned char tmp;
+
+ /* nothing should be in powerdown mode */
+ /* note: it's important to set the rate at first */
+ tmp = AC97_MEA_GPIO;
+ if (ac97->ext_mid & AC97_MEI_LINE1) {
+ snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 12000);
+ tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1;
+ }
+ if (ac97->ext_mid & AC97_MEI_LINE2) {
+ snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 12000);
+ tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2;
+ }
+ if (ac97->ext_mid & AC97_MEI_HANDSET) {
+ snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 12000);
+ tmp |= AC97_MEA_HADC | AC97_MEA_HDAC;
+ }
+ snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp <<
8));
+ udelay(100);
+ /* nothing should be in powerdown mode */
+ snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp <<
8));
+ end_time = jiffies + (HZ / 10);
+ do {
+ if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp)
+ goto __ready_ok;
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ } while (time_after_eq(end_time, jiffies));
+ snd_printk(KERN_ERR "MC'97 %d converters and GPIO not ready (0x%x)\n",
ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
+ }
+
__ready_ok:
- if (ac97->clock == 0)
- ac97->clock = 48000; /* standard value */
if (ac97_is_audio(ac97))
ac97->addr = (ac97->ext_id & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT;
else
@@ -1781,8 +1887,8 @@
ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
}
/* additional initializations */
- if (ac97->init)
- ac97->init(ac97);
+ if (bus->init)
+ bus->init(ac97);
snd_ac97_get_name(ac97, ac97->id, name, 0);
snd_ac97_get_name(NULL, ac97->id, name, 0); // ac97->id might be changed in
the special setup code
if (ac97_is_audio(ac97)) {
@@ -1803,183 +1909,6 @@
return -ENOMEM;
}
}
- snd_ac97_proc_init(card, ac97, "ac97");
- if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ac97, &ops)) < 0) {
- snd_ac97_free(ac97);
- return err;
- }
- *rac97 = ac97;
- return 0;
-}
-
-/* wait for a while until registers are accessible after RESET
- * return 0 if ok, negative not ready
- */
-static int ac97_modem_reset_wait(ac97_t *ac97, int timeout)
-{
- unsigned long end_time;
- end_time = jiffies + timeout;
- do {
- unsigned short ext_mid;
-
- /* use preliminary reads to settle the communication */
- snd_ac97_read(ac97, AC97_EXTENDED_MID);
- snd_ac97_read(ac97, AC97_VENDOR_ID1);
- snd_ac97_read(ac97, AC97_VENDOR_ID2);
- ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
- if (ext_mid != 0xffff && (ext_mid & 1) != 0)
- return 0;
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(HZ/100);
- } while (time_after_eq(end_time, jiffies));
- return -ENODEV;
-}
-
-/**
- * snd_ac97_modem - create an MC97 codec component
- * @card: the card instance
- * @_ac97: the template of ac97, including index, callbacks and
- * the private data.
- * @rac97: the pointer to store the new ac97 instance.
- *
- * Creates an MC97 codec component. An ac97_t instance is newly
- * allocated and initialized from the template (_ac97). The codec
- * is then initialized by the standard procedure.
- *
- * The template must include the valid callbacks (at least read and
- * write), the codec number (num) and address (addr), and the private
- * data (private_data). The other callbacks, wait and reset, are not
- * mandatory.
- *
- * The clock is set to 48000. If another clock is needed, reset
- * ac97->clock manually afterwards.
- *
- * The ac97 instance is registered as a low-level device, so you don't
- * have to release it manually.
- *
- * The ACs (Audio Codecs only) are only detected but valid. The PCM driver
- * have to check for ACs using the !ac97_is_modem() function.
- *
- * Returns zero if successful, or a negative error code on failure.
- */
-int snd_ac97_modem(snd_card_t * card, ac97_t * _ac97, ac97_t ** rac97)
-{
- int err;
- ac97_t *ac97;
- char name[64];
- unsigned long end_time;
- unsigned short tmp;
- static snd_device_ops_t ops = {
- .dev_free = snd_ac97_dev_free,
- };
-
- snd_assert(rac97 != NULL, return -EINVAL);
- *rac97 = NULL;
- snd_assert(card != NULL && _ac97 != NULL, return -EINVAL);
- ac97 = snd_magic_kcalloc(ac97_t, 0, GFP_KERNEL);
- if (ac97 == NULL)
- return -ENOMEM;
- *ac97 = *_ac97;
- ac97->card = card;
- spin_lock_init(&ac97->reg_lock);
-
- ac97->pci = _ac97->pci;
- if (ac97->pci) {
- pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_VENDOR_ID,
&ac97->subsystem_vendor);
- pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_ID,
&ac97->subsystem_device);
- }
-
- if (ac97->reset) {
- ac97->reset(ac97);
- goto __access_ok;
- }
-
- snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); /* reset to defaults */
- if (ac97->wait)
- ac97->wait(ac97);
- else {
- udelay(50);
- if (ac97_modem_reset_wait(ac97, HZ/2) < 0) {
- snd_printk("MC'97 %d:%d does not respond - MODEM RESET\n",
ac97->num, ac97->addr);
- snd_ac97_free(ac97);
- return -ENXIO;
- }
- }
- __access_ok:
- ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16;
- ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2);
- if (ac97->id == 0x00000000 || ac97->id == 0xffffffff) {
- snd_printk("MC'97 %d:%d access is not valid [0x%x], removing modem
controls.\n", ac97->num, ac97->addr, ac97->id);
- snd_ac97_free(ac97);
- return -EIO;
- }
-
- /* test for MC'97 */
- ac97->ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
- if (ac97->ext_mid == 0xffff) /* invalid combination */
- ac97->ext_mid = 0;
- if (ac97->ext_mid & 1)
- ac97->scaps |= AC97_SCAP_MODEM;
-
- /* non-destructive test for AC'97 */
- tmp = snd_ac97_read(ac97, AC97_RESET);
- if (tmp == 0 || tmp == 0xffff) {
- tmp = snd_ac97_read(ac97, AC97_EXTENDED_ID);
- if (tmp == 0 || tmp == 0xffff) {
- tmp = snd_ac97_read(ac97, AC97_REC_GAIN);
- if (tmp == 0 || tmp == 0xffff)
- tmp = snd_ac97_read(ac97, AC97_POWERDOWN);
- }
- }
- if ((tmp != 0 && tmp != 0xffff) || !(ac97->scaps & AC97_SCAP_MODEM))
- ac97->scaps |= AC97_SCAP_AUDIO;
-
- if (ac97->reset) // FIXME: always skipping?
- goto __ready_ok;
-
- /* FIXME: add powerdown control */
- if (ac97->scaps & AC97_SCAP_MODEM) {
- /* nothing should be in powerdown mode */
- /* note: it's important to set the rate at first */
- tmp = AC97_MEA_GPIO;
- if (ac97->ext_mid & AC97_MEI_LINE1) {
- snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 12000);
- tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1;
- }
- if (ac97->ext_mid & AC97_MEI_LINE2) {
- snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 12000);
- tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2;
- }
- if (ac97->ext_mid & AC97_MEI_HANDSET) {
- snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 12000);
- tmp |= AC97_MEA_HADC | AC97_MEA_HDAC;
- }
- snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp <<
8));
- udelay(100);
- /* nothing should be in powerdown mode */
- snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp <<
8));
- end_time = jiffies + (HZ / 10);
- do {
- if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp)
- goto __ready_ok;
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(HZ/10);
- } while (time_after_eq(end_time, jiffies));
- snd_printk("MC'97 %d:%d converters and GPIO not ready (0x%x)\n",
ac97->num, ac97->addr, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
- }
-
- __ready_ok:
- /* additional initializations */
- /* FIXME: ADD MODEM INITALIZATION */
- if (ac97_is_modem(ac97))
- ac97->addr = (ac97->ext_mid & AC97_MEI_ADDR_MASK) >>
AC97_MEI_ADDR_SHIFT;
- else
- ac97->addr = (ac97->ext_id & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT;
-
- if (ac97->init)
- ac97->init(ac97);
- snd_ac97_get_name(ac97, ac97->id, name, 1);
- snd_ac97_get_name(NULL, ac97->id, name, 1); // ac97->id might be changed in
the special setup code
if (ac97_is_modem(ac97)) {
if (card->mixername[0] == '\0') {
strcpy(card->mixername, name);
@@ -1993,12 +1922,12 @@
snd_ac97_free(ac97);
return err;
}
+ if (snd_ac97_modem_build(card, ac97) < 0) {
+ snd_ac97_free(ac97);
+ return -ENOMEM;
+ }
}
- if (ac97_is_modem(ac97) && snd_ac97_modem_build(card, ac97) < 0) {
- snd_ac97_free(ac97);
- return -ENOMEM;
- }
- snd_ac97_proc_init(card, ac97, "mc97");
+ snd_ac97_proc_init(ac97);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ac97, &ops)) < 0) {
snd_ac97_free(ac97);
return err;
@@ -2104,7 +2033,7 @@
default:
return -EINVAL;
}
- tmp = ((unsigned int)rate * ac97->clock) / 48000;
+ tmp = ((unsigned int)rate * ac97->bus->clock) / 48000;
if (tmp > 65535)
return -EINVAL;
snd_ac97_update(ac97, reg, tmp & 0xffff);
@@ -2146,8 +2075,8 @@
{
int i, is_ad18xx, codec;
- if (ac97->reset) {
- ac97->reset(ac97);
+ if (ac97->bus->reset) {
+ ac97->bus->reset(ac97);
goto __reset_ready;
}
@@ -2166,8 +2095,8 @@
}
__reset_ready:
- if (ac97->init)
- ac97->init(ac97);
+ if (bus->init)
+ bus->init(ac97);
is_ad18xx = (ac97->id & 0xffffff40) == AC97_ID_AD1881;
if (is_ad18xx) {
@@ -2240,7 +2169,7 @@
memset(&id, 0, sizeof(id));
strcpy(id.name, name);
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- return snd_ctl_remove_id(ac97->card, &id);
+ return snd_ctl_remove_id(ac97->bus->card, &id);
}
static snd_kcontrol_t *ctl_find(ac97_t *ac97, const char *name)
@@ -2249,7 +2178,7 @@
memset(&sid, 0, sizeof(sid));
strcpy(sid.name, name);
sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- return snd_ctl_find_id(ac97->card, &sid);
+ return snd_ctl_find_id(ac97->bus->card, &sid);
}
int snd_ac97_rename_ctl(ac97_t *ac97, const char *src, const char *dst)
@@ -2356,8 +2285,8 @@
EXPORT_SYMBOL(snd_ac97_write_cache);
EXPORT_SYMBOL(snd_ac97_update);
EXPORT_SYMBOL(snd_ac97_update_bits);
+EXPORT_SYMBOL(snd_ac97_bus);
EXPORT_SYMBOL(snd_ac97_mixer);
-EXPORT_SYMBOL(snd_ac97_modem);
EXPORT_SYMBOL(snd_ac97_set_rate);
EXPORT_SYMBOL(snd_ac97_tune_hardware);
#ifdef CONFIG_PM
Index: ac97_local.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_local.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ac97_local.h 16 Oct 2003 15:13:54 -0000 1.3
+++ ac97_local.h 23 Oct 2003 14:34:52 -0000 1.4
@@ -42,4 +42,7 @@
int snd_ac97_swap_ctl(ac97_t *ac97, const char *s1, const char *s2);
/* ac97_proc.c */
-void snd_ac97_proc_init(snd_card_t * card, ac97_t * ac97, const char *prefix);
+void snd_ac97_bus_proc_init(ac97_bus_t * ac97);
+void snd_ac97_bus_proc_done(ac97_bus_t * ac97);
+void snd_ac97_proc_init(ac97_t * ac97);
+void snd_ac97_proc_done(ac97_t * ac97);
Index: ac97_patch.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_patch.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ac97_patch.c 17 Oct 2003 10:28:06 -0000 1.26
+++ ac97_patch.c 23 Oct 2003 14:34:52 -0000 1.27
@@ -46,7 +46,7 @@
int idx, err;
for (idx = 0; idx < count; idx++)
- if ((err = snd_ctl_add(ac97->card, snd_ac97_cnew(&controls[idx],
ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx],
ac97))) < 0)
return err;
return 0;
}
@@ -201,12 +201,12 @@
snd_kcontrol_t *kctl;
int err;
- if ((err = snd_ctl_add(ac97->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
return err;
strcpy(kctl->id.name, "3D Control - Wide");
kctl->private_value = AC97_3D_CONTROL | (9 << 8) | (7 << 16);
snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
- if ((err = snd_ctl_add(ac97->card,
snd_ac97_cnew(&snd_ac97_ymf753_controls_speaker, ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card,
snd_ac97_cnew(&snd_ac97_ymf753_controls_speaker, ac97))) < 0)
return err;
snd_ac97_write_cache(ac97, AC97_YMF753_3D_MODE_SEL, 0x0c00);
return 0;
@@ -306,7 +306,7 @@
snd_kcontrol_t *kctl;
int err;
- if ((err = snd_ctl_add(ac97->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
return err;
strcpy(kctl->id.name, "3D Control Sigmatel - Depth");
kctl->private_value = AC97_3D_CONTROL | (3 << 16);
@@ -319,11 +319,11 @@
snd_kcontrol_t *kctl;
int err;
- if ((err = snd_ctl_add(ac97->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
return err;
strcpy(kctl->id.name, "3D Control Sigmatel - Depth");
kctl->private_value = AC97_3D_CONTROL | (3 << 16);
- if ((err = snd_ctl_add(ac97->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
+ if ((err = snd_ctl_add(ac97->bus->card, kctl =
snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
return err;
strcpy(kctl->id.name, "3D Control Sigmatel - Rear Depth");
kctl->private_value = AC97_3D_CONTROL | (2 << 8) | (3 << 16);
Index: ac97_proc.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_proc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ac97_proc.c 6 Oct 2003 10:55:25 -0000 1.3
+++ ac97_proc.c 23 Oct 2003 14:34:52 -0000 1.4
@@ -296,21 +296,67 @@
}
}
-void snd_ac97_proc_init(snd_card_t * card, ac97_t * ac97, const char *prefix)
+void snd_ac97_proc_init(ac97_t * ac97)
{
snd_info_entry_t *entry;
char name[32];
+ const char *prefix;
- if (ac97->num)
- sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
- else
- sprintf(name, "%s#%d", prefix, ac97->addr);
- if (! snd_card_proc_new(card, name, &entry))
- snd_info_set_text_ops(entry, ac97, snd_ac97_proc_read);
- if (ac97->num)
- sprintf(name, "%s#%d-%dregs", prefix, ac97->addr, ac97->num);
- else
- sprintf(name, "%s#%dregs", prefix, ac97->addr);
- if (! snd_card_proc_new(card, name, &entry))
- snd_info_set_text_ops(entry, ac97, snd_ac97_proc_regs_read);
+ if (ac97->bus->proc == NULL)
+ return;
+ prefix = ac97_is_audio(ac97) ? "ac97" : "mc97";
+ sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
+ if ((entry = snd_info_create_card_entry(ac97->bus->card, name,
ac97->bus->proc)) != NULL) {
+ snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_read);
+ if (snd_info_register(entry) < 0) {
+ snd_info_free_entry(entry);
+ entry = NULL;
+ }
+ }
+ ac97->proc = entry;
+ sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num);
+ if ((entry = snd_info_create_card_entry(ac97->bus->card, name,
ac97->bus->proc)) != NULL) {
+ snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_regs_read);
+ if (snd_info_register(entry) < 0) {
+ snd_info_free_entry(entry);
+ entry = NULL;
+ }
+ }
+ ac97->proc_regs = entry;
+}
+
+void snd_ac97_proc_done(ac97_t * ac97)
+{
+ if (ac97->proc_regs) {
+ snd_info_unregister(ac97->proc_regs);
+ ac97->proc_regs = NULL;
+ }
+ if (ac97->proc) {
+ snd_info_unregister(ac97->proc);
+ ac97->proc = NULL;
+ }
+}
+
+void snd_ac97_bus_proc_init(ac97_bus_t * bus)
+{
+ snd_info_entry_t *entry;
+ char name[32];
+
+ sprintf(name, "codec97#%d", bus->num);
+ if ((entry = snd_info_create_card_entry(bus->card, name,
bus->card->proc_root)) != NULL) {
+ entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
+ if (snd_info_register(entry) < 0) {
+ snd_info_free_entry(entry);
+ entry = NULL;
+ }
+ }
+ bus->proc = entry;
+}
+
+void snd_ac97_bus_proc_done(ac97_bus_t * bus)
+{
+ if (bus->proc) {
+ snd_info_unregister(bus->proc);
+ bus->proc = NULL;
+ }
}
Index: ak4531_codec.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ak4531_codec.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ak4531_codec.c 31 Jan 2003 15:20:43 -0000 1.8
+++ ak4531_codec.c 23 Oct 2003 14:34:53 -0000 1.9
@@ -425,7 +425,7 @@
snd_info_entry_t *entry;
if (! snd_card_proc_new(card, "ak4531", &entry))
- snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read);
+ snd_info_set_text_ops(entry, ak4531, 1024, snd_ak4531_proc_read);
}
EXPORT_SYMBOL(snd_ak4531_mixer);
-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog