1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/init.h>
22#include <linux/slab.h>
23#include <linux/pci.h>
24#include <linux/module.h>
25#include <sound/core.h>
26#include "hda_codec.h"
27#include "hda_local.h"
28#include "hda_auto_parser.h"
29#include "hda_jack.h"
30#include "hda_generic.h"
31
32
33static const struct hda_codec_ops ca0110_patch_ops = {
34 .build_controls = snd_hda_gen_build_controls,
35 .build_pcms = snd_hda_gen_build_pcms,
36 .init = snd_hda_gen_init,
37 .free = snd_hda_gen_free,
38 .unsol_event = snd_hda_jack_unsol_event,
39};
40
41static int ca0110_parse_auto_config(struct hda_codec *codec)
42{
43 struct hda_gen_spec *spec = codec->spec;
44 int err;
45
46 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
47 if (err < 0)
48 return err;
49 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
50 if (err < 0)
51 return err;
52
53 return 0;
54}
55
56
57static int patch_ca0110(struct hda_codec *codec)
58{
59 struct hda_gen_spec *spec;
60 int err;
61
62 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
63 if (!spec)
64 return -ENOMEM;
65 snd_hda_gen_spec_init(spec);
66 codec->spec = spec;
67
68 spec->multi_cap_vol = 1;
69 codec->bus->needs_damn_long_delay = 1;
70
71 err = ca0110_parse_auto_config(codec);
72 if (err < 0)
73 goto error;
74
75 codec->patch_ops = ca0110_patch_ops;
76
77 return 0;
78
79 error:
80 snd_hda_gen_free(codec);
81 return err;
82}
83
84
85
86
87
88static const struct hda_codec_preset snd_hda_preset_ca0110[] = {
89 { .id = 0x1102000a, .name = "CA0110-IBG", .patch = patch_ca0110 },
90 { .id = 0x1102000b, .name = "CA0110-IBG", .patch = patch_ca0110 },
91 { .id = 0x1102000d, .name = "SB0880 X-Fi", .patch = patch_ca0110 },
92 {}
93};
94
95MODULE_ALIAS("snd-hda-codec-id:1102000a");
96MODULE_ALIAS("snd-hda-codec-id:1102000b");
97MODULE_ALIAS("snd-hda-codec-id:1102000d");
98
99MODULE_LICENSE("GPL");
100MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
101
102static struct hda_codec_preset_list ca0110_list = {
103 .preset = snd_hda_preset_ca0110,
104 .owner = THIS_MODULE,
105};
106
107static int __init patch_ca0110_init(void)
108{
109 return snd_hda_add_codec_preset(&ca0110_list);
110}
111
112static void __exit patch_ca0110_exit(void)
113{
114 snd_hda_delete_codec_preset(&ca0110_list);
115}
116
117module_init(patch_ca0110_init)
118module_exit(patch_ca0110_exit)
119