27 #include <linux/slab.h>
28 #include <linux/module.h>
34 #define SI3054_VERB_READ_NODE 0x900
35 #define SI3054_VERB_WRITE_NODE 0x100
38 #define SI3054_EXTENDED_MID 2
39 #define SI3054_LINE_RATE 3
40 #define SI3054_LINE_LEVEL 4
41 #define SI3054_GPIO_CFG 5
42 #define SI3054_GPIO_POLARITY 6
43 #define SI3054_GPIO_STICKY 7
44 #define SI3054_GPIO_WAKEUP 8
45 #define SI3054_GPIO_STATUS 9
46 #define SI3054_GPIO_CONTROL 10
47 #define SI3054_MISC_AFE 11
48 #define SI3054_CHIPID 12
49 #define SI3054_LINE_CFG1 13
50 #define SI3054_LINE_STATUS 14
51 #define SI3054_DC_TERMINATION 15
52 #define SI3054_LINE_CONFIG 16
53 #define SI3054_CALLPROG_ATT 17
54 #define SI3054_SQ_CONTROL 18
55 #define SI3054_MISC_CONTROL 19
56 #define SI3054_RING_CTRL1 20
57 #define SI3054_RING_CTRL2 21
60 #define SI3054_MEI_READY 0xf
63 #define SI3054_ATAG_MASK 0x00f0
64 #define SI3054_DTAG_MASK 0xf000
67 #define SI3054_GPIO_OH 0x0001
68 #define SI3054_GPIO_CID 0x0002
71 #define SI3054_CHIPID_CODEC_REV_MASK 0x000f
72 #define SI3054_CHIPID_DAA_REV_MASK 0x00f0
73 #define SI3054_CHIPID_INTERNATIONAL 0x0100
74 #define SI3054_CHIPID_DAA_ID 0x0f00
75 #define SI3054_CHIPID_CODEC_ID (1<<12)
78 #define GET_REG(codec,reg) (snd_hda_codec_read(codec,reg,0,SI3054_VERB_READ_NODE,0))
79 #define SET_REG(codec,reg,val) (snd_hda_codec_write(codec,reg,0,SI3054_VERB_WRITE_NODE,val))
80 #define SET_REG_CACHE(codec,reg,val) \
81 snd_hda_codec_write_cache(codec,reg,0,SI3054_VERB_WRITE_NODE,val)
94 #define PRIVATE_VALUE(reg,mask) ((reg<<16)|(mask&0xffff))
95 #define PRIVATE_REG(val) ((val>>16)&0xffff)
96 #define PRIVATE_MASK(val) (val&0xffff)
98 #define si3054_switch_info snd_ctl_boolean_mono_info
100 static int si3054_switch_get(
struct snd_kcontrol *kcontrol,
106 uvalue->
value.integer.value[0] = (
GET_REG(codec, reg)) & mask ? 1 : 0 ;
110 static int si3054_switch_put(
struct snd_kcontrol *kcontrol,
116 if (uvalue->
value.integer.value[0])
123 #define SI3054_KCONTROL(kname,reg,mask) { \
124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
126 .subdevice = HDA_SUBDEV_NID_FLAG | reg, \
127 .info = si3054_switch_info, \
128 .get = si3054_switch_get, \
129 .put = si3054_switch_put, \
130 .private_value = PRIVATE_VALUE(reg,mask), \
140 static int si3054_build_controls(
struct hda_codec *codec)
152 unsigned int stream_tag,
165 stream_tag, 0, format);
173 static unsigned int rates[] = { 8000, 9600, 16000 };
179 substream->
runtime->hw.period_bytes_min = 80;
194 .open = si3054_pcm_open,
195 .prepare = si3054_pcm_prepare,
200 static int si3054_build_pcms(
struct hda_codec *codec)
206 info->
name =
"Si3054 Modem";
220 static int si3054_init(
struct hda_codec *codec)
238 if((val&SI3054_MEI_READY) != SI3054_MEI_READY) {
250 snd_printd(
"Link Frame Detect(FDT) is not ready (line status: %04x)\n",
259 static void si3054_free(
struct hda_codec *codec)
269 .build_controls = si3054_build_controls,
270 .build_pcms = si3054_build_pcms,
275 static int patch_si3054(
struct hda_codec *codec)
289 { .id = 0x163c3055, .name =
"Si3054", .patch = patch_si3054 },
290 { .id = 0x163c3155, .name =
"Si3054", .patch = patch_si3054 },
291 { .id = 0x11c13026, .name =
"Si3054", .patch = patch_si3054 },
292 { .id = 0x11c13055, .name =
"Si3054", .patch = patch_si3054 },
293 { .id = 0x11c13155, .name =
"Si3054", .patch = patch_si3054 },
294 { .id = 0x10573055, .name =
"Si3054", .patch = patch_si3054 },
295 { .id = 0x10573057, .name =
"Si3054", .patch = patch_si3054 },
296 { .id = 0x10573155, .name =
"Si3054", .patch = patch_si3054 },
298 { .id = 0x11063288, .name =
"Si3054", .patch = patch_si3054 },
300 { .id = 0x15433155, .name =
"Si3054", .patch = patch_si3054 },
302 { .id = 0x18540018, .name =
"Si3054", .patch = patch_si3054 },
322 .preset = snd_hda_preset_si3054,
326 static int __init patch_si3054_init(
void)
331 static void __exit patch_si3054_exit(
void)