Add framework for better audigy sound card capabilities selection.
PATCH 1/1 Add framework for better audigy sound card capabilities selection.
Hi,
This patch adds more options to help identify all the many different creative sound cards. It will eventually be used to control features more finely.
Signed off: James Courtier-Dutton
P.S. The reason for this patch is that there are so many different Creative sound cards now, that we have to write too many exception cases for each card. For example, the Audigy 1 does not have the P16V chip, and the Audigy 2 has it. The Audigy 2 Value does not have a P16V chip, but has all the features of the P16V chip, but only uses a different set of registers, so different code will be needed to support it. This patch adds a simple matrix, so when a new sound card arrives, we just add a new line to the matrix table, and the driver will work with it, instead of having to go all through the drivers code adding more and more if statements.
Index: alsa-driver/alsa-kernel/include/emu10k1.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/include/emu10k1.h,v retrieving revision 1.59
alsa-kernel/include/emu10k1.h +16 -0
@@ -1035,6 +1035,22 @@void (*interrupt)(emu10k1_t *emu,unsigned int status); } emu10k1_midi_t; +typedef struct { +u32 vendor; +u32 device; +u32 subsystem; +u32 emu10k1_chip;/* Original SB Live. Not SB Live 24bit. */ +u32 emu10k2_chip;/* Audigy 1 or Audigy 2. */ +u32 ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ +u32 ca0108_chip;/* Audigy 2 Value */ +u32 ca0151_chip;/* P16V */ +u32 spk71;/* Has 7.1 speakers */ +u32 spdif_bug;/* Has Spdif phasing bug */ +u32 ac97_chip;/* Has an AC97 chip */ +u32 ecard;/* APS EEPROM */ +char * name; +}emu_chip_details_t ; +struct _snd_emu10k1 {int irq;
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.44
alsa-kernel/pci/emu10k1/emu10k1_main.c +47 -17
101 lines not on this page · raw message
Hi,
the idea looks nice, but...
At Fri, 18 Mar 2005 20:04:47 +0000,
Quoted 17 lines · [email protected] wrote:
Index:
alsa-driver/alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.44
diff -u -r1.44emu10k1_main.calsa-kernel/pci/emu10k1/emu10k1_main.c +5
-0@@ -611,6 +611,22 @@return snd_emu10k1_free (emu); } +/* vendor, device, subsystem, emu10k1_chip, emu10k2_chip, ca0102_chip, ca0108_chip, ca0151_chip, spk71, spdif_bug, ac97_chip, ecard, name */ + +static emu_chip_details_t emu_chip_details[] = { + {0x1102 ,0x0008 ,0x10011102 ,0 ,1 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,"Audigy 2 Value [SB0400]" } , + {0x1102 ,0x0008 ,0x00000000 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,"Audigy 2 Value [Unknown]" } ,
alsa-kernel/pci/emu10k1/emu10k1_main.c line 628
Quoted 10 lines
alsa-kernel/pci/emu10k1/emu10k1_main.c +10
-0+ { 0x1102, 0x0004, 0x20071102, 0, 1, 1, 0, 1, 1, 0, 1, 0, "Audigy 4 PRO [SB0380]"} , + { 0x1102, 0x0004, 0x20021102, 0, 1, 1, 0, 1, 1, 0, 1, 0, "Audigy 2 ZS [2002]"} , + { 0x1102, 0x0004, 0x20011102, 0, 1, 1, 0, 1, 1, 0, 1, 0, "Audigy 2 ZS [2001]"} , + { 0x1102, 0x0004, 0x10071102, 0, 1, 1, 0, 1, 1, 1, 1, 0, "Audigy 2 [SB0240]"} , + { 0x1102, 0x0004, 0x10051102, 0, 1, 1, 0, 1, 0, 0, 0, 0, "Audigy 2 EX [1005]"} , + { 0x1102, 0x0004, 0x00000000, 0, 1, 1, 0, 0, 0, 1, 0, 0, "Audigy 1 or 2 [Unknown]"} , + { 0x1102, 0x0002, 0x40011102, 1, 0, 0, 0, 0, 0, 0, 0, 1, "E-mu APS [4001]"} , + { 0x1102, 0x0002, 0x00000000, 1, 0, 0, 0, 0, 0, 0, 1, 0, "SB Live [Unknown]"} , + { 0x0000, 0x0000, 0x00000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Unknown"} , +};
Can you rewrite in C99-init style, such as
{ .vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,.emu10k2_chip = 1, ... },
??
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 4 lines · Takashi Iwai
Hi,
the idea looks nice, but...
Is this better?
James
Signed off: James Courtier-Dutton
Adds clearer card identification capabilities.
Index: alsa-driver/alsa-kernel/include/emu10k1.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/include/emu10k1.h,v retrieving revision 1.59
alsa-kernel/include/emu10k1.h +18 -0
@@ -1035,6 +1035,23 @@void (*interrupt)(emu10k1_t *emu,unsigned int status); } emu10k1_midi_t; +typedef struct { +u32 vendor; +u32 device; +u32 subsystem; +u32 emu10k1_chip;/* Original SB Live. Not SB Live 24bit. */ +u32 emu10k2_chip;/* Audigy 1 or Audigy 2. */ +u32 ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ +u32 ca0108_chip;/* Audigy 2 Value */ +u32 ca0151_chip;/* P16V */ +u32 spk71;/* Has 7.1 speakers */ +u32 spdif_bug;/* Has Spdif phasing bug */ +u32 ac97_chip;/* Has an AC97 chip */ +u32 ecard;/* APS EEPROM */ +char * driver; +char * name; +}emu_chip_details_t ; +struct _snd_emu10k1 {int irq;
@@ -1044,6 +1061,7 @@ tos_link: 1, /* tos link detected */ rear_ac97: 1, /* rear channels are on AC'97 */ spk71:1; /* 7.1 configuration (Audigy 2 ZS) */ +emu_chip_details_t *card_capabilities;/* Contains profile of card capabilities */ unsigned int audigy;/* is Audigy? */ unsigned int revision;/* chip revision */ unsigned int serial;/* serial number */
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1.c,v retrieving revision 1.33
alsa-kernel/pci/emu10k1/emu10k1.c +2 -16
@@ -198,22 +198,8 @@ }#endif -if (emu->audigy && (emu->serial ==0x10011102 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2_Value" ); - }else if (emu->audigy && (emu->revision ==4 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2" ); - }else if (emu->audigy) { -strcpy (card->driver,"Audigy" ); -strcpy (card->shortname,"Sound Blaster Audigy" ); - }else if (emu->APS) { -strcpy (card->driver,"E-mu APS" ); -strcpy (card->shortname,"E-mu APS" ); - }else { -strcpy (card->driver,"EMU10K1" ); -strcpy (card->shortname,"Sound Blaster Live!" ); - } +strcpy (card->driver, emu->card_capabilities->driver); +strcpy (card->shortname, emu->card_capabilities->name);sprintf (card->longname,"%s (rev.%d, serial:0x%x) at 0x%lx, irq %i" , card->shortname, emu->revision, emu->serial, emu->port, emu->irq);if ((err =snd_card_register (card)) <0 ) {
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.45
alsa-kernel/pci/emu10k1/emu10k1_main.c +176 -17
230 lines not on this page · raw message
At Mon, 21 Mar 2005 21:22:54 +0000,
Quoted 9 lines · James Courtier-Dutton
[1 <text/plain; ISO-8859-1 (7bit)>]
Quoted 4 lines · Takashi Iwai
Hi,
the idea looks nice, but...
Is this better?
Thanks! One more correction below:
alsa-kernel/pci/emu10k1/emu10k1_main.c line 620
Quoted 12 lines
alsa-kernel/pci/emu10k1/emu10k1_main.c +6
-0@@ -612,6 +612,144 @@return snd_emu10k1_free (emu); } +/* vendor, device, subsystem, emu10k1_chip, emu10k2_chip, ca0102_chip, ca0108_chip, ca0151_chip, spk71, spdif_bug, ac97_chip, ecard, driver, name */ + +static emu_chip_details_t emu_chip_details[] = { +/* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ + {.vendor =0x1102 , .device =0x0008 , .subsystem =0x10011102 , + .emu10k1_chip =0 ,
You don't need to initialize fields with zero. That's another advantage of this initialization style.
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 9 lines · Takashi Iwai
You don't need to initialize fields with zero. That's another advantage of this initialization style.
Takashi
3rd time lucky.
Same sign off as before
Index: alsa-driver/alsa-kernel/include/emu10k1.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/include/emu10k1.h,v retrieving revision 1.59
alsa-kernel/include/emu10k1.h +18 -0
@@ -1035,6 +1035,23 @@void (*interrupt)(emu10k1_t *emu,unsigned int status); } emu10k1_midi_t; +typedef struct { +u32 vendor; +u32 device; +u32 subsystem; +u32 emu10k1_chip;/* Original SB Live. Not SB Live 24bit. */ +u32 emu10k2_chip;/* Audigy 1 or Audigy 2. */ +u32 ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ +u32 ca0108_chip;/* Audigy 2 Value */ +u32 ca0151_chip;/* P16V */ +u32 spk71;/* Has 7.1 speakers */ +u32 spdif_bug;/* Has Spdif phasing bug */ +u32 ac97_chip;/* Has an AC97 chip */ +u32 ecard;/* APS EEPROM */ +char * driver; +char * name; +}emu_chip_details_t ; +struct _snd_emu10k1 {int irq;
@@ -1044,6 +1061,7 @@ tos_link: 1, /* tos link detected */ rear_ac97: 1, /* rear channels are on AC'97 */ spk71:1; /* 7.1 configuration (Audigy 2 ZS) */ +emu_chip_details_t *card_capabilities;/* Contains profile of card capabilities */ unsigned int audigy;/* is Audigy? */ unsigned int revision;/* chip revision */ unsigned int serial;/* serial number */
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1.c,v retrieving revision 1.33
alsa-kernel/pci/emu10k1/emu10k1.c +2 -16
@@ -198,22 +198,8 @@ }#endif -if (emu->audigy && (emu->serial ==0x10011102 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2_Value" ); - }else if (emu->audigy && (emu->revision ==4 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2" ); - }else if (emu->audigy) { -strcpy (card->driver,"Audigy" ); -strcpy (card->shortname,"Sound Blaster Audigy" ); - }else if (emu->APS) { -strcpy (card->driver,"E-mu APS" ); -strcpy (card->shortname,"E-mu APS" ); - }else { -strcpy (card->driver,"EMU10K1" ); -strcpy (card->shortname,"Sound Blaster Live!" ); - } +strcpy (card->driver, emu->card_capabilities->driver); +strcpy (card->shortname, emu->card_capabilities->name);sprintf (card->longname,"%s (rev.%d, serial:0x%x) at 0x%lx, irq %i" , card->shortname, emu->revision, emu->serial, emu->port, emu->irq);if ((err =snd_card_register (card)) <0 ) {
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.45
alsa-kernel/pci/emu10k1/emu10k1_main.c +114 -17
168 lines not on this page · raw message
Index: alsa-driver/alsa-kernel/pci/emu10k1/emufx.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emufx.c,v retrieving revision 1.69
alsa-kernel/pci/emu10k1/emufx.c +9 -1
@@ -1339,6 +1339,7 @@/* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ /* IEC958 Optical Raw Playback Switch */ + gpr_map[gpr++] =0 ; gpr_map[gpr++] =0x1008 ; gpr_map[gpr++] =0xffff0000 ;for (z =0 ; z <2 ; z++) {
@@ -1349,7 +1350,14 @@A_SWITCH (icode, &ptr, tmp +0 , tmp +2 , gpr + z);A_SWITCH_NEG (icode, &ptr, tmp +1 , gpr + z);A_SWITCH (icode, &ptr, tmp +1 , playback +SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp +1 ); -A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); +if ((z==1 ) && (emu->card_capabilities->spdif_bug)) { +/* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ +snd_printk ("Installing spdif_bug patch: %s\n" , emu->card_capabilities->name); +A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (gpr -3 ),A_C_00000000 ,A_C_00000000 ); +A_OP (icode, &ptr, iACC3,A_GPR (gpr -3 ),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); + }else { +A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); + } }snd_emu10k1_init_stereo_onoff_control (controls + nctl++,"IEC958 Optical Raw Playback Switch" , gpr,0 ); gpr +=2 ;
Quoted 8 lines · James Courtier-Dutton
Quoted 6 lines · Takashi Iwai
You don't need to initialize fields with zero. That's another advantage of this initialization style.
Quoted 8 lines
Quoted 3 lines
Takashi
3rd time lucky.
Same sign off as before
No such luck...this one might even compile!
Index: alsa-driver/alsa-kernel/include/emu10k1.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/include/emu10k1.h,v retrieving revision 1.59
alsa-kernel/include/emu10k1.h +18 -0
@@ -1035,6 +1035,23 @@void (*interrupt)(emu10k1_t *emu,unsigned int status); } emu10k1_midi_t; +typedef struct { +u32 vendor; +u32 device; +u32 subsystem; +u32 emu10k1_chip;/* Original SB Live. Not SB Live 24bit. */ +u32 emu10k2_chip;/* Audigy 1 or Audigy 2. */ +u32 ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ +u32 ca0108_chip;/* Audigy 2 Value */ +u32 ca0151_chip;/* P16V */ +u32 spk71;/* Has 7.1 speakers */ +u32 spdif_bug;/* Has Spdif phasing bug */ +u32 ac97_chip;/* Has an AC97 chip */ +u32 ecard;/* APS EEPROM */ +char * driver; +char * name; +}emu_chip_details_t ; +struct _snd_emu10k1 {int irq;
@@ -1044,6 +1061,7 @@ tos_link: 1, /* tos link detected */ rear_ac97: 1, /* rear channels are on AC'97 */ spk71:1; /* 7.1 configuration (Audigy 2 ZS) */ +emu_chip_details_t *card_capabilities;/* Contains profile of card capabilities */ unsigned int audigy;/* is Audigy? */ unsigned int revision;/* chip revision */ unsigned int serial;/* serial number */
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1.c,v retrieving revision 1.33
alsa-kernel/pci/emu10k1/emu10k1.c +2 -16
@@ -198,22 +198,8 @@ }#endif -if (emu->audigy && (emu->serial ==0x10011102 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2_Value" ); - }else if (emu->audigy && (emu->revision ==4 ) ) { -strcpy (card->driver,"Audigy2" ); -strcpy (card->shortname,"Sound Blaster Audigy2" ); - }else if (emu->audigy) { -strcpy (card->driver,"Audigy" ); -strcpy (card->shortname,"Sound Blaster Audigy" ); - }else if (emu->APS) { -strcpy (card->driver,"E-mu APS" ); -strcpy (card->shortname,"E-mu APS" ); - }else { -strcpy (card->driver,"EMU10K1" ); -strcpy (card->shortname,"Sound Blaster Live!" ); - } +strcpy (card->driver, emu->card_capabilities->driver); +strcpy (card->shortname, emu->card_capabilities->name);sprintf (card->longname,"%s (rev.%d, serial:0x%x) at 0x%lx, irq %i" , card->shortname, emu->revision, emu->serial, emu->port, emu->irq);if ((err =snd_card_register (card)) <0 ) {
Index: alsa-driver/alsa-kernel/pci/emu10k1/emu10k1_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emu10k1_main.c,v retrieving revision 1.45
alsa-kernel/pci/emu10k1/emu10k1_main.c +114 -17
168 lines not on this page · raw message
At Tue, 22 Mar 2005 19:48:31 +0000,
Quoted 14 lines · James Courtier-Dutton
Quoted 12 lines · James Courtier-Dutton
Quoted 9 lines · Takashi Iwai
You don't need to initialize fields with zero. That's another advantage of this initialization style.
Takashi
Quoted 6 lines
Quoted 4 lines
3rd time lucky.
Same sign off as before
No such luck...this one might even compile!
I took this one. Thanks.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at
http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click