Commit graph

139 commits

Author SHA1 Message Date
Sylwester Nawrocki
fed07f8488 [media] s5p-fimc: Use selection API in place of crop operations
Replace deprecated crop operations with the selection API.
Original crop ioctls are supported through a compatibility
layer at the v4l2 core.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kuyngmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-20 09:29:12 -03:00
Sylwester Nawrocki
9448ab7dec [media] s5p-fimc: Add color effect control
Add support for V4L2_CID_COLORFX control at the mem-to-mem and capture
video nodes.

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>
2012-05-20 09:27:16 -03:00
Sylwester Nawrocki
0c9204d342 [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>
2012-05-20 09:26:49 -03:00
Sylwester Nawrocki
4af813108b [media] s5p-fimc: Add support for Exynos4x12 FIMC-LITE
This patch adds driver for FIMC-LITE camera host interface. This new IP
differs from the regular FIMC IP in that it doesn't have input DMA,
scaler and color space conversion support. So it just plain camera host
interface for MIPI-CSI2 and ITU-R interfaces. For the serial bus support
it interworks with MIPI-CSIS and the exisiting s5p-csis driver.
The FIMC-LITE and MIPI-CSIS drivers can also be reused in the Exynos5
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>
2012-05-20 09:26:24 -03:00
Sylwester Nawrocki
5af86c2691 [media] s5p-fimc: Make sure an interrupt is properly requested
Use dev_name() for requesting an interrupt so we don't get an interrupt
requested with same name for multiple device instances.

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>
2012-05-20 09:23:49 -03:00
Sylwester Nawrocki
bb7c276ec4 [media] s5p-fimc: Minor cleanups
Tidy up the variant and driver data handling. Remove the 'samsung_'
prefix from some data structures since it doesn't really carry any
useful information and makes the names unnecessarily long.

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>
2012-05-20 09:23:35 -03:00
Sylwester Nawrocki
3d112d9ace [media] s5p-fimc: Prefix format enumerations with FIMC_FMT_
Prefix the pixel format enumerations with FIMC_FMT_ to make it more clear,
especially when used in new IP drivers, like fimc-lite, etc. Also add IO_
prefix in the input/output enumeration.

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>
2012-05-20 09:23:09 -03:00
Sylwester Nawrocki
0f735f5236 [media] s5p-fimc: Rework the video pipeline control functions
There is getting more entities to manage within single video pipeline
in newer SoCs. To simplify code put subdevs' pointer into an array
rather than adding new member in struct fimc_pipeline for each subdev.
This allows to easier handle subdev operations in proper order.

Additionally walk graph in one direction only in fimc_pipeline_prepare()
function to make sure we properly gather only media entities that below
to single data pipeline. This avoids wrong initialization in case where,
for example there are multiple active links from s5p-mipi-csis subdev
output pad.

struct fimc_pipeline declaration is moved to the driver's public header
to allow other drivers to reuse the fimc-lite driver added in subsequent
patches.

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>
2012-05-20 09:22:47 -03:00
Sylwester Nawrocki
2b511edb98 [media] s5p-fimc: Add FIMC-LITE register definitions
Add register definitions and register API for FIMC-LITE devices.

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>
2012-05-20 09:21:50 -03:00
Sylwester Nawrocki
c83a1ff063 [media] s5p-fimc: Refactor the register interface functions
Simplify the register API and use FIMC_REG_ prefix for all register
definitions for consistency with FIMC-LITE. The unused image effect
defines are removed.

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>
2012-05-20 09:19:32 -03:00
Sylwester Nawrocki
693f5c4082 [media] s5p-fimc: Use v4l2_subdev internal ops to register video nodes
In order to be able to select only FIMC-LITE support, which is added
with subsequent patches, the regular FIMC support is now contained
only in fimc-core.c, fimc-m2m.c and fimc-capture.c files. The graph
and pipeline management is now solely handled in fimc-mdevice.[ch].
This means the FIMC driver can now be excluded with Kconfig option,
leaving only FIMC-LITE and allowing this driver to be reused in SoCs
that have only FIMC-LITE and no regular FIMC IP.

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>
2012-05-20 09:17:11 -03:00
Sylwester Nawrocki
97d9742265 [media] s5p-fimc: Move m2m node driver into separate file
Virtually no functional changes, just code reordering. This let us to
clearly separate all logical functions available in the driver: fimc
capture, mem-to-mem, and later fimc-lite capture, ISP features, etc.

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>
2012-05-20 09:15:10 -03:00
Sylwester Nawrocki
41df5bf088 [media] s5p-fimc: Avoid crash with null platform_data
In commit "s5p-fimc: Handle sub-device interdependencies using deferred.."
there was a check added for pdata->num_clients without first checking
pdata against NULL. This causes a crash when platform_data is not set,
which is a valid use case. Fix this regression by skipping the MIPI-CSIS
subdev registration also when pdata is null.

Reported-by: HeungJun Kim <riverful.kim@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>
2012-05-20 09:14:11 -03:00
Mauro Carvalho Chehab
69ecdbac14 Merge remote-tracking branch 'linus/master' into staging/for_v3.5
* linus/master: (805 commits)
  tty: Fix LED error return
  openvswitch: checking wrong variable in queue_userspace_packet()
  bonding: Fix LACPDU rx_dropped commit.
  Linux 3.4-rc7
  ARM: EXYNOS: fix ctrlbit for exynos5_clk_pdma1
  ARM: EXYNOS: use s5p-timer for UniversalC210 board
  ARM / mach-shmobile: Invalidate caches when booting secondary cores
  ARM / mach-shmobile: sh73a0 SMP TWD boot regression fix
  ARM / mach-shmobile: r8a7779 SMP TWD boot regression fix
  ARM: mach-shmobile: convert ag5evm to use the generic MMC GPIO hotplug helper
  ARM: mach-shmobile: convert mackerel to use the generic MMC GPIO hotplug helper
  MAINTAINERS: Add myself as the cpufreq maintainer
  dm mpath: check if scsi_dh module already loaded before trying to load
  dm thin: correct module description
  dm thin: fix unprotected use of prepared_discards list
  dm thin: reinstate missing mempool_free in cell_release_singleton
  gpio/exynos: Fix compiler warnings when non-exynos machines are selected
  gpio: pch9: Use proper flow type handlers
  powerpc/irq: Fix another case of lazy IRQ state getting out of sync
  ks8851: Update link status during link change interrupt
  ...

Conflicts:
	drivers/media/common/tuners/xc5000.c
	drivers/media/common/tuners/xc5000.h
	drivers/usb/gadget/uvc_queue.c
2012-05-15 08:39:25 -03:00
Linus Torvalds
b6255ee3d8 Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab:
 "For a some fix patches for v3.4, including a regression fix at DVB core"

Fix up trivial conflicts in Documentation/feature-removal-schedule.txt

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  [media] gspca - sonixj: Fix a zero divide in isoc interrupt
  [media] media: videobuf2-dma-contig: include header for exported symbols
  [media] media: videobuf2-dma-contig: quiet sparse noise about plain integer as NULL pointer
  [media] media: vb2-memops: Export vb2_get_vma symbol
  [media] s5p-fimc: Correct memory allocation for VIDIOC_CREATE_BUFS
  [media] s5p-fimc: Fix locking in subdev set_crop op
  [media] dvb_frontend: fix a regression with DVB-S zig-zag
  [media] fintek-cir: change || to &&
  [media] V4L: Schedule V4L2_CID_HCENTER, V4L2_CID_VCENTER controls for removal
  [media] rc: Postpone ISR registration
  [media] marvell-cam: fix an ARM build error
  [media] V4L: soc-camera: protect hosts during probing from overzealous user-space
2012-05-14 11:23:37 -07:00
Sylwester Nawrocki
5be4fe633a [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>
2012-05-14 10:20:21 -03:00
Hans Verkuil
5126f2590b [media] v4l2-dev: add flag to have the core lock all file operations
This used to be the default if the lock pointer was set, but now that lock is by
default only used for ioctl serialization. Those drivers that already used
core locking have this flag set explicitly, except for some drivers where
it was obvious that there was no need to serialize any file operations other
than ioctl.

The drivers that didn't need this flag were:

drivers/media/radio/dsbr100.c
drivers/media/radio/radio-isa.c
drivers/media/radio/radio-keene.c
drivers/media/radio/radio-miropcm20.c
drivers/media/radio/radio-mr800.c
drivers/media/radio/radio-tea5764.c
drivers/media/radio/radio-timb.c
drivers/media/video/vivi.c
sound/i2c/other/tea575x-tuner.c

The other drivers that use core locking and where it was not immediately
obvious that this flag wasn't needed were changed so that the flag is set
together with a comment that that driver needs work to avoid having to
set that flag. This will often involve taking the core lock in the fops
themselves.

Eventually this flag should go and it should not be used in new drivers.

There are a few reasons why we want to avoid core locking of non-ioctl
fops: in the case of mmap this can lead to a deadlock in rare situations
since when mmap is called the mmap_sem is held and it is possible for
other parts of the code to take that lock as well (copy_from_user()/copy_to_user()
perform a down_read(&mm->mmap_sem) when a page fault occurs).

It is very unlikely that that happens since the core lock serializes all
fops, but the kernel warns about it if lock validation is turned on.

For poll it is also undesirable to take the core lock as that can introduce
increased latency. The same is true for read/write.

While it was possible to make flags or something to turn on/off taking the
core lock for each file operation, in practice it is much simpler to just
not take it at all except for ioctl and leave it to the driver to take the
lock. There are only a handful fops compared to the zillion ioctls we have.

I also wanted to make it obvious which drivers still take the lock for all
fops, so that's why I chose to have drivers set it explicitly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-14 09:19:38 -03:00
Sylwester Nawrocki
63746be543 [media] s5p-fimc: Correct memory allocation for VIDIOC_CREATE_BUFS
The commit 3b4c34aac7
"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>
2012-05-08 09:11:32 -03:00
Sylwester Nawrocki
e985dbf7d9 [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>
2012-05-08 09:07:42 -03:00
Sylwester Nawrocki
ecd9acbf54 [media] s5p-fimc: Handle sub-device interdependencies using deferred probing
In this driver there are several entities associated with separate
platform or I2C client devices, which may get probed in random order.

When the platform device bound to the media device driver is probed
all other entity drivers need to be already in place and initialized.
If any of them is not, fail the media device probe and return an error
indicating we need to be retried once any new driver gets registered.
The media device driver probe will not succeed until there are available
all needed sub-drivers, as specified in the platform data.

While at it, make sure the s5p-csis module (MIPI-CSI receiver driver)
does not get unloaded when in use, by guarding its usage with
try_module_get/module_put.

This patch is a prerequisite for adding the device tree support.
It now also allows again to unbind/bind the driver at runtime from
user space via sysfs.

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>
2012-04-10 15:25:25 -03:00
Sylwester Nawrocki
6ec0163b79 [media] s5p-fimc: Remove unneeded fields from struct fimc_dev
irq is used only locally and num_clocks is constant, so remove them.

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>
2012-04-10 15:24:20 -03:00
Sylwester Nawrocki
935b1892d8 [media] s5p-fimc: Refactor hardware setup for m2m transaction
Remove redundant H/W setup logic by merging fimc_prepare_config()
and the device_run() callback.

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>
2012-04-10 15:23:59 -03:00
Sylwester Nawrocki
efb13c3d4d [media] s5p-fimc: Simplify locking by removing the context data structure spinlock
Access to the memory-to-memory video node is serialized through a
mutex so now there is no point in having per device context structure
spinlock.

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>
2012-04-10 15:23:28 -03:00
Sylwester Nawrocki
aa333122c9 [media] s5p-fimc: Reinitialize the pipeline properly after VIDIOC_STREAMOFF
This patch prevents blocking on DQBUF at a video capture node in some
conditions, after STREAOMOFF/STREAMON sequence. The ST_CAPT_SUSPEND
flag should not be set during normal stream off, otherwise the
capture engine is not properly enabled at stream on.

Reported-by: Bernard Debbasch <b.debbasch@ssi.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>
2012-04-10 15:22:47 -03:00
Sylwester Nawrocki
20676a4c95 [media] s5p-fimc: Don't use platform data for CSI data alignment configuration
The MIPI-CSI2 data alignment parameter can be derived from media bus
pixel code, so it can be now dropped from the platform data structure.
This is a prerequisite for adding the device tree support. Once this
patch is merged the corresponding fields will be removed from the
drivers' public headers and corresponding board files.

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>
2012-04-10 15:22:26 -03:00
Mauro Carvalho Chehab
50953e0640 Merge branch 'poll' into staging/for_v3.4
* poll: (5970 commits)
  poll: add poll_requested_events() and poll_does_not_wait() functions
  crc32: select an algorithm via Kconfig
  crc32: add self-test code for crc32c
  crypto: crc32c should use library implementation
  crc32: bolt on crc32c
  crc32: add note about this patchset to crc32.c
  crc32: optimize loop counter for x86
  crc32: add slice-by-8 algorithm to existing code
  crc32: make CRC_*_BITS definition correspond to actual bit counts
  crc32: fix mixing of endian-specific types
  crc32: miscellaneous cleanups
  crc32: simplify unit test code
  crc32: move long comment about crc32 fundamentals to Documentation/
  crc32: remove two instances of trailing whitespaces
  checkpatch: check for quoted strings broken across lines
  checkpatch: whitespace - add/remove blank lines
  checkpatch: warn on use of yield()
  checkpatch: add --strict tests for braces, comments and casts
  checkpatch: add [] to type extensions
  checkpatch: high precedence operators do not require additional parentheses in #defines
  ...
2012-03-27 11:32:29 -03:00
Linus Torvalds
e317234975 Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:
 - V4L2 API additions to better support JPEG compression control
 - media API additions to properly support MPEG decoders
 - V4L2 API additions for image crop/scaling
 - a few other V4L2 API DocBook fixes/improvements
 - two new DVB frontend drivers: m88rs2000 and rtl2830
 - two new DVB drivers: az6007 and rtl28xxu
 - a framework for ISA drivers, that removed lots of common code found
   at the ISA radio drivers
 - a new FM transmitter driver (radio-keene)
 - a GPIO-based IR receiver driver
 - a new sensor driver: mt9m032
 - some new video drivers: adv7183, blackfin, mx2_emmaprp, sii9234_drv,
   vs6624
 - several new board additions, driver fixes, improvements and cleanups.

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (295 commits)
  [media] update CARDLIST.em28xx
  [media] partially reverts changeset fa5527c
  [media] stb0899: fix the limits for signal strength values
  [media] em28xx: support for 2304:0242 PCTV QuatroStick (510e)
  [media] em28xx: support for 2013:0251 PCTV QuatroStick nano (520e)
  [media] -EINVAL -> -ENOTTY
  [media] gspca - sn9c20x: Cleanup source
  [media] gspca - sn9c20x: Simplify register write for capture start/stop
  [media] gspca - sn9c20x: Add automatic JPEG compression mechanism
  [media] gspca - sn9c20x: Greater delay in case of sensor no response
  [media] gspca - sn9c20x: Optimize the code of write sequences
  [media] gspca - sn9c20x: Add the JPEG compression quality control
  [media] gspca - sn9c20x: Add a delay after Omnivision sensor reset
  [media] gspca - sn9c20x: Propagate USB errors to higher level
  [media] gspca - sn9c20x: Use the new video control mechanism
  [media] gspca - sn9c20x: Fix loss of frame start
  [media] gspca - zc3xx: Lack of register 08 value for sensor cs2102k
  [media] gspca - ov534_9: Add brightness to OmniVision 5621 sensor
  [media] gspca - zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support
  [media] pvrusb2: fix 7MHz & 8MHz DVB-T tuner support for HVR1900 rev D1F5
  ...
2012-03-23 14:39:09 -07:00
Sylwester Nawrocki
68a6bb5465 [media] s5p-csis: Fix compilation with PM_SLEEP disabled
Fix following compilation error when CONFIG_PM_SLEEP is disabled:

  CC      drivers/media/video/s5p-fimc/mipi-csis.o
drivers/media/video/s5p-fimc/mipi-csis.c: In function ‘s5pcsis_remove’:
drivers/media/video/s5p-fimc/mipi-csis.c:956: error: implicit declaration of function ‘s5pcsis_suspend’

Reported-by: Marek Szyprowski <m.szyprowski@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>
2012-03-19 15:42:24 -03:00
Sylwester Nawrocki
a1212162f4 [media] s5p-csis: Convert to the device managed resources
The devm_* functions are used in the platform device probe() for data
that is freed on driver removal. The managed device layer takes care
of undoing actions taken in the probe callback() and freeing resources
on driver detach. This eliminates the need for manually releasing
resources and simplifies error handling.

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>
2012-03-08 07:41:43 -03:00
Sylwester Nawrocki
f9331d115d [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>
2012-03-08 07:41:26 -03:00
Sylwester Nawrocki
3b4c34aac7 [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>
2012-03-08 07:41:01 -03:00
Sylwester Nawrocki
6d91a51ae1 [media] s5p-fimc: Convert to the device managed resources
The devm_* functions are used in the platform device probe() for data
that is freed on driver removal. The managed device layer takes care
of undoing actions taken in the probe callback() and freeing resources
on driver detach. This eliminates the need for manually releasing
resources and simplifies error handling.

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>
2012-03-08 07:40:40 -03:00
Sylwester Nawrocki
bd7d8888e9 [media] s5p-fimc: convert to clk_prepare()/clk_unprepare()
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>
2012-03-08 07:37:27 -03:00
Alan Stern
fde25a9b63 Driver core: driver_find() drops reference before returning
As part of the removal of get_driver()/put_driver(), this patch
(as1510) changes driver_find(); it now drops the reference it acquires
before returning.  The patch also adjusts all the callers of
driver_find() to remove the now unnecessary calls to put_driver().

In addition, the patch adds a warning to driver_find(): Callers must
make sure the driver they are searching for does not get unloaded
while they are using it.  This has always been the case; driver_find()
has never prevented a driver from being unregistered or unloaded.
Hence the patch will not introduce any new bugs.  The existing callers
all seem to be okay in this respect, however I don't understand the
video drivers well enough to be certain about them.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: Kyungmin Park <kyungmin.park@samsung.com>
CC: Andy Walls <awalls@md.metrocast.net>
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2012-01-24 16:00:34 -08:00
Sachin Kamat
a2e2baad60 [media] s5p-fimc: Remove linux/version.h include from fimc-mdevice.c
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-17 23:06:24 -02:00
Julia Lawall
b1aa60892e [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>
2012-01-17 22:53:34 -02:00
Sachin Kamat
53e5ab946a [media] s5p-fimc: Fix incorrect control ID assignment
This patch fixes the mismatch between control IDs (CID) and controls
for hflip, vflip and rotate.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
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>
2012-01-17 22:53:12 -02:00
Sylwester Nawrocki
f664684a56 [media] s5p-fimc: Prevent lock up caused by incomplete H/W initialization
The following ioctl sequence causes fimc_dma_run() to start processing without
complete scaler and DMA initialization which causes missing interrupt and
blocking on DQBUF:
S_FMT, STREAMON, QBUF, DQBUF, STREAMOFF, STREAMON, QBUF, DQBUF.

Fix this regression caused by moving pm_runtime* calls to start/stop_streaming
callback by making sure the fimc_m2m_resume() is always invoked when expected.

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>
2012-01-06 12:59:42 -02:00
Sylwester Nawrocki
6cf1056f0a [media] s5p-csis: Enable v4l subdev device node
Set v4l2_subdev flags for a host driver to create a sub-device
node for the driver so the subdev can be directly configured
by applications. Add the subdev open() handler.

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>
2011-12-30 14:39:54 -02:00
Sylwester Nawrocki
dafb9c70ab [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>
2011-12-30 14:06:14 -02:00
Sylwester Nawrocki
393a23fc93 [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>
2011-12-11 12:08:51 -02:00
Sylwester Nawrocki
f83f71fda2 [media] s5p-fimc: Use correct fourcc for RGB565 colour format
With 16-bit RGB565 colour format pixels are stored by the device in memory
in the following order:

    | b3  | b2  | b1  | b0  |
   ~+-----+-----+-----+-----+
    | R5 G6 B5  | R5 G6 B5  |

This corresponds to V4L2_PIX_FMT_RGB565 fourcc, not V4L2_PIX_FMT_RGB565X.
This change is required to avoid trouble when setting up video pipeline
with the s5p-tv devices, so the colour formats at both devices can be
properly matched.

Cc: <stable@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>
2011-11-24 21:03:35 -02:00
Sylwester Nawrocki
d12392ec00 [media] s5p-fimc: Fail driver probing when sensor configuration is wrong
When a sensor with MIPI-CSI interface is attached through platform
data definition and the MIPI-CSI receiver is not selected in kernel
configuration s5p-fimc driver probe() will now succeed, issuing only
a warning. It was done this way to allow the driver to work even if
system configuration is not exactly right.

Instead make the driver's probe() fail if a MIPI-CSI sensor was
requested but s5p-csis module is not present.

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>
2011-11-24 21:03:18 -02:00
Sylwester Nawrocki
9c63afcb02 [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>
2011-11-24 21:03:03 -02:00
Sylwester Nawrocki
5cbf6f16ec [media] s5p-fimc: Allow probe() to succeed with null platform data
The "s5p-fimc-md" platform device platform_data is used to pass
attached camera sensor data. Not allowing device probe() to succeed
when it's null prevents using FIMC as a mem-to-mem device only.
Fix this by removing the platform_data check against null and
registering sensors only if platform_data is specified.
Also add logging of the information which /dev/video is assigned
to which device during probe().

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>
2011-11-24 21:02:39 -02:00
Sylwester Nawrocki
2c1bb62e21 [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>
2011-11-24 21:02:10 -02:00
Sylwester Nawrocki
7aa9f1844a [media] s5p-fimc: Fix initialization for proper system suspend support
ST_LPM bit must not be initially set, so the first resume helper
call properly quiesce the device's operation.
Also fimc_runtime_suspend() at device remove is unneeded and
leads to unbalanced clock disable so 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>
2011-11-24 21:01:50 -02:00
Sylwester Nawrocki
64c570f505 [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>
2011-11-24 21:01:35 -02:00
Sylwester Nawrocki
7acde02a5b [media] s5p-fimc: Fix wrong pointer dereference when unregistering sensors
After i2c_unregister_device() has been called the client object can already
be freed and thus using the client pointer may lead to dereferencing freed
memory. Avoid this by saving the adapter pointer for further use before
i2c_unregister_device() call.

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>
2011-11-24 20:57:12 -02:00
Guennadi Liakhovetski
fc714e70dd [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>
2011-11-03 18:28:28 -02:00