/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Apple Onboard Audio definitions3*4* Copyright 2006 Johannes Berg <[email protected]>5*/67#ifndef __AOA_H8#define __AOA_H9#include <linux/module.h>10#include <sound/core.h>11#include <sound/asound.h>12#include <sound/control.h>13#include "aoa-gpio.h"14#include "soundbus/soundbus.h"1516#define MAX_CODEC_NAME_LEN 321718struct aoa_codec {19char name[MAX_CODEC_NAME_LEN];2021struct module *owner;2223/* called when the fabric wants to init this codec.24* Do alsa card manipulations from here. */25int (*init)(struct aoa_codec *codec);2627/* called when the fabric is done with the codec.28* The alsa card will be cleaned up so don't bother. */29void (*exit)(struct aoa_codec *codec);3031/* May be NULL, but can be used by the fabric.32* Refcounting is the codec driver's responsibility */33struct device_node *node;3435/* assigned by fabric before init() is called, points36* to the soundbus device. Cannot be NULL. */37struct soundbus_dev *soundbus_dev;3839/* assigned by the fabric before init() is called, points40* to the fabric's gpio runtime record for the relevant41* device. */42struct gpio_runtime *gpio;4344/* assigned by the fabric before init() is called, contains45* a codec specific bitmask of what outputs and inputs are46* actually connected */47u32 connected;4849/* data the fabric can associate with this structure */50void *fabric_data;5152/* private! */53struct list_head list;54struct aoa_fabric *fabric;55};5657/* return 0 on success */58extern int59aoa_codec_register(struct aoa_codec *codec);60extern void61aoa_codec_unregister(struct aoa_codec *codec);6263#define MAX_LAYOUT_NAME_LEN 326465struct aoa_fabric {66char name[MAX_LAYOUT_NAME_LEN];6768struct module *owner;6970/* once codecs register, they are passed here after.71* They are of course not initialised, since the72* fabric is responsible for initialising some fields73* in the codec structure! */74int (*found_codec)(struct aoa_codec *codec);75/* called for each codec when it is removed,76* also in the case that aoa_fabric_unregister77* is called and all codecs are removed78* from this fabric.79* Also called if found_codec returned 0 but80* the codec couldn't initialise. */81void (*remove_codec)(struct aoa_codec *codec);82/* If found_codec returned 0, and the codec83* could be initialised, this is called. */84void (*attached_codec)(struct aoa_codec *codec);85};8687/* return 0 on success, -EEXIST if another fabric is88* registered, -EALREADY if the same fabric is registered.89* Passing NULL can be used to test for the presence90* of another fabric, if -EALREADY is returned there is91* no other fabric present.92* In the case that the function returns -EALREADY93* and the fabric passed is not NULL, all codecs94* that are not assigned yet are passed to the fabric95* again for reconsideration. */96extern int97aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);9899/* it is vital to call this when the fabric exits!100* When calling, the remove_codec will be called101* for all codecs, unless it is NULL. */102extern void103aoa_fabric_unregister(struct aoa_fabric *fabric);104105/* if for some reason you want to get rid of a codec106* before the fabric is removed, use this.107* Note that remove_codec is called for it! */108extern void109aoa_fabric_unlink_codec(struct aoa_codec *codec);110111/* alsa help methods */112struct aoa_card {113struct snd_card *alsa_card;114};115116extern int aoa_snd_device_new(enum snd_device_type type,117void *device_data, const struct snd_device_ops *ops);118extern struct snd_card *aoa_get_card(void);119extern int aoa_snd_ctl_add(struct snd_kcontrol* control);120121/* GPIO stuff */122extern struct gpio_methods *pmf_gpio_methods;123extern struct gpio_methods *ftr_gpio_methods;124/* extern struct gpio_methods *map_gpio_methods; */125126#endif /* __AOA_H */127128129