18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef __SOUND_INITVAL_H
38c2ecf20Sopenharmony_ci#define __SOUND_INITVAL_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci *  Init values for soundcard modules
78c2ecf20Sopenharmony_ci *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define SNDRV_AUTO_PORT		1
118c2ecf20Sopenharmony_ci#define SNDRV_AUTO_IRQ		0xffff
128c2ecf20Sopenharmony_ci#define SNDRV_AUTO_DMA		0xffff
138c2ecf20Sopenharmony_ci#define SNDRV_AUTO_DMA_SIZE	(0x7fffffff)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_IDX1	(-1)
168c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_STR1	NULL
178c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_ENABLE1	1
188c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_PORT1	SNDRV_AUTO_PORT
198c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_IRQ1	SNDRV_AUTO_IRQ
208c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_DMA1	SNDRV_AUTO_DMA
218c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_DMA_SIZE1	SNDRV_AUTO_DMA_SIZE
228c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_PTR1	SNDRV_DEFAULT_STR1
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_IDX	{ [0 ... (SNDRV_CARDS-1)] = -1 }
258c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_STR	{ [0 ... (SNDRV_CARDS-1)] = NULL }
268c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_ENABLE	{ 1, [1 ... (SNDRV_CARDS-1)] = 0 }
278c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_ENABLE_PNP { [0 ... (SNDRV_CARDS-1)] = 1 }
288c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
298c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
308c2ecf20Sopenharmony_ci#else
318c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
328c2ecf20Sopenharmony_ci#endif
338c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_PORT	{ [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_PORT }
348c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_IRQ	{ [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
358c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_DMA	{ [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
368c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_DMA_SIZE	{ [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE }
378c2ecf20Sopenharmony_ci#define SNDRV_DEFAULT_PTR	SNDRV_DEFAULT_STR
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
408c2ecf20Sopenharmony_cistatic long snd_legacy_find_free_ioport(const long *port_table, long size)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	while (*port_table != -1) {
438c2ecf20Sopenharmony_ci		if (request_region(*port_table, size, "ALSA test")) {
448c2ecf20Sopenharmony_ci			release_region(*port_table, size);
458c2ecf20Sopenharmony_ci			return *port_table;
468c2ecf20Sopenharmony_ci		}
478c2ecf20Sopenharmony_ci		port_table++;
488c2ecf20Sopenharmony_ci	}
498c2ecf20Sopenharmony_ci	return -1;
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci#endif
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#ifdef SNDRV_LEGACY_FIND_FREE_IRQ
548c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic int snd_legacy_find_free_irq(const int *irq_table)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	while (*irq_table != -1) {
648c2ecf20Sopenharmony_ci		if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
658c2ecf20Sopenharmony_ci				 IRQF_PROBE_SHARED, "ALSA Test IRQ",
668c2ecf20Sopenharmony_ci				 (void *) irq_table)) {
678c2ecf20Sopenharmony_ci			free_irq(*irq_table, (void *) irq_table);
688c2ecf20Sopenharmony_ci			return *irq_table;
698c2ecf20Sopenharmony_ci		}
708c2ecf20Sopenharmony_ci		irq_table++;
718c2ecf20Sopenharmony_ci	}
728c2ecf20Sopenharmony_ci	return -1;
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci#endif
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#ifdef SNDRV_LEGACY_FIND_FREE_DMA
778c2ecf20Sopenharmony_cistatic int snd_legacy_find_free_dma(const int *dma_table)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	while (*dma_table != -1) {
808c2ecf20Sopenharmony_ci		if (!request_dma(*dma_table, "ALSA Test DMA")) {
818c2ecf20Sopenharmony_ci			free_dma(*dma_table);
828c2ecf20Sopenharmony_ci			return *dma_table;
838c2ecf20Sopenharmony_ci		}
848c2ecf20Sopenharmony_ci		dma_table++;
858c2ecf20Sopenharmony_ci	}
868c2ecf20Sopenharmony_ci	return -1;
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci#endif
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#endif /* __SOUND_INITVAL_H */
91