platform/kernel/linux-rpi.git
10 years ago[media] em28xx: only enable PCTV 80e led when streaming
Mauro Carvalho Chehab [Tue, 4 Mar 2014 23:49:07 +0000 (20:49 -0300)]
[media] em28xx: only enable PCTV 80e led when streaming

Instead of keeping the led always on, use it to indicate
when DVB is streaming.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vivi: fix ENUM_FRAMEINTERVALS implementation
Hans Verkuil [Tue, 25 Feb 2014 10:15:54 +0000 (07:15 -0300)]
[media] vivi: fix ENUM_FRAMEINTERVALS implementation

This function never checked if width and height are correct. Add such
a check so the v4l2-compliance tool returns OK again for vivi.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vivi: correctly cleanup after a start_streaming failure
Hans Verkuil [Fri, 21 Feb 2014 08:34:49 +0000 (05:34 -0300)]
[media] vivi: correctly cleanup after a start_streaming failure

If start_streaming fails then any queued buffers must be given back
to the vb2 core.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: call buf_finish after the state check
Hans Verkuil [Fri, 28 Feb 2014 16:30:48 +0000 (13:30 -0300)]
[media] vb2: call buf_finish after the state check

Don't call buf_finish unless we know that the buffer is in a valid state.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: fix streamoff handling if streamon wasn't called
Hans Verkuil [Tue, 25 Feb 2014 12:42:45 +0000 (09:42 -0300)]
[media] vb2: fix streamoff handling if streamon wasn't called

If you request buffers, then queue buffers and then call STREAMOFF
those buffers are not returned to their dequeued state because streamoff
will just return if q->streaming was 0.

This means that afterwards you can never QBUF that same buffer again unless
you do STREAMON, REQBUFS or close the filehandle first.

It is clear that if you do STREAMOFF even if no STREAMON was called before,
you still want to have all buffers returned to their proper dequeued state.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: replace BUG by WARN_ON
Hans Verkuil [Mon, 3 Feb 2014 14:22:45 +0000 (11:22 -0300)]
[media] vb2: replace BUG by WARN_ON

No need to oops for this, WARN_ON is good enough.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: properly clean up PREPARED and QUEUED buffers
Hans Verkuil [Fri, 28 Feb 2014 15:49:18 +0000 (12:49 -0300)]
[media] vb2: properly clean up PREPARED and QUEUED buffers

If __reqbufs was called then existing buffers are freed. However, if that
happens without ever having started STREAMON, but if buffers have been queued,
then the buf_finish op is never called.

Add a call to __vb2_queue_cancel in __reqbufs so that these buffers are
cleaned up there as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: only call start_streaming if sufficient buffers are queued
Hans Verkuil [Mon, 24 Feb 2014 16:51:03 +0000 (13:51 -0300)]
[media] vb2: only call start_streaming if sufficient buffers are queued

In commit 02f142ecd24aaf891324ffba8527284c1731b561 support was added to
start_streaming to return -ENOBUFS if insufficient buffers were queued
for the DMA engine to start. The vb2 core would attempt calling
start_streaming again if another buffer would be queued up.

Later analysis uncovered problems with the queue management if start_streaming
would return an error: the buffers are enqueued to the driver before the
start_streaming op is called, so after an error they are never returned to
the vb2 core. The solution for this is to let the driver return them to
the vb2 core in case of an error while starting the DMA engine. However,
in the case of -ENOBUFS that would be weird: it is not a real error, it
just says that more buffers are needed. Requiring start_streaming to give
them back only to have them requeued again the next time the application
calls QBUF is inefficient.

This patch changes this mechanism: it adds a 'min_buffers_needed' field
to vb2_queue that drivers can set with the minimum number of buffers
required to start the DMA engine. The start_streaming op is only called
if enough buffers are queued. The -ENOBUFS handling has been dropped in
favor of this new method.

Drivers are expected to return buffers back to vb2 core with state QUEUED
if start_streaming would return an error. The vb2 core checks for this
and produces a warning if that didn't happen and it will forcefully
reclaim such buffers to ensure that the internal vb2 core state remains
consistent and all buffer-related resources have been correctly freed
and all op calls have been balanced.

__reqbufs() has been updated to check that at least min_buffers_needed
buffers could be allocated. If fewer buffers were allocated then __reqbufs
will free what was allocated and return -ENOMEM. Based on a suggestion from
Pawel Osciak.

__create_bufs() doesn't do that check, since the use of __create_bufs
assumes some advance scenario where the user might want more control.
Instead streamon will check if enough buffers were allocated to prevent
streaming with fewer than the minimum required number of buffers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: don't init the list if there are still buffers
Hans Verkuil [Mon, 24 Feb 2014 16:41:20 +0000 (13:41 -0300)]
[media] vb2: don't init the list if there are still buffers

__vb2_queue_free() would init the queued_list at all times, even if
q->num_buffers > 0. This should only happen if num_buffers == 0.

This situation can happen if a CREATE_BUFFERS call couldn't allocate
enough buffers and had to free those it did manage to allocate before
returning an error.

While we're at it: __vb2_queue_alloc() returns the number of buffers
allocated, not an error code. So stick the result in allocated_buffers
instead of ret as that's very confusing.

Signed-off-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>
10 years ago[media] vb2: rename queued_count to owned_by_drv_count
Hans Verkuil [Thu, 6 Feb 2014 08:46:11 +0000 (05:46 -0300)]
[media] vb2: rename queued_count to owned_by_drv_count

'queued_count' is a bit vague since it is not clear to which queue it
refers to: the vb2 internal list of buffers or the driver-owned list
of buffers.

Rename to make it explicit.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: fix buf_init/buf_cleanup call sequences
Hans Verkuil [Wed, 29 Jan 2014 16:36:53 +0000 (13:36 -0300)]
[media] vb2: fix buf_init/buf_cleanup call sequences

