Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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