OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-sparc64/] [audioio.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 * include/asm-sparc/audioio.h
3
 *
4
 * Sparc Audio Midlayer
5
 * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
6
 */
7
 
8
#ifndef _AUDIOIO_H_
9
#define _AUDIOIO_H_
10
 
11
/*
12
 *      SunOS/Solaris /dev/audio interface
13
 */
14
 
15
#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
16
#include <linux/types.h>
17
#include <linux/time.h>
18
#include <linux/ioctl.h>
19
#endif
20
 
21
/*
22
 * This structure contains state information for audio device IO streams.
23
 */
24
typedef struct audio_prinfo {
25
        /*
26
         * The following values describe the audio data encoding.
27
         */
28
        unsigned int sample_rate;       /* samples per second */
29
        unsigned int channels;  /* number of interleaved channels */
30
        unsigned int precision; /* bit-width of each sample */
31
        unsigned int encoding;  /* data encoding method */
32
 
33
        /*
34
         * The following values control audio device configuration
35
         */
36
        unsigned int gain;              /* gain level: 0 - 255 */
37
        unsigned int port;              /* selected I/O port (see below) */
38
        unsigned int avail_ports;       /* available I/O ports (see below) */
39
        unsigned int _xxx[2];           /* Reserved for future use */
40
 
41
        unsigned int buffer_size;       /* I/O buffer size */
42
 
43
        /*
44
         * The following values describe driver state
45
         */
46
        unsigned int samples;           /* number of samples converted */
47
        unsigned int eof;               /* End Of File counter (play only) */
48
 
49
        unsigned char   pause;          /* non-zero for pause, zero to resume */
50
        unsigned char   error;          /* non-zero if overflow/underflow */
51
        unsigned char   waiting;        /* non-zero if a process wants access */
52
        unsigned char balance;  /* stereo channel balance */
53
 
54
        unsigned short minordev;
55
 
56
        /*
57
         * The following values are read-only state flags
58
         */
59
        unsigned char open;             /* non-zero if open access permitted */
60
        unsigned char active;           /* non-zero if I/O is active */
61
} audio_prinfo_t;
62
 
63
 
64
/*
65
 * This structure describes the current state of the audio device.
66
 */
67
typedef struct audio_info {
68
        /*
69
         * Per-stream information
70
         */
71
        audio_prinfo_t play;    /* output status information */
72
        audio_prinfo_t record;  /* input status information */
73
 
74
        /*
75
         * Per-unit/channel information
76
         */
77
        unsigned int monitor_gain;      /* input to output mix: 0 - 255 */
78
        unsigned char output_muted;     /* non-zero if output is muted */
79
        unsigned char _xxx[3];  /* Reserved for future use */
80
        unsigned int _yyy[3];           /* Reserved for future use */
81
} audio_info_t;
82
 
83
 
84
/*
85
 * Audio encoding types
86
 */
87
#define AUDIO_ENCODING_NONE     (0)     /* no encoding assigned   */
88
#define AUDIO_ENCODING_ULAW     (1)     /* u-law encoding         */
89
#define AUDIO_ENCODING_ALAW     (2)     /* A-law encoding         */
90
#define AUDIO_ENCODING_LINEAR   (3)     /* Linear PCM encoding    */
91
#define AUDIO_ENCODING_FLOAT    (4)     /* IEEE float (-1. <-> +1.) */
92
#define AUDIO_ENCODING_DVI      (104)   /* DVI ADPCM              */
93
#define AUDIO_ENCODING_LINEAR8  (105)   /* 8 bit UNSIGNED         */
94
#define AUDIO_ENCODING_LINEARLE (106)   /* Linear PCM LE encoding */
95
 
96
/*
97
 * These ranges apply to record, play, and monitor gain values
98
 */
99
#define AUDIO_MIN_GAIN  (0)     /* minimum gain value */
100
#define AUDIO_MAX_GAIN  (255)   /* maximum gain value */
101
 
102
/*
103
 * These values apply to the balance field to adjust channel gain values
104
 */
105
#define AUDIO_LEFT_BALANCE      (0)     /* left channel only    */
106
#define AUDIO_MID_BALANCE       (32)    /* equal left/right channel */
107
#define AUDIO_RIGHT_BALANCE     (64)    /* right channel only   */
108
#define AUDIO_BALANCE_SHIFT     (3)
109
 
110
/*
111
 * Generic minimum/maximum limits for number of channels, both modes
112
 */
113
#define AUDIO_MIN_PLAY_CHANNELS (1)
114
#define AUDIO_MAX_PLAY_CHANNELS (4)
115
#define AUDIO_MIN_REC_CHANNELS  (1)
116
#define AUDIO_MAX_REC_CHANNELS  (4)
117
 
118
/*
119
 * Generic minimum/maximum limits for sample precision
120
 */
121
#define AUDIO_MIN_PLAY_PRECISION        (8)
122
#define AUDIO_MAX_PLAY_PRECISION        (32)
123
#define AUDIO_MIN_REC_PRECISION         (8)
124
#define AUDIO_MAX_REC_PRECISION         (32)
125
 
126
/*
127
 * Define some convenient names for typical audio ports
128
 */
129
/*
130
 * output ports (several may be enabled simultaneously)
131
 */
132
#define AUDIO_SPEAKER           0x01    /* output to built-in speaker */
133
#define AUDIO_HEADPHONE         0x02    /* output to headphone jack */
134
#define AUDIO_LINE_OUT          0x04    /* output to line out    */
135
 
136
/*
137
 * input ports (usually only one at a time)
138
 */
139
#define AUDIO_MICROPHONE        0x01    /* input from microphone */
140
#define AUDIO_LINE_IN           0x02    /* input from line in    */
141
#define AUDIO_CD                0x04    /* input from on-board CD inputs */
142
#define AUDIO_INTERNAL_CD_IN    AUDIO_CD        /* input from internal CDROM */
143
#define AUDIO_ANALOG_LOOPBACK   0x40    /* input from output */
144
 
145
 
146
/*
147
 * This macro initializes an audio_info structure to 'harmless' values.
148
 * Note that (~0) might not be a harmless value for a flag that was
149
 * a signed int.
150
 */
151
#define AUDIO_INITINFO(i)       {                                       \
152
        unsigned int    *__x__;                                         \
153
        for (__x__ = (unsigned int *)(i);                               \
154
            (char *) __x__ < (((char *)(i)) + sizeof (audio_info_t));   \
155
            *__x__++ = ~0);                                              \
156
}
157
 
