etnaviv: add initial support

Add initial etnaviv support.  This is a copy of the vivante code,
adapted to the etnaviv library, and is at feature parity with the
vivante code.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add tile support

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: cpu/gpu read/write state tracking

Track the state of pixmaps on the CPU and GPU, including whether they
are being read from, or written to by each.  This allows us to permit
concurrent read-only access by the CPU and GPU to a pixmap without
having to map and unmap it from the GPU.

On Dove, this gives an overall 10% performance boost as measured by
gtkperf.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: re-architect to use etna fences

Use etna fences to detect whether the GPU has completed operations on
pixmaps, rather than stalling and waiting for the GPU to reach that
point.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: delay freeing pixmaps when GPU busy

When we need to free a pixmap which is busy on the GPU, transfer it
to a separate list rather than freeing it.  This avoids an explicit
commit and stall at this point - we can batch up the pixmaps to be
freed, and do that work when we have a pressing reason to commit and
stall.

This batching reduces the number of commit+stall events, and the
resulting interrupt load - the number of interrupts received during
a gtkperf run is roughly halved.

Limit the maximum time that unused pixmaps can be on the busy_free_list
to 500ms, before we invoke a commit+stall event.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add a pixmap GPU usage hint

There are several places where we wish to allocate a pixmap usable by
the GPU.  Should the allocation fail, we do not want to fall back to
a standard non-GPU pixmap.  CREATE_PIXMAP_USAGE_GPU marks this
behaviour.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
etnaviv: create pixmaps for GPU acceleration with CREATE_PIXMAP_USAGE_GPU

When we wish to allocate a pixmap for acceleration purposes, use the
CREATE_PIXMAP_USAGE_GPU usage hint, so we know not to try falling
back if the allocation on the GPU fails.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add component alpha blending for PE2.0 hardware

PE2.0 hardware has support for component alpha blending.  This is where
the blend factors are taken from each individual channel of the other
image, rather than the alpha channel of the other image.  Hence, a
standard InReverse would be:

	dst.A = src.A * 0 + dst.A * src.A
	dst.C = src.C * 0 + dst.C * src.A

A component alpha InReverse is:

	dst.A = src.A * 0 + dst.A * src.A
	dst.C = src.C * 0 + dst.C * src.C

This mode is selected by the COLOR and COLOR_INVERSED blend modes.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add acceleration for GetImage()

Provide an accelerated GetImage implementation.  This implmentation
optimises the case where the source pixmap is already on the GPU,
avoiding bouncing it back to the CPU before copying the data.

Instead, we allocate a new pixmap of the desired width and height, use
the GPU to copy to the new pixmap, before falling back to the non-
accelerated methods to copy the data from the new pixmap.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add acceleration for PolySegment()

Add an accelerated PolySegment implementation.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add acceleration for PolyLines()

Add an accelerated PolyLines implementation.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add glyph caching support

Add initial support for glyph caching on a 1024x1024 GPU surface.
This allows us to assemble the glyphs onto a mask buffer for rendering
solely via the GPU rather than using the CPU for this operation.

We always upload the glyphs via a page-aligned page-sized buffer to
avoid any effects from mapping the buffer to the GPU (eg, CPU cache
handling for DMA coherency.)

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: add support for drm_armada_bo_create_size()

Add support for drm_armada_bo_create_size(), and use it in preference
to drm_armada_bo_create() which calculates the bo size internally.
This allows us to use tiled formats with armada bos.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: avoid PutImage() bringing a pixmap onto GPU

If PutImage() is called on a pixmap which is not already on the GPU,
do not pull it onto the GPU.  Delay this until the pixmap is used
some other way.  This avoids unnecessarily bouncing a pixmap onto
the GPU at PutImage time only to have it freed a short time later.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: fixes to stop gc320 crash

Add additional fixes to stop GC320 on iMX6 locking up.  We appear to
need three dummy load states after a GPU operation, followed by a
dummy blit, then the cache flush, semaphore+signal between the PE and
FE, and finally about 20 NOPs.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
packaging: add etnaviv sub-package

Add a sub-package for the etnaviv GPU driver.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
export a function (HACK)
etnaviv: Xv: add etnaviv textured adapter

Add a textured Xv adapter which can render YUV422 packed and YUV420
planar formats.  This is done using a two stage blit - first stage
scales vertically, preferably to a tiled buffer, followed by a
second stage scaling horizontally.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: Xv: disable tiled YUY2 support for stage1 bo

Tiled support does not appear to work with the video rasteriser.
Disable it for the time being.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
etnaviv: Xv: align image buffer sizes to the MMU page size

Etnadrm requires user buffers to be aligned to the CPU page size in
order to map them directly to the GPU.  Arrange for us to report
that the image size is a multiple of the CPU page size.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>