Ensure that these ops are properly balanced.

There are two scenarios:

1) for MMAP buf_init is called when the buffers are created and buf_cleanup
   must be called when the queue is finally freed. This scenario was always
   working.

2) for USERPTR and DMABUF it is more complicated. When a buffer is queued
   the code checks if all planes of this buffer have been acquired before.
   If that's the case, then only buf_prepare has to be called. Otherwise
   buf_cleanup needs to be called if the buffer was acquired before, then,
   once all changed planes have been (re)acquired, buf_init has to be
   called followed by buf_prepare. Should buf_prepare fail, then buf_cleanup
   must be called on the newly acquired planes to release them in.

Finally, in __vb2_queue_free we have to check if the buffer was actually
acquired before calling buf_cleanup. While that it always true for MMAP
mode, it is not necessarily true for the other modes. E.g. if you just
call REQBUFS and close the file handle, then buffers were never queued and
so no buf_init was ever called.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: consistent usage of periods in videobuf2-core.h
Hans Verkuil [Fri, 28 Feb 2014 15:25:28 +0000 (12:25 -0300)]
[media] vb2: consistent usage of periods in videobuf2-core.h

Sometimes sentences in comments ended with a period, and sometimes they
didn't. Add periods. No other changes.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: call buf_finish from __queue_cancel
Hans Verkuil [Tue, 4 Mar 2014 10:34:49 +0000 (07:34 -0300)]
[media] vb2: call buf_finish from __queue_cancel

If a queue was canceled, then the buf_finish op was never called for the
pending buffers. So add this call to queue_cancel. Before calling buf_finish
set the buffer state to PREPARED, which is the correct state. That way the
states DONE and ERROR will only be seen in buf_finish if streaming is in
progress.

Since buf_finish can now be called from non-streaming state we need to
adapt the handful of drivers that actually need to know this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] pwc: do not decompress the image unless the state is DONE
Hans Verkuil [Tue, 4 Mar 2014 10:28:11 +0000 (07:28 -0300)]
[media] pwc: do not decompress the image unless the state is DONE

There is no point in trying to decompress a captured frame unless
the buffer state is OK. It won't be used in any other state, and
in fact the contents of the buffer might well be corrupt.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: change result code of buf_finish to void
Hans Verkuil [Tue, 4 Mar 2014 10:27:13 +0000 (07:27 -0300)]
[media] vb2: change result code of buf_finish to void

The buf_finish op should always work, so change the return type to void.
Update the few drivers that use it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Reviewed-by: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: add debugging code to check for unbalanced ops
Hans Verkuil [Wed, 29 Jan 2014 14:53:25 +0000 (11:53 -0300)]
[media] vb2: add debugging code to check for unbalanced ops

When a vb2_queue is freed check if all the mem_ops and queue ops were balanced.
So the number of calls to e.g. buf_finish has to match the number of calls to
buf_prepare, etc.

This code is only enabled if CONFIG_VIDEO_ADV_DEBUG is set.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: fix PREPARE_BUF regression
Hans Verkuil [Mon, 10 Feb 2014 16:12:00 +0000 (13:12 -0300)]
[media] vb2: fix PREPARE_BUF regression

Fix an incorrect test in vb2_internal_qbuf() where only DEQUEUED buffers
are allowed. But PREPARED buffers are also OK.

Introduced by commit 4138111a27859dcc56a5592c804dd16bb12a23d1
("vb2: simplify qbuf/prepare_buf by removing callback").

Signed-off-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>
10 years ago[media] vb2: fix read/write regression
Hans Verkuil [Fri, 14 Feb 2014 09:46:50 +0000 (06:46 -0300)]
[media] vb2: fix read/write regression

Commit 88e268702bfba78448abd20a31129458707383aa ("vb2: Improve file I/O
emulation to handle buffers in any order") broke read/write support if
the size of the buffer being read/written is less than the size of the
image.

When the commit was tested originally I used qv4l2, which calls read()
with exactly the size of the image. But if you try 'cat /dev/video0'
then it will fail and typically hang after reading two buffers.

This patch fixes the behavior by adding a new cur_index field that
contains the index of the field currently being filled/read, or it
is num_buffers in which case a new buffer needs to be dequeued.

The old index field has been renamed to initial_index in order to be
a bit more descriptive.

This has been tested with both read and write.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: Check if there are buffers before streamon
Ricardo Ribalda Delgado [Wed, 8 Jan 2014 08:01:33 +0000 (05:01 -0300)]
[media] vb2: Check if there are buffers before streamon

This patch adds a test preventing streamon() if there is no buffer
ready.

Without this patch, a user could call streamon() before
preparing any buffer. This leads to a situation where if he calls
close() before calling streamoff() the device is kept streaming.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agoMerge tag 'v3.14-rc5' into patchwork
Mauro Carvalho Chehab [Tue, 11 Mar 2014 09:55:49 +0000 (06:55 -0300)]
Merge tag 'v3.14-rc5' into patchwork

Linux 3.14-rc5

* tag 'v3.14-rc5': (1117 commits)
  Linux 3.14-rc5
  drm/vmwgfx: avoid null pointer dereference at failure paths
  drm/vmwgfx: Make sure backing mobs are cleared when allocated. Update driver date.
  drm/vmwgfx: Remove some unused surface formats
  MAINTAINERS: add maintainer entry for Armada DRM driver
  arm64: Fix !CONFIG_SMP kernel build
  arm64: mm: Add double logical invert to pte accessors
  dm cache: fix truncation bug when mapping I/O to >2TB fast device
  perf tools: Fix strict alias issue for find_first_bit
  powerpc/powernv: Fix indirect XSCOM unmangling
  powerpc/powernv: Fix opal_xscom_{read,write} prototype
  powerpc/powernv: Refactor PHB diag-data dump
  powerpc/powernv: Dump PHB diag-data immediately
  powerpc: Increase stack redzone for 64-bit userspace to 512 bytes
  powerpc/ftrace: bugfix for test_24bit_addr
  powerpc/crashdump : Fix page frame number check in copy_oldmem_page
  powerpc/le: Ensure that the 'stop-self' RTAS token is handled correctly
  kvm, vmx: Really fix lazy FPU on nested guest
  perf tools: fix BFD detection on opensuse
  drm/radeon: enable speaker allocation setup on dce3.2
  ...

10 years ago[media] omap3isp: Fix kerneldoc for _module_sync_is_stopping and isp_isr()
Peter Meerwald [Fri, 28 Feb 2014 17:36:07 +0000 (14:36 -0300)]
[media] omap3isp: Fix kerneldoc for _module_sync_is_stopping and isp_isr()

Use the correct name in the comment describing function
omap3isp_module_sync_is_stopping().

isp_isr() never returned IRQ_NONE, remove the comment saying so.

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] omap3isp: Rename the variable names in description
Lad, Prabhakar [Fri, 21 Feb 2014 12:07:23 +0000 (09:07 -0300)]
[media] omap3isp: Rename the variable names in description

