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