* [patch] alsa-driver-1.0.9b/alsa-kernel/pci/hda/: HDA driver for ULI M5461
@ 2005-08-24 7:47 Wei.Ni
2005-08-24 11:02 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Wei.Ni @ 2005-08-24 7:47 UTC (permalink / raw)
To: tiwai, pshou; +Cc: linux-kernel, Emily.Jiang, Peer.Chen
[-- Attachment #1: Type: text/plain, Size: 710 bytes --]
Hi,Takashi Iwai & PeiSen Hou:
We add some codes in hda_intel.c which is in
alsa-driver-1.0.9b/alsa-kernel/pci/hda/ folder to support our HDA
controller ULi M5461.
Because that our controller has little different with Intel:
1.The M5461 have 11 streams(5 input streams and 6 output streams), and the
Intel's controller is only support 8 streams.
2.The M5461 CORB/RIRB size's default value is 2 entries, and it need to set
to 256 entries.
Could you please update the hda driver to support our controller M5461?
Thanks.
The following file is the patch of the hda_intel.c file. we have made a
full test for it.
Signed-off-by: Wei ni <wei.ni@uli.com.tw>
(See attached file: hda_intel.patch)
Have a good day!
wei
[-- Attachment #2: hda_intel.patch --]
[-- Type: application/octet-stream, Size: 2858 bytes --]
--- alsa-driver-1.0.9b/alsa-kernel/pci/hda/hda_intel.c.orig 2005-05-30 15:33:44.000000000 -0400
+++ alsa-driver-1.0.9b/alsa-kernel/pci/hda/hda_intel.c 2005-08-24 11:11:31.970792648 -0400
@@ -70,6 +70,7 @@
"{Intel, ICH7},"
"{Intel, ESB2},"
"{ATI, SB450},"
+ "{ULi, M5461},"
"{VIA, VT8251},"
"{VIA, VT8237A}}");
MODULE_DESCRIPTION("Intel HDA driver");
@@ -357,6 +358,8 @@
azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
+ /* set the corb size to 256 entries */
+ azx_writeb(chip, CORBSIZE, 0x02);
/* set the corb write pointer to 0 */
azx_writew(chip, CORBWP, 0);
/* reset the corb hw read pointer */
@@ -370,6 +373,8 @@
azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
+ /* set the rirb size to 256 entries */
+ azx_writeb(chip, RIRBSIZE, 0x02);
/* reset the rirb hw write pointer */
azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR);
/* set N=1, get RIRB response interrupt for new entry */
@@ -1177,6 +1182,31 @@
{
int i;
+ if (chip->pci->vendor == 0x10b9 && chip->pci->device == 0x5461)
+ {
+ int j;
+ for (j = 0; j < MAX_ICH6_DEV; j++) {
+ unsigned int off = sizeof(u32) * (j * AZX_MAX_FRAG * 4);
+ azx_dev_t *azx_dev = &chip->azx_dev[j];
+ azx_dev->bdl = (u32 *)(chip->bdl.area + off);
+ azx_dev->bdl_addr = chip->bdl.addr + off;
+ if (chip->position_fix == POS_FIX_POSBUF)
+ azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + j * 8);
+ if (j >= 4)
+ i = j+1;
+ else
+ i = j;
+ /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
+ azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
+ /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
+ azx_dev->sd_int_sta_mask = 1 << i;
+ /* stream tag: must be non-zero and unique */
+ azx_dev->index = i;
+ azx_dev->stream_tag = i + 1;
+ }
+ }
+ else
+ {
/* initialize each stream (aka device)
* assign the starting bdl address to each stream (device) and initialize
*/
@@ -1195,6 +1225,7 @@
azx_dev->index = i;
azx_dev->stream_tag = i + 1;
}
+ }
return 0;
}
@@ -1297,6 +1328,15 @@
if ((err = pci_enable_device(pci)) < 0)
return err;
+{
+#if BITS_PER_LONG == 64
+#else
+u16 tmp3;
+pci_read_config_word(pci, 0x40, &tmp3);
+pci_write_config_word(pci, 0x40, tmp3 | 0x10);
+pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
+#endif
+}
chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
if (NULL == chip) {
@@ -1458,6 +1498,7 @@
{ 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */
{ 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */
{ 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */
+ { 0x10B9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ULi M5461 */
{ 0, }
};
MODULE_DEVICE_TABLE(pci, azx_ids);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] alsa-driver-1.0.9b/alsa-kernel/pci/hda/: HDA driver for ULI M5461
2005-08-24 7:47 [patch] alsa-driver-1.0.9b/alsa-kernel/pci/hda/: HDA driver for ULI M5461 Wei.Ni
@ 2005-08-24 11:02 ` Takashi Iwai
2005-08-24 13:12 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2005-08-24 11:02 UTC (permalink / raw)
To: Wei.Ni; +Cc: pshou, linux-kernel, Emily.Jiang, Peer.Chen
Hi,
At Wed, 24 Aug 2005 15:47:35 +0800,
Wei.Ni@uli.com.tw wrote:
>
> Hi,Takashi Iwai & PeiSen Hou:
> We add some codes in hda_intel.c which is in
> alsa-driver-1.0.9b/alsa-kernel/pci/hda/ folder to support our HDA
> controller ULi M5461.
> Because that our controller has little different with Intel:
> 1.The M5461 have 11 streams(5 input streams and 6 output streams), and the
> Intel's controller is only support 8 streams.
> 2.The M5461 CORB/RIRB size's default value is 2 entries, and it need to set
> to 256 entries.
> Could you please update the hda driver to support our controller M5461?
Thanks for the patch.
We released a newer version of ALSA in the last week, ver 1.0.10rc1,
and the code was slightly changed since 1.0.9b.
The below is the patch to the latset CVS but should be applicable to
1.0.10rc1, too. Could you check whether it works for you?
Also, since M5451 supports more streams, we'll need to fix the code
for better handling of stream assignment in future...
Takashi
Index: alsa-kernel/pci/hda/hda_intel.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/hda/hda_intel.c,v
retrieving revision 1.17
diff -u -r1.17 hda_intel.c
--- alsa-kernel/pci/hda/hda_intel.c 16 Aug 2005 13:29:57 -0000 1.17
+++ alsa-kernel/pci/hda/hda_intel.c 24 Aug 2005 10:58:28 -0000
@@ -72,7 +72,8 @@
"{ATI, SB450},"
"{VIA, VT8251},"
"{VIA, VT8237A},"
- "{SiS, SIS966}}");
+ "{SiS, SIS966},"
+ "{ULI, M5451}}");
MODULE_DESCRIPTION("Intel HDA driver");
#define SFX "hda-intel: "
@@ -201,7 +202,6 @@
};
/* Defines for ATI HD Audio support in SB450 south bridge */
-#define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b
#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
@@ -258,6 +258,7 @@
struct snd_azx {
snd_card_t *card;
struct pci_dev *pci;
+ int driver_type;
/* pci resources */
unsigned long addr;
@@ -293,6 +294,15 @@
unsigned int initialized: 1;
};
+/* driver types */
+enum {
+ AZX_DRIVER_ICH,
+ AZX_DRIVER_ATI,
+ AZX_DRIVER_VIA,
+ AZX_DRIVER_SIS,
+ AZX_DRIVER_ULI,
+};
+
/*
* macros for easy use
*/
@@ -361,6 +371,8 @@
azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
+ /* set the corb size to 256 entries (ULI requires explicitly) */
+ azx_writeb(chip, CORBSIZE, 0x02);
/* set the corb write pointer to 0 */
azx_writew(chip, CORBWP, 0);
/* reset the corb hw read pointer */
@@ -374,6 +386,8 @@
azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
+ /* set the rirb size to 256 entries (ULI requires explicitly) */
+ azx_writeb(chip, RIRBSIZE, 0x02);
/* reset the rirb hw write pointer */
azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR);
/* set N=1, get RIRB response interrupt for new entry */
@@ -687,8 +701,7 @@
}
/* For ATI SB450 azalia HD audio, we need to enable snoop */
- if (chip->pci->vendor == PCI_VENDOR_ID_ATI &&
- chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) {
+ if (chip->driver_type == AZX_DRIVER_ATI) {
pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
&ati_misc_cntl2);
pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
@@ -1185,7 +1198,7 @@
*/
static int __devinit azx_init_stream(azx_t *chip)
{
- int i;
+ int i, idx;
/* initialize each stream (aka device)
* assign the starting bdl address to each stream (device) and initialize
@@ -1197,13 +1210,21 @@
azx_dev->bdl_addr = chip->bdl.addr + off;
if (chip->position_fix == POS_FIX_POSBUF)
azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8);
+
+ idx = i;
+ if (chip->driver_type == AZX_DRIVER_ULI) {
+ /* fix up the stream index for the last 4 streams */
+ if (i >= 4)
+ idx++;
+ }
+
/* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
- azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
+ azx_dev->sd_addr = chip->remap_addr + (0x20 * idx + 0x80);
/* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
- azx_dev->sd_int_sta_mask = 1 << i;
+ azx_dev->sd_int_sta_mask = 1 << idx;
/* stream tag: must be non-zero and unique */
- azx_dev->index = i;
- azx_dev->stream_tag = i + 1;
+ azx_dev->index = idx;
+ azx_dev->stream_tag = i + idx;
}
return 0;
@@ -1323,6 +1344,16 @@
chip->position_fix = posfix;
+#if BITS_PER_LONG != 64
+ /* Fix up base address on ULI M5461 */
+ if (chip->driver_type == AZX_DRIVER_ULI) {
+ u16 tmp3;
+ pci_read_config_word(pci, 0x40, &tmp3);
+ pci_write_config_word(pci, 0x40, tmp3 | 0x10);
+ pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
+ }
+#endif
+
if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {
kfree(chip);
pci_disable_device(pci);
@@ -1463,13 +1494,13 @@
/* PCI IDs */
static struct pci_device_id azx_ids[] = {
- { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */
- { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */
- { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */
- { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */
- { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */
- { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SIS966 */
- { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ALI 5461? */
+ { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */
+ { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */
+ { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
+ { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
+ { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
+ { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
+ { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
{ 0, }
};
MODULE_DEVICE_TABLE(pci, azx_ids);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] alsa-driver-1.0.9b/alsa-kernel/pci/hda/: HDA driver for ULI M5461
2005-08-24 11:02 ` Takashi Iwai
@ 2005-08-24 13:12 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2005-08-24 13:12 UTC (permalink / raw)
To: Wei.Ni; +Cc: pshou, linux-kernel, Emily.Jiang, Peer.Chen, alsa-devel
[Added alsa-devel ML to Cc]
At Wed, 24 Aug 2005 13:02:18 +0200,
I wrote:
>
> Hi,
>
> At Wed, 24 Aug 2005 15:47:35 +0800,
> Wei.Ni@uli.com.tw wrote:
> >
> > Hi,Takashi Iwai & PeiSen Hou:
> > We add some codes in hda_intel.c which is in
> > alsa-driver-1.0.9b/alsa-kernel/pci/hda/ folder to support our HDA
> > controller ULi M5461.
> > Because that our controller has little different with Intel:
> > 1.The M5461 have 11 streams(5 input streams and 6 output streams), and the
> > Intel's controller is only support 8 streams.
> > 2.The M5461 CORB/RIRB size's default value is 2 entries, and it need to set
> > to 256 entries.
> > Could you please update the hda driver to support our controller M5461?
>
> Thanks for the patch.
>
> We released a newer version of ALSA in the last week, ver 1.0.10rc1,
> and the code was slightly changed since 1.0.9b.
> The below is the patch to the latset CVS but should be applicable to
> 1.0.10rc1, too. Could you check whether it works for you?
>
> Also, since M5451 supports more streams, we'll need to fix the code
> for better handling of stream assignment in future...
Argh, my last patch was wrong. It didn't set driver_type.
The below is the newer one. It also increases the max number of
streams for M5461, and changes the driver's short/long name to be
more card-specific.
Please give it a try.
Takashi
Index: alsa-kernel/pci/hda/hda_intel.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/pci/hda/hda_intel.c,v
retrieving revision 1.17
retrieving revision 1.21
diff -u -r1.17 -r1.21
--- alsa-kernel/pci/hda/hda_intel.c 16 Aug 2005 13:29:57 -0000 1.17
+++ alsa-kernel/pci/hda/hda_intel.c 24 Aug 2005 13:09:36 -0000 1.21
@@ -72,7 +72,8 @@
"{ATI, SB450},"
"{VIA, VT8251},"
"{VIA, VT8237A},"
- "{SiS, SIS966}}");
+ "{SiS, SIS966},"
+ "{ULI, M5461}}");
MODULE_DESCRIPTION("Intel HDA driver");
#define SFX "hda-intel: "
@@ -142,9 +143,24 @@
*/
/* max number of SDs */
-#define MAX_ICH6_DEV 8
+/* ICH, ATI and VIA have 4 playback and 4 capture */
+#define ICH6_CAPTURE_INDEX 0
+#define ICH6_NUM_CAPTURE 4
+#define ICH6_PLAYBACK_INDEX 4
+#define ICH6_NUM_PLAYBACK 4
+
+/* ULI has 6 playback and 5 capture */
+#define ULI_CAPTURE_INDEX 0
+#define ULI_NUM_CAPTURE 5
+#define ULI_PLAYBACK_INDEX 5
+#define ULI_NUM_PLAYBACK 6
+
+/* this number is statically defined for simplicity */
+#define MAX_AZX_DEV 16
+
/* max number of fragments - we may use more if allocating more pages for BDL */
-#define AZX_MAX_FRAG (PAGE_SIZE / (MAX_ICH6_DEV * 16))
+#define BDL_SIZE PAGE_ALIGN(8192)
+#define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16))
/* max buffer size - no h/w limit, you can increase as you like */
#define AZX_MAX_BUF_SIZE (1024*1024*1024)
/* max number of PCM devics per card */
@@ -201,7 +217,6 @@
};
/* Defines for ATI HD Audio support in SB450 south bridge */
-#define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b
#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
@@ -259,6 +274,14 @@
snd_card_t *card;
struct pci_dev *pci;
+ /* chip type specific */
+ int driver_type;
+ int playback_streams;
+ int playback_index_offset;
+ int capture_streams;
+ int capture_index_offset;
+ int num_streams;
+
/* pci resources */
unsigned long addr;
void __iomem *remap_addr;
@@ -268,8 +291,8 @@
spinlock_t reg_lock;
struct semaphore open_mutex;
- /* streams */
- azx_dev_t azx_dev[MAX_ICH6_DEV];
+ /* streams (x num_streams) */
+ azx_dev_t *azx_dev;
/* PCM */
unsigned int pcm_devs;
@@ -293,6 +316,23 @@
unsigned int initialized: 1;
};
+/* driver types */
+enum {
+ AZX_DRIVER_ICH,
+ AZX_DRIVER_ATI,
+ AZX_DRIVER_VIA,
+ AZX_DRIVER_SIS,
+ AZX_DRIVER_ULI,
+};
+
+static char *driver_short_names[] __devinitdata = {
+ [AZX_DRIVER_ICH] = "HDA Intel",
+ [AZX_DRIVER_ATI] = "HDA ATI SB",
+ [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
+ [AZX_DRIVER_SIS] = "HDA SIS966",
+ [AZX_DRIVER_ULI] = "HDA ULI M5461"
+};
+
/*
* macros for easy use
*/
@@ -361,6 +401,8 @@
azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
+ /* set the corb size to 256 entries (ULI requires explicitly) */
+ azx_writeb(chip, CORBSIZE, 0x02);
/* set the corb write pointer to 0 */
azx_writew(chip, CORBWP, 0);
/* reset the corb hw read pointer */
@@ -374,6 +416,8 @@
azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
+ /* set the rirb size to 256 entries (ULI requires explicitly) */
+ azx_writeb(chip, RIRBSIZE, 0x02);
/* reset the rirb hw write pointer */
azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR);
/* set N=1, get RIRB response interrupt for new entry */
@@ -597,7 +641,7 @@
int i;
/* disable interrupts in stream descriptor */
- for (i = 0; i < MAX_ICH6_DEV; i++) {
+ for (i = 0; i < chip->num_streams; i++) {
azx_dev_t *azx_dev = &chip->azx_dev[i];
azx_sd_writeb(azx_dev, SD_CTL,
azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK);
@@ -617,7 +661,7 @@
int i;
/* clear stream status */
- for (i = 0; i < MAX_ICH6_DEV; i++) {
+ for (i = 0; i < chip->num_streams; i++) {
azx_dev_t *azx_dev = &chip->azx_dev[i];
azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
}
@@ -687,8 +731,7 @@
}
/* For ATI SB450 azalia HD audio, we need to enable snoop */
- if (chip->pci->vendor == PCI_VENDOR_ID_ATI &&
- chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) {
+ if (chip->driver_type == AZX_DRIVER_ATI) {
pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
&ati_misc_cntl2);
pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
@@ -715,7 +758,7 @@
return IRQ_NONE;
}
- for (i = 0; i < MAX_ICH6_DEV; i++) {
+ for (i = 0; i < chip->num_streams; i++) {
azx_dev = &chip->azx_dev[i];
if (status & azx_dev->sd_int_sta_mask) {
azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
@@ -880,9 +923,15 @@
/* assign a stream for the PCM */
static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream)
{
- int dev, i;
- dev = stream == SNDRV_PCM_STREAM_PLAYBACK ? 4 : 0;
- for (i = 0; i < 4; i++, dev++)
+ int dev, i, nums;
+ if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ dev = chip->playback_index_offset;
+ nums = chip->playback_streams;
+ } else {
+ dev = chip->capture_index_offset;
+ nums = chip->capture_streams;
+ }
+ for (i = 0; i < nums; i++, dev++)
if (! chip->azx_dev[dev].opened) {
chip->azx_dev[dev].opened = 1;
return &chip->azx_dev[dev];
@@ -1190,7 +1239,7 @@
/* initialize each stream (aka device)
* assign the starting bdl address to each stream (device) and initialize
*/
- for (i = 0; i < MAX_ICH6_DEV; i++) {
+ for (i = 0; i < chip->num_streams; i++) {
unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
azx_dev_t *azx_dev = &chip->azx_dev[i];
azx_dev->bdl = (u32 *)(chip->bdl.area + off);
@@ -1249,7 +1298,7 @@
if (chip->initialized) {
int i;
- for (i = 0; i < MAX_ICH6_DEV; i++)
+ for (i = 0; i < chip->num_streams; i++)
azx_stream_stop(chip, &chip->azx_dev[i]);
/* disable interrupts */
@@ -1265,10 +1314,10 @@
/* wait a little for interrupts to finish */
msleep(1);
-
- iounmap(chip->remap_addr);
}
+ if (chip->remap_addr)
+ iounmap(chip->remap_addr);
if (chip->irq >= 0)
free_irq(chip->irq, (void*)chip);
@@ -1280,6 +1329,7 @@
snd_dma_free_pages(&chip->posbuf);
pci_release_regions(chip->pci);
pci_disable_device(chip->pci);
+ kfree(chip->azx_dev);
kfree(chip);
return 0;
@@ -1294,7 +1344,8 @@
* constructor
*/
static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
- int posfix, azx_t **rchip)
+ int posfix, int driver_type,
+ azx_t **rchip)
{
azx_t *chip;
int err = 0;
@@ -1320,9 +1371,20 @@
chip->card = card;
chip->pci = pci;
chip->irq = -1;
+ chip->driver_type = driver_type;
chip->position_fix = posfix;
+#if BITS_PER_LONG != 64
+ /* Fix up base address on ULI M5461 */
+ if (chip->driver_type == AZX_DRIVER_ULI) {
+ u16 tmp3;
+ pci_read_config_word(pci, 0x40, &tmp3);
+ pci_write_config_word(pci, 0x40, tmp3 | 0x10);
+ pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
+ }
+#endif
+
if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {
kfree(chip);
pci_disable_device(pci);
@@ -1348,16 +1410,37 @@
pci_set_master(pci);
synchronize_irq(chip->irq);
+ switch (chip->driver_type) {
+ case AZX_DRIVER_ULI:
+ chip->playback_streams = ULI_NUM_PLAYBACK;
+ chip->capture_streams = ULI_NUM_CAPTURE;
+ chip->playback_index_offset = ULI_PLAYBACK_INDEX;
+ chip->capture_index_offset = ULI_CAPTURE_INDEX;
+ break;
+ default:
+ chip->playback_streams = ICH6_NUM_PLAYBACK;
+ chip->capture_streams = ICH6_NUM_CAPTURE;
+ chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
+ chip->capture_index_offset = ICH6_CAPTURE_INDEX;
+ break;
+ }
+ chip->num_streams = chip->playback_streams + chip->capture_streams;
+ chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL);
+ if (! chip->azx_dev) {
+ snd_printk(KERN_ERR "cannot malloc azx_dev\n");
+ goto errout;
+ }
+
/* allocate memory for the BDL for each stream */
if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
- PAGE_SIZE, &chip->bdl)) < 0) {
+ BDL_SIZE, &chip->bdl)) < 0) {
snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
goto errout;
}
if (chip->position_fix == POS_FIX_POSBUF) {
/* allocate memory for the position buffer */
if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
- MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) {
+ chip->num_streams * 8, &chip->posbuf)) < 0) {
snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
goto errout;
}
@@ -1386,6 +1469,10 @@
goto errout;
}
+ strcpy(card->driver, "HDA-Intel");
+ strcpy(card->shortname, driver_short_names[chip->driver_type]);
+ sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq);
+
*rchip = chip;
return 0;
@@ -1414,15 +1501,12 @@
return -ENOMEM;
}
- if ((err = azx_create(card, pci, position_fix[dev], &chip)) < 0) {
+ if ((err = azx_create(card, pci, position_fix[dev], pci_id->driver_data,
+ &chip)) < 0) {
snd_card_free(card);
return err;
}
- strcpy(card->driver, "HDA-Intel");
- strcpy(card->shortname, "HDA Intel");
- sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq);
-
/* create codec instances */
if ((err = azx_codec_create(chip, model[dev])) < 0) {
snd_card_free(card);
@@ -1463,13 +1547,13 @@
/* PCI IDs */
static struct pci_device_id azx_ids[] = {
- { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */
- { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */
- { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */
- { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */
- { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */
- { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SIS966 */
- { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ALI 5461? */
+ { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */
+ { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */
+ { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
+ { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
+ { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
+ { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
+ { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
{ 0, }
};
MODULE_DEVICE_TABLE(pci, azx_ids);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-24 13:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-24 7:47 [patch] alsa-driver-1.0.9b/alsa-kernel/pci/hda/: HDA driver for ULI M5461 Wei.Ni
2005-08-24 11:02 ` Takashi Iwai
2005-08-24 13:12 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®