Commit 1c8470ce authored by Daniel Mack's avatar Daniel Mack Committed by Takashi Iwai

ALSA: snd-usb-caiaq: rename 'dev' to 'cdev'

This is needed in order to make the device namespace cleaner, and will
help when moving this driver over to dev_*() logging.
Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6dbe51c2
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
#define ENDPOINT_CAPTURE 2 #define ENDPOINT_CAPTURE 2
#define ENDPOINT_PLAYBACK 6 #define ENDPOINT_PLAYBACK 6
#define MAKE_CHECKBYTE(dev,stream,i) \ #define MAKE_CHECKBYTE(cdev,stream,i) \
(stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) (stream << 1) | (~(i / (cdev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)
static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
...@@ -60,32 +60,32 @@ static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { ...@@ -60,32 +60,32 @@ static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
}; };
static void static void
activate_substream(struct snd_usb_caiaqdev *dev, activate_substream(struct snd_usb_caiaqdev *cdev,
struct snd_pcm_substream *sub) struct snd_pcm_substream *sub)
{ {
spin_lock(&dev->spinlock); spin_lock(&cdev->spinlock);
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
dev->sub_playback[sub->number] = sub; cdev->sub_playback[sub->number] = sub;
else else
dev->sub_capture[sub->number] = sub; cdev->sub_capture[sub->number] = sub;
spin_unlock(&dev->spinlock); spin_unlock(&cdev->spinlock);
} }
static void static void
deactivate_substream(struct snd_usb_caiaqdev *dev, deactivate_substream(struct snd_usb_caiaqdev *cdev,
struct snd_pcm_substream *sub) struct snd_pcm_substream *sub)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&cdev->spinlock, flags);
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
dev->sub_playback[sub->number] = NULL; cdev->sub_playback[sub->number] = NULL;
else else
dev->sub_capture[sub->number] = NULL; cdev->sub_capture[sub->number] = NULL;
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&cdev->spinlock, flags);
} }
static int static int
...@@ -98,28 +98,28 @@ all_substreams_zero(struct snd_pcm_substream **subs) ...@@ -98,28 +98,28 @@ all_substreams_zero(struct snd_pcm_substream **subs)
return 1; return 1;
} }
static int stream_start(struct snd_usb_caiaqdev *dev) static int stream_start(struct snd_usb_caiaqdev *cdev)
{ {
int i, ret; int i, ret;
debug("%s(%p)\n", __func__, dev); debug("%s(%p)\n", __func__, cdev);
if (dev->streaming) if (cdev->streaming)
return -EINVAL; return -EINVAL;
memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback));
memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture));
dev->input_panic = 0; cdev->input_panic = 0;
dev->output_panic = 0; cdev->output_panic = 0;
dev->first_packet = 4; cdev->first_packet = 4;
dev->streaming = 1; cdev->streaming = 1;
dev->warned = 0; cdev->warned = 0;
for (i = 0; i < N_URBS; i++) { for (i = 0; i < N_URBS; i++) {
ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC);
if (ret) { if (ret) {
log("unable to trigger read #%d! (ret %d)\n", i, ret); log("unable to trigger read #%d! (ret %d)\n", i, ret);
dev->streaming = 0; cdev->streaming = 0;
return -EPIPE; return -EPIPE;
} }
} }
...@@ -127,46 +127,46 @@ static int stream_start(struct snd_usb_caiaqdev *dev) ...@@ -127,46 +127,46 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
return 0; return 0;
} }
static void stream_stop(struct snd_usb_caiaqdev *dev) static void stream_stop(struct snd_usb_caiaqdev *cdev)
{ {
int i; int i;
debug("%s(%p)\n", __func__, dev); debug("%s(%p)\n", __func__, cdev);
if (!dev->streaming) if (!cdev->streaming)
return; return;
dev->streaming = 0; cdev->streaming = 0;
for (i = 0; i < N_URBS; i++) { for (i = 0; i < N_URBS; i++) {
usb_kill_urb(dev->data_urbs_in[i]); usb_kill_urb(cdev->data_urbs_in[i]);
if (test_bit(i, &dev->outurb_active_mask)) if (test_bit(i, &cdev->outurb_active_mask))
usb_kill_urb(dev->data_urbs_out[i]); usb_kill_urb(cdev->data_urbs_out[i]);
} }
dev->outurb_active_mask = 0; cdev->outurb_active_mask = 0;
} }
static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
{ {
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
debug("%s(%p)\n", __func__, substream); debug("%s(%p)\n", __func__, substream);
substream->runtime->hw = dev->pcm_info; substream->runtime->hw = cdev->pcm_info;
snd_pcm_limit_hw_rates(substream->runtime); snd_pcm_limit_hw_rates(substream->runtime);
return 0; return 0;
} }
static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
{ {
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
debug("%s(%p)\n", __func__, substream); debug("%s(%p)\n", __func__, substream);
if (all_substreams_zero(dev->sub_playback) && if (all_substreams_zero(cdev->sub_playback) &&
all_substreams_zero(dev->sub_capture)) { all_substreams_zero(cdev->sub_capture)) {
/* when the last client has stopped streaming, /* when the last client has stopped streaming,
* all sample rates are allowed again */ * all sample rates are allowed again */
stream_stop(dev); stream_stop(cdev);
dev->pcm_info.rates = dev->samplerates; cdev->pcm_info.rates = cdev->samplerates;
} }
return 0; return 0;
...@@ -181,9 +181,9 @@ static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, ...@@ -181,9 +181,9 @@ static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
{ {
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
debug("%s(%p)\n", __func__, sub); debug("%s(%p)\n", __func__, sub);
deactivate_substream(dev, sub); deactivate_substream(cdev, sub);
return snd_pcm_lib_free_pages(sub); return snd_pcm_lib_free_pages(sub);
} }
...@@ -199,7 +199,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -199,7 +199,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
{ {
int bytes_per_sample, bpp, ret, i; int bytes_per_sample, bpp, ret, i;
int index = substream->number; int index = substream->number;
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
debug("%s(%p)\n", __func__, substream); debug("%s(%p)\n", __func__, substream);
...@@ -207,7 +207,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -207,7 +207,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
int out_pos; int out_pos;
switch (dev->spec.data_alignment) { switch (cdev->spec.data_alignment) {
case 0: case 0:
case 2: case 2:
out_pos = BYTES_PER_SAMPLE + 1; out_pos = BYTES_PER_SAMPLE + 1;
...@@ -218,12 +218,12 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -218,12 +218,12 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
break; break;
} }
dev->period_out_count[index] = out_pos; cdev->period_out_count[index] = out_pos;
dev->audio_out_buf_pos[index] = out_pos; cdev->audio_out_buf_pos[index] = out_pos;
} else { } else {
int in_pos; int in_pos;
switch (dev->spec.data_alignment) { switch (cdev->spec.data_alignment) {
case 0: case 0:
in_pos = BYTES_PER_SAMPLE + 2; in_pos = BYTES_PER_SAMPLE + 2;
break; break;
...@@ -236,44 +236,44 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -236,44 +236,44 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
break; break;
} }
dev->period_in_count[index] = in_pos; cdev->period_in_count[index] = in_pos;
dev->audio_in_buf_pos[index] = in_pos; cdev->audio_in_buf_pos[index] = in_pos;
} }
if (dev->streaming) if (cdev->streaming)
return 0; return 0;
/* the first client that opens a stream defines the sample rate /* the first client that opens a stream defines the sample rate
* setting for all subsequent calls, until the last client closed. */ * setting for all subsequent calls, until the last client closed. */
for (i=0; i < ARRAY_SIZE(rates); i++) for (i=0; i < ARRAY_SIZE(rates); i++)
if (runtime->rate == rates[i]) if (runtime->rate == rates[i])
dev->pcm_info.rates = 1 << i; cdev->pcm_info.rates = 1 << i;
snd_pcm_limit_hw_rates(runtime); snd_pcm_limit_hw_rates(runtime);
bytes_per_sample = BYTES_PER_SAMPLE; bytes_per_sample = BYTES_PER_SAMPLE;
if (dev->spec.data_alignment >= 2) if (cdev->spec.data_alignment >= 2)
bytes_per_sample++; bytes_per_sample++;
bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE)
* bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; * bytes_per_sample * CHANNELS_PER_STREAM * cdev->n_streams;
if (bpp > MAX_ENDPOINT_SIZE) if (bpp > MAX_ENDPOINT_SIZE)
bpp = MAX_ENDPOINT_SIZE; bpp = MAX_ENDPOINT_SIZE;
ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate, ret = snd_usb_caiaq_set_audio_params(cdev, runtime->rate,
runtime->sample_bits, bpp); runtime->sample_bits, bpp);
if (ret) if (ret)
return ret; return ret;
ret = stream_start(dev); ret = stream_start(cdev);
if (ret) if (ret)
return ret; return ret;
dev->output_running = 0; cdev->output_running = 0;
wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); wait_event_timeout(cdev->prepare_wait_queue, cdev->output_running, HZ);
if (!dev->output_running) { if (!cdev->output_running) {
stream_stop(dev); stream_stop(cdev);
return -EPIPE; return -EPIPE;
} }
...@@ -282,18 +282,18 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -282,18 +282,18 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
{ {
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
debug("%s(%p) cmd %d\n", __func__, sub, cmd); debug("%s(%p) cmd %d\n", __func__, sub, cmd);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
activate_substream(dev, sub); activate_substream(cdev, sub);
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
deactivate_substream(dev, sub); deactivate_substream(cdev, sub);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -306,25 +306,25 @@ static snd_pcm_uframes_t ...@@ -306,25 +306,25 @@ static snd_pcm_uframes_t
snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
{ {
int index = sub->number; int index = sub->number;
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
snd_pcm_uframes_t ptr; snd_pcm_uframes_t ptr;
spin_lock(&dev->spinlock); spin_lock(&cdev->spinlock);
if (dev->input_panic || dev->output_panic) { if (cdev->input_panic || cdev->output_panic) {
ptr = SNDRV_PCM_POS_XRUN; ptr = SNDRV_PCM_POS_XRUN;
goto unlock; goto unlock;
} }
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
ptr = bytes_to_frames(sub->runtime, ptr = bytes_to_frames(sub->runtime,
dev->audio_out_buf_pos[index]); cdev->audio_out_buf_pos[index]);
else else
ptr = bytes_to_frames(sub->runtime, ptr = bytes_to_frames(sub->runtime,
dev->audio_in_buf_pos[index]); cdev->audio_in_buf_pos[index]);
unlock: unlock:
spin_unlock(&dev->spinlock); spin_unlock(&cdev->spinlock);
return ptr; return ptr;
} }
...@@ -340,21 +340,21 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { ...@@ -340,21 +340,21 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = {
.pointer = snd_usb_caiaq_pcm_pointer .pointer = snd_usb_caiaq_pcm_pointer
}; };
static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, static void check_for_elapsed_periods(struct snd_usb_caiaqdev *cdev,
struct snd_pcm_substream **subs) struct snd_pcm_substream **subs)
{ {
int stream, pb, *cnt; int stream, pb, *cnt;
struct snd_pcm_substream *sub; struct snd_pcm_substream *sub;
for (stream = 0; stream < dev->n_streams; stream++) { for (stream = 0; stream < cdev->n_streams; stream++) {
sub = subs[stream]; sub = subs[stream];
if (!sub) if (!sub)
continue; continue;
pb = snd_pcm_lib_period_bytes(sub); pb = snd_pcm_lib_period_bytes(sub);
cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
&dev->period_out_count[stream] : &cdev->period_out_count[stream] :
&dev->period_in_count[stream]; &cdev->period_in_count[stream];
if (*cnt >= pb) { if (*cnt >= pb) {
snd_pcm_period_elapsed(sub); snd_pcm_period_elapsed(sub);
...@@ -363,7 +363,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, ...@@ -363,7 +363,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev,
} }
} }
static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, static void read_in_urb_mode0(struct snd_usb_caiaqdev *cdev,
const struct urb *urb, const struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
...@@ -371,27 +371,27 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, ...@@ -371,27 +371,27 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
struct snd_pcm_substream *sub; struct snd_pcm_substream *sub;
int stream, i; int stream, i;
if (all_substreams_zero(dev->sub_capture)) if (all_substreams_zero(cdev->sub_capture))
return; return;
for (i = 0; i < iso->actual_length;) { for (i = 0; i < iso->actual_length;) {
for (stream = 0; stream < dev->n_streams; stream++, i++) { for (stream = 0; stream < cdev->n_streams; stream++, i++) {
sub = dev->sub_capture[stream]; sub = cdev->sub_capture[stream];
if (sub) { if (sub) {
struct snd_pcm_runtime *rt = sub->runtime; struct snd_pcm_runtime *rt = sub->runtime;
char *audio_buf = rt->dma_area; char *audio_buf = rt->dma_area;
int sz = frames_to_bytes(rt, rt->buffer_size); int sz = frames_to_bytes(rt, rt->buffer_size);
audio_buf[dev->audio_in_buf_pos[stream]++] audio_buf[cdev->audio_in_buf_pos[stream]++]
= usb_buf[i]; = usb_buf[i];
dev->period_in_count[stream]++; cdev->period_in_count[stream]++;
if (dev->audio_in_buf_pos[stream] == sz) if (cdev->audio_in_buf_pos[stream] == sz)
dev->audio_in_buf_pos[stream] = 0; cdev->audio_in_buf_pos[stream] = 0;
} }
} }
} }
} }
static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, static void read_in_urb_mode2(struct snd_usb_caiaqdev *cdev,
const struct urb *urb, const struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
...@@ -401,44 +401,44 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, ...@@ -401,44 +401,44 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
int stream, i; int stream, i;
for (i = 0; i < iso->actual_length;) { for (i = 0; i < iso->actual_length;) {
if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { if (i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) == 0) {
for (stream = 0; for (stream = 0;
stream < dev->n_streams; stream < cdev->n_streams;
stream++, i++) { stream++, i++) {
if (dev->first_packet) if (cdev->first_packet)
continue; continue;
check_byte = MAKE_CHECKBYTE(dev, stream, i); check_byte = MAKE_CHECKBYTE(cdev, stream, i);
if ((usb_buf[i] & 0x3f) != check_byte) if ((usb_buf[i] & 0x3f) != check_byte)
dev->input_panic = 1; cdev->input_panic = 1;
if (usb_buf[i] & 0x80) if (usb_buf[i] & 0x80)
dev->output_panic = 1; cdev->output_panic = 1;
} }
} }
dev->first_packet = 0; cdev->first_packet = 0;
for (stream = 0; stream < dev->n_streams; stream++, i++) { for (stream = 0; stream < cdev->n_streams; stream++, i++) {
sub = dev->sub_capture[stream]; sub = cdev->sub_capture[stream];
if (dev->input_panic) if (cdev->input_panic)
usb_buf[i] = 0; usb_buf[i] = 0;
if (sub) { if (sub) {
struct snd_pcm_runtime *rt = sub->runtime; struct snd_pcm_runtime *rt = sub->runtime;
char *audio_buf = rt->dma_area; char *audio_buf = rt->dma_area;
int sz = frames_to_bytes(rt, rt->buffer_size); int sz = frames_to_bytes(rt, rt->buffer_size);
audio_buf[dev->audio_in_buf_pos[stream]++] = audio_buf[cdev->audio_in_buf_pos[stream]++] =
usb_buf[i]; usb_buf[i];
dev->period_in_count[stream]++; cdev->period_in_count[stream]++;
if (dev->audio_in_buf_pos[stream] == sz) if (cdev->audio_in_buf_pos[stream] == sz)
dev->audio_in_buf_pos[stream] = 0; cdev->audio_in_buf_pos[stream] = 0;
} }
} }
} }
} }
static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, static void read_in_urb_mode3(struct snd_usb_caiaqdev *cdev,
const struct urb *urb, const struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
...@@ -450,12 +450,12 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, ...@@ -450,12 +450,12 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev,
return; return;
for (i = 0; i < iso->actual_length;) { for (i = 0; i < iso->actual_length;) {
for (stream = 0; stream < dev->n_streams; stream++) { for (stream = 0; stream < cdev->n_streams; stream++) {
struct snd_pcm_substream *sub = dev->sub_capture[stream]; struct snd_pcm_substream *sub = cdev->sub_capture[stream];
char *audio_buf = NULL; char *audio_buf = NULL;
int c, n, sz = 0; int c, n, sz = 0;
if (sub && !dev->input_panic) { if (sub && !cdev->input_panic) {
struct snd_pcm_runtime *rt = sub->runtime; struct snd_pcm_runtime *rt = sub->runtime;
audio_buf = rt->dma_area; audio_buf = rt->dma_area;
sz = frames_to_bytes(rt, rt->buffer_size); sz = frames_to_bytes(rt, rt->buffer_size);
...@@ -465,23 +465,23 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, ...@@ -465,23 +465,23 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev,
/* 3 audio data bytes, followed by 1 check byte */ /* 3 audio data bytes, followed by 1 check byte */
if (audio_buf) { if (audio_buf) {
for (n = 0; n < BYTES_PER_SAMPLE; n++) { for (n = 0; n < BYTES_PER_SAMPLE; n++) {
audio_buf[dev->audio_in_buf_pos[stream]++] = usb_buf[i+n]; audio_buf[cdev->audio_in_buf_pos[stream]++] = usb_buf[i+n];
if (dev->audio_in_buf_pos[stream] == sz) if (cdev->audio_in_buf_pos[stream] == sz)
dev->audio_in_buf_pos[stream] = 0; cdev->audio_in_buf_pos[stream] = 0;
} }
dev->period_in_count[stream] += BYTES_PER_SAMPLE; cdev->period_in_count[stream] += BYTES_PER_SAMPLE;
} }
i += BYTES_PER_SAMPLE; i += BYTES_PER_SAMPLE;
if (usb_buf[i] != ((stream << 1) | c) && if (usb_buf[i] != ((stream << 1) | c) &&
!dev->first_packet) { !cdev->first_packet) {
if (!dev->input_panic) if (!cdev->input_panic)
printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n",
((stream << 1) | c), usb_buf[i], c, stream, i); ((stream << 1) | c), usb_buf[i], c, stream, i);
dev->input_panic = 1; cdev->input_panic = 1;
} }
i++; i++;
...@@ -489,41 +489,41 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, ...@@ -489,41 +489,41 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev,
} }
} }
if (dev->first_packet > 0) if (cdev->first_packet > 0)
dev->first_packet--; cdev->first_packet--;
} }
static void read_in_urb(struct snd_usb_caiaqdev *dev, static void read_in_urb(struct snd_usb_caiaqdev *cdev,
const struct urb *urb, const struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
if (!dev->streaming) if (!cdev->streaming)
return; return;
if (iso->actual_length < dev->bpp) if (iso->actual_length < cdev->bpp)
return; return;
switch (dev->spec.data_alignment) { switch (cdev->spec.data_alignment) {
case 0: case 0:
read_in_urb_mode0(dev, urb, iso); read_in_urb_mode0(cdev, urb, iso);
break; break;
case 2: case 2:
read_in_urb_mode2(dev, urb, iso); read_in_urb_mode2(cdev, urb, iso);
break; break;
case 3: case 3:
read_in_urb_mode3(dev, urb, iso); read_in_urb_mode3(cdev, urb, iso);
break; break;
} }
if ((dev->input_panic || dev->output_panic) && !dev->warned) { if ((cdev->input_panic || cdev->output_panic) && !cdev->warned) {
debug("streaming error detected %s %s\n", debug("streaming error detected %s %s\n",
dev->input_panic ? "(input)" : "", cdev->input_panic ? "(input)" : "",
dev->output_panic ? "(output)" : ""); cdev->output_panic ? "(output)" : "");
dev->warned = 1; cdev->warned = 1;
} }
} }
static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *cdev,
struct urb *urb, struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
...@@ -532,32 +532,32 @@ static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, ...@@ -532,32 +532,32 @@ static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev,
int stream, i; int stream, i;
for (i = 0; i < iso->length;) { for (i = 0; i < iso->length;) {
for (stream = 0; stream < dev->n_streams; stream++, i++) { for (stream = 0; stream < cdev->n_streams; stream++, i++) {
sub = dev->sub_playback[stream]; sub = cdev->sub_playback[stream];
if (sub) { if (sub) {
struct snd_pcm_runtime *rt = sub->runtime; struct snd_pcm_runtime *rt = sub->runtime;
char *audio_buf = rt->dma_area; char *audio_buf = rt->dma_area;
int sz = frames_to_bytes(rt, rt->buffer_size); int sz = frames_to_bytes(rt, rt->buffer_size);
usb_buf[i] = usb_buf[i] =
audio_buf[dev->audio_out_buf_pos[stream]]; audio_buf[cdev->audio_out_buf_pos[stream]];
dev->period_out_count[stream]++; cdev->period_out_count[stream]++;
dev->audio_out_buf_pos[stream]++; cdev->audio_out_buf_pos[stream]++;
if (dev->audio_out_buf_pos[stream] == sz) if (cdev->audio_out_buf_pos[stream] == sz)
dev->audio_out_buf_pos[stream] = 0; cdev->audio_out_buf_pos[stream] = 0;
} else } else
usb_buf[i] = 0; usb_buf[i] = 0;
} }
/* fill in the check bytes */ /* fill in the check bytes */
if (dev->spec.data_alignment == 2 && if (cdev->spec.data_alignment == 2 &&
i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) ==
(dev->n_streams * CHANNELS_PER_STREAM)) (cdev->n_streams * CHANNELS_PER_STREAM))
for (stream = 0; stream < dev->n_streams; stream++, i++) for (stream = 0; stream < cdev->n_streams; stream++, i++)
usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); usb_buf[i] = MAKE_CHECKBYTE(cdev, stream, i);
} }
} }
static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *cdev,
struct urb *urb, struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
...@@ -565,8 +565,8 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, ...@@ -565,8 +565,8 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev,
int stream, i; int stream, i;
for (i = 0; i < iso->length;) { for (i = 0; i < iso->length;) {
for (stream = 0; stream < dev->n_streams; stream++) { for (stream = 0; stream < cdev->n_streams; stream++) {
struct snd_pcm_substream *sub = dev->sub_playback[stream]; struct snd_pcm_substream *sub = cdev->sub_playback[stream];
char *audio_buf = NULL; char *audio_buf = NULL;
int c, n, sz = 0; int c, n, sz = 0;
...@@ -579,17 +579,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, ...@@ -579,17 +579,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev,
for (c = 0; c < CHANNELS_PER_STREAM; c++) { for (c = 0; c < CHANNELS_PER_STREAM; c++) {
for (n = 0; n < BYTES_PER_SAMPLE; n++) { for (n = 0; n < BYTES_PER_SAMPLE; n++) {
if (audio_buf) { if (audio_buf) {
usb_buf[i+n] = audio_buf[dev->audio_out_buf_pos[stream]++]; usb_buf[i+n] = audio_buf[cdev->audio_out_buf_pos[stream]++];
if (dev->audio_out_buf_pos[stream] == sz) if (cdev->audio_out_buf_pos[stream] == sz)
dev->audio_out_buf_pos[stream] = 0; cdev->audio_out_buf_pos[stream] = 0;
} else { } else {
usb_buf[i+n] = 0; usb_buf[i+n] = 0;
} }
} }
if (audio_buf) if (audio_buf)
dev->period_out_count[stream] += BYTES_PER_SAMPLE; cdev->period_out_count[stream] += BYTES_PER_SAMPLE;
i += BYTES_PER_SAMPLE; i += BYTES_PER_SAMPLE;
...@@ -600,17 +600,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, ...@@ -600,17 +600,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev,
} }
} }
static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, static inline void fill_out_urb(struct snd_usb_caiaqdev *cdev,
struct urb *urb, struct urb *urb,
const struct usb_iso_packet_descriptor *iso) const struct usb_iso_packet_descriptor *iso)
{ {
switch (dev->spec.data_alignment) { switch (cdev->spec.data_alignment) {
case 0: case 0:
case 2: case 2:
fill_out_urb_mode_0(dev, urb, iso); fill_out_urb_mode_0(cdev, urb, iso);
break; break;
case 3: case 3:
fill_out_urb_mode_3(dev, urb, iso); fill_out_urb_mode_3(cdev, urb, iso);
break; break;
} }
} }
...@@ -618,7 +618,7 @@ static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, ...@@ -618,7 +618,7 @@ static inline void fill_out_urb(struct snd_usb_caiaqdev *dev,
static void read_completed(struct urb *urb) static void read_completed(struct urb *urb)
{ {
struct snd_usb_caiaq_cb_info *info = urb->context; struct snd_usb_caiaq_cb_info *info = urb->context;
struct snd_usb_caiaqdev *dev; struct snd_usb_caiaqdev *cdev;
struct urb *out = NULL; struct urb *out = NULL;
int i, frame, len, send_it = 0, outframe = 0; int i, frame, len, send_it = 0, outframe = 0;
size_t offset = 0; size_t offset = 0;
...@@ -626,15 +626,15 @@ static void read_completed(struct urb *urb) ...@@ -626,15 +626,15 @@ static void read_completed(struct urb *urb)
if (urb->status || !info) if (urb->status || !info)
return; return;
dev = info->dev; cdev = info->cdev;
if (!dev->streaming) if (!cdev->streaming)
return; return;
/* find an unused output urb that is unused */ /* find an unused output urb that is unused */
for (i = 0; i < N_URBS; i++) for (i = 0; i < N_URBS; i++)
if (test_and_set_bit(i, &dev->outurb_active_mask) == 0) { if (test_and_set_bit(i, &cdev->outurb_active_mask) == 0) {
out = dev->data_urbs_out[i]; out = cdev->data_urbs_out[i];
break; break;
} }
...@@ -656,12 +656,12 @@ static void read_completed(struct urb *urb) ...@@ -656,12 +656,12 @@ static void read_completed(struct urb *urb)
offset += len; offset += len;
if (len > 0) { if (len > 0) {
spin_lock(&dev->spinlock); spin_lock(&cdev->spinlock);
fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]);
read_in_urb(dev, urb, &urb->iso_frame_desc[frame]); read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]);
spin_unlock(&dev->spinlock); spin_unlock(&cdev->spinlock);
check_for_elapsed_periods(dev, dev->sub_playback); check_for_elapsed_periods(cdev, cdev->sub_playback);
check_for_elapsed_periods(dev, dev->sub_capture); check_for_elapsed_periods(cdev, cdev->sub_capture);
send_it = 1; send_it = 1;
} }
...@@ -674,7 +674,7 @@ static void read_completed(struct urb *urb) ...@@ -674,7 +674,7 @@ static void read_completed(struct urb *urb)
usb_submit_urb(out, GFP_ATOMIC); usb_submit_urb(out, GFP_ATOMIC);
} else { } else {
struct snd_usb_caiaq_cb_info *oinfo = out->context; struct snd_usb_caiaq_cb_info *oinfo = out->context;
clear_bit(oinfo->index, &dev->outurb_active_mask); clear_bit(oinfo->index, &cdev->outurb_active_mask);
} }
requeue: requeue:
...@@ -693,21 +693,21 @@ static void read_completed(struct urb *urb) ...@@ -693,21 +693,21 @@ static void read_completed(struct urb *urb)
static void write_completed(struct urb *urb) static void write_completed(struct urb *urb)
{ {
struct snd_usb_caiaq_cb_info *info = urb->context; struct snd_usb_caiaq_cb_info *info = urb->context;
struct snd_usb_caiaqdev *dev = info->dev; struct snd_usb_caiaqdev *cdev = info->cdev;
if (!dev->output_running) { if (!cdev->output_running) {
dev->output_running = 1; cdev->output_running = 1;
wake_up(&dev->prepare_wait_queue); wake_up(&cdev->prepare_wait_queue);
} }
clear_bit(info->index, &dev->outurb_active_mask); clear_bit(info->index, &cdev->outurb_active_mask);
} }
static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
{ {
int i, frame; int i, frame;
struct urb **urbs; struct urb **urbs;
struct usb_device *usb_dev = dev->chip.dev; struct usb_device *usb_dev = cdev->chip.dev;
unsigned int pipe; unsigned int pipe;
pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
...@@ -749,7 +749,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) ...@@ -749,7 +749,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
urbs[i]->pipe = pipe; urbs[i]->pipe = pipe;
urbs[i]->transfer_buffer_length = FRAMES_PER_URB urbs[i]->transfer_buffer_length = FRAMES_PER_URB
* BYTES_PER_FRAME; * BYTES_PER_FRAME;
urbs[i]->context = &dev->data_cb_info[i]; urbs[i]->context = &cdev->data_cb_info[i];
urbs[i]->interval = 1; urbs[i]->interval = 1;
urbs[i]->transfer_flags = URB_ISO_ASAP; urbs[i]->transfer_flags = URB_ISO_ASAP;
urbs[i]->number_of_packets = FRAMES_PER_URB; urbs[i]->number_of_packets = FRAMES_PER_URB;
...@@ -780,110 +780,110 @@ static void free_urbs(struct urb **urbs) ...@@ -780,110 +780,110 @@ static void free_urbs(struct urb **urbs)
kfree(urbs); kfree(urbs);
} }
int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
{ {
int i, ret; int i, ret;
dev->n_audio_in = max(dev->spec.num_analog_audio_in, cdev->n_audio_in = max(cdev->spec.num_analog_audio_in,
dev->spec.num_digital_audio_in) / cdev->spec.num_digital_audio_in) /
CHANNELS_PER_STREAM; CHANNELS_PER_STREAM;
dev->n_audio_out = max(dev->spec.num_analog_audio_out, cdev->n_audio_out = max(cdev->spec.num_analog_audio_out,
dev->spec.num_digital_audio_out) / cdev->spec.num_digital_audio_out) /
CHANNELS_PER_STREAM; CHANNELS_PER_STREAM;
dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); cdev->n_streams = max(cdev->n_audio_in, cdev->n_audio_out);
debug("dev->n_audio_in = %d\n", dev->n_audio_in); debug("cdev->n_audio_in = %d\n", cdev->n_audio_in);
debug("dev->n_audio_out = %d\n", dev->n_audio_out); debug("cdev->n_audio_out = %d\n", cdev->n_audio_out);
debug("dev->n_streams = %d\n", dev->n_streams); debug("cdev->n_streams = %d\n", cdev->n_streams);
if (dev->n_streams > MAX_STREAMS) { if (cdev->n_streams > MAX_STREAMS) {
log("unable to initialize device, too many streams.\n"); log("unable to initialize device, too many streams.\n");
return -EINVAL; return -EINVAL;
} }
ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, ret = snd_pcm_new(cdev->chip.card, cdev->product_name, 0,
dev->n_audio_out, dev->n_audio_in, &dev->pcm); cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm);
if (ret < 0) { if (ret < 0) {
log("snd_pcm_new() returned %d\n", ret); log("snd_pcm_new() returned %d\n", ret);
return ret; return ret;
} }
dev->pcm->private_data = dev; cdev->pcm->private_data = cdev;
strlcpy(dev->pcm->name, dev->product_name, sizeof(dev->pcm->name)); strlcpy(cdev->pcm->name, cdev->product_name, sizeof(cdev->pcm->name));
memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback));
memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture));
memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, memcpy(&cdev->pcm_info, &snd_usb_caiaq_pcm_hardware,
sizeof(snd_usb_caiaq_pcm_hardware)); sizeof(snd_usb_caiaq_pcm_hardware));
/* setup samplerates */ /* setup samplerates */
dev->samplerates = dev->pcm_info.rates; cdev->samplerates = cdev->pcm_info.rates;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE):
dev->samplerates |= SNDRV_PCM_RATE_192000; cdev->samplerates |= SNDRV_PCM_RATE_192000;
/* fall thru */ /* fall thru */
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2):
dev->samplerates |= SNDRV_PCM_RATE_88200; cdev->samplerates |= SNDRV_PCM_RATE_88200;
break; break;
} }
snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_PLAYBACK,
&snd_usb_caiaq_ops); &snd_usb_caiaq_ops);
snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE,
&snd_usb_caiaq_ops); &snd_usb_caiaq_ops);
snd_pcm_lib_preallocate_pages_for_all(dev->pcm, snd_pcm_lib_preallocate_pages_for_all(cdev->pcm,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
dev->data_cb_info = cdev->data_cb_info =
kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
GFP_KERNEL); GFP_KERNEL);
if (!dev->data_cb_info) if (!cdev->data_cb_info)
return -ENOMEM; return -ENOMEM;
dev->outurb_active_mask = 0; cdev->outurb_active_mask = 0;
BUILD_BUG_ON(N_URBS > (sizeof(dev->outurb_active_mask) * 8)); BUILD_BUG_ON(N_URBS > (sizeof(cdev->outurb_active_mask) * 8));
for (i = 0; i < N_URBS; i++) { for (i = 0; i < N_URBS; i++) {
dev->data_cb_info[i].dev = dev; cdev->data_cb_info[i].cdev = cdev;
dev->data_cb_info[i].index = i; cdev->data_cb_info[i].index = i;
} }
dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); cdev->data_urbs_in = alloc_urbs(cdev, SNDRV_PCM_STREAM_CAPTURE, &ret);
if (ret < 0) { if (ret < 0) {
kfree(dev->data_cb_info); kfree(cdev->data_cb_info);
free_urbs(dev->data_urbs_in); free_urbs(cdev->data_urbs_in);
return ret; return ret;
} }
dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); cdev->data_urbs_out = alloc_urbs(cdev, SNDRV_PCM_STREAM_PLAYBACK, &ret);
if (ret < 0) { if (ret < 0) {
kfree(dev->data_cb_info); kfree(cdev->data_cb_info);
free_urbs(dev->data_urbs_in); free_urbs(cdev->data_urbs_in);
free_urbs(dev->data_urbs_out); free_urbs(cdev->data_urbs_out);
return ret; return ret;
} }
return 0; return 0;
} }
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev) void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)
{ {
debug("%s(%p)\n", __func__, dev); debug("%s(%p)\n", __func__, cdev);
stream_stop(dev); stream_stop(cdev);
free_urbs(dev->data_urbs_in); free_urbs(cdev->data_urbs_in);
free_urbs(dev->data_urbs_out); free_urbs(cdev->data_urbs_out);
kfree(dev->data_cb_info); kfree(cdev->data_cb_info);
} }
#ifndef CAIAQ_AUDIO_H #ifndef CAIAQ_AUDIO_H
#define CAIAQ_AUDIO_H #define CAIAQ_AUDIO_H
int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev); int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev);
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev); void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev);
#endif /* CAIAQ_AUDIO_H */ #endif /* CAIAQ_AUDIO_H */
...@@ -32,7 +32,7 @@ static int control_info(struct snd_kcontrol *kcontrol, ...@@ -32,7 +32,7 @@ static int control_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo) struct snd_ctl_elem_info *uinfo)
{ {
struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
int pos = kcontrol->private_value; int pos = kcontrol->private_value;
int is_intval = pos & CNT_INTVAL; int is_intval = pos & CNT_INTVAL;
int maxval = 63; int maxval = 63;
...@@ -40,7 +40,7 @@ static int control_info(struct snd_kcontrol *kcontrol, ...@@ -40,7 +40,7 @@ static int control_info(struct snd_kcontrol *kcontrol,
uinfo->count = 1; uinfo->count = 1;
pos &= ~CNT_INTVAL; pos &= ~CNT_INTVAL;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
if (pos == 0) { if (pos == 0) {
...@@ -78,15 +78,15 @@ static int control_get(struct snd_kcontrol *kcontrol, ...@@ -78,15 +78,15 @@ static int control_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
int pos = kcontrol->private_value; int pos = kcontrol->private_value;
if (pos & CNT_INTVAL) if (pos & CNT_INTVAL)
ucontrol->value.integer.value[0] ucontrol->value.integer.value[0]
= dev->control_state[pos & ~CNT_INTVAL]; = cdev->control_state[pos & ~CNT_INTVAL];
else else
ucontrol->value.integer.value[0] ucontrol->value.integer.value[0]
= !!(dev->control_state[pos / 8] & (1 << pos % 8)); = !!(cdev->control_state[pos / 8] & (1 << pos % 8));
return 0; return 0;
} }
...@@ -95,43 +95,43 @@ static int control_put(struct snd_kcontrol *kcontrol, ...@@ -95,43 +95,43 @@ static int control_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
int pos = kcontrol->private_value; int pos = kcontrol->private_value;
int v = ucontrol->value.integer.value[0]; int v = ucontrol->value.integer.value[0];
unsigned char cmd = EP1_CMD_WRITE_IO; unsigned char cmd = EP1_CMD_WRITE_IO;
if (dev->chip.usb_id == if (cdev->chip.usb_id ==
USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1))
cmd = EP1_CMD_DIMM_LEDS; cmd = EP1_CMD_DIMM_LEDS;
if (pos & CNT_INTVAL) { if (pos & CNT_INTVAL) {
int i = pos & ~CNT_INTVAL; int i = pos & ~CNT_INTVAL;
dev->control_state[i] = v; cdev->control_state[i] = v;
if (dev->chip.usb_id == if (cdev->chip.usb_id ==
USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) { USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) {
int actual_len; int actual_len;
dev->ep8_out_buf[0] = i; cdev->ep8_out_buf[0] = i;
dev->ep8_out_buf[1] = v; cdev->ep8_out_buf[1] = v;
usb_bulk_msg(dev->chip.dev, usb_bulk_msg(cdev->chip.dev,
usb_sndbulkpipe(dev->chip.dev, 8), usb_sndbulkpipe(cdev->chip.dev, 8),
dev->ep8_out_buf, sizeof(dev->ep8_out_buf), cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf),
&actual_len, 200); &actual_len, 200);
} else { } else {
snd_usb_caiaq_send_command(dev, cmd, snd_usb_caiaq_send_command(cdev, cmd,
dev->control_state, sizeof(dev->control_state)); cdev->control_state, sizeof(cdev->control_state));
} }
} else { } else {
if (v) if (v)
dev->control_state[pos / 8] |= 1 << (pos % 8); cdev->control_state[pos / 8] |= 1 << (pos % 8);
else else
dev->control_state[pos / 8] &= ~(1 << (pos % 8)); cdev->control_state[pos / 8] &= ~(1 << (pos % 8));
snd_usb_caiaq_send_command(dev, cmd, snd_usb_caiaq_send_command(cdev, cmd,
dev->control_state, sizeof(dev->control_state)); cdev->control_state, sizeof(cdev->control_state));
} }
return 1; return 1;
...@@ -490,7 +490,7 @@ static struct caiaq_controller kontrols4_controller[] = { ...@@ -490,7 +490,7 @@ static struct caiaq_controller kontrols4_controller[] = {
}; };
static int add_controls(struct caiaq_controller *c, int num, static int add_controls(struct caiaq_controller *c, int num,
struct snd_usb_caiaqdev *dev) struct snd_usb_caiaqdev *cdev)
{ {
int i, ret; int i, ret;
struct snd_kcontrol *kc; struct snd_kcontrol *kc;
...@@ -498,8 +498,8 @@ static int add_controls(struct caiaq_controller *c, int num, ...@@ -498,8 +498,8 @@ static int add_controls(struct caiaq_controller *c, int num,
for (i = 0; i < num; i++, c++) { for (i = 0; i < num; i++, c++) {
kcontrol_template.name = c->name; kcontrol_template.name = c->name;
kcontrol_template.private_value = c->index; kcontrol_template.private_value = c->index;
kc = snd_ctl_new1(&kcontrol_template, dev); kc = snd_ctl_new1(&kcontrol_template, cdev);
ret = snd_ctl_add(dev->chip.card, kc); ret = snd_ctl_add(cdev->chip.card, kc);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -507,50 +507,50 @@ static int add_controls(struct caiaq_controller *c, int num, ...@@ -507,50 +507,50 @@ static int add_controls(struct caiaq_controller *c, int num,
return 0; return 0;
} }
int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev)
{ {
int ret = 0; int ret = 0;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
ret = add_controls(ak1_controller, ret = add_controls(ak1_controller,
ARRAY_SIZE(ak1_controller), dev); ARRAY_SIZE(ak1_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
ret = add_controls(rk2_controller, ret = add_controls(rk2_controller,
ARRAY_SIZE(rk2_controller), dev); ARRAY_SIZE(rk2_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
ret = add_controls(rk3_controller, ret = add_controls(rk3_controller,
ARRAY_SIZE(rk3_controller), dev); ARRAY_SIZE(rk3_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
ret = add_controls(kore_controller, ret = add_controls(kore_controller,
ARRAY_SIZE(kore_controller), dev); ARRAY_SIZE(kore_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
ret = add_controls(a8dj_controller, ret = add_controls(a8dj_controller,
ARRAY_SIZE(a8dj_controller), dev); ARRAY_SIZE(a8dj_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
ret = add_controls(a4dj_controller, ret = add_controls(a4dj_controller,
ARRAY_SIZE(a4dj_controller), dev); ARRAY_SIZE(a4dj_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
ret = add_controls(kontrolx1_controller, ret = add_controls(kontrolx1_controller,
ARRAY_SIZE(kontrolx1_controller), dev); ARRAY_SIZE(kontrolx1_controller), cdev);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
ret = add_controls(kontrols4_controller, ret = add_controls(kontrols4_controller,
ARRAY_SIZE(kontrols4_controller), dev); ARRAY_SIZE(kontrols4_controller), cdev);
break; break;
} }
......
#ifndef CAIAQ_CONTROL_H #ifndef CAIAQ_CONTROL_H
#define CAIAQ_CONTROL_H #define CAIAQ_CONTROL_H
int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev); int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev);
#endif /* CAIAQ_CONTROL_H */ #endif /* CAIAQ_CONTROL_H */
...@@ -158,67 +158,67 @@ static struct usb_device_id snd_usb_id_table[] = { ...@@ -158,67 +158,67 @@ static struct usb_device_id snd_usb_id_table[] = {
static void usb_ep1_command_reply_dispatch (struct urb* urb) static void usb_ep1_command_reply_dispatch (struct urb* urb)
{ {
int ret; int ret;
struct snd_usb_caiaqdev *dev = urb->context; struct snd_usb_caiaqdev *cdev = urb->context;
unsigned char *buf = urb->transfer_buffer; unsigned char *buf = urb->transfer_buffer;
if (urb->status || !dev) { if (urb->status || !cdev) {
log("received EP1 urb->status = %i\n", urb->status); log("received EP1 urb->status = %i\n", urb->status);
return; return;
} }
switch(buf[0]) { switch(buf[0]) {
case EP1_CMD_GET_DEVICE_INFO: case EP1_CMD_GET_DEVICE_INFO:
memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec)); memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec));
dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version); cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version);
debug("device spec (firmware %d): audio: %d in, %d out, " debug("device spec (firmware %d): audio: %d in, %d out, "
"MIDI: %d in, %d out, data alignment %d\n", "MIDI: %d in, %d out, data alignment %d\n",
dev->spec.fw_version, cdev->spec.fw_version,
dev->spec.num_analog_audio_in, cdev->spec.num_analog_audio_in,
dev->spec.num_analog_audio_out, cdev->spec.num_analog_audio_out,
dev->spec.num_midi_in, cdev->spec.num_midi_in,
dev->spec.num_midi_out, cdev->spec.num_midi_out,
dev->spec.data_alignment); cdev->spec.data_alignment);
dev->spec_received++; cdev->spec_received++;
wake_up(&dev->ep1_wait_queue); wake_up(&cdev->ep1_wait_queue);
break; break;
case EP1_CMD_AUDIO_PARAMS: case EP1_CMD_AUDIO_PARAMS:
dev->audio_parm_answer = buf[1]; cdev->audio_parm_answer = buf[1];
wake_up(&dev->ep1_wait_queue); wake_up(&cdev->ep1_wait_queue);
break; break;
case EP1_CMD_MIDI_READ: case EP1_CMD_MIDI_READ:
snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); snd_usb_caiaq_midi_handle_input(cdev, buf[1], buf + 3, buf[2]);
break; break;
case EP1_CMD_READ_IO: case EP1_CMD_READ_IO:
if (dev->chip.usb_id == if (cdev->chip.usb_id ==
USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) {
if (urb->actual_length > sizeof(dev->control_state)) if (urb->actual_length > sizeof(cdev->control_state))
urb->actual_length = sizeof(dev->control_state); urb->actual_length = sizeof(cdev->control_state);
memcpy(dev->control_state, buf + 1, urb->actual_length); memcpy(cdev->control_state, buf + 1, urb->actual_length);
wake_up(&dev->ep1_wait_queue); wake_up(&cdev->ep1_wait_queue);
break; break;
} }
#ifdef CONFIG_SND_USB_CAIAQ_INPUT #ifdef CONFIG_SND_USB_CAIAQ_INPUT
case EP1_CMD_READ_ERP: case EP1_CMD_READ_ERP:
case EP1_CMD_READ_ANALOG: case EP1_CMD_READ_ANALOG:
snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length);
#endif #endif
break; break;
} }
dev->ep1_in_urb.actual_length = 0; cdev->ep1_in_urb.actual_length = 0;
ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC); ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC);
if (ret < 0) if (ret < 0)
log("unable to submit urb. OOM!?\n"); log("unable to submit urb. OOM!?\n");
} }
int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
unsigned char command, unsigned char command,
const unsigned char *buffer, const unsigned char *buffer,
int len) int len)
{ {
int actual_len; int actual_len;
struct usb_device *usb_dev = dev->chip.dev; struct usb_device *usb_dev = cdev->chip.dev;
if (!usb_dev) if (!usb_dev)
return -EIO; return -EIO;
...@@ -227,14 +227,14 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, ...@@ -227,14 +227,14 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
len = EP1_BUFSIZE - 1; len = EP1_BUFSIZE - 1;
if (buffer && len > 0) if (buffer && len > 0)
memcpy(dev->ep1_out_buf+1, buffer, len); memcpy(cdev->ep1_out_buf+1, buffer, len);
dev->ep1_out_buf[0] = command; cdev->ep1_out_buf[0] = command;
return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
dev->ep1_out_buf, len+1, &actual_len, 200); cdev->ep1_out_buf, len+1, &actual_len, 200);
} }
int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
int rate, int depth, int bpp) int rate, int depth, int bpp)
{ {
int ret; int ret;
...@@ -262,46 +262,46 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, ...@@ -262,46 +262,46 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
debug("setting audio params: %d Hz, %d bits, %d bpp\n", debug("setting audio params: %d Hz, %d bits, %d bpp\n",
rate, depth, bpp); rate, depth, bpp);
dev->audio_parm_answer = -1; cdev->audio_parm_answer = -1;
ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS, ret = snd_usb_caiaq_send_command(cdev, EP1_CMD_AUDIO_PARAMS,
tmp, sizeof(tmp)); tmp, sizeof(tmp));
if (ret) if (ret)
return ret; return ret;
if (!wait_event_timeout(dev->ep1_wait_queue, if (!wait_event_timeout(cdev->ep1_wait_queue,
dev->audio_parm_answer >= 0, HZ)) cdev->audio_parm_answer >= 0, HZ))
return -EPIPE; return -EPIPE;
if (dev->audio_parm_answer != 1) if (cdev->audio_parm_answer != 1)
debug("unable to set the device's audio params\n"); debug("unable to set the device's audio params\n");
else else
dev->bpp = bpp; cdev->bpp = bpp;
return dev->audio_parm_answer == 1 ? 0 : -EINVAL; return cdev->audio_parm_answer == 1 ? 0 : -EINVAL;
} }
int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *cdev,
int digital, int analog, int erp) int digital, int analog, int erp)
{ {
char tmp[3] = { digital, analog, erp }; char tmp[3] = { digital, analog, erp };
return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, return snd_usb_caiaq_send_command(cdev, EP1_CMD_AUTO_MSG,
tmp, sizeof(tmp)); tmp, sizeof(tmp));
} }
static void setup_card(struct snd_usb_caiaqdev *dev) static void setup_card(struct snd_usb_caiaqdev *cdev)
{ {
int ret; int ret;
char val[4]; char val[4];
/* device-specific startup specials */ /* device-specific startup specials */
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
/* RigKontrol2 - display centered dash ('-') */ /* RigKontrol2 - display centered dash ('-') */
val[0] = 0x00; val[0] = 0x00;
val[1] = 0x00; val[1] = 0x00;
val[2] = 0x01; val[2] = 0x01;
snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3); snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 3);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
/* RigKontrol2 - display two centered dashes ('--') */ /* RigKontrol2 - display two centered dashes ('--') */
...@@ -309,67 +309,67 @@ static void setup_card(struct snd_usb_caiaqdev *dev) ...@@ -309,67 +309,67 @@ static void setup_card(struct snd_usb_caiaqdev *dev)
val[1] = 0x40; val[1] = 0x40;
val[2] = 0x40; val[2] = 0x40;
val[3] = 0x00; val[3] = 0x00;
snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4); snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 4);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
/* Audio Kontrol 1 - make USB-LED stop blinking */ /* Audio Kontrol 1 - make USB-LED stop blinking */
val[0] = 0x00; val[0] = 0x00;
snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1); snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 1);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
/* Audio 8 DJ - trigger read of current settings */ /* Audio 8 DJ - trigger read of current settings */
dev->control_state[0] = 0xff; cdev->control_state[0] = 0xff;
snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0); snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 0);
snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0); snd_usb_caiaq_send_command(cdev, EP1_CMD_READ_IO, NULL, 0);
if (!wait_event_timeout(dev->ep1_wait_queue, if (!wait_event_timeout(cdev->ep1_wait_queue,
dev->control_state[0] != 0xff, HZ)) cdev->control_state[0] != 0xff, HZ))
return; return;
/* fix up some defaults */ /* fix up some defaults */
if ((dev->control_state[1] != 2) || if ((cdev->control_state[1] != 2) ||
(dev->control_state[2] != 3) || (cdev->control_state[2] != 3) ||
(dev->control_state[4] != 2)) { (cdev->control_state[4] != 2)) {
dev->control_state[1] = 2; cdev->control_state[1] = 2;
dev->control_state[2] = 3; cdev->control_state[2] = 3;
dev->control_state[4] = 2; cdev->control_state[4] = 2;
snd_usb_caiaq_send_command(dev, snd_usb_caiaq_send_command(cdev,
EP1_CMD_WRITE_IO, dev->control_state, 6); EP1_CMD_WRITE_IO, cdev->control_state, 6);
} }
break; break;
} }
if (dev->spec.num_analog_audio_out + if (cdev->spec.num_analog_audio_out +
dev->spec.num_analog_audio_in + cdev->spec.num_analog_audio_in +
dev->spec.num_digital_audio_out + cdev->spec.num_digital_audio_out +
dev->spec.num_digital_audio_in > 0) { cdev->spec.num_digital_audio_in > 0) {
ret = snd_usb_caiaq_audio_init(dev); ret = snd_usb_caiaq_audio_init(cdev);
if (ret < 0) if (ret < 0)
log("Unable to set up audio system (ret=%d)\n", ret); log("Unable to set up audio system (ret=%d)\n", ret);
} }
if (dev->spec.num_midi_in + if (cdev->spec.num_midi_in +
dev->spec.num_midi_out > 0) { cdev->spec.num_midi_out > 0) {
ret = snd_usb_caiaq_midi_init(dev); ret = snd_usb_caiaq_midi_init(cdev);
if (ret < 0) if (ret < 0)
log("Unable to set up MIDI system (ret=%d)\n", ret); log("Unable to set up MIDI system (ret=%d)\n", ret);
} }
#ifdef CONFIG_SND_USB_CAIAQ_INPUT #ifdef CONFIG_SND_USB_CAIAQ_INPUT
ret = snd_usb_caiaq_input_init(dev); ret = snd_usb_caiaq_input_init(cdev);
if (ret < 0) if (ret < 0)
log("Unable to set up input system (ret=%d)\n", ret); log("Unable to set up input system (ret=%d)\n", ret);
#endif #endif
/* finally, register the card and all its sub-instances */ /* finally, register the card and all its sub-instances */
ret = snd_card_register(dev->chip.card); ret = snd_card_register(cdev->chip.card);
if (ret < 0) { if (ret < 0) {
log("snd_card_register() returned %d\n", ret); log("snd_card_register() returned %d\n", ret);
snd_card_free(dev->chip.card); snd_card_free(cdev->chip.card);
} }
ret = snd_usb_caiaq_control_init(dev); ret = snd_usb_caiaq_control_init(cdev);
if (ret < 0) if (ret < 0)
log("Unable to set up control system (ret=%d)\n", ret); log("Unable to set up control system (ret=%d)\n", ret);
} }
...@@ -381,7 +381,7 @@ static int create_card(struct usb_device *usb_dev, ...@@ -381,7 +381,7 @@ static int create_card(struct usb_device *usb_dev,
int devnum; int devnum;
int err; int err;
struct snd_card *card; struct snd_card *card;
struct snd_usb_caiaqdev *dev; struct snd_usb_caiaqdev *cdev;
for (devnum = 0; devnum < SNDRV_CARDS; devnum++) for (devnum = 0; devnum < SNDRV_CARDS; devnum++)
if (enable[devnum] && !snd_card_used[devnum]) if (enable[devnum] && !snd_card_used[devnum])
...@@ -395,23 +395,23 @@ static int create_card(struct usb_device *usb_dev, ...@@ -395,23 +395,23 @@ static int create_card(struct usb_device *usb_dev,
if (err < 0) if (err < 0)
return err; return err;
dev = caiaqdev(card); cdev = caiaqdev(card);
dev->chip.dev = usb_dev; cdev->chip.dev = usb_dev;
dev->chip.card = card; cdev->chip.card = card;
dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
le16_to_cpu(usb_dev->descriptor.idProduct)); le16_to_cpu(usb_dev->descriptor.idProduct));
spin_lock_init(&dev->spinlock); spin_lock_init(&cdev->spinlock);
snd_card_set_dev(card, &intf->dev); snd_card_set_dev(card, &intf->dev);
*cardp = card; *cardp = card;
return 0; return 0;
} }
static int init_card(struct snd_usb_caiaqdev *dev) static int init_card(struct snd_usb_caiaqdev *cdev)
{ {
char *c, usbpath[32]; char *c, usbpath[32];
struct usb_device *usb_dev = dev->chip.dev; struct usb_device *usb_dev = cdev->chip.dev;
struct snd_card *card = dev->chip.card; struct snd_card *card = cdev->chip.card;
int err, len; int err, len;
if (usb_set_interface(usb_dev, 0, 1) != 0) { if (usb_set_interface(usb_dev, 0, 1) != 0) {
...@@ -419,41 +419,41 @@ static int init_card(struct snd_usb_caiaqdev *dev) ...@@ -419,41 +419,41 @@ static int init_card(struct snd_usb_caiaqdev *dev)
return -EIO; return -EIO;
} }
usb_init_urb(&dev->ep1_in_urb); usb_init_urb(&cdev->ep1_in_urb);
usb_init_urb(&dev->midi_out_urb); usb_init_urb(&cdev->midi_out_urb);
usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, usb_fill_bulk_urb(&cdev->ep1_in_urb, usb_dev,
usb_rcvbulkpipe(usb_dev, 0x1), usb_rcvbulkpipe(usb_dev, 0x1),
dev->ep1_in_buf, EP1_BUFSIZE, cdev->ep1_in_buf, EP1_BUFSIZE,
usb_ep1_command_reply_dispatch, dev); usb_ep1_command_reply_dispatch, cdev);
usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, usb_fill_bulk_urb(&cdev->midi_out_urb, usb_dev,
usb_sndbulkpipe(usb_dev, 0x1), usb_sndbulkpipe(usb_dev, 0x1),
dev->midi_out_buf, EP1_BUFSIZE, cdev->midi_out_buf, EP1_BUFSIZE,
snd_usb_caiaq_midi_output_done, dev); snd_usb_caiaq_midi_output_done, cdev);
init_waitqueue_head(&dev->ep1_wait_queue); init_waitqueue_head(&cdev->ep1_wait_queue);
init_waitqueue_head(&dev->prepare_wait_queue); init_waitqueue_head(&cdev->prepare_wait_queue);
if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0)
return -EIO; return -EIO;
err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
if (err) if (err)
return err; return err;
if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ)) if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ))
return -ENODEV; return -ENODEV;
usb_string(usb_dev, usb_dev->descriptor.iManufacturer, usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
dev->vendor_name, CAIAQ_USB_STR_LEN); cdev->vendor_name, CAIAQ_USB_STR_LEN);
usb_string(usb_dev, usb_dev->descriptor.iProduct, usb_string(usb_dev, usb_dev->descriptor.iProduct,
dev->product_name, CAIAQ_USB_STR_LEN); cdev->product_name, CAIAQ_USB_STR_LEN);
strlcpy(card->driver, MODNAME, sizeof(card->driver)); strlcpy(card->driver, MODNAME, sizeof(card->driver));
strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); strlcpy(card->shortname, cdev->product_name, sizeof(card->shortname));
strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); strlcpy(card->mixername, cdev->product_name, sizeof(card->mixername));
/* if the id was not passed as module option, fill it with a shortened /* if the id was not passed as module option, fill it with a shortened
* version of the product string which does not contain any * version of the product string which does not contain any
...@@ -475,9 +475,9 @@ static int init_card(struct snd_usb_caiaqdev *dev) ...@@ -475,9 +475,9 @@ static int init_card(struct snd_usb_caiaqdev *dev)
usb_make_path(usb_dev, usbpath, sizeof(usbpath)); usb_make_path(usb_dev, usbpath, sizeof(usbpath));
snprintf(card->longname, sizeof(card->longname), snprintf(card->longname, sizeof(card->longname),
"%s %s (%s)", "%s %s (%s)",
dev->vendor_name, dev->product_name, usbpath); cdev->vendor_name, cdev->product_name, usbpath);
setup_card(dev); setup_card(cdev);
return 0; return 0;
} }
...@@ -486,9 +486,9 @@ static int snd_probe(struct usb_interface *intf, ...@@ -486,9 +486,9 @@ static int snd_probe(struct usb_interface *intf,
{ {
int ret; int ret;
struct snd_card *card = NULL; struct snd_card *card = NULL;
struct usb_device *device = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
ret = create_card(device, intf, &card); ret = create_card(usb_dev, intf, &card);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -506,7 +506,7 @@ static int snd_probe(struct usb_interface *intf, ...@@ -506,7 +506,7 @@ static int snd_probe(struct usb_interface *intf,
static void snd_disconnect(struct usb_interface *intf) static void snd_disconnect(struct usb_interface *intf)
{ {
struct snd_usb_caiaqdev *dev; struct snd_usb_caiaqdev *cdev;
struct snd_card *card = usb_get_intfdata(intf); struct snd_card *card = usb_get_intfdata(intf);
debug("%s(%p)\n", __func__, intf); debug("%s(%p)\n", __func__, intf);
...@@ -514,16 +514,16 @@ static void snd_disconnect(struct usb_interface *intf) ...@@ -514,16 +514,16 @@ static void snd_disconnect(struct usb_interface *intf)
if (!card) if (!card)
return; return;
dev = caiaqdev(card); cdev = caiaqdev(card);
snd_card_disconnect(card); snd_card_disconnect(card);
#ifdef CONFIG_SND_USB_CAIAQ_INPUT #ifdef CONFIG_SND_USB_CAIAQ_INPUT
snd_usb_caiaq_input_free(dev); snd_usb_caiaq_input_free(cdev);
#endif #endif
snd_usb_caiaq_audio_free(dev); snd_usb_caiaq_audio_free(cdev);
usb_kill_urb(&dev->ep1_in_urb); usb_kill_urb(&cdev->ep1_in_urb);
usb_kill_urb(&dev->midi_out_urb); usb_kill_urb(&cdev->midi_out_urb);
snd_card_free(card); snd_card_free(card);
usb_reset_device(interface_to_usbdev(intf)); usb_reset_device(interface_to_usbdev(intf));
......
...@@ -124,15 +124,15 @@ struct snd_usb_caiaqdev { ...@@ -124,15 +124,15 @@ struct snd_usb_caiaqdev {
}; };
struct snd_usb_caiaq_cb_info { struct snd_usb_caiaq_cb_info {
struct snd_usb_caiaqdev *dev; struct snd_usb_caiaqdev *cdev;
int index; int index;
}; };
#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp); int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp);
int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp); int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp);
int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
unsigned char command, unsigned char command,
const unsigned char *buffer, const unsigned char *buffer,
int len); int len);
......
...@@ -199,55 +199,55 @@ static unsigned int decode_erp(unsigned char a, unsigned char b) ...@@ -199,55 +199,55 @@ static unsigned int decode_erp(unsigned char a, unsigned char b)
#undef HIGH_PEAK #undef HIGH_PEAK
#undef LOW_PEAK #undef LOW_PEAK
static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *dev, static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *cdev,
int axis, const unsigned char *buf, int axis, const unsigned char *buf,
int offset) int offset)
{ {
input_report_abs(dev->input_dev, axis, input_report_abs(cdev->input_dev, axis,
(buf[offset * 2] << 8) | buf[offset * 2 + 1]); (buf[offset * 2] << 8) | buf[offset * 2 + 1]);
} }
static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *cdev,
const unsigned char *buf, const unsigned char *buf,
unsigned int len) unsigned int len)
{ {
struct input_dev *input_dev = dev->input_dev; struct input_dev *input_dev = cdev->input_dev;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
snd_caiaq_input_report_abs(dev, ABS_X, buf, 2); snd_caiaq_input_report_abs(cdev, ABS_X, buf, 2);
snd_caiaq_input_report_abs(dev, ABS_Y, buf, 0); snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 0);
snd_caiaq_input_report_abs(dev, ABS_Z, buf, 1); snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 1);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
snd_caiaq_input_report_abs(dev, ABS_X, buf, 0); snd_caiaq_input_report_abs(cdev, ABS_X, buf, 0);
snd_caiaq_input_report_abs(dev, ABS_Y, buf, 1); snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 1);
snd_caiaq_input_report_abs(dev, ABS_Z, buf, 2); snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 2);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
snd_caiaq_input_report_abs(dev, ABS_HAT0X, buf, 4); snd_caiaq_input_report_abs(cdev, ABS_HAT0X, buf, 4);
snd_caiaq_input_report_abs(dev, ABS_HAT0Y, buf, 2); snd_caiaq_input_report_abs(cdev, ABS_HAT0Y, buf, 2);
snd_caiaq_input_report_abs(dev, ABS_HAT1X, buf, 6); snd_caiaq_input_report_abs(cdev, ABS_HAT1X, buf, 6);
snd_caiaq_input_report_abs(dev, ABS_HAT1Y, buf, 1); snd_caiaq_input_report_abs(cdev, ABS_HAT1Y, buf, 1);
snd_caiaq_input_report_abs(dev, ABS_HAT2X, buf, 7); snd_caiaq_input_report_abs(cdev, ABS_HAT2X, buf, 7);
snd_caiaq_input_report_abs(dev, ABS_HAT2Y, buf, 0); snd_caiaq_input_report_abs(cdev, ABS_HAT2Y, buf, 0);
snd_caiaq_input_report_abs(dev, ABS_HAT3X, buf, 5); snd_caiaq_input_report_abs(cdev, ABS_HAT3X, buf, 5);
snd_caiaq_input_report_abs(dev, ABS_HAT3Y, buf, 3); snd_caiaq_input_report_abs(cdev, ABS_HAT3Y, buf, 3);
break; break;
} }
input_sync(input_dev); input_sync(input_dev);
} }
static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *cdev,
const char *buf, unsigned int len) const char *buf, unsigned int len)
{ {
struct input_dev *input_dev = dev->input_dev; struct input_dev *input_dev = cdev->input_dev;
int i; int i;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
i = decode_erp(buf[0], buf[1]); i = decode_erp(buf[0], buf[1]);
input_report_abs(input_dev, ABS_X, i); input_report_abs(input_dev, ABS_X, i);
...@@ -299,10 +299,10 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, ...@@ -299,10 +299,10 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev,
} }
} }
static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *cdev,
unsigned char *buf, unsigned int len) unsigned char *buf, unsigned int len)
{ {
struct input_dev *input_dev = dev->input_dev; struct input_dev *input_dev = cdev->input_dev;
unsigned short *keycode = input_dev->keycode; unsigned short *keycode = input_dev->keycode;
int i; int i;
...@@ -317,17 +317,17 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, ...@@ -317,17 +317,17 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
input_report_key(input_dev, keycode[i], input_report_key(input_dev, keycode[i],
buf[i / 8] & (1 << (i % 8))); buf[i / 8] & (1 << (i % 8)));
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]); input_report_abs(cdev->input_dev, ABS_MISC, 255 - buf[4]);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
/* rotary encoders */ /* rotary encoders */
input_report_abs(dev->input_dev, ABS_X, buf[5] & 0xf); input_report_abs(cdev->input_dev, ABS_X, buf[5] & 0xf);
input_report_abs(dev->input_dev, ABS_Y, buf[5] >> 4); input_report_abs(cdev->input_dev, ABS_Y, buf[5] >> 4);
input_report_abs(dev->input_dev, ABS_Z, buf[6] & 0xf); input_report_abs(cdev->input_dev, ABS_Z, buf[6] & 0xf);
input_report_abs(dev->input_dev, ABS_MISC, buf[6] >> 4); input_report_abs(cdev->input_dev, ABS_MISC, buf[6] >> 4);
break; break;
} }
...@@ -336,7 +336,7 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, ...@@ -336,7 +336,7 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
#define TKS4_MSGBLOCK_SIZE 16 #define TKS4_MSGBLOCK_SIZE 16
static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev,
const unsigned char *buf, const unsigned char *buf,
unsigned int len) unsigned int len)
{ {
...@@ -347,121 +347,121 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, ...@@ -347,121 +347,121 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev,
case 0: case 0:
/* buttons */ /* buttons */
for (i = 0; i < KONTROLS4_BUTTONS; i++) for (i = 0; i < KONTROLS4_BUTTONS; i++)
input_report_key(dev->input_dev, KONTROLS4_BUTTON(i), input_report_key(cdev->input_dev, KONTROLS4_BUTTON(i),
(buf[4 + (i / 8)] >> (i % 8)) & 1); (buf[4 + (i / 8)] >> (i % 8)) & 1);
break; break;
case 1: case 1:
/* left wheel */ /* left wheel */
input_report_abs(dev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); input_report_abs(cdev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8));
/* right wheel */ /* right wheel */
input_report_abs(dev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); input_report_abs(cdev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8));
/* rotary encoders */ /* rotary encoders */
input_report_abs(dev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); input_report_abs(cdev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf);
input_report_abs(dev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); input_report_abs(cdev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4);
input_report_abs(dev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); input_report_abs(cdev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf);
input_report_abs(dev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); input_report_abs(cdev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4);
input_report_abs(dev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); input_report_abs(cdev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf);
input_report_abs(dev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); input_report_abs(cdev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4);
input_report_abs(dev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); input_report_abs(cdev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf);
input_report_abs(dev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); input_report_abs(cdev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4);
input_report_abs(dev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); input_report_abs(cdev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf);
break; break;
case 2: case 2:
/* Volume Fader Channel D */ /* Volume Fader Channel D */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(0), buf, 1); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(0), buf, 1);
/* Volume Fader Channel B */ /* Volume Fader Channel B */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(1), buf, 2); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(1), buf, 2);
/* Volume Fader Channel A */ /* Volume Fader Channel A */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(2), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(2), buf, 3);
/* Volume Fader Channel C */ /* Volume Fader Channel C */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(3), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(3), buf, 4);
/* Loop Volume */ /* Loop Volume */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(4), buf, 6); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(4), buf, 6);
/* Crossfader */ /* Crossfader */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(7), buf, 7); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(7), buf, 7);
break; break;
case 3: case 3:
/* Tempo Fader R */ /* Tempo Fader R */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(6), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(6), buf, 3);
/* Tempo Fader L */ /* Tempo Fader L */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(5), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(5), buf, 4);
/* Mic Volume */ /* Mic Volume */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(8), buf, 6); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(8), buf, 6);
/* Cue Mix */ /* Cue Mix */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(9), buf, 7); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(9), buf, 7);
break; break;
case 4: case 4:
/* Wheel distance sensor L */ /* Wheel distance sensor L */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(10), buf, 1); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(10), buf, 1);
/* Wheel distance sensor R */ /* Wheel distance sensor R */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(11), buf, 2); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(11), buf, 2);
/* Channel D EQ - Filter */ /* Channel D EQ - Filter */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(12), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(12), buf, 3);
/* Channel D EQ - Low */ /* Channel D EQ - Low */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(13), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(13), buf, 4);
/* Channel D EQ - Mid */ /* Channel D EQ - Mid */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(14), buf, 5); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(14), buf, 5);
/* Channel D EQ - Hi */ /* Channel D EQ - Hi */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(15), buf, 6); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(15), buf, 6);
/* FX2 - dry/wet */ /* FX2 - dry/wet */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(16), buf, 7); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(16), buf, 7);
break; break;
case 5: case 5:
/* FX2 - 1 */ /* FX2 - 1 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(17), buf, 1); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(17), buf, 1);
/* FX2 - 2 */ /* FX2 - 2 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(18), buf, 2); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(18), buf, 2);
/* FX2 - 3 */ /* FX2 - 3 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(19), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(19), buf, 3);
/* Channel B EQ - Filter */ /* Channel B EQ - Filter */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(20), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(20), buf, 4);
/* Channel B EQ - Low */ /* Channel B EQ - Low */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(21), buf, 5); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(21), buf, 5);
/* Channel B EQ - Mid */ /* Channel B EQ - Mid */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(22), buf, 6); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(22), buf, 6);
/* Channel B EQ - Hi */ /* Channel B EQ - Hi */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(23), buf, 7); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(23), buf, 7);
break; break;
case 6: case 6:
/* Channel A EQ - Filter */ /* Channel A EQ - Filter */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(24), buf, 1); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(24), buf, 1);
/* Channel A EQ - Low */ /* Channel A EQ - Low */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(25), buf, 2); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(25), buf, 2);
/* Channel A EQ - Mid */ /* Channel A EQ - Mid */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(26), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(26), buf, 3);
/* Channel A EQ - Hi */ /* Channel A EQ - Hi */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(27), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(27), buf, 4);
/* Channel C EQ - Filter */ /* Channel C EQ - Filter */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(28), buf, 5); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(28), buf, 5);
/* Channel C EQ - Low */ /* Channel C EQ - Low */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(29), buf, 6); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(29), buf, 6);
/* Channel C EQ - Mid */ /* Channel C EQ - Mid */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(30), buf, 7); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(30), buf, 7);
break; break;
case 7: case 7:
/* Channel C EQ - Hi */ /* Channel C EQ - Hi */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(31), buf, 1); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(31), buf, 1);
/* FX1 - wet/dry */ /* FX1 - wet/dry */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(32), buf, 2); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(32), buf, 2);
/* FX1 - 1 */ /* FX1 - 1 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(33), buf, 3); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(33), buf, 3);
/* FX1 - 2 */ /* FX1 - 2 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(34), buf, 4); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(34), buf, 4);
/* FX1 - 3 */ /* FX1 - 3 */
snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(35), buf, 5); snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(35), buf, 5);
break; break;
...@@ -475,12 +475,12 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, ...@@ -475,12 +475,12 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev,
buf += TKS4_MSGBLOCK_SIZE; buf += TKS4_MSGBLOCK_SIZE;
} }
input_sync(dev->input_dev); input_sync(cdev->input_dev);
} }
#define MASCHINE_MSGBLOCK_SIZE 2 #define MASCHINE_MSGBLOCK_SIZE 2
static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev,
const unsigned char *buf, const unsigned char *buf,
unsigned int len) unsigned int len)
{ {
...@@ -491,65 +491,65 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, ...@@ -491,65 +491,65 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev,
pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]);
pad_id = pressure >> 12; pad_id = pressure >> 12;
input_report_abs(dev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff);
} }
input_sync(dev->input_dev); input_sync(cdev->input_dev);
} }
static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb)
{ {
struct snd_usb_caiaqdev *dev = urb->context; struct snd_usb_caiaqdev *cdev = urb->context;
unsigned char *buf = urb->transfer_buffer; unsigned char *buf = urb->transfer_buffer;
int ret; int ret;
if (urb->status || !dev || urb != dev->ep4_in_urb) if (urb->status || !cdev || urb != cdev->ep4_in_urb)
return; return;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
if (urb->actual_length < 24) if (urb->actual_length < 24)
goto requeue; goto requeue;
if (buf[0] & 0x3) if (buf[0] & 0x3)
snd_caiaq_input_read_io(dev, buf + 1, 7); snd_caiaq_input_read_io(cdev, buf + 1, 7);
if (buf[0] & 0x4) if (buf[0] & 0x4)
snd_caiaq_input_read_analog(dev, buf + 8, 16); snd_caiaq_input_read_analog(cdev, buf + 8, 16);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
snd_usb_caiaq_tks4_dispatch(dev, buf, urb->actual_length); snd_usb_caiaq_tks4_dispatch(cdev, buf, urb->actual_length);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE))
goto requeue; goto requeue;
snd_usb_caiaq_maschine_dispatch(dev, buf, urb->actual_length); snd_usb_caiaq_maschine_dispatch(cdev, buf, urb->actual_length);
break; break;
} }
requeue: requeue:
dev->ep4_in_urb->actual_length = 0; cdev->ep4_in_urb->actual_length = 0;
ret = usb_submit_urb(dev->ep4_in_urb, GFP_ATOMIC); ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC);
if (ret < 0) if (ret < 0)
log("unable to submit urb. OOM!?\n"); log("unable to submit urb. OOM!?\n");
} }
static int snd_usb_caiaq_input_open(struct input_dev *idev) static int snd_usb_caiaq_input_open(struct input_dev *idev)
{ {
struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev);
if (!dev) if (!cdev)
return -EINVAL; return -EINVAL;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
if (usb_submit_urb(dev->ep4_in_urb, GFP_KERNEL) != 0) if (usb_submit_urb(cdev->ep4_in_urb, GFP_KERNEL) != 0)
return -EIO; return -EIO;
break; break;
} }
...@@ -559,43 +559,43 @@ static int snd_usb_caiaq_input_open(struct input_dev *idev) ...@@ -559,43 +559,43 @@ static int snd_usb_caiaq_input_open(struct input_dev *idev)
static void snd_usb_caiaq_input_close(struct input_dev *idev) static void snd_usb_caiaq_input_close(struct input_dev *idev)
{ {
struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev);
if (!dev) if (!cdev)
return; return;
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
usb_kill_urb(dev->ep4_in_urb); usb_kill_urb(cdev->ep4_in_urb);
break; break;
} }
} }
void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev,
char *buf, char *buf,
unsigned int len) unsigned int len)
{ {
if (!dev->input_dev || len < 1) if (!cdev->input_dev || len < 1)
return; return;
switch (buf[0]) { switch (buf[0]) {
case EP1_CMD_READ_ANALOG: case EP1_CMD_READ_ANALOG:
snd_caiaq_input_read_analog(dev, buf + 1, len - 1); snd_caiaq_input_read_analog(cdev, buf + 1, len - 1);
break; break;
case EP1_CMD_READ_ERP: case EP1_CMD_READ_ERP:
snd_caiaq_input_read_erp(dev, buf + 1, len - 1); snd_caiaq_input_read_erp(cdev, buf + 1, len - 1);
break; break;
case EP1_CMD_READ_IO: case EP1_CMD_READ_IO:
snd_caiaq_input_read_io(dev, buf + 1, len - 1); snd_caiaq_input_read_io(cdev, buf + 1, len - 1);
break; break;
} }
} }
int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)
{ {
struct usb_device *usb_dev = dev->chip.dev; struct usb_device *usb_dev = cdev->chip.dev;
struct input_dev *input; struct input_dev *input;
int i, ret = 0; int i, ret = 0;
...@@ -603,49 +603,49 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -603,49 +603,49 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
if (!input) if (!input)
return -ENOMEM; return -ENOMEM;
usb_make_path(usb_dev, dev->phys, sizeof(dev->phys)); usb_make_path(usb_dev, cdev->phys, sizeof(cdev->phys));
strlcat(dev->phys, "/input0", sizeof(dev->phys)); strlcat(cdev->phys, "/input0", sizeof(cdev->phys));
input->name = dev->product_name; input->name = cdev->product_name;
input->phys = dev->phys; input->phys = cdev->phys;
usb_to_input_id(usb_dev, &input->id); usb_to_input_id(usb_dev, &input->id);
input->dev.parent = &usb_dev->dev; input->dev.parent = &usb_dev->dev;
input_set_drvdata(input, dev); input_set_drvdata(input, cdev);
switch (dev->chip.usb_id) { switch (cdev->chip.usb_id) {
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
BIT_MASK(ABS_Z); BIT_MASK(ABS_Z);
BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2)); BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk2));
memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2)); memcpy(cdev->keycode, keycode_rk2, sizeof(keycode_rk2));
input->keycodemax = ARRAY_SIZE(keycode_rk2); input->keycodemax = ARRAY_SIZE(keycode_rk2);
input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
BIT_MASK(ABS_Z); BIT_MASK(ABS_Z);
BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk3));
memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); memcpy(cdev->keycode, keycode_rk3, sizeof(keycode_rk3));
input->keycodemax = ARRAY_SIZE(keycode_rk3); input->keycodemax = ARRAY_SIZE(keycode_rk3);
input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); input_set_abs_params(input, ABS_X, 0, 1024, 0, 10);
input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10);
input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input->absbit[0] = BIT_MASK(ABS_X); input->absbit[0] = BIT_MASK(ABS_X);
BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1)); BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_ak1));
memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1)); memcpy(cdev->keycode, keycode_ak1, sizeof(keycode_ak1));
input->keycodemax = ARRAY_SIZE(keycode_ak1); input->keycodemax = ARRAY_SIZE(keycode_ak1);
input_set_abs_params(input, ABS_X, 0, 999, 0, 10); input_set_abs_params(input, ABS_X, 0, 999, 0, 10);
snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 5);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
...@@ -657,8 +657,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -657,8 +657,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
BIT_MASK(ABS_Z); BIT_MASK(ABS_Z);
input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore)); BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_kore));
memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore)); memcpy(cdev->keycode, keycode_kore, sizeof(keycode_kore));
input->keycodemax = ARRAY_SIZE(keycode_kore); input->keycodemax = ARRAY_SIZE(keycode_kore);
input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10);
input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10);
...@@ -672,7 +672,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -672,7 +672,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
...@@ -683,9 +683,9 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -683,9 +683,9 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
BIT_MASK(ABS_Z); BIT_MASK(ABS_Z);
input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLX1_INPUTS); BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLX1_INPUTS);
for (i = 0; i < KONTROLX1_INPUTS; i++) for (i = 0; i < KONTROLX1_INPUTS; i++)
dev->keycode[i] = BTN_MISC + i; cdev->keycode[i] = BTN_MISC + i;
input->keycodemax = KONTROLX1_INPUTS; input->keycodemax = KONTROLX1_INPUTS;
/* analog potentiometers */ /* analog potentiometers */
...@@ -704,26 +704,26 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -704,26 +704,26 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1);
input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1);
dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->ep4_in_urb) { if (!cdev->ep4_in_urb) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit_free_idev; goto exit_free_idev;
} }
usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
usb_rcvbulkpipe(usb_dev, 0x4), usb_rcvbulkpipe(usb_dev, 0x4),
dev->ep4_in_buf, EP4_BUFSIZE, cdev->ep4_in_buf, EP4_BUFSIZE,
snd_usb_caiaq_ep4_reply_dispatch, dev); snd_usb_caiaq_ep4_reply_dispatch, cdev);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
break; break;
case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLS4_BUTTONS); BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLS4_BUTTONS);
for (i = 0; i < KONTROLS4_BUTTONS; i++) for (i = 0; i < KONTROLS4_BUTTONS; i++)
dev->keycode[i] = KONTROLS4_BUTTON(i); cdev->keycode[i] = KONTROLS4_BUTTON(i);
input->keycodemax = KONTROLS4_BUTTONS; input->keycodemax = KONTROLS4_BUTTONS;
for (i = 0; i < KONTROLS4_AXIS; i++) { for (i = 0; i < KONTROLS4_AXIS; i++) {
...@@ -743,18 +743,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -743,18 +743,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1);
dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->ep4_in_urb) { if (!cdev->ep4_in_urb) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit_free_idev; goto exit_free_idev;
} }
usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
usb_rcvbulkpipe(usb_dev, 0x4), usb_rcvbulkpipe(usb_dev, 0x4),
dev->ep4_in_buf, EP4_BUFSIZE, cdev->ep4_in_buf, EP4_BUFSIZE,
snd_usb_caiaq_ep4_reply_dispatch, dev); snd_usb_caiaq_ep4_reply_dispatch, cdev);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
break; break;
...@@ -767,8 +767,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -767,8 +767,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) |
BIT_MASK(ABS_RZ); BIT_MASK(ABS_RZ);
BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_maschine)); BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_maschine));
memcpy(dev->keycode, keycode_maschine, sizeof(keycode_maschine)); memcpy(cdev->keycode, keycode_maschine, sizeof(keycode_maschine));
input->keycodemax = ARRAY_SIZE(keycode_maschine); input->keycodemax = ARRAY_SIZE(keycode_maschine);
for (i = 0; i < MASCHINE_PADS; i++) { for (i = 0; i < MASCHINE_PADS; i++) {
...@@ -788,18 +788,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -788,18 +788,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); input_set_abs_params(input, ABS_RY, 0, 999, 0, 10);
input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10);
dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->ep4_in_urb) { if (!cdev->ep4_in_urb) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit_free_idev; goto exit_free_idev;
} }
usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev,
usb_rcvbulkpipe(usb_dev, 0x4), usb_rcvbulkpipe(usb_dev, 0x4),
dev->ep4_in_buf, EP4_BUFSIZE, cdev->ep4_in_buf, EP4_BUFSIZE,
snd_usb_caiaq_ep4_reply_dispatch, dev); snd_usb_caiaq_ep4_reply_dispatch, cdev);
snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5);
break; break;
default: default:
...@@ -809,12 +809,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -809,12 +809,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
input->open = snd_usb_caiaq_input_open; input->open = snd_usb_caiaq_input_open;
input->close = snd_usb_caiaq_input_close; input->close = snd_usb_caiaq_input_close;
input->keycode = dev->keycode; input->keycode = cdev->keycode;
input->keycodesize = sizeof(unsigned short); input->keycodesize = sizeof(unsigned short);
for (i = 0; i < input->keycodemax; i++) for (i = 0; i < input->keycodemax; i++)
__set_bit(dev->keycode[i], input->keybit); __set_bit(cdev->keycode[i], input->keybit);
dev->input_dev = input; cdev->input_dev = input;
ret = input_register_device(input); ret = input_register_device(input);
if (ret < 0) if (ret < 0)
...@@ -824,19 +824,19 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) ...@@ -824,19 +824,19 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
exit_free_idev: exit_free_idev:
input_free_device(input); input_free_device(input);
dev->input_dev = NULL; cdev->input_dev = NULL;
return ret; return ret;
} }
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev) void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev)
{ {
if (!dev || !dev->input_dev) if (!cdev || !cdev->input_dev)
return; return;
usb_kill_urb(dev->ep4_in_urb); usb_kill_urb(cdev->ep4_in_urb);
usb_free_urb(dev->ep4_in_urb); usb_free_urb(cdev->ep4_in_urb);
dev->ep4_in_urb = NULL; cdev->ep4_in_urb = NULL;
input_unregister_device(dev->input_dev); input_unregister_device(cdev->input_dev);
dev->input_dev = NULL; cdev->input_dev = NULL;
} }
#ifndef CAIAQ_INPUT_H #ifndef CAIAQ_INPUT_H
#define CAIAQ_INPUT_H #define CAIAQ_INPUT_H
void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, char *buf, unsigned int len); void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, char *buf, unsigned int len);
int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev); int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev);
void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev); void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev);
#endif #endif
...@@ -37,12 +37,12 @@ static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substrea ...@@ -37,12 +37,12 @@ static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substrea
static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
{ {
struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (!dev) if (!cdev)
return; return;
dev->midi_receive_substream = up ? substream : NULL; cdev->midi_receive_substream = up ? substream : NULL;
} }
...@@ -53,49 +53,49 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea ...@@ -53,49 +53,49 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea
static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream) static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
{ {
struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (dev->midi_out_active) { if (cdev->midi_out_active) {
usb_kill_urb(&dev->midi_out_urb); usb_kill_urb(&cdev->midi_out_urb);
dev->midi_out_active = 0; cdev->midi_out_active = 0;
} }
return 0; return 0;
} }
static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev,
struct snd_rawmidi_substream *substream) struct snd_rawmidi_substream *substream)
{ {
int len, ret; int len, ret;
dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
dev->midi_out_buf[1] = 0; /* port */ cdev->midi_out_buf[1] = 0; /* port */
len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, len = snd_rawmidi_transmit(substream, cdev->midi_out_buf + 3,
EP1_BUFSIZE - 3); EP1_BUFSIZE - 3);
if (len <= 0) if (len <= 0)
return; return;
dev->midi_out_buf[2] = len; cdev->midi_out_buf[2] = len;
dev->midi_out_urb.transfer_buffer_length = len+3; cdev->midi_out_urb.transfer_buffer_length = len+3;
ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC);
if (ret < 0) if (ret < 0)
log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
"ret=%d, len=%d\n", "ret=%d, len=%d\n",
substream, ret, len); substream, ret, len);
else else
dev->midi_out_active = 1; cdev->midi_out_active = 1;
} }
static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{ {
struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data;
if (up) { if (up) {
dev->midi_out_substream = substream; cdev->midi_out_substream = substream;
if (!dev->midi_out_active) if (!cdev->midi_out_active)
snd_usb_caiaq_midi_send(dev, substream); snd_usb_caiaq_midi_send(cdev, substream);
} else { } else {
dev->midi_out_substream = NULL; cdev->midi_out_substream = NULL;
} }
} }
...@@ -114,13 +114,13 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = ...@@ -114,13 +114,13 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input =
.trigger = snd_usb_caiaq_midi_input_trigger, .trigger = snd_usb_caiaq_midi_input_trigger,
}; };
void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *cdev,
int port, const char *buf, int len) int port, const char *buf, int len)
{ {
if (!dev->midi_receive_substream) if (!cdev->midi_receive_substream)
return; return;
snd_rawmidi_receive(dev->midi_receive_substream, buf, len); snd_rawmidi_receive(cdev->midi_receive_substream, buf, len);
} }
int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
...@@ -160,15 +160,15 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) ...@@ -160,15 +160,15 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
void snd_usb_caiaq_midi_output_done(struct urb* urb) void snd_usb_caiaq_midi_output_done(struct urb* urb)
{ {
struct snd_usb_caiaqdev *dev = urb->context; struct snd_usb_caiaqdev *cdev = urb->context;
dev->midi_out_active = 0; cdev->midi_out_active = 0;
if (urb->status != 0) if (urb->status != 0)
return; return;
if (!dev->midi_out_substream) if (!cdev->midi_out_substream)
return; return;
snd_usb_caiaq_midi_send(dev, dev->midi_out_substream); snd_usb_caiaq_midi_send(cdev, cdev->midi_out_substream);
} }
#ifndef CAIAQ_MIDI_H #ifndef CAIAQ_MIDI_H
#define CAIAQ_MIDI_H #define CAIAQ_MIDI_H
int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev); int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *cdev);
void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len); void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *cdev,
int port, const char *buf, int len);
void snd_usb_caiaq_midi_output_done(struct urb *urb); void snd_usb_caiaq_midi_output_done(struct urb *urb);
#endif /* CAIAQ_MIDI_H */ #endif /* CAIAQ_MIDI_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment