History log of /drivers/media/video/s5p-fimc/fimc-capture.c
Revision Date Author Comments
63746be543db923a8337e26c4723e65c38a99dc7 22-Apr-2012 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Correct memory allocation for VIDIOC_CREATE_BUFS

The commit 3b4c34aac7abea4754059084d0eef667a1993ac8
"s5p-fimc: Add support for VIDIOC_PREPARE_BUF/CREATE_BUFS ioctls"
added a handler for VIDIOC_CREATE_BUFS ioctl, but the queue_setup
callback wasn't updated to properly interpret the pixel format.
In this situation memory corruption may happen with VIDIOC_CREATE_BUFS
ioctl. Update the queue_setup op to fix this.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e985dbf7d93e2a3e114b4525413e50f83613e0cb 21-Apr-2012 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix locking in subdev set_crop op

When setting TRY crop on the sub-device the mutex was erroneously acquired
rather than released on exit path. This bug is present in kernels starting
from v3.2.

Cc: stable@vger.kernel.org
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f9331d115dadd4e63619ebb47960ec2b7d253700 04-Feb-2012 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Replace the crop ioctls with VIDIOC_S/G_SELECTION

Add support for cropping and composition setup on the video capture
node through VIDIOC_S/G_SELECTION ioctls. S/G_CROP, CROPCAP ioctls
are still supported for applications since the core will translate
them to *_selection handler calls.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3b4c34aac7abea4754059084d0eef667a1993ac8 30-Jan-2012 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add support for VIDIOC_PREPARE_BUF/CREATE_BUFS ioctls

Add VIDIOC_PREPARE_BUF and VIDIOC_CREATE_BUFS ioctl handlers to enable
support for multi-size buffer queue.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b1aa60892ecc1ba03185e7dfed99cc9202ef03b7 12-Jan-2012 Julia Lawall <Julia.Lawall@lip6.fr> [media] drivers/media/video/s5p-fimc/fimc-capture.c: adjust double test

Rewrite a duplicated test to test the correct value

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E;
@@

