Remove all inclusions of <linux/config.h>
[pandora-kernel.git] / sound / oss / ac97_plugin_ad1980.c
1 /*
2     ac97_plugin_ad1980.c  Copyright (C) 2003 Red Hat, Inc. All rights reserved.
3
4    The contents of this file are subject to the Open Software License version 1.1
5    that can be found at http://www.opensource.org/licenses/osl-1.1.txt and is 
6    included herein by reference. 
7    
8    Alternatively, the contents of this file may be used under the
9    terms of the GNU General Public License version 2 (the "GPL") as 
10    distributed in the kernel source COPYING file, in which
11    case the provisions of the GPL are applicable instead of the
12    above.  If you wish to allow the use of your version of this file
13    only under the terms of the GPL and not to allow others to use
14    your version of this file under the OSL, indicate your decision
15    by deleting the provisions above and replace them with the notice
16    and other provisions required by the GPL.  If you do not delete
17    the provisions above, a recipient may use your version of this
18    file under either the OSL or the GPL.
19    
20    Authors:     Alan Cox <alan@redhat.com>
21
22    This is an example codec plugin. This one switches the connections
23    around to match the setups some vendors use with audio switched to
24    non standard front connectors not the normal rear ones
25
26    This code primarily exists to demonstrate how to use the codec
27    interface
28
29 */
30
31 #include <linux/module.h>
32 #include <linux/init.h>
33 #include <linux/kernel.h>
34 #include <linux/ac97_codec.h>
35
36 /**
37  *      ad1980_remove           -       codec remove callback
38  *      @codec: The codec that is being removed
39  *
40  *      This callback occurs when an AC97 codec is being removed. A
41  *      codec remove call will not occur for a codec during that codec
42  *      probe callback.
43  *
44  *      Most drivers will need to lock their remove versus their 
45  *      use of the codec after the probe function.
46  */
47  
48 static void __devexit ad1980_remove(struct ac97_codec *codec, struct ac97_driver *driver)
49 {
50         /* Nothing to do in the simple example */
51 }
52
53
54 /**
55  *      ad1980_probe            -       codec found callback
56  *      @codec: ac97 codec matching the idents
57  *      @driver: ac97_driver it matched
58  *
59  *      This entry point is called when a codec is found which matches
60  *      the driver. At the point it is called the codec is basically
61  *      operational, mixer operations have been initialised and can
62  *      be overriden. Called in process context. The field driver_private
63  *      is available for the driver to use to store stuff.
64  *
65  *      The caller can claim the device by returning zero, or return
66  *      a negative error code. 
67  */
68  
69 static int ad1980_probe(struct ac97_codec *codec, struct ac97_driver *driver)
70 {
71         u16 control;
72
73 #define AC97_AD_MISC    0x76
74
75         /* Switch the inputs/outputs over (from Dell code) */
76         control = codec->codec_read(codec, AC97_AD_MISC);
77         codec->codec_write(codec, AC97_AD_MISC, control | 0x4420);
78         
79         /* We could refuse the device since we dont need to hang around,
80            but we will claim it */
81         return 0;
82 }
83         
84  
85 static struct ac97_driver ad1980_driver = {
86         .codec_id       = 0x41445370,
87         .codec_mask     = 0xFFFFFFFF,
88         .name           = "AD1980 example",
89         .probe          = ad1980_probe,
90         .remove         = __devexit_p(ad1980_remove),
91 };
92
93 /**
94  *      ad1980_exit             -       module exit path
95  *
96  *      Our module is being unloaded. At this point unregister_driver
97  *      will call back our remove handler for any existing codecs. You
98  *      may not unregister_driver from interrupt context or from a 
99  *      probe/remove callback.
100  */
101
102 static void ad1980_exit(void)
103 {
104         ac97_unregister_driver(&ad1980_driver);
105 }
106
107 /**
108  *      ad1980_init             -       set up ad1980 handlers
109  *
110  *      After we call the register function it will call our probe
111  *      function for each existing matching device before returning to us.
112  *      Any devices appearing afterwards whose id's match the codec_id
113  *      will also cause the probe function to be called.
114  *      You may not register_driver from interrupt context or from a 
115  *      probe/remove callback.
116  */
117  
118 static int ad1980_init(void)
119 {
120         return ac97_register_driver(&ad1980_driver);
121 }
122
123 module_init(ad1980_init);
124 module_exit(ad1980_exit);
125 MODULE_LICENSE("GPL");