sb16_csp.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
  4. * Takashi Iwai <tiwai@suse.de>
  5. *
  6. * SB16ASP/AWE32 CSP control
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #ifndef __SOUND_SB16_CSP_H
  24. #define __SOUND_SB16_CSP_H
  25. /* CSP modes */
  26. #define SNDRV_SB_CSP_MODE_NONE 0x00
  27. #define SNDRV_SB_CSP_MODE_DSP_READ 0x01 /* Record from DSP */
  28. #define SNDRV_SB_CSP_MODE_DSP_WRITE 0x02 /* Play to DSP */
  29. #define SNDRV_SB_CSP_MODE_QSOUND 0x04 /* QSound */
  30. /* CSP load flags */
  31. #define SNDRV_SB_CSP_LOAD_FROMUSER 0x01
  32. #define SNDRV_SB_CSP_LOAD_INITBLOCK 0x02
  33. /* CSP sample width */
  34. #define SNDRV_SB_CSP_SAMPLE_8BIT 0x01
  35. #define SNDRV_SB_CSP_SAMPLE_16BIT 0x02
  36. /* CSP channels */
  37. #define SNDRV_SB_CSP_MONO 0x01
  38. #define SNDRV_SB_CSP_STEREO 0x02
  39. /* CSP rates */
  40. #define SNDRV_SB_CSP_RATE_8000 0x01
  41. #define SNDRV_SB_CSP_RATE_11025 0x02
  42. #define SNDRV_SB_CSP_RATE_22050 0x04
  43. #define SNDRV_SB_CSP_RATE_44100 0x08
  44. #define SNDRV_SB_CSP_RATE_ALL 0x0f
  45. /* CSP running state */
  46. #define SNDRV_SB_CSP_ST_IDLE 0x00
  47. #define SNDRV_SB_CSP_ST_LOADED 0x01
  48. #define SNDRV_SB_CSP_ST_RUNNING 0x02
  49. #define SNDRV_SB_CSP_ST_PAUSED 0x04
  50. #define SNDRV_SB_CSP_ST_AUTO 0x08
  51. #define SNDRV_SB_CSP_ST_QSOUND 0x10
  52. /* maximum QSound value (180 degrees right) */
  53. #define SNDRV_SB_CSP_QSOUND_MAX_RIGHT 0x20
  54. /* maximum microcode RIFF file size */
  55. #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000
  56. /* microcode header */
  57. struct snd_sb_csp_mc_header {
  58. char codec_name[16]; /* id name of codec */
  59. unsigned short func_req; /* requested function */
  60. };
  61. /* microcode to be loaded */
  62. struct snd_sb_csp_microcode {
  63. struct snd_sb_csp_mc_header info;
  64. unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE];
  65. };
  66. /* start CSP with sample_width in mono/stereo */
  67. struct snd_sb_csp_start {
  68. int sample_width; /* sample width, look above */
  69. int channels; /* channels, look above */
  70. };
  71. /* CSP information */
  72. struct snd_sb_csp_info {
  73. char codec_name[16]; /* id name of codec */
  74. unsigned short func_nr; /* function number */
  75. unsigned int acc_format; /* accepted PCM formats */
  76. unsigned short acc_channels; /* accepted channels */
  77. unsigned short acc_width; /* accepted sample width */
  78. unsigned short acc_rates; /* accepted sample rates */
  79. unsigned short csp_mode; /* CSP mode, see above */
  80. unsigned short run_channels; /* current channels */
  81. unsigned short run_width; /* current sample width */
  82. unsigned short version; /* version id: 0x10 - 0x1f */
  83. unsigned short state; /* state bits */
  84. };
  85. /* HWDEP controls */
  86. /* get CSP information */
  87. #define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info)
  88. /* load microcode to CSP */
  89. /* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
  90. * defined for some architectures like MIPS, and it leads to build errors.
  91. * (x86 and co have 14-bit size, thus it's valid, though.)
  92. * As a workaround for skipping the size-limit check, here we don't use the
  93. * normal _IOW() macro but _IOC() with the manual argument.
  94. */
  95. #define SNDRV_SB_CSP_IOCTL_LOAD_CODE \
  96. _IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
  97. /* unload microcode from CSP */
  98. #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12)
  99. /* start CSP */
  100. #define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start)
  101. /* stop CSP */
  102. #define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14)
  103. /* pause CSP and DMA transfer */
  104. #define SNDRV_SB_CSP_IOCTL_PAUSE _IO('H', 0x15)
  105. /* restart CSP and DMA transfer */
  106. #define SNDRV_SB_CSP_IOCTL_RESTART _IO('H', 0x16)
  107. #endif /* __SOUND_SB16_CSP_H */