[alsa-devel] [PATCH 2/2] ac97: YMF743 missing controls support
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
---
The second one contains following changes:
- A chip-specific SPDIF support for YMF743 (It doesn't have AC97 standard SPDIF registers seen on YMF753).
- The implementation for "IEC958 Playback Source" and "IEC958 Mute" are identical to the ones for YMF753. But there is no "IEC958 Output Pin" for YMF743.
diff -r 92978f62cc03 pci/ac97/ac97_codec.c --- a/pci/ac97/ac97_codec.c Tue Sep 18 00:28:51 2007 +0900 +++ b/pci/ac97/ac97_codec.c Tue Sep 18 00:29:26 2007 +0900 @@ -176,7 +176,7 @@ static const struct ac97_codec_id snd_ac { 0x574d4C09, 0xffffffff, "WM9709", NULL, NULL}, { 0x574d4C12, 0xffffffff, "WM9711,WM9712", patch_wolfson11, NULL}, { 0x574d4c13, 0xffffffff, "WM9713,WM9714", patch_wolfson13, NULL, AC97_DEFAULT_POWER_OFF}, -{ 0x594d4800, 0xffffffff, "YMF743", NULL, NULL }, +{ 0x594d4800, 0xffffffff, "YMF743", patch_yamaha_ymf743, NULL }, { 0x594d4802, 0xffffffff, "YMF752", NULL, NULL }, { 0x594d4803, 0xffffffff, "YMF753", patch_yamaha_ymf753, NULL }, { 0x83847600, 0xffffffff, "STAC9700,83,84", patch_sigmatel_stac9700, NULL }, @@ -779,6 +779,12 @@ static int snd_ac97_spdif_default_put(st change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, AC97_CXR_SPDIF_MASK | AC97_CXR_COPYRGT, v); + } else if (ac97->id == AC97_ID_YMF743) { + change |= snd_ac97_update_bits_nolock(ac97, + AC97_YMF7X3_DIT_CTRL, + 0xff38, + ((val << 4) & 0xff00) | + ((val << 2) & 0x0038)); } else { unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ @@ -1375,7 +1381,8 @@ static int snd_ac97_mixer_build(struct s for (idx = 0; idx < 2; idx++) { if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97))) < 0) return err; - if (ac97->id == AC97_ID_YMF753) { + if (ac97->id == AC97_ID_YMF743 || + ac97->id == AC97_ID_YMF753) { kctl->private_value &= ~(0xff << 16); kctl->private_value |= 7 << 16; } diff -r 92978f62cc03 pci/ac97/ac97_id.h --- a/pci/ac97/ac97_id.h Tue Sep 18 00:28:51 2007 +0900 +++ b/pci/ac97/ac97_id.h Tue Sep 18 00:29:26 2007 +0900 @@ -54,6 +54,7 @@ #define AC97_ID_ALC658 0x414c4780 #define AC97_ID_ALC658D 0x414c4781 #define AC97_ID_ALC850 0x414c4790 +#define AC97_ID_YMF743 0x594d4800 #define AC97_ID_YMF753 0x594d4803 #define AC97_ID_VT1616 0x49434551 #define AC97_ID_CM9738 0x434d4941 diff -r 92978f62cc03 pci/ac97/ac97_patch.c --- a/pci/ac97/ac97_patch.c Tue Sep 18 00:28:51 2007 +0900 +++ b/pci/ac97/ac97_patch.c Tue Sep 18 00:29:26 2007 +0900 @@ -204,6 +204,7 @@ static inline int is_shared_micin(struct
/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ +/* Modified for YMF743 by Keita Maehara maehara@debian.org */
/* It is possible to indicate to the Yamaha YMF7x3 the type of speakers being used. */ static int snd_ac97_ymf7x3_info_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -287,6 +288,63 @@ static int snd_ac97_ymf7x3_spdif_source_ return -EINVAL; val = ucontrol->value.enumerated.item[0] << 1; return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val); +} + +static int patch_yamaha_ymf7x3_3d(struct snd_ac97 * ac97) +{ + struct snd_kcontrol *kctl; + int err; + + 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_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0); + snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); + if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_ymf7x3_controls_speaker, ac97))) < 0) + return err; + snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00); + return 0; +} + +static const struct snd_kcontrol_new snd_ac97_yamaha_ymf743_controls_spdif[3] = { + AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), AC97_YMF7X3_DIT_CTRL, 0, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", + .info = snd_ac97_ymf7x3_spdif_source_info, + .get = snd_ac97_ymf7x3_spdif_source_get, + .put = snd_ac97_ymf7x3_spdif_source_put, + }, + AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",NONE,NONE) "Mute", AC97_YMF7X3_DIT_CTRL, 2, 1, 1) +}; + +static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 * ac97) +{ + int err; + + if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0) + return err; + if ((err = patch_build_controls(ac97, snd_ac97_yamaha_ymf743_controls_spdif, ARRAY_SIZE(snd_ac97_yamaha_ymf743_controls_spdif))) < 0) + return err; + /* set default PCM S/PDIF params */ + /* PCM audio,no copyright,no preemphasis,PCM coder,original */ + snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201); + return 0; +} + +static struct snd_ac97_build_ops patch_yamaha_ymf743_ops = { + .build_spdif = patch_yamaha_ymf743_build_spdif, + .build_3d = patch_yamaha_ymf7x3_3d, +}; + +static int patch_yamaha_ymf743(struct snd_ac97 * ac97) +{ + ac97->build_ops = &patch_yamaha_ymf743_ops; + ac97->caps |= AC97_BC_BASS_TREBLE; + ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */ + ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ + ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ + return 0; }
/* The AC'97 spec states that the S/PDIF signal is to be output at pin 48. @@ -347,22 +405,6 @@ static const struct snd_kcontrol_new snd }, AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",NONE,NONE) "Mute", AC97_YMF7X3_DIT_CTRL, 2, 1, 1) }; - -static int patch_yamaha_ymf7x3_3d(struct snd_ac97 * ac97) -{ - struct snd_kcontrol *kctl; - int err; - - 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_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0); - snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_ymf7x3_controls_speaker, ac97))) < 0) - return err; - snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00); - return 0; -}
static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97) { diff -r 92978f62cc03 pci/ac97/ac97_proc.c --- a/pci/ac97/ac97_proc.c Tue Sep 18 00:28:51 2007 +0900 +++ b/pci/ac97/ac97_proc.c Tue Sep 18 00:29:26 2007 +0900 @@ -236,10 +236,14 @@ static void snd_ac97_proc_read_main(stru val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE); snd_iprintf(buffer, "PCM MIC ADC : %iHz\n", val); } - if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF)) { + if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF) || + (ac97->id == AC97_ID_YMF743)) { if (ac97->flags & AC97_CS_SPDIF) val = snd_ac97_read(ac97, AC97_CSR_SPDIF); - else + else if (ac97->id == AC97_ID_YMF743) { + val = snd_ac97_read(ac97, AC97_YMF7X3_DIT_CTRL); + val = 0x2000 | (val & 0xff00) >> 4 | (val & 0x38) >> 2; + } else val = snd_ac97_read(ac97, AC97_SPDIF);
snd_iprintf(buffer, "SPDIF Control :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n",
At Wed, 19 Sep 2007 00:50:54 +0900, Keita Maehara wrote:
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
The changes look good to me, but I'd like to ask you to rewrite the patch to follow the standard coding style. Yes, the original ac97 code doesn't follow, but at least, we should do it right for the newly added/changed codes. For example, keep lines within 80 chars, fold lines appropriately, avoid if ((err = ...)) style, etc.
In doubt, you can run scripts/checkpatch.pl in the linux kernel tree.
Thanks,
Takashi
At Tue, 18 Sep 2007 18:04:02 +0200, Takashi Iwai wrote:
At Wed, 19 Sep 2007 00:50:54 +0900, Keita Maehara wrote:
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
The changes look good to me, but I'd like to ask you to rewrite the patch to follow the standard coding style. Yes, the original ac97 code doesn't follow, but at least, we should do it right for the newly added/changed codes. For example, keep lines within 80 chars, fold lines appropriately, avoid if ((err = ...)) style, etc.
I was wondering whether to follow the coding style for them indeed but understood the policy now. Sorry to bother you.
In doubt, you can run scripts/checkpatch.pl in the linux kernel tree.
Now they're checkpatch-clean anyway. I've put the second version at http://people.debian.org/~maehara/alsa-ymf743.
At Wed, 19 Sep 2007 08:47:23 +0900, Keita Maehara wrote:
At Tue, 18 Sep 2007 18:04:02 +0200, Takashi Iwai wrote:
At Wed, 19 Sep 2007 00:50:54 +0900, Keita Maehara wrote:
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
The changes look good to me, but I'd like to ask you to rewrite the patch to follow the standard coding style. Yes, the original ac97 code doesn't follow, but at least, we should do it right for the newly added/changed codes. For example, keep lines within 80 chars, fold lines appropriately, avoid if ((err = ...)) style, etc.
I was wondering whether to follow the coding style for them indeed but understood the policy now. Sorry to bother you.
In doubt, you can run scripts/checkpatch.pl in the linux kernel tree.
Now they're checkpatch-clean anyway. I've put the second version at http://people.debian.org/~maehara/alsa-ymf743.
Could you repost here again? Then I could give further review comments (if any).
thanks,
Takashi
At Wed, 19 Sep 2007 13:06:38 +0200, Takashi Iwai wrote:
Now they're checkpatch-clean anyway. I've put the second version at http://people.debian.org/~maehara/alsa-ymf743.
Could you repost here again? Then I could give further review comments (if any).
Okay, here it is.
From: Keita Maehara maehara@debian.org
These patches enable some YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
---
The first one contains only cosmetic changes to share a few YMF753-specific symbols with YMF743.
diff -r 0028e39ead78 include/ac97_codec.h --- a/include/ac97_codec.h Tue Sep 18 00:52:38 2007 +0200 +++ b/include/ac97_codec.h Wed Sep 19 01:19:44 2007 +0900 @@ -345,9 +345,9 @@ #define AC97_ALC650_GPIO_STATUS 0x78 #define AC97_ALC650_CLOCK 0x7a
-/* specific - Yamaha YMF753 */ -#define AC97_YMF753_DIT_CTRL2 0x66 /* DIT Control 2 */ -#define AC97_YMF753_3D_MODE_SEL 0x68 /* 3D Mode Select */ +/* specific - Yamaha YMF7x3 */ +#define AC97_YMF7X3_DIT_CTRL 0x66 /* DIT Control (YMF743) / 2 (YMF753) */ +#define AC97_YMF7X3_3D_MODE_SEL 0x68 /* 3D Mode Select */
/* specific - C-Media */ #define AC97_CM9738_VENDOR_CTRL 0x5a diff -r 0028e39ead78 pci/ac97/ac97_patch.c --- a/pci/ac97/ac97_patch.c Tue Sep 18 00:52:38 2007 +0200 +++ b/pci/ac97/ac97_patch.c Wed Sep 19 01:34:44 2007 +0900 @@ -205,8 +205,11 @@ static inline int is_shared_micin(struct
/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
-/* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ -static int snd_ac97_ymf753_info_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +/* It is possible to indicate to the Yamaha YMF7x3 the type of + speakers being used. */ + +static int snd_ac97_ymf7x3_info_speaker(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Standard", "Small", "Smaller" @@ -221,12 +224,13 @@ static int snd_ac97_ymf753_info_speaker( return 0; }
-static int snd_ac97_ymf753_get_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_ymf7x3_get_speaker(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val;
- val = ac97->regs[AC97_YMF753_3D_MODE_SEL]; + val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL]; val = (val >> 10) & 3; if (val > 0) /* 0 = invalid */ val--; @@ -234,7 +238,8 @@ static int snd_ac97_ymf753_get_speaker(s return 0; }
-static int snd_ac97_ymf753_put_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_ymf7x3_put_speaker(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; @@ -242,20 +247,22 @@ static int snd_ac97_ymf753_put_speaker(s if (ucontrol->value.enumerated.item[0] > 2) return -EINVAL; val = (ucontrol->value.enumerated.item[0] + 1) << 10; - return snd_ac97_update(ac97, AC97_YMF753_3D_MODE_SEL, val); -} - -static const struct snd_kcontrol_new snd_ac97_ymf753_controls_speaker = + return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val); +} + +static const struct snd_kcontrol_new snd_ac97_ymf7x3_controls_speaker = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Speaker", - .info = snd_ac97_ymf753_info_speaker, - .get = snd_ac97_ymf753_get_speaker, - .put = snd_ac97_ymf753_put_speaker, -}; - -/* It is possible to indicate to the Yamaha YMF753 the source to direct to the S/PDIF output. */ -static int snd_ac97_ymf753_spdif_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) + .info = snd_ac97_ymf7x3_info_speaker, + .get = snd_ac97_ymf7x3_get_speaker, + .put = snd_ac97_ymf7x3_put_speaker, +}; + +/* It is possible to indicate to the Yamaha YMF7x3 the source to + direct to the S/PDIF output. */ +static int snd_ac97_ymf7x3_spdif_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "AC-Link", "A/D Converter" };
@@ -268,17 +275,19 @@ static int snd_ac97_ymf753_spdif_source_ return 0; }
-static int snd_ac97_ymf753_spdif_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_ymf7x3_spdif_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val;
- val = ac97->regs[AC97_YMF753_DIT_CTRL2]; + val = ac97->regs[AC97_YMF7X3_DIT_CTRL]; ucontrol->value.enumerated.item[0] = (val >> 1) & 1; return 0; }
-static int snd_ac97_ymf753_spdif_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_ymf7x3_spdif_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; @@ -286,7 +295,7 @@ static int snd_ac97_ymf753_spdif_source_ if (ucontrol->value.enumerated.item[0] > 1) return -EINVAL; val = ucontrol->value.enumerated.item[0] << 1; - return snd_ac97_update_bits(ac97, AC97_YMF753_DIT_CTRL2, 0x0002, val); + return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val); }
/* The AC'97 spec states that the S/PDIF signal is to be output at pin 48. @@ -311,7 +320,7 @@ static int snd_ac97_ymf753_spdif_output_ struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val;
- val = ac97->regs[AC97_YMF753_DIT_CTRL2]; + val = ac97->regs[AC97_YMF7X3_DIT_CTRL]; ucontrol->value.enumerated.item[0] = (val & 0x0008) ? 2 : (val & 0x0020) ? 1 : 0; return 0; } @@ -325,7 +334,7 @@ static int snd_ac97_ymf753_spdif_output_ return -EINVAL; val = (ucontrol->value.enumerated.item[0] == 2) ? 0x0008 : (ucontrol->value.enumerated.item[0] == 1) ? 0x0020 : 0; - return snd_ac97_update_bits(ac97, AC97_YMF753_DIT_CTRL2, 0x0028, val); + return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val); /* The following can be used to direct S/PDIF output to pin 47 (EAPD). snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */ } @@ -334,9 +343,9 @@ static const struct snd_kcontrol_new snd { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", - .info = snd_ac97_ymf753_spdif_source_info, - .get = snd_ac97_ymf753_spdif_source_get, - .put = snd_ac97_ymf753_spdif_source_put, + .info = snd_ac97_ymf7x3_spdif_source_info, + .get = snd_ac97_ymf7x3_spdif_source_get, + .put = snd_ac97_ymf7x3_spdif_source_put, }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -345,22 +354,29 @@ static const struct snd_kcontrol_new snd .get = snd_ac97_ymf753_spdif_output_pin_get, .put = snd_ac97_ymf753_spdif_output_pin_put, }, - AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",NONE,NONE) "Mute", AC97_YMF753_DIT_CTRL2, 2, 1, 1) -}; - -static int patch_yamaha_ymf753_3d(struct snd_ac97 * ac97) + AC97_SINGLE(SNDRV_CTL_NAME_IEC958("", NONE, NONE) "Mute", + AC97_YMF7X3_DIT_CTRL, 2, 1, 1) +}; + +static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97) { struct snd_kcontrol *kctl; int err;
- if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); + err = snd_ctl_add(ac97->bus->card, kctl); + if (err < 0) return err; strcpy(kctl->id.name, "3D Control - Wide"); kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0); snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_ymf753_controls_speaker, ac97))) < 0) + + err = snd_ctl_add(ac97->bus->card, + snd_ac97_cnew(&snd_ac97_ymf7x3_controls_speaker, + ac97)); + if (err < 0) return err; - snd_ac97_write_cache(ac97, AC97_YMF753_3D_MODE_SEL, 0x0c00); + snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00); return 0; }
@@ -374,7 +390,7 @@ static int patch_yamaha_ymf753_post_spdi }
static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = { - .build_3d = patch_yamaha_ymf753_3d, + .build_3d = patch_yamaha_ymf7x3_3d, .build_post_spdif = patch_yamaha_ymf753_post_spdif };
At Wed, 19 Sep 2007 20:28:22 +0900, Keita Maehara wrote:
Okay, here it is.
And this is the second part.
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
---
The second one contains following changes:
- A chip-specific SPDIF support for YMF743 (It doesn't have AC97 standard SPDIF registers seen on YMF753).
- The implementation for "IEC958 Playback Source" and "IEC958 Mute" are identical to the ones for YMF753. But there is no "IEC958 Output Pin" for YMF743.
diff -r a543470c3455 pci/ac97/ac97_codec.c --- a/pci/ac97/ac97_codec.c Wed Sep 19 07:52:08 2007 +0900 +++ b/pci/ac97/ac97_codec.c Wed Sep 19 07:52:14 2007 +0900 @@ -176,7 +176,7 @@ static const struct ac97_codec_id snd_ac { 0x574d4C09, 0xffffffff, "WM9709", NULL, NULL}, { 0x574d4C12, 0xffffffff, "WM9711,WM9712", patch_wolfson11, NULL}, { 0x574d4c13, 0xffffffff, "WM9713,WM9714", patch_wolfson13, NULL, AC97_DEFAULT_POWER_OFF}, -{ 0x594d4800, 0xffffffff, "YMF743", NULL, NULL }, +{ 0x594d4800, 0xffffffff, "YMF743", patch_yamaha_ymf743, NULL }, { 0x594d4802, 0xffffffff, "YMF752", NULL, NULL }, { 0x594d4803, 0xffffffff, "YMF753", patch_yamaha_ymf753, NULL }, { 0x83847600, 0xffffffff, "STAC9700,83,84", patch_sigmatel_stac9700, NULL }, @@ -779,6 +779,12 @@ static int snd_ac97_spdif_default_put(st change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, AC97_CXR_SPDIF_MASK | AC97_CXR_COPYRGT, v); + } else if (ac97->id == AC97_ID_YMF743) { + change |= snd_ac97_update_bits_nolock(ac97, + AC97_YMF7X3_DIT_CTRL, + 0xff38, + ((val << 4) & 0xff00) | + ((val << 2) & 0x0038)); } else { unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ @@ -1375,7 +1381,8 @@ static int snd_ac97_mixer_build(struct s for (idx = 0; idx < 2; idx++) { if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97))) < 0) return err; - if (ac97->id == AC97_ID_YMF753) { + if (ac97->id == AC97_ID_YMF743 || + ac97->id == AC97_ID_YMF753) { kctl->private_value &= ~(0xff << 16); kctl->private_value |= 7 << 16; } diff -r a543470c3455 pci/ac97/ac97_id.h --- a/pci/ac97/ac97_id.h Wed Sep 19 07:52:08 2007 +0900 +++ b/pci/ac97/ac97_id.h Wed Sep 19 07:52:14 2007 +0900 @@ -54,6 +54,7 @@ #define AC97_ID_ALC658 0x414c4780 #define AC97_ID_ALC658D 0x414c4781 #define AC97_ID_ALC850 0x414c4790 +#define AC97_ID_YMF743 0x594d4800 #define AC97_ID_YMF753 0x594d4803 #define AC97_ID_VT1616 0x49434551 #define AC97_ID_CM9738 0x434d4941 diff -r a543470c3455 pci/ac97/ac97_patch.c --- a/pci/ac97/ac97_patch.c Wed Sep 19 07:52:08 2007 +0900 +++ b/pci/ac97/ac97_patch.c Wed Sep 19 07:52:39 2007 +0900 @@ -204,6 +204,7 @@ static inline int is_shared_micin(struct
/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ +/* Modified for YMF743 by Keita Maehara maehara@debian.org */
/* It is possible to indicate to the Yamaha YMF7x3 the type of speakers being used. */ @@ -296,6 +297,74 @@ static int snd_ac97_ymf7x3_spdif_source_ return -EINVAL; val = ucontrol->value.enumerated.item[0] << 1; return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val); +} + +static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97) +{ + struct snd_kcontrol *kctl; + int err; + + kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); + err = snd_ctl_add(ac97->bus->card, kctl); + if (err < 0) + return err; + strcpy(kctl->id.name, "3D Control - Wide"); + kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0); + snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); + err = snd_ctl_add(ac97->bus->card, + snd_ac97_cnew(&snd_ac97_ymf7x3_controls_speaker, + ac97)); + if (err < 0) + return err; + snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00); + return 0; +} + +static const struct snd_kcontrol_new snd_ac97_yamaha_ymf743_controls_spdif[3] = +{ + AC97_SINGLE(SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), + AC97_YMF7X3_DIT_CTRL, 0, 1, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, NONE) "Source", + .info = snd_ac97_ymf7x3_spdif_source_info, + .get = snd_ac97_ymf7x3_spdif_source_get, + .put = snd_ac97_ymf7x3_spdif_source_put, + }, + AC97_SINGLE(SNDRV_CTL_NAME_IEC958("", NONE, NONE) "Mute", + AC97_YMF7X3_DIT_CTRL, 2, 1, 1) +}; + +static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97) +{ + int err; + + err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3); + if (err < 0) + return err; + err = patch_build_controls(ac97, + snd_ac97_yamaha_ymf743_controls_spdif, 3); + if (err < 0) + return err; + /* set default PCM S/PDIF params */ + /* PCM audio,no copyright,no preemphasis,PCM coder,original */ + snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201); + return 0; +} + +static struct snd_ac97_build_ops patch_yamaha_ymf743_ops = { + .build_spdif = patch_yamaha_ymf743_build_spdif, + .build_3d = patch_yamaha_ymf7x3_3d, +}; + +static int patch_yamaha_ymf743(struct snd_ac97 *ac97) +{ + ac97->build_ops = &patch_yamaha_ymf743_ops; + ac97->caps |= AC97_BC_BASS_TREBLE; + ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */ + ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ + ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ + return 0; }
/* The AC'97 spec states that the S/PDIF signal is to be output at pin 48. @@ -357,28 +426,6 @@ static const struct snd_kcontrol_new snd AC97_SINGLE(SNDRV_CTL_NAME_IEC958("", NONE, NONE) "Mute", AC97_YMF7X3_DIT_CTRL, 2, 1, 1) }; - -static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97) -{ - struct snd_kcontrol *kctl; - int err; - - kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); - err = snd_ctl_add(ac97->bus->card, kctl); - if (err < 0) - return err; - strcpy(kctl->id.name, "3D Control - Wide"); - kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 9, 7, 0); - snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); - - err = snd_ctl_add(ac97->bus->card, - snd_ac97_cnew(&snd_ac97_ymf7x3_controls_speaker, - ac97)); - if (err < 0) - return err; - snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00); - return 0; -}
static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97) { diff -r a543470c3455 pci/ac97/ac97_proc.c --- a/pci/ac97/ac97_proc.c Wed Sep 19 07:52:08 2007 +0900 +++ b/pci/ac97/ac97_proc.c Wed Sep 19 07:52:14 2007 +0900 @@ -236,10 +236,14 @@ static void snd_ac97_proc_read_main(stru val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE); snd_iprintf(buffer, "PCM MIC ADC : %iHz\n", val); } - if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF)) { + if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF) || + (ac97->id == AC97_ID_YMF743)) { if (ac97->flags & AC97_CS_SPDIF) val = snd_ac97_read(ac97, AC97_CSR_SPDIF); - else + else if (ac97->id == AC97_ID_YMF743) { + val = snd_ac97_read(ac97, AC97_YMF7X3_DIT_CTRL); + val = 0x2000 | (val & 0xff00) >> 4 | (val & 0x38) >> 2; + } else val = snd_ac97_read(ac97, AC97_SPDIF);
snd_iprintf(buffer, "SPDIF Control :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n",
At Wed, 19 Sep 2007 20:34:53 +0900, Keita Maehara wrote:
At Wed, 19 Sep 2007 20:28:22 +0900, Keita Maehara wrote:
Okay, here it is.
And this is the second part.
From: Keita Maehara maehara@debian.org
These patches enable a few YMF743 controls (Tone/3D/IEC958) that won't be detected with the current version of ALSA.
Signed-off-by: Keita Maehara maehara@debian.org
Thanks! Now applied to HG tree.
Takashi
participants (2)
-
Keita Maehara
-
Takashi Iwai