Hans Verkuil [Thu, 7 Aug 2014 06:47:14 +0000 (03:47 -0300)]
[media] videobuf2: fix lockdep warning
The following lockdep warning has been there ever since commit
a517cca6b24fc54ac209e44118ec8962051662e3
one year ago:
[ 403.117947] ======================================================
[ 403.117949] [ INFO: possible circular locking dependency detected ]
[ 403.117953] 3.16.0-rc6-test-media #961 Not tainted
[ 403.117954] -------------------------------------------------------
[ 403.117956] v4l2-ctl/15377 is trying to acquire lock:
[ 403.117959] (&dev->mutex#3){+.+.+.}, at: [<
ffffffffa005a6c3>] vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.117974]
[ 403.117974] but task is already holding lock:
[ 403.117976] (&mm->mmap_sem){++++++}, at: [<
ffffffff8118291f>] vm_mmap_pgoff+0x6f/0xc0
[ 403.117987]
[ 403.117987] which lock already depends on the new lock.
[ 403.117987]
[ 403.117990]
[ 403.117990] the existing dependency chain (in reverse order) is:
[ 403.117992]
[ 403.117992] -> #1 (&mm->mmap_sem){++++++}:
[ 403.117997] [<
ffffffff810d733c>] validate_chain.isra.39+0x5fc/0x9a0
[ 403.118006] [<
ffffffff810d8bc3>] __lock_acquire+0x4d3/0xd30
[ 403.118010] [<
ffffffff810d9da7>] lock_acquire+0xa7/0x160
[ 403.118014] [<
ffffffff8118c9ec>] might_fault+0x7c/0xb0
[ 403.118018] [<
ffffffffa0028a25>] video_usercopy+0x425/0x610 [videodev]
[ 403.118028] [<
ffffffffa0028c25>] video_ioctl2+0x15/0x20 [videodev]
[ 403.118034] [<
ffffffffa0022764>] v4l2_ioctl+0x184/0x1a0 [videodev]
[ 403.118040] [<
ffffffff811d77d0>] do_vfs_ioctl+0x2f0/0x4f0
[ 403.118307] [<
ffffffff811d7a51>] SyS_ioctl+0x81/0xa0
[ 403.118311] [<
ffffffff8199dc69>] system_call_fastpath+0x16/0x1b
[ 403.118319]
[ 403.118319] -> #0 (&dev->mutex#3){+.+.+.}:
[ 403.118324] [<
ffffffff810d6a96>] check_prevs_add+0x746/0x9f0
[ 403.118329] [<
ffffffff810d733c>] validate_chain.isra.39+0x5fc/0x9a0
[ 403.118333] [<
ffffffff810d8bc3>] __lock_acquire+0x4d3/0xd30
[ 403.118336] [<
ffffffff810d9da7>] lock_acquire+0xa7/0x160
[ 403.118340] [<
ffffffff81999664>] mutex_lock_interruptible_nested+0x64/0x640
[ 403.118344] [<
ffffffffa005a6c3>] vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118349] [<
ffffffffa0022122>] v4l2_mmap+0x62/0xa0 [videodev]
[ 403.118354] [<
ffffffff81197270>] mmap_region+0x3d0/0x5d0
[ 403.118359] [<
ffffffff8119778d>] do_mmap_pgoff+0x31d/0x400
[ 403.118363] [<
ffffffff81182940>] vm_mmap_pgoff+0x90/0xc0
[ 403.118366] [<
ffffffff81195cef>] SyS_mmap_pgoff+0x1df/0x2a0
[ 403.118369] [<
ffffffff810085c2>] SyS_mmap+0x22/0x30
[ 403.118376] [<
ffffffff8199dc69>] system_call_fastpath+0x16/0x1b
[ 403.118381]
[ 403.118381] other info that might help us debug this:
[ 403.118381]
[ 403.118383] Possible unsafe locking scenario:
[ 403.118383]
[ 403.118385] CPU0 CPU1
[ 403.118387] ---- ----
[ 403.118388] lock(&mm->mmap_sem);
[ 403.118391] lock(&dev->mutex#3);
[ 403.118394] lock(&mm->mmap_sem);
[ 403.118397] lock(&dev->mutex#3);
[ 403.118400]
[ 403.118400] *** DEADLOCK ***
[ 403.118400]
[ 403.118403] 1 lock held by v4l2-ctl/15377:
[ 403.118405] #0: (&mm->mmap_sem){++++++}, at: [<
ffffffff8118291f>] vm_mmap_pgoff+0x6f/0xc0
[ 403.118411]
[ 403.118411] stack backtrace:
[ 403.118415] CPU: 0 PID: 15377 Comm: v4l2-ctl Not tainted 3.16.0-rc6-test-media #961
[ 403.118418] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013
[ 403.118420]
ffffffff82a6c9d0 ffff8800af37fb00 ffffffff819916a2 ffffffff82a6c9d0
[ 403.118425]
ffff8800af37fb40 ffffffff810d5715 ffff8802308e4200 0000000000000000
[ 403.118429]
ffff8802308e4a48 ffff8802308e4a48 ffff8802308e4200 0000000000000001
[ 403.118433] Call Trace:
[ 403.118441] [<
ffffffff819916a2>] dump_stack+0x4e/0x7a
[ 403.118445] [<
ffffffff810d5715>] print_circular_bug+0x1d5/0x2a0
[ 403.118449] [<
ffffffff810d6a96>] check_prevs_add+0x746/0x9f0
[ 403.118455] [<
ffffffff8119c172>] ? find_vmap_area+0x42/0x70
[ 403.118459] [<
ffffffff810d733c>] validate_chain.isra.39+0x5fc/0x9a0
[ 403.118463] [<
ffffffff810d8bc3>] __lock_acquire+0x4d3/0xd30
[ 403.118468] [<
ffffffff810d9da7>] lock_acquire+0xa7/0x160
[ 403.118472] [<
ffffffffa005a6c3>] ? vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118476] [<
ffffffffa005a6c3>] ? vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118480] [<
ffffffff81999664>] mutex_lock_interruptible_nested+0x64/0x640
[ 403.118484] [<
ffffffffa005a6c3>] ? vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118488] [<
ffffffffa005a6c3>] ? vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118493] [<
ffffffff810d8055>] ? mark_held_locks+0x75/0xa0
[ 403.118497] [<
ffffffffa005a6c3>] vb2_fop_mmap+0x33/0x90 [videobuf2_core]
[ 403.118502] [<
ffffffffa0022122>] v4l2_mmap+0x62/0xa0 [videodev]
[ 403.118506] [<
ffffffff81197270>] mmap_region+0x3d0/0x5d0
[ 403.118510] [<
ffffffff8119778d>] do_mmap_pgoff+0x31d/0x400
[ 403.118513] [<
ffffffff81182940>] vm_mmap_pgoff+0x90/0xc0
[ 403.118517] [<
ffffffff81195cef>] SyS_mmap_pgoff+0x1df/0x2a0
[ 403.118521] [<
ffffffff810085c2>] SyS_mmap+0x22/0x30
[ 403.118525] [<
ffffffff8199dc69>] system_call_fastpath+0x16/0x1b
The reason is that vb2_fop_mmap and vb2_fop_get_unmapped_area take the core lock
while they are called with the mmap_sem semaphore held. But elsewhere in the code
the core lock is taken first but calls to copy_to/from_user() can take the mmap_sem
semaphore as well, potentially causing a classical A-B/B-A deadlock.
However, the mmap/get_unmapped_area calls really shouldn't take the core lock
at all. So what would happen if they don't take the core lock anymore?
There are two situations that need to be taken into account: calling mmap while
new buffers are being added and calling mmap while buffers are being deleted.
The first case works almost fine without a lock: in all cases mmap relies on
correctly filled-in q->num_buffers/q->num_planes values and those are only
updated by reqbufs and create_buffers *after* any new buffers have been
initialized completely. Except in one case: if an error occurred while allocating
the buffers it will increase num_buffers and rely on __vb2_queue_free to
decrease it again. So there is a short period where the buffer information
may be wrong.
The second case definitely does pose a problem: buffers may be in the process
of being deleted, without the internal structure being updated.
In order to fix this a new mutex is added to vb2_queue that is taken when
buffers are allocated or deleted, and in vb2_mmap. That way vb2_mmap won't
get stale buffer data. Note that this is a problem only for MEMORY_MMAP, so
even though __qbuf_userptr and __qbuf_dmabuf also mess around with buffers
(mem_priv in particular), this doesn't clash with vb2_mmap or
vb2_get_unmapped_area since those are MMAP specific.
As an additional bonus the hack in __buf_prepare, the USERPTR case, can be
removed as well since mmap() no longer takes the core lock.
All in all a much cleaner solution.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Dan Carpenter [Tue, 5 Aug 2014 08:11:13 +0000 (05:11 -0300)]
[media] vmalloc_sg: off by one in error handling
The "i--" needs to happen at the start of the loop or it will try to
release something bogus (probably it will crash) and it won't release
the first ->vaddr_page[].
Fixes: 7b4eeed174b7 ('[media] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Wed, 13 Aug 2014 00:35:44 +0000 (21:35 -0300)]
[media] as102-fe: Add a release function
This is needed to free state and for dvb_detach() to be
called.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:24 +0000 (18:50 -0300)]
[media] as102: add missing viterbi lock
In order to get FE_HAS_SYNC, the viterbi should already be
locked too. So, add the missing FE_HAS_VITERBI lock.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:23 +0000 (18:50 -0300)]
[media] as102-fe: make it an independent driver
Move as102-fe to dvb-frontends directory and make it an
independent driver.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:22 +0000 (18:50 -0300)]
[media] as102: prepare as102_fe to be compiled as a module
Remove the dependencies of as102_cmd from as102, in order to
allow it to be compiled as a separate module.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:21 +0000 (18:50 -0300)]
[media] as102: get rid of as10x_fe_copy_tps_parameters()
This function just converts from the as10x internal data into
the DVBv5 cache. Get rid of it.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:20 +0000 (18:50 -0300)]
[media] as102: get rid of as102_fe_copy_tune_parameters()
This function just parses the frontend cache and converts
to the as102 internal format message. Get rid of it.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:19 +0000 (18:50 -0300)]
[media] as102: Move ancillary routines to the beggining
Avoid having function prototypes by moving some
ancillary routines to the beginning of the file.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:18 +0000 (18:50 -0300)]
[media] as102: better name the unknown frontend
Make the frontend .name more coherent with DVB namespace.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:17 +0000 (18:50 -0300)]
[media] as102: CodingStyle fixes
Fix this warning:
WARNING: quoted string split across lines
566: FILE: drivers/media/usb/as102/as102_fe.c:141:
+ "demod status: fc: 0x%08x, bad fc: 0x%08x, "
+ "bytes corrected: 0x%08x , MER: 0x%04x\n",
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:16 +0000 (18:50 -0300)]
[media] as102: get rid of FSF mail address
Make checkpatch happier by removing FSF mail address.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Tue, 12 Aug 2014 21:50:15 +0000 (18:50 -0300)]
[media] as102: promote it out of staging
This driver is stable and doesn't contain any really serious
issue. Move it out of staging.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Martin Kepplinger [Mon, 4 Aug 2014 11:13:16 +0000 (08:13 -0300)]
[media] staging: media: as102: replace custom dprintk() with dev_dbg()
remove dprintk() and replace it with dev_dbg() or pr_debug()
in order to use the common kernel coding style.
Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Mon, 11 Aug 2014 21:09:32 +0000 (18:09 -0300)]
[media] siano: add support for PCTV 77e
Add support for PCTV microStick (77e) device that uses a sms1140
chipset.
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Wed, 11 Jun 2014 13:37:36 +0000 (10:37 -0300)]
[media] smiapp: Set 64-bit integer control using v4l2_ctrl_s_ctrl_int64()
Don't manipulate struct v4l2_ctrl directly. Instead, use
v4l2_ctrl_s_ctrl_int64() to change the values.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Wed, 11 Jun 2014 13:34:35 +0000 (10:34 -0300)]
[media] smiapp: Use unlocked __v4l2_ctrl_modify_range()
Instead of modifying the control ranges directly by manipulating struct
v4l2_ctrl, use __v4l2_ctrl_modify_range() for the purpose.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 6 Aug 2014 11:02:23 +0000 (08:02 -0300)]
[media] coda: checkpatch cleanup
This patch breaks most long lines, concatenates broken up text strings,
and adds or removes parentheses where needed to make checkpatch happy.
The long codec list lines and a few 81-wide lines remain.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:20 +0000 (14:00 -0300)]
[media] coda: disable old cropping ioctls
Since we neither support composing on the OUTPUT side, nor cropping
on the CAPTURE side, disable VIDIOC_CROPCAP and VIDIOC_G/S_CROP
altogether. This silences a GStreamer warning when GStreamer tries
to obtain the pixel aspect ratio using VIDIOC_CROPCAP.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:19 +0000 (14:00 -0300)]
[media] coda: set capture frame size with output S_FMT
This patch makes coda_s_fmt_vid_out propagate the output frame size
to the capture side.
The GStreamer v4l2videodec only ever calls S_FMT on the output side
and then expects G_FMT on the capture side to return a valid format.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:18 +0000 (14:00 -0300)]
[media] coda: fix coda_s_fmt_vid_out
Set the context color space when s_fmt succeeded, not when it failed.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:17 +0000 (14:00 -0300)]
[media] coda: fix timestamp list handling
Lock modification of the timestamp list with bitstream_mutex and do not
try to remove a timestamp element if the list is empty. This can happen
if the userspace feeds us garbage or multiple encoded frames in a single
buffer.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:16 +0000 (14:00 -0300)]
[media] coda: improve allocation error messages
Produce some error messages when internal buffer allocation
fails, for example because the CMA region is too small.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:15 +0000 (14:00 -0300)]
[media] coda: add an intermediate debug level
Dumping all register accesses drowns other debugging messages
in the log. Add a less verbose debug level.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:14 +0000 (14:00 -0300)]
[media] coda: increase max vertical frame size to 1088
This patch increases the maximum vertical frame size reported
by enum_fmt and accepted by try_fmt/s_fmt from 1080 to 1088.
Since for 16x16-pixel macroblocks 1080p will be rounded up to
this anyway, we may as well admit that we support it.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:13 +0000 (14:00 -0300)]
[media] coda: allow running coda without iram on mx6dl
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:12 +0000 (14:00 -0300)]
[media] coda: skip calling coda_find_codec in encoder try_fmt_vid_out
We know that it will return NULL in this case, so we can just as well
skip it altogether.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:11 +0000 (14:00 -0300)]
[media] coda: dequeue buffers on streamoff
This is needed to decrease the q->owned_by_drv_count to zero before
__vb2_queue_cancel is called, to avoid the WARN_ON therein.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:10 +0000 (14:00 -0300)]
[media] coda: dequeue buffers if start_streaming fails
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:09 +0000 (14:00 -0300)]
[media] coda: request BIT processor interrupt by name
Request the main coda interrupt using its name, "bit", if available.
Fall back to requesting the first interrupt for backwards compatibility.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:08 +0000 (14:00 -0300)]
[media] coda: remove unnecessary peek at next destination buffer from coda_finish_decode
The return value of this call to v4l2_m2m_next_dst_buf() is never used.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:06 +0000 (14:00 -0300)]
[media] coda: include header for memcpy
coda_h264_padding uses memcpy, we should include string.h for that.
Reported-by: Ian Jamison <ian.dev@arkver.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:45 +0000 (12:28 -0300)]
[media] coda: move BIT specific functions into separate file
This patch moves the BIT processor specific coda_context_ops, the firmware
upload and other related functions from coda-common.c into coda-bit.c.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:44 +0000 (12:28 -0300)]
[media] coda: move H.264 helper function into separate file
Currently there is only the coda_h264_padding function, but
we will have to add more H.264 specific helpers later.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:43 +0000 (12:28 -0300)]
[media] coda: move per-instance buffer allocation and cleanup
This patch moves the context buffer allocation into the context start_streaming
callbacks. The context buffer and internal framebuffer cleanup is moved into
the context release callback.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:42 +0000 (12:28 -0300)]
[media] coda: add coda_bit_stream_set_flag helper
This adds a helper function to consolidate three occurences where
the bitstream parameter stream end flag is set during operation.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:41 +0000 (12:28 -0300)]
[media] coda: move BIT processor command execution out of pic_run_work
In preparation for the split, move the AXI_SRAM_USE register access and the
PIC_RUN command execution out of pic_run_work into prepare_encode/decode.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:40 +0000 (12:28 -0300)]
[media] coda: add context ops
Add a struct coda_context_ops that encapsulates context specific operations.
This will simplify adding JPEG support in the future and helps to avoid
exporting all functions individually when they move out of the main code
file.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:39 +0000 (12:28 -0300)]
[media] coda: move defines, enums, and structs into shared header
These will have to be shared between multiple code files.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 23 Jul 2014 15:28:38 +0000 (12:28 -0300)]
[media] coda: move coda driver into its own directory
The coda driver has grown significantly and will continue to grow.
Move the coda driver into its own directory so it can be split.
Rename coda.h to coda_regs.h as it contains the register defines.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:45 +0000 (07:22 -0300)]
[media] coda: mark constant structures as such
The format and codec lists and the ops structures are read-only.
Mark them as const.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:44 +0000 (07:22 -0300)]
[media] coda: default to h.264 decoder on invalid formats
If the user provides an invalid format, let the decoder device
default to h.264.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:43 +0000 (07:22 -0300)]
[media] coda: split format enumeration for encoder end decoder device
Let the decoder capture side and encoder output side only list
uncompressed formats, and the decoder output and encoder capture
side only list compressed formats.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:42 +0000 (07:22 -0300)]
[media] coda: split userspace interface into encoder and decoder device
Userspace has a hard time making sense of format enumerations on V4L2
mem2mem devices if there are restrictions on which input and output
formats can be used together. Alleviate the problem by splitting the
video4linux device into separate encoder and decoder devices which list
only raw formats on one side and only encoded formats on the other side.
With this patch, the instance type (encoder or decoder) is already
determined by the open file operation.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:41 +0000 (07:22 -0300)]
[media] coda: lock capture frame size to output frame size when streaming
As soon as the output queue is streaming, let try_fmt on the capture side
only allow the frame size that was set on the output side.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Michael Olbrich [Fri, 18 Jul 2014 10:22:40 +0000 (07:22 -0300)]
[media] coda: delay coda_fill_bitstream()
coda_fill_bitstream() calls v4l2_m2m_buf_done() which is no longer allowed
before streaming was started.
Delay coda_fill_bitstream() until coda_start_streaming() and explicitly set
'start_streaming_called' before calling coda_fill_bitstream()
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Michael Olbrich [Fri, 18 Jul 2014 10:22:39 +0000 (07:22 -0300)]
[media] coda: use CODA_MAX_FRAME_SIZE everywhere
Without this changing CODA_MAX_FRAME_SIZE to anything other than 0x100000
can break the bitstram handling
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:38 +0000 (07:22 -0300)]
[media] coda: remove VB2_USERPTR from queue io_modes
Disallow USERPTR buffers, videobuf2-dma-contig doesn't support them.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:37 +0000 (07:22 -0300)]
[media] coda: remove CAPTURE and OUTPUT caps
This is a mem2mem driver, pure capture or output modes are not
supported.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:36 +0000 (07:22 -0300)]
[media] coda: initialize hardware on pm runtime resume only if firmware available
If no firmware was found and the coda module is unloaded, coda_runtime_resume
will be called without an allocated code buffer. Do not call coda_hw_init in
this case.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:35 +0000 (07:22 -0300)]
[media] coda: fix CODA7541 hardware reset
Do not try to read the CODA960 GDI status register on CODA7541.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Wed, 23 Jul 2014 13:30:57 +0000 (10:30 -0300)]
[media] omap3isp: resizer: Protect against races when updating crop
When updating the crop rectangle during streaming, the IRQ handler will
reprogram the resizer after the current frame. A race condition
currently exists between the set selection operation and the IRQ
handler: if the set selection operation is called twice in a row and the
IRQ handler runs only during the second call, it could reprogram the
hardware with partially updated values. Use a spinlock to protect
against that.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Wed, 23 Jul 2014 13:30:57 +0000 (10:30 -0300)]
[media] omap3isp: resizer: Remove slow debugging message from interrupt handler
The resizer_set_input_size() function prints a debugging message with
the input width and height values. As the function is called from
interrupt context, printing that message to the serial console could
slow down the interrupt handler and cause it to miss the start of the
next frame, causing image corruption.
Fix this by reorganizing the resizer debug messages. The driver now
prints the input size, the crop rectangle and the output size in the set
selection handler instead of scattering debug messages in various
places.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Wed, 23 Jul 2014 13:30:57 +0000 (10:30 -0300)]
[media] omap3isp: resizer: Remove needless variable initializations
There's no need to initialize local variables to zero when they're
explicitly assigned another value right after. Remove the needless
initializations.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 13:28:48 +0000 (10:28 -0300)]
[media] omap3isp: ccdc: Restart the CCDC immediately after an underrun in BT.656
As the CCDC doesn't generate interrupts when stopped in BT.656 mode,
restart it immediately when the next buffer after an underrun is queued
instead of relying on the interrupt handler to restart the CCDC.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 13:26:28 +0000 (10:26 -0300)]
[media] omap3isp: ccdc: Don't timeout on stream off when the CCDC is stopped
When the CCDC is already stopped due to a buffer underrun, the stop
state machine won't advance in BT.656 mode as no interrupt are generated
by the stopped CCDC in that mode. Handle this case explicitly in the
ccdc_disable() function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 12:41:57 +0000 (09:41 -0300)]
[media] omap3isp: ccdc: Fix freeze when a short frame is received
In BT.656 mode the synchronization signals are generated by the CCDC
from the embedded sync codes. The VD0 and VD1 interrupts are thus only
triggered when the CCDC is enabled, unlike external sync mode where the
line counter runs even when the CCDC is stopped. We can't disable the
CCDC at VD1 time, as no VD0 interrupt would be generated for a short
frame, which would result in the CCDC being stopped and no VD interrupt
generated anymore. The CCDC is stopped from the VD0 interrupt handler
instead for BT.656.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 12:16:08 +0000 (09:16 -0300)]
[media] omap3isp: ccdc: Increment the frame number at VD0 time for BT.656
We will stop using VD1 in BT.656 mode, move frame number increment to
the VD0 interrupt handler.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 09:15:33 +0000 (06:15 -0300)]
[media] omap3isp: ccdc: Simplify ccdc_lsc_is_configured()
Use a local variable to avoid the duplicate spin_unlock_irqrestore()
call.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Sat, 7 Jun 2014 23:57:07 +0000 (20:57 -0300)]
[media] omap3isp: ccdc: Rename __ccdc_handle_stopping to ccdc_handle_stopping
There's no need for a double underscore in the function name, remove it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Sat, 7 Jun 2014 23:57:07 +0000 (20:57 -0300)]
[media] omap3isp: ccdc: Only complete buffer when all fields are captured
Checking that the captured field corresponds to the last required field
depending on the requested field order before completing the buffer
isn't enough. When the first field at stream start corresponds to the
last required field, this would result in returning an interlaced buffer
containing a single field.
Fix this by keeping track of the fields captured in the buffer, and make
sure that both fields are present for alternate field orders.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 10 Jun 2014 14:51:34 +0000 (11:51 -0300)]
[media] omap3isp: ccdc: Disable the video port when unused
The video port doesn't support YUV formats. Disable it when the CCDC
sink pad format is set to YUV instead of leaving it enabled and relying
on downstream modules not to process data they receive from the video
port.
Experiments showed that this fixes some of the CCDC failures to stop,
especially in BT.656 mode.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 20 May 2014 17:18:53 +0000 (14:18 -0300)]
[media] omap3isp: ccdc: Add support for BT.656 YUV format at the CCDC input
Query the CCDC input media bus type from the subdev connected to the
CCDC sink pad and configure the CCDC accordingly to support BT.656
synchronization.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 22:40:04 +0000 (19:40 -0300)]
[media] omap3isp: ccdc: Support the interlaced field orders at the CCDC output
The CCDC can interleave fields into a single buffer when writing to
memory. Support it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 19:37:38 +0000 (16:37 -0300)]
[media] omap3isp: ccdc: Add basic support for interlaced video
When the CCDC input is interlaced enable the alternate field order on
the CCDC output video node. The field signal polarity is specified
through platform data.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 20 May 2014 00:46:33 +0000 (21:46 -0300)]
[media] omap3isp: ccdc: Simplify the ccdc_isr_buffer() function
Instead of using goto statements to a single line return, return the
correct value immediately.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 18:05:51 +0000 (15:05 -0300)]
[media] omap3isp: ccdc: Simplify the configuration function
Assign the format variable to the sink pad format earlier and use it
instead of accessing the sink pad format directly from the ISP
structure.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 15:14:42 +0000 (12:14 -0300)]
[media] omap3isp: video: Validate the video node field order
The field order requested on the video node must match the field order
at the connected subdevice source pad.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 13:49:58 +0000 (10:49 -0300)]
[media] omap3isp: Default to progressive field order when setting the format
If the requested field order is not supported default to progressive as
we can't guess how the user will configure the pipeline later on.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 13:33:15 +0000 (10:33 -0300)]
[media] omap3isp: Move non-critical code out of the mutex-protected section
The isp_video_pix_to_mbus() and isp_video_mbus_to_pix() calls in
isp_video_set_format() only access static fields of the isp_video
structure. They don't need to be protected by a mutex.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 21:17:55 +0000 (18:17 -0300)]
[media] omap3isp: Remove boilerplate disclaimer and FSF address
We don't want to modify all source files the day the FSF moves.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Tue, 20 May 2014 21:21:13 +0000 (18:21 -0300)]
[media] omap3isp: Don't ignore subdev streamoff failures
Record the value returned by subdevs from s_stream(0) and handle stop
failures when an error occurs.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Laurent Pinchart [Mon, 19 May 2014 14:36:23 +0000 (11:36 -0300)]
[media] v4l: subdev: Extend default link validation to cover field order
The field order must match between the source and sink pads, or the sink
pad field order must be NONE. This allows connecting an interlaced
source to a bridge that has no hardware support for interlaced formats.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Enrico Butera <ebutera@users.sourceforge.net>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Wed, 21 May 2014 19:58:11 +0000 (16:58 -0300)]
[media] smiapp: Implement the test pattern control
Add support for the V4L2_CID_TEST_PATTERN control. When the solid colour
mode is selected, additional controls become available for setting the
solid four solid colour components.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Mon, 26 May 2014 12:46:18 +0000 (09:46 -0300)]
[media] smiapp: Add driver-specific test pattern menu item definitions
Add numeric definitions for menu items used in the smiapp driver's test
pattern menu.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Wed, 28 May 2014 12:38:21 +0000 (09:38 -0300)]
[media] v4l: Add test pattern colour component controls
In many cases the test pattern has selectable values for each colour
component. Implement controls for raw bayer components. Additional controls
should be defined for colour components that are not covered by these
controls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 02:14:22 +0000 (23:14 -0300)]
[media] xc5000: be sure that the firmware is there before set params
Now that xc5000_set_params() is also called during resume,
move the code that checks for the firmware to happen there.
This way, the firmware will be loaded either for analog or
digital TV when .resume callback is called.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 02:14:21 +0000 (23:14 -0300)]
[media] au0828: Fix DVB resume when streaming
When DVB is streaming and suspend is called, it will call
au0828_stop_transport(), with will clean the streaming flag.
Due to that, stop_urb_transfer() will be called twice,
causing an oops.
So, we need another flag to be used at resume, telling it
to restart DVB.
While here, add a logic at stop_urb_transfer() to prevent
it of being called twice, and convert the usb_streaming
flag into boolean.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 02:14:20 +0000 (23:14 -0300)]
[media] au0828: fix checks if dvb is initialized
dev->dvb is always not null, as it is an area at the dev
memory. So, checking if (dev->dvb) is always true.
Instead of this stupid check, what the code wants to do is
to know if the DVB was successully registered.
Fix it by checking, instead, for dvb->frontend. It should
also be sure that this var will be NULL if the device was
not properly initialized.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:24 +0000 (21:47 -0300)]
[media] xc5000: better name the functions
xc5000_set_params() is a bad name for a function that
handles only digital TV. Rename it to xc5000_set_digital_params(),
and proper name the generic function that works for both
digital and analog.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:23 +0000 (21:47 -0300)]
[media] xc5000: add a resume function
If a device suspends/hibertates with a station tuned, restore
the tuner station at resume.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:22 +0000 (21:47 -0300)]
[media] xc5000: Split config and set code for analog/radio
As we need a function that reapply the last tuned radio,
in order to do resume, split the code that validates and
updates the internal priv struct from the ones that
actually set radio and TV.
A latter patch will add support for resume.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:21 +0000 (21:47 -0300)]
[media] au0828: move the code that sets DTV on a separate function
As we'll be adding a code to resume tuner operation, we
need to move the code that actually sets DTV on a separate
function, to be called by the resume code.
No functional changes, just code got moved.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:20 +0000 (21:47 -0300)]
[media] xc5000: fix xc5000 suspend
After xc5000 stops working, it waits for 5 seconds, waiting
for a new usage. Only after that it goes to low power mode.
If a suspend event happens before that, a work queue will
remain active, with causes suspend to crash.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:19 +0000 (21:47 -0300)]
[media] dvb-frontend: add core support for tuner suspend/resume
While several tuners have some sort of suspend/resume
implementation, this is currently mangled with an optional
.sleep callback that it is also used to put the device on
low power mode.
Not all drivers implement it, as returning the driver from
low power may require to re-load the firmware, with takes
some time. Also, some drivers may delay it.
So, the more coherent is to add two new optional callbacks
that will let the tuners to directy implement suspend and
resume callbacks if they need.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:18 +0000 (21:47 -0300)]
[media] au0828: add pr_info to track au0828 suspend/resume code
Suspend/resume conditions can be very tricky. Add some info
printk's to help tracking what's happening there.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:17 +0000 (21:47 -0300)]
[media] au0828: use pr_foo macros
Instead of using printk(KERN_foo, use pr_foo() macros.
No functional changes.
Note: we should do the same for dprintk(), but that would
require to remove the dprintk levels. So, for now, let's
not touch on it.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:16 +0000 (21:47 -0300)]
[media] au0828: Remove a bad whitespace
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:15 +0000 (21:47 -0300)]
[media] au0828: add suspend/resume code for V4L2
No timers should be enabled during suspend. So,
stop them. At resume time, we should do the proper
initialization for it to keep working.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:14 +0000 (21:47 -0300)]
[media] au0828: properly handle stream on/off state
The STREAM_ON state is used by s_format callback,
but the driver never sets it.
Fix it. This will also be needed in order to handle
suspend/resume ops.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:13 +0000 (21:47 -0300)]
[media] au0828: Add suspend code for DVB
The scheduled work should be cancelled during suspend.
At resume time, we need to set the frontend again. So,
add such logic to the driver.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:12 +0000 (21:47 -0300)]
[media] au0828: be sure to reenable the bridge and GPIOs on resume
At resume, we should restore the register contents. So,
reenable the bridge and GPIO settings.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:11 +0000 (21:47 -0300)]
[media] au0828: don't let the IR polling thread to run at suspend
Trying to make au0828 to suspend can do very bad things, as
the polling Kthread is not handled. We should disable it
during suspend, only re-enabling it at resume.
Still, analog and digital TV won't work, as we don't reinit
the settings at resume, but at least it won't hang.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Shuah Khan [Sun, 10 Aug 2014 00:47:10 +0000 (21:47 -0300)]
[media] au0828: remove CONFIG_VIDEO_AU0828_RC scope around au0828_rc_*()
Remove CONFIG_VIDEO_AU0828_RC scope around au0828_rc_register()
and au0828_rc_unregister() calls in au0828-core
Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Shuah Khan [Sat, 9 Aug 2014 00:36:18 +0000 (21:36 -0300)]
[media] au0828: add au0828_rc_*() stubs for VIDEO_AU0828_RC disabled case
Define au0828_rc_*() stubs to avoid compile errors when
VIDEO_AU0828_RC is disabled and avoid the need to enclose
au0828_rc_*() in ifdef CONFIG_VIDEO_AU0828_RC in .c files.
Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:08 +0000 (21:47 -0300)]
[media] au0828: handle IR int during suspend/resume
It doesn't make sense to handle an IR code given before
suspending after the device resume. So, turn off IR
int while suspending.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Sun, 10 Aug 2014 00:47:07 +0000 (21:47 -0300)]
[media] au0828: avoid race conditions at RC stop
As the RC kthread can re-enable IR int, we should first
cancel the kthread and then disable IR int.
While here, remove a temporary debug printk.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Thu, 7 Aug 2014 13:46:30 +0000 (10:46 -0300)]
[media] au0828-input: Be sure that IR is enabled at polling
When the DVB code sets the frontend, it disables the IR
INT, probably due to some hardware bug, as there's no code
there at au8522 frontend that writes on register 0xe0.
Fixing it at au8522 code is hard, as it doesn't know if the
IR is enabled or disabled, and just restoring the value of
register 0xe0 could cause other nasty effects. So, better
to add a hack at au0828-input polling interval to enable int,
if disabled.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Thu, 7 Aug 2014 16:10:26 +0000 (13:10 -0300)]
[media] au0828: Enable IR for HVR-850
HVR-850 also has a remote. Enable it.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mauro Carvalho Chehab [Thu, 7 Aug 2014 16:10:25 +0000 (13:10 -0300)]
[media] au0828: add an option to disable IR via modprobe parameter
The IR code increases the power consumption of the device.
Allow to disable it via modprobe parameter.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>