158
/*
159
 * These allow testing for what the user wants to set
160
 */
161
#define AUD_INITVALUE   (~0)
162
#define Modify(X)       ((unsigned int)(X) != AUD_INITVALUE)
163
#define Modifys(X)      ((X) != (unsigned short)AUD_INITVALUE)
164
#define Modifyc(X)      ((X) != (unsigned char)AUD_INITVALUE)
165
 
166
/*
167
 * Parameter for the AUDIO_GETDEV ioctl to determine current
168
 * audio devices.
169
 */
170
#define MAX_AUDIO_DEV_LEN       (16)
171
typedef struct audio_device {
172
        char name[MAX_AUDIO_DEV_LEN];
173
        char version[MAX_AUDIO_DEV_LEN];
174
        char config[MAX_AUDIO_DEV_LEN];
175
} audio_device_t;
176
 
177
 
178
/*
179
 * Ioctl calls for the audio device.
180
 */
181
 
182
/*
183
 * AUDIO_GETINFO retrieves the current state of the audio device.
184
 *
185
 * AUDIO_SETINFO copies all fields of the audio_info structure whose
186
 * values are not set to the initialized value (-1) to the device state.
187
 * It performs an implicit AUDIO_GETINFO to return the new state of the
188
 * device.  Note that the record.samples and play.samples fields are set
189
 * to the last value before the AUDIO_SETINFO took effect.  This allows
190
 * an application to reset the counters while atomically retrieving the
191
 * last value.
192
 *
193
 * AUDIO_DRAIN suspends the calling process until the write buffers are
194
 * empty.
195
 *
196
 * AUDIO_GETDEV returns a structure of type audio_device_t which contains
197
 * three strings.  The string "name" is a short identifying string (for
198
 * example, the SBus Fcode name string), the string "version" identifies
199
 * the current version of the device, and the "config" string identifies
200
 * the specific configuration of the audio stream.  All fields are
201
 * device-dependent -- see the device specific manual pages for details.
202
 *
203
 * AUDIO_GETDEV_SUNOS returns a number which is an audio device defined
204
 * herein (making it not too portable)
205
 *
206
 * AUDIO_FLUSH stops all playback and recording, clears all queued buffers,
207
 * resets error counters, and restarts recording and playback as appropriate
208
 * for the current sampling mode.
209
 */
