~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to kernel/framework/vmix_core/vmix.h

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: Definitions for the vmix driver
 
3
 */
 
4
/*
 
5
 *
 
6
 * This file is part of Open Sound System.
 
7
 *
 
8
 * Copyright (C) 4Front Technologies 1996-2008.
 
9
 *
 
10
 * This this source file is released under GPL v2 license (no other versions).
 
11
 * See the COPYING file included in the main directory of this source
 
12
 * distribution for the license terms and conditions.
 
13
 *
 
14
 */
 
15
 
 
16
#define SUPPORTED_FORMATS (AFMT_S16_NE | AFMT_S16_OE | AFMT_S32_NE | AFMT_S32_OE)
 
17
 
 
18
/*
 
19
 * Maximum number of clients per "real" device is defined by MAX_CLIENTS. Limit of 4 would be good for 95% of systems.
 
20
 * For each client there will be a mixer volume control and peak meter in the mixer interface. Raising the
 
21
 * client limit will make the mixer interface larger and larger. Something like 8 is probably the practical limit
 
22
 * for number of clients.
 
23
 *
 
24
 * Mixing more than 16 streams together doesn't make much sense since the result is likely to be
 
25
 * just noise. Mixing a stream will cause some overhead so it's not a good idea to let large number of iddle
 
26
 * applications running muted or playing silence.
 
27
 */
 
28
 
 
29
#define MAX_CLIENTS             9       
 
30
 
 
31
#define MAX_LOOPDEVS            2       /* Maximum number of vmix loopback devices */
 
32
 
 
33
/*
 
34
 * 8 play channels and 2 rec channels might be OK for most devices. However envy24 requires 10 play and 12 rec 
 
35
 * channels for the "raw devices". Some professional (ADAT) cards like Digi96 requires 8+8 channels.
 
36
 */
 
37
#define MAX_PLAY_CHANNELS       12
 
38
/* MAX_REC_CHANNELS must be less or equal than MAX_PLAY_CHANNELS */
 
39
#define MAX_REC_CHANNELS        12
 
40
 
 
41
#define CHBUF_SAMPLES           2048    /* Max samples (frames) per fragment */
 
42
 
 
43
typedef struct _vmix_mixer_t vmix_mixer_t;
 
44
typedef struct _vmix_portc_t vmix_portc_t;
 
45
typedef struct _vmix_engine_t vmix_engine_t;
 
46
typedef unsigned char vmix_channel_map_t[MAX_PLAY_CHANNELS];
 
47
 
 
48
struct _vmix_portc_t            /* Audio device specific data */
 
49
{
 
50
  int num;
 
51
  vmix_mixer_t *mixer;
 
52
  vmix_portc_t *next;           /* Linked list for all portc structures */
 
53
  int dev_type;
 
54
#define DT_IN           1
 
55
#define DT_OUT          2
 
56
#define DT_LOOP         3
 
57
 
 
58
  int disabled_modes;
 
59
 
 
60
  int fmt, bits;
 
61
  int channels;
 
62
  int rate;
 
63
 
 
64
  int audio_dev;
 
65
  int open_mode;
 
66
  int trigger_bits;
 
67
 
 
68
  int open_pending;     /* Set to 1 by vmix_create_client() and cleared by vmix_open() */
 
69
 
 
70
  int play_dma_pointer;
 
71
  int play_choffs;              /* Index of the first channel on multich play engines */
 
72
  int rec_choffs;               /* Index of the first channel on multich rec engines */
 
73
#ifdef CONFIG_OSS_VMIX_FLOAT
 
74
  double play_dma_pointer_src;
 
75
#endif
 
76
  int rec_dma_pointer;
 
77
  int volume[2]; /* Left and right ch volumes */
 
78
  int vu[2];
 
79
 
 
80
  void (*play_mixing_func) (vmix_portc_t * portc, int nsamples);
 
81
  void (*rec_mixing_func) (vmix_portc_t * portc, int nsamples);
 
82
  int do_src;
 
83
  vmix_channel_map_t channel_order;
 
84
};
 
85
 
 
86
#ifdef CONFIG_OSS_VMIX_FLOAT
 
87
   typedef float vmix_sample_t;
 
88
#else
 
89
   typedef int vmix_sample_t;
 
90
#endif
 
91
 
 
92
typedef void (*converter_t) (vmix_engine_t * engine, void *outbuf,
 
93
                             vmix_sample_t * chbufs[], int channels,
 
94
                             int samples);
 
95
 
 
96
struct _vmix_engine_t
 
97
{
 
98
  int rate, channels, fmt, bits;
 
99
  int max_playahead;
 
100
  int fragsize;
 
101
  int samples_per_frag;
 
102
 
 
103
  converter_t converter;
 
104
  vmix_sample_t *chbufs[MAX_PLAY_CHANNELS];
 
105
  unsigned int limiter_statevar;
 
106
 
 
107
/*
 
108
 * Mixer volumes, etc.
 
109
 */
 
110
  int outvol;
 
111
  int vu[2];
 
112
  int num_active_outputs;
 
113
  vmix_channel_map_t channel_order;
 
114
};
 
115
 
 
116
struct _vmix_mixer_t            /* Instance specific data */
 