This patch renames the variable in the description to match it
appropriately to function definition.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] omap3isp: ispccdc: Remove unwanted comments
Lad, Prabhakar [Fri, 21 Feb 2014 12:07:22 +0000 (09:07 -0300)]
[media] omap3isp: ispccdc: Remove unwanted comments

This patch removes the description of members which does not exists for
ispccdc_lsc structure.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] omap3isp: Fix typos
Lad, Prabhakar [Fri, 21 Feb 2014 12:07:21 +0000 (09:07 -0300)]
[media] omap3isp: Fix typos

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] uvcvideo: Add bayer 8-bit patterns to uvcvideo
Edgar Thier [Thu, 20 Feb 2014 07:12:51 +0000 (04:12 -0300)]
[media] uvcvideo: Add bayer 8-bit patterns to uvcvideo

Add bayer 8-bit GUIDs to uvcvideo and associated them with the
corresponding V4L2 pixel formats.

Signed-off-by: Edgar Thier <info@edgarthier.net>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] uvcvideo: Do not use usb_set_interface on bulk EP
Oleksij Rempel [Sun, 16 Feb 2014 09:59:32 +0000 (06:59 -0300)]
[media] uvcvideo: Do not use usb_set_interface on bulk EP

The UVC specification uses alternate setting selection to notify devices
of stream start/stop. This breaks when using bulk-based devices, as the
video streaming interface has a single alternate setting in that case,
making video stream start and video stream stop events to appear
identical to the device. Bulk-based devices are thus not well supported
by UVC.

The webcam built in the Asus Zenbook UX302LA ignores the set interface
request and will keep the video stream enabled when the driver tries to
stop it. If USB autosuspend is enabled the device will then be suspended
and will crash, requiring a cold reboot.

USB trace capture showed that Windows sends a CLEAR_FEATURE(HALT)
request to the bulk endpoint when stopping the stream instead of
selecting alternate setting 0. The camera then behaves correctly, and
thus seems to require that behaviour.

Replace selection of alternate setting 0 with clearing of the endpoint
halt feature at video stream stop for bulk-based devices. Let's refrain
from blaming Microsoft this time, as it's not clear whether this
Windows-specific but USB-compliant behaviour was specifically developed
to handle bulkd-based UVC devices, or if the camera just took advantage
of it.

CC: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Document timestamp buffer flag behaviour
Sakari Ailus [Fri, 7 Feb 2014 22:44:39 +0000 (19:44 -0300)]
[media] v4l: Document timestamp buffer flag behaviour

Timestamp buffer flags are constant at the moment. Document them so that 1)
they're always valid and 2) not changed by the drivers. This leaves room to
extend the functionality later on if needed.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Copy timestamp source flags to destination on m2m devices
Sakari Ailus [Sat, 8 Feb 2014 17:21:35 +0000 (14:21 -0300)]
[media] v4l: Copy timestamp source flags to destination on m2m devices

Copy the flags containing the timestamp source from source buffer flags to
the destination buffer flags on memory-to-memory devices. This is analogous
to copying the timestamp field from source to destination.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src...
Sakari Ailus [Sat, 8 Feb 2014 16:37:59 +0000 (13:37 -0300)]
[media] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst

The timestamp and timecode fields were copied from destination to source,
not the other way around as they should. Fix it.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] uvcvideo: Tell the user space we're using start-of-exposure timestamps
Sakari Ailus [Mon, 10 Feb 2014 22:26:44 +0000 (19:26 -0300)]
[media] uvcvideo: Tell the user space we're using start-of-exposure timestamps

The UVC device provided timestamps are taken from the clock once the
exposure of the frame has begun, not when the reception of the frame would
have been finished as almost anywhere else. Show this to the user space by
using V4L2_BUF_FLAG_TSTAMP_SRC_SOE buffer flag.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Handle buffer timestamp flags correctly
Sakari Ailus [Tue, 25 Feb 2014 22:08:52 +0000 (19:08 -0300)]
[media] v4l: Handle buffer timestamp flags correctly

For COPY timestamps, buffer timestamp source flags will traverse the queue
untouched.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Add timestamp source flags, mask and document them
Sakari Ailus [Sun, 25 Aug 2013 20:57:03 +0000 (17:57 -0300)]
[media] v4l: Add timestamp source flags, mask and document them

Some devices do not produce timestamps that correspond to the end of the
frame. The user space should be informed on the matter. This patch achieves
that by adding buffer flags (and a mask) for timestamp sources since more
possible timestamping points are expected than just two.

