Loading...
1/*
2 * Apple Onboard Audio definitions
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPL v2, can be found in COPYING.
7 */
8
9#ifndef __AOA_H
10#define __AOA_H
11#include <asm/prom.h>
12#include <linux/module.h>
13#include <sound/core.h>
14#include <sound/asound.h>
15#include <sound/control.h>
16#include "aoa-gpio.h"
17#include "soundbus/soundbus.h"
18
19#define MAX_CODEC_NAME_LEN 32
20
21struct aoa_codec {
22 char name[MAX_CODEC_NAME_LEN];
23
24 struct module *owner;
25
26 /* called when the fabric wants to init this codec.
27 * Do alsa card manipulations from here. */
28 int (*init)(struct aoa_codec *codec);
29
30 /* called when the fabric is done with the codec.
31 * The alsa card will be cleaned up so don't bother. */
32 void (*exit)(struct aoa_codec *codec);
33
34 /* May be NULL, but can be used by the fabric.
35 * Refcounting is the codec driver's responsibility */
36 struct device_node *node;
37
38 /* assigned by fabric before init() is called, points
39 * to the soundbus device. Cannot be NULL. */
40 struct soundbus_dev *soundbus_dev;
41
42 /* assigned by the fabric before init() is called, points
43 * to the fabric's gpio runtime record for the relevant
44 * device. */
45 struct gpio_runtime *gpio;
46
47 /* assigned by the fabric before init() is called, contains
48 * a codec specific bitmask of what outputs and inputs are
49 * actually connected */
50 u32 connected;
51
52 /* data the fabric can associate with this structure */
53 void *fabric_data;
54
55 /* private! */
56 struct list_head list;
57 struct aoa_fabric *fabric;
58};
59
60/* return 0 on success */
61extern int
62aoa_codec_register(struct aoa_codec *codec);
63extern void
64aoa_codec_unregister(struct aoa_codec *codec);
65
66#define MAX_LAYOUT_NAME_LEN 32
67
68struct aoa_fabric {
69 char name[MAX_LAYOUT_NAME_LEN];
70
71 struct module *owner;
72
73 /* once codecs register, they are passed here after.
74 * They are of course not initialised, since the
75 * fabric is responsible for initialising some fields
76 * in the codec structure! */
77 int (*found_codec)(struct aoa_codec *codec);
78 /* called for each codec when it is removed,
79 * also in the case that aoa_fabric_unregister
80 * is called and all codecs are removed
81 * from this fabric.
82 * Also called if found_codec returned 0 but
83 * the codec couldn't initialise. */
84 void (*remove_codec)(struct aoa_codec *codec);
85 /* If found_codec returned 0, and the codec
86 * could be initialised, this is called. */
87 void (*attached_codec)(struct aoa_codec *codec);
88};
89
90/* return 0 on success, -EEXIST if another fabric is
91 * registered, -EALREADY if the same fabric is registered.
92 * Passing NULL can be used to test for the presence
93 * of another fabric, if -EALREADY is returned there is
94 * no other fabric present.
95 * In the case that the function returns -EALREADY
96 * and the fabric passed is not NULL, all codecs
97 * that are not assigned yet are passed to the fabric
98 * again for reconsideration. */
99extern int
100aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);
101
102/* it is vital to call this when the fabric exits!
103 * When calling, the remove_codec will be called
104 * for all codecs, unless it is NULL. */
105extern void
106aoa_fabric_unregister(struct aoa_fabric *fabric);
107
108/* if for some reason you want to get rid of a codec
109 * before the fabric is removed, use this.
110 * Note that remove_codec is called for it! */
111extern void
112aoa_fabric_unlink_codec(struct aoa_codec *codec);
113
114/* alsa help methods */
115struct aoa_card {
116 struct snd_card *alsa_card;
117};
118
119extern int aoa_snd_device_new(enum snd_device_type type,
120 void * device_data, struct snd_device_ops * ops);
121extern struct snd_card *aoa_get_card(void);
122extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
123
124/* GPIO stuff */
125extern struct gpio_methods *pmf_gpio_methods;
126extern struct gpio_methods *ftr_gpio_methods;
127/* extern struct gpio_methods *map_gpio_methods; */
128
129#endif /* __AOA_H */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Apple Onboard Audio definitions
4 *
5 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
6 */
7
8#ifndef __AOA_H
9#define __AOA_H
10#include <asm/prom.h>
11#include <linux/module.h>
12#include <sound/core.h>
13#include <sound/asound.h>
14#include <sound/control.h>
15#include "aoa-gpio.h"
16#include "soundbus/soundbus.h"
17
18#define MAX_CODEC_NAME_LEN 32
19
20struct aoa_codec {
21 char name[MAX_CODEC_NAME_LEN];
22
23 struct module *owner;
24
25 /* called when the fabric wants to init this codec.
26 * Do alsa card manipulations from here. */
27 int (*init)(struct aoa_codec *codec);
28
29 /* called when the fabric is done with the codec.
30 * The alsa card will be cleaned up so don't bother. */
31 void (*exit)(struct aoa_codec *codec);
32
33 /* May be NULL, but can be used by the fabric.
34 * Refcounting is the codec driver's responsibility */
35 struct device_node *node;
36
37 /* assigned by fabric before init() is called, points
38 * to the soundbus device. Cannot be NULL. */
39 struct soundbus_dev *soundbus_dev;
40
41 /* assigned by the fabric before init() is called, points
42 * to the fabric's gpio runtime record for the relevant
43 * device. */
44 struct gpio_runtime *gpio;
45
46 /* assigned by the fabric before init() is called, contains
47 * a codec specific bitmask of what outputs and inputs are
48 * actually connected */
49 u32 connected;
50
51 /* data the fabric can associate with this structure */
52 void *fabric_data;
53
54 /* private! */
55 struct list_head list;
56 struct aoa_fabric *fabric;
57};
58
59/* return 0 on success */
60extern int
61aoa_codec_register(struct aoa_codec *codec);
62extern void
63aoa_codec_unregister(struct aoa_codec *codec);
64
65#define MAX_LAYOUT_NAME_LEN 32
66
67struct aoa_fabric {
68 char name[MAX_LAYOUT_NAME_LEN];
69
70 struct module *owner;
71
72 /* once codecs register, they are passed here after.
73 * They are of course not initialised, since the
74 * fabric is responsible for initialising some fields
75 * in the codec structure! */
76 int (*found_codec)(struct aoa_codec *codec);
77 /* called for each codec when it is removed,
78 * also in the case that aoa_fabric_unregister
79 * is called and all codecs are removed
80 * from this fabric.
81 * Also called if found_codec returned 0 but
82 * the codec couldn't initialise. */
83 void (*remove_codec)(struct aoa_codec *codec);
84 /* If found_codec returned 0, and the codec
85 * could be initialised, this is called. */
86 void (*attached_codec)(struct aoa_codec *codec);
87};
88
89/* return 0 on success, -EEXIST if another fabric is
90 * registered, -EALREADY if the same fabric is registered.
91 * Passing NULL can be used to test for the presence
92 * of another fabric, if -EALREADY is returned there is
93 * no other fabric present.
94 * In the case that the function returns -EALREADY
95 * and the fabric passed is not NULL, all codecs
96 * that are not assigned yet are passed to the fabric
97 * again for reconsideration. */
98extern int
99aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);
100
101/* it is vital to call this when the fabric exits!
102 * When calling, the remove_codec will be called
103 * for all codecs, unless it is NULL. */
104extern void
105aoa_fabric_unregister(struct aoa_fabric *fabric);
106
107/* if for some reason you want to get rid of a codec
108 * before the fabric is removed, use this.
109 * Note that remove_codec is called for it! */
110extern void
111aoa_fabric_unlink_codec(struct aoa_codec *codec);
112
113/* alsa help methods */
114struct aoa_card {
115 struct snd_card *alsa_card;
116};
117
118extern int aoa_snd_device_new(enum snd_device_type type,
119 void *device_data, const struct snd_device_ops *ops);
120extern struct snd_card *aoa_get_card(void);
121extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
122
123/* GPIO stuff */
124extern struct gpio_methods *pmf_gpio_methods;
125extern struct gpio_methods *ftr_gpio_methods;
126/* extern struct gpio_methods *map_gpio_methods; */
127
128#endif /* __AOA_H */