diff mbox

[v3,03/12] ALSA: line6: Support assymetrical in/out configurations

Message ID 1474017177-23769-4-git-send-email-dev@andree.sk (mailing list archive)
State New, archived
Headers show

Commit Message

Andrej Krutak Sept. 16, 2016, 9:12 a.m. UTC
Splits max_packet_size to max_packet_size_in/out (e.g. for
different channel counts).

Signed-off-by: Andrej Krutak <dev@andree.sk>
---
 sound/usb/line6/capture.c  | 10 +++++-----
 sound/usb/line6/pcm.c      | 28 ++++++++++++++++------------
 sound/usb/line6/pcm.h      |  5 +++--
 sound/usb/line6/playback.c |  2 +-
 4 files changed, 25 insertions(+), 20 deletions(-)

Comments

kernel test robot Sept. 16, 2016, 6:34 p.m. UTC | #1
Hi Andrej,

[auto build test ERROR on sound/for-next]
[also build test ERROR on v4.8-rc6 next-20160916]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Andrej-Krutak/Line6-POD-X3-X3Live-suport/20160916-210558
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: s390-allmodconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=s390 

Note: the linux-review/Andrej-Krutak/Line6-POD-X3-X3Live-suport/20160916-210558 HEAD 9ed07506e73b5835987ae6d7e2ba79e6c29dc6b6 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   sound/usb/line6/pcm.c: In function 'line6_pcm_acquire':
>> sound/usb/line6/pcm.c:297:9: error: too few arguments to function 'line6_buffer_acquire'
      ret = line6_buffer_acquire(line6pcm, pstr, type);
            ^~~~~~~~~~~~~~~~~~~~
   sound/usb/line6/pcm.c:151:12: note: declared here
    static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
               ^~~~~~~~~~~~~~~~~~~~
   sound/usb/line6/pcm.c: In function 'snd_line6_hw_params':
   sound/usb/line6/pcm.c:342:8: error: too few arguments to function 'line6_buffer_acquire'
     ret = line6_buffer_acquire(line6pcm, pstr, LINE6_STREAM_PCM);
           ^~~~~~~~~~~~~~~~~~~~
   sound/usb/line6/pcm.c:151:12: note: declared here
    static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
               ^~~~~~~~~~~~~~~~~~~~

vim +/line6_buffer_acquire +297 sound/usb/line6/pcm.c

63e20df1 Takashi Iwai 2015-01-27  291  	struct line6_pcm_stream *pstr;
63e20df1 Takashi Iwai 2015-01-27  292  	int ret = 0, dir;
63e20df1 Takashi Iwai 2015-01-27  293  
63e20df1 Takashi Iwai 2015-01-27  294  	mutex_lock(&line6pcm->state_mutex);
63e20df1 Takashi Iwai 2015-01-27  295  	for (dir = 0; dir < 2; dir++) {
63e20df1 Takashi Iwai 2015-01-27  296  		pstr = get_stream(line6pcm, dir);
63e20df1 Takashi Iwai 2015-01-27 @297  		ret = line6_buffer_acquire(line6pcm, pstr, type);
63e20df1 Takashi Iwai 2015-01-27  298  		if (ret < 0)
63e20df1 Takashi Iwai 2015-01-27  299  			goto error;
63e20df1 Takashi Iwai 2015-01-27  300  		if (!pstr->running)

:::::: The code at line 297 was first introduced by commit
:::::: 63e20df1e5b2ef8d871ecbdb6c038d554ed1ca74 ALSA: line6: Reorganize PCM stream handling

:::::: TO: Takashi Iwai <tiwai@suse.de>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c
index 44e9a8c..73cea26 100644
--- a/sound/usb/line6/capture.c
+++ b/sound/usb/line6/capture.c
@@ -44,13 +44,13 @@  static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm)
 		struct usb_iso_packet_descriptor *fin =
 		    &urb_in->iso_frame_desc[i];
 		fin->offset = urb_size;
-		fin->length = line6pcm->max_packet_size;
-		urb_size += line6pcm->max_packet_size;
+		fin->length = line6pcm->max_packet_size_in;
+		urb_size += line6pcm->max_packet_size_in;
 	}
 
 	urb_in->transfer_buffer =
 	    line6pcm->in.buffer +
-	    index * LINE6_ISO_PACKETS * line6pcm->max_packet_size;
+	    index * LINE6_ISO_PACKETS * line6pcm->max_packet_size_in;
 	urb_in->transfer_buffer_length = urb_size;
 	urb_in->context = line6pcm;
 
@@ -173,10 +173,10 @@  static void audio_in_callback(struct urb *urb)
 		fbuf = urb->transfer_buffer + fin->offset;
 		fsize = fin->actual_length;
 
