initval.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef __SOUND_INITVAL_H
  3. #define __SOUND_INITVAL_H
  4. /*
  5. * Init values for soundcard modules
  6. * Copyright (c) by Jaroslav Kysela <[email protected]>
  7. */
  8. #define SNDRV_AUTO_PORT 1
  9. #define SNDRV_AUTO_IRQ 0xffff
  10. #define SNDRV_AUTO_DMA 0xffff
  11. #define SNDRV_AUTO_DMA_SIZE (0x7fffffff)
  12. #define SNDRV_DEFAULT_IDX1 (-1)
  13. #define SNDRV_DEFAULT_STR1 NULL
  14. #define SNDRV_DEFAULT_ENABLE1 1
  15. #define SNDRV_DEFAULT_PORT1 SNDRV_AUTO_PORT
  16. #define SNDRV_DEFAULT_IRQ1 SNDRV_AUTO_IRQ
  17. #define SNDRV_DEFAULT_DMA1 SNDRV_AUTO_DMA
  18. #define SNDRV_DEFAULT_DMA_SIZE1 SNDRV_AUTO_DMA_SIZE
  19. #define SNDRV_DEFAULT_PTR1 SNDRV_DEFAULT_STR1
  20. #define SNDRV_DEFAULT_IDX { [0 ... (SNDRV_CARDS-1)] = -1 }
  21. #define SNDRV_DEFAULT_STR { [0 ... (SNDRV_CARDS-1)] = NULL }
  22. #define SNDRV_DEFAULT_ENABLE { 1, [1 ... (SNDRV_CARDS-1)] = 0 }
  23. #define SNDRV_DEFAULT_ENABLE_PNP { [0 ... (SNDRV_CARDS-1)] = 1 }
  24. #ifdef CONFIG_PNP
  25. #define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE_PNP
  26. #else
  27. #define SNDRV_DEFAULT_ENABLE_ISAPNP SNDRV_DEFAULT_ENABLE
  28. #endif
  29. #define SNDRV_DEFAULT_PORT { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_PORT }
  30. #define SNDRV_DEFAULT_IRQ { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_IRQ }
  31. #define SNDRV_DEFAULT_DMA { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA }
  32. #define SNDRV_DEFAULT_DMA_SIZE { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE }
  33. #define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR
  34. #ifdef SNDRV_LEGACY_FIND_FREE_IOPORT
  35. static long snd_legacy_find_free_ioport(const long *port_table, long size)
  36. {
  37. while (*port_table != -1) {
  38. if (request_region(*port_table, size, "ALSA test")) {
  39. release_region(*port_table, size);
  40. return *port_table;
  41. }
  42. port_table++;
  43. }
  44. return -1;
  45. }
  46. #endif
  47. #ifdef SNDRV_LEGACY_FIND_FREE_IRQ
  48. #include <linux/interrupt.h>
  49. static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id)
  50. {
  51. return IRQ_HANDLED;
  52. }
  53. static int snd_legacy_find_free_irq(const int *irq_table)
  54. {
  55. while (*irq_table != -1) {
  56. if (!request_irq(*irq_table, snd_legacy_empty_irq_handler,
  57. IRQF_PROBE_SHARED, "ALSA Test IRQ",
  58. (void *) irq_table)) {
  59. free_irq(*irq_table, (void *) irq_table);
  60. return *irq_table;
  61. }
  62. irq_table++;
  63. }
  64. return -1;
  65. }
  66. #endif
  67. #ifdef SNDRV_LEGACY_FIND_FREE_DMA
  68. static int snd_legacy_find_free_dma(const int *dma_table)
  69. {
  70. while (*dma_table != -1) {
  71. if (!request_dma(*dma_table, "ALSA Test DMA")) {
  72. free_dma(*dma_table);
  73. return *dma_table;
  74. }
  75. dma_table++;
  76. }
  77. return -1;
  78. }
  79. #endif
  80. #endif /* __SOUND_INITVAL_H */