ca0110.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HD audio codec driver for Creative X-Fi CA0110-IBG chip
  4. *
  5. * Copyright (c) 2008 Takashi Iwai <tiwai@suse.de>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/slab.h>
  9. #include <linux/module.h>
  10. #include <sound/core.h>
  11. #include <sound/hda_codec.h>
  12. #include "hda_local.h"
  13. #include "hda_auto_parser.h"
  14. #include "hda_jack.h"
  15. #include "generic.h"
  16. static int ca0110_parse_auto_config(struct hda_codec *codec)
  17. {
  18. struct hda_gen_spec *spec = codec->spec;
  19. int err;
  20. err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
  21. if (err < 0)
  22. return err;
  23. err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
  24. if (err < 0)
  25. return err;
  26. return 0;
  27. }
  28. static int ca0110_probe(struct hda_codec *codec, const struct hda_device_id *id)
  29. {
  30. struct hda_gen_spec *spec;
  31. int err;
  32. spec = kzalloc_obj(*spec);
  33. if (!spec)
  34. return -ENOMEM;
  35. snd_hda_gen_spec_init(spec);
  36. codec->spec = spec;
  37. spec->multi_cap_vol = 1;
  38. codec->bus->core.needs_damn_long_delay = 1;
  39. err = ca0110_parse_auto_config(codec);
  40. if (err < 0)
  41. goto error;
  42. return 0;
  43. error:
  44. snd_hda_gen_remove(codec);
  45. return err;
  46. }
  47. static const struct hda_codec_ops ca0110_codec_ops = {
  48. .probe = ca0110_probe,
  49. .remove = snd_hda_gen_remove,
  50. .build_controls = snd_hda_gen_build_controls,
  51. .build_pcms = snd_hda_gen_build_pcms,
  52. .init = snd_hda_gen_init,
  53. .unsol_event = snd_hda_jack_unsol_event,
  54. };
  55. /*
  56. * driver entries
  57. */
  58. static const struct hda_device_id snd_hda_id_ca0110[] = {
  59. HDA_CODEC_ID(0x1102000a, "CA0110-IBG"),
  60. HDA_CODEC_ID(0x1102000b, "CA0110-IBG"),
  61. HDA_CODEC_ID(0x1102000d, "SB0880 X-Fi"),
  62. {} /* terminator */
  63. };
  64. MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0110);
  65. MODULE_LICENSE("GPL");
  66. MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
  67. static struct hda_codec_driver ca0110_driver = {
  68. .id = snd_hda_id_ca0110,
  69. .ops = &ca0110_codec_ops,
  70. };
  71. module_hda_codec_driver(ca0110_driver);