title: Flickering and failing video streaming with uvc-gadget and g_webcam
body: <p>Am using <a href="http://git.ideasonboard.org/uvc-gadget.git/commit/349679083d1f1053ee79cc933e0e41c48ce05fb9" rel="nofollow noreferrer">this commit</a> of uvc-gadget together with g_webcam as of 4.4.143 for Rockchip. This version of uvc-gadget only transmits a static mjpeg image (and is much better written than earlier sources of uvc-gadget).</p>
  
  <p>Observing interesting behavior on host laptop, which is receiving the stream from gadget with <code>guvcview</code>: after a while frames start to flicker like an old TV (<code>V4L2_CORE: (jpeg decoder) error while decoding frame</code>), and then eventually the stream breaks down on host: <code>V4L2_CORE: Could not grab image (select timeout): Resource temporarily unavailable</code>. Underneath host continues polling (<code>[75290.124695] uvcvideo: uvc_v4l2_poll</code>), there is no error neither in host's dmesg, nor in uvc-gadget on device. In fact, after re-opening guvcview streaming works again without uvc-gadget restart, but soon crashes in the same way.</p>
  
  <p>I'm using stock USB3.0 cable, which is both for streaming and powering the device. AFAIK, there is no source of noise that may result in such kind of strange flickering on physical level.</p>
  
  <p>Additionally, I've noticed with smaller USB packet sizes going down from 1024 to 256, stream survives for longer (up to 50,000 frames or so), but still finally crashes.</p>
  
  <p>Any idea what's going on here?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After I switched from MJPEG-compressed to uncompressed stream, there is no longer flickering, but still always loss of contact after several seconds: <code>V4L2_CORE: Could not grab image (select timeout): Resource temporarily unavailable</code></p>