mm/cma: Move dma contiguous changes into a seperate config

We want to use CMA for allocating hash page table and real mode area for
PPC64. Hence move DMA contiguous related changes into a seperate config
so that ppc64 can enable CMA without requiring DMA contiguous.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[removed defconfig changes]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

(cherry picked from commit f825c736e75b11adb59ec52a4a1096efddd2ec97)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
drivers: dma-contiguous: clean source code and prepare for device tree

This patch cleans the initialization of dma contiguous framework. The
all-in-one dma_declare_contiguous() function is now separated into
dma_contiguous_reserve_area() which only steals the the memory from
memblock allocator and dma_contiguous_add_device() function, which
assigns given device to the specified reserved memory area. This improves
the flexibility in defining contiguous memory areas and assigning device
to them, because now it is possible to assign more than one device to
the given contiguous memory area. Such split in initialization procedure
is also required for upcoming device tree support.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Tomasz Figa <t.figa@samsung.com>
(cherry picked from commit a2547380393ac82c659b40182b0da8d05a8365f3)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
[media] v4l: vsp1: Remove unexisting rt clocks

The VSP1 has no rt clock. Remove them from the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] v4l: vsp1: uds: Enable scaling of alpha layer

Scaling of the alpha layer is disabled as both the RPF and WPF are
configured to hardcode the alpha value to 255. This results in a 0 alpha
value at the UDS output, making the image invisible when alpha blended
in the BRU. Fix it by enabling scaling of the alpha layer.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] v4l: vsp1: Support multi-input entities

Rework the route configuration code to support entities with multiple
sink pads.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] v4l: vsp1: Add BRU support

The Blend ROP Unit performs blending and ROP operations for up to four
sources.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Conflicts:
	drivers/media/platform/vsp1/vsp1_video.c
[media] v4l: vsp1: Add DT bindings documentation

All parameters supplied through platform data can now be passed through
the device tree.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] v4l: vsp1: Add DT support

Implement support for the VSP1 DT bindings in the VSP1 driver. The
driver now first retrieves platform data either from the platform data
pointer or by reading the device tree node, and then validates it
regardless of the platform data source.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
v4l: Add ARGB and XRGB pixel formats

The existing RGB pixel formats are ill-defined in respect to their alpha
bits and their meaning is driver dependent. Create new standard ARGB and
XRGB variants with clearly defined meanings and make the existing
variants deprecated.

The new pixel formats 4CC values have been selected to match the DRM
4CCs for the same in-memory formats.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Conflicts:
	 include/uapi/linux/videodev2.h
DocBook: media: Document ALPHA_COMPONENT control usage on output devices

Extend the V4L2_CID_ALPHA_COMPONENT control for use on output devices,
to set the alpha component value when the output format doesn't have an
alpha channel.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: Support extending the v4l2_pix_format structure

The v4l2_pix_format structure has no reserved field. It is embedded in
the v4l2_framebuffer structure which has no reserved fields either, and
in the v4l2_format structure which has reserved fields that were not
previously required to be zeroed out by applications.

To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer
structure, and use the priv field as a magic value to indicate that the
application has set all v4l2_pix_format extended fields and zeroed all
reserved fields following the v4l2_pix_format field in the v4l2_format
structure.

The availability of this API extension is reported to userspace through
the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the
priv field is still set to the magic value at [GS]_FMT return wouldn't
be enough, as older kernels don't zero the priv field on return.

To simplify the internal API towards drivers zero the extended fields
and set the priv field to the magic value for applications not aware of
the extensions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Conflicts:
	Documentation/DocBook/media/v4l/v4l2.xml
	Documentation/DocBook/media/v4l/vidioc-querycap.xml
	drivers/media/pci/saa7134/saa7134-empress.c
	drivers/media/pci/saa7134/saa7134-video.c
	drivers/media/platform/davinci/vpif_display.c
	drivers/media/platform/mem2mem_testdev.c
	drivers/media/usb/gspca/gspca.c
	include/uapi/linux/videodev2.h
v4l: Add premultiplied alpha flag for pixel formats

When set, the new V4L2_PIX_FMT_FLAG_PREMUL_ALPHA flag indicates that the
pixel values are premultiplied by the alpha channel value.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Conflicts:
	Documentation/DocBook/media/v4l/v4l2.xml
v4l: vsp1: Fix typos

Several macros were mistakenly prefixed with VPS1 instead of VSP1. Fix
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: Cleanup video nodes at removal time

Video nodes created and initialized in the RPF and WPF init code paths
are never unregistered, and the related resources (videobuf alloc
context and media entity) never released.

Fix this by storing a pointer to the vsp1_video object in vsp1_entity
and calling vsp1_video_cleanup() from vsp1_entity_destroy(). This also
allows simplifying the init error code paths.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: Propagate vsp1_device_get errors to the callers

Modify the vsp1_device_get() function to return an error code instead of
a pointer to the VSP1 device, and use the return value in the callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Conflicts:
	drivers/media/platform/vsp1/vsp1_drv.c
v4l: vsp1: Setup control handler automatically at stream on time

When setting a control directly on a subdev node the VSP1 driver doesn't
guarantee that the device is powered on. This leads to crashes when the
control handlers writes to hardware registers. One easy way to fix this
is to ensure that the device gets powered on when a subdev node is
opened. However, this consumes power unnecessarily, as there's no need
to power the device on when setting formats on the pipeline.
Furthermore, control handler setup at entity init time suffers from the
same problem as the device isn't powered on easier.

Fix this by extend the entity base object to setup the control handler
automatically when starting the stream. Entities must then skip writing
to registers in the set control handler when not streaming, which can be
tested with the new vsp1_entity_is_streaming() helper function.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: sru: Fix the intensity control default value

The default value isn't set and defaults to 0, which isn't in the 1-6
min-max range. Fix it by setting the default value to 1.

This shoud have been caught when checking the control handler error
field at initialization time, but the check was missing. Add it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: sru: Make the intensity controllable during streaming

The control value is currently stored in the SRU structure by the
control set handler and written to the hardware at stream on time,
making control set during streaming ineffective. Fix it by writing to
the registers from within the control set handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: wpf: Simplify cast to pipeline structure

USe the subdev pointer directly to_vsp1_pipeline() macro instead of
casting from the subdev to the wpf object and back to the subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
v4l: vsp1: wpf: Clear RPF to WPF association at stream off time

The VSP1 stores the video pipelines' input (RPF) to output (WPF)
mappings in a WPF register. An RPF must never be associated with
multiple WPFs, even if all of those WPFs but one are unused, otherwise
the hardware won't function properly.

The driver doesn't ensure this correctly as it never clears the
mappings. An RPF used with one WPF and later with a different WPF will
lead to malfunction, as it will be associated with two WPFs. Clear the
mappings at stream off time to fix this.

Reported-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>