| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | #ifndef __SOUND_CORE_H |
|---|
| 2 | 3 | #define __SOUND_CORE_H |
|---|
| 3 | 4 | |
|---|
| 4 | 5 | /* |
|---|
| 5 | 6 | * Main header file for the ALSA driver |
|---|
| 6 | 7 | * Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz> |
|---|
| 7 | | - * |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 22 | | - * |
|---|
| 23 | 8 | */ |
|---|
| 24 | 9 | |
|---|
| 25 | 10 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 29 | 14 | #include <linux/pm.h> /* pm_message_t */ |
|---|
| 30 | 15 | #include <linux/stringify.h> |
|---|
| 31 | 16 | #include <linux/printk.h> |
|---|
| 17 | +#include <linux/android_kabi.h> |
|---|
| 32 | 18 | |
|---|
| 33 | 19 | /* number of supported soundcards */ |
|---|
| 34 | 20 | #ifdef CONFIG_SND_DYNAMIC_MINORS |
|---|
| .. | .. |
|---|
| 76 | 62 | int (*dev_free)(struct snd_device *dev); |
|---|
| 77 | 63 | int (*dev_register)(struct snd_device *dev); |
|---|
| 78 | 64 | int (*dev_disconnect)(struct snd_device *dev); |
|---|
| 65 | + |
|---|
| 66 | + ANDROID_KABI_RESERVE(1); |
|---|
| 79 | 67 | }; |
|---|
| 80 | 68 | |
|---|
| 81 | 69 | struct snd_device { |
|---|
| .. | .. |
|---|
| 84 | 72 | enum snd_device_state state; /* state of the device */ |
|---|
| 85 | 73 | enum snd_device_type type; /* device type */ |
|---|
| 86 | 74 | void *device_data; /* device structure */ |
|---|
| 87 | | - struct snd_device_ops *ops; /* operations */ |
|---|
| 75 | + const struct snd_device_ops *ops; /* operations */ |
|---|
| 76 | + |
|---|
| 77 | + ANDROID_KABI_RESERVE(1); |
|---|
| 88 | 78 | }; |
|---|
| 89 | 79 | |
|---|
| 90 | 80 | #define snd_device(n) list_entry(n, struct snd_device, list) |
|---|
| .. | .. |
|---|
| 120 | 110 | struct list_head ctl_files; /* active control files */ |
|---|
| 121 | 111 | |
|---|
| 122 | 112 | struct snd_info_entry *proc_root; /* root for soundcard specific files */ |
|---|
| 123 | | - struct snd_info_entry *proc_id; /* the card id */ |
|---|
| 124 | 113 | struct proc_dir_entry *proc_root_link; /* number link to real id */ |
|---|
| 125 | 114 | |
|---|
| 126 | 115 | struct list_head files_list; /* all files associated to this card */ |
|---|
| .. | .. |
|---|
| 133 | 122 | struct device card_dev; /* cardX object for sysfs */ |
|---|
| 134 | 123 | const struct attribute_group *dev_groups[4]; /* assigned sysfs attr */ |
|---|
| 135 | 124 | bool registered; /* card_dev is registered? */ |
|---|
| 125 | + int sync_irq; /* assigned irq, used for PCM sync */ |
|---|
| 136 | 126 | wait_queue_head_t remove_sleep; |
|---|
| 137 | | - int offline; /* if this sound card is offline */ |
|---|
| 138 | | - unsigned long offline_change; |
|---|
| 139 | | - wait_queue_head_t offline_poll_wait; |
|---|
| 127 | + |
|---|
| 128 | + size_t total_pcm_alloc_bytes; /* total amount of allocated buffers */ |
|---|
| 129 | + struct mutex memory_mutex; /* protection for the above */ |
|---|
| 140 | 130 | |
|---|
| 141 | 131 | #ifdef CONFIG_PM |
|---|
| 142 | 132 | unsigned int power_state; /* power state */ |
|---|
| .. | .. |
|---|
| 147 | 137 | struct snd_mixer_oss *mixer_oss; |
|---|
| 148 | 138 | int mixer_oss_change_count; |
|---|
| 149 | 139 | #endif |
|---|
| 140 | + |
|---|
| 141 | + ANDROID_KABI_RESERVE(1); |
|---|
| 142 | + ANDROID_KABI_RESERVE(2); |
|---|
| 150 | 143 | }; |
|---|
| 151 | 144 | |
|---|
| 152 | 145 | #define dev_to_snd_card(p) container_of(p, struct snd_card, card_dev) |
|---|
| .. | .. |
|---|
| 182 | 175 | void *private_data; /* private data for f_ops->open */ |
|---|
| 183 | 176 | struct device *dev; /* device for sysfs */ |
|---|
| 184 | 177 | struct snd_card *card_ptr; /* assigned card instance */ |
|---|
| 178 | + |
|---|
| 179 | + ANDROID_KABI_RESERVE(1); |
|---|
| 185 | 180 | }; |
|---|
| 186 | 181 | |
|---|
| 187 | 182 | /* return a device pointer linked to each sound device as a parent */ |
|---|
| .. | .. |
|---|
| 230 | 225 | |
|---|
| 231 | 226 | /* init.c */ |
|---|
| 232 | 227 | |
|---|
| 233 | | -extern struct snd_card *snd_cards[SNDRV_CARDS]; |
|---|
| 234 | 228 | int snd_card_locked(int card); |
|---|
| 235 | 229 | #if IS_ENABLED(CONFIG_SND_MIXER_OSS) |
|---|
| 236 | 230 | #define SND_MIXER_OSS_NOTIFY_REGISTER 0 |
|---|
| .. | .. |
|---|
| 255 | 249 | int snd_component_add(struct snd_card *card, const char *component); |
|---|
| 256 | 250 | int snd_card_file_add(struct snd_card *card, struct file *file); |
|---|
| 257 | 251 | int snd_card_file_remove(struct snd_card *card, struct file *file); |
|---|
| 258 | | -#define snd_card_unref(card) put_device(&(card)->card_dev) |
|---|
| 259 | | -void snd_card_change_online_state(struct snd_card *card, int online); |
|---|
| 252 | + |
|---|
| 253 | +struct snd_card *snd_card_ref(int card); |
|---|
| 254 | + |
|---|
| 255 | +/** |
|---|
| 256 | + * snd_card_unref - Unreference the card object |
|---|
| 257 | + * @card: the card object to unreference |
|---|
| 258 | + * |
|---|
| 259 | + * Call this function for the card object that was obtained via snd_card_ref() |
|---|
| 260 | + * or snd_lookup_minor_data(). |
|---|
| 261 | + */ |
|---|
| 262 | +static inline void snd_card_unref(struct snd_card *card) |
|---|
| 263 | +{ |
|---|
| 264 | + put_device(&card->card_dev); |
|---|
| 265 | +} |
|---|
| 260 | 266 | |
|---|
| 261 | 267 | #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) |
|---|
| 262 | 268 | |
|---|
| 263 | 269 | /* device.c */ |
|---|
| 264 | 270 | |
|---|
| 265 | 271 | int snd_device_new(struct snd_card *card, enum snd_device_type type, |
|---|
| 266 | | - void *device_data, struct snd_device_ops *ops); |
|---|
| 272 | + void *device_data, const struct snd_device_ops *ops); |
|---|
| 267 | 273 | int snd_device_register(struct snd_card *card, void *device_data); |
|---|
| 268 | 274 | int snd_device_register_all(struct snd_card *card); |
|---|
| 269 | 275 | void snd_device_disconnect(struct snd_card *card, void *device_data); |
|---|
| 270 | 276 | void snd_device_disconnect_all(struct snd_card *card); |
|---|
| 271 | 277 | void snd_device_free(struct snd_card *card, void *device_data); |
|---|
| 272 | 278 | void snd_device_free_all(struct snd_card *card); |
|---|
| 279 | +int snd_device_get_state(struct snd_card *card, void *device_data); |
|---|
| 273 | 280 | |
|---|
| 274 | 281 | /* isadma.c */ |
|---|
| 275 | 282 | |
|---|
| .. | .. |
|---|
| 335 | 342 | #define snd_BUG() WARN(1, "BUG?\n") |
|---|
| 336 | 343 | |
|---|
| 337 | 344 | /** |
|---|
| 338 | | - * Suppress high rates of output when CONFIG_SND_DEBUG is enabled. |
|---|
| 345 | + * snd_printd_ratelimit - Suppress high rates of output when |
|---|
| 346 | + * CONFIG_SND_DEBUG is enabled. |
|---|
| 339 | 347 | */ |
|---|
| 340 | 348 | #define snd_printd_ratelimit() printk_ratelimit() |
|---|
| 341 | 349 | |
|---|
| .. | .. |
|---|
| 448 | 456 | } |
|---|
| 449 | 457 | #endif |
|---|
| 450 | 458 | |
|---|
| 459 | +/* async signal helpers */ |
|---|
| 460 | +struct snd_fasync; |
|---|
| 461 | + |
|---|
| 462 | +int snd_fasync_helper(int fd, struct file *file, int on, |
|---|
| 463 | + struct snd_fasync **fasyncp); |
|---|
| 464 | +void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll); |
|---|
| 465 | +void snd_fasync_free(struct snd_fasync *fasync); |
|---|
| 466 | + |
|---|
| 451 | 467 | #endif /* __SOUND_CORE_H */ |
|---|