0001
0002
0003
0004
0005
0006 #ifndef __SOUND_AC97_CODEC2_H
0007 #define __SOUND_AC97_CODEC2_H
0008
0009 #include <linux/device.h>
0010
0011 #define AC97_ID(vendor_id1, vendor_id2) \
0012 ((((vendor_id1) & 0xffff) << 16) | ((vendor_id2) & 0xffff))
0013 #define AC97_DRIVER_ID(vendor_id1, vendor_id2, mask_id1, mask_id2, _data) \
0014 { .id = (((vendor_id1) & 0xffff) << 16) | ((vendor_id2) & 0xffff), \
0015 .mask = (((mask_id1) & 0xffff) << 16) | ((mask_id2) & 0xffff), \
0016 .data = (_data) }
0017
0018 struct ac97_controller;
0019 struct clk;
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 struct ac97_id {
0030 unsigned int id;
0031 unsigned int mask;
0032 void *data;
0033 };
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 struct ac97_codec_device {
0048 struct device dev;
0049 unsigned int vendor_id;
0050 unsigned int num;
0051 struct clk *clk;
0052 struct ac97_controller *ac97_ctrl;
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct ac97_codec_driver {
0064 struct device_driver driver;
0065 int (*probe)(struct ac97_codec_device *);
0066 int (*remove)(struct ac97_codec_device *);
0067 void (*shutdown)(struct ac97_codec_device *);
0068 const struct ac97_id *id_table;
0069 };
0070
0071 static inline struct ac97_codec_device *to_ac97_device(struct device *d)
0072 {
0073 return container_of(d, struct ac97_codec_device, dev);
0074 }
0075
0076 static inline struct ac97_codec_driver *to_ac97_driver(struct device_driver *d)
0077 {
0078 return container_of(d, struct ac97_codec_driver, driver);
0079 }
0080
0081 #if IS_ENABLED(CONFIG_AC97_BUS_NEW)
0082 int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv);
0083 void snd_ac97_codec_driver_unregister(struct ac97_codec_driver *drv);
0084 #else
0085 static inline int
0086 snd_ac97_codec_driver_register(struct ac97_codec_driver *drv)
0087 {
0088 return 0;
0089 }
0090 static inline void
0091 snd_ac97_codec_driver_unregister(struct ac97_codec_driver *drv)
0092 {
0093 }
0094 #endif
0095
0096
0097 static inline struct device *
0098 ac97_codec_dev2dev(struct ac97_codec_device *adev)
0099 {
0100 return &adev->dev;
0101 }
0102
0103 static inline void *ac97_get_drvdata(struct ac97_codec_device *adev)
0104 {
0105 return dev_get_drvdata(ac97_codec_dev2dev(adev));
0106 }
0107
0108 static inline void ac97_set_drvdata(struct ac97_codec_device *adev,
0109 void *data)
0110 {
0111 dev_set_drvdata(ac97_codec_dev2dev(adev), data);
0112 }
0113
0114 void *snd_ac97_codec_get_platdata(const struct ac97_codec_device *adev);
0115
0116 #endif