HID: picolcd: sanity check report size in raw_event() callback
[firefly-linux-kernel-4.4.55.git] / sound / pci / hda / patch_cmedia.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for C-Media CMI9880
5  *
6  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
7  *
8  *
9  *  This driver is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This driver is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  */
23
24 #include <linux/init.h>
25 #include <linux/slab.h>
26 #include <linux/module.h>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
30 #include "hda_auto_parser.h"
31 #include "hda_jack.h"
32 #include "hda_generic.h"
33
34 struct cmi_spec {
35         struct hda_gen_spec gen;
36 };
37
38 /*
39  * stuff for auto-parser
40  */
41 static const struct hda_codec_ops cmi_auto_patch_ops = {
42         .build_controls = snd_hda_gen_build_controls,
43         .build_pcms = snd_hda_gen_build_pcms,
44         .init = snd_hda_gen_init,
45         .free = snd_hda_gen_free,
46         .unsol_event = snd_hda_jack_unsol_event,
47 };
48
49 static int patch_cmi9880(struct hda_codec *codec)
50 {
51         struct cmi_spec *spec;
52         struct auto_pin_cfg *cfg;
53         int err;
54
55         spec = kzalloc(sizeof(*spec), GFP_KERNEL);
56         if (spec == NULL)
57                 return -ENOMEM;
58
59         codec->spec = spec;
60         cfg = &spec->gen.autocfg;
61         snd_hda_gen_spec_init(&spec->gen);
62
63         err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
64         if (err < 0)
65                 goto error;
66         err = snd_hda_gen_parse_auto_config(codec, cfg);
67         if (err < 0)
68                 goto error;
69
70         codec->patch_ops = cmi_auto_patch_ops;
71         return 0;
72
73  error:
74         snd_hda_gen_free(codec);
75         return err;
76 }
77
78 /*
79  * patch entries
80  */
81 static const struct hda_codec_preset snd_hda_preset_cmedia[] = {
82         { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 },
83         { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 },
84         {} /* terminator */
85 };
86
87 MODULE_ALIAS("snd-hda-codec-id:13f69880");
88 MODULE_ALIAS("snd-hda-codec-id:434d4980");
89
90 MODULE_LICENSE("GPL");
91 MODULE_DESCRIPTION("C-Media HD-audio codec");
92
93 static struct hda_codec_preset_list cmedia_list = {
94         .preset = snd_hda_preset_cmedia,
95         .owner = THIS_MODULE,
96 };
97
98 static int __init patch_cmedia_init(void)
99 {
100         return snd_hda_add_codec_preset(&cmedia_list);
101 }
102
103 static void __exit patch_cmedia_exit(void)
104 {
105         snd_hda_delete_codec_preset(&cmedia_list);
106 }
107
108 module_init(patch_cmedia_init)
109 module_exit(patch_cmedia_exit)