| 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 | #ifdef TARGET_OS2
|
|---|
| 18 | #define KBUILD_MODNAME "patch_ca0110"
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | static const struct hda_codec_ops ca0110_patch_ops = {
|
|---|
| 22 | .build_controls = snd_hda_gen_build_controls,
|
|---|
| 23 | .build_pcms = snd_hda_gen_build_pcms,
|
|---|
| 24 | .init = snd_hda_gen_init,
|
|---|
| 25 | .free = snd_hda_gen_free,
|
|---|
| 26 | .unsol_event = snd_hda_jack_unsol_event,
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | static int ca0110_parse_auto_config(struct hda_codec *codec)
|
|---|
| 30 | {
|
|---|
| 31 | struct hda_gen_spec *spec = codec->spec;
|
|---|
| 32 | int err;
|
|---|
| 33 |
|
|---|
| 34 | err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
|
|---|
| 35 | if (err < 0)
|
|---|
| 36 | return err;
|
|---|
| 37 | err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
|
|---|
| 38 | if (err < 0)
|
|---|
| 39 | return err;
|
|---|
| 40 |
|
|---|
| 41 | return 0;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | static int patch_ca0110(struct hda_codec *codec)
|
|---|
| 46 | {
|
|---|
| 47 | struct hda_gen_spec *spec;
|
|---|
| 48 | int err;
|
|---|
| 49 |
|
|---|
| 50 | spec = kzalloc(sizeof(*spec), GFP_KERNEL);
|
|---|
| 51 | if (!spec)
|
|---|
| 52 | return -ENOMEM;
|
|---|
| 53 | snd_hda_gen_spec_init(spec);
|
|---|
| 54 | codec->spec = spec;
|
|---|
| 55 | codec->patch_ops = ca0110_patch_ops;
|
|---|
| 56 |
|
|---|
| 57 | spec->multi_cap_vol = 1;
|
|---|
| 58 | codec->bus->core.needs_damn_long_delay = 1;
|
|---|
| 59 |
|
|---|
| 60 | err = ca0110_parse_auto_config(codec);
|
|---|
| 61 | if (err < 0)
|
|---|
| 62 | goto error;
|
|---|
| 63 |
|
|---|
| 64 | return 0;
|
|---|
| 65 |
|
|---|
| 66 | error:
|
|---|
| 67 | snd_hda_gen_free(codec);
|
|---|
| 68 | return err;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | /*
|
|---|
| 73 | * patch entries
|
|---|
| 74 | */
|
|---|
| 75 | static const struct hda_device_id snd_hda_id_ca0110[] = {
|
|---|
| 76 | HDA_CODEC_ENTRY(0x1102000a, "CA0110-IBG", patch_ca0110),
|
|---|
| 77 | HDA_CODEC_ENTRY(0x1102000b, "CA0110-IBG", patch_ca0110),
|
|---|
| 78 | HDA_CODEC_ENTRY(0x1102000d, "SB0880 X-Fi", patch_ca0110),
|
|---|
| 79 | {0} /* terminator */
|
|---|
| 80 | };
|
|---|
| 81 | MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0110);
|
|---|
| 82 |
|
|---|
| 83 | MODULE_LICENSE("GPL");
|
|---|
| 84 | MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
|
|---|
| 85 |
|
|---|
| 86 | static struct hda_codec_driver ca0110_driver = {
|
|---|
| 87 | .id = snd_hda_id_ca0110,
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | module_hda_codec_driver(ca0110_driver);
|
|---|