A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
value).

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Kamil Debski <k.debski@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Timestamp flags will soon contain timestamp source, not just type
Sakari Ailus [Sat, 1 Mar 2014 13:28:02 +0000 (10:28 -0300)]
[media] v4l: Timestamp flags will soon contain timestamp source, not just type

Mask out other bits when comparing timestamp types.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags
Sakari Ailus [Tue, 25 Feb 2014 22:12:19 +0000 (19:12 -0300)]
[media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags

The timestamp_type field used to contain only the timestamp type. Soon it
will be used for timestamp source flags as well. Rename the field
accordingly.

[m.chehab@samsung.com: do the change also to drivers/staging/media and at s2255]
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Use full 32 bits for buffer flags
Sakari Ailus [Sun, 25 Aug 2013 17:00:43 +0000 (14:00 -0300)]
[media] v4l: Use full 32 bits for buffer flags

The buffer flags field is 32 bits but the defined only used 16. This is
fine, but as more than 16 bits will be used in the very near future, define
them as 32-bit numbers for consistency.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: Document timestamp behaviour to correspond to reality
Sakari Ailus [Fri, 25 Jan 2013 18:00:07 +0000 (15:00 -0300)]
[media] v4l: Document timestamp behaviour to correspond to reality

Document that monotonic timestamps are taken after the corresponding frame
has been received, not when the reception has begun. This corresponds to the
reality of current drivers: the timestamp is naturally taken when the
hardware triggers an interrupt to tell the driver to handle the received
frame.

Remove the note on timestamp accuracy as it is fairly subjective what is
actually an unstable timestamp.

Also remove explanation that output buffer timestamps can be used to delay
outputting a frame.

Remove the footnote saying we always use realtime clock.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] vb2: fix timecode and flags handling for output buffers
Hans Verkuil [Mon, 24 Feb 2014 17:44:50 +0000 (14:44 -0300)]
[media] vb2: fix timecode and flags handling for output buffers

When sending a buffer to a video output device some of the fields need
to be copied so they arrive in the driver. These are the KEY/P/BFRAME
flags and the TIMECODE flag, and, if that flag is set, the timecode field
itself.

There are a number of functions involved in this: the __fill_vb2_buffer()
is called while preparing a buffer. For output buffers the buffer contains
the video data, so any meta data associated with that (KEY/P/BFRAME and
the field information) should be stored at that point.

The timecode, timecode flag and timestamp information is not part of that,
that information will have to be set when vb2_internal_qbuf() is called to
actually queue the buffer to the driver. Usually VIDIOC_QBUF will do the
prepare as well, but you can call PREPARE_BUF first and only later VIDIOC_QBUF.
You most likely will want to set the timestamp and timecode when you actually
queue the buffer, not when you prepare it.

Finally, in buf_prepare() make sure the timestamp and sequence fields are
actually cleared so that when you do a QUERYBUF of a prepared-but-not-yet-queued
buffer you will not see stale timestamp/sequence data.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: add RF tuner gain controls
Antti Palosaari [Sat, 25 Jan 2014 02:44:26 +0000 (23:44 -0300)]
[media] v4l: add RF tuner gain controls

Modern silicon RF tuners used nowadays has many controllable gain
stages on signal path. Usually, but not always, there is at least
3 gain stages. Also on some cases there could be multiple gain
stages within the ones specified here. However, I think that having
these three controllable gain stages offers enough fine-tuning for
real use cases.

1) LNA gain. That is first gain just after antenna input.
2) Mixer gain. It is located quite middle of the signal path, where
RF signal is down-converted to IF/BB.
3) IF gain. That is last gain in order to adjust output signal level
to optimal level for receiving party (usually demodulator ADC).

Each gain stage could be set rather often both manual or automatic
(AGC) mode. Due to that add separate controls for controlling
operation mode.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: document RF tuner gain controls
Antti Palosaari [Thu, 30 Jan 2014 03:00:10 +0000 (00:00 -0300)]
[media] DocBook: document RF tuner gain controls

Add documentation for LNA, mixer and IF gain controls. These
controls are RF tuner specific.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: media: document V4L2_CTRL_CLASS_RF_TUNER
Antti Palosaari [Sat, 1 Feb 2014 00:27:19 +0000 (21:27 -0300)]
[media] DocBook: media: document V4L2_CTRL_CLASS_RF_TUNER

It is class for RF tuner specific controls, like gain controls,
filters, signal strength.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: implement delayed I2C gate close
Antti Palosaari [Sat, 8 Feb 2014 06:50:04 +0000 (03:50 -0300)]
[media] rtl2832: implement delayed I2C gate close

Delay possible I2C gate close a little bit in order to see if there
is next message coming to tuner in a sequence.

Also, export private muxed I2C adapter. That is aimed only for SDR
extension module as SDR belongs to same RTL2832 physical I2C bus (it
is physically property of RTL2832, whilst it is own kernel module).

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: Fix deadlock on i2c mux select function
Luis Alves [Wed, 4 Dec 2013 23:21:22 +0000 (20:21 -0300)]
[media] rtl2832: Fix deadlock on i2c mux select function

Signed-off-by: Luis Alves <ljalvs@gmail.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: add muxed I2C adapter for demod itself
Antti Palosaari [Tue, 3 Dec 2013 21:19:39 +0000 (18:19 -0300)]
[media] rtl2832: add muxed I2C adapter for demod itself

There was a deadlock between master I2C adapter and muxed I2C
adapter. Implement two I2C muxed I2C adapters and leave master
alone, just only for offering I2C adapter for these mux adapters.

Reported-by: Luis Alves <ljalvs@gmail.com>
Reported-by: Benjamin Larsson <benjamin@southpole.se>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: provide muxed I2C adapter
Antti Palosaari [Tue, 26 Nov 2013 15:53:46 +0000 (12:53 -0300)]
[media] rtl2832: provide muxed I2C adapter

