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