2 * AM824 format in Audio and Music Data Transmission Protocol (IEC 61883-6)
4 * Copyright (c) 2015 Takashi Sakamoto <o-takashi@sakamocchi.jp>
6 * Licensed under the terms of the GNU General Public License, version 2.
9 #include "amdtp-am824.h"
11 #define CIP_FMT_AM 0x10
13 /* "Clock-based rate control mode" is just supported. */
14 #define AMDTP_FDF_AM824 0x00
17 * amdtp_am824_set_parameters - set stream parameters
18 * @s: the AMDTP stream to configure
19 * @rate: the sample rate
20 * @pcm_channels: the number of PCM samples in each data block, to be encoded
21 * as AM824 multi-bit linear audio
22 * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
23 * @double_pcm_frames: one data block transfers two PCM frames
25 * The parameters must be set before the stream is started, and must not be
26 * changed while the stream is running.
28 int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
29 unsigned int pcm_channels,
30 unsigned int midi_ports,
31 bool double_pcm_frames)
35 err = amdtp_stream_set_parameters(s, rate, pcm_channels, midi_ports);
39 s->fdf = AMDTP_FDF_AM824 | s->sfc;
42 * In IEC 61883-6, one data block represents one event. In ALSA, one
43 * event equals to one PCM frame. But Dice has a quirk at higher
44 * sampling rate to transfer two PCM frames in one data block.
46 if (double_pcm_frames)
47 s->frame_multiplier = 2;
49 s->frame_multiplier = 1;
53 EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters);
56 * amdtp_am824_init - initialize an AMDTP stream structure to handle AM824
58 * @s: the AMDTP stream to initialize
59 * @unit: the target of the stream
60 * @dir: the direction of stream
61 * @flags: the packet transmission method to use
63 int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit,
64 enum amdtp_stream_direction dir, enum cip_flags flags)
66 return amdtp_stream_init(s, unit, dir, flags, CIP_FMT_AM);
68 EXPORT_SYMBOL_GPL(amdtp_am824_init);