blob: db7635cd8255a46744fcc9f0a7c8591317088fcd [file] [log] [blame]
Takashi Iwai4e01f542009-04-16 08:53:34 +02001/*
2 * HD audio interface patch for Creative X-Fi CA0110-IBG chip
3 *
4 * Copyright (c) 2008 Takashi Iwai <tiwai@suse.de>
5 *
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This driver is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/slab.h>
24#include <linux/pci.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040025#include <linux/module.h>
Takashi Iwai4e01f542009-04-16 08:53:34 +020026#include <sound/core.h>
27#include "hda_codec.h"
28#include "hda_local.h"
Takashi Iwai128bc4b2012-05-07 17:42:31 +020029#include "hda_auto_parser.h"
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010030#include "hda_jack.h"
31#include "hda_generic.h"
Takashi Iwai4e01f542009-04-16 08:53:34 +020032
Takashi Iwai4e01f542009-04-16 08:53:34 +020033
Takashi Iwai728850a2011-05-02 11:36:00 +020034static const struct hda_codec_ops ca0110_patch_ops = {
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010035 .build_controls = snd_hda_gen_build_controls,
36 .build_pcms = snd_hda_gen_build_pcms,
37 .init = snd_hda_gen_init,
38 .free = snd_hda_gen_free,
Takashi Iwai8a6c21a2013-01-18 07:51:17 +010039 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai4e01f542009-04-16 08:53:34 +020040};
41
Takashi Iwai4e01f542009-04-16 08:53:34 +020042static int ca0110_parse_auto_config(struct hda_codec *codec)
43{
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010044 struct hda_gen_spec *spec = codec->spec;
Takashi Iwai4e01f542009-04-16 08:53:34 +020045 int err;
46
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010047 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
48 if (err < 0)
49 return err;
50 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
Takashi Iwai4e01f542009-04-16 08:53:34 +020051 if (err < 0)
52 return err;
53
Takashi Iwai4e01f542009-04-16 08:53:34 +020054 return 0;
55}
56
57
Takashi Iwai1e168952009-07-01 08:34:32 +020058static int patch_ca0110(struct hda_codec *codec)
Takashi Iwai4e01f542009-04-16 08:53:34 +020059{
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010060 struct hda_gen_spec *spec;
Takashi Iwai4e01f542009-04-16 08:53:34 +020061 int err;
62
63 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
64 if (!spec)
65 return -ENOMEM;
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010066 snd_hda_gen_spec_init(spec);
Takashi Iwai4e01f542009-04-16 08:53:34 +020067 codec->spec = spec;
68
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010069 spec->multi_cap_vol = 1;
Takashi Iwai4e01f542009-04-16 08:53:34 +020070 codec->bus->needs_damn_long_delay = 1;
71
72 err = ca0110_parse_auto_config(codec);
73 if (err < 0)
74 goto error;
75
76 codec->patch_ops = ca0110_patch_ops;
77
78 return 0;
79
80 error:
Takashi Iwai8fadf1d2012-12-19 18:04:37 +010081 snd_hda_gen_free(codec);
Takashi Iwai4e01f542009-04-16 08:53:34 +020082 return err;
83}
84
85
86/*
87 * patch entries
88 */
Takashi Iwai728850a2011-05-02 11:36:00 +020089static const struct hda_codec_preset snd_hda_preset_ca0110[] = {
Takashi Iwai4e01f542009-04-16 08:53:34 +020090 { .id = 0x1102000a, .name = "CA0110-IBG", .patch = patch_ca0110 },
91 { .id = 0x1102000b, .name = "CA0110-IBG", .patch = patch_ca0110 },
92 { .id = 0x1102000d, .name = "SB0880 X-Fi", .patch = patch_ca0110 },
93 {} /* terminator */
94};
95
96MODULE_ALIAS("snd-hda-codec-id:1102000a");
97MODULE_ALIAS("snd-hda-codec-id:1102000b");
98MODULE_ALIAS("snd-hda-codec-id:1102000d");
99
100MODULE_LICENSE("GPL");
101MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
102
103static struct hda_codec_preset_list ca0110_list = {
104 .preset = snd_hda_preset_ca0110,
105 .owner = THIS_MODULE,
106};
107
108static int __init patch_ca0110_init(void)
109{
110 return snd_hda_add_codec_preset(&ca0110_list);
111}
112
113static void __exit patch_ca0110_exit(void)
114{
115 snd_hda_delete_codec_preset(&ca0110_list);
116}
117
118module_init(patch_ca0110_init)
119module_exit(patch_ca0110_exit)