210
#define AUDIO_GETINFO   _IOR('A', 1, audio_info_t)
211
#define AUDIO_SETINFO   _IOWR('A', 2, audio_info_t)
212
#define AUDIO_DRAIN     _IO('A', 3)
213
#define AUDIO_GETDEV    _IOR('A', 4, audio_device_t)
214
#define AUDIO_GETDEV_SUNOS      _IOR('A', 4, int)
215
#define AUDIO_FLUSH     _IO('A', 5)
216
 
217
/* Define possible audio hardware configurations for
218
 * old SunOS-style AUDIO_GETDEV ioctl */
219
#define AUDIO_DEV_UNKNOWN       (0)     /* not defined */
220
#define AUDIO_DEV_AMD           (1)     /* audioamd device */
221
#define AUDIO_DEV_SPEAKERBOX    (2)     /* dbri device with speakerbox */
222
#define AUDIO_DEV_CODEC         (3)     /* dbri device (internal speaker) */
223
#define AUDIO_DEV_CS4231        (5)     /* cs4231 device */
224
 
225
/*
226
 * The following ioctl sets the audio device into an internal loopback mode,
227
 * if the hardware supports this.  The argument is TRUE to set loopback,
228
 * FALSE to reset to normal operation.  If the hardware does not support
229
 * internal loopback, the ioctl should fail with EINVAL.
230
 * Causes ADC data to be digitally mixed in and sent to the DAC.
231
 */
232
#define AUDIO_DIAG_LOOPBACK     _IOW('A', 101, int)
233
 
234
/*
235
 *      Linux kernel internal implementation.
236
 */
237
 
238
#ifdef __KERNEL__
239
 
240
#include <linux/fs.h>
241
#include <linux/tqueue.h>
242
#include <linux/wait.h>
243
 
244
#define SDF_OPEN_WRITE  0x00000001
245
#define SDF_OPEN_READ   0x00000002
246
 
247
struct sparcaudio_ringbuffer
248
{
249
  __u8 *rb_start, *rb_end;              /* start, end of this memory buffer */
250
  __u8 *rb_in, *rb_out;                 /* input, output pointers */
251
 
252
  int rb_fragsize;                      /* size of an audio frag */
253
  int rb_numfrags;                      /* number of frags */
254
 
255
  int rb_count, rb_hiwat, rb_lowat;     /* bytes in use, hi/lo wat points */
256
 
257
  int rb_bufsize;                       /* total size of buffer */
258
};
259
 
