title: Camera2 and Renderscript Allocations
body: <p>I'm trying to use an Allocation created with the USING_IO_INPUT flag to get images from the camera. I'm setting it up as follows</p>
  
  <pre><code>Type.Builder yuvType = new Type.Builder(mRS, Element.YUV(mRS));
                  yuvType.setYuvFormat(imageReaderFormat);
                  yuvType.setX(mCameraWidth).setY(mCameraHeight);
  mAllocation = Allocation.createTyped(mRS, yuvType.create(), Allocation
                          .MipmapControl.MIPMAP_NONE,
                          Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
  mAllocation.setOnBufferAvailableListener(mOnBufferAllocationAvailable);
  </code></pre>
  
  <p>I'm adding the Allocation surface to a Preview Session, and getting the callbacks to my very simple function</p>
  
  <pre><code>public void onBufferAvailable(Allocation allocation) {
       allocation.ioReceive();
       //mPixels is properly initialised
       allocation.copyTo(mPixels);
  }
  </code></pre>
  
  <p>This setup works on a Nexus 5X, but fails on a Nexus 4 running 5.1.1. When I call <code>allocation.ioReceive()</code> in the callback, I get a few warnings printed from the driver, and copying from the Allocation to a byte array results in garbage being copied.</p>
  
  <pre><code>W/Adreno-RS: &lt;rsdVendorAllocationUnMapQCOM:394&gt;: NOT Found allocation map for alloc 0xa1761000
  W/Adreno-GSL: &lt;gsl_ldd_control:427&gt;: ioctl fd 25 code 0xc01c0915 (IOCTL_KGSL_MAP_USER_MEM) failed: errno 22 Invalid argument
  W/Adreno-RS: &lt;rsdVendorAllocationMapQCOM:288&gt;: gsl_memory_map_fd failed -5 hostptr: 0xa0112000 sz: 0 offset: 0 flags: 0x10c0b00 alloc: 0xa1761000
  </code></pre>
  
  <p>I am running the camera in a background thread, although <code>onBufferAvailable</code> gets called in the "RSMessageThread".</p>
  
  <p>Is this problem related to the way I am setting the Allocations and the Camera Preview, or is it a bug in the driver?</p>