xref: /linux/sound/hda/codecs/ca0110.c (revision 177bf8620cf4ed290ee170a6c5966adc0924b336)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * HD audio codec driver for Creative X-Fi CA0110-IBG chip
4  *
5  * Copyright (c) 2008 Takashi Iwai <tiwai@suse.de>
6  */
7 
8 #include <linux/init.h>
9 #include <linux/slab.h>
10 #include <linux/module.h>
11 #include <sound/core.h>
12 #include <sound/hda_codec.h>
13 #include "hda_local.h"
14 #include "hda_auto_parser.h"
15 #include "hda_jack.h"
16 #include "generic.h"
17 
ca0110_parse_auto_config(struct hda_codec * codec)18 static int ca0110_parse_auto_config(struct hda_codec *codec)
19 {
20 	struct hda_gen_spec *spec = codec->spec;
21 	int err;
22 
23 	err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
24 	if (err < 0)
25 		return err;
26 	err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
27 	if (err < 0)
28 		return err;
29 
30 	return 0;
31 }
32 
ca0110_probe(struct hda_codec * codec,const struct hda_device_id * id)33 static int ca0110_probe(struct hda_codec *codec, const struct hda_device_id *id)
34 {
35 	struct hda_gen_spec *spec;
36 	int err;
37 
38 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
39 	if (!spec)
40 		return -ENOMEM;
41 	snd_hda_gen_spec_init(spec);
42 	codec->spec = spec;
43 
44 	spec->multi_cap_vol = 1;
45 	codec->bus->core.needs_damn_long_delay = 1;
46 
47 	err = ca0110_parse_auto_config(codec);
48 	if (err < 0)
49 		goto error;
50 
51 	return 0;
52 
53  error:
54 	snd_hda_gen_remove(codec);
55 	return err;
56 }
57 
58 
59 static const struct hda_codec_ops ca0110_codec_ops = {
60 	.probe = ca0110_probe,
61 	.remove = snd_hda_gen_remove,
62 	.build_controls = snd_hda_gen_build_controls,
63 	.build_pcms = snd_hda_gen_build_pcms,
64 	.init = snd_hda_gen_init,
65 	.unsol_event = snd_hda_jack_unsol_event,
66 };
67 
68 /*
69  * driver entries
70  */
71 static const struct hda_device_id snd_hda_id_ca0110[] = {
72 	HDA_CODEC_ID(0x1102000a, "CA0110-IBG"),
73 	HDA_CODEC_ID(0x1102000b, "CA0110-IBG"),
74 	HDA_CODEC_ID(0x1102000d, "SB0880 X-Fi"),
75 	{} /* terminator */
76 };
77 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0110);
78 
79 MODULE_LICENSE("GPL");
80 MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
81 
82 static struct hda_codec_driver ca0110_driver = {
83 	.id = snd_hda_id_ca0110,
84 	.ops = &ca0110_codec_ops,
85 };
86 
87 module_hda_codec_driver(ca0110_driver);
88