-		if (fsize > line6pcm->max_packet_size) {
+		if (fsize > line6pcm->max_packet_size_in) {
 			dev_err(line6pcm->line6->ifcdev,
 				"driver and/or device bug: packet too large (%d > %d)\n",
-				fsize, line6pcm->max_packet_size);
+				fsize, line6pcm->max_packet_size_in);
 		}
 
 		length += fsize;
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
index 6c9b7cf..5fc1394 100644
--- a/sound/usb/line6/pcm.c
+++ b/sound/usb/line6/pcm.c
@@ -146,16 +146,20 @@  get_stream(struct snd_line6_pcm *line6pcm, int direction)
 }
 
 /* allocate a buffer if not opened yet;
- * call this in line6pcm.state_change mutex
+ * call this in line6pcm.state_mutex
  */
 static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
-				struct line6_pcm_stream *pstr, int type)
+				struct line6_pcm_stream *pstr, int direction, int type)
 {
+	const int pkt_size =
+		(direction == SNDRV_PCM_STREAM_PLAYBACK) ?
+			line6pcm->max_packet_size_out :
+			line6pcm->max_packet_size_in;
+
 	/* Invoked multiple times in a row so allocate once only */
 	if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) {
 		pstr->buffer = kmalloc(line6pcm->line6->iso_buffers *
-                                      LINE6_ISO_PACKETS *
-                                      line6pcm->max_packet_size, GFP_KERNEL);
+				       LINE6_ISO_PACKETS * pkt_size, GFP_KERNEL);
 		if (!pstr->buffer)
 			return -ENOMEM;
 	}
@@ -163,12 +167,11 @@  static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
 }
 
 /* free a buffer if all streams are closed;
- * call this in line6pcm.state_change mutex
+ * call this in line6pcm.state_mutex
  */
 static void line6_buffer_release(struct snd_line6_pcm *line6pcm,
 				 struct line6_pcm_stream *pstr, int type)
 {
-
 	clear_bit(type, &pstr->opened);
 	if (!pstr->opened) {
 		line6_wait_clear_audio_urbs(line6pcm, pstr);
@@ -195,6 +198,7 @@  static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,
 		else
 			ret = line6_submit_audio_in_all_urbs(line6pcm);
 	}
+
 	if (ret < 0)
 		clear_bit(type, &pstr->running);
 	spin_unlock_irqrestore(&pstr->lock, flags);
@@ -530,12 +534,12 @@  int line6_init_pcm(struct usb_line6 *line6,
 	line6pcm->volume_monitor = 255;
 	line6pcm->line6 = line6;
 
-	/* Read and write buffers are sized identically, so choose minimum */
-	line6pcm->max_packet_size = min(
-			usb_maxpacket(line6->usbdev,
-				usb_rcvisocpipe(line6->usbdev, ep_read), 0),
-			usb_maxpacket(line6->usbdev,
-				usb_sndisocpipe(line6->usbdev, ep_write), 1));
+	line6pcm->max_packet_size_in =
+		usb_maxpacket(line6->usbdev,
+			usb_rcvisocpipe(line6->usbdev, ep_read), 0);
+	line6pcm->max_packet_size_out =
+		usb_maxpacket(line6->usbdev,
+			usb_sndisocpipe(line6->usbdev, ep_write), 1);
 
 	spin_lock_init(&line6pcm->out.lock);
 	spin_lock_init(&line6pcm->in.lock);
diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h
index 38bf4df..f408d15 100644
--- a/sound/usb/line6/pcm.h
+++ b/sound/usb/line6/pcm.h
@@ -155,11 +155,12 @@  struct snd_line6_pcm {
 	/* Previously captured frame (for software monitoring) */
 	unsigned char *prev_fbuf;
 
-	/* Size of previously captured frame (for software monitoring) */
+	/* Size of previously captured frame (for software monitoring/sync) */
 	int prev_fsize;
 
 	/* Maximum size of USB packet */
-	int max_packet_size;
+	int max_packet_size_in;
+	int max_packet_size_out;
 
 	/* PCM playback volume (left and right) */
 	int volume_playback[2];
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c
index d53aad1..7b2644f 100644
--- a/sound/usb/line6/playback.c
+++ b/sound/usb/line6/playback.c
@@ -195,7 +195,7 @@  static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
 	urb_frames = urb_size / bytes_per_frame;
 	urb_out->transfer_buffer =
 	    line6pcm->out.buffer +
-	    index * LINE6_ISO_PACKETS * line6pcm->max_packet_size;
+	    index * LINE6_ISO_PACKETS * line6pcm->max_packet_size_out;
 	urb_out->transfer_buffer_length = urb_size;
 	urb_out->context = line6pcm;