/*1* Apple Onboard Audio definitions2*3* Copyright 2006 Johannes Berg <[email protected]>4*5* GPL v2, can be found in COPYING.6*/78#ifndef __AOA_H9#define __AOA_H10#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"1718#define MAX_CODEC_NAME_LEN 321920struct aoa_codec {21char name[MAX_CODEC_NAME_LEN];2223struct module *owner;2425/* called when the fabric wants to init this codec.26* Do alsa card manipulations from here. */27int (*init)(struct aoa_codec *codec);2829/* called when the fabric is done with the codec.30* The alsa card will be cleaned up so don't bother. */31void (*exit)(struct aoa_codec *codec);3233/* May be NULL, but can be used by the fabric.34* Refcounting is the codec driver's responsibility */35struct device_node *node;3637/* assigned by fabric before init() is called, points38* to the soundbus device. Cannot be NULL. */39struct soundbus_dev *soundbus_dev;4041/* assigned by the fabric before init() is called, points42* to the fabric's gpio runtime record for the relevant43* device. */44struct gpio_runtime *gpio;4546/* assigned by the fabric before init() is called, contains47* a codec specific bitmask of what outputs and inputs are48* actually connected */49u32 connected;5051/* data the fabric can associate with this structure */52void *fabric_data;5354/* private! */55struct list_head list;56struct aoa_fabric *fabric;57};5859/* return 0 on success */60extern int61aoa_codec_register(struct aoa_codec *codec);62extern void63aoa_codec_unregister(struct aoa_codec *codec);6465#define MAX_LAYOUT_NAME_LEN 326667struct aoa_fabric {68char name[MAX_LAYOUT_NAME_LEN];6970struct module *owner;7172/* once codecs register, they are passed here after.73* They are of course not initialised, since the74* fabric is responsible for initialising some fields75* in the codec structure! */76int (*found_codec)(struct aoa_codec *codec);77/* called for each codec when it is removed,78* also in the case that aoa_fabric_unregister79* is called and all codecs are removed80* from this fabric.81* Also called if found_codec returned 0 but82* the codec couldn't initialise. */83void (*remove_codec)(struct aoa_codec *codec);84/* If found_codec returned 0, and the codec85* could be initialised, this is called. */86void (*attached_codec)(struct aoa_codec *codec);87};8889/* return 0 on success, -EEXIST if another fabric is90* registered, -EALREADY if the same fabric is registered.91* Passing NULL can be used to test for the presence92* of another fabric, if -EALREADY is returned there is93* no other fabric present.94* In the case that the function returns -EALREADY95* and the fabric passed is not NULL, all codecs96* that are not assigned yet are passed to the fabric97* again for reconsideration. */98extern int99aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);100101/* it is vital to call this when the fabric exits!102* When calling, the remove_codec will be called103* for all codecs, unless it is NULL. */104extern void105aoa_fabric_unregister(struct aoa_fabric *fabric);106107/* if for some reason you want to get rid of a codec108* before the fabric is removed, use this.109* Note that remove_codec is called for it! */110extern void111aoa_fabric_unlink_codec(struct aoa_codec *codec);112113/* alsa help methods */114struct aoa_card {115struct snd_card *alsa_card;116};117118extern int aoa_snd_device_new(snd_device_type_t type,119void * device_data, struct snd_device_ops * ops);120extern struct snd_card *aoa_get_card(void);121extern int aoa_snd_ctl_add(struct snd_kcontrol* control);122123/* GPIO stuff */124extern struct gpio_methods *pmf_gpio_methods;125extern struct gpio_methods *ftr_gpio_methods;126/* extern struct gpio_methods *map_gpio_methods; */127128#endif /* __AOA_H */129130131