(
* E
|| ... || E
|
* E
&& ... && E
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
dafb9c70abb7896a43288fbec2a9f2ed6e915d18 01-Dec-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add support for alpha component configuration

On Exynos SoCs the FIMC IP allows to configure globally the alpha
component of all pixels for V4L2_PIX_FMT_RGB32, V4L2_PIX_FMT_RGB555
and V4L2_PIX_FMT_RGB444 image formats. This patch adds a v4l2 control
in order to let the applications control the alpha component value.

The alpha value range depends on the pixel format, for RGB32 it's
0..255 (8-bits), for RGB555 - 0..1 (1-bit) and for RGB444 - 0..15
(4-bits). The v4l2 control range is always 0..255 and the alpha
component data width is determined by currently set format on the
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE buffer queue. The applications
need to match the alpha channel value range and the pixel format
since the driver will clamp the alpha component. Depending on
fourcc the valid alpha bits are:

- V4L2_PIX_FMT_RGB555 [0]
- V4L2_PIX_FMT_RGB444 [3:0]
- V4L2_PIX_FMT_RGB32 [7:0]

When switching to a pixel format with smaller alpha component width
the currently set alpha value will be clamped to maximum value valid
for current format. When switching to a format with wider alpha the
alpha value remains unchanged.

The variant description data structure is extended with a new entry
so an additional control is created only where really supported by
the hardware.

V4L2_PIX_FMT_RGB555 and V4L2_PIX_FMT_RGB444 formats are only valid
for V4L2_BUF_TYPE_VIDEO_CAPTURE buffer queue.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
393a23fc9377ac3deaa97c5cc00b5c78746c8570 08-Dec-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix camera input configuration in subdev operations

When using only subdev user-space operations the camera
interface input was not configured properly. Fix this by
updating the corresponding data structure in set_fmt
operation.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9c63afcb02b4313838d83c3660e45544d9fc9976 27-May-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Adjust pixel height alignments according to the IP revision

Minimum vertical pixel size alignment for input and output DMA and
the scaler depend on color format, rotation, the IP instance and revision.

Make vertical pixel size of format and crop better fit for each SoC
revision and the IP instance by adding min_vsize_align attribute to
the FIMC variant data structure. It's now common for the DMA engines
and the scaler.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2c1bb62e217f4f2eb6fa9734dcb331bc09c7768e 05-Oct-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix buffer dequeue order issue

When requested more than 2 buffers the buffer dequeue order was wrong
due to erroneous updating FIMC registers in every interrupt handler
call. This also fixes regression of resetting the output DMA buffer
pointer at wrong time, when some buffers are already queued in hardware.
The hardware is reset in the start_streaming callback in order to align
the H/W state with the software output buffer pointer (buf_index).

Additionally a simple write to S5P_CISCCTRL register is replaced with
a read/modification/write to make sure the scaler is not being disabled
in fimc_hw_set_scaler().

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
64c570f505a0eac4914402bb7832d019c44eabd8 11-Sep-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix error in the capture subdev deinitialization

Make sure the subdev pointer is cleared when the subdev object
has been freed.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
fc714e70dd063e6887d09872ac6158b0c20cc817 24-Aug-2011 Guennadi Liakhovetski <g.liakhovetski@gmx.de> [media] V4L: vb2: prepare to support multi-size buffers

In preparation for the forthcoming VIDIOC_CREATE_BUFS ioctl add a
"const struct v4l2_format *" argument to the .queue_setup() vb2
operation.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8f401543ec96fb58533a2bef41e2c584fe55a114 07-Jul-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Remove single-planar capability flags

The driver supports only multi-planar API and conversion to single-planar
API should be done in libv4l2. Remove misleading single planar capability
flags to avoid problems in applications and libv4l2.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3e4748d867781732c29c00fe8fe4b179d914a977 25-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add runtime PM support in the camera capture driver

Add support for whole pipeline suspend/resume. Sensors must support
suspend/resume through s_power subdev operation.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
0295202ca7b2816ddccae83e6efcf6d24cc243c3 10-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Use consistent names for the buffer list functions

Also correct and improve *_queue_add/pop functions description.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e1d72f4d521733bbf16cb5ba63683fe4147fa349 10-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add v4l2_device notification support for single frame capture

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ee7160e57c98ffb03253abb2cb4ad5b1376a2257 26-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add support for JPEG capture

Add support for transparent DMA transfer of JPEG data with MIPI-CSI2
USER1 format. In JPEG mode the color effect, scaling and cropping
is not supported as well as image rotation and flipping thus these
controls are marked as inactive if V4L2_PIX_FMT_JPEG pixel format
was selected.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
237e026559b7cd03fc575b6007cea11aef9e0aa6 25-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add subdev for the FIMC processing block

Add a subdev to expose the host's scaling and composition functions.
The camera frame composition onto an output buffer may be configured
through set/get_crop at FIMC.{n} source pad.
Additionally allow crop, composition and controls to be modified
during streaming. Make sure the default format is set when opening
the video capture node.
Rename struct fimc_vid_cap::fmt to more relevant 'mf' to avoid
confusion.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
4db5e27ed9401a635b3c10994f2971c0441e3c90 26-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Convert to use media pipeline operations

In the camera capture driver use fimc_pipeline_* calls provided by
the media device driver part, in place where v4l2_subdev_call() were
used. This way the capture driver don't need to differentiate between
various H/W pipeline setups, i.e. if the MIPI-CSI receiver subdev is
used or not.

Remove the sync_capture_fmt() function instead of which
fimc_pipeline_try_format() is introduced in the following patch adding
the FIMC capture subdev.

The TRY_FMT ioctl function is completed by a subsequent patch adding
the capture subdev, so the try_fmt routines can be reused in the subdev
and the video node ioctl handlers.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
cf52df8acfda9442d64ab4d3d6085877f6d88d46 13-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Correct color format enumeration

Replace fimc_find_format() and find_mbus_format() with single function
that can return a pointer to the private format description based
on fourcc, media bus code or index in the table.

Create separate VIDIOC_ENUM_FMT ioctl handlers for video capture
and mem-to-mem video node. This is needed because some formats are
valid only for the video capture and some only for the mem-to-mem
video node.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9e803a0450a5973d1c252980ea69e5b171d7f0ca 10-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add PM helper function for streaming control

Move the camera capture H/W initialization sequence to a separate
function. This is needed for reuse in the following runtime PM code.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d09a7dc887275564ea226b3b089b51c2c8b07bee 25-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add media operations in the capture entity driver

Add the link_setup handler for the camera capture video node.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
131b6c619758ed8fd16d26b06a423801a497b867 25-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Convert to the new control framework

Convert the v4l controls code to use the new control framework.

fimc_ctrls_activate/deactivate functions are introduced for the
transparent DMA transfer mode (JPEG), where the rotation and flipping
controls are not supported.

The capture video node does not inherit sensors' controls when the
subdevs are configured by the user space (user_subdev_api == true).
However by default after the driver's initialization
the 'user-subdev_api' flag is false and any sensor controls will
also be available at the video node.

When the pipeline links are disconnected through the media device
the FIMC and any sensor inherited controls are destroyed and then
again created when the pipeline connection completes.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e578588eb01d9493513ca1527f464715cfd3f47f 10-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Conversion to use struct v4l2_fh

This is a prerequisite for the patch converting the driver to use
the control framework. As the capture driver does not use per file
handle contexts, two separate ioctl handlers are created for it
(vidioc_try_fmt_mplane, and vidioc_g_fmt_mplane) so there is no
handlers shared between the memory-to-memory and capture video node.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
30c9939d79d6edf64092148842835893d156b672 10-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Remove v4l2_device from video capture and m2m driver

Currently there is a v4l2_device instance being registered per each
(capture and memory-to-memory) video node created per FIMC H/W instance.
This patch is a prerequisite for using the top level v4l2_device
instantiated by the media device driver.
To retain current debug trace semantic (so it's possible to distinguish
between the capture and m2m FIMC) the video_device is used in place
of v4l2_device where appropriate.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2319c539e39b9e74f0477887bb8ff45816cb38d9 26-Jul-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Remove sensor management code from FIMC capture driver

The sensor subdevs need to be shared between all available FIMC instances.
Remove their registration from FIMC capture driver so they can then be
registered to the media device driver.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3e00218207a22e10c205e15a47b8d71c822fedec 26-Jul-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Limit number of available inputs to one

The current driver allowed camera sensors to be used only with single
FIMC H/W instance, FIMC0..FIMC2/3, designated at compile time. Remaining FIMC
entities could be used for video processing only, as mem-to-mem devices.
Required camera could be selected with S_INPUT ioctl at one devnode only.

However in that case it was not possible to use both cameras independently
at the same time, as all sensors were registered to single FIMC capture
driver. In most recent S5P SoC version there is enough FIMC H/W instances
to cover all physical camera interfaces.
Each FIMC instance exports its own video devnode. Thus we distribute
the camera sensors one per each /dev/video? by default. It will allow to
use both camera simultaneously by opening different video node.

The camera sensors at FIMC are now not selected with S_INPUT ioctl, there
is one input only available per /dev/video?.

By default a single sensor is connected at FIMC input as specified by the
media device platform data subdev description table. This assignment
can be changed at runtime through the pipeline reconfiguration at the media
device level.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
96a857421a9d212696364d210bd85a2162e73966 26-Aug-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Remove registration of video nodes from probe()

Do not register video nodes during FIMC device probe. Also make
fimc_register_m2m_device() public for use by the media device driver.
The video nodes are to be registered during the media device driver
initialization, altogether with the subdev devnodes. The video
capture nodes need to be registered as last ones when the remaining
pipeline elements are already initialized.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
574e171788ce84366e77dea5ba3db2a3a9912d34 26-Jul-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add media entity initialization

Add intialization of the media entities for video capture
and mem-to-mem video nodes. The mem-to-mem entity has no pads
whereas the capture entity has single sink pad.
Also clean up the video node naming for consistency.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e9e21083ef9361f89e19bb709eac441edc24ba02 02-Sep-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add runtime PM support in the mem-to-mem driver

Add runtime PM and system sleep support in the memory-to-memory
driver. It's required to enable the FIMC operation on Exynos4
SoCs. This patch prevents system boot failure when the driver
is compiled in, as it now tries to access its I/O memory without
first enabling the corresponding power domain.

The camera capture device suspend/resume is not fully covered,
the capture device is just powered on/off during the video
node open/close. However this enables it's normal operation
on Exynos4 SoCs.

[mchehab@redhat.com: fix a small checkpatch error]
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
bd323e28bd82dfd4b72c50ddc4d5fc24e3678b99 29-Aug-2011 Marek Szyprowski <m.szyprowski@samsung.com> [media] media: vb2: change queue initialization order

This patch changes the order of operations during stream on call. Now the
buffers are first queued to the driver and then the start_streaming method
is called.

This resolves the most common case when the driver needs to know buffer
addresses to enable dma engine and start streaming. Additional parameter
to start_streaming method have been added to simplify drivers code. The
driver are now obliged to check if the number of queued buffers is high
enough to enable hardware streaming. If not - it can return an error. In
such case all the buffers that have been pre-queued are invalidated.

This patch also updates all videobuf2 clients to work properly with the
changed order of operations.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
CC: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
CC: Hans Verkuil <hverkuil@xs4all.nl>
CC: Tomasz Stanislawski <t.stanislaws@samsung.com>
CC: Sylwester Nawrocki <s.nawrocki@samsung.com>
CC: Kamil Debski <k.debski@samsung.com>
CC: Jonathan Corbet <corbet@lwn.net>
CC: Josh Wu <josh.wu@atmel.com>
CC: Hans de Goede <hdegoede@redhat.com>
CC: Paul Mundt <lethal@linux-sh.org>
Tested-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
035aa1475d6e4afdf97dccf6c6d6059063398b57 24-Aug-2011 Marek Szyprowski <m.szyprowski@samsung.com> [media] media: vb2: change plane sizes array to unsigned int[]

Plane sizes array was declared as unsigned long[], while unsigned int is
more than enough for storing size of the video buffer. This patch reduces
the size of the array by definiting it as unsigned int[].

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
64dc3c1a906467d90c24913b0b38dd13d9378f4f 25-Jun-2011 Mauro Carvalho Chehab <mchehab@redhat.com> [media] Stop using linux/version.h on the remaining video drivers

Standardize the remaining video drivers to return the API version
for the VIDIOC_QUERYCAP version, instead of a per-driver version.

Those drivers had the version updated more recently or are SoC
drivers. Even so, it doesn't sound a good idea to keep a per-driver
version control, so, let's use the per-subsystem version control
instead.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3a3f94497aa236d9a4f47f0f4f8dc84e531ffa22 28-Apr-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Update copyright notices

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
dbdd0dfb89ca45895f2063db8b31085cf32aa81d 23-May-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Remove empty buf_init operation

The buf_init buffer queue operation is optional and
buffer_init() does nothing, remove it.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3495dcefeb3b5ab825788206d5b696be14f4de19 20-May-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix data structures documentation and cleanup debug trace

Correct inconsistencies in data structures' documentation.
Remove meaningless debug traces.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
cfd77310a93aac6de7077335b2b73c19531043e4 02-Jun-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix possible memory leak during capture devnode registration

Add missing kfree on the error path.

Reported-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
045030fa16648449b416d4fc8dcc54bfefd6f4aa 08-Apr-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix bytesperline and plane payload setup

Make sure the sizeimage for 3-planar color formats is
width * height * 3/2 and the bytesperline is same for each
plane in case of a multi-planar format.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c4a627333f0d952c5e10c02609493fa63b5c7b28 15-Mar-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Do not allow changing format after REQBUFS

Protecting the color format with vb2_is_streaming() is not sufficient
as this prevents changing the format only after VIDIOC_STREAMON.
To prevent the color format reconfiguration as soon as buffers
are allocated use vb2_is_busy() instead.
Also make the videobuf queue ops structure static.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
117182d18399a956719be94d3e6e17aad9210cda 28-Feb-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Allow defining number of sensors at runtime

Add num_clients field to struct s5p_fimc_isp_info to define exactly
size of clients array which simplifies a bit the sensors management.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
4ecbf5d1d2bb7d1e3882de79e512c1a0a2816581 23-Feb-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Prevent hanging on device close and fix the locking

Rework the locking in m2m driver to assure proper operation on SMP systems.

When job_abort or stop_streaming was called to immediately shutdown
a memory-to-memory transaction video buffers scheduled for processing
were never returned to vb2 and v4l2_m2m_job_finish was not called
which led to hanging.

Correct this and also return the unprocessed buffers to vb2 marking
them as erroneous, in case the end of frame interrupt do not occur.

Reported-by: Sewoon Park <seuni.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a0f8caefaf3295721ef00415c7d63ec10af253ab 11-Feb-2011 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Prevent oops when i2c adapter is not available

Prevent invalid pointer dereference on error path.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8ec737ffccd7fab629e28427b4d0581ce62ffedd 07-Feb-2011 Sungchun Kang <sungchun.kang@samsung.com> [media] s5p-fimc: fix ISR and buffer handling for fimc-capture

In some cases fimc H/W did not stop although there were no output
buffers available. So the capture deactivation interrupt routine
is modified and the state of ST_CAPT_RUN is cleared only
in the LAST-IRQ call.

After LAST-IRQ is generated, H/W pointer will be skipped by 1 frame.
(reference by user manual) So, S/W pointer should be increased too.

Reviewed-by Jonghun Han <jonghun.han@samsung.com>
Signed-off-by: Sungchun Kang <sungchun.kang@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ba10795ed1018488964e6054b5076ec31a471d96 30-Dec-2010 Sungchun Kang <sungchun.kang@samsung.com> [media] s5p-fimc: fimc_stop_capture bug fix

When is called fimc_stop_capture, it seems that wait_event_timeout
used improperly. It should be wake up by irq handler.

Reviewed-by Jonghun Han <jonghun.han@samsung.com>

Signed-off-by: Sungchun Kang <sungchun.kang@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1b09f292eb99fd6a3601e8421c463905dbb0a866 29-Dec-2010 Hyunwoong Kim <khw0178.kim@samsung.com> [media] s5p-fimc: update checking scaling ratio range

Horizontal and vertical scaling range are according to the following equations.
If (SRC_Width >= 64 x DST_Width) { Exit(-1); /* Out of Horizontal scale range}
If (SRC_Height >= 64 x DST_Height) { Exit(-1); /* Out of Vertical scale range}

fimc_check_scaler_ratio() is used to check if horizontal and vertical
scale range are valid or not. To use fimc_check_scaler_ratio,
source and destination format should be set by VIDIOC_S_FMT.
And in case of scaling up, it doesn't have to check the scale range.

Reviewed-by: Jonghun Han <jonghun.han@samsung.com>
Signed-off-by: Hyunwoong Kim <khw0178.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
70f66ea2aafbd9022a5dcdfd823538e540873585 28-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Move scaler details handling to the register API file

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b241c6d6f4ceddddfd8097c702dcfdd6b38fbe18 28-Dec-2010 Hyunwoong Kim <khw0178.kim@samsung.com> [media] s5p-fimc: Configure scaler registers depending on FIMC version

The main scaler has four SFRs for main scaler ratio depending on FIMC version.
FIMC 4.x has only two SFRs and FIMC 5.x has four SFRs for main scaler.
Those are MainHorRatio, MainHorRatio_ext, MainVerRatio and MainverRatio_ext.

The FIMC 5.x has 15 bit resolution for scaling ratio as below.
{MainHorRatio,MainHorRatio_ext} = {[14:6],[5:0]}.
{MainVerRatio,MainVerRatio_ext} = {[14:6],[5:0]}.
MainHorRatio = CISCCTRL[24:16], MainHorRatio_ext = CIEXTEN[15:10]
MainVerRatio = CISCCTRL[8:0], MainVerRatio_ext = CIEXTEN[5:0]

This patch supports FIMC 4.x and FIMC 5.x using platform_device_id::driver_data.

Reviewed-by: Jonghun Han <jonghun.han@samsung.com>
Signed-off-by: Hyunwoong Kim <khw0178.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a25be18dfb6e1b172498a9f6c9793d67057000b0 27-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add control of the external sensor clock

Manage the camera sensor clock in the host driver rather than
leaving this task for sensor drivers. The clock frequency
must be passed in the sensor's and host driver's platform data.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e9654ef28740867c0aa151bbaec93f090f60cd24 27-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Enable interworking without subdev s_stream

Prevent VIDIOC_STREAMON failing when s_stream callback is
not implemented by a sensor subdev driver.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
df7e09a351199ad9a70eb9ae3b072cc4fc59a9bb 27-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Rename s3c_fimc* to s5p_fimc*

Change s3c_fimc.h header file name to s5p_fimc.h, replace s3c_fimc_*
names with s5p_fimc_*. s3c_fimc need to be reserved for S3C series
and s5p-fimc driver will not cover CAMIF devices in S3C SoC series.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8293ebfce2053242e30069e65427e7560aff1fee 01-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Use v4l core mutex in ioctl and file operations

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ef7af59b2cf950a44576d4364459ffd3d5d1d9bc 08-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Conversion to multiplanar formats

Conversion to multiplanar color formats and minor cleanup.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2dab38e2272e9b30540e2782ef7aa8bc45848144 01-Dec-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Porting to videobuf 2

Porting to videobuf 2 and minor cleanup.
Separate videobuf_queue_ops are are created for m2m
and capture video nodes.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
798174ab6257dc2ba2ee91e242e21491c3922355 25-Nov-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix output DMA handling in S5PV310 IP revisions

FIMC IP in S5Pv310 series has extended DMA status registers
and some bit fields are marked as reserved comparing to S5PC100/110.
Use correct registers for getting DMA write pointer in each SoC variant
supported by the driver.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
e004e02f3a121e5293ef56eaca6ee6d4ad60bc64 25-Nov-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Fix vidioc_g_crop/cropcap on camera sensor

Create separate vidioc_g_crop/vidioc_s_crop handlers for capture
video node and so image cropping parameters are properly queried
at FIMC input (image sensor) and not at FIMC output.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
09b693f0bdf360b6a8e099f26c771c9fca4c3447 30-Nov-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: BKL lock removal - compilation fix

Adapt to recent videobuf_queue_dma_contig_init signature change.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9a1f8b34aa539000da17a06235e4bec254d0bfb5 24-Sep-2010 Laurent Pinchart <laurent.pinchart@ideasonboard.com> [media] v4l: Remove module_name argument to the v4l2_i2c_new_subdev* functions

The argument isn't used anymore by the functions, remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
aa2d8cbe169b7328eeabc9e2debccf5aee6f9199 23-Oct-2010 Laurent Pinchart <laurent.pinchart@ideasonboard.com> [media] v4l: Remove hardcoded module names passed to v4l2_i2c_new_subdev* (2)

With the v4l2_i2c_new_subdev* functions now supporting loading modules
based on modaliases, replace the hardcoded module name passed to those
functions by NULL in the cafe-ccic, via-camera and s5p-fimc drivers.

All corresponding I2C modules have been checked, and all of them include
a module aliases table with names corresponding to what the drivers
modified here use.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
5f3cc4474cdeab3ee44962fd752baec24e8fecec 07-Oct-2010 Sylwester Nawrocki <s.nawrocki@samsung.com> [media] s5p-fimc: Add camera capture support

Add a video device driver per each FIMC entity to support
the camera capture input mode. Video capture node is registered
only if CCD sensor data is provided through driver's platfrom data
and board setup code.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>