source: GPL/alsa-kernel/include/sound/initval.h@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 6.6 KB
Line 
1#ifndef __INITVAL_H
2#define __INITVAL_H
3
4/*
5 * Init values for soundcard modules
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#ifndef MODULE_GENERIC_STRING
25#ifdef MODULE
26#define MODULE_GENERIC_STRING(name, string) \
27static const char __module_generic_string_##name [] \
28 __attribute__ ((section(".modstring"))) = #name "=" string;
29#else
30#define MODULE_GENERIC_STRING(name, string)
31#endif
32#endif
33
34#ifdef TARGET_OS2
35#define MODULE_CLASSES(val)
36#define MODULE_DEVICES(val)
37#define MODULE_PARM_SYNTAX(id, val)
38#else
39#define MODULE_CLASSES(val) MODULE_GENERIC_STRING(info_classes, val)
40#define MODULE_DEVICES(val) MODULE_GENERIC_STRING(info_devices, val)
41#define MODULE_PARM_SYNTAX(id, val) MODULE_GENERIC_STRING(info_parm_##id, val)
42
43#define SNDRV_MODULE_TYPE_int "i"
44#define SNDRV_MODULE_TYPE_bool "i"
45#define SNDRV_MODULE_TYPE_uint "i"
46#define SNDRV_MODULE_TYPE_charp "s"
47#define SNDRV_MODULE_TYPE_long "l"
48#define module_param_array(name, type, nump, perm) \
49 MODULE_PARM(name, "1-" __MODULE_STRING(SNDRV_CARDS) SNDRV_MODULE_TYPE_##type)
50#define module_param(name, type, perm) \
51 MODULE_PARM(name, SNDRV_MODULE_TYPE_##type)
52
53#endif
54
55#define SNDRV_AUTO_PORT 0xffff
56#define SNDRV_AUTO_IRQ 0xffff
57#define SNDRV_AUTO_DMA 0xffff
58#define SNDRV_AUTO_DMA_SIZE (0x7fffffff)
59
60#define SNDRV_DEFAULT_IDX1 (-1)
61#define SNDRV_DEFAULT_STR1 NULL
62#define SNDRV_DEFAULT_ENABLE1 1
63#define SNDRV_DEFAULT_PORT1 SNDRV_AUTO_PORT
64#define SNDRV_DEFAULT_IRQ1 SNDRV_AUTO_IRQ
65#define SNDRV_DEFAULT_DMA1 SNDRV_AUTO_DMA
66#define SNDRV_DEFAULT_DMA_SIZE1 SNDRV_AUTO_DMA_SIZE
67#define SNDRV_DEFAULT_PTR1 SNDRV_DEFAULT_STR1
68
69#ifdef TARGET_OS2
70#define REPEAT_SNDRV(a) a,a,a,a,a,a,a,a
71#define SNDRV_DEFAULT_IDX { REPEAT_SNDRV(-1) }
72#define SNDRV_DEFAULT_STR { REPEAT_SNDRV(NULL) }
73#define SNDRV_DEFAULT_ENABLE { 1,1,1,1,1,1,1,1 }
74#define SNDRV_DEFAULT_ENABLE_PNP SNDRV_DEFAULT_ENABLE
75#define SNDRV_DEFAULT_PORT { REPEAT_SNDRV(-1) }
76#define SNDRV_DEFAULT_IRQ { REPEAT_SNDRV(SNDRV_AUTO_IRQ) }
77#define SNDRV_DEFAULT_DMA { REPEAT_SNDRV(SNDRV_AUTO_DMA) }
78#define SNDRV_DEFAULT_DMA_SIZE { REPEAT_SNDRV(SNDRV_AUTO_DMA_SIZE) }
79#define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR
80#define SNDDRV_DEFAULT_PCM_DEVS {REPEAT_SNDRV(1)};
81#define SNDDRV_DEFAULT_PCM_SUBSTREAMS {REPEAT_SNDRV(8)};
82#define SNDDRV_DEFAULT_MIDI_DEVS {REPEAT_SNDRV(4)};
83#else
84#define SNDRV_DEFAULT_IDX { [0 ... (SNDRV_CARDS-1)] = -1 }
85#define SNDRV_DEFAULT_STR { [0 ... (SNDRV_CARDS-1)] = NULL }
86#define SNDRV_DEFAULT_ENABLE { 1, [1 ... (SNDRV_CARDS-1)] = 0 }
87#define SNDRV_DEFAULT_PORT { SNDRV_AUTO_PORT, [1 ... (SNDRV_CARDS-1)] = -1 }
88#define SNDRV_DEFAULT_IRQ { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
89#define SNDRV_DEFAULT_DMA { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
90#define SNDRV_DEFAULT_DMA_SIZE { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE }
91#define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR
92#endif
93
94#define SNDRV_BOOLEAN_TRUE_DESC "allows:{{0,Disabled},{1,Enabled}},default:1,dialog:check"
95#define SNDRV_BOOLEAN_FALSE_DESC "allows:{{0,Disabled},{1,Enabled}},default:0,dialog:check"
96
97#define SNDRV_ENABLED "enable:(snd_enable)"
98
99#define SNDRV_INDEX_DESC SNDRV_ENABLED ",allows:{{0,7}},unique,skill:required,dialog:list"
100#define SNDRV_ID_DESC SNDRV_ENABLED ",unique"
101#define SNDRV_ENABLE_DESC SNDRV_BOOLEAN_FALSE_DESC
102#define SNDRV_ISAPNP_DESC SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC
103#define SNDRV_DMA8_DESC SNDRV_ENABLED ",allows:{{0,1},{3}},dialog:list"
104#define SNDRV_DMA16_DESC SNDRV_ENABLED ",allows:{{5,7}},dialog:list"
105#define SNDRV_DMA_DESC SNDRV_ENABLED ",allows:{{0,1},{3},{5,7}},dialog:list"
106#define SNDRV_IRQ_DESC SNDRV_ENABLED ",allows:{{5},{7},{9},{10,12},{14,15}},dialog:list"
107#define SNDRV_DMA_SIZE_DESC SNDRV_ENABLED ",allows:{{4,128}},default:64,skill:advanced"
108#define SNDRV_DMA8_SIZE_DESC SNDRV_ENABLED ",allows:{{4, 64}},default:64,skill:advanced"
109#define SNDRV_DMA16_SIZE_DESC SNDRV_ENABLED ",allows:{{4,128}},default:64,skill:advanced"
110#define SNDRV_PORT12_DESC SNDRV_ENABLED ",allows:{{0,0x3fff}},base:16"
111#define SNDRV_PORT_DESC SNDRV_ENABLED ",allows:{{0,0xffff}},base:16"
112
113#ifdef SNDRV_LEGACY_AUTO_PROBE
114static int snd_legacy_auto_probe(unsigned long *ports, int (*probe)(unsigned long port))
115{
116 int result = 0; /* number of detected cards */
117
118 while ((signed long)*ports != -1) {
119 if (probe(*ports) >= 0)
120 result++;
121 ports++;
122 }
123 return result;
124}
125#endif
126
127#ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
128static long snd_legacy_find_free_ioport(long *port_table, long size)
129{
130 while (*port_table != -1) {
131 if (!check_region(*port_table, size))
132 return *port_table;
133 port_table++;
134 }
135 return -1;
136}
137#endif
138
139#ifdef SNDRV_LEGACY_FIND_FREE_IRQ
140static void snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
141{
142}
143
144static int snd_legacy_find_free_irq(int *irq_table)
145{
146 while (*irq_table != -1) {
147 if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
148 SA_INTERRUPT, "ALSA Test IRQ", (void *) irq_table)) {
149 free_irq(*irq_table, (void *) irq_table);
150 return *irq_table;
151 }
152 irq_table++;
153 }
154 return -1;
155}
156#endif
157
158#ifdef SNDRV_LEGACY_FIND_FREE_DMA
159static int snd_legacy_find_free_dma(int *dma_table)
160{
161 while (*dma_table != -1) {
162 if (!request_dma(*dma_table, "ALSA Test DMA")) {
163 free_dma(*dma_table);
164 return *dma_table;
165 }
166 dma_table++;
167 }
168 return -1;
169}
170#endif
171
172#if defined(SNDRV_GET_ID) && !defined(MODULE)
173#include <linux/ctype.h>
174static int __init get_id(char **str, char **dst)
175{
176 char *s, *d;
177
178 if (!(*str) || !(**str))
179 return 0;
180 for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++);
181 if (s != *str) {
182 *dst = (char *)kmalloc(s - *str, GFP_KERNEL);
183 if ((d = *dst) != NULL) {
184 s = *str;
185 while (isalpha(*s) || isdigit(*s) || *s == '_')
186 *d++ = *s++;
187 }
188 }
189 *str = s;
190 if (*s == ',') {
191 (*str)++;
192 return 2;
193 }
194 return 1;
195}
196#endif
197
198#endif /* __INITVAL_H */
Note: See TracBrowser for help on using the repository browser.