patch_ca0110.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/module.h>
  23. #include <sound/core.h>
  24. #include "hda_codec.h"
  25. #include "hda_local.h"
  26. #include "hda_auto_parser.h"
  27. #include "hda_jack.h"
  28. #include "hda_generic.h"
  29. static const struct hda_codec_ops ca0110_patch_ops = {
  30. .build_controls = snd_hda_gen_build_controls,
  31. .build_pcms = snd_hda_gen_build_pcms,
  32. .init = snd_hda_gen_init,
  33. .free = snd_hda_gen_free,
  34. .unsol_event = snd_hda_jack_unsol_event,
  35. };
  36. static int ca0110_parse_auto_config(struct hda_codec *codec)
  37. {
  38. struct hda_gen_spec *spec = codec->spec;
  39. int err;
  40. err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
  41. if (err < 0)
  42. return err;
  43. err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
  44. if (err < 0)
  45. return err;
  46. return 0;
  47. }
  48. static int patch_ca0110(struct hda_codec *codec)
  49. {
  50. struct hda_gen_spec *spec;
  51. int err;
  52. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  53. if (!spec)
  54. return -ENOMEM;
  55. snd_hda_gen_spec_init(spec);
  56. codec->spec = spec;
  57. codec->patch_ops = ca0110_patch_ops;
  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. return 0;
  64. error:
  65. snd_hda_gen_free(codec);
  66. return err;
  67. }
  68. /*
  69. * patch entries
  70. */
  71. static const struct hda_device_id snd_hda_id_ca0110[] = {
  72. HDA_CODEC_ENTRY(0x1102000a, "CA0110-IBG", patch_ca0110),
  73. HDA_CODEC_ENTRY(0x1102000b, "CA0110-IBG", patch_ca0110),
  74. HDA_CODEC_ENTRY(0x1102000d, "SB0880 X-Fi", patch_ca0110),
  75. {} /* terminator */
  76. };
  77. MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0110);
  78. MODULE_LICENSE("GPL");
  79. MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
  80. static struct hda_codec_driver ca0110_driver = {
  81. .id = snd_hda_id_ca0110,
  82. };
  83. module_hda_codec_driver(ca0110_driver);