23 #include <linux/slab.h>
24 #include <linux/pci.h>
25 #include <linux/module.h>
61 static int ca0110_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
63 unsigned int stream_tag,
69 stream_tag, format, substream);
72 static int ca0110_playback_pcm_cleanup(
struct hda_pcm_stream *hinfo,
83 static int ca0110_dig_playback_pcm_open(
struct hda_pcm_stream *hinfo,
91 static int ca0110_dig_playback_pcm_close(
struct hda_pcm_stream *hinfo,
99 static int ca0110_dig_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
101 unsigned int stream_tag,
113 static int ca0110_capture_pcm_prepare(
struct hda_pcm_stream *hinfo,
115 unsigned int stream_tag,
122 stream_tag, 0, format);
126 static int ca0110_capture_pcm_cleanup(
struct hda_pcm_stream *hinfo,
139 static const char *
const dirstr[2] = {
"Playback",
"Capture" };
148 sprintf(namestr,
"%s %s Switch", pfx, dirstr[dir]);
159 sprintf(namestr,
"%s %s Volume", pfx, dirstr[dir]);
163 #define add_out_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 0)
164 #define add_out_volume(codec, nid, pfx) _add_volume(codec, nid, pfx, 3, 0)
165 #define add_in_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 1)
166 #define add_in_volume(codec, nid, pfx) _add_volume(codec, nid, pfx, 3, 1)
167 #define add_mono_switch(codec, nid, pfx, chan) \
168 _add_switch(codec, nid, pfx, chan, 0)
169 #define add_mono_volume(codec, nid, pfx, chan) \
170 _add_volume(codec, nid, pfx, chan, 0)
172 static int ca0110_build_controls(
struct hda_codec *codec)
177 "Front",
"Surround",
NULL,
"Side",
"Multi"
182 for (i = 0; i < spec->
multiout.num_dacs; i++) {
235 mutenid = spec->
adcs[
i];
270 .open = ca0110_playback_pcm_open,
271 .prepare = ca0110_playback_pcm_prepare,
272 .cleanup = ca0110_playback_pcm_cleanup
281 .prepare = ca0110_capture_pcm_prepare,
282 .cleanup = ca0110_capture_pcm_cleanup
286 static const struct hda_pcm_stream ca0110_pcm_digital_playback = {
291 .open = ca0110_dig_playback_pcm_open,
292 .close = ca0110_dig_playback_pcm_close,
293 .prepare = ca0110_dig_playback_pcm_prepare
303 static int ca0110_build_pcms(
struct hda_codec *codec)
311 info->
name =
"CA0110 Analog";
325 info->
name =
"CA0110 Digital";
329 ca0110_pcm_digital_playback;
334 ca0110_pcm_digital_capture;
345 snd_hda_set_pin_ctl(codec, pin,
PIN_HP);
359 snd_hda_set_pin_ctl(codec, pin,
PIN_IN |
371 static int ca0110_init(
struct hda_codec *codec)
377 for (i = 0; i < spec->
multiout.num_dacs; i++)
378 init_output(codec, spec->
out_pins[i],
389 static void ca0110_free(
struct hda_codec *codec)
395 .build_controls = ca0110_build_controls,
396 .build_pcms = ca0110_build_pcms,
402 static void parse_line_outs(
struct hda_codec *codec)
407 unsigned int def_conf;
422 spec->
multiout.max_channels = n * 2;
425 static void parse_hp_out(
struct hda_codec *codec)
430 unsigned int def_conf;
445 if (dac == spec->
dacs[i])
453 static void parse_input(
struct hda_codec *codec)
462 for (i = 0; i < codec->
num_nodes; i++, nid++) {
463 unsigned int wcaps = get_wcaps(codec, nid);
464 unsigned int type = get_wcaps_type(wcaps);
474 if (cfg->
inputs[j].pin == pin)
488 static void parse_digital(
struct hda_codec *codec)
499 static int ca0110_parse_auto_config(
struct hda_codec *codec)
508 parse_line_outs(codec);
510 parse_digital(codec);
516 static int patch_ca0110(
struct hda_codec *codec)
526 codec->
bus->needs_damn_long_delay = 1;
528 err = ca0110_parse_auto_config(codec);
547 { .id = 0x1102000a, .name =
"CA0110-IBG", .patch = patch_ca0110 },
548 { .id = 0x1102000b, .name =
"CA0110-IBG", .patch = patch_ca0110 },
549 { .id = 0x1102000d, .name =
"SB0880 X-Fi", .patch = patch_ca0110 },
561 .preset = snd_hda_preset_ca0110,
565 static int __init patch_ca0110_init(
void)
570 static void __exit patch_ca0110_exit(
void)