RTL2832 provides gated / repeater I2C adapter for tuner.
Implement it as a muxed I2C adapter.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: style changes and minor cleanup
Antti Palosaari [Sun, 13 Oct 2013 03:06:44 +0000 (00:06 -0300)]
[media] rtl2832: style changes and minor cleanup

Most of those were reported by checkpatch.pl...

debug module parameter is not used anywhere so remove it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl2832: remove unused if_dvbt config parameter
Antti Palosaari [Sun, 13 Oct 2013 02:45:34 +0000 (23:45 -0300)]
[media] rtl2832: remove unused if_dvbt config parameter

All used tuners has get_if_frequency() callback and that parameter
is not needed and will not needed as all upcoming tuner drivers
should implement get_if_frequency().

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] rtl28xxu: add module parameter to disable IR
Antti Palosaari [Fri, 22 Nov 2013 17:20:14 +0000 (14:20 -0300)]
[media] rtl28xxu: add module parameter to disable IR

Disable IR interrupts in order to avoid SDR sample loss.
IR interrupts causes some extra load for device and it seems
be one reason to loss samples when sampling rate is high.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] xc2028: silence compiler warnings
Antti Palosaari [Sat, 1 Feb 2014 00:55:47 +0000 (21:55 -0300)]
[media] xc2028: silence compiler warnings

There is now new tuner types which are not handled on that switch-case.
Print error if unknown tuner type is meet.

drivers/media/tuners/tuner-xc2028.c: In function ‘generic_set_freq’:
drivers/media/tuners/tuner-xc2028.c:1037:2: warning: enumeration value ‘V4L2_TUNER_ADC’ not handled in switch [-Wswitch]
  switch (new_type) {
  ^
drivers/media/tuners/tuner-xc2028.c:1037:2: warning: enumeration value ‘V4L2_TUNER_RF’ not handled in switch [-Wswitch]

Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: Fix a breakage at controls.xml
Mauro Carvalho Chehab [Wed, 5 Mar 2014 17:18:59 +0000 (14:18 -0300)]
[media] DocBook: Fix a breakage at controls.xml

Some previous patch introduced this bug:

/devel/v4l/patchwork/Documentation/DocBook/controls.xml:2262: parser error : attributes construct error
      <row id=""v4l2-mpeg-video-hor-search-range">
                ^
/devel/v4l/patchwork/Documentation/DocBook/controls.xml:2262: parser error : Couldn't find end of Start Tag row line 2262
      <row id=""v4l2-mpeg-video-hor-search-range">
                ^

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: add Antti at the V4L2 revision list
Mauro Carvalho Chehab [Fri, 7 Feb 2014 14:19:37 +0000 (11:19 -0300)]
[media] DocBook: add Antti at the V4L2 revision list

Add SDR to V3.15 revlist, and add the credits to Antti.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l2-framework.txt: add SDR device type
Antti Palosaari [Fri, 20 Dec 2013 04:52:29 +0000 (01:52 -0300)]
[media] v4l2-framework.txt: add SDR device type

Add SDR device type to v4l2-framework.txt document.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: mark SDR API as Experimental
Antti Palosaari [Tue, 14 Jan 2014 01:03:12 +0000 (22:03 -0300)]
[media] DocBook: mark SDR API as Experimental

Let it be experimental still as all SDR drivers are in staging.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: Software Defined Radio Interface
Antti Palosaari [Fri, 20 Dec 2013 04:50:38 +0000 (01:50 -0300)]
[media] DocBook: Software Defined Radio Interface

Document V4L2 SDR interface.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] DocBook: document 1 Hz flag
Antti Palosaari [Thu, 19 Dec 2013 02:40:49 +0000 (23:40 -0300)]
[media] DocBook: document 1 Hz flag

Update documentation to reflect 1 Hz frequency step flag.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: do not allow modulator ioctls for non-radio devices
Hans Verkuil [Fri, 20 Dec 2013 05:32:21 +0000 (02:32 -0300)]
[media] v4l: do not allow modulator ioctls for non-radio devices

Modulator ioctls could be enabled mistakenly for non-radio devices.
Currently those ioctls are only valid for radio. Fix it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: add device capability flag for SDR receiver
Antti Palosaari [Tue, 17 Dec 2013 20:41:12 +0000 (17:41 -0300)]
[media] v4l: add device capability flag for SDR receiver

VIDIOC_QUERYCAP IOCTL is used to query device capabilities. Add new
capability flag to inform given device supports SDR capture.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: enable some IOCTLs for SDR receiver
Antti Palosaari [Thu, 12 Dec 2013 16:44:14 +0000 (13:44 -0300)]
[media] v4l: enable some IOCTLs for SDR receiver

Enable stream format (FMT) IOCTLs for SDR use. These are used for negotiate
used data stream format.

Reorganise some some IOCTL selection logic.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: define own IOCTL ops for SDR FMT
Antti Palosaari [Sat, 14 Dec 2013 16:10:20 +0000 (13:10 -0300)]
[media] v4l: define own IOCTL ops for SDR FMT

Use own format ops for SDR data:
vidioc_enum_fmt_sdr_cap
vidioc_g_fmt_sdr_cap
vidioc_s_fmt_sdr_cap
vidioc_try_fmt_sdr_cap

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: add stream format for SDR receiver
Antti Palosaari [Thu, 12 Dec 2013 16:34:30 +0000 (13:34 -0300)]
[media] v4l: add stream format for SDR receiver

