summaryrefslogtreecommitdiff
path: root/drivers/media/video/mx2_camera.c
AgeCommit message (Collapse)Author
2012-08-15[media] rename drivers/media/video as .../platformMauro Carvalho Chehab
The remaining drivers are mostly platform drivers. Name the dir to reflect it. It makes sense to latter break it into a few other dirs. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-11media: mx2_camera: Fix mbus format handlingJavier Martin
Do not use MX2_CAMERA_SWAP16 and MX2_CAMERA_PACK_DIR_MSB flags. The driver must negotiate with the attached sensor whether the mbus format is UYUV or YUYV and set CSICR1 configuration accordingly. This is needed for the video function on mach-imx27_visstrim_m10.c to perform properly, since an earlier version of this patch has been proven wrong and has been reverted and a commit, depending on it: "[media] i.MX27: visstrim_m10: Remove use of MX2_CAMERA_SWAP16" is in the mainline. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Reviewed-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [ g.liakhovetski@gmx.de: move a macro definition to a more logical place ] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> [ Applying directly because Mauro is on vacation - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-06-18[media] Revert "[media] media: mx2_camera: Fix mbus format handling"Guennadi Liakhovetski
This reverts commit d509835e32bd761a2b7b446034a273da568e5573. That commit breaks support for the generic pass-through mode in the driver for formats, not natively supported by it. Besides due to a merge conflict it also breaks driver compilation: drivers/media/video/mx2_camera.c: In function 'mx2_camera_set_bus_param': drivers/media/video/mx2_camera.c:937: error: 'pixfmt' undeclared (first use in this function) drivers/media/video/mx2_camera.c:937: error: (Each undeclared identifier is reported only once drivers/media/video/mx2_camera.c:937: error: for each function it appears in.) Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] V4L: mx2-camera: avoid overflowing 32-bitsGuennadi Liakhovetski
In mx2_camera_try_fmt(), when applying i.MX25 restrictions to frame sizes, the height is checked to be <= 0xffff. But later an integer multiplication height * 4 * 0x3ffff is performed, which will overflow even for bounded height values. This patch switches to using 64-bit multiplication and division to avoid overflowing. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] soc-camera: Support user-configurable line strideLaurent Pinchart
Add a capabilities field to the soc_camera_host structure to flag hosts that support user-configurable line strides. soc_camera_try_fmt() then passes the user-provided bytesperline and sizeimage format fields to such hosts, and expects the host to check (and fix if needed) the values. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [g.liakhovetski@gmx.de: fix a typo in mx2_camera.c] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] mx2_camera: Use soc_mbus_image_size() instead of manual computationLaurent Pinchart
Use the new soc_mbus_image_size() function to compute the image size. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] soc_camera: Use soc_camera_device::sizeimage to compute buffer sizesLaurent Pinchart
Instead of computing the buffer size manually in the videobuf queue setup and buffer prepare callbacks, use the previously negotiated soc_camera_device::sizeimage value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] mx2_camera: Fix sizeimage computation in try_fmt()Laurent Pinchart
The try_fmt() handler restricts the image width based on the hardware limits and updates the bytesperline value, but doesn't update sizeimage. Fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-05-15[media] media: mx2_camera: Fix mbus format handlingJavier Martin
Remove MX2_CAMERA_SWAP16 and MX2_CAMERA_PACK_DIR_MSB flags so that the driver can negotiate with the attached sensor whether the mbus format needs convertion from UYUV to YUYV or not. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: Add resizing supportJavier Martin
If the attached video sensor cannot provide the requested image size, try to use resizing engine included in the eMMa-PrP IP. This patch supports both averaging and bilinear algorithms. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: video: mx2_camera.c: Remove unneeded dev_dbgFabio Estevam
csi clock frequency is already shown by: dev_info(&pdev->dev, "MX2 Camera (CSI) driver probed, clock frequency: %ld\n", clk_get_rate(pcdev->clk_csi)); ,so no need to have the dev_dbg call to present the same information. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: video: mx2_camera.c: Provide error message if clk_get failsFabio Estevam
Provide error message if clk_get fails. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: more efficient discard buffer handlingJavier Martin
Some elements of 'mx2_buffer' are grouped together in another auxiliary structure. This way we don't need to have unused 'vb2_buffer' structures for both discard buffers. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: fix compilation warningJavier Martin
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: return IRQ_NONE if no IRQ status bit is setJavier Martin
If active_bufs() list is empty and no IRQ status bit is set we are probably dealing with a share IRQ. Return IRQ_NONE in this case. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: Use spin_lock() inside the IRQ handlerJavier Martin
We don't need to use spin_lock_irqsave() since there are not any other IRQs that can race with this ISR. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media: i.MX27 camera: Use list_first_entry() whenever possibleJavier Martin
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> [g.liakhovetski@gmx.de: fix one list_first_entry() instance] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media i.MX27 camera: handle overflows properlyJavier Martin
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media i.MX27 camera: improve discard buffer handlingJavier Martin
The way discard buffer was previously handled lead to possible races that made a buffer that was not yet ready to be overwritten by new video data. This is easily detected at 25fps just adding "#define DEBUG" to enable the "memset" check and seeing how the image is corrupted. A new "discard" queue and two discard buffers have been added to make them flow trough the pipeline of queues and thus provide suitable event ordering. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media i.MX27 camera: add start_stream and stop_stream callbacksJavier Martin
Add "start_stream" and "stop_stream" callback in order to enable and disable the eMMa-PrP properly and save CPU usage avoiding IRQs when the device is not streaming. This also makes the driver return 0 as the sequence number of the first frame. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> [g.liakhovetski@gmx.de: remove the mx27_camera_emma() macro] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] media i.MX27 camera: migrate driver to videobuf2Javier Martin
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-03-08[media] V4L: mx2_camera: remove unsupported i.MX27 DMA mode, make EMMA mandatorySascha Hauer
The i.MX27 DMA support was introduced with the initial commit of this driver and originally created by me. However, I never got this stable due to the racy DMA engine and used the EMMA engine instead. As the DMA support is most probably unused and broken in its current state, remove it. EMMA becomes the only supported mode on i.MX27. This also helps us get rid of another user of the legacy i.MX DMA support and remove the dependency on ARCH_MX* macros as these are scheduled for removal. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> [g.liakhovetski@gmx.de: remove unused goto] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-06[media] media i.MX27 camera: Fix field_count handlingJavier Martin
To properly detect frame loss the driver must keep track of a frame_count. Furthermore, field_count use was erroneous because in progressive format this must be incremented twice. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-06[media] i.MX27 camera: add support for YUV420 formatJavier Martin
This patch uses channel 2 of the eMMa-PrP to convert format provided by the sensor to YUV420. This format is very useful since it is used by the internal H.264 encoder. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-06[media] soc-camera: remove redundant parameter from .set_bus_param()Guennadi Liakhovetski
The "pixfmt" parameter of the struct soc_camera_host_ops::set_bus_param() method is redundant, because at the time, when this method is called, pixfmt is guaranteed to be equal to icd->current_fmt->host_fmt->fourcc. Remove this parameter and update all drivers accordingly. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-11-03[media] V4L: mx2_camera: convert to the new mbus-config subdev operationsGuennadi Liakhovetski
Switch from soc-camera specific .{query,set}_bus_param() to V4L2 subdevice .[gs]_mbus_config() operations. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-27[media] V4L: soc-camera: remove soc-camera bus and devices on itGuennadi Liakhovetski
Now that v4l2 subdevices have got their own device objects, having one more device in soc-camera clients became redundant and confusing. This patch removes those devices and the soc-camera bus, they used to reside on. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-27[media] V4L: mx2_camera: .try_fmt shouldn't failGuennadi Liakhovetski
If the user is requesting too large a frame, instead of failing select an acceptable geometry, preserving the requested aspect ratio. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-07-27[media] Stop using linux/version.h on the remaining video driversMauro Carvalho Chehab
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>
2010-12-31[media] v4l: soc-camera: switch to .unlocked_ioctlGuennadi Liakhovetski
Use the V4L mutex infrastructure in soc-camera core and drivers and switch to .unlocked_ioctl. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-20[media] mx2_camera: fix pixel clock polarity configurationBaruch Siach
When SOCAM_PCLK_SAMPLE_FALLING, just leave CSICR1_REDGE unset, otherwise we get the inverted behaviour. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-11-09[media] soc-camera: Compile fixes for mx2-cameraSascha Hauer
mx2-camera got broken during the last merge window. This patch fixes this and removes some unused variables. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: videobuf: add ext_lock argument to the queue init functions (part 2)Hans Verkuil
Missed a few init functions on non-Intel platforms the first time :-( Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: mx2_camera: add informative camera clock frequency printoutMichael Grzeschik
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: mx2_camera: implement forced termination of active buffer for mx25Baruch Siach
This allows userspace to terminate a capture without waiting for the current frame to complete. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: mx2_camera: fix comment typoBaruch Siach
Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: mx2_camera: remove emma limitation for RGB565Michael Grzeschik
In the current source status the emma has no limitation for any PIXFMT since the data is parsed raw and unprocessed into the memory. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21V4L/DVB: videobuf: add queue argument to videobuf_waiton()Hans Verkuil
videobuf_waiton() must unlock and relock ext_lock if it has to wait. For that to happen it needs the videobuf_queue pointer. Don't attempt to unlock/relock q->ext_lock unless it was locked in the first place. vb->state has to be protected by a spinlock to be safe. This patch is based on code from Mauro Carvalho Chehab <mchehab@redhat.com>. [mchehab@redhat.com: add extra argument to a few missing places] Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-09-28V4L/DVB: mx2_camera: fix a race causing NULL dereferenceBaruch Siach
The mx25_camera_irq irq handler may get called after the camera has been deactivated (from mx2_camera_deactivate). Detect this situation, and bail out. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-08-09V4L/DVB: mx2_camera: add rising edge for pixclockMichael Grzeschik
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-08-09V4L/DVB: mx2_camera: fix for list bufnum in frame_done_emmaMichael Grzeschik
The emma uses bufnum 1 and 0. This patch tells the bufqueue to change the next buffer to the next one and not the current one. Otherwise the BUG_ON above will trigger everytime. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-07-28mx2_camera: fix type of dma buffer virtual address pointerBaruch Siach
Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-28mx2_camera: Add soc_camera support for i.MX25/i.MX27Baruch Siach
This is the soc_camera support developed by Sascha Hauer for the i.MX27. Alan Carvalho de Assis modified the original driver to get it working on more recent kernels. I modified it further to add support for i.MX25. This driver has been tested on i.MX25 and i.MX27 based platforms. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>