Deleted Added
full compact
ac97.c (167611) ac97.c (168861)
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27#include <dev/sound/pcm/sound.h>
28#include <dev/sound/pcm/ac97.h>
29#include <dev/sound/pcm/ac97_patch.h>
30
31#include <dev/pci/pcivar.h>
32
33#include "mixer_if.h"
34
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27#include <dev/sound/pcm/sound.h>
28#include <dev/sound/pcm/ac97.h>
29#include <dev/sound/pcm/ac97_patch.h>
30
31#include <dev/pci/pcivar.h>
32
33#include "mixer_if.h"
34
35SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/ac97.c 167611 2007-03-15 18:19:01Z ariff $");
35SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/ac97.c 168861 2007-04-19 13:54:22Z ariff $");
36
37MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
38
39struct ac97mixtable_entry {
40 int reg:8; /* register index */
41 /* reg < 0 if inverted polarity */
42 unsigned bits:4; /* width of control field */
43 unsigned ofs:4; /* offset (only if stereo=0) */

--- 5 unchanged lines hidden (view full) ---

49};
50
51#define AC97_NAMELEN 16
52struct ac97_info {
53 kobj_t methods;
54 device_t dev;
55 void *devinfo;
56 u_int32_t id;
36
37MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
38
39struct ac97mixtable_entry {
40 int reg:8; /* register index */
41 /* reg < 0 if inverted polarity */
42 unsigned bits:4; /* width of control field */
43 unsigned ofs:4; /* offset (only if stereo=0) */

--- 5 unchanged lines hidden (view full) ---

49};
50
51#define AC97_NAMELEN 16
52struct ac97_info {
53 kobj_t methods;
54 device_t dev;
55 void *devinfo;
56 u_int32_t id;
57 u_int32_t subvendor;
57 unsigned count, caps, se, extcaps, extid, extstat, noext:1;
58 u_int32_t flags;
59 struct ac97mixtable_entry mix[32];
60 char name[AC97_NAMELEN];
61 struct mtx *lock;
62};
63
64struct ac97_vendorid {

--- 82 unchanged lines hidden (view full) ---

147 { 0x414b4d06, 0x00, 0, "AK4544A", 0 },
148 { 0x454b4d07, 0x00, 0, "AK4545", 0 },
149 { 0x414c4320, 0x0f, 0, "ALC100", 0 },
150 { 0x414c4730, 0x0f, 0, "ALC101", 0 },
151 { 0x414c4710, 0x0f, 0, "ALC200", 0 },
152 { 0x414c4740, 0x0f, 0, "ALC202", 0 },
153 { 0x414c4720, 0x0f, 0, "ALC650", 0 },
154 { 0x414c4752, 0x0f, 0, "ALC250", 0 },
58 unsigned count, caps, se, extcaps, extid, extstat, noext:1;
59 u_int32_t flags;
60 struct ac97mixtable_entry mix[32];
61 char name[AC97_NAMELEN];
62 struct mtx *lock;
63};
64
65struct ac97_vendorid {

--- 82 unchanged lines hidden (view full) ---

148 { 0x414b4d06, 0x00, 0, "AK4544A", 0 },
149 { 0x454b4d07, 0x00, 0, "AK4545", 0 },
150 { 0x414c4320, 0x0f, 0, "ALC100", 0 },
151 { 0x414c4730, 0x0f, 0, "ALC101", 0 },
152 { 0x414c4710, 0x0f, 0, "ALC200", 0 },
153 { 0x414c4740, 0x0f, 0, "ALC202", 0 },
154 { 0x414c4720, 0x0f, 0, "ALC650", 0 },
155 { 0x414c4752, 0x0f, 0, "ALC250", 0 },
155 { 0x414c4760, 0x0f, 0, "ALC655", 0 },
156 { 0x414c4760, 0x0f, 0, "ALC655", alc655_patch },
156 { 0x414c4770, 0x0f, 0, "ALC203", 0 },
157 { 0x414c4780, 0x0f, 0, "ALC658", 0 },
158 { 0x414c4790, 0x0f, 0, "ALC850", 0 },
159 { 0x43525900, 0x07, 0, "CS4297", 0 },
160 { 0x43525910, 0x07, 0, "CS4297A", 0 },
161 { 0x43525920, 0x07, 0, "CS4294/98", 0 },
162 { 0x4352592d, 0x07, 0, "CS4294", 0 },
163 { 0x43525930, 0x07, 0, "CS4299", 0 },

--- 236 unchanged lines hidden (view full) ---

400}
401
402u_int16_t
403ac97_getcaps(struct ac97_info *codec)
404{
405 return codec->caps;
406}
407
157 { 0x414c4770, 0x0f, 0, "ALC203", 0 },
158 { 0x414c4780, 0x0f, 0, "ALC658", 0 },
159 { 0x414c4790, 0x0f, 0, "ALC850", 0 },
160 { 0x43525900, 0x07, 0, "CS4297", 0 },
161 { 0x43525910, 0x07, 0, "CS4297A", 0 },
162 { 0x43525920, 0x07, 0, "CS4294/98", 0 },
163 { 0x4352592d, 0x07, 0, "CS4294", 0 },
164 { 0x43525930, 0x07, 0, "CS4299", 0 },

--- 236 unchanged lines hidden (view full) ---

401}
402
403u_int16_t
404ac97_getcaps(struct ac97_info *codec)
405{
406 return codec->caps;
407}
408
409u_int32_t
410ac97_getsubvendor(struct ac97_info *codec)
411{
412 return codec->subvendor;
413}
414
408static int
409ac97_setrecsrc(struct ac97_info *codec, int channel)
410{
411 struct ac97mixtable_entry *e = &codec->mix[channel];
412
413 if (e->recidx > 0) {
414 int val = e->recidx - 1;
415 val |= val << 8;

--- 206 unchanged lines hidden (view full) ---

622 id = (ac97_rdcd(codec, AC97_REG_ID1) << 16) | ac97_rdcd(codec, AC97_REG_ID2);
623 if (id == 0 || id == 0xffffffff) {
624 device_printf(codec->dev, "ac97 codec invalid or not present (id == %x)\n", id);
625 snd_mtxunlock(codec->lock);
626 return ENODEV;
627 }
628
629 codec->id = id;
415static int
416ac97_setrecsrc(struct ac97_info *codec, int channel)
417{
418 struct ac97mixtable_entry *e = &codec->mix[channel];
419
420 if (e->recidx > 0) {
421 int val = e->recidx - 1;
422 val |= val << 8;

--- 206 unchanged lines hidden (view full) ---

629 id = (ac97_rdcd(codec, AC97_REG_ID1) << 16) | ac97_rdcd(codec, AC97_REG_ID2);
630 if (id == 0 || id == 0xffffffff) {
631 device_printf(codec->dev, "ac97 codec invalid or not present (id == %x)\n", id);
632 snd_mtxunlock(codec->lock);
633 return ENODEV;
634 }
635
636 codec->id = id;
637 codec->subvendor = (u_int32_t)pci_get_subdevice(codec->dev) << 16;
638 codec->subvendor |= (u_int32_t)pci_get_subvendor(codec->dev) &
639 0x0000ffff;
630 codec->noext = 0;
631 codec_patch = NULL;
632
633 cname = NULL;
634 model = step = 0;
635 for (i = 0; ac97codecid[i].id; i++) {
636 u_int32_t modelmask = 0xffffffff ^ ac97codecid[i].stepmask;
637 if ((ac97codecid[i].id & modelmask) == (id & modelmask)) {

--- 270 unchanged lines hidden (view full) ---

908#endif
909}
910
911static int
912ac97mix_init(struct snd_mixer *m)
913{
914 struct ac97_info *codec = mix_getdevinfo(m);
915 struct snddev_info *d;
640 codec->noext = 0;
641 codec_patch = NULL;
642
643 cname = NULL;
644 model = step = 0;
645 for (i = 0; ac97codecid[i].id; i++) {
646 u_int32_t modelmask = 0xffffffff ^ ac97codecid[i].stepmask;
647 if ((ac97codecid[i].id & modelmask) == (id & modelmask)) {

--- 270 unchanged lines hidden (view full) ---

918#endif
919}
920
921static int
922ac97mix_init(struct snd_mixer *m)
923{
924 struct ac97_info *codec = mix_getdevinfo(m);
925 struct snddev_info *d;
916 u_int32_t subvendor;
917 u_int32_t i, mask;
918
919 if (codec == NULL)
920 return -1;
921
922 if (ac97_initmixer(codec))
923 return -1;
924
925 switch (codec->id) {
926 case 0x41445374: /* AD1981B */
926 u_int32_t i, mask;
927
928 if (codec == NULL)
929 return -1;
930
931 if (ac97_initmixer(codec))
932 return -1;
933
934 switch (codec->id) {
935 case 0x41445374: /* AD1981B */
927 subvendor = (u_int32_t)pci_get_subdevice(codec->dev) << 16;
928 subvendor |= (u_int32_t)pci_get_subvendor(codec->dev) &
929 0x0000ffff;
930 /* IBM Thinkcentre */
931 if (subvendor == 0x02d91014) {
932 /* Enable headphone jack sensing */
933 ac97_wrcd(codec, 0x72, ac97_rdcd(codec, 0x72) |
934 0x0800);
936 if (codec->subvendor == 0x02d91014) {
937 /*
938 * IBM Thinkcentre:
939 * Tie "ogain" and "phone" to "vol" since its
940 * master volume is basically useless and can't
941 * control anything.
942 */
935 mask = 0;
936 if (codec->mix[SOUND_MIXER_OGAIN].enable)
937 mask |= SOUND_MASK_OGAIN;
938 if (codec->mix[SOUND_MIXER_PHONEOUT].enable)
939 mask |= SOUND_MASK_PHONEOUT;
943 mask = 0;
944 if (codec->mix[SOUND_MIXER_OGAIN].enable)
945 mask |= SOUND_MASK_OGAIN;
946 if (codec->mix[SOUND_MIXER_PHONEOUT].enable)
947 mask |= SOUND_MASK_PHONEOUT;
940 /* Tie ogain/phone to master volume */
941 if (codec->mix[SOUND_MIXER_VOLUME].enable)
942 mix_setparentchild(m, SOUND_MIXER_VOLUME,
943 mask);
944 else {
945 mix_setparentchild(m, SOUND_MIXER_VOLUME,
946 mask);
947 mix_setrealdev(m, SOUND_MIXER_VOLUME,
948 SOUND_MIXER_NONE);

--- 109 unchanged lines hidden ---
948 if (codec->mix[SOUND_MIXER_VOLUME].enable)
949 mix_setparentchild(m, SOUND_MIXER_VOLUME,
950 mask);
951 else {
952 mix_setparentchild(m, SOUND_MIXER_VOLUME,
953 mask);
954 mix_setrealdev(m, SOUND_MIXER_VOLUME,
955 SOUND_MIXER_NONE);

--- 109 unchanged lines hidden ---