drm/udl: implement dmabuf export.

BUG=chromium:402599
TEST=none
Signed-off-by: Haixia Shi <hshi@chromium.org>

Change-Id: I4049e78f96f39f7f32c549fb573db3a74988017b
Reviewed-on: https://chromium-review.googlesource.com/227156
Commit-Queue: Haixia Shi <hshi@chromium.org>
Tested-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
BACKPORT: [media] V4L: Add mem2mem ioctl and file operation helpers

This patch adds ioctl helpers to the V4L2 mem-to-mem API, so we can avoid
several ioctl handlers in the mem-to-mem video node drivers that are simply
a pass-through to the v4l2_m2m_* calls. These helpers will only be useful
for drivers that use same mutex for both OUTPUT and CAPTURE queue, which
is the case for all currently in tree v4l2 m2m drivers. In order to use
the helpers the drivers are required to use struct v4l2_fh.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
(cherry picked from commit 8e6e8f93f7cb3452b1c00da8a30d01558628d913)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: Ieac45319762ed1c80277ca5f3c9ef0a75b331ebe
Reviewed-on: https://chromium-review.googlesource.com/226153
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: convert struct spinlock to spinlock_t

spinlock_t should always be used.
Could not get this to build with allmodconfig:
mcgrof@frijol ~/linux-next (git::(no branch))$ make C=1 M=drivers/media/platform/s5p-jpeg
  WARNING: Symbol version dump /home/mcgrof/linux-next/Module.symvers
           is missing; modules will have no dependencies and modversions.
  Building modules, stage 2.
  MODPOST 0 modules

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Reported-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
(cherry picked from commit a75831f3600c479054fc3f70cd11257ab07886e2)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I8b5f372db82935110656c2c0424adafde9497d27
Reviewed-on: https://chromium-review.googlesource.com/226154
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p makefiles: don't override other selections on obj-[ym]

The $obj-m/$obj-y vars should be adding new modules to build, not
overriding it. So, it should never use
	$obj-y := foo.o
instead, it should use:
	$obj-y += foo.o

Failing to do that is very bad, as it will suppress needed modules.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
(cherry picked from commit 5f63adbb4cb9f952a8daee97f89c8811da5fd68a)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: Id7c57e1a7a19530f13bdb905186fa8dcd63609bb
Reviewed-on: https://chromium-review.googlesource.com/226155
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Initialize vfd_decoder->vfl_dir field

This patch fixes regression introduced in commit 5c77879ff9ab9e7
"[media] v4l2-dev: add new VFL_DIR_ defines" caused by not initializing
the vfl_dir field of the vfd_decoder instance of struct video_device,
after the field was introduced. It precluded calling the driver's ioctls
which require vfl_dir not to be equal to VFL_DIR_RX which is defined as
0 and uninitialized vfl_dir field is interpreted as such. In effect the
test in the v4l_s_fmt function failed for the ioctls that expect is_tx
to be false, which prevented the ioctl callbacks registered by the driver
from being called.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 7f7d8fe258df18d122aebaffb29eeaa40d6d7f51)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I940b5b62fb9a76b3b34a5f2ac79a41942d09e112
Reviewed-on: https://chromium-review.googlesource.com/226156
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Use mem-to-mem ioctl helpers

Simplify the driver by using the m2m ioctl and vb2 helpers.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
(cherry picked from commit 718cf4a9da22b2abf3d4f220b7a0a4e4a5b6287d)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Conflicts:
	drivers/media/platform/s5p-jpeg/jpeg-core.c

Change-Id: I3c0c98b4bc0eb71d403507610c277843b4211186
Reviewed-on: https://chromium-review.googlesource.com/226157
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Fix encoder and decoder video dev names

It is hard to distinguish between decoder and encoder video device
because their names are same. So this patch fixes the names.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit baaf046d8297cb1c777374341953833750a73131)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: Iac418ce0d046ee40b2322f8f93b805ea91aeba6a
Reviewed-on: https://chromium-review.googlesource.com/226158
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Add initial device tree support for S5PV210/Exynos4210 SoCs

This patch enables the JPEG codec on S5PV210 and Exynos4210 SoCs. There are
some differences in newer versions of the JPEG codec IP on SoCs like Exynos4x12
and Exynos5 series and support for them will be added in subsequent patches.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit f7074ab348e29c8068a2daaaf89920aebc903a98)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I7dde8ed52ba53b2dd0d560bda044c392ff5b13ce
Reviewed-on: https://chromium-review.googlesource.com/226159
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Reorder quantization tables

Reorder quantization tables so that their elements
are arranged in the manner reflecting compression
quality level that is in accordance with V4L2 documentation,
i.e. the larger value of the V4L2_CID_JPEG_COMPRESSION_QUALITY
control the better image quality, and thus lower compression
quality. The modification allows also to get rid of
reverse logic in the s_ctrl callback while assigning
user space value to the ctx->compr_quality variable.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 78e5a3ce9cca4fa87d28d4d8d4a5fb74bf606fde)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I7636fe3e267c2b63013cddb6c7078f9f5030a99b
Reviewed-on: https://chromium-review.googlesource.com/226200
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder

