Linux Audio

Check our new training course

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