Add new V4L2 stream format definition, V4L2_BUF_TYPE_SDR_CAPTURE,
for SDR receiver.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: 1 Hz resolution flag for tuners
Antti Palosaari [Wed, 11 Dec 2013 23:27:31 +0000 (20:27 -0300)]
[media] v4l: 1 Hz resolution flag for tuners

Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: add new tuner types for SDR
Antti Palosaari [Wed, 11 Dec 2013 23:24:02 +0000 (20:24 -0300)]
[media] v4l: add new tuner types for SDR

Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage.

ADC is used for setting sampling rate (sampling frequency) to SDR
device.

Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner.
Is is used to down-convert RF frequency to range ADC could sample.
Having RF tuner is optional, whilst in practice it is almost always
there.

Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and
VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device
type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check
tuner type, instead override type with V4L2_TUNER_ADC in every
case (requested by Hans in order to keep functionality in line with
existing tuners and existing API does not specify it).

Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR,
as device cannot do hardware seek without a hardware demodulator.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] v4l: add device type for Software Defined Radio
Antti Palosaari [Wed, 11 Dec 2013 23:03:07 +0000 (20:03 -0300)]
[media] v4l: add device type for Software Defined Radio

Add new V4L device type VFL_TYPE_SDR for Software Defined Radio.
It is registered as /dev/swradio0 (/dev/sdr0 was already reserved).

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] devices.txt: add video4linux device for Software Defined Radio
Antti Palosaari [Wed, 22 Jan 2014 04:07:25 +0000 (01:07 -0300)]
[media] devices.txt: add video4linux device for Software Defined Radio

Add new video4linux device named /dev/swradio for Software Defined
Radio use. V4L device minor numbers are allocated dynamically
nowadays, but there is still configuration option for old fixed style.
Add note to mention that configuration option too.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] em28xx: Add LED support for Kworld UB435-Q v3
Mauro Carvalho Chehab [Tue, 4 Mar 2014 15:34:34 +0000 (12:34 -0300)]
[media] em28xx: Add LED support for Kworld UB435-Q v3

This device has a led at bit 7 of GPIO reg. 0x80 to indicate
when a DVB capture is happening.

Add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] em28xx: add support for DVB monitor led
Mauro Carvalho Chehab [Tue, 4 Mar 2014 15:33:45 +0000 (12:33 -0300)]
[media] em28xx: add support for DVB monitor led

Some devices have a LED to indicate when DVB capture started.
Add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] em28xx: add support for Kworld UB435-Q version 3
Mauro Carvalho Chehab [Mon, 3 Mar 2014 19:28:39 +0000 (16:28 -0300)]
[media] em28xx: add support for Kworld UB435-Q version 3

This device is close to Kworld UB435-Q, but it uses a different
tuner. Add support for it.

Tested with both 8VSB and 256QAM modulations.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] tda18212: add support for ATSC and clearQAM on tda18272
Mauro Carvalho Chehab [Mon, 3 Mar 2014 19:27:38 +0000 (16:27 -0300)]
[media] tda18212: add support for ATSC and clearQAM on tda18272

tda18272 is programmed just like tda18212, but it also
supports ClearQAM and ATSC.

Add support for them. Tested with a Kworld UB435-Q on both
8VSB and 256QAM modes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] Update CARDLIST.cx23885
Mauro Carvalho Chehab [Mon, 3 Mar 2014 16:15:33 +0000 (13:15 -0300)]
[media] Update CARDLIST.cx23885

Some boards got added there. Update the cardlist to reflect the
current status.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] em28xx: update CARDLIST.em28xx
Mauro Carvalho Chehab [Mon, 3 Mar 2014 16:14:45 +0000 (13:14 -0300)]
[media] em28xx: update CARDLIST.em28xx

Some new boards got added. Update the cardlist.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: set it to serial mode by default
Mauro Carvalho Chehab [Mon, 3 Mar 2014 09:13:17 +0000 (06:13 -0300)]
[media] drx-j: set it to serial mode by default

Currently, there's just one device using this frontend: PCTV 80e,
and it works on serial mode.

Change the default here to serial mode. If we add more devices,
then this option should be set via config structure.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Properly initialize mpeg struct before using it
Mauro Carvalho Chehab [Sun, 2 Mar 2014 14:01:11 +0000 (11:01 -0300)]
[media] drx-j: Properly initialize mpeg struct before using it

The cfg_mpeg_output has more fields than what it is initialized
when the code is called. Be sure to initialize everything before
use, in order to avoid random behaviors.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: disable OOB
Mauro Carvalho Chehab [Sun, 2 Mar 2014 12:52:34 +0000 (09:52 -0300)]
[media] drx-j: disable OOB

Just like the windows driver, disable OOB after setting the driver
version.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: fix boot failure due to null pointer dereference
Shuah Khan [Fri, 28 Feb 2014 21:23:02 +0000 (18:23 -0300)]
[media] drx-j: fix boot failure due to null pointer dereference

