initval.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef __SOUND_INITVAL_H
  2. #define __SOUND_INITVAL_H
  3. /*
  4. * Init values for soundcard modules
  5. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #define SNDRV_AUTO_PORT 1
  23. #define SNDRV_AUTO_IRQ 0xffff
  24. #define SNDRV_AUTO_DMA 0xffff
  25. #define SNDRV_AUTO_DMA_SIZE (0x7fffffff)
  26. #define SNDRV_DEFAULT_IDX1 (-1)
  27. #define SNDRV_DEFAULT_STR1 NULL
  28. #define SNDRV_DEFAULT_ENABLE1 1
  29. #define SNDRV_DEFAULT_PORT1 SNDRV_AUTO_PORT
  30. #define SNDRV_DEFAULT_IRQ1 SNDRV_AUTO_IRQ
  31. #define SNDRV_DEFAULT_DMA1 SNDRV_AUTO_DMA
  32. #define SNDRV_DEFAULT_DMA_SIZE1 SNDRV_AUTO_DMA_SIZE
  33. #define SNDRV_DEFAULT_PTR1 SNDRV_DEFAULT_STR1
  34. #define SNDRV_DEFAULT_IDX { [0 ... (SNDRV_CARDS-1)] = -1 }
  35. #define SNDRV_DEFAULT_STR { [0 ... (SNDRV_CARDS-1)] = NULL }
  36. #define SNDRV_DEFAULT_ENABLE { 1, [1 ... (SNDRV_CARDS-1)] = 0 }
  37. #define SNDRV_DEFAULT_ENABLE_PNP { [0 ... (SNDRV_CARDS-1)] = 1 }
  38. #ifdef CONFIG_PNP
  39. #define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
  40. #else
  41. #define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
  42. #endif
  43. #define SNDRV_DEFAULT_PORT { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_PORT }
  44. #define SNDRV_DEFAULT_IRQ { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
  45. #define SNDRV_DEFAULT_DMA { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
  46. #define SNDRV_DEFAULT_DMA_SIZE { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE }
  47. #define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR
  48. #ifdef SNDRV_LEGACY_AUTO_PROBE
  49. static int snd_legacy_auto_probe(unsigned long *ports, int (*probe)(unsigned long port))
  50. {
  51. int result = 0; /* number of detected cards */
  52. while ((signed long)*ports != -1) {
  53. if (probe(*ports) >= 0)
  54. result++;
  55. ports++;
  56. }
  57. return result;
  58. }
  59. #endif
  60. #ifdef SNDRV_LEGACY_FIND_FREE_IRQ
  61. #include <linux/interrupt.h>
  62. static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
  63. {
  64. return IRQ_HANDLED;
  65. }
  66. static int snd_legacy_find_free_irq(int *irq_table)
  67. {
  68. while (*irq_table != -1) {
  69. if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
  70. SA_INTERRUPT, "ALSA Test IRQ", (void *) irq_table)) {
  71. free_irq(*irq_table, (void *) irq_table);
  72. return *irq_table;
  73. }
  74. irq_table++;
  75. }
  76. return -1;
  77. }
  78. #endif
  79. #ifdef SNDRV_LEGACY_FIND_FREE_DMA
  80. static int snd_legacy_find_free_dma(int *dma_table)
  81. {
  82. while (*dma_table != -1) {
  83. if (!request_dma(*dma_table, "ALSA Test DMA")) {
  84. free_dma(*dma_table);
  85. return *dma_table;
  86. }
  87. dma_table++;
  88. }
  89. return -1;
  90. }
  91. #endif
  92. #endif /* __SOUND_INITVAL_H */