blob: a1ff3b4865b4de9783240696809ef6242768d205 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __SOUND_INITVAL_H
3#define __SOUND_INITVAL_H
4
5/*
6 * Init values for soundcard modules
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02007 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
10#define SNDRV_AUTO_PORT 1
11#define SNDRV_AUTO_IRQ 0xffff
12#define SNDRV_AUTO_DMA 0xffff
13#define SNDRV_AUTO_DMA_SIZE (0x7fffffff)
14
15#define SNDRV_DEFAULT_IDX1 (-1)
16#define SNDRV_DEFAULT_STR1 NULL
17#define SNDRV_DEFAULT_ENABLE1 1
18#define SNDRV_DEFAULT_PORT1 SNDRV_AUTO_PORT
19#define SNDRV_DEFAULT_IRQ1 SNDRV_AUTO_IRQ
20#define SNDRV_DEFAULT_DMA1 SNDRV_AUTO_DMA
21#define SNDRV_DEFAULT_DMA_SIZE1 SNDRV_AUTO_DMA_SIZE
22#define SNDRV_DEFAULT_PTR1 SNDRV_DEFAULT_STR1
23
24#define SNDRV_DEFAULT_IDX { [0 ... (SNDRV_CARDS-1)] = -1 }
25#define SNDRV_DEFAULT_STR { [0 ... (SNDRV_CARDS-1)] = NULL }
26#define SNDRV_DEFAULT_ENABLE { 1, [1 ... (SNDRV_CARDS-1)] = 0 }
27#define SNDRV_DEFAULT_ENABLE_PNP { [0 ... (SNDRV_CARDS-1)] = 1 }
28#ifdef CONFIG_PNP
29#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
30#else
31#define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
32#endif
33#define SNDRV_DEFAULT_PORT { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_PORT }
34#define SNDRV_DEFAULT_IRQ { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
35#define SNDRV_DEFAULT_DMA { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
36#define SNDRV_DEFAULT_DMA_SIZE { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE }
37#define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR
38
Ondrej Zary988aec32012-08-01 16:05:39 +020039#ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
Takashi Iwaif5f87ab2020-01-05 15:47:16 +010040static long snd_legacy_find_free_ioport(const long *port_table, long size)
Ondrej Zary988aec32012-08-01 16:05:39 +020041{
42 while (*port_table != -1) {
43 if (request_region(*port_table, size, "ALSA test")) {
44 release_region(*port_table, size);
45 return *port_table;
46 }
47 port_table++;
48 }
49 return -1;
50}
51#endif
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#ifdef SNDRV_LEGACY_FIND_FREE_IRQ
54#include <linux/interrupt.h>
55
David Howells7d12e782006-10-05 14:55:46 +010056static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057{
58 return IRQ_HANDLED;
59}
60
Takashi Iwaif5f87ab2020-01-05 15:47:16 +010061static int snd_legacy_find_free_irq(const int *irq_table)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
63 while (*irq_table != -1) {
64 if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
Yong Zhang88e24c32011-09-22 16:59:20 +080065 IRQF_PROBE_SHARED, "ALSA Test IRQ",
Takashi Iwai02ada9c2006-06-23 15:13:57 +020066 (void *) irq_table)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 free_irq(*irq_table, (void *) irq_table);
68 return *irq_table;
69 }
70 irq_table++;
71 }
72 return -1;
73}
74#endif
75
76#ifdef SNDRV_LEGACY_FIND_FREE_DMA
Takashi Iwaif5f87ab2020-01-05 15:47:16 +010077static int snd_legacy_find_free_dma(const int *dma_table)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
79 while (*dma_table != -1) {
80 if (!request_dma(*dma_table, "ALSA Test DMA")) {
81 free_dma(*dma_table);
82 return *dma_table;
83 }
84 dma_table++;
85 }
86 return -1;
87}
88#endif
89
90#endif /* __SOUND_INITVAL_H */