Lines Matching refs:mc
80 static void reset_all_controllers(midictl *mc, uint_fast8_t chan);
81 static void enter14(midictl *mc, uint_fast8_t chan, class c,
83 static uint_fast16_t read14(midictl *mc, uint_fast8_t chan, class c,
170 midictl_open(midictl *mc) in midictl_open() argument
175 if (mc->lock == NULL) in midictl_open()
177 if (NULL == mc->notify) in midictl_open()
178 mc->notify = notify_no_one; in midictl_open()
182 s->lock = mc->lock; in midictl_open()
193 mc->store = s; in midictl_open()
198 midictl_close(midictl *mc) in midictl_close() argument
203 s = mc->store; in midictl_close()
213 midictl_change(midictl *mc, uint_fast8_t chan, uint8_t *ctlval) in midictl_change() argument
219 KASSERT(mutex_owned(mc->lock)); in midictl_change()
220 KASSERT(!mc->store->destroy); in midictl_change()
230 if ( chan != mc->base_channel ) in midictl_change()
235 mc->notify(mc->cookie, MIDICTL_NOTES_OFF, chan, 0); in midictl_change()
238 mc->notify(mc->cookie, MIDICTL_LOCAL, chan, ctlval[1]); in midictl_change()
241 mc->notify(mc->cookie, MIDICTL_SOUND_OFF, chan, 0); in midictl_change()
244 reset_all_controllers(mc, chan); in midictl_change()
250 mc-> rpn &= ~0x7f; in midictl_change()
251 mc-> rpn |= PN_SET | (0x7f & ctlval[1]); in midictl_change()
252 mc->nrpn &= ~PN_SET; in midictl_change()
255 mc-> rpn &= ~0x7fU<<7; in midictl_change()
256 mc-> rpn |= PN_SET | (0x7f & ctlval[1])<<7; in midictl_change()
257 mc->nrpn &= ~PN_SET; in midictl_change()
260 mc->nrpn &= ~0x7f; in midictl_change()
261 mc->nrpn |= PN_SET | (0x7f & ctlval[1]); in midictl_change()
262 mc-> rpn &= ~PN_SET; in midictl_change()
265 mc->nrpn &= ~0x7fU<<7; in midictl_change()
266 mc->nrpn |= PN_SET | (0x7f & ctlval[1])<<7; in midictl_change()
267 mc-> rpn &= ~PN_SET; in midictl_change()
275 if ( 0 == ( (mc->rpn ^ mc->nrpn) & PN_SET ) ) in midictl_change()
277 if ( mc->rpn & PN_SET ) { in midictl_change()
278 key = mc->rpn; in midictl_change()
281 key = mc->nrpn; in midictl_change()
287 enter14(mc, chan, c, key, islsb, ctlval[1]); in midictl_change()
305 enter14(mc, chan, c, key, islsb, ctlval[1]); in midictl_change()
308 present = store_locate(mc->store, c, chan, key); in midictl_change()
309 if ( !mc->accept_any_ctl_rpn ) { in midictl_change()
312 val = store_extract(mc->store, c, chan, key); in midictl_change()
316 store_update(mc->store, c, chan, key, in midictl_change()
318 mc->notify(mc->cookie, MIDICTL_CTLR, chan, key); in midictl_change()
321 present = store_locate(mc->store, c, chan, key); in midictl_change()
322 if ( !mc->accept_any_ctl_rpn ) { in midictl_change()
325 val = store_extract(mc->store, c, chan, key); in midictl_change()
329 store_update(mc->store, c, chan, key, in midictl_change()
331 mc->notify(mc->cookie, MIDICTL_CTLR, chan, key); in midictl_change()
340 midictl_read(midictl *mc, uint_fast8_t chan, uint_fast8_t ctlr, in midictl_read() argument
347 KASSERT(mutex_owned(mc->lock)); in midictl_read()
348 KASSERT(!mc->store->destroy); in midictl_read()
354 present = store_locate(mc->store, c, chan, key); in midictl_read()
356 !(C1_SET&(val = store_extract(mc->store, c, chan, key))) ) { in midictl_read()
358 store_update(mc->store, c, chan, key, val); in midictl_read()
362 present = store_locate(mc->store, c, chan, key); in midictl_read()
364 !(C7_SET&(val = store_extract(mc->store, c, chan, key))) ) { in midictl_read()
366 store_update(mc->store, c, chan, key, val); in midictl_read()
371 return read14(mc, chan, c, key, dflt); in midictl_read()
380 midictl_rpn_read(midictl *mc, uint_fast8_t chan, uint_fast16_t ctlr, in midictl_rpn_read() argument
384 KASSERT(mutex_owned(mc->lock)); in midictl_rpn_read()
385 KASSERT(!mc->store->destroy); in midictl_rpn_read()
387 return read14(mc, chan, RPN, ctlr, dflt); in midictl_rpn_read()
391 midictl_nrpn_read(midictl *mc, uint_fast8_t chan, uint_fast16_t ctlr, in midictl_nrpn_read() argument
395 KASSERT(mutex_owned(mc->lock)); in midictl_nrpn_read()
396 KASSERT(!mc->store->destroy); in midictl_nrpn_read()
398 return read14(mc, chan, NRPN, ctlr, dflt); in midictl_nrpn_read()
402 reset_all_controllers(midictl *mc, uint_fast8_t chan) in reset_all_controllers() argument
408 KASSERT(mutex_owned(mc->lock)); in reset_all_controllers()
437 present = store_locate(mc->store, c, chan, key); in reset_all_controllers()
440 store_update(mc->store, c, chan, key, 0); /* no C*SET */ in reset_all_controllers()
443 mc->notify(mc->cookie, MIDICTL_RESET, chan, 0); in reset_all_controllers()
447 enter14(midictl *mc, uint_fast8_t chan, class c, uint_fast16_t key, in enter14() argument
453 KASSERT(mutex_owned(mc->lock)); in enter14()
455 present = store_locate(mc->store, c, chan, key); in enter14()
456 stval = (present) ? store_extract(mc->store, c, chan, key) : 0; in enter14()
458 if ( !((NRPN==c)? mc->accept_any_nrpn: mc->accept_any_ctl_rpn) ) in enter14()
465 store_update(mc->store, c, chan, key, stval); in enter14()
466 mc->notify(mc->cookie, CTL14 == c ? MIDICTL_CTLR in enter14()
472 read14(midictl *mc, uint_fast8_t chan, class c, uint_fast16_t key, in read14() argument
478 KASSERT(mutex_owned(mc->lock)); in read14()
480 present = store_locate(mc->store, c, chan, key); in read14()
484 val = store_extract(mc->store, c, chan, key); in read14()
498 store_update(mc->store, c, chan, key, val); in read14()