* Line 6 Linux USB driver
*
* Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*/
PCM interface to POD series devices.
*/
#ifndef PCM_H
#define PCM_H
#include <sound/pcm.h>
#include "driver.h"
number of USB frames per URB
The Line 6 Windows driver always transmits two frames per packet, but
the Linux driver performs significantly better (i.e., lower latency)
with only one frame per packet.
*/
#define LINE6_ISO_PACKETS 1
* for "high speed" it's 1/8ms
*/
#define LINE6_ISO_INTERVAL 1
#define LINE6_IMPULSE_DEFAULT_PERIOD 100
Get substream from Line 6 PCM data structure
*/
#define get_substream(line6pcm, stream) \
(line6pcm->pcm->streams[stream].substream)
PCM mode bits.
There are several features of the Line 6 USB driver which require PCM
data to be exchanged with the device:
*) PCM playback and capture via ALSA
*) software monitoring (for devices without hardware monitoring)
*) optional impulse response measurement
However, from the device's point of view, there is just a single
capture and playback stream, which must be shared between these
subsystems. It is therefore necessary to maintain the state of the
subsystems with respect to PCM usage.
We define two bit flags, "opened" and "running", for each playback
or capture stream. Both can contain the bit flag corresponding to
LINE6_STREAM_* type,
LINE6_STREAM_PCM = ALSA PCM playback or capture
LINE6_STREAM_MONITOR = software monitoring
IMPULSE = optional impulse response measurement
The opened flag indicates whether the buffer is allocated while
the running flag indicates whether the stream is running.
For monitor or impulse operations, the driver needs to call
line6_pcm_acquire() or line6_pcm_release() with the appropriate
LINE6_STREAM_* flag.
*/
enum {
LINE6_STREAM_PCM,
LINE6_STREAM_MONITOR,
LINE6_STREAM_IMPULSE,
LINE6_STREAM_CAPTURE_HELPER,
};
enum {
LINE6_FLAG_PAUSE_PLAYBACK,
LINE6_FLAG_PREPARED,
};
struct line6_pcm_properties {
struct snd_pcm_hardware playback_hw, capture_hw;
struct snd_pcm_hw_constraint_ratdens rates;
int bytes_per_channel;
};
struct line6_pcm_stream {
struct urb **urbs;
* Since the packet size is not known in advance, this buffer is
* large enough to store maximum size packets.
*/
unsigned char *buffer;
snd_pcm_uframes_t pos;
* This is modulo period size (to determine when a period is finished).
*/
unsigned bytes;
unsigned count;
unsigned period;
* The contents of the ring buffer have been consumed by the USB
* subsystem (i.e., sent to the USB device) up to this position.
*/
snd_pcm_uframes_t pos_done;
unsigned long active_urbs;
unsigned long unlink_urbs;
*/
spinlock_t lock;
unsigned long opened;
unsigned long running;
int last_frame;
};
struct snd_line6_pcm {
struct usb_line6 *line6;
struct line6_pcm_properties *properties;
struct snd_pcm *pcm;
struct mutex state_mutex;
struct line6_pcm_stream in;
struct line6_pcm_stream out;
unsigned char *prev_fbuf;
int prev_fsize;
int max_packet_size_in;
int max_packet_size_out;
int volume_playback[2];
int volume_monitor;
int impulse_volume;
int impulse_period;
int impulse_count;
unsigned long flags;
};
extern int line6_init_pcm(struct usb_line6 *line6,
struct line6_pcm_properties *properties);
extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd);
extern int snd_line6_prepare(struct snd_pcm_substream *substream);
extern int snd_line6_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params);
extern int snd_line6_hw_free(struct snd_pcm_substream *substream);
extern snd_pcm_uframes_t snd_line6_pointer(struct snd_pcm_substream *substream);
extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm);
extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int type,
bool start);
extern void line6_pcm_release(struct snd_line6_pcm *line6pcm, int type);
#endif