8
8
#include <sound/core.h>
9
9
#include <sound/asound.h>
10
10
#include <sound/ump.h>
11
- #include " ump_convert.h"
11
+ #include <sound/ ump_convert.h>
12
12
13
13
/*
14
14
* Upgrade / downgrade value bits
@@ -205,12 +205,18 @@ static int cvt_ump_sysex7_to_legacy(const u32 *data, unsigned char *buf)
205
205
return size ;
206
206
}
207
207
208
- /* convert from a UMP packet @data to MIDI 1.0 bytes at @buf;
209
- * the target group is stored at @group_ret,
210
- * returns the number of bytes of MIDI 1.0 stream
208
+ /**
209
+ * snd_ump_convert_from_ump - convert from UMP to legacy MIDI
210
+ * @data: UMP packet
211
+ * @buf: buffer to store legacy MIDI data
212
+ * @group_ret: pointer to store the target group
213
+ *
214
+ * Convert from a UMP packet @data to MIDI 1.0 bytes at @buf.
215
+ * The target group is stored at @group_ret.
216
+ *
217
+ * The function returns the number of bytes of MIDI 1.0 stream.
211
218
*/
212
- int snd_ump_convert_from_ump (struct snd_ump_endpoint * ump ,
213
- const u32 * data ,
219
+ int snd_ump_convert_from_ump (const u32 * data ,
214
220
unsigned char * buf ,
215
221
unsigned char * group_ret )
216
222
{
@@ -230,6 +236,7 @@ int snd_ump_convert_from_ump(struct snd_ump_endpoint *ump,
230
236
231
237
return 0 ;
232
238
}
239
+ EXPORT_SYMBOL_GPL (snd_ump_convert_from_ump );
233
240
234
241
/*
235
242
* MIDI 1 byte stream -> UMP conversion
@@ -302,10 +309,10 @@ static void fill_rpn(struct ump_cvt_to_ump_bank *cc,
302
309
}
303
310
304
311
/* convert to a MIDI 1.0 Channel Voice message */
305
- static int cvt_legacy_cmd_to_ump (struct snd_ump_endpoint * ump ,
306
- struct ump_cvt_to_ump * cvt ,
307
- unsigned char group , u32 * data ,
308
- unsigned char bytes )
312
+ static int cvt_legacy_cmd_to_ump (struct ump_cvt_to_ump * cvt ,
313
+ unsigned char group ,
314
+ unsigned int protocol ,
315
+ u32 * data , unsigned char bytes )
309
316
{
310
317
const unsigned char * buf = cvt -> buf ;
311
318
struct ump_cvt_to_ump_bank * cc ;
@@ -316,7 +323,7 @@ static int cvt_legacy_cmd_to_ump(struct snd_ump_endpoint *ump,
316
323
BUILD_BUG_ON (sizeof (union snd_ump_midi2_msg ) != 8 );
317
324
318
325
/* for MIDI 1.0 UMP, it's easy, just pack it into UMP */
319
- if (ump -> info . protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI1 ) {
326
+ if (protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI1 ) {
320
327
data [0 ] = ump_compose (UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE ,
321
328
group , 0 , buf [0 ]);
322
329
data [0 ] |= buf [1 ] << 8 ;
@@ -413,8 +420,8 @@ static int cvt_legacy_cmd_to_ump(struct snd_ump_endpoint *ump,
413
420
return 8 ;
414
421
}
415
422
416
- static int do_convert_to_ump (struct snd_ump_endpoint * ump ,
417
- unsigned char group , unsigned char c , u32 * data )
423
+ static int do_convert_to_ump (struct ump_cvt_to_ump * cvt , unsigned char group ,
424
+ unsigned int protocol , unsigned char c , u32 * data )
418
425
{
419
426
/* bytes for 0x80-0xf0 */
420
427
static unsigned char cmd_bytes [8 ] = {
@@ -424,7 +431,6 @@ static int do_convert_to_ump(struct snd_ump_endpoint *ump,
424
431
static unsigned char system_bytes [16 ] = {
425
432
0 , 2 , 3 , 2 , 0 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1
426
433
};
427
- struct ump_cvt_to_ump * cvt = & ump -> out_cvts [group ];
428
434
unsigned char bytes ;
429
435
430
436
if (c == UMP_MIDI1_MSG_SYSEX_START ) {
@@ -478,40 +484,22 @@ static int do_convert_to_ump(struct snd_ump_endpoint *ump,
478
484
cvt -> len = 1 ;
479
485
if ((cvt -> buf [0 ] & 0xf0 ) == UMP_MIDI1_MSG_REALTIME )
480
486
return cvt_legacy_system_to_ump (cvt , group , data );
481
- return cvt_legacy_cmd_to_ump (ump , cvt , group , data , cvt -> cmd_bytes );
487
+ return cvt_legacy_cmd_to_ump (cvt , group , protocol , data , cvt -> cmd_bytes );
482
488
}
483
489
484
- /* feed a MIDI 1.0 byte @c and convert to a UMP packet;
485
- * the target group is @group,
486
- * the result is stored in out_cvts[group].ump[] and out_cvts[group].ump_bytes
490
+ /**
491
+ * snd_ump_convert_to_ump - convert legacy MIDI byte to UMP packet
492
+ * @cvt: converter context
493
+ * @group: target UMP group
494
+ * @protocol: target UMP protocol
495
+ * @c: MIDI 1.0 byte data
496
+ *
497
+ * Feed a MIDI 1.0 byte @c and convert to a UMP packet if completed.
498
+ * The result is stored in the buffer in @cvt.
487
499
*/
488
- void snd_ump_convert_to_ump (struct snd_ump_endpoint * ump ,
489
- unsigned char group , unsigned char c )
500
+ void snd_ump_convert_to_ump (struct ump_cvt_to_ump * cvt , unsigned char group ,
501
+ unsigned int protocol , unsigned char c )
490
502
{
491
- struct ump_cvt_to_ump * cvt = & ump -> out_cvts [group ];
492
-
493
- cvt -> ump_bytes = do_convert_to_ump (ump , group , c , cvt -> ump );
494
- }
495
-
496
- /* reset the converter context, called at each open */
497
- void snd_ump_reset_convert_to_ump (struct snd_ump_endpoint * ump ,
498
- unsigned char group )
499
- {
500
- memset (& ump -> out_cvts [group ], 0 , sizeof (* ump -> out_cvts ));
501
- }
502
-
503
- /* initialize converters */
504
- int snd_ump_convert_init (struct snd_ump_endpoint * ump )
505
- {
506
- ump -> out_cvts = kcalloc (16 , sizeof (* ump -> out_cvts ), GFP_KERNEL );
507
- if (!ump -> out_cvts )
508
- return - ENOMEM ;
509
- return 0 ;
510
- }
511
-
512
- /* release resources */
513
- void snd_ump_convert_free (struct snd_ump_endpoint * ump )
514
- {
515
- kfree (ump -> out_cvts );
516
- ump -> out_cvts = NULL ;
503
+ cvt -> ump_bytes = do_convert_to_ump (cvt , group , protocol , c , cvt -> ump );
517
504
}
505
+ EXPORT_SYMBOL_GPL (snd_ump_convert_to_ump );
0 commit comments