DJH_DEBUG only code path in drxbsp_i2c_write_read() dereferences
w_dev_addr and subsequently w_dev_addr->user_data->i2c which results
in failure during boot. This patch fixes the null pointer derefence
bug as well as the following compile errors:

  LD      arch/x86/built-in.o
  CC      drivers/media/dvb-frontends/drx39xyj/drxj.o
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxbsp_i2c_write_read’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:25: error: redeclaration of ‘state’ with no linkage
  struct drx39xxj_state *state = w_dev_addr->user_data;
                         ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1512:25: note: previous declaration of ‘state’ was here
  struct drx39xxj_state *state;
                         ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  struct drx39xxj_state *state = w_dev_addr->user_data;
  ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1560:17: error: redeclaration of ‘msg’ with no linkage
  struct i2c_msg msg[2] = {
                 ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1513:17: note: previous declaration of ‘msg’ was here
  struct i2c_msg msg[2];
                 ^

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: remove return that prevents DJH_DEBUG code to run
Shuah Khan [Fri, 28 Feb 2014 21:23:01 +0000 (18:23 -0300)]
[media] drx-j: remove return that prevents DJH_DEBUG code to run

drxbsp_i2c_write_read() has return that prevents DJH_DEBUG code to run.
Remove it.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: fix pr_dbg undefined compile errors when DJH_DEBUG is defined
Shuah Khan [Fri, 28 Feb 2014 21:23:00 +0000 (18:23 -0300)]
[media] drx-j: fix pr_dbg undefined compile errors when DJH_DEBUG is defined

drxj.c fails to compile with the following errors when DJH_DEBUG
is defined.

drivers/media/dvb-frontends/drx39xyj/drxj.c:1567:2: error: implicit declaration of function ‘pr_dbg’ [-Werror=implicit-function-declaration]
  pr_dbg("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
  ^

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: be sure to do a full software reset
Mauro Carvalho Chehab [Thu, 27 Feb 2014 11:48:44 +0000 (08:48 -0300)]
[media] drx-j: be sure to do a full software reset

Mimic what windows driver does here: it writes 0x07 to
SIO_CC_SOFT_RST__A, instead of just 0x03.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: be sure to send the powerup command at device open
Mauro Carvalho Chehab [Thu, 27 Feb 2014 08:35:13 +0000 (05:35 -0300)]
[media] drx-j: be sure to send the powerup command at device open

As drxj_close puts the device in powerdown, we need to power it up
properly at drxj_open.

This is the behavior noticed at the Windows driver.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Use single master mode
Mauro Carvalho Chehab [Thu, 27 Feb 2014 06:34:17 +0000 (03:34 -0300)]
[media] drx-j: Use single master mode

There are no other I2C masters here. Also, the Windows driver uses
this mode (and both drxd and drxk Kernel drivers). So, switch
to it.

That helps to compare the logs between the Linux driver and the
Windows one.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Allow userspace control of LNA
Mauro Carvalho Chehab [Sun, 16 Feb 2014 03:38:44 +0000 (00:38 -0300)]
[media] drx-j: Allow userspace control of LNA

Instead of just disabling the LNA every time, allow to control it from
userspace.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of function wrappers
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:33:18 +0000 (02:33 -0300)]
[media] drx-j: get rid of function wrappers

On several places, the I2C functions are just wrappers to others.

Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of struct drx_dap_fasi_funct_g
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:24:25 +0000 (02:24 -0300)]
[media] drx-j: get rid of struct drx_dap_fasi_funct_g

This struct contains the first abstraction layer for the I2C
access routines. Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of drx_dap_fasi.c
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:14:14 +0000 (02:14 -0300)]
[media] drx-j: get rid of drx_dap_fasi.c

This file contains an abstract layer for the I2C transfer
functions. Get rid of it, merging it at drxj. This will allow
to remove another abstraction layer there, making the code
easier to read, and removing the functions that just return
-EIO.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of function prototypes at drx_dap_fasi.c
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:07:01 +0000 (02:07 -0300)]
[media] drx-j: get rid of function prototypes at drx_dap_fasi.c

Reorder functions and data at drx_dap_fasi.c, in order to avoid
having function prototypes.

This is in preparation to merge this code inside drxj, removing
some duplicated bits there, and getting rid of yet another
abstraction layer.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Get rid of I2C protocol version
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:01:40 +0000 (02:01 -0300)]
[media] drx-j: Get rid of I2C protocol version

This is not used anywere. Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Fix qam/256 mode
Mauro Carvalho Chehab [Sun, 26 Jan 2014 19:41:51 +0000 (16:41 -0300)]
[media] drx-j: Fix qam/256 mode

QAM/256 currently doesn't work, as the code is only called if
channel->mirror is DRX_MIRROR_AUTO, but a prevous if prevents
this condition to happen.

While here, returns -EINVAL to not supported QAM modes and
simplify the code, reducing the number of indents.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: remove some unused data
Mauro Carvalho Chehab [Sun, 26 Jan 2014 19:07:53 +0000 (16:07 -0300)]
[media] drx-j: remove some unused data

Those struct data aren't used anymore. Get rid of them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: use the proper timeout code on scu_command
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:55:57 +0000 (15:55 -0300)]
[media] drx-j: use the proper timeout code on scu_command

Checking if a time is after another one can have issues, as
times are generally u32 wide.

Use the proper macros for that at scu_command().

It should be noticed that other places also use jiffies
calculus on an improper way. This should be fixed too,
but the logic there is more complex. So, let's do it in
separate patches.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: call ctrl_set_standard even if a standard is powered
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:39:06 +0000 (15:39 -0300)]
[media] drx-j: call ctrl_set_standard even if a standard is powered

Modulation and other parameters might have changed. So, better
to call ctrl_set_standard() even if the device is already
powered.

That helps to put the device into a sane state, if something
got wrong on a previous set_frontend call.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: avoid calling power_down_foo twice
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:30:53 +0000 (15:30 -0300)]
[media] drx-j: avoid calling power_down_foo twice

When switching from one video standard to another one,
power_down_vsb is called twice. Well, as the device is already
in power_down mode, the second call always fail. This causes that
any subsequent frontend set to fail as well:

