Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0
0002  *
0003  * Copyright (C) 2016 Robert Jarzmik <robert.jarzmik@free.fr>
0004  */
0005 
0006 #ifndef AC97_CONTROLLER_H
0007 #define AC97_CONTROLLER_H
0008 
0009 #include <linux/device.h>
0010 #include <linux/list.h>
0011 
0012 #define AC97_BUS_MAX_CODECS 4
0013 #define AC97_SLOTS_AVAILABLE_ALL 0xf
0014 
0015 struct ac97_controller_ops;
0016 
0017 /**
0018  * struct ac97_controller - The AC97 controller of the AC-Link
0019  * @ops:        the AC97 operations.
0020  * @controllers:    linked list of all existing controllers.
0021  * @adap:       the shell device ac97-%d, ie. ac97 adapter
0022  * @nr:         the number of the shell device
0023  * @slots_available:    the mask of accessible/scanable codecs.
0024  * @parent:     the device providing the AC97 controller.
0025  * @codecs:     the 4 possible AC97 codecs (NULL if none found).
0026  * @codecs_pdata:   platform_data for each codec (NULL if no pdata).
0027  *
0028  * This structure is internal to AC97 bus, and should not be used by the
0029  * controllers themselves, excepting for using @dev.
0030  */
0031 struct ac97_controller {
0032     const struct ac97_controller_ops *ops;
0033     struct list_head controllers;
0034     struct device adap;
0035     int nr;
0036     unsigned short slots_available;
0037     struct device *parent;
0038     struct ac97_codec_device *codecs[AC97_BUS_MAX_CODECS];
0039     void *codecs_pdata[AC97_BUS_MAX_CODECS];
0040 };
0041 
0042 /**
0043  * struct ac97_controller_ops - The AC97 operations
0044  * @reset:  Cold reset of the AC97 AC-Link.
0045  * @warm_reset: Warm reset of the AC97 AC-Link.
0046  * @read:   Read of a single AC97 register.
0047  *      Returns the register value or a negative error code.
0048  * @write:  Write of a single AC97 register.
0049  *
0050  * These are the basic operation an AC97 controller must provide for an AC97
0051  * access functions. Amongst these, all but the last 2 are mandatory.
0052  * The slot number is also known as the AC97 codec number, between 0 and 3.
0053  */
0054 struct ac97_controller_ops {
0055     void (*reset)(struct ac97_controller *adrv);
0056     void (*warm_reset)(struct ac97_controller *adrv);
0057     int (*write)(struct ac97_controller *adrv, int slot,
0058              unsigned short reg, unsigned short val);
0059     int (*read)(struct ac97_controller *adrv, int slot, unsigned short reg);
0060 };
0061 
0062 #if IS_ENABLED(CONFIG_AC97_BUS_NEW)
0063 struct ac97_controller *snd_ac97_controller_register(
0064     const struct ac97_controller_ops *ops, struct device *dev,
0065     unsigned short slots_available, void **codecs_pdata);
0066 void snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl);
0067 #else
0068 static inline struct ac97_controller *
0069 snd_ac97_controller_register(const struct ac97_controller_ops *ops,
0070                  struct device *dev,
0071                  unsigned short slots_available,
0072                  void **codecs_pdata)
0073 {
0074     return ERR_PTR(-ENODEV);
0075 }
0076 
0077 static inline void
0078 snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl)
0079 {
0080 }
0081 #endif
0082 
0083 #endif