x86/mm/init: Add helper for freeing kernel image pages
[linux/fpc-iii.git] / include / sound / ac97 / codec.h
blobec04be9ab119281b0b1f8f1dfdb9eedf6132448d
1 /*
2 * Copyright (C) 2016 Robert Jarzmik <robert.jarzmik@free.fr>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8 #ifndef __SOUND_AC97_CODEC2_H
9 #define __SOUND_AC97_CODEC2_H
11 #include <linux/device.h>
13 #define AC97_ID(vendor_id1, vendor_id2) \
14 ((((vendor_id1) & 0xffff) << 16) | ((vendor_id2) & 0xffff))
15 #define AC97_DRIVER_ID(vendor_id1, vendor_id2, mask_id1, mask_id2, _data) \
16 { .id = (((vendor_id1) & 0xffff) << 16) | ((vendor_id2) & 0xffff), \
17 .mask = (((mask_id1) & 0xffff) << 16) | ((mask_id2) & 0xffff), \
18 .data = (_data) }
20 struct ac97_controller;
21 struct clk;
23 /**
24 * struct ac97_id - matches a codec device and driver on an ac97 bus
25 * @id: The significant bits if the codec vendor ID1 and ID2
26 * @mask: Bitmask specifying which bits of the id field are significant when
27 * matching. A driver binds to a device when :
28 * ((vendorID1 << 8 | vendorID2) & (mask_id1 << 8 | mask_id2)) == id.
29 * @data: Private data used by the driver.
31 struct ac97_id {
32 unsigned int id;
33 unsigned int mask;
34 void *data;
37 /**
38 * ac97_codec_device - a ac97 codec
39 * @dev: the core device
40 * @vendor_id: the vendor_id of the codec, as sensed on the AC-link
41 * @num: the codec number, 0 is primary, 1 is first slave, etc ...
42 * @clk: the clock BIT_CLK provided by the codec
43 * @ac97_ctrl: ac97 digital controller on the same AC-link
45 * This is the device instantiated for each codec living on a AC-link. There are
46 * normally 0 to 4 codec devices per AC-link, and all of them are controlled by
47 * an AC97 digital controller.
49 struct ac97_codec_device {
50 struct device dev;
51 unsigned int vendor_id;
52 unsigned int num;
53 struct clk *clk;
54 struct ac97_controller *ac97_ctrl;
57 /**
58 * ac97_codec_driver - a ac97 codec driver
59 * @driver: the device driver structure
60 * @probe: the function called when a ac97_codec_device is matched
61 * @remove: the function called when the device is unbound/removed
62 * @shutdown: shutdown function (might be NULL)
63 * @id_table: ac97 vendor_id match table, { } member terminated
65 struct ac97_codec_driver {
66 struct device_driver driver;
67 int (*probe)(struct ac97_codec_device *);
68 int (*remove)(struct ac97_codec_device *);
69 void (*shutdown)(struct ac97_codec_device *);
70 const struct ac97_id *id_table;
73 static inline struct ac97_codec_device *to_ac97_device(struct device *d)
75 return container_of(d, struct ac97_codec_device, dev);
78 static inline struct ac97_codec_driver *to_ac97_driver(struct device_driver *d)
80 return container_of(d, struct ac97_codec_driver, driver);
83 #if IS_ENABLED(CONFIG_AC97_BUS_NEW)
84 int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv);
85 void snd_ac97_codec_driver_unregister(struct ac97_codec_driver *drv);
86 #else
87 static inline int
88 snd_ac97_codec_driver_register(struct ac97_codec_driver *drv)
90 return 0;
92 static inline void
93 snd_ac97_codec_driver_unregister(struct ac97_codec_driver *drv)
96 #endif
99 static inline struct device *
100 ac97_codec_dev2dev(struct ac97_codec_device *adev)
102 return &adev->dev;
105 static inline void *ac97_get_drvdata(struct ac97_codec_device *adev)
107 return dev_get_drvdata(ac97_codec_dev2dev(adev));
110 static inline void ac97_set_drvdata(struct ac97_codec_device *adev,
111 void *data)
113 dev_set_drvdata(ac97_codec_dev2dev(adev), data);
116 void *snd_ac97_codec_get_platdata(const struct ac97_codec_device *adev);
118 #endif