Skip to contentSkip to conversation

S/PDIF on AD1980 patch

DISCUSSION Jaroslaw Sobierski 2 participants 4 messages Feb 17, 2003 – Feb 20, 2003

lore
Share & tools
lore
#0 lore raw

OK, here is the unified diff. Two of them actually, i separated the different options for better clarity.

Option 1 : The simple switch control

Index: ac97_codec.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_codec.c,v retrieving revision 1.66

ac97_codec.c +2 -0
diff -u -r1.66 ac97_codec.c
@@ -1022,6 +1022,9 @@
 AD18XX_PCM_BITS("LFE Playback Volume", 2, 0, 31)
 };
 
+static const snd_kcontrol_new_t snd_ac97_ad1980_spdif_link =
+    AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Link",

AC97_AD_SERIAL_CFG, 2, 1, 0);
+
/*
* ALC650
*/
@@ -1679,6 +1682,10 @@
if (ac97->id == AC97_ID_YMF753) {
for (idx = 0; idx < 3; idx++)
if ((err = snd_ctl_add(card,
snd_ac97_cnew(&snd_ac97_ymf753_controls_spdif[idx], ac97))) < 0)
+ return err;
+ }
+ if (ac97->id == AC97_ID_AD1980) {
+ if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_ad1980_spdif_link,
ac97))) < 0)
return err;
}
/* set default PCM S/PDIF params */
Index: ac97_id.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_id.h,v retrieving revision 1.6

ac97_id.h +1 -0
diff -u -r1.6 ac97_id.h
@@ -31,6 +31,7 @@
 #define AC97_ID_AD1886		0x41445361
 #define AC97_ID_AD1887		0x41445362
 #define AC97_ID_AD1886A		0x41445363
+#define AC97_ID_AD1980 		0x41445370
 #define AC97_ID_TR28028		0x54524108
 #define AC97_ID_STAC9700	0x83847600
 #define AC97_ID_STAC9704	0x83847604

===================================================================

Option 2 : The enumerated (more readable but more code) control

Index: ac97_codec.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_codec.c,v retrieving revision 1.66

ac97_codec.c +1 -0
diff -u -r1.66 ac97_codec.c
@@ -1022,6 +1022,49 @@
 AD18XX_PCM_BITS("LFE Playback Volume", 2, 0, 31)
 };
 
+static int snd_ac97_ad1980_spdif_source_info(snd_kcontrol_t *kcontrol,

snd_ctl_elem_info_t * uinfo)
+{
+ static char *texts[2] = { "AC-Link", "A/D Converter" };
+
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+ uinfo->count = 1;
+ uinfo->value.enumerated.items = 2;
+ if (uinfo->value.enumerated.item > 1)
+ uinfo->value.enumerated.item = 1;
+ strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
+ return 0;
+}
+
+static int snd_ac97_ad1980_spdif_source_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+ ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+ unsigned short val;
+
+ val = ac97->regs[AC97_AD_SERIAL_CFG];
+ ucontrol->value.enumerated.item[0] = (val >> 2) & 1;
+ return 0;
+}
+
+static int snd_ac97_ad1980_spdif_source_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+{
+ ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+ unsigned short val;
+
+ if (ucontrol->value.enumerated.item[0] > 1)
+ return -EINVAL;
+ val = ucontrol->value.enumerated.item[0] << 2;
+ return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
+}
+
+static const snd_kcontrol_new_t snd_ac97_ad1980_spdif_source =
+ {
+ iface: SNDRV_CTL_ELEM_IFACE_MIXER,
+ name: SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
+ info: snd_ac97_ad1980_spdif_source_info,
+ get: snd_ac97_ad1980_spdif_source_get,
+ put: snd_ac97_ad1980_spdif_source_put,
+ };
+
/*
* ALC650
*/
@@ -1679,6 +1722,10 @@
if (ac97->id == AC97_ID_YMF753) {
for (idx = 0; idx < 3; idx++)
if ((err = snd_ctl_add(card,
snd_ac97_cnew(&snd_ac97_ymf753_controls_spdif[idx], ac97))) < 0)
+ return err;
+ }
+ if (ac97->id == AC97_ID_AD1980) {
+ if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_ad1980_spdif_source,
ac97))) < 0)
return err;
}
/* set default PCM S/PDIF params */
Index: ac97_id.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ac97/ac97_id.h,v retrieving revision 1.6

ac97_id.h +1 -0
diff -u -r1.6 ac97_id.h
@@ -31,6 +31,7 @@
 #define AC97_ID_AD1886		0x41445361
 #define AC97_ID_AD1887		0x41445362
 #define AC97_ID_AD1886A		0x41445363
+#define AC97_ID_AD1980 		0x41445370
 #define AC97_ID_TR28028		0x54524108
 #define AC97_ID_STAC9700	0x83847600
 #define AC97_ID_STAC9704	0x83847604

===================================================================

See previous post for details.

--------------
Fycio (J.Sobierski)
[email protected]

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#1 lore raw

At Mon, 17 Feb 2003 11:36:34 -0800,

Quoted 3 lines · Jaroslaw Sobierski

OK, here is the unified diff. Two of them actually, i separated the different options for better clarity.

...

Quoted 2 lines

Option 2 : The enumerated (more readable but more code) control

i took this. clarity is better, isn't it? (btw, you can change enum values via alsamixer, too.)

ok, i committed to cvs. please check whether it works for you.

the changes for AD1981A/B are not done yet. does anyone have this device?

thanks,

Takashi

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven.
http://thinkgeek.com/sf

#2 lore raw

Quoting Takashi Iwai <[email protected]>:

Quoted 10 lines

At Mon, 17 Feb 2003 11:36:34 -0800,

Quoted 3 lines · Jaroslaw Sobierski

OK, here is the unified diff. Two of them actually, i separated the different options for better clarity.

...

Quoted 2 lines

Option 2 : The enumerated (more readable but more code) control

i took this. clarity is better, isn't it?

By all means.

Quoted 1 line

(btw, you can change enum values via alsamixer, too.)

Really? Well I assumed it would be possible but couldn't figure out how. And the help feature didn't help much :-)

Quoted 3 lines

ok, i committed to cvs. please check whether it works for you.

I will this evening, had some network problems yesterday.

Quoted 4 lines

the changes for AD1981A/B are not done yet.
does anyone have this device?

I know 1981A is installed on a few boards with the 845 chipset, mainly Fujitsu and AOpen, but probably others too.

Tha 1981B is harder to come by, maybe because it's newer, it's mostly on Intel boards (with different flavors of the 845 chipset).

--------------
Fycio (J.Sobierski)
[email protected]

-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge

#3 lore raw
In reply to Takashi Iwai

Quoting Takashi Iwai <[email protected]>:

Quoted 5 lines

At Mon, 17 Feb 2003 11:36:34 -0800,

Quoted 3 lines · Jaroslaw Sobierski

OK, here is the unified diff. Two of them actually, i separated the different options for better clarity.

Quoted 9 lines

...

Quoted 2 lines

Option 2 : The enumerated (more readable but more code) control

i took this. clarity is better, isn't it? (btw, you can change enum values via alsamixer, too.)

ok, i committed to cvs. please check whether it works for you.

It does, I checked yesterday.
Does anybody else have this chip to confirm?

--------------
Fycio (J.Sobierski)
[email protected]

-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge