sb16_csp.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef __SOUND_SB16_CSP_H
  2. #define __SOUND_SB16_CSP_H
  3. /*
  4. * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
  5. * Takashi Iwai <tiwai@suse.de>
  6. *
  7. * SB16ASP/AWE32 CSP control
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. /* CSP modes */
  25. #define SNDRV_SB_CSP_MODE_NONE 0x00
  26. #define SNDRV_SB_CSP_MODE_DSP_READ 0x01 /* Record from DSP */
  27. #define SNDRV_SB_CSP_MODE_DSP_WRITE 0x02 /* Play to DSP */
  28. #define SNDRV_SB_CSP_MODE_QSOUND 0x04 /* QSound */
  29. /* CSP load flags */
  30. #define SNDRV_SB_CSP_LOAD_FROMUSER 0x01
  31. #define SNDRV_SB_CSP_LOAD_INITBLOCK 0x02
  32. /* CSP sample width */
  33. #define SNDRV_SB_CSP_SAMPLE_8BIT 0x01
  34. #define SNDRV_SB_CSP_SAMPLE_16BIT 0x02
  35. /* CSP channels */
  36. #define SNDRV_SB_CSP_MONO 0x01
  37. #define SNDRV_SB_CSP_STEREO 0x02
  38. /* CSP rates */
  39. #define SNDRV_SB_CSP_RATE_8000 0x01
  40. #define SNDRV_SB_CSP_RATE_11025 0x02
  41. #define SNDRV_SB_CSP_RATE_22050 0x04
  42. #define SNDRV_SB_CSP_RATE_44100 0x08
  43. #define SNDRV_SB_CSP_RATE_ALL 0x0f
  44. /* CSP running state */
  45. #define SNDRV_SB_CSP_ST_IDLE 0x00
  46. #define SNDRV_SB_CSP_ST_LOADED 0x01
  47. #define SNDRV_SB_CSP_ST_RUNNING 0x02
  48. #define SNDRV_SB_CSP_ST_PAUSED 0x04
  49. #define SNDRV_SB_CSP_ST_AUTO 0x08
  50. #define SNDRV_SB_CSP_ST_QSOUND 0x10
  51. /* maximum QSound value (180 degrees right) */
  52. #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT 0x20
  53. /* maximum microcode RIFF file size */
  54. #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000
  55. /* microcode header */
  56. struct snd_sb_csp_mc_header {
  57. char codec_name[16]; /* id name of codec */
  58. unsigned short func_req; /* requested function */
  59. };
  60. /* microcode to be loaded */
  61. struct snd_sb_csp_microcode {
  62. struct snd_sb_csp_mc_header info;
  63. unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
  64. };
  65. /* start CSP with sample_width in mono/stereo */
  66. struct snd_sb_csp_start {
  67. int sample_width; /* sample width, look above */
  68. int channels; /* channels, look above */
  69. };
  70. /* CSP information */
  71. struct snd_sb_csp_info {
  72. char codec_name[16]; /* id name of codec */
  73. unsigned short func_nr; /* function number */
  74. unsigned int acc_format; /* accepted PCM formats */
  75. unsigned short acc_channels; /* accepted channels */
  76. unsigned short acc_width; /* accepted sample width */
  77. unsigned short acc_rates; /* accepted sample rates */
  78. unsigned short csp_mode; /* CSP mode, see above */
  79. unsigned short run_channels; /* current channels */
  80. unsigned short run_width; /* current sample width */
  81. unsigned short version; /* version id: 0x10 - 0x1f */
  82. unsigned short state; /* state bits */
  83. };
  84. /* HWDEP controls */
  85. /* get CSP information */
  86. #define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info)
  87. /* load microcode to CSP */
  88. #define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, struct snd_sb_csp_microcode)
  89. /* unload microcode from CSP */
  90. #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12)
  91. /* start CSP */
  92. #define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start)
  93. /* stop CSP */
  94. #define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14)
  95. /* pause CSP and DMA transfer */
  96. #define SNDRV_SB_CSP_IOCTL_PAUSE _IO('H', 0x15)
  97. /* restart CSP and DMA transfer */
  98. #define SNDRV_SB_CSP_IOCTL_RESTART _IO('H', 0x16)
  99. #ifdef __KERNEL__
  100. #include "sb.h"
  101. #include "hwdep.h"
  102. #include <linux/firmware.h>
  103. struct snd_sb_csp;
  104. /* indices for the known CSP programs */
  105. enum {
  106. CSP_PROGRAM_MULAW,
  107. CSP_PROGRAM_ALAW,
  108. CSP_PROGRAM_ADPCM_INIT,
  109. CSP_PROGRAM_ADPCM_PLAYBACK,
  110. CSP_PROGRAM_ADPCM_CAPTURE,
  111. CSP_PROGRAM_COUNT
  112. };
  113. /*
  114. * CSP operators
  115. */
  116. struct snd_sb_csp_ops {
  117. int (*csp_use) (struct snd_sb_csp * p);
  118. int (*csp_unuse) (struct snd_sb_csp * p);
  119. int (*csp_autoload) (struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode);
  120. int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels);
  121. int (*csp_stop) (struct snd_sb_csp * p);
  122. int (*csp_qsound_transfer) (struct snd_sb_csp * p);
  123. };
  124. /*
  125. * CSP private data
  126. */
  127. struct snd_sb_csp {
  128. struct snd_sb *chip; /* SB16 DSP */
  129. int used; /* usage flag - exclusive */
  130. char codec_name[16]; /* name of codec */
  131. unsigned short func_nr; /* function number */
  132. unsigned int acc_format; /* accepted PCM formats */
  133. int acc_channels; /* accepted channels */
  134. int acc_width; /* accepted sample width */
  135. int acc_rates; /* accepted sample rates */
  136. int mode; /* MODE */
  137. int run_channels; /* current CSP channels */
  138. int run_width; /* current sample width */
  139. int version; /* CSP version (0x10 - 0x1f) */
  140. int running; /* running state */
  141. struct snd_sb_csp_ops ops; /* operators */
  142. spinlock_t q_lock; /* locking */
  143. int q_enabled; /* enabled flag */
  144. int qpos_left; /* left position */
  145. int qpos_right; /* right position */
  146. int qpos_changed; /* position changed flag */
  147. struct snd_kcontrol *qsound_switch;
  148. struct snd_kcontrol *qsound_space;
  149. struct mutex access_mutex; /* locking */
  150. const struct firmware *csp_programs[CSP_PROGRAM_COUNT];
  151. };
  152. int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep);
  153. #endif
  154. #endif /* __SOUND_SB16_CSP */