260
struct sparcaudio_driver
261
{
262
        const char * name;
263
        struct sparcaudio_operations *ops;
264
        void *private;
265
        unsigned long flags;
266
        struct strevent *sd_siglist;
267
        /* duplex: 0=simplex, 1=duplex, 2=loop */
268
        int sd_sigflags, duplex;
269
 
270
        /* Which audio device are we? */
271
        int index;
272
 
273
        /* This device */
274
        struct sbus_dev *dev;
275
 
276
        /* Processes blocked on open() sit here. */
277
        wait_queue_head_t open_wait;
278
 
279
        /* Task queue for this driver's bottom half. */
280
        struct tq_struct tqueue;
281
 
282
        /* Start of ring buffer support */
283
        __u8 *input_buffer, *output_buffer;
284
 
285
        /* Support for a circular queue of output buffers. */
286
        __u8 **output_buffers;
287
        size_t *output_sizes, output_size, output_buffer_size;
288
        int num_output_buffers, output_front, output_rear, output_offset;
289
        int output_count, output_active, playing_count, output_eof;
290
        wait_queue_head_t output_write_wait, output_drain_wait;
291
        char *output_notify;
292
 
293
        /* Support for a circular queue of input buffers. */
294
        __u8 **input_buffers;
295
        size_t *input_sizes, input_size, input_buffer_size;
296
        int num_input_buffers, input_front, input_rear, input_offset;
297
        int input_count, input_active, recording_count;
298
        wait_queue_head_t input_read_wait;
299
 
300
        /* Hack to make it look like we support variable size buffers. */
301
        int buffer_size;
302
 
303
        int mixer_modify_counter;
304
};
305
 
306
struct sparcaudio_operations
307
{
308
        int (*open)(struct inode *, struct file *, struct sparcaudio_driver *);
309
        void (*release)(struct inode *, struct file *, struct sparcaudio_driver *);
310
        int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long,
311
                     struct sparcaudio_driver *);
312
 
313
        /* Ask driver to begin playing a buffer. */
314
        void (*start_output)(struct sparcaudio_driver *, __u8 *, unsigned long);
315
 
316
        /* Ask driver to stop playing a buffer. */
317
        void (*stop_output)(struct sparcaudio_driver *);
318
 
319
        /* Ask driver to begin recording into a buffer. */
320
        void (*start_input)(struct sparcaudio_driver *, __u8 *, unsigned long);
321
 
322
        /* Ask driver to stop recording. */
323
        void (*stop_input)(struct sparcaudio_driver *);
324
 
325
        /* Return driver name/version to caller. (/dev/audio specific) */
326
        void (*sunaudio_getdev)(struct sparcaudio_driver *, audio_device_t *);
327
 
328
        /* Get and set the output volume. (0-255) */
329
        int (*set_output_volume)(struct sparcaudio_driver *, int);
330
        int (*get_output_volume)(struct sparcaudio_driver *);
331
 
332
        /* Get and set the input volume. (0-255) */
333
        int (*set_input_volume)(struct sparcaudio_driver *, int);
334
        int (*get_input_volume)(struct sparcaudio_driver *);
335
 
336
        /* Get and set the monitor volume. (0-255) */
337
        int (*set_monitor_volume)(struct sparcaudio_driver *, int);
338
        int (*get_monitor_volume)(struct sparcaudio_driver *);
339
 
340
        /* Get and set the output balance. (0-64) */
341
        int (*set_output_balance)(struct sparcaudio_driver *, int);
342
        int (*get_output_balance)(struct sparcaudio_driver *);
343
 
344
        /* Get and set the input balance. (0-64) */
345
        int (*set_input_balance)(struct sparcaudio_driver *, int);
346
        int (*get_input_balance)(struct sparcaudio_driver *);
347
 
348
        /* Get and set the output channels. (1-4) */
349
        int (*set_output_channels)(struct sparcaudio_driver *, int);
350
        int (*get_output_channels)(struct sparcaudio_driver *);
351
 
352
        /* Get and set the input channels. (1-4) */
353
        int (*set_input_channels)(struct sparcaudio_driver *, int);
354
        int (*get_input_channels)(struct sparcaudio_driver *);
355
 
356
        /* Get and set the output precision. (8-32) */
357
        int (*set_output_precision)(struct sparcaudio_driver *, int);
