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