diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index 0e9d75b..9e659e2 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -31,6 +31,7 @@ #include <sound/pcm.h> #include <sound/control.h> #include <sound/info.h> +#include <sound/jack.h>
/* maximum number of devices on the AC97 bus */ #define AC97_BUS_MAX_DEVICES 4 @@ -531,6 +532,10 @@ struct snd_ac97 { struct device dev;
struct snd_pcm_chmap *chmaps[2]; /* channel-maps (optional) */ + + struct snd_jack *hp_jack; + struct snd_jack *lo_jack; + struct snd_jack *sp_jack; };
#define to_ac97_t(d) container_of(d, struct snd_ac97, dev) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index f4234ed..581000c 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -1886,6 +1886,23 @@ static int patch_ad1981a(struct snd_ac97 *ac97) static const struct snd_kcontrol_new snd_ac97_ad198x_2cmic = AC97_SINGLE("Stereo Mic", AC97_AD_MISC, 6, 1, 0);
+#define AD198X_JS1_ST 0x08 +#define AD198X_JS0_ST 0x04 + +void ad198x_handle_hp_jack(struct snd_ac97 *ac97) +{ + bool hp_plugged = (snd_ac97_read(ac97, AC97_AD_JACK_SPDIF) & + AD198X_JS1_ST) == AD198X_JS1_ST; + snd_jack_report(ac97->hp_jack, hp_plugged ? SND_JACK_HEADPHONE : 0); +} + +void ad198x_handle_lo_jack(struct snd_ac97 *ac97) +{ + bool lo_plugged = (snd_ac97_read(ac97, AC97_AD_JACK_SPDIF) & + AD198X_JS0_ST) == AD198X_JS0_ST; + snd_jack_report(ac97->lo_jack, lo_plugged ? SND_JACK_LINEOUT : 0); +} + static int patch_ad1981b_specific(struct snd_ac97 *ac97) { int err; @@ -1894,8 +1911,23 @@ static int patch_ad1981b_specific(struct snd_ac97 *ac97) return err; if (check_list(ac97, ad1981_jacks_blacklist)) return 0; - return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, + err = patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); + if (err < 0) + return err; + if (( err = snd_jack_new(ac97->bus->card, "Headphone", SND_JACK_HEADPHONE, + &ac97->hp_jack, true, false)) < 0) + return err; + ad198x_handle_hp_jack(ac97); + if (( err = snd_jack_new(ac97->bus->card, "Line Out", SND_JACK_LINEOUT, + &ac97->lo_jack, true, false)) < 0) + return err; + ad198x_handle_lo_jack(ac97); + if (( err = snd_jack_new(ac97->bus->card, "Internal Speaker", SND_JACK_LINEOUT, + &ac97->sp_jack, true, true)) < 0) + return err; + snd_jack_report(ac97->sp_jack, SND_JACK_LINEOUT); + return 0; }
static const struct snd_ac97_build_ops patch_ad1981b_build_ops = {
diff --git a/include/ sound/ac97_ codec.h b/include/ sound/ac97_ codec.h sound/ac97_ codec.h sound/ac97_ codec.h
index 0e9d75b..9e659e2 100644
--- a/include/
+++ b/include/
@@ -31,6 +31,7 @@
#include <sound/pcm.h>
#include <sound/control.h>
#include <sound/info.h>
+#include <sound/jack.h>
/* maximum number of devices on the AC97 bus */ MAX_DEVICES 4
#define AC97_BUS_
@@ -531,6 +532,10 @@ struct snd_ac97 {
struct device dev;
struct snd_pcm_chmap *chmaps[2]; /* channel-maps (optional) */
+
+ struct snd_jack *hp_jack;
+ struct snd_jack *lo_jack;
+ struct snd_jack *sp_jack;
};
#define to_ac97_t(d) container_of(d, struct snd_ac97, dev) pci/ac97/ ac97_patch. c b/sound/ pci/ac97/ ac97_patch. c pci/ac97/ ac97_patch. c pci/ac97/ ac97_patch. c struct snd_ac97 *ac97) ad198x_ 2cmic = "Stereo Mic", AC97_AD_MISC, 6, 1, 0);
diff --git a/sound/
index f4234ed..581000c 100644
--- a/sound/
+++ b/sound/
@@ -1886,6 +1886,23 @@ static int patch_ad1981a(
static const struct snd_kcontrol_new snd_ac97_
AC97_SINGLE(
+#define AD198X_JS1_ST 0x08 handle_ hp_jack( struct snd_ac97 *ac97) read(ac97, AC97_AD_JACK_SPDIF) & report( ac97->hp_ jack, hp_plugged ? SND_JACK_HEADPHONE : 0); handle_ lo_jack( struct snd_ac97 *ac97) read(ac97, AC97_AD_JACK_SPDIF) & report( ac97->lo_ jack, lo_plugged ? SND_JACK_LINEOUT : 0); specific( struct snd_ac97 *ac97) specific( struct snd_ac97 *ac97) jacks_blacklist )) controls( ac97, snd_ac97_ ad1981x_ jack_sense, controls( ac97, snd_ac97_ ad1981x_ jack_sense,
ARRAY_ SIZE(snd_ ac97_ad1981x_ jack_sense) ); new(ac97- >bus->card, "Headphone", SND_JACK_HEADPHONE, handle_ hp_jack( ac97); new(ac97- >bus->card, "Line Out", SND_JACK_LINEOUT, handle_ lo_jack( ac97); new(ac97- >bus->card, "Internal Speaker", SND_JACK_LINEOUT, report( ac97->sp_ jack, SND_JACK_LINEOUT);
+#define AD198X_JS0_ST 0x04
+
+void ad198x_
+{
+ bool hp_plugged = (snd_ac97_
+ AD198X_JS1_ST) == AD198X_JS1_ST;
+ snd_jack_
+}
+
+void ad198x_
+{
+ bool lo_plugged = (snd_ac97_
+ AD198X_JS0_ST) == AD198X_JS0_ST;
+ snd_jack_
+}
+
static int patch_ad1981b_
{
int err;
@@ -1894,8 +1911,23 @@ static int patch_ad1981b_
return err;
if (check_list(ac97, ad1981_
return 0;
- return patch_build_
+ err = patch_build_
+ if (err < 0)
+ return err;
+ if (( err = snd_jack_
+ &ac97->hp_jack, true, false)) < 0)
+ return err;
+ ad198x_
+ if (( err = snd_jack_
+ &ac97->lo_jack, true, false)) < 0)
+ return err;
+ ad198x_
+ if (( err = snd_jack_
+ &ac97->sp_jack, true, true)) < 0)
+ return err;
+ snd_jack_
+ return 0;
}
static const struct snd_ac97_build_ops patch_ad1981b_ build_ops = {