Output samples during decoding phase for the YUV 4:2:0 format
are arranged in the manner compatible with 2-planar NV12,
not 3-planar YUV420 fourcc.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit c97ba28b0f17d88ef072e3536aa160df6d48431d)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: If73b23344e2ce0c5381c7e7fc3e3000236e60fac
Reviewed-on: https://chromium-review.googlesource.com/226201
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Fix erroneous condition while validating bytesperline value

The aim of the condition is ensuring that the bytesperline
value set by the user space application is proper for the
given format and adjusting it if isn't. As the depth value
of the format description entry is expressed in bits then
the bytesperline value needs to be divided, not multiplied,
by that value to get the number of bytes required to store
single line of image samples.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit cc690904247fdbb169e2544cbbbd4ebd2c05f8cb)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I8ef2cb3f7980b256c2127595dc189945422f6f59
Reviewed-on: https://chromium-review.googlesource.com/226202
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function

Aligning capture queue image dimensions while enqueuing output
queue doesn't make a sense as the S_FMT ioctl might have not
been called for the capture queue until that moment, whereas
it is required to know capture format as the type of alignment
heavily depends on it.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 170f55bd85d19b06d825c18462fcb5985d6e5508)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: Iabd3fab232b9ba4b6ce55e829776d5c5556e10f6
Reviewed-on: https://chromium-review.googlesource.com/226203
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 31dc0ac0d0686a5e9246d83f98105d0aa21eb2b8)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I481126a27efb6ebc1b882816beadd4a23790dfd4
Reviewed-on: https://chromium-review.googlesource.com/226204
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Fix clock resource management

Standard suspend/resume path is called after runtime resume
of the given device, so suspend/resume callbacks must do all
clock management done also by runtime pm to allow for proper
power domain shutdown. Moreover, JPEG clock is enabled from
probe function but is is not necessary. This patch also moves
control of jpeg clock to runtime_pm callbacks.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit f1347132a655f40397d9ceb703950bc5a097416d)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I796a7ce76f6e9dd1dc694ac745ee4d3f7390abb5
Reviewed-on: https://chromium-review.googlesource.com/226205
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Fix lack of spin_lock protection

s5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should
have spin_lock protection as they alter device registers.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit b3c932a9940349cb3f00226e9713a2b25dcedc71)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I237f17ca01cc2dd82ed54e9eb5c53bb3220dc4e4
Reviewed-on: https://chromium-review.googlesource.com/226206
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Synchronize cached controls with V4L2 core

This patch adds proper initialization of the in-driver
cached state of JPEG controls with V4L2 core.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 088f8300c99e798637012195682d40dd1070bb82)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I08f14cae178abfa4fd1b888271551e4c488f60b9
Reviewed-on: https://chromium-review.googlesource.com/226207
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c

Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c,
add "s5p" prefix and put function declarations in the jpeg-hw-s5p.h.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 9f7b62d9f961e0a839de7dc5547db0f5a612cfd4)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I0ba12ea2fbfbe4fc9b1e5fb9754624b1fa56bf71
Reviewed-on: https://chromium-review.googlesource.com/226208
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg:  JPEG codec

Add hardware API for the exynos4x12 on s5p-jpeg.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 80529ae5c13725e12ba0377e29b2160794ba6b25)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I02b1feb2d4543acdbe28b05e6750003386d64994
Reviewed-on: https://chromium-review.googlesource.com/226209
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header

Make s5p_jpeg_parse_hdr function capable of parsing
"YCbCr subsampling" field of a jpeg file header. Store the
parsed value in the context.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

The information about source JPEG subsampling is required to
make validation of destination format possible, which must be
conducted for exynos4x12 device as the decoding process will
not succeed if the destination format is set to YUV with
subsampling lower than the one of the source JPEG image.

With this knowledge the driver can adjust the destination format
appropriately.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit f84339628d9224200e9145320da494da2d92cd50)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: If21bcd45b58cb299e7325c38e3806c2ec35a4087
Reviewed-on: https://chromium-review.googlesource.com/226210
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>
BACKPORT: [media] s5p-jpeg: Ensure correct capture format for Exynos4x12

Adjust capture format to the Exynos4x12 device limitations,
according to the subsampling value parsed from the source
JPEG image header. If the capture format was set to YUV with
subsampling lower than the one of the source JPEG image
the decoding process would not succeed.

BUG=chrome-os-partner:33364
TEST=With all the patches in the series run the decoder JPEG test
	./test-jpeg -m 1 -f [input jpeg file] -o [output file]
		-v [decoder node]  -r [format] -s 1
	where:
		format should be a value from 0 to 9

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
(cherry picked from commit 337777a42d033b3be1a7f9af13eb8f5eb0cdd95a)
Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>

Change-Id: I970eed91d76254f683995a3d31df60aa32dddf7a
Reviewed-on: https://chromium-review.googlesource.com/226211
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Abhilash Kesavan <a.kesavan@samsung.com>
Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>