blob: da08e72875575749443dc3f8a0f6b77cf2eaac04 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Advanced Linux Sound Architecture
3 *
4 * Simple (MOD player) Instrument Format
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02005 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +010064struct simple_instrument_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +010069};
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71/*
72 * Instrument
73 */
74
Takashi Iwai19ac31e2005-11-17 14:04:44 +010075struct simple_instrument {
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +010095};
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
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
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100115struct simple_xinstrument {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 __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 */
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100131};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133#ifdef __KERNEL__
134
135#include "seq_instr.h"
136
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100137struct snd_simple_ops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 void *private_data;
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100139 int (*info)(void *private_data, struct simple_instrument_info *info);
140 int (*put_sample)(void *private_data, struct simple_instrument *instr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 char __user *data, long len, int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100142 int (*get_sample)(void *private_data, struct simple_instrument *instr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 char __user *data, long len, int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100144 int (*remove_sample)(void *private_data, struct simple_instrument *instr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 int atomic);
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100146 void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
147 struct snd_seq_kinstr_ops kops;
148};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100150int snd_seq_simple_init(struct snd_simple_ops *ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 void *private_data,
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100152 struct snd_seq_kinstr_ops *next);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154#endif
155
Takashi Iwai19ac31e2005-11-17 14:04:44 +0100156/* typedefs for compatibility to user-space */
157typedef struct simple_xinstrument simple_xinstrument_t;
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#endif /* __SOUND_AINSTR_SIMPLE_H */