@@ -287,25 +287,37 @@ static int cvt_legacy_system_to_ump(struct ump_cvt_to_ump *cvt,
287
287
return 4 ;
288
288
}
289
289
290
- static void fill_rpn (struct ump_cvt_to_ump_bank * cc ,
291
- union snd_ump_midi2_msg * midi2 )
290
+ static int fill_rpn (struct ump_cvt_to_ump_bank * cc ,
291
+ union snd_ump_midi2_msg * midi2 ,
292
+ bool flush )
292
293
{
294
+ if (!(cc -> cc_data_lsb_set || cc -> cc_data_msb_set ))
295
+ return 0 ; // skip
296
+ /* when not flushing, wait for complete data set */
297
+ if (!flush && (!cc -> cc_data_lsb_set || !cc -> cc_data_msb_set ))
298
+ return 0 ; // skip
299
+
293
300
if (cc -> rpn_set ) {
294
301
midi2 -> rpn .status = UMP_MSG_STATUS_RPN ;
295
302
midi2 -> rpn .bank = cc -> cc_rpn_msb ;
296
303
midi2 -> rpn .index = cc -> cc_rpn_lsb ;
297
- cc -> rpn_set = 0 ;
298
- cc -> cc_rpn_msb = cc -> cc_rpn_lsb = 0 ;
299
- } else {
304
+ } else if (cc -> nrpn_set ) {
300
305
midi2 -> rpn .status = UMP_MSG_STATUS_NRPN ;
301
306
midi2 -> rpn .bank = cc -> cc_nrpn_msb ;
302
307
midi2 -> rpn .index = cc -> cc_nrpn_lsb ;
303
- cc -> nrpn_set = 0 ;
304
- cc -> cc_nrpn_msb = cc -> cc_nrpn_lsb = 0 ;
308
+ } else {
309
+ return 0 ; // skip
305
310
}
311
+
306
312
midi2 -> rpn .data = upscale_14_to_32bit ((cc -> cc_data_msb << 7 ) |
307
313
cc -> cc_data_lsb );
314
+
315
+ cc -> rpn_set = 0 ;
316
+ cc -> nrpn_set = 0 ;
317
+ cc -> cc_rpn_msb = cc -> cc_rpn_lsb = 0 ;
308
318
cc -> cc_data_msb = cc -> cc_data_lsb = 0 ;
319
+ cc -> cc_data_msb_set = cc -> cc_data_lsb_set = 0 ;
320
+ return 1 ;
309
321
}
310
322
311
323
/* convert to a MIDI 1.0 Channel Voice message */
@@ -318,6 +330,7 @@ static int cvt_legacy_cmd_to_ump(struct ump_cvt_to_ump *cvt,
318
330
struct ump_cvt_to_ump_bank * cc ;
319
331
union snd_ump_midi2_msg * midi2 = (union snd_ump_midi2_msg * )data ;
320
332
unsigned char status , channel ;
333
+ int ret ;
321
334
322
335
BUILD_BUG_ON (sizeof (union snd_ump_midi1_msg ) != 4 );
323
336
BUILD_BUG_ON (sizeof (union snd_ump_midi2_msg ) != 8 );
@@ -358,24 +371,29 @@ static int cvt_legacy_cmd_to_ump(struct ump_cvt_to_ump *cvt,
358
371
case UMP_MSG_STATUS_CC :
359
372
switch (buf [1 ]) {
360
373
case UMP_CC_RPN_MSB :
374
+ ret = fill_rpn (cc , midi2 , true);
361
375
cc -> rpn_set = 1 ;
362
376
cc -> cc_rpn_msb = buf [2 ];
363
- return 0 ; // skip
377
+ return ret ;
364
378
case UMP_CC_RPN_LSB :
379
+ ret = fill_rpn (cc , midi2 , true);
365
380
cc -> rpn_set = 1 ;
366
381
cc -> cc_rpn_lsb = buf [2 ];
367
- return 0 ; // skip
382
+ return ret ;
368
383
case UMP_CC_NRPN_MSB :
384
+ ret = fill_rpn (cc , midi2 , true);
369
385
cc -> nrpn_set = 1 ;
370
386
cc -> cc_nrpn_msb = buf [2 ];
371
- return 0 ; // skip
387
+ return ret ;
372
388
case UMP_CC_NRPN_LSB :
389
+ ret = fill_rpn (cc , midi2 , true);
373
390
cc -> nrpn_set = 1 ;
374
391
cc -> cc_nrpn_lsb = buf [2 ];
375
- return 0 ; // skip
392
+ return ret ;
376
393
case UMP_CC_DATA :
394
+ cc -> cc_data_msb_set = 1 ;
377
395
cc -> cc_data_msb = buf [2 ];
378
- return 0 ; // skip
396
+ return fill_rpn ( cc , midi2 , false);
379
397
case UMP_CC_BANK_SELECT :
380
398
cc -> bank_set = 1 ;
381
399
cc -> cc_bank_msb = buf [2 ];
@@ -385,12 +403,9 @@ static int cvt_legacy_cmd_to_ump(struct ump_cvt_to_ump *cvt,
385
403
cc -> cc_bank_lsb = buf [2 ];
386
404
return 0 ; // skip
387
405
case UMP_CC_DATA_LSB :
406
+ cc -> cc_data_lsb_set = 1 ;
388
407
cc -> cc_data_lsb = buf [2 ];
389
- if (cc -> rpn_set || cc -> nrpn_set )
390
- fill_rpn (cc , midi2 );
391
- else
392
- return 0 ; // skip
393
- break ;
408
+ return fill_rpn (cc , midi2 , false);
394
409
default :
395
410
midi2 -> cc .index = buf [1 ];
396
411
midi2 -> cc .data = upscale_7_to_32bit (buf [2 ]);
0 commit comments