annotate playercode/unix_drv/drv_hp.c @ 21:eb5b14d0e054

Makefile unneeded rule mikmodux.h Fix MODULE
author darius
date Fri, 24 Apr 1998 08:04:39 +0000
parents b30908f9d9f9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4 drv_hp.c
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 Description:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7 Mikmod driver for output to HP 9000 series /dev/audio
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 Portability:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11 HP-UX only
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 Written by Lutz Vieweg <lkv@mania.robin.de>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14 based on drv_raw.c
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16 Feel free to distribute just as you like.
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17 No warranties at all.
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19 */
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 #include <stdio.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22 #include <stdlib.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24 #include <sys/audio.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 #include <unistd.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26 #include <fcntl.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 #include <sys/ioctl.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29 #include "mikmod.h"
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31 static int fd;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32 #define RAWBUFFERSIZE 16384
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33 static char RAW_DMABUF[RAWBUFFERSIZE];
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 static BOOL HP_IsThere(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37 return 1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 static BOOL HP_Init(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42 int flags;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 if (! (md_mode & DMODE_16BITS)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45 myerr = "sorry, this driver supports 16-bit linear output only";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49 if ((fd = open("/dev/audio", O_WRONLY | O_NDELAY, 0)) < 0) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50 myerr = "unable to open /dev/audio";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54 if ((flags = fcntl (fd, F_GETFL, 0)) < 0) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55 myerr = "unable to set non-blocking mode for /dev/audio";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 flags |= O_NDELAY;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59 if (fcntl (fd, F_SETFL, flags) < 0) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 myerr = "unable to set non-blocking mode for /dev/audio";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64 if (ioctl(fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR16BIT)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 myerr = "unable to select 16bit-linear sample format";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69 if (ioctl(fd, AUDIO_SET_SAMPLE_RATE, md_mixfreq)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70 myerr = "unable to select requested sample-rate";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74 if (ioctl(fd, AUDIO_SET_CHANNELS, (md_mode & DMODE_STEREO)? 2 : 1)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75 myerr = "unable to select requested number of channels";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 /*
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80 choose between:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 AUDIO_OUT_SPEAKER
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 AUDIO_OUT_HEADPHONE
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 AUDIO_OUT_LINE
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 */
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 if (ioctl(fd, AUDIO_SET_OUTPUT,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86 AUDIO_OUT_SPEAKER | AUDIO_OUT_HEADPHONE | AUDIO_OUT_LINE)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87 myerr = "unable to select audio output";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 struct audio_describe description;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93 struct audio_gains gains;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 float volume = 1.0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 if (ioctl(fd, AUDIO_DESCRIBE, &description)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 myerr = "unable to get audio description";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 if (ioctl (fd, AUDIO_GET_GAINS, &gains)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100 myerr = "unable to get gain values";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104 gains.transmit_gain = (int)((float)description.min_transmit_gain +
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 (float)(description.max_transmit_gain
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 - description.min_transmit_gain)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 * volume);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 if (ioctl (fd, AUDIO_SET_GAINS, &gains)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109 myerr = "unable to set gain values";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 if (ioctl(fd, AUDIO_SET_TXBUFSIZE, RAWBUFFERSIZE*8)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 myerr = "unable to set transmission buffer size";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 if(!VC_Init()){
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120 close(fd);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124 return 1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129 static void HP_Exit(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131 VC_Exit();
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132 close(fd);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136 static void HP_Update(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138 VC_WriteBytes(RAW_DMABUF,RAWBUFFERSIZE);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139 write(fd, RAW_DMABUF, RAWBUFFERSIZE);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143 DRIVER drv_hp={
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144 NULL,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 "HP-UX /dev/audio",
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 "MikMod HP-UX /dev/audio driver v1.10",
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147 HP_IsThere,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148 VC_SampleLoad,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149 VC_SampleUnload,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150 VC_SampleSpace,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151 VC_SampleLength,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 HP_Init,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153 HP_Exit,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154 VC_SetNumChannels,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155 VC_PlayStart,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 VC_PlayStop,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 HP_Update,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158 VC_VoiceSetVolume,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159 VC_VoiceSetFrequency,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160 VC_VoiceSetPanning,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161 VC_VoicePlay,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 VC_VoiceStop,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163 VC_VoiceStopped,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164 VC_VoiceReleaseSustain,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 VC_VoiceGetPosition,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166 VC_RealVolume
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 };