ainstr_simple.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Advanced Linux Sound Architecture
  3. *
  4. * Simple (MOD player) Instrument Format
  5. * Copyright (c) 1994-99 by Jaroslav Kysela <perex@suse.cz>
  6. *
  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_AINSTR_SIMPLE_H
  24. #define __SOUND_AINSTR_SIMPLE_H
  25. #ifndef __KERNEL__
  26. #include <asm/types.h>
  27. #include <asm/byteorder.h>
  28. #endif
  29. /*
  30. * share types (share ID 1)
  31. */
  32. #define SIMPLE_SHARE_FILE 0
  33. /*
  34. * wave formats
  35. */
  36. #define SIMPLE_WAVE_16BIT 0x0001 /* 16-bit wave */
  37. #define SIMPLE_WAVE_UNSIGNED 0x0002 /* unsigned wave */
  38. #define SIMPLE_WAVE_INVERT 0x0002 /* same as unsigned wave */
  39. #define SIMPLE_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
  40. #define SIMPLE_WAVE_LOOP 0x0008 /* loop mode */
  41. #define SIMPLE_WAVE_BIDIR 0x0010 /* bidirectional mode */
  42. #define SIMPLE_WAVE_STEREO 0x0100 /* stereo wave */
  43. #define SIMPLE_WAVE_ULAW 0x0200 /* uLaw compression mode */
  44. /*
  45. * instrument effects
  46. */
  47. #define SIMPLE_EFFECT_NONE 0
  48. #define SIMPLE_EFFECT_REVERB 1
  49. #define SIMPLE_EFFECT_CHORUS 2
  50. #define SIMPLE_EFFECT_ECHO 3
  51. /*
  52. * instrument info
  53. */
  54. struct simple_instrument_info {
  55. unsigned int format; /* supported format bits */
  56. unsigned int effects; /* supported effects (1 << SIMPLE_EFFECT_*) */
  57. unsigned int max8_len; /* maximum 8-bit wave length */
  58. unsigned int max16_len; /* maximum 16-bit wave length */
  59. };
  60. /*
  61. * Instrument
  62. */
  63. struct simple_instrument {
  64. unsigned int share_id[4]; /* share id - zero = no sharing */
  65. unsigned int format; /* wave format */
  66. struct {
  67. unsigned int number; /* some other ID for this instrument */
  68. unsigned int memory; /* begin of waveform in onboard memory */
  69. unsigned char *ptr; /* pointer to waveform in system memory */
  70. } address;
  71. unsigned int size; /* size of waveform in samples */
  72. unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
  73. unsigned int loop_start; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
  74. unsigned int loop_end; /* loop end offset in samples * 16 (lowest 4 bits - fraction) */
  75. unsigned short loop_repeat; /* loop repeat - 0 = forever */
  76. unsigned char effect1; /* effect 1 */
  77. unsigned char effect1_depth; /* 0-127 */
  78. unsigned char effect2; /* effect 2 */
  79. unsigned char effect2_depth; /* 0-127 */
  80. };
  81. /*
  82. *
  83. * Kernel <-> user space
  84. * Hardware (CPU) independent section
  85. *
  86. * * = zero or more
  87. * + = one or more
  88. *
  89. * simple_xinstrument SIMPLE_STRU_INSTR
  90. *
  91. */
  92. #define SIMPLE_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
  93. /*
  94. * Instrument
  95. */
  96. struct simple_xinstrument {
  97. __u32 stype;
  98. __u32 share_id[4]; /* share id - zero = no sharing */
  99. __u32 format; /* wave format */
  100. __u32 size; /* size of waveform in samples */
  101. __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
  102. __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
  103. __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
  104. __u16 loop_repeat; /* loop repeat - 0 = forever */
  105. __u8 effect1; /* effect 1 */
  106. __u8 effect1_depth; /* 0-127 */
  107. __u8 effect2; /* effect 2 */
  108. __u8 effect2_depth; /* 0-127 */
  109. };
  110. #ifdef __KERNEL__
  111. #include "seq_instr.h"
  112. struct snd_simple_ops {
  113. void *private_data;
  114. int (*info)(void *private_data, struct simple_instrument_info *info);
  115. int (*put_sample)(void *private_data, struct simple_instrument *instr,
  116. char __user *data, long len, int atomic);
  117. int (*get_sample)(void *private_data, struct simple_instrument *instr,
  118. char __user *data, long len, int atomic);
  119. int (*remove_sample)(void *private_data, struct simple_instrument *instr,
  120. int atomic);
  121. void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
  122. struct snd_seq_kinstr_ops kops;
  123. };
  124. int snd_seq_simple_init(struct snd_simple_ops *ops,
  125. void *private_data,
  126. struct snd_seq_kinstr_ops *next);
  127. #endif
  128. /* typedefs for compatibility to user-space */
  129. typedef struct simple_xinstrument simple_xinstrument_t;
  130. #endif /* __SOUND_AINSTR_SIMPLE_H */