[145074.501243] drx39xyj:power_down_vsb: called
[145089.195396] drx39xyj:power_down_vsb: error -5
[145089.195404] drx39xyj:ctrl_set_standard: error -5
[145089.195417] drx39xyj:drx39xxj_set_frontend: Failed to set standard! result=fffffffb
[145089.195470] drx39xyj:ctrl_sig_quality: error -5
[145089.195473] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195475] drx39xyj:ctrl_sig_quality: error -5
[145089.195477] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195479] drx39xyj:ctrl_sig_quality: error -5
[145089.195480] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195482] drx39xyj:ctrl_sig_quality: error -5
[145089.195484] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145089.195498] drx39xyj:ctrl_sig_quality: error -5
[145089.195500] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195502] drx39xyj:ctrl_sig_quality: error -5
[145089.195503] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195505] drx39xyj:ctrl_sig_quality: error -5
[145089.195506] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195508] drx39xyj:ctrl_sig_quality: error -5
[145089.195510] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196291] drx39xyj:drx39xxj_read_status: drx39xxj: could not get lock status!
[145090.196508] drx39xyj:ctrl_sig_quality: error -5
[145090.196511] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196514] drx39xyj:ctrl_sig_quality: error -5
[145090.196515] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196518] drx39xyj:ctrl_sig_quality: error -5
[145090.196519] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196522] drx39xyj:ctrl_sig_quality: error -5
[145090.196523] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196553] drx39xyj:ctrl_sig_quality: error -5
[145090.196554] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196557] drx39xyj:ctrl_sig_quality: error -5
[145090.196558] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196560] drx39xyj:ctrl_sig_quality: error -5
[145090.196562] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196564] drx39xyj:ctrl_sig_quality: error -5
[145090.196565] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145091.119265] drx39xyj:ctrl_sig_quality: error -5
[145091.119271] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145091.119274] drx39xyj:ctrl_sig_quality: error -5
[145091.119276] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145091.119278] drx39xyj:ctrl_sig_quality: error -5
[145091.119280] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145091.119282] drx39xyj:ctrl_sig_quality: error -5
[145091.119283] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: be sure to use tuner's IF
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:02:25 +0000 (15:02 -0300)]
[media] drx-j: be sure to use tuner's IF

Instead of just hardcoding an IF value of 5MHz, use the one
provided by the tuner, with can be different for QAM and
VSB.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of tuner dummy get/set frequency
Mauro Carvalho Chehab [Sun, 26 Jan 2014 17:54:08 +0000 (14:54 -0300)]
[media] drx-j: get rid of tuner dummy get/set frequency

Those functions will never be used with Linux DVB binding.

Get rid of them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: remove some ugly bindings from drx39xxj_dummy.c
Mauro Carvalho Chehab [Sun, 26 Jan 2014 17:23:24 +0000 (14:23 -0300)]
[media] drx-j: remove some ugly bindings from drx39xxj_dummy.c

This file does an ugly binding between drxj and DVB frontend.

Remove most of the functions there. We still need to get rid of
get_frequency and set_frequency, but such patch is a little more
complex, as it should also remove some previous tuner bindings.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: comment or remove unused code
Mauro Carvalho Chehab [Fri, 24 Jan 2014 16:16:16 +0000 (13:16 -0300)]
[media] drx-j: comment or remove unused code

In order to avoid warnings and to remove dead code, remove
the functions that don't make sense to happen, while commenting
the others that might still be useful some day.

That reduced a lot the text size:

Before:

   text    data     bss     dec     hex filename
  58419    2916       4   61339    ef9b drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko

After:
   text    data     bss     dec     hex filename
  78331    2916       4   81251   13d63 drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko

Without any functional changes.

It could be make sense latter to remove those drivers or to
move them into an analog-specific part of the driver.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of drxj_ctrl()
Mauro Carvalho Chehab [Fri, 24 Jan 2014 16:00:08 +0000 (13:00 -0300)]
[media] drx-j: get rid of drxj_ctrl()

With this change, we finally got rid of all abstraction
layers on this driver.

This patch also fixes the LNA GPIO settings, as the original
code were using a wrong control name for it.

This patch exposes the several functions that aren't used.
Some of them are related to analog demod that might be
used some day, but others will likely never be needed, as
they don't fit on Linux media APIs.

Latter patches will clean up this mess.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: move drx39xxj into drxj.c
Mauro Carvalho Chehab [Fri, 24 Jan 2014 15:25:04 +0000 (12:25 -0300)]
[media] drx-j: move drx39xxj into drxj.c

While drxj is already too big, moving the code there will
make easier to get rid of the drxj_ctrl function.

It will also help to detect and remove the unused functions,
helping to remove lots of dead code there.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of the remaining drx generic functions
Mauro Carvalho Chehab [Fri, 24 Jan 2014 15:21:17 +0000 (12:21 -0300)]
[media] drx-j: get rid of the remaining drx generic functions

Get rid of drx_open and drx_close, as those are just wrapper
functions to drxj_open/drxj_close.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of drx_ctrl
Mauro Carvalho Chehab [Fri, 24 Jan 2014 14:14:17 +0000 (11:14 -0300)]
[media] drx-j: get rid of drx_ctrl

This function is used only as an abstraction layer to call the
two firmware functions. Remove it.

As a bonus, the drx_ctrl_function is now unused and can be
removed.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Remove duplicated firmware upload code
Mauro Carvalho Chehab [Fri, 24 Jan 2014 10:49:29 +0000 (07:49 -0300)]
[media] drx-j: Remove duplicated firmware upload code

Remove the duplicated firmware upload code that was commented
inside drxj.c.

This code is not used, and will not work anyway, as it doesn't
download the firmware from userspace.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: Avoid any regressions by preserving old behavior
Mauro Carvalho Chehab [Fri, 24 Jan 2014 09:31:03 +0000 (06:31 -0300)]
[media] drx-j: Avoid any regressions by preserving old behavior

The version is initialized with zero at drx_driver.c. Keep it,
in order to avoid the risk of causing any regression.

While here, remove the drx_driver.h from drxj, as this is not
required there.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years ago[media] drx-j: get rid of drx_driver.c
Mauro Carvalho Chehab [Fri, 24 Jan 2014 09:25:07 +0000 (06:25 -0300)]
[media] drx-j: get rid of drx_driver.c

This file contains just the firmware load code, that it is also
somewhat duplicated at drxj.c.

Move the code into there. Latter patches will remove the
duplicated code.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>