358
        int (*get_output_precision)(struct sparcaudio_driver *);
359
 
360
        /* Get and set the input precision. (8-32) */
361
        int (*set_input_precision)(struct sparcaudio_driver *, int);
362
        int (*get_input_precision)(struct sparcaudio_driver *);
363
 
364
        /* Get and set the output port. () */
365
        int (*set_output_port)(struct sparcaudio_driver *, int);
366
        int (*get_output_port)(struct sparcaudio_driver *);
367
 
368
        /* Get and set the input port. () */
369
        int (*set_input_port)(struct sparcaudio_driver *, int);
370
        int (*get_input_port)(struct sparcaudio_driver *);
371
 
372
        /* Get and set the output encoding. () */
373
        int (*set_output_encoding)(struct sparcaudio_driver *, int);
374
        int (*get_output_encoding)(struct sparcaudio_driver *);
375
 
376
        /* Get and set the input encoding. () */
377
        int (*set_input_encoding)(struct sparcaudio_driver *, int);
378
        int (*get_input_encoding)(struct sparcaudio_driver *);
379
 
380
        /* Get and set the output rate. () */
381
        int (*set_output_rate)(struct sparcaudio_driver *, int);
382
        int (*get_output_rate)(struct sparcaudio_driver *);
383
 
384
        /* Get and set the input rate. () */
385
        int (*set_input_rate)(struct sparcaudio_driver *, int);
386
        int (*get_input_rate)(struct sparcaudio_driver *);
387
 
388
        /* Return driver number to caller. (SunOS /dev/audio specific) */
389
        int (*sunaudio_getdev_sunos)(struct sparcaudio_driver *);
390
 
391
        /* Get available ports */
392
        int (*get_output_ports)(struct sparcaudio_driver *);
393
        int (*get_input_ports)(struct sparcaudio_driver *);
394
 
395
        /* Get and set output mute */
396
        int (*set_output_muted)(struct sparcaudio_driver *, int);
397
        int (*get_output_muted)(struct sparcaudio_driver *);
398
 
399
        /* Get and set output pause */
400
        int (*set_output_pause)(struct sparcaudio_driver *, int);
401
        int (*get_output_pause)(struct sparcaudio_driver *);
402
 
403
        /* Get and set input pause */
404
        int (*set_input_pause)(struct sparcaudio_driver *, int);
405
        int (*get_input_pause)(struct sparcaudio_driver *);
406
 
407
        /* Get and set output samples */
408
        int (*set_output_samples)(struct sparcaudio_driver *, int);
409
        int (*get_output_samples)(struct sparcaudio_driver *);
410
 
411
        /* Get and set input samples */
412
        int (*set_input_samples)(struct sparcaudio_driver *, int);
413
        int (*get_input_samples)(struct sparcaudio_driver *);
414
 
415
        /* Get and set output error */
416
        int (*set_output_error)(struct sparcaudio_driver *, int);
417
        int (*get_output_error)(struct sparcaudio_driver *);
418
 
419
        /* Get and set input error */
420
        int (*set_input_error)(struct sparcaudio_driver *, int);
421
        int (*get_input_error)(struct sparcaudio_driver *);
422
 
423
        /* Get supported encodings */
424
        int (*get_formats)(struct sparcaudio_driver *);
425
};
426
 
427
extern int register_sparcaudio_driver(struct sparcaudio_driver *, int);
428
extern int unregister_sparcaudio_driver(struct sparcaudio_driver *, int);
429
extern void sparcaudio_output_done(struct sparcaudio_driver *, int);
430
extern void sparcaudio_input_done(struct sparcaudio_driver *, int);
431
 
432
#endif
433
 
434
/* Device minor numbers */
435
 
