ALSA: snd_usb_caiaq: clean whitespaces
Subsystems (2)
PATCH 1/5 ALSA: snd_usb_caiaq: clean whitespaces
Cosmetic changes only, no code change.
Signed-off-by Daniel Mack <[email protected]>
--- sound/usb/caiaq/audio.c | 88 +++++++++++++++++++++++----------------------- sound/usb/caiaq/device.c | 60 ++++++++++++++++---------------- sound/usb/caiaq/midi.c | 24 ++++++------ 3 files changed, 86 insertions(+), 86 deletions(-)
sound/usb/caiaq/audio.c +44 -44
@@ -42,10 +42,10 @@ (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)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 |SNDRV_PCM_INFO_BLOCK_TRANSFER ), .formats =SNDRV_PCM_FMTBIT_S24_3BE , - .rates = (SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 | + .rates = (SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 |SNDRV_PCM_RATE_96000 ), .rate_min =44100 , .rate_max =0 ,/* will overwrite later */
@@ -68,7 +68,7 @@ activate_substream(struct snd_usb_caiaqdev *dev, dev->sub_capture[sub->number] = sub; } -static void +static void deactivate_substream (struct snd_usb_caiaqdev *dev,struct snd_pcm_substream *sub) {
@@ -118,7 +118,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)return -EPIPE ; } } - +return 0 ; }
@@ -129,7 +129,7 @@ static void stream_stop(struct snd_usb_caiaqdev *dev)debug ("%s(%p)\n" , __func__, dev);if (!dev->streaming)return ; - + dev->streaming =0 ;for (i =0 ; i <N_URBS ; i++) {
@@ -154,7 +154,7 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)debug ("%s(%p)\n" , __func__, substream);if (all_substreams_zero (dev->sub_playback) &&all_substreams_zero (dev->sub_capture)) { -/* when the last client has stopped streaming, +/* when the last client has stopped streaming, * all sample rates are allowed again */ stream_stop (dev); dev->pcm_info.rates = dev->samplerates;
@@ -194,7 +194,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;debug ("%s(%p)\n" , __func__, substream); - +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { dev->period_out_count[index] =BYTES_PER_SAMPLE +1 ; dev->audio_out_buf_pos[index] =BYTES_PER_SAMPLE +1 ;
@@ -205,19 +205,19 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)if (dev->streaming)return 0 ; - +/* the first client that opens a stream defines the sample rate * setting for all subsequent calls, until the last client closed. */ for (i=0 ; i <ARRAY_SIZE (rates); i++)if (runtime->rate == rates[i]) dev->pcm_info.rates =1 << i; - +snd_pcm_limit_hw_rates (runtime); bytes_per_sample =BYTES_PER_SAMPLE ;if (dev->spec.data_alignment ==2 ) bytes_per_sample++; - + bpp = ((runtime->rate /8000 ) +CLOCK_DRIFT_TOLERANCE ) * bytes_per_sample *CHANNELS_PER_STREAM * dev->n_streams;
@@ -232,7 +232,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) ret =stream_start (dev);if (ret)return ret; - + dev->output_running =0 ;wait_event_timeout (dev->prepare_wait_queue, dev->output_running,HZ );if (!dev->output_running) {
@@ -273,7 +273,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)return SNDRV_PCM_POS_XRUN ;if (sub->stream ==SNDRV_PCM_STREAM_PLAYBACK ) -return bytes_to_frames (sub->runtime, +return bytes_to_frames (sub->runtime, dev->audio_out_buf_pos[index]);else return bytes_to_frames(sub->runtime,
@@ -291,7 +291,7 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { .trigger = snd_usb_caiaq_pcm_trigger, .pointer = snd_usb_caiaq_pcm_pointer }; - +static void check_for_elapsed_periods (struct snd_usb_caiaqdev *dev,struct snd_pcm_substream **subs) {
@@ -333,7 +333,7 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,struct snd_pcm_runtime *rt = sub->runtime;char *audio_buf = rt->dma_area;int sz =frames_to_bytes (rt, rt->buffer_size); - audio_buf[dev->audio_in_buf_pos[stream]++] + audio_buf[dev->audio_in_buf_pos[stream]++] = usb_buf[i]; dev->period_in_count[stream]++;if (dev->audio_in_buf_pos[stream] == sz)
@@ -354,14 +354,14 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,for (i =0 ; i < iso->actual_length;) {if (i % (dev->n_streams *BYTES_PER_SAMPLE_USB ) ==0 ) { -for (stream =0 ; - stream < dev->n_streams; +for (stream =0 ; + stream < dev->n_streams; stream++, i++) {if (dev->first_packet)continue ; check_byte =MAKE_CHECKBYTE (dev, stream, i); - +if ((usb_buf[i] &0x3f ) != check_byte) dev->input_panic =1 ;
@@ -410,21 +410,21 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev, }if ((dev->input_panic || dev->output_panic) && !dev->warned) { -debug ("streaming error detected %s %s\n" , +debug ("streaming error detected %s %s\n" , dev->input_panic ?"(input)" :"" , dev->output_panic ?"(output)" :"" ); dev->warned =1 ; } } -static void fill_out_urb (struct snd_usb_caiaqdev *dev, -struct urb *urb, +static void fill_out_urb (struct snd_usb_caiaqdev *dev, +struct urb *urb,const struct usb_iso_packet_descriptor *iso) {unsigned char *usb_buf = urb->transfer_buffer + iso->offset;struct snd_pcm_substream *sub;int stream, i; - +for (i =0 ; i < iso->length;) {for (stream =0 ; stream < dev->n_streams; stream++, i++) { sub = dev->sub_playback[stream];
@@ -444,7 +444,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,/* fill in the check bytes */ if (dev->spec.data_alignment ==2 && - i % (dev->n_streams *BYTES_PER_SAMPLE_USB ) == + i % (dev->n_streams *BYTES_PER_SAMPLE_USB ) == (dev->n_streams *CHANNELS_PER_STREAM ))for (stream =0 ; stream < dev->n_streams; stream++, i++) usb_buf[i] =MAKE_CHECKBYTE (dev, stream, i);
@@ -453,7 +453,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,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 urb *out;int frame, len, send_it =0 , outframe =0 ;
@@ -478,7 +478,7 @@ static void read_completed(struct urb *urb) out->iso_frame_desc[outframe].length = len; out->iso_frame_desc[outframe].actual_length =0 ; out->iso_frame_desc[outframe].offset =BYTES_PER_FRAME * frame; - +if (len >0 ) {spin_lock (&dev->spinlock);fill_out_urb (dev, out, &out->iso_frame_desc[outframe]);
@@ -497,14 +497,14 @@ static void read_completed(struct urb *urb) out->transfer_flags =URB_ISO_ASAP ;usb_submit_urb (out,GFP_ATOMIC ); } - +/* re-submit inbound urb */ for (frame =0 ; frame <FRAMES_PER_URB ; frame++) { urb->iso_frame_desc[frame].offset =BYTES_PER_FRAME * frame; urb->iso_frame_desc[frame].length =BYTES_PER_FRAME ; urb->iso_frame_desc[frame].actual_length =0 ; } - + urb->number_of_packets =FRAMES_PER_URB ; urb->transfer_flags =URB_ISO_ASAP ;usb_submit_urb (urb,GFP_ATOMIC );
@@ -528,7 +528,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)struct usb_device *usb_dev = dev->chip.dev;unsigned int pipe; - pipe = (dir ==SNDRV_PCM_STREAM_PLAYBACK ) ? + pipe = (dir ==SNDRV_PCM_STREAM_PLAYBACK ) ?usb_sndisocpipe (usb_dev,ENDPOINT_PLAYBACK ) :usb_rcvisocpipe (usb_dev,ENDPOINT_CAPTURE );
@@ -547,25 +547,25 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)return urbs; } - urbs[i]->transfer_buffer = + urbs[i]->transfer_buffer =kmalloc (FRAMES_PER_URB *BYTES_PER_FRAME ,GFP_KERNEL );if (!urbs[i]->transfer_buffer) {log ("unable to kmalloc() transfer buffer, OOM!?\n" ); *ret = -ENOMEM ;return urbs; } - +for (frame =0 ; frame <FRAMES_PER_URB ; frame++) { -struct usb_iso_packet_descriptor *iso = +struct usb_iso_packet_descriptor *iso = &urbs[i]->iso_frame_desc[frame]; - + iso->offset =BYTES_PER_FRAME * frame; iso->length =BYTES_PER_FRAME ; } - + urbs[i]->dev = usb_dev; urbs[i]->pipe = pipe; - urbs[i]->transfer_buffer_length =FRAMES_PER_URB + urbs[i]->transfer_buffer_length =FRAMES_PER_URB *BYTES_PER_FRAME ; urbs[i]->context = &dev->data_cb_info[i]; urbs[i]->interval =1 ;
@@ -589,7 +589,7 @@ static void free_urbs(struct urb **urbs)for (i =0 ; i <N_URBS ; i++) {if (!urbs[i])continue ; - +usb_kill_urb (urbs[i]);kfree (urbs[i]->transfer_buffer);usb_free_urb (urbs[i]);
@@ -602,11 +602,11 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) {int i, ret; - dev->n_audio_in =max (dev->spec.num_analog_audio_in, - dev->spec.num_digital_audio_in) / + dev->n_audio_in =max (dev->spec.num_analog_audio_in, + dev->spec.num_digital_audio_in) /CHANNELS_PER_STREAM ; dev->n_audio_out =max (dev->spec.num_analog_audio_out, - dev->spec.num_digital_audio_out) / + dev->spec.num_digital_audio_out) /CHANNELS_PER_STREAM ; dev->n_streams =max (dev->n_audio_in, dev->n_audio_out);
@@ -619,7 +619,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)return -EINVAL ; } - ret =snd_pcm_new (dev->chip.card, dev->product_name,0 , + ret =snd_pcm_new (dev->chip.card, dev->product_name,0 , dev->n_audio_out, dev->n_audio_in, &dev->pcm);if (ret <0 ) {
@@ -632,7 +632,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)memset (dev->sub_playback,0 ,sizeof (dev->sub_playback));memset (dev->sub_capture,0 ,sizeof (dev->sub_capture)); - +memcpy (&dev->pcm_info, &snd_usb_caiaq_pcm_hardware,sizeof (snd_usb_caiaq_pcm_hardware));
@@ -651,9 +651,9 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)break ; } -snd_pcm_set_ops (dev->pcm,SNDRV_PCM_STREAM_PLAYBACK , +snd_pcm_set_ops (dev->pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_usb_caiaq_ops); -snd_pcm_set_ops (dev->pcm,SNDRV_PCM_STREAM_CAPTURE , +snd_pcm_set_ops (dev->pcm,SNDRV_PCM_STREAM_CAPTURE , &snd_usb_caiaq_ops); snd_pcm_lib_preallocate_pages_for_all(dev->pcm,
@@ -662,7 +662,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); dev->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 );if (!dev->data_cb_info)
@@ -672,14 +672,14 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) dev->data_cb_info[i].dev = dev; dev->data_cb_info[i].index = i; } - + dev->data_urbs_in =alloc_urbs (dev,SNDRV_PCM_STREAM_CAPTURE , &ret);if (ret <0 ) {kfree (dev->data_cb_info);free_urbs (dev->data_urbs_in);return ret; } - + dev->data_urbs_out =alloc_urbs (dev,SNDRV_PCM_STREAM_PLAYBACK , &ret);if (ret <0 ) {kfree (dev->data_cb_info);
sound/usb/caiaq/device.c +30 -30
177 lines not on this page · raw message
sound/usb/caiaq/midi.c +12 -12
@@ -40,7 +40,7 @@ static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substif (!dev)return ; - + dev->midi_receive_substream = up ? substream :NULL ; }
@@ -64,18 +64,18 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, struct snd_rawmidi_substream *substream) {int len, ret; - + dev->midi_out_buf[0 ] =EP1_CMD_MIDI_WRITE ; dev->midi_out_buf[1 ] =0 ;/* port */ len =snd_rawmidi_transmit (substream, dev->midi_out_buf +3 ,EP1_BUFSIZE -3 ); - +if (len <=0 )return ; - + dev->midi_out_buf[2 ] = len; dev->midi_out_urb.transfer_buffer_length = len+3 ; - + ret =usb_submit_urb (&dev->midi_out_urb,GFP_ATOMIC );if (ret <0 ) log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
@@ -88,7 +88,7 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,static void snd_usb_caiaq_midi_output_trigger (struct snd_rawmidi_substream *substream,int up) {struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; - +if (up) { dev->midi_out_substream = substream;if (!dev->midi_out_active)
@@ -113,12 +113,12 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = .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 *dev,int port,const char *buf,int len) {if (!dev->midi_receive_substream)return ; - +snd_rawmidi_receive (dev->midi_receive_substream, buf, len); }
@@ -142,16 +142,16 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)if (device->spec.num_midi_out >0 ) { rmidi->info_flags |=SNDRV_RAWMIDI_INFO_OUTPUT ; -snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , +snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_usb_caiaq_midi_output); }if (device->spec.num_midi_in >0 ) { rmidi->info_flags |=SNDRV_RAWMIDI_INFO_INPUT ; -snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_INPUT , +snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_INPUT , &snd_usb_caiaq_midi_input); } - + device->rmidi = rmidi;return 0 ;
@@ -160,7 +160,7 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)void snd_usb_caiaq_midi_output_done (struct urb * urb) {struct snd_usb_caiaqdev *dev = urb->context; - + dev->midi_out_active =0 ;if (urb->status !=0 )return ;
Signature · 1 line
1.6.3.1
PATCH 2/5 ALSA: snd_usb_caiaq: give better shortname
Signed-off-by Daniel Mack <[email protected]>
--- sound/usb/caiaq/device.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
sound/usb/caiaq/device.c +5 -0
@@ -435,6 +435,11 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)strcpy (card->driver,MODNAME );strcpy (card->shortname, dev->product_name); +/* replace ' ' with '_' in device shortname */ +for (c = card->shortname; *c; c++) +if (*c ==' ' ) + *c ='_' ; + len =snprintf (card->longname,sizeof (card->longname),"%s %s (serial %s, " , dev->vendor_name, dev->product_name, dev->serial);
Signature · 1 line
1.6.3.1
PATCH 3/5 ALSA: snd_usb_caiaq: use strncpy
Signed-off-by Daniel Mack <[email protected]>
--- sound/usb/caiaq/device.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
sound/usb/caiaq/device.c +2 -2
@@ -432,8 +432,8 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)if (c) *c ='\0' ; -strcpy (card->driver,MODNAME ); -strcpy (card->shortname, dev->product_name); +strncpy (card->driver,MODNAME ,sizeof (card->driver)); +strncpy (card->shortname, dev->product_name,sizeof (card->shortname));/* replace ' ' with '_' in device shortname */ for (c = card->shortname; *c; c++)
Signature · 1 line
1.6.3.1
PATCH 4/5 ALSA: snd_usb_caiaq: give better longname
The serial number is of no interest in the longname, remove it. This gives space for the usb patrh information which is more informative.
Signed-off-by Daniel Mack <[email protected]>
--- sound/usb/caiaq/device.c | 17 ++++++----------- sound/usb/caiaq/device.h | 1 - 2 files changed, 6 insertions(+), 12 deletions(-)
sound/usb/caiaq/device.c +6 -11
@@ -382,10 +382,10 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)static int __devinit init_card (struct snd_usb_caiaqdev *dev) { -char *c; +char *c, usbpath[32 ];struct usb_device *usb_dev = dev->chip.dev;struct snd_card *card = dev->chip.card; -int err, len; +int err;if (usb_set_interface (usb_dev,0 ,1 ) !=0 ) {log ("can't set alt interface.\n" );
@@ -440,16 +440,11 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)if (*c ==' ' ) *c ='_' ; - len =snprintf (card->longname,sizeof (card->longname), -"%s %s (serial %s, " , - dev->vendor_name, dev->product_name, dev->serial); - -if (len <sizeof (card->longname) -2 ) - len +=usb_make_path (usb_dev, card->longname + len, -sizeof (card->longname) - len); +usb_make_path (usb_dev, usbpath,sizeof (usbpath)); +snprintf (card->longname,sizeof (card->longname), +"%s %s (%s)" , + dev->vendor_name, dev->product_name, usbpath); - card->longname[len++] =')' ; - card->longname[len] ='\0' ;setup_card (dev);return 0 ; }
sound/usb/caiaq/device.h +0 -1
@@ -81,7 +81,6 @@ struct snd_usb_caiaqdev {char vendor_name[CAIAQ_USB_STR_LEN ];char product_name[CAIAQ_USB_STR_LEN ]; -char serial[CAIAQ_USB_STR_LEN ];int n_streams, n_audio_in, n_audio_out;int streaming, first_packet, output_running;
Signature · 1 line
1.6.3.1
PATCH 5/5 ALSA: snd_usb_caiaq: bump version number
Signed-off-by Daniel Mack <[email protected]>
--- sound/usb/caiaq/device.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-)
sound/usb/caiaq/device.c +1 -9
@@ -35,7 +35,7 @@#include "input.h" MODULE_AUTHOR ("Daniel Mack <[email protected]>" ); -MODULE_DESCRIPTION ("caiaq USB audio, version 1.3.14" ); +MODULE_DESCRIPTION ("caiaq USB audio, version 1.3.15" );MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Native Instruments, RigKontrol2}," "{Native Instruments, RigKontrol3},"
@@ -424,14 +424,6 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)usb_string (usb_dev, usb_dev->descriptor.iProduct, dev->product_name,CAIAQ_USB_STR_LEN ); -usb_string (usb_dev, usb_dev->descriptor.iSerialNumber, - dev->serial,CAIAQ_USB_STR_LEN ); - -/* terminate serial string at first white space occurence */ - c =strchr (dev->serial,' ' ); -if (c) - *c ='\0' ; -strncpy (card->driver,MODNAME ,sizeof (card->driver));strncpy (card->shortname, dev->product_name,sizeof (card->shortname));
Signature · 1 line
1.6.3.1
Re: [PATCH 5/5] ALSA: snd_usb_caiaq: bump version number
Quoted 20 lines · Daniel Mack
Signed-off-by Daniel Mack <[email protected]>--- sound/usb/caiaq/device.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-)sound/usb/caiaq/device.c +1
-1@@ -35,7 +35,7 @@#include "input.h" MODULE_AUTHOR ("Daniel Mack <[email protected]>" ); -MODULE_DESCRIPTION ("caiaq USB audio, version 1.3.14" ); +MODULE_DESCRIPTION ("caiaq USB audio, version 1.3.15" );MODULE_LICENSE ("GPL" );MODULE_SUPPORTED_DEVICE ("{{Native Instruments, RigKontrol2}," "{Native Instruments, RigKontrol3},"@@ -424,14 +424,6 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) usb_string(usb_dev, usb_dev->descriptor.iProduct,
sound/usb/caiaq/device.c static int __devinit init_card(struct snd_usb_caiaqdev *dev) · line 434
Quoted 10 lines
sound/usb/caiaq/device.c +0
-8dev->product_name, CAIAQ_USB_STR_LEN); -usb_string (usb_dev, usb_dev->descriptor.iSerialNumber, - dev->serial,CAIAQ_USB_STR_LEN ); - -/* terminate serial string at first white space occurence */ - c =strchr (dev->serial,' ' ); -if (c) - *c ='\0' ; -
Argh, the set is messed, and I saw it only now. Will resend. Sorry.
Daniel