Lines Matching +full:0 +full:m
56 #define MPU_DATAPORT 0
59 #define MPU_RESET 0xff
60 #define MPU_UART 0x3f
61 #define MPU_ACK 0xfe
62 #define MPU_STATMASK 0xc0
63 #define MPU_OUTPUTBUSY 0x40
64 #define MPU_INPUTBUSY 0x80
68 #define CMD(m,d) MPUFOI_WRITE(m, m->cookie, MPU_CMDPORT,d)
69 #define STATUS(m) MPUFOI_READ(m, m->cookie, MPU_STATPORT)
70 #define READ(m) MPUFOI_READ(m, m->cookie, MPU_DATAPORT)
71 #define WRITE(m,d) MPUFOI_WRITE(m, m->cookie, MPU_DATAPORT,d)
82 static void mpu401_timeout(void *m);
106 DEFINE_CLASS(mpu401, mpu401_methods, 0);
111 struct mpu401 *m = (struct mpu401 *)a;
113 if (m->si)
114 (m->si)(m->cookie);
118 mpu401_intr(struct mpu401 *m)
128 #define RXRDY(m) ( (STATUS(m) & MPU_INPUTBUSY) == 0)
129 #define TXRDY(m) ( (STATUS(m) & MPU_OUTPUTBUSY) == 0)
130 #if 0
135 i = 0;
136 s = STATUS(m);
138 while ((s & MPU_INPUTBUSY) == 0 && i < MPU_INTR_BUF) {
139 b[i] = READ(m);
144 s = STATUS(m);
147 midi_in(m->mid, b, i);
148 i = 0;
150 if (midi_out(m->mid, b, 1)) {
152 printf("mpu401_intr out i %d d %d\n", i, b[0]);
155 WRITE(m, *b);
160 return 0;
164 s = STATUS(m);
167 if ((m->flags & M_TXEN) && (m->si)) {
168 callout_reset(&m->timer, 1, mpu401_timeout, m);
170 return (m->flags & M_TXEN) == M_TXEN;
177 struct mpu401 *m;
180 m = malloc(sizeof(*m), M_MIDI, M_NOWAIT | M_ZERO);
182 if (!m)
185 kobj_init((kobj_t)m, cls);
187 callout_init(&m->timer, 1);
189 m->si = softintr;
190 m->cookie = cookie;
191 m->flags = 0;
193 m->mid = midi_init(&mpu401_class, 0, 0, m);
194 if (!m->mid)
197 return m;
200 free(m, M_MIDI);
205 mpu401_uninit(struct mpu401 *m)
209 CMD(m, MPU_RESET);
210 retval = midi_uninit(m->mid);
213 free(m, M_MIDI);
214 return 0;
220 struct mpu401 *m = arg;
223 CMD(m, MPU_RESET);
224 CMD(m, MPU_UART);
225 return 0;
226 i = 0;
228 if (RXRDY(m))
229 if (READ(m) == MPU_ACK)
234 CMD(m, MPU_UART);
235 return 0;
244 struct mpu401 *m = arg;
246 return MPUFOI_UNINIT(m, m->cookie);
264 struct mpu401 *m = arg;
265 #if 0
272 if (flags & M_TXEN && m->si) {
273 callout_reset(&m->timer, 1, mpu401_timeout, m);
275 m->flags = flags;
293 mpu401_mprovider(struct snd_midi *m, void *arg)