x86/xen: resume timer irqs early
[linux/fpc-iii.git] / sound / firewire / amdtp.h
blobf6103d68c4b1660bf9d61ba8d0c053086eec923b
1 #ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED
2 #define SOUND_FIREWIRE_AMDTP_H_INCLUDED
4 #include <linux/interrupt.h>
5 #include <linux/mutex.h>
6 #include "packets-buffer.h"
8 /**
9 * enum cip_out_flags - describes details of the streaming protocol
10 * @CIP_NONBLOCKING: In non-blocking mode, each packet contains
11 * sample_rate/8000 samples, with rounding up or down to adjust
12 * for clock skew and left-over fractional samples. This should
13 * be used if supported by the device.
15 enum cip_out_flags {
16 CIP_NONBLOCKING = 0,
19 /**
20 * enum cip_sfc - a stream's sample rate
22 enum cip_sfc {
23 CIP_SFC_32000 = 0,
24 CIP_SFC_44100 = 1,
25 CIP_SFC_48000 = 2,
26 CIP_SFC_88200 = 3,
27 CIP_SFC_96000 = 4,
28 CIP_SFC_176400 = 5,
29 CIP_SFC_192000 = 6,
32 #define AMDTP_OUT_PCM_FORMAT_BITS (SNDRV_PCM_FMTBIT_S16 | \
33 SNDRV_PCM_FMTBIT_S32)
35 struct fw_unit;
36 struct fw_iso_context;
37 struct snd_pcm_substream;
39 struct amdtp_out_stream {
40 struct fw_unit *unit;
41 enum cip_out_flags flags;
42 struct fw_iso_context *context;
43 struct mutex mutex;
45 enum cip_sfc sfc;
46 unsigned int data_block_quadlets;
47 unsigned int pcm_channels;
48 unsigned int midi_ports;
49 void (*transfer_samples)(struct amdtp_out_stream *s,
50 struct snd_pcm_substream *pcm,
51 __be32 *buffer, unsigned int frames);
53 unsigned int syt_interval;
54 unsigned int source_node_id_field;
55 struct iso_packets_buffer buffer;
57 struct snd_pcm_substream *pcm;
58 struct tasklet_struct period_tasklet;
60 int packet_index;
61 unsigned int data_block_counter;
63 unsigned int data_block_state;
65 unsigned int last_syt_offset;
66 unsigned int syt_offset_state;
68 unsigned int pcm_buffer_pointer;
69 unsigned int pcm_period_pointer;
70 bool pointer_flush;
73 int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
74 enum cip_out_flags flags);
75 void amdtp_out_stream_destroy(struct amdtp_out_stream *s);
77 void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate);
78 unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s);
80 int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed);
81 void amdtp_out_stream_update(struct amdtp_out_stream *s);
82 void amdtp_out_stream_stop(struct amdtp_out_stream *s);
84 void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
85 snd_pcm_format_t format);
86 void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s);
87 unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s);
88 void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s);
90 /**
91 * amdtp_out_stream_set_pcm - configure format of PCM samples
92 * @s: the AMDTP output stream to be configured
93 * @pcm_channels: the number of PCM samples in each data block, to be encoded
94 * as AM824 multi-bit linear audio
96 * This function must not be called while the stream is running.
98 static inline void amdtp_out_stream_set_pcm(struct amdtp_out_stream *s,
99 unsigned int pcm_channels)
101 s->pcm_channels = pcm_channels;
105 * amdtp_out_stream_set_midi - configure format of MIDI data
106 * @s: the AMDTP output stream to be configured
107 * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
109 * This function must not be called while the stream is running.
111 static inline void amdtp_out_stream_set_midi(struct amdtp_out_stream *s,
112 unsigned int midi_ports)
114 s->midi_ports = midi_ports;
118 * amdtp_out_streaming_error - check for streaming error
119 * @s: the AMDTP output stream
121 * If this function returns true, the stream's packet queue has stopped due to
122 * an asynchronous error.
124 static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
126 return s->packet_index < 0;
130 * amdtp_out_stream_pcm_trigger - start/stop playback from a PCM device
131 * @s: the AMDTP output stream
132 * @pcm: the PCM device to be started, or %NULL to stop the current device
134 * Call this function on a running isochronous stream to enable the actual
135 * transmission of PCM data. This function should be called from the PCM
136 * device's .trigger callback.
138 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
139 struct snd_pcm_substream *pcm)
141 ACCESS_ONCE(s->pcm) = pcm;
144 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
146 return sfc & 1;
149 #endif