Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 1 | /* |
| 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> |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 22 | #include <linux/slab.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 23 | #include <linux/module.h> |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 24 | #include <sound/core.h> |
| 25 | #include "hda_codec.h" |
| 26 | #include "hda_local.h" |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 27 | #include "hda_auto_parser.h" |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 28 | #include "hda_jack.h" |
| 29 | #include "hda_generic.h" |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 30 | |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 31 | |
Takashi Iwai | 728850a | 2011-05-02 11:36:00 +0200 | [diff] [blame] | 32 | static const struct hda_codec_ops ca0110_patch_ops = { |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 33 | .build_controls = snd_hda_gen_build_controls, |
| 34 | .build_pcms = snd_hda_gen_build_pcms, |
| 35 | .init = snd_hda_gen_init, |
| 36 | .free = snd_hda_gen_free, |
Takashi Iwai | 8a6c21a | 2013-01-18 07:51:17 +0100 | [diff] [blame] | 37 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 38 | }; |
| 39 | |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 40 | static int ca0110_parse_auto_config(struct hda_codec *codec) |
| 41 | { |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 42 | struct hda_gen_spec *spec = codec->spec; |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 43 | int err; |
| 44 | |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 45 | err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0); |
| 46 | if (err < 0) |
| 47 | return err; |
| 48 | err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg); |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 49 | if (err < 0) |
| 50 | return err; |
| 51 | |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | |
Takashi Iwai | 1e16895 | 2009-07-01 08:34:32 +0200 | [diff] [blame] | 56 | static int patch_ca0110(struct hda_codec *codec) |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 57 | { |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 58 | struct hda_gen_spec *spec; |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 59 | int err; |
| 60 | |
| 61 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 62 | if (!spec) |
| 63 | return -ENOMEM; |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 64 | snd_hda_gen_spec_init(spec); |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 65 | codec->spec = spec; |
Takashi Iwai | 225068a | 2015-05-29 10:42:14 +0200 | [diff] [blame] | 66 | codec->patch_ops = ca0110_patch_ops; |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 67 | |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 68 | spec->multi_cap_vol = 1; |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 69 | codec->bus->needs_damn_long_delay = 1; |
| 70 | |
| 71 | err = ca0110_parse_auto_config(codec); |
| 72 | if (err < 0) |
| 73 | goto error; |
| 74 | |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 75 | return 0; |
| 76 | |
| 77 | error: |
Takashi Iwai | 8fadf1d | 2012-12-19 18:04:37 +0100 | [diff] [blame] | 78 | snd_hda_gen_free(codec); |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 79 | return err; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | /* |
| 84 | * patch entries |
| 85 | */ |
Takashi Iwai | 728850a | 2011-05-02 11:36:00 +0200 | [diff] [blame] | 86 | static const struct hda_codec_preset snd_hda_preset_ca0110[] = { |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 87 | { .id = 0x1102000a, .name = "CA0110-IBG", .patch = patch_ca0110 }, |
| 88 | { .id = 0x1102000b, .name = "CA0110-IBG", .patch = patch_ca0110 }, |
| 89 | { .id = 0x1102000d, .name = "SB0880 X-Fi", .patch = patch_ca0110 }, |
| 90 | {} /* terminator */ |
| 91 | }; |
| 92 | |
| 93 | MODULE_ALIAS("snd-hda-codec-id:1102000a"); |
| 94 | MODULE_ALIAS("snd-hda-codec-id:1102000b"); |
| 95 | MODULE_ALIAS("snd-hda-codec-id:1102000d"); |
| 96 | |
| 97 | MODULE_LICENSE("GPL"); |
| 98 | MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec"); |
| 99 | |
Takashi Iwai | d8a766a | 2015-02-17 15:25:37 +0100 | [diff] [blame] | 100 | static struct hda_codec_driver ca0110_driver = { |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 101 | .preset = snd_hda_preset_ca0110, |
Takashi Iwai | 4e01f54 | 2009-04-16 08:53:34 +0200 | [diff] [blame] | 102 | }; |
| 103 | |
Takashi Iwai | d8a766a | 2015-02-17 15:25:37 +0100 | [diff] [blame] | 104 | module_hda_codec_driver(ca0110_driver); |