436
#define SPARCAUDIO_MIXER_MINOR 0
437
/* No sequencer (1) */
438
/* No midi (2) */
439
#define SPARCAUDIO_DSP_MINOR   3
440
#define SPARCAUDIO_AUDIO_MINOR 4
441
#define SPARCAUDIO_DSP16_MINOR 5
442
#define SPARCAUDIO_STATUS_MINOR 6
443
#define SPARCAUDIO_AUDIOCTL_MINOR 7
444
/* No sequencer l2 (8) */
445
/* No sound processor (9) */
446
 
447
/* allocate 2^SPARCAUDIO_DEVICE_SHIFT minors per audio device */
448
#define SPARCAUDIO_DEVICE_SHIFT 4
449
 
450
/* With the coming of dummy devices this should perhaps be as high as 5? */
451
#define SPARCAUDIO_MAX_DEVICES 3
452
 
453
/* Streams crap for realaudio */
454
 
455
typedef
456
struct strevent {
457
    struct strevent *se_next;   /* next event for this stream or NULL*/
458
    struct strevent *se_prev;   /* previous event for this stream or last
459
                                 * event if this is the first one*/
460
    pid_t se_pid;               /* process to be signaled */
461
    short se_evs;               /* events wanted */
462
} strevent_t;
463
 
464
typedef
465
struct stdata
466
{
467
        struct stdata    *sd_next ;     /* all stdatas are linked together */
468
        struct stdata    *sd_prev ;
469
        struct strevent   *sd_siglist;  /* processes to be sent SIGPOLL */
470
        int  sd_sigflags;               /* logical OR of all siglist events */
471
} stdata_t;
472
 
473
#define I_NREAD _IOR('S',01, int)
474
#define I_NREAD_SOLARIS (('S'<<8)|1)
475
 
476
#define I_FLUSH _IO('S',05)
477
#define I_FLUSH_SOLARIS (('S'<<8)|5)
478
#define FLUSHR  1                       /* flush read queue */
479
#define FLUSHW  2                       /* flush write queue */
480
#define FLUSHRW 3                       /* flush both queues */
481
 
482
#define I_SETSIG _IO('S',011)
483
#define I_SETSIG_SOLARIS (('S'<<8)|11)
484
#define S_INPUT         0x01
485
#define S_HIPRI         0x02           
486
#define S_OUTPUT        0x04           
487
#define S_MSG           0x08           
488
#define S_ERROR         0x0010         
489
#define S_HANGUP        0x0020         
490
#define S_RDNORM        0x0040         
491
#define S_WRNORM        S_OUTPUT
492
#define S_RDBAND        0x0080         
493
#define S_WRBAND        0x0100         
494
#define S_BANDURG       0x0200         
495
#define S_ALL           0x03FF
496
 
497
#define I_GETSIG _IOR('S',012,int)
498
#define I_GETSIG_SOLARIS (('S'<<8)|12)
499
 
500
/* Conversion between Sun and OSS volume settings */
501
static __inline__
502
int OSS_LEFT(int value)
503
{
504
  return ((value & 0xff) % 101);
505
}
506
 
507
static __inline__
508
int OSS_RIGHT(int value)
509
{
510
  return  (((value >> 8) & 0xff) % 101);
511
}
512
 
513
static __inline__
514
int O_TO_S(int value)
515
{
516
  return value * 255 / 100;
517
}
518
 
519
static __inline__
520
int S_TO_O(int value)
521
{
522
  return value * 100 / 255;
523
}
524
 
525
static __inline__
526
int OSS_TO_GAIN(int value)
527
{
528
  int l = O_TO_S(OSS_LEFT(value));
529
  int r = O_TO_S(OSS_RIGHT(value));
530
  return ((l > r) ? l : r);
531
}
532
 
533
static __inline__
534
int OSS_TO_LGAIN(int value)
535
{
536
  int l = O_TO_S(OSS_LEFT(value));
537
  int r = O_TO_S(OSS_RIGHT(value));
538
  return ((l < r) ? l : r);
539
}
540
 
