patch_ca0110.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #include <linux/init.h>
  21. #include <linux/slab.h>
  22. #include <linux/pci.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. static const struct hda_codec_ops ca0110_patch_ops = {
  31. .build_controls = snd_hda_gen_build_controls,
  32. .build_pcms = snd_hda_gen_build_pcms,
  33. .init = snd_hda_gen_init,
  34. .free = snd_hda_gen_free,
  35. .unsol_event = snd_hda_jack_unsol_event,
  36. };
  37. static int ca0110_parse_auto_config(struct hda_codec *codec)
  38. {
  39. struct hda_gen_spec *spec = codec->spec;
  40. int err;
  41. err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
  42. if (err < 0)
  43. return err;
  44. err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
  45. if (err < 0)
  46. return err;
  47. return 0;
  48. }
  49. static int patch_ca0110(struct hda_codec *codec)
  50. {
  51. struct hda_gen_spec *spec;
  52. int err;
  53. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  54. if (!spec)
  55. return -ENOMEM;
  56. snd_hda_gen_spec_init(spec);
  57. codec->spec = spec;
  58. spec->multi_cap_vol = 1;
  59. codec->bus->needs_damn_long_delay = 1;
  60. err = ca0110_parse_auto_config(codec);
  61. if (err < 0)
  62. goto error;
  63. codec->patch_ops = ca0110_patch_ops;
  64. return 0;
  65. error:
  66. snd_hda_gen_free(codec);
  67. return err;
  68. }
  69. /*
  70. * patch entries
  71. */
  72. static const struct hda_codec_preset snd_hda_preset_ca0110[] = {
  73. { .id = 0x1102000a, .name = "CA0110-IBG", .patch = patch_ca0110 },
  74. { .id = 0x1102000b, .name = "CA0110-IBG", .patch = patch_ca0110 },
  75. { .id = 0x1102000d, .name = "SB0880 X-Fi", .patch = patch_ca0110 },
  76. {} /* terminator */
  77. };
  78. MODULE_ALIAS("snd-hda-codec-id:1102000a");
  79. MODULE_ALIAS("snd-hda-codec-id:1102000b");
  80. MODULE_ALIAS("snd-hda-codec-id:1102000d");
  81. MODULE_LICENSE("GPL");
  82. MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
  83. static struct hda_codec_preset_list ca0110_list = {
  84. .preset = snd_hda_preset_ca0110,
  85. .owner = THIS_MODULE,
  86. };
  87. static int __init patch_ca0110_init(void)
  88. {
  89. return snd_hda_add_codec_preset(&ca0110_list);
  90. }
  91. static void __exit patch_ca0110_exit(void)
  92. {
  93. snd_hda_delete_codec_preset(&ca0110_list);
  94. }
  95. module_init(patch_ca0110_init)
  96. module_exit(patch_ca0110_exit)