117
{
 
118
  vmix_mixer_t *next;           /* Pointer to the next vmix instance */
 
119
  int instance_num;
 
120
  int disabled;
 
121
  oss_device_t *osdev;
 
122
  oss_device_t *master_osdev;
 
123
  oss_mutex_t mutex;
 
124
  unsigned int attach_flags;
 
125
 
 
126
  int installed_ok;
 
127
 
 
128
  int open_devices, open_inputs;
 
129
  struct fileinfo master_finfo, input_finfo;
 
130
  int masterdev_opened;
 
131
 
 
132
  int vmix_flags;               /* Copy of adev[master]->vmix_flags */
 
133
 
 
134
/*
 
135
 * Config options for this instance
 
136
 */
 
137
  int masterdev;
 
138
  int inputdev;
 
139
  int rate;
 
140
 
 
141
  int src_quality;              /* Control panel setting */
 
142
  int multich_enable;           /* Enable multi channel mode */
 
143
  int max_channels;
 
144
 
 
145
  vmix_engine_t play_engine, record_engine;
 
146
 
 
147
  vmix_portc_t *client_portc[MAX_CLIENTS];
 
148
  vmix_portc_t *loop_portc[MAX_LOOPDEVS];
 
149
  int num_clientdevs, num_loopdevs;
 
150
 
 
151
/*
 
152
 * Mixer interface
 
153
 *
 
154
 * Mixer device numbers for the master audio devices
 
155
 */
 
156
  int output_mixer_dev;
 
157
  int input_mixer_dev;
 
158
  int first_input_mixext;
 
159
  int first_output_mixext;
 
160
  int client_mixer_group;       /* Create the client controls under this mixer group */
 
161
};
 
162
 
 
163
extern void vmix_setup_play_engine (vmix_mixer_t * mixer, adev_t * adev,
 
164
                                    dmap_t * dmap);
 
165
extern void vmix_setup_record_engine (vmix_mixer_t * mixer, adev_t * adev,
 
166
                                      dmap_t * dmap);
 
167
extern void finalize_record_engine (vmix_mixer_t * mixer, int fmt,
 
168
                                    adev_t * adev, dmap_p dmap);
 
169
 
 
170
extern void vmix_outmix_16ne (vmix_portc_t * portc, int nsamples);
 
171
extern void vmix_outmix_16oe (vmix_portc_t * portc, int nsamples);
 
172
extern void vmix_outmix_32ne (vmix_portc_t * portc, int nsamples);
 
173
extern void vmix_outmix_32oe (vmix_portc_t * portc, int nsamples);
 
174
#ifdef CONFIG_OSS_VMIX_FLOAT
 
175
extern void vmix_outmix_float (vmix_portc_t * portc, int nsamples);
 
176
#endif
 
177
 
 
178
#ifdef CONFIG_OSS_VMIX_FLOAT
 
179
/*
 
180
 * For the time being these routines will only work in floating point.
 
181
 */
 
182
extern void vmix_outmix_16ne_src (vmix_portc_t * portc, int nsamples);
 
183
extern void vmix_outmix_16oe_src (vmix_portc_t * portc, int nsamples);
 
184
extern void vmix_outmix_32ne_src (vmix_portc_t * portc, int nsamples);
 
185
extern void vmix_outmix_32oe_src (vmix_portc_t * portc, int nsamples);
 
186
extern void vmix_outmix_float_src (vmix_portc_t * portc, int nsamples);
 
187
#endif
 
188
 
 
189
extern void vmix_rec_export_16ne (vmix_portc_t * portc, int nsamples);
 
190
extern void vmix_rec_export_16oe (vmix_portc_t * portc, int nsamples);
 
191
extern void vmix_rec_export_32ne (vmix_portc_t * portc, int nsamples);
 
192
extern void vmix_rec_export_32oe (vmix_portc_t * portc, int nsamples);
 
193
#ifdef CONFIG_OSS_VMIX_FLOAT
 
194
extern void vmix_rec_export_float (vmix_portc_t * portc, int nsamples);
 
195
#endif
 
196
 
 
197
#define DB_SIZE 50
 
198
#define VMIX_VOL_SCALE  127
 
199
 
 
200
#ifdef CONFIG_OSS_VMIX_FLOAT
 
201
   extern const float vmix_db_table[DB_SIZE + 1];
 
202
#else
 
203
   extern const int vmix_db_table[DB_SIZE + 1];
 
204
#endif
 
205
 
 
206
#ifdef VMIX_MAIN
 
207
#include "db_scale.h"
 
208
#endif
 
209
 
 
210
#ifdef SWAP_SUPPORT
 
211
/*
 
212
 * Endianess swapping functions
 
213
 */
 
214
static __inline__ short
 
215
bswap16 (short x)
 
216
{
 
217
  short y = 0;
 
218
  unsigned char *a = ((unsigned char *) &x) + 1;
 
219
  unsigned char *b = (unsigned char *) &y;
 
220
 
 
221
  *b++ = *a--;
 
222
  *b++ = *a--;
 
223
 
 
224
  return y;
 
225
}
 
226
 
 
227
static __inline__ int
 
228
bswap32 (int x)
 
229
{
 
230
 
 
231
  int y = 0;
 
232
  unsigned char *a = ((unsigned char *) &x) + 3;
 
233
  unsigned char *b = (unsigned char *) &y;
 
234
 
 
235
  *b++ = *a--;
 
236
  *b++ = *a--;
 
237
  *b++ = *a--;
 
238
  *b++ = *a--;
 
239
 
 
240
  return y;
 
241
}
 
242
#endif