541
static __inline__
542
int OSS_TO_BAL(int value)
543
{
544
  if (!OSS_TO_GAIN(value))
545
    return AUDIO_MID_BALANCE;
546
  if (!OSS_TO_LGAIN(value)) {
547
    if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value)))
548
      return AUDIO_RIGHT_BALANCE;
549
    else
550
      return AUDIO_LEFT_BALANCE;
551
  }
552
  if (OSS_TO_GAIN(value) == OSS_TO_GAIN(OSS_RIGHT(value)))
553
    return ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value)) >> AUDIO_BALANCE_SHIFT)
554
      + AUDIO_MID_BALANCE;
555
  else
556
    return AUDIO_MID_BALANCE - ((OSS_TO_GAIN(value) - OSS_TO_LGAIN(value))
557
                                >> AUDIO_BALANCE_SHIFT);
558
}
559
 
560
static __inline__
561
int BAL_TO_OSS(int value, unsigned char balance)
562
{
563
  int l, r, adj;
564
  if (balance > 63) balance = 63;
565
  if (balance < AUDIO_MID_BALANCE) {
566
    l = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
567
    adj = ((AUDIO_MID_BALANCE - balance) << AUDIO_BALANCE_SHIFT);
568
    if (adj < value)
569
      r = (int)(value - adj)
570
        * 100 / 255;
571
    else r = 0;
572
  } else if (balance > AUDIO_MID_BALANCE) {
573
    r = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
574
    adj = ((balance - AUDIO_MID_BALANCE) << AUDIO_BALANCE_SHIFT);
575
    if (adj < value)
576
      l = (int)(value - adj)
577
        * 100 / 255;
578
    else l = 0;
579
  } else {
580
    l = r = (int)value * 100 / 255 + ((value * 100 % 255) > 0);
581
  }
582
 
583
  return ((r << 8) + l);
584
}
585
 
586
#ifdef __KERNEL__
587
/* OSS mixer ioctl port handling */
588
static __inline__
589
int OSS_PORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set)
590
{
591
  int p;
592
  if (drv->ops->get_output_port) {
593
    p = drv->ops->get_output_port(drv);
594
    if (p & set)
595
      return 0x6464;
596
  }
597
  return 0;
598
}
599
 
600
static __inline__
601
int OSS_IPORT_AUDIO(struct sparcaudio_driver *drv, unsigned int set)
602
{
603
  int p;
604
  if (drv->ops->get_input_port) {
605
    p = drv->ops->get_input_port(drv);
606
    if (p & set)
607
      return 0x6464;
608
  }
609
  return 0;
610
}
611
 
612
static __inline__
613
void OSS_TWIDDLE_PORT(struct sparcaudio_driver *drv, unsigned int ioctl,
614
                      unsigned int port, unsigned int set, unsigned int value)
615
{
616
  if (ioctl == port) {
617
    int p;
618
    if (drv->ops->get_output_port && drv->ops->set_output_port) {
619
      p = drv->ops->get_output_port(drv);
620
      if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100)))
621
        drv->ops->set_output_port(drv, p & ~(set));
622
      else
623
        drv->ops->set_output_port(drv, p | set);
624
    }
625
  }
626
}
627
 
628
static __inline__
629
void OSS_TWIDDLE_IPORT(struct sparcaudio_driver *drv, unsigned int ioctl,
630
                      unsigned int port, unsigned int set, unsigned int value)
631
{
632
  if (ioctl == port) {
633
    int p;
634
    if (drv->ops->get_input_port && drv->ops->set_input_port) {
635
      p = drv->ops->get_input_port(drv);
636
      if ((value == 0) || ((p & set) && (OSS_LEFT(value) < 100)))
637
        drv->ops->set_input_port(drv, p & ~(set));
638
      else
639
        drv->ops->set_input_port(drv, p | set);
640
    }
641
  }
642
}
643
#endif /* __KERNEL__ */
644
#endif /* _AUDIOIO_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.