Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * HD audio interface patch for Creative X-Fi CA0110-IBG chip
0004  *
0005  * Copyright (c) 2008 Takashi Iwai <tiwai@suse.de>
0006  */
0007 
0008 #include <linux/init.h>
0009 #include <linux/slab.h>
0010 #include <linux/module.h>
0011 #include <sound/core.h>
0012 #include <sound/hda_codec.h>
0013 #include "hda_local.h"
0014 #include "hda_auto_parser.h"
0015 #include "hda_jack.h"
0016 #include "hda_generic.h"
0017 
0018 
0019 static const struct hda_codec_ops ca0110_patch_ops = {
0020     .build_controls = snd_hda_gen_build_controls,
0021     .build_pcms = snd_hda_gen_build_pcms,
0022     .init = snd_hda_gen_init,
0023     .free = snd_hda_gen_free,
0024     .unsol_event = snd_hda_jack_unsol_event,
0025 };
0026 
0027 static int ca0110_parse_auto_config(struct hda_codec *codec)
0028 {
0029     struct hda_gen_spec *spec = codec->spec;
0030     int err;
0031 
0032     err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
0033     if (err < 0)
0034         return err;
0035     err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
0036     if (err < 0)
0037         return err;
0038 
0039     return 0;
0040 }
0041 
0042 
0043 static int patch_ca0110(struct hda_codec *codec)
0044 {
0045     struct hda_gen_spec *spec;
0046     int err;
0047 
0048     spec = kzalloc(sizeof(*spec), GFP_KERNEL);
0049     if (!spec)
0050         return -ENOMEM;
0051     snd_hda_gen_spec_init(spec);
0052     codec->spec = spec;
0053     codec->patch_ops = ca0110_patch_ops;
0054 
0055     spec->multi_cap_vol = 1;
0056     codec->bus->core.needs_damn_long_delay = 1;
0057 
0058     err = ca0110_parse_auto_config(codec);
0059     if (err < 0)
0060         goto error;
0061 
0062     return 0;
0063 
0064  error:
0065     snd_hda_gen_free(codec);
0066     return err;
0067 }
0068 
0069 
0070 /*
0071  * patch entries
0072  */
0073 static const struct hda_device_id snd_hda_id_ca0110[] = {
0074     HDA_CODEC_ENTRY(0x1102000a, "CA0110-IBG", patch_ca0110),
0075     HDA_CODEC_ENTRY(0x1102000b, "CA0110-IBG", patch_ca0110),
0076     HDA_CODEC_ENTRY(0x1102000d, "SB0880 X-Fi", patch_ca0110),
0077     {} /* terminator */
0078 };
0079 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0110);
0080 
0081 MODULE_LICENSE("GPL");
0082 MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
0083 
0084 static struct hda_codec_driver ca0110_driver = {
0085     .id = snd_hda_id_ca0110,
0086 };
0087 
0088 module_hda_codec_driver(ca0110_driver);