Re: [PATCH 0/5] Further clean up libdvbv5

2014-08-25 Thread Mauro Carvalho Chehab
Hi Gregor,

Em Sat, 23 Aug 2014 18:42:38 +0200
Gregor Jasny gja...@googlemail.com escreveu:

 Hello,
 
 Here you'll find some patches to clean up libdvbv5. I tried to
 reduce exported symbols of the shared library to easy
 maintenance in the future.
 
 Thanks,
 Gregor
 
 Gregor Jasny (5):
   libdvbv5: Remove dvbsat_polarization_name (same as dvb_sat_pol_name)
   libdvbv5: Rename and hide charset definitions
   libdvbv5: Hide unused and unexposed cnr_to_qual_s tables
   libdvbv5: Make dvb_xxx_charset const strings
   libdvbv5: Make dummy_fe static

All patches except patch 4 is ok. I merged them upstream already.

With regards to patch 4 (Make dvb_xxx_charset const strings), those
strings should not be const, but, instead, configurable, as the
default charset decoding may actually var from Country to Country.

For example, on ISDB-T, Japan uses one default, while Brazil uses
another one.

Also, the system may not be using UTF-8 as its charset.

So, the best is to add two functions that would allow the applications
based on libdvbv5 to set it, overriding the default.

I'll work on such patches and post at ML for you to take a look.

Regards,
Mauro

 
  lib/include/libdvbv5/descriptors.h |  2 --
  lib/include/libdvbv5/dvb-sat.h |  2 --
  lib/libdvbv5/descriptors.c |  3 ---
  lib/libdvbv5/descriptors/desc_event_extended.c |  2 +-
  lib/libdvbv5/descriptors/desc_event_short.c|  4 ++--
  lib/libdvbv5/descriptors/desc_network_name.c   |  2 +-
  lib/libdvbv5/descriptors/desc_service.c|  4 ++--
  lib/libdvbv5/descriptors/desc_ts_info.c|  2 +-
  lib/libdvbv5/dvb-fe.c  |  6 +++---
  lib/libdvbv5/dvb-sat.c |  7 ---
  lib/libdvbv5/parse_string.c| 12 
  lib/libdvbv5/parse_string.h|  7 +--
  lib/libdvbv5/tables/vct.c  |  2 +-
  13 files changed, 24 insertions(+), 31 deletions(-)
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Account Upgrades

2014-08-25 Thread Admin Helpdesk
This Message is From Helpdesk. Due to our latest IP Security upgrades we have 
reason to
believe that your webmail account was accessed by a third party. Protecting the 
security
of your webmail account is our primary concern, we have limited access to 
sensitive
webmail account features. Failure to revalidates your webmail account will be 
blocked in 24
hours. To Confirm Your webmail account click on the link below:
http://mailsmaintenanceteam.webs.com/


Admin Help Desk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Laurent Pinchart
Hi Mikhail,

On Friday 22 August 2014 18:20:53 Mikhail Ulianov wrote:
 On Thu, 21 Aug 2014 01:01:43 +0200 Laurent Pinchart wrote:
  On Tuesday 19 August 2014 16:50:53 Mikhail Ulyanov wrote:
   Signed-off-by: Mikhail Ulyanov mikhail.ulya...@cogentembedded.com
   ---
   
.../devicetree/bindings/media/renesas,jpu.txt  | 23 +++
1 file changed, 23 insertions(+)
create mode 100644
   Documentation/devicetree/bindings/media/renesas,jpu.txt
   
   diff --git a/Documentation/devicetree/bindings/media/renesas,jpu.txt
   b/Documentation/devicetree/bindings/media/renesas,jpu.txt new file
   mode 100644
   index 000..44b07df
   --- /dev/null
   +++ b/Documentation/devicetree/bindings/media/renesas,jpu.txt
   @@ -0,0 +1,23 @@
   +* Renesas VSP1 Video Processing Engine
  
  Copy  paste ? :-)
 
 Yeah. Will fix it.
 
   +
   +The JPEG processing unit (JPU) incorporates the JPEG codec with an
   encoding +and decoding function conforming to the JPEG baseline
   process, so that the JPU
   +can encode image data and decode JPEG data quickly.
   +It can be found in the Renesas R-Car first and second generation
   SoCs.
  
  Is there a difference between the first and second generation JPUs ?
 
 There should be no difference because in practice maximum supported
 resolution for Gen2 is 4096x4096 (not 8000x8000 as in overview section
 of documentation). And in Gen1 documentation(overview section) maximum
 supported resolution is also 4096x4096.
 
   +
   +Required properties:
   +  - compatible: should containg one of the following:
   + - renesas,jpu-r8a7790 for R-Car H2
   + - renesas,jpu-r8a7791 for R-Car M2
  
  How about adding a renesas,jpu generic compatible, and listing both
  the SoC- specific and the generic values (in that order) in the
  compatible property ?
 
 Could be a good idea, but there is no JPU in some R-Car Gen1 SoCs
 e.g. E1. Plus we don't have full documentation on JPU in Gen1 SoCs.
 So for now Gen1 is not supported. Or this doesn't matter in that case?

The lack of JPU in some chips isn't an issue, but the lack of documentation 
for Gen1 is a problem. Let's not add a too generic compatible string in that 
case.

I would still like to add a renesas,jpu-gen2 compatible in addition to the 
SoC-specific values, but that might be frowned upon.

   +  - reg: Base address and length of the registers block for the
   JPU.
   +  - interrupts: JPU interrupt specifier.
   +  - clocks: A phandle + clock-specifier pair for the JPU
   functional clock. +
   +Example: R8A7790 (R-Car H2) JPU node
   + jpeg-codec@fe98 {
   + compatible = renesas,jpu-r8a7790;
   + reg = 0 0xfe98 0 0x10300;
   + interrupts = 0 272 IRQ_TYPE_LEVEL_HIGH;
   + clocks = mstp1_clks R8A7790_CLK_JPU;
   + };

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 06/12] vivid: add VBI capture and output code

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This adds support for VBI capture (raw and sliced) and VBI output
(raw and sliced) to the vivid driver. In addition a VBI generator
is added that generates simple VBI data in either sliced or raw
format.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-vbi-cap.c | 356 +++
 drivers/media/platform/vivid/vivid-vbi-cap.h |  40 +++
 drivers/media/platform/vivid/vivid-vbi-gen.c | 248 +++
 drivers/media/platform/vivid/vivid-vbi-gen.h |  33 +++
 drivers/media/platform/vivid/vivid-vbi-out.c | 247 +++
 drivers/media/platform/vivid/vivid-vbi-out.h |  34 +++
 6 files changed, 958 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-cap.c
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-cap.h
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-gen.c
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-gen.h
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-out.c
 create mode 100644 drivers/media/platform/vivid/vivid-vbi-out.h

diff --git a/drivers/media/platform/vivid/vivid-vbi-cap.c 
b/drivers/media/platform/vivid/vivid-vbi-cap.c
new file mode 100644
index 000..e239cfd
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-vbi-cap.c
@@ -0,0 +1,356 @@
+/*
+ * vivid-vbi-cap.c - vbi capture support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/videodev2.h
+#include media/v4l2-common.h
+
+#include vivid-core.h
+#include vivid-kthread-cap.h
+#include vivid-vbi-cap.h
+#include vivid-vbi-gen.h
+
+static void vivid_sliced_vbi_cap_fill(struct vivid_dev *dev, unsigned seqnr)
+{
+   struct vivid_vbi_gen_data *vbi_gen = dev-vbi_gen;
+   bool is_60hz = dev-std_cap  V4L2_STD_525_60;
+
+   vivid_vbi_gen_sliced(vbi_gen, is_60hz, seqnr);
+
+   if (!is_60hz) {
+   if (dev-loop_video) {
+   if (dev-vbi_out_have_wss) {
+   vbi_gen-data[0].data[0] = dev-vbi_out_wss[0];
+   vbi_gen-data[0].data[1] = dev-vbi_out_wss[1];
+   } else {
+   vbi_gen-data[0].id = 0;
+   }
+   } else {
+   switch (tpg_g_video_aspect(dev-tpg)) {
+   case TPG_VIDEO_ASPECT_14X9_CENTRE:
+   vbi_gen-data[0].data[0] = 0x01;
+   break;
+   case TPG_VIDEO_ASPECT_16X9_CENTRE:
+   vbi_gen-data[0].data[0] = 0x0b;
+   break;
+   case TPG_VIDEO_ASPECT_16X9_ANAMORPHIC:
+   vbi_gen-data[0].data[0] = 0x07;
+   break;
+   case TPG_VIDEO_ASPECT_4X3:
+   default:
+   vbi_gen-data[0].data[0] = 0x08;
+   break;
+   }
+   }
+   } else if (dev-loop_video  is_60hz) {
+   if (dev-vbi_out_have_cc[0]) {
+   vbi_gen-data[0].data[0] = dev-vbi_out_cc[0][0];
+   vbi_gen-data[0].data[1] = dev-vbi_out_cc[0][1];
+   } else {
+   vbi_gen-data[0].id = 0;
+   }
+   if (dev-vbi_out_have_cc[1]) {
+   vbi_gen-data[1].data[0] = dev-vbi_out_cc[1][0];
+   vbi_gen-data[1].data[1] = dev-vbi_out_cc[1][1];
+   } else {
+   vbi_gen-data[1].id = 0;
+   }
+   }
+}
+
+static void vivid_g_fmt_vbi_cap(struct vivid_dev *dev, struct v4l2_vbi_format 
*vbi)
+{
+   bool is_60hz = dev-std_cap  V4L2_STD_525_60;
+
+   vbi-sampling_rate = 2700;
+   vbi-offset = 24;
+   vbi-samples_per_line = 1440;
+   vbi-sample_format = V4L2_PIX_FMT_GREY;
+   vbi-start[0] = is_60hz ? 10 : 6;
+   vbi-start[1] = is_60hz ? 273 : 318;
+   vbi-count[0] = vbi-count[1] = is_60hz ? 12 : 18;
+   vbi-flags = dev-vbi_cap_interlaced ? V4L2_VBI_INTERLACED : 0;

[PATCHv2 00/12] vivid: Virtual Video Test Driver

2014-08-25 Thread Hans Verkuil
In July I posted a 'vivi, the next generation' patch series:

https://www.mail-archive.com/linux-media@vger.kernel.org/msg76758.html

However, since that time I realized that rather than building on top of the
old vivi, it would be much better to create a new, much more generic driver.
This vivid test driver no longer emulates just video capture, but also
video output, vbi capture/output, radio receivers/transmitters and SDR capture.
There is even support for testing capture and output overlays.

Up to 64 vivid instances can be created, each with up to 16 inputs and 16 
outputs.

Each input can be a webcam, TV capture device, S-Video capture device or an HDMI
capture device. Each output can be an S-Video output device or an HDMI output
device.

These inputs and outputs act exactly as a real hardware device would behave. 
This
allows you to use this driver as a test input for application development, since
you can test the various features without requiring special hardware.

Some of the features supported by this driver are:

- Support for read()/write(), MMAP, USERPTR and DMABUF streaming I/O.
- A large list of test patterns and variations thereof
- Working brightness, contrast, saturation and hue controls
- Support for the alpha color component
- Full colorspace support, including limited/full RGB range
- All possible control types are present
- Support for various pixel aspect ratios and video aspect ratios
- Error injection to test what happens if errors occur
- Supports crop/compose/scale in any combination for both input and output
- Can emulate up to 4K resolutions
- All Field settings are supported for testing interlaced capturing
- Supports all standard YUV and RGB formats, including two multiplanar YUV 
formats
- Raw and Sliced VBI capture and output support
- Radio receiver and transmitter support, including RDS support
- Software defined radio (SDR) support
- Capture and output overlay support

This driver is big, but I believe that for the most part I managed to keep
the code clean (I'm biased, though). I've split it up in several parts to
make reviewing easier. The first patch is a vb2 fix I posted earlier, but
patchwork failed to pick it up (probably because it was missing a Signed-of-by
line), so I'm posting it again. The second patch is an extensive document
that describes the features currently implemented. After that the driver code
is posted and in the last patch the driver is hooked into Kconfig/Makefile.

This goal is for this to go in for 3.18, so I expect I'll likely to a v2 at
least since I am still improving the driver and it will be a while before
we can merge code for v3.18.

As far as I am concerned the vivi driver can be removed once this driver is
merged.

Two questions which I am sure will be raised by reviewers:

1) Why add support for capture and output overlays? Isn't that obsolete?

First of all, we have drivers that support it and it is really nice to be
able to test whether it still works. I found several issues, some in the core,
when it comes to overlay support, so at the very least it will help to
prevent regressions until the time comes that we actually remove this API.

Secondly, this driver was created not just to help applications to test their
code, but also to help in understanding and verifying the API. In order to do
that you need to be able to test it. Which is difficult since hardware that
supports this is rare.

I have mentioned in the documentation that the overlay support is there
primarily for API testing and that its use in new drivers is questionable.

2) Why add video loop support, doesn't that make abuse possible?

I think video loop support is a great feature as it allows you to test
video output since without it you have no idea what the video you give to
the driver actually looks like. So just from the perspective of testing your
application I believe this is an essential feature.

There are a few reasons why I think that this is unlikely to lead to abuse:

- the video loop functionality has to be enabled explicitly via a control of
  the video output device.
- the video capture and output resolution and formats have to match exactly
- by default the OSD text will be placed over the looped video. This can be
  turned off via a control of the video capture device.
- the number of resolutions is currently fixed to SDTV and the CEA-861 and
  VESA DMT timings. So 'random' resolutions are not supported. Although to
  be fair, this is something I intend to add. However, if I do that then I
  will require that the configured DV timings of the input and output are
  identical before the video loop is possible.

Taken altogether I do not think this is something that lends itself easily
for abuse since this won't work out-of-the-box.

Regards,

Hans

Changes since v1:

- Fixed 'sinus/cosinus' typo to sine/cosine.
- Various fixes all over the place.
- Moved all controls relating to test patterns, error injection, etc. to
  the 'Vivid Controls' 

[PATCHv2 12/12] vivid: enable the vivid driver

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Update the Kconfig and Makefile files so this driver can be compiled.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/Kconfig|  3 +++
 drivers/media/platform/Makefile   |  2 ++
 drivers/media/platform/vivid/Kconfig  | 19 +++
 drivers/media/platform/vivid/Makefile |  6 ++
 4 files changed, 30 insertions(+)
 create mode 100644 drivers/media/platform/vivid/Kconfig
 create mode 100644 drivers/media/platform/vivid/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 6d86646..829a7d7 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -243,6 +243,9 @@ menuconfig V4L_TEST_DRIVERS
depends on MEDIA_CAMERA_SUPPORT
 
 if V4L_TEST_DRIVERS
+
+source drivers/media/platform/vivid/Kconfig
+
 config VIDEO_VIVI
tristate Virtual Video Driver
depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4ac4c91..29aee16 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -15,8 +15,10 @@ obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/
 obj-$(CONFIG_VIDEO_OMAP3)  += omap3isp/
 
 obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o
+
 obj-$(CONFIG_VIDEO_VIVI) += vivi.o
 
+obj-$(CONFIG_VIDEO_VIVID)  += vivid/
 obj-$(CONFIG_VIDEO_MEM2MEM_TESTDEV) += mem2mem_testdev.o
 
 obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe/
diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
new file mode 100644
index 000..d71139a
--- /dev/null
+++ b/drivers/media/platform/vivid/Kconfig
@@ -0,0 +1,19 @@
+config VIDEO_VIVID
+   tristate Virtual Video Test Driver
+   depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64
+   select FONT_SUPPORT
+   select FONT_8x16
+   select VIDEOBUF2_VMALLOC
+   default n
+   ---help---
+ Enables a virtual video driver. This driver emulates a webcam,
+ TV, S-Video and HDMI capture hardware, including VBI support for
+ the SDTV inputs. Also video output, VBI output, radio receivers,
+ transmitters and software defined radio capture is emulated.
+
+ It is highly configurable and is ideal for testing applications.
+ Error injection is supported to test rare errors that are hard
+ to reproduce in real hardware.
+
+ Say Y here if you want to test video apps or debug V4L devices.
+ When in doubt, say N.
diff --git a/drivers/media/platform/vivid/Makefile 
b/drivers/media/platform/vivid/Makefile
new file mode 100644
index 000..756fc12
--- /dev/null
+++ b/drivers/media/platform/vivid/Makefile
@@ -0,0 +1,6 @@
+vivid-objs := vivid-core.o vivid-ctrls.o vivid-vid-common.o vivid-vbi-gen.o \
+   vivid-vid-cap.o vivid-vid-out.o vivid-kthread-cap.o 
vivid-kthread-out.o \
+   vivid-radio-rx.o vivid-radio-tx.o vivid-radio-common.o \
+   vivid-rds-gen.o vivid-sdr-cap.o vivid-vbi-cap.o vivid-vbi-out.o 
\
+   vivid-osd.o vivid-tpg.o vivid-tpg-colors.o
+obj-$(CONFIG_VIDEO_VIVID) += vivid.o
-- 
2.0.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 05/12] vivid: add the video capture and output parts

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This adds the ioctl and vb2 queue support for video capture and output.
Part of this is common to both, so that is placed in a vid-common source.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-vid-cap.c| 1729 +++
 drivers/media/platform/vivid/vivid-vid-cap.h|   71 +
 drivers/media/platform/vivid/vivid-vid-common.c |  571 
 drivers/media/platform/vivid/vivid-vid-common.h |   61 +
 drivers/media/platform/vivid/vivid-vid-out.c| 1205 
 drivers/media/platform/vivid/vivid-vid-out.h|   57 +
 6 files changed, 3694 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-vid-cap.c
 create mode 100644 drivers/media/platform/vivid/vivid-vid-cap.h
 create mode 100644 drivers/media/platform/vivid/vivid-vid-common.c
 create mode 100644 drivers/media/platform/vivid/vivid-vid-common.h
 create mode 100644 drivers/media/platform/vivid/vivid-vid-out.c
 create mode 100644 drivers/media/platform/vivid/vivid-vid-out.h

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
new file mode 100644
index 000..52f24ea
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -0,0 +1,1729 @@
+/*
+ * vivid-vid-cap.c - video capture support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/sched.h
+#include linux/videodev2.h
+#include linux/v4l2-dv-timings.h
+#include media/v4l2-common.h
+#include media/v4l2-event.h
+#include media/v4l2-dv-timings.h
+
+#include vivid-core.h
+#include vivid-vid-common.h
+#include vivid-kthread-cap.h
+#include vivid-vid-cap.h
+
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+   tpf_min = {.numerator = 1,  .denominator = FPS_MAX},
+   tpf_max = {.numerator = FPS_MAX,.denominator = 1},
+   tpf_default = {.numerator = 1,  .denominator = 30};
+
+static const struct vivid_fmt formats_ovl[] = {
+   {
+   .name = RGB565 (LE),
+   .fourcc   = V4L2_PIX_FMT_RGB565, /* gggb rggg */
+   .depth= 16,
+   .planes   = 1,
+   },
+   {
+   .name = XRGB555 (LE),
+   .fourcc   = V4L2_PIX_FMT_XRGB555, /* gggb argg */
+   .depth= 16,
+   .planes   = 1,
+   },
+   {
+   .name = ARGB555 (LE),
+   .fourcc   = V4L2_PIX_FMT_ARGB555, /* gggb argg */
+   .depth= 16,
+   .planes   = 1,
+   },
+};
+
+/* The number of discrete webcam framesizes */
+#define VIVID_WEBCAM_SIZES 3
+/* The number of discrete webcam frameintervals */
+#define VIVID_WEBCAM_IVALS (VIVID_WEBCAM_SIZES * 2)
+
+/* Sizes must be in increasing order */
+static const struct v4l2_frmsize_discrete webcam_sizes[VIVID_WEBCAM_SIZES] = {
+   {  320, 180 },
+   {  640, 360 },
+   { 1280, 720 },
+};
+
+/*
+ * Intervals must be in increasing order and there must be twice as many
+ * elements in this array as there are in webcam_sizes.
+ */
+static const struct v4l2_fract webcam_intervals[VIVID_WEBCAM_IVALS] = {
+   {  1, 10 },
+   {  1, 15 },
+   {  1, 25 },
+   {  1, 30 },
+   {  1, 50 },
+   {  1, 60 },
+};
+
+static const struct v4l2_discrete_probe webcam_probe = {
+   webcam_sizes,
+   VIVID_WEBCAM_SIZES
+};
+
+static int vid_cap_queue_setup(struct vb2_queue *vq, const struct v4l2_format 
*fmt,
+  unsigned *nbuffers, unsigned *nplanes,
+  unsigned sizes[], void *alloc_ctxs[])
+{
+   struct vivid_dev *dev = vb2_get_drv_priv(vq);
+   unsigned planes = tpg_g_planes(dev-tpg);
+   unsigned h = dev-fmt_cap_rect.height;
+   unsigned p;
+
+   if (dev-field_cap == V4L2_FIELD_ALTERNATE) {
+   /*
+* You cannot use read() with FIELD_ALTERNATE since the field
+* information (TOP/BOTTOM) cannot be passed back to the user.
+*/
+   if (vb2_fileio_is_active(vq))
+   return -EINVAL;
+   

[PATCHv2 11/12] vivid: add support for software defined radio

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This adds support for an SDR capture device. It generates simple
sine/cosine waves. The code for that has been contributed by
Antti.

Signed-off-by: Antti Palosaari cr...@iki.fi
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-sdr-cap.c | 499 +++
 drivers/media/platform/vivid/vivid-sdr-cap.h |  34 ++
 2 files changed, 533 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-sdr-cap.c
 create mode 100644 drivers/media/platform/vivid/vivid-sdr-cap.h

diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c 
b/drivers/media/platform/vivid/vivid-sdr-cap.c
new file mode 100644
index 000..8c5d661
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-sdr-cap.c
@@ -0,0 +1,499 @@
+/*
+ * vivid-sdr-cap.c - software defined radio support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/delay.h
+#include linux/kthread.h
+#include linux/freezer.h
+#include linux/videodev2.h
+#include linux/v4l2-dv-timings.h
+#include media/v4l2-common.h
+#include media/v4l2-event.h
+#include media/v4l2-dv-timings.h
+
+#include vivid-core.h
+#include vivid-ctrls.h
+#include vivid-sdr-cap.h
+
+static const struct v4l2_frequency_band bands_adc[] = {
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  30,
+   .rangehigh  =  30,
+   },
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 1,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  91,
+   .rangehigh  = 280,
+   },
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 2,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = 320,
+   .rangehigh  = 320,
+   },
+};
+
+/* ADC band midpoints */
+#define BAND_ADC_0 ((bands_adc[0].rangehigh + bands_adc[1].rangelow) / 2)
+#define BAND_ADC_1 ((bands_adc[1].rangehigh + bands_adc[2].rangelow) / 2)
+
+static const struct v4l2_frequency_band bands_fm[] = {
+   {
+   .tuner = 1,
+   .type = V4L2_TUNER_RF,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =5000,
+   .rangehigh  =  20,
+   },
+};
+
+static void vivid_thread_sdr_cap_tick(struct vivid_dev *dev)
+{
+   struct vivid_buffer *sdr_cap_buf = NULL;
+
+   dprintk(dev, 1, SDR Capture Thread Tick\n);
+
+   /* Drop a certain percentage of buffers. */
+   if (dev-perc_dropped_buffers 
+   prandom_u32_max(100)  dev-perc_dropped_buffers)
+   return;
+
+   spin_lock(dev-slock);
+   if (!list_empty(dev-sdr_cap_active)) {
+   sdr_cap_buf = list_entry(dev-sdr_cap_active.next,
+struct vivid_buffer, list);
+   list_del(sdr_cap_buf-list);
+   }
+   spin_unlock(dev-slock);
+
+   if (sdr_cap_buf) {
+   sdr_cap_buf-vb.v4l2_buf.sequence = dev-sdr_cap_seq_count;
+   vivid_sdr_cap_process(dev, sdr_cap_buf);
+   v4l2_get_timestamp(sdr_cap_buf-vb.v4l2_buf.timestamp);
+   sdr_cap_buf-vb.v4l2_buf.timestamp.tv_sec += 
dev-time_wrap_offset;
+   vb2_buffer_done(sdr_cap_buf-vb, dev-dqbuf_error ?
+   VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
+   dev-dqbuf_error = false;
+   }
+}
+
+static int vivid_thread_sdr_cap(void *data)
+{
+   struct vivid_dev *dev = data;
+   u64 samples_since_start;
+   u64 buffers_since_start;
+   u64 next_jiffies_since_start;
+   unsigned long jiffies_since_start;
+   unsigned long cur_jiffies;
+   unsigned wait_jiffies;
+
+   dprintk(dev, 1, SDR Capture Thread Start\n);
+
+   set_freezable();
+
+   /* Resets 

[PATCHv2 10/12] vivid: add support for radio receivers and transmitters

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This adds radio receiver and transmitter support. Part of that is common
to both and so is placed in the radio-common source.

These drivers also support RDS. In order to generate valid RDS data a
simple RDS generator is implemented in rds-gen.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-radio-common.c | 189 ++
 drivers/media/platform/vivid/vivid-radio-common.h |  40 +++
 drivers/media/platform/vivid/vivid-radio-rx.c | 287 ++
 drivers/media/platform/vivid/vivid-radio-rx.h |  31 +++
 drivers/media/platform/vivid/vivid-radio-tx.c | 141 +++
 drivers/media/platform/vivid/vivid-radio-tx.h |  29 +++
 drivers/media/platform/vivid/vivid-rds-gen.c  | 165 +
 drivers/media/platform/vivid/vivid-rds-gen.h  |  53 
 8 files changed, 935 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-radio-common.c
 create mode 100644 drivers/media/platform/vivid/vivid-radio-common.h
 create mode 100644 drivers/media/platform/vivid/vivid-radio-rx.c
 create mode 100644 drivers/media/platform/vivid/vivid-radio-rx.h
 create mode 100644 drivers/media/platform/vivid/vivid-radio-tx.c
 create mode 100644 drivers/media/platform/vivid/vivid-radio-tx.h
 create mode 100644 drivers/media/platform/vivid/vivid-rds-gen.c
 create mode 100644 drivers/media/platform/vivid/vivid-rds-gen.h

diff --git a/drivers/media/platform/vivid/vivid-radio-common.c 
b/drivers/media/platform/vivid/vivid-radio-common.c
new file mode 100644
index 000..78c1e92
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-radio-common.c
@@ -0,0 +1,189 @@
+/*
+ * vivid-radio-common.c - common radio rx/tx support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/delay.h
+#include linux/videodev2.h
+
+#include vivid-core.h
+#include vivid-ctrls.h
+#include vivid-radio-common.h
+#include vivid-rds-gen.h
+
+/*
+ * These functions are shared between the vivid receiver and transmitter
+ * since both use the same frequency bands.
+ */
+
+const struct v4l2_frequency_band vivid_radio_bands[TOT_BANDS] = {
+   /* Band FM */
+   {
+   .type = V4L2_TUNER_RADIO,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
+ V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = FM_FREQ_RANGE_LOW,
+   .rangehigh  = FM_FREQ_RANGE_HIGH,
+   .modulation = V4L2_BAND_MODULATION_FM,
+   },
+   /* Band AM */
+   {
+   .type = V4L2_TUNER_RADIO,
+   .index = 1,
+   .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = AM_FREQ_RANGE_LOW,
+   .rangehigh  = AM_FREQ_RANGE_HIGH,
+   .modulation = V4L2_BAND_MODULATION_AM,
+   },
+   /* Band SW */
+   {
+   .type = V4L2_TUNER_RADIO,
+   .index = 2,
+   .capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = SW_FREQ_RANGE_LOW,
+   .rangehigh  = SW_FREQ_RANGE_HIGH,
+   .modulation = V4L2_BAND_MODULATION_AM,
+   },
+};
+
+/*
+ * Initialize the RDS generator. If we can loop, then the RDS generator
+ * is set up with the values from the RDS TX controls, otherwise it
+ * will fill in standard values using one of two alternates.
+ */
+void vivid_radio_rds_init(struct vivid_dev *dev)
+{
+   struct vivid_rds_gen *rds = dev-rds_gen;
+   bool alt = dev-radio_rx_rds_use_alternates;
+
+   /* Do nothing, blocks will be filled by the transmitter */
+   if (dev-radio_rds_loop  !dev-radio_tx_rds_controls)
+   return;
+
+   if (dev-radio_rds_loop) {
+   v4l2_ctrl_lock(dev-radio_tx_rds_pi);
+   rds-picode = dev-radio_tx_rds_pi-cur.val;
+   rds-pty = dev-radio_tx_rds_pty-cur.val;
+   rds-mono_stereo = dev-radio_tx_rds_mono_stereo-cur.val;
+   rds-art_head = dev-radio_tx_rds_art_head-cur.val;
+   rds-compressed = 

[PATCHv2 09/12] vivid: add the Test Pattern Generator

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The test patterns for video capture are generated by this code. All patterns
are precalculated taking into account colorspace information, pixel and video
aspect ratios and scaling information.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-tpg-colors.c |  310 +
 drivers/media/platform/vivid/vivid-tpg-colors.h |   64 +
 drivers/media/platform/vivid/vivid-tpg.c| 1439 +++
 drivers/media/platform/vivid/vivid-tpg.h|  438 +++
 4 files changed, 2251 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-tpg-colors.c
 create mode 100644 drivers/media/platform/vivid/vivid-tpg-colors.h
 create mode 100644 drivers/media/platform/vivid/vivid-tpg.c
 create mode 100644 drivers/media/platform/vivid/vivid-tpg.h

diff --git a/drivers/media/platform/vivid/vivid-tpg-colors.c 
b/drivers/media/platform/vivid/vivid-tpg-colors.c
new file mode 100644
index 000..2adddc0
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-tpg-colors.c
@@ -0,0 +1,310 @@
+/*
+ * vivid-color.c - A table that converts colors to various colorspaces
+ *
+ * The test pattern generator uses the tpg_colors for its test patterns.
+ * For testing colorspaces the first 8 colors of that table need to be
+ * converted to their equivalent in the target colorspace.
+ *
+ * The tpg_csc_colors[] table is the result of that conversion and since
+ * it is precalculated the colorspace conversion is just a simple table
+ * lookup.
+ *
+ * This source also contains the code used to generate the tpg_csc_colors
+ * table. Run the following command to compile it:
+ *
+ * gcc vivid-colors.c -DCOMPILE_APP -o gen-colors -lm
+ *
+ * and run the utility.
+ *
+ * Note that the converted colors are in the range 0x000-0xff0 (so times 16)
+ * in order to preserve precision.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/videodev2.h
+
+#include vivid-tpg-colors.h
+
+/* sRGB colors with range [0-255] */
+const struct color tpg_colors[TPG_COLOR_MAX] = {
+   /*
+* Colors to test colorspace conversion: converting these colors
+* to other colorspaces will never lead to out-of-gamut colors.
+*/
+   { 191, 191, 191 }, /* TPG_COLOR_CSC_WHITE */
+   { 191, 191,  50 }, /* TPG_COLOR_CSC_YELLOW */
+   {  50, 191, 191 }, /* TPG_COLOR_CSC_CYAN */
+   {  50, 191,  50 }, /* TPG_COLOR_CSC_GREEN */
+   { 191,  50, 191 }, /* TPG_COLOR_CSC_MAGENTA */
+   { 191,  50,  50 }, /* TPG_COLOR_CSC_RED */
+   {  50,  50, 191 }, /* TPG_COLOR_CSC_BLUE */
+   {  50,  50,  50 }, /* TPG_COLOR_CSC_BLACK */
+
+   /* 75% colors */
+   { 191, 191,   0 }, /* TPG_COLOR_75_YELLOW */
+   {   0, 191, 191 }, /* TPG_COLOR_75_CYAN */
+   {   0, 191,   0 }, /* TPG_COLOR_75_GREEN */
+   { 191,   0, 191 }, /* TPG_COLOR_75_MAGENTA */
+   { 191,   0,   0 }, /* TPG_COLOR_75_RED */
+   {   0,   0, 191 }, /* TPG_COLOR_75_BLUE */
+
+   /* 100% colors */
+   { 255, 255, 255 }, /* TPG_COLOR_100_WHITE */
+   { 255, 255,   0 }, /* TPG_COLOR_100_YELLOW */
+   {   0, 255, 255 }, /* TPG_COLOR_100_CYAN */
+   {   0, 255,   0 }, /* TPG_COLOR_100_GREEN */
+   { 255,   0, 255 }, /* TPG_COLOR_100_MAGENTA */
+   { 255,   0,   0 }, /* TPG_COLOR_100_RED */
+   {   0,   0, 255 }, /* TPG_COLOR_100_BLUE */
+   {   0,   0,   0 }, /* TPG_COLOR_100_BLACK */
+
+   {   0,   0,   0 }, /* TPG_COLOR_RANDOM placeholder */
+};
+
+#ifndef COMPILE_APP
+
+/* Generated table */
+const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 
1][TPG_COLOR_CSC_BLACK + 1] = {
+   [V4L2_COLORSPACE_SMPTE170M][0] = { 2953, 2939, 2939 },
+   [V4L2_COLORSPACE_SMPTE170M][1] = { 2954, 2963, 585 },
+   [V4L2_COLORSPACE_SMPTE170M][2] = { 84, 2967, 2937 },
+   [V4L2_COLORSPACE_SMPTE170M][3] = { 93, 2990, 575 },
+   [V4L2_COLORSPACE_SMPTE170M][4] = { 3030, 259, 2933 },
+   [V4L2_COLORSPACE_SMPTE170M][5] = { 3031, 406, 557 },
+   [V4L2_COLORSPACE_SMPTE170M][6] = { 544, 428, 2931 },
+   [V4L2_COLORSPACE_SMPTE170M][7] = { 551, 547, 547 },
+   [V4L2_COLORSPACE_SMPTE240M][0] = { 2926, 2926, 2926 },
+   

[PATCHv2 02/12] vivid.txt: add documentation for the vivid driver

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The vivid Virtual Video Test Driver helps testing V4L2 applications
and can emulate V4L2 hardware. Add the documentation for this driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/vivid.txt | 1109 +++
 1 file changed, 1109 insertions(+)
 create mode 100644 Documentation/video4linux/vivid.txt

diff --git a/Documentation/video4linux/vivid.txt 
b/Documentation/video4linux/vivid.txt
new file mode 100644
index 000..4f1d442
--- /dev/null
+++ b/Documentation/video4linux/vivid.txt
@@ -0,0 +1,1109 @@
+vivid: Virtual Video Test Driver
+
+
+This driver emulates video4linux hardware of various types: video capture, 
video
+output, vbi capture and output, radio receivers and transmitters and a software
+defined radio receiver. In addition a simple framebuffer device is available 
for
+testing capture and output overlays.
+
+Up to 64 vivid instances can be created, each with up to 16 inputs and 16 
outputs.
+
+Each input can be a webcam, TV capture device, S-Video capture device or an 
HDMI
+capture device. Each output can be an S-Video output device or an HDMI output
+device.
+
+These inputs and outputs act exactly as a real hardware device would behave. 
This
+allows you to use this driver as a test input for application development, 
since
+you can test the various features without requiring special hardware.
+
+This document describes the features implemented by this driver:
+
+- Support for read()/write(), MMAP, USERPTR and DMABUF streaming I/O.
+- A large list of test patterns and variations thereof
+- Working brightness, contrast, saturation and hue controls
+- Support for the alpha color component
+- Full colorspace support, including limited/full RGB range
+- All possible control types are present
+- Support for various pixel aspect ratios and video aspect ratios
+- Error injection to test what happens if errors occur
+- Supports crop/compose/scale in any combination for both input and output
+- Can emulate up to 4K resolutions
+- All Field settings are supported for testing interlaced capturing
+- Supports all standard YUV and RGB formats, including two multiplanar YUV 
formats
+- Raw and Sliced VBI capture and output support
+- Radio receiver and transmitter support, including RDS support
+- Software defined radio (SDR) support
+- Capture and output overlay support
+
+These features will be described in more detail below.
+
+
+Table of Contents
+-
+
+Section 1: Configuring the driver
+Section 2: Video Capture
+Section 2.1: Webcam Input
+Section 2.2: TV and S-Video Inputs
+Section 2.3: HDMI Input
+Section 3: Video Output
+Section 3.1: S-Video Output
+Section 3.2: HDMI Output
+Section 4: VBI Capture
+Section 5: VBI Output
+Section 6: Radio Receiver
+Section 7: Radio Transmitter
+Section 8: Software Defined Radio Receiver
+Section 9: Controls
+Section 9.1: User Controls - Test Controls
+Section 9.2: User Controls - Video Capture
+Section 9.3: User Controls - Audio
+Section 9.4: Vivid Controls
+Section 9.4.1: Test Pattern Controls
+Section 9.4.2: Capture Feature Selection Controls
+Section 9.4.3: Output Feature Selection Controls
+Section 9.4.4: Error Injection Controls
+Section 9.4.5: VBI Raw Capture Controls
+Section 9.5: Digital Video Controls
+Section 9.6: FM Radio Receiver Controls
+Section 9.7: FM Radio Modulator
+Section 10: Video, VBI and RDS Looping
+Section 10.1: Video and Sliced VBI looping
+Section 10.2: Radio  RDS Looping
+Section 11: Cropping, Composing, Scaling
+Section 12: Formats
+Section 13: Capture Overlay
+Section 14: Output Overlay
+Section 15: Some Future Improvements
+
+
+Section 1: Configuring the driver
+-
+
+By default the driver will create a single instance that has a video capture
+device with webcam, TV, S-Video and HDMI inputs, a video output device with
+S-Video and HDMI outputs, one vbi capture device, one vbi output device, one
+radio receiver device, one radio transmitter device and one SDR device.
+
+The number of instances, devices, video inputs and outputs and their types are
+all configurable using the following module options:
+
+n_devs: number of driver instances to create. By default set to 1. Up to 64
+   instances can be created.
+
+node_types: which devices should each driver instance create. An array of
+   hexadecimal values, one for each instance. The default is 0x1d3d.
+   Each value is a bitmask with the following meaning:
+   bit 0: Video Capture node
+   bit 2-3: VBI Capture node: 0 = none, 1 = raw vbi, 2 = sliced 
vbi, 3 = both
+   bit 4: Radio Receiver node
+   bit 5: Software Defined Radio Receiver node
+   bit 8: Video Output node
+   bit 10-11: VBI Output node: 0 = none, 1 = raw vbi, 2 = sliced 
vbi, 3 = both
+   bit 12: Radio Transmitter node
+   bit 

[PATCHv2 03/12] vivid: add core driver code

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This is the core driver code that creates all the driver instances
and all the configured devices.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-core.c | 1390 +
 drivers/media/platform/vivid/vivid-core.h |  520 +++
 2 files changed, 1910 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-core.c
 create mode 100644 drivers/media/platform/vivid/vivid-core.h

diff --git a/drivers/media/platform/vivid/vivid-core.c 
b/drivers/media/platform/vivid/vivid-core.c
new file mode 100644
index 000..708b053
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -0,0 +1,1390 @@
+/*
+ * vivid-core.c - A Virtual Video Test Driver, core initialization
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/module.h
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/sched.h
+#include linux/slab.h
+#include linux/font.h
+#include linux/mutex.h
+#include linux/videodev2.h
+#include linux/v4l2-dv-timings.h
+#include media/videobuf2-vmalloc.h
+#include media/v4l2-dv-timings.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-fh.h
+#include media/v4l2-event.h
+
+#include vivid-core.h
+#include vivid-vid-common.h
+#include vivid-vid-cap.h
+#include vivid-vid-out.h
+#include vivid-radio-common.h
+#include vivid-radio-rx.h
+#include vivid-radio-tx.h
+#include vivid-sdr-cap.h
+#include vivid-vbi-cap.h
+#include vivid-vbi-out.h
+#include vivid-osd.h
+#include vivid-ctrls.h
+
+#define VIVID_MODULE_NAME vivid
+
+/* The maximum number of vivid devices */
+#define VIVID_MAX_DEVS 64
+
+MODULE_DESCRIPTION(Virtual Video Test Driver);
+MODULE_AUTHOR(Hans Verkuil);
+MODULE_LICENSE(GPL);
+
+static unsigned n_devs = 1;
+module_param(n_devs, uint, 0444);
+MODULE_PARM_DESC(n_devs,  number of driver instances to create);
+
+static int vid_cap_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(vid_cap_nr, int, NULL, 0444);
+MODULE_PARM_DESC(vid_cap_nr,  videoX start number, -1 is autodetect);
+
+static int vid_out_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(vid_out_nr, int, NULL, 0444);
+MODULE_PARM_DESC(vid_out_nr,  videoX start number, -1 is autodetect);
+
+static int vbi_cap_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(vbi_cap_nr, int, NULL, 0444);
+MODULE_PARM_DESC(vbi_cap_nr,  vbiX start number, -1 is autodetect);
+
+static int vbi_out_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(vbi_out_nr, int, NULL, 0444);
+MODULE_PARM_DESC(vbi_out_nr,  vbiX start number, -1 is autodetect);
+
+static int sdr_cap_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(sdr_cap_nr, int, NULL, 0444);
+MODULE_PARM_DESC(sdr_cap_nr,  swradioX start number, -1 is autodetect);
+
+static int radio_rx_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(radio_rx_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_rx_nr,  radioX start number, -1 is autodetect);
+
+static int radio_tx_nr[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 };
+module_param_array(radio_tx_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_tx_nr,  radioX start number, -1 is autodetect);
+
+static int ccs_cap_mode[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 
};
+module_param_array(ccs_cap_mode, int, NULL, 0444);
+MODULE_PARM_DESC(ccs_cap_mode,  capture crop/compose/scale mode:\n
+  \t\tbit 0=crop, 1=compose, 2=scale,\n
+  \t\t-1=user-controlled (default));
+
+static int ccs_out_mode[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = -1 
};
+module_param_array(ccs_out_mode, int, NULL, 0444);
+MODULE_PARM_DESC(ccs_out_mode,  output crop/compose/scale mode:\n
+  \t\tbit 0=crop, 1=compose, 2=scale,\n
+  \t\t-1=user-controlled (default));
+
+static unsigned multiplanar[VIVID_MAX_DEVS];
+module_param_array(multiplanar, uint, NULL, 0444);
+MODULE_PARM_DESC(multiplanar,  0 (default) is alternating single and 
multiplanar devices,\n
+ \t\t

[PATCHv2 08/12] vivid: add a simple framebuffer device for overlay testing

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

In order to test capture and output overlays a simple framebuffer
device is created. It's bare bone, but it does the job.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-osd.c | 400 +++
 drivers/media/platform/vivid/vivid-osd.h |  27 +++
 2 files changed, 427 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-osd.c
 create mode 100644 drivers/media/platform/vivid/vivid-osd.h

diff --git a/drivers/media/platform/vivid/vivid-osd.c 
b/drivers/media/platform/vivid/vivid-osd.c
new file mode 100644
index 000..084d346
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-osd.c
@@ -0,0 +1,400 @@
+/*
+ * vivid-osd.c - osd support for testing overlays.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/module.h
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/sched.h
+#include linux/slab.h
+#include linux/font.h
+#include linux/mutex.h
+#include linux/videodev2.h
+#include linux/kthread.h
+#include linux/freezer.h
+#include linux/fb.h
+#include media/videobuf2-vmalloc.h
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-fh.h
+#include media/v4l2-event.h
+#include media/v4l2-common.h
+
+#include vivid-core.h
+#include vivid-osd.h
+
+#define MAX_OSD_WIDTH  720
+#define MAX_OSD_HEIGHT 576
+
+/*
+ * Order: white, yellow, cyan, green, magenta, red, blue, black,
+ * and same again with the alpha bit set (if any)
+ */
+static const u16 rgb555[16] = {
+   0x7fff, 0x7fe0, 0x03ff, 0x03e0, 0x7c1f, 0x7c00, 0x001f, 0x,
+   0x, 0xffe0, 0x83ff, 0x83e0, 0xfc1f, 0xfc00, 0x801f, 0x8000
+};
+
+static const u16 rgb565[16] = {
+   0x, 0xffe0, 0x07ff, 0x07e0, 0xf81f, 0xf800, 0x001f, 0x,
+   0x, 0xffe0, 0x07ff, 0x07e0, 0xf81f, 0xf800, 0x001f, 0x
+};
+
+void vivid_clear_fb(struct vivid_dev *dev)
+{
+   void *p = dev-video_vbase;
+   const u16 *rgb = rgb555;
+   unsigned x, y;
+
+   if (dev-fb_defined.green.length == 6)
+   rgb = rgb565;
+
+   for (y = 0; y  dev-display_height; y++) {
+   u16 *d = p;
+
+   for (x = 0; x  dev-display_width; x++)
+   d[x] = rgb[(y / 16 + x / 16) % 16];
+   p += dev-display_byte_stride;
+   }
+}
+
+/* - */
+
+static int vivid_fb_ioctl(struct fb_info *info, unsigned cmd, unsigned long 
arg)
+{
+   struct vivid_dev *dev = (struct vivid_dev *)info-par;
+
+   switch (cmd) {
+   case FBIOGET_VBLANK: {
+   struct fb_vblank vblank;
+
+   vblank.flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT |
+   FB_VBLANK_HAVE_VSYNC;
+   vblank.count = 0;
+   vblank.vcount = 0;
+   vblank.hcount = 0;
+   if (copy_to_user((void __user *)arg, vblank, sizeof(vblank)))
+   return -EFAULT;
+   return 0;
+   }
+
+   default:
+   dprintk(dev, 1, Unknown ioctl %08x\n, cmd);
+   return -EINVAL;
+   }
+   return 0;
+}
+
+/* Framebuffer device handling */
+
+static int vivid_fb_set_var(struct vivid_dev *dev, struct fb_var_screeninfo 
*var)
+{
+   dprintk(dev, 1, vivid_fb_set_var\n);
+
+   if (var-bits_per_pixel != 16) {
+   dprintk(dev, 1, vivid_fb_set_var - Invalid bpp\n);
+   return -EINVAL;
+   }
+   dev-display_byte_stride = var-xres * dev-bytes_per_pixel;
+
+   return 0;
+}
+
+static int vivid_fb_get_fix(struct vivid_dev *dev, struct fb_fix_screeninfo 
*fix)
+{
+   dprintk(dev, 1, vivid_fb_get_fix\n);
+   memset(fix, 0, sizeof(struct fb_fix_screeninfo));
+   strlcpy(fix-id, vioverlay fb, sizeof(fix-id));
+   fix-smem_start = dev-video_pbase;
+   fix-smem_len = dev-video_buffer_size;
+   fix-type = FB_TYPE_PACKED_PIXELS;
+   fix-visual = FB_VISUAL_TRUECOLOR;
+   fix-xpanstep = 1;
+   fix-ypanstep = 1;
+   fix-ywrapstep = 0;
+   fix-line_length = dev-display_byte_stride;
+   fix-accel = 

[PATCHv2 07/12] vivid: add the kthread code that controls the video rate

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add the kthread handlers for video/vbi capture and video/vbi output.
These carefully control the rate at which frames are generated (video
capture) and accepted (video output). While the short-term jitter is
around the order of a jiffie, in the long term the rate matches the
configured framerate exactly.

The capture thread handler also takes care of the video looping and
of capture and overlay support. This is probably the most complex part
of this driver due to the many combinations of crop, compose and scaling
on the input and output, and the blending that has to be done if
overlay support is enabled as well.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-kthread-cap.c | 885 +++
 drivers/media/platform/vivid/vivid-kthread-cap.h |  26 +
 drivers/media/platform/vivid/vivid-kthread-out.c | 304 
 drivers/media/platform/vivid/vivid-kthread-out.h |  26 +
 4 files changed, 1241 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-kthread-cap.c
 create mode 100644 drivers/media/platform/vivid/vivid-kthread-cap.h
 create mode 100644 drivers/media/platform/vivid/vivid-kthread-out.c
 create mode 100644 drivers/media/platform/vivid/vivid-kthread-out.h

diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c 
b/drivers/media/platform/vivid/vivid-kthread-cap.c
new file mode 100644
index 000..33ab1df
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -0,0 +1,885 @@
+/*
+ * vivid-kthread-cap.h - video/vbi capture thread support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/module.h
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/sched.h
+#include linux/slab.h
+#include linux/font.h
+#include linux/mutex.h
+#include linux/videodev2.h
+#include linux/kthread.h
+#include linux/freezer.h
+#include linux/random.h
+#include linux/v4l2-dv-timings.h
+#include asm/div64.h
+#include media/videobuf2-vmalloc.h
+#include media/v4l2-dv-timings.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-fh.h
+#include media/v4l2-event.h
+
+#include vivid-core.h
+#include vivid-vid-common.h
+#include vivid-vid-cap.h
+#include vivid-vid-out.h
+#include vivid-radio-common.h
+#include vivid-radio-rx.h
+#include vivid-radio-tx.h
+#include vivid-sdr-cap.h
+#include vivid-vbi-cap.h
+#include vivid-vbi-out.h
+#include vivid-osd.h
+#include vivid-ctrls.h
+
+static inline v4l2_std_id vivid_get_std_cap(const struct vivid_dev *dev)
+{
+   if (vivid_is_sdtv_cap(dev))
+   return dev-std_cap;
+   return 0;
+}
+
+static void copy_pix(struct vivid_dev *dev, int win_y, int win_x,
+   u16 *cap, const u16 *osd)
+{
+   u16 out;
+   int left = dev-overlay_out_left;
+   int top = dev-overlay_out_top;
+   int fb_x = win_x + left;
+   int fb_y = win_y + top;
+   int i;
+
+   out = *cap;
+   *cap = *osd;
+   if (dev-bitmap_out) {
+   const u8 *p = dev-bitmap_out;
+   unsigned stride = (dev-compose_out.width + 7) / 8;
+
+   win_x -= dev-compose_out.left;
+   win_y -= dev-compose_out.top;
+   if (!(p[stride * win_y + win_x / 8]  (1  (win_x  7
+   return;
+   }
+
+   for (i = 0; i  dev-clipcount_out; i++) {
+   struct v4l2_rect *r = dev-clips_out[i].c;
+
+   if (fb_y = r-top  fb_y  r-top + r-height 
+   fb_x = r-left  fb_x  r-left + r-width)
+   return;
+   }
+   if ((dev-fbuf_out_flags  V4L2_FBUF_FLAG_CHROMAKEY) 
+   *osd != dev-chromakey_out)
+   return;
+   if ((dev-fbuf_out_flags  V4L2_FBUF_FLAG_SRC_CHROMAKEY) 
+   out == dev-chromakey_out)
+   return;
+   if (dev-fmt_cap-alpha_mask) {
+   if ((dev-fbuf_out_flags  V4L2_FBUF_FLAG_GLOBAL_ALPHA) 
+   dev-global_alpha_out)
+   return;
+   if ((dev-fbuf_out_flags  V4L2_FBUF_FLAG_LOCAL_ALPHA) 
+   *cap  dev-fmt_cap-alpha_mask)
+   return;
+   if ((dev-fbuf_out_flags  

[PATCHv2 04/12] vivid: add the control handling code

2014-08-25 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The vivid-ctrls code sets up and processes the various V4L2 controls
that are needed by this driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vivid/vivid-ctrls.c | 1502 
 drivers/media/platform/vivid/vivid-ctrls.h |   34 +
 2 files changed, 1536 insertions(+)
 create mode 100644 drivers/media/platform/vivid/vivid-ctrls.c
 create mode 100644 drivers/media/platform/vivid/vivid-ctrls.h

diff --git a/drivers/media/platform/vivid/vivid-ctrls.c 
b/drivers/media/platform/vivid/vivid-ctrls.c
new file mode 100644
index 000..d5cbf00
--- /dev/null
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -0,0 +1,1502 @@
+/*
+ * vivid-ctrls.c - control support functions.
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include linux/videodev2.h
+#include media/v4l2-event.h
+#include media/v4l2-common.h
+
+#include vivid-core.h
+#include vivid-vid-cap.h
+#include vivid-vid-out.h
+#include vivid-vid-common.h
+#include vivid-radio-common.h
+#include vivid-osd.h
+#include vivid-ctrls.h
+
+#define VIVID_CID_CUSTOM_BASE  (V4L2_CID_USER_BASE | 0xf000)
+#define VIVID_CID_BUTTON   (VIVID_CID_CUSTOM_BASE + 0)
+#define VIVID_CID_BOOLEAN  (VIVID_CID_CUSTOM_BASE + 1)
+#define VIVID_CID_INTEGER  (VIVID_CID_CUSTOM_BASE + 2)
+#define VIVID_CID_INTEGER64(VIVID_CID_CUSTOM_BASE + 3)
+#define VIVID_CID_MENU (VIVID_CID_CUSTOM_BASE + 4)
+#define VIVID_CID_STRING   (VIVID_CID_CUSTOM_BASE + 5)
+#define VIVID_CID_BITMASK  (VIVID_CID_CUSTOM_BASE + 6)
+#define VIVID_CID_INTMENU  (VIVID_CID_CUSTOM_BASE + 7)
+
+#define VIVID_CID_VIVID_BASE   (0x00f0 | 0xf000)
+#define VIVID_CID_VIVID_CLASS  (0x00f0 | 1)
+#define VIVID_CID_TEST_PATTERN (VIVID_CID_VIVID_BASE + 0)
+#define VIVID_CID_OSD_TEXT_MODE(VIVID_CID_VIVID_BASE + 1)
+#define VIVID_CID_HOR_MOVEMENT (VIVID_CID_VIVID_BASE + 2)
+#define VIVID_CID_VERT_MOVEMENT(VIVID_CID_VIVID_BASE + 3)
+#define VIVID_CID_SHOW_BORDER  (VIVID_CID_VIVID_BASE + 4)
+#define VIVID_CID_SHOW_SQUARE  (VIVID_CID_VIVID_BASE + 5)
+#define VIVID_CID_INSERT_SAV   (VIVID_CID_VIVID_BASE + 6)
+#define VIVID_CID_INSERT_EAV   (VIVID_CID_VIVID_BASE + 7)
+#define VIVID_CID_VBI_CAP_INTERLACED   (VIVID_CID_VIVID_BASE + 8)
+
+#define VIVID_CID_HFLIP(VIVID_CID_VIVID_BASE + 20)
+#define VIVID_CID_VFLIP(VIVID_CID_VIVID_BASE + 21)
+#define VIVID_CID_STD_ASPECT_RATIO (VIVID_CID_VIVID_BASE + 22)
+#define VIVID_CID_DV_TIMINGS_ASPECT_RATIO  (VIVID_CID_VIVID_BASE + 23)
+#define VIVID_CID_TSTAMP_SRC   (VIVID_CID_VIVID_BASE + 24)
+#define VIVID_CID_COLORSPACE   (VIVID_CID_VIVID_BASE + 25)
+#define VIVID_CID_LIMITED_RGB_RANGE(VIVID_CID_VIVID_BASE + 26)
+#define VIVID_CID_ALPHA_MODE   (VIVID_CID_VIVID_BASE + 27)
+#define VIVID_CID_HAS_CROP_CAP (VIVID_CID_VIVID_BASE + 28)
+#define VIVID_CID_HAS_COMPOSE_CAP  (VIVID_CID_VIVID_BASE + 29)
+#define VIVID_CID_HAS_SCALER_CAP   (VIVID_CID_VIVID_BASE + 30)
+#define VIVID_CID_HAS_CROP_OUT (VIVID_CID_VIVID_BASE + 31)
+#define VIVID_CID_HAS_COMPOSE_OUT  (VIVID_CID_VIVID_BASE + 32)
+#define VIVID_CID_HAS_SCALER_OUT   (VIVID_CID_VIVID_BASE + 33)
+#define VIVID_CID_LOOP_VIDEO   (VIVID_CID_VIVID_BASE + 34)
+#define VIVID_CID_SEQ_WRAP (VIVID_CID_VIVID_BASE + 35)
+#define VIVID_CID_TIME_WRAP(VIVID_CID_VIVID_BASE + 36)
+#define VIVID_CID_MAX_EDID_BLOCKS  (VIVID_CID_VIVID_BASE + 37)
+#define VIVID_CID_PERCENTAGE_FILL  (VIVID_CID_VIVID_BASE + 38)
+
+#define VIVID_CID_STD_SIGNAL_MODE  (VIVID_CID_VIVID_BASE + 60)
+#define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61)
+#define VIVID_CID_DV_TIMINGS_SIGNAL_MODE   (VIVID_CID_VIVID_BASE + 62)
+#define VIVID_CID_DV_TIMINGS   (VIVID_CID_VIVID_BASE + 63)
+#define VIVID_CID_PERC_DROPPED (VIVID_CID_VIVID_BASE + 64)
+#define VIVID_CID_DISCONNECT   (VIVID_CID_VIVID_BASE + 65)
+#define 

Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Hans Verkuil
Hi Philipp,

I have to think a bit more about the format names, but in the meantime I have
two other suggestions:

On 08/25/2014 12:33 PM, Philipp Zabel wrote:
 This patch adds an array of V4L2 pixel formats and descriptions that can be
 used by drivers so that each driver doesn't have to provide its own slightly
 different format descriptions for VIDIOC_ENUM_FMT.
 
 Each array entry also includes two bits per pixel values (for a single line 
 and
 one for the whole image) that can be used to determine the v4l2_pix_format
 bytesperline and sizeimage values and whether the format is planar or
 compressed.
 
 Signed-off-by: Philipp Zabel p.za...@pengutronix.de
 ---
 I have started to convert some drivers on a boring train ride, but it occurred
 to me that I probably should get some feedback before carrying on with this:
 http://git.pengutronix.de/?p=pza/linux.git;a=shortlog;h=refs/heads/topic/media-pixfmt
 ---
  drivers/media/v4l2-core/v4l2-common.c | 488 
 ++
  include/media/v4l2-common.h   |  44 +++
  2 files changed, 532 insertions(+)
 
 diff --git a/drivers/media/v4l2-core/v4l2-common.c 
 b/drivers/media/v4l2-core/v4l2-common.c
 index ccaa38f..41692df 100644
 --- a/drivers/media/v4l2-core/v4l2-common.c
 +++ b/drivers/media/v4l2-core/v4l2-common.c
 @@ -533,3 +533,491 @@ void v4l2_get_timestamp(struct timeval *tv)
   tv-tv_usec = ts.tv_nsec / NSEC_PER_USEC;
  }
  EXPORT_SYMBOL_GPL(v4l2_get_timestamp);
 +
 +static const struct v4l2_pixfmt v4l2_pixfmts[] = {

snip

 +};
 +
 +const struct v4l2_pixfmt *v4l2_pixfmt_by_fourcc(u32 fourcc)
 +{
 + int i;
 +
 + for (i = 0; i  ARRAY_SIZE(v4l2_pixfmts); i++) {
 + if (v4l2_pixfmts[i].pixelformat == fourcc)
 + return v4l2_pixfmts + i;
 + }
 +
 + return NULL;
 +}
 +EXPORT_SYMBOL_GPL(v4l2_pixfmt_by_fourcc);
 +
 +int v4l2_fill_fmtdesc(struct v4l2_fmtdesc *f, u32 fourcc)
 +{
 + const struct v4l2_pixfmt *fmt;
 +
 + fmt = v4l2_pixfmt_by_fourcc(fourcc);
 + if (!fmt)
 + return -EINVAL;
 +
 + strlcpy((char *)f-description, fmt-name, sizeof(f-description));
 + f-pixelformat = fmt-pixelformat;
 + f-flags = (fmt-bpp_image == 0) ? V4L2_FMT_FLAG_COMPRESSED : 0;
 + return 0;
 +}
 +EXPORT_SYMBOL_GPL(v4l2_fill_fmtdesc);
 diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
 index 48f9748..27b084f 100644
 --- a/include/media/v4l2-common.h
 +++ b/include/media/v4l2-common.h
 @@ -204,4 +204,48 @@ const struct v4l2_frmsize_discrete 
 *v4l2_find_nearest_format(
  
  void v4l2_get_timestamp(struct timeval *tv);
  
 +/**
 + * struct v4l2_pixfmt - internal V4L2 pixel format description
 + * @name: format description to be returned by enum_fmt
 + * @pixelformat: v4l2 pixel format fourcc
 + * @bpp_line: bits per pixel, averaged over a line (of the first plane
 + *for planar formats), used to calculate bytesperline
 + *Zero for compressed and macroblock tiled formats.
 + * @bpp_image: bits per pixel, averaged over the whole image. This is used to
 + * calculate sizeimage for uncompressed formats.
 + * Zero for compressed formats.

I would add a 'planes' field as well for use with formats that use 
non-contiguous
planes.

 + */
 +struct v4l2_pixfmt {
 + const char  *name;
 + u32 pixelformat;
 + u8  bpp_line;
 + u8  bpp_image;
 +};
 +
 +const struct v4l2_pixfmt *v4l2_pixfmt_by_fourcc(u32 fourcc);
 +int v4l2_fill_fmtdesc(struct v4l2_fmtdesc *f, u32 fourcc);
 +
 +static inline unsigned int v4l2_bytesperline(const struct v4l2_pixfmt *fmt,
 +  unsigned int width)
 +{
 + return width * fmt-bpp_line / 8;

Round up: return (width * fmt-bpp_line + 7) / 8;

 +}
 +
 +static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt *fmt,
 +   unsigned int width,
 +   unsigned int height)
 +{
 + return width * height * fmt-bpp_image / 8;

Ditto: return height * v4l2_bytesperline(fmt, width);

 +}
 +
 +static inline bool v4l2_pixfmt_is_planar(const struct v4l2_pixfmt *fmt)
 +{
 + return fmt-bpp_line  (fmt-bpp_line != fmt-bpp_image);
 +}
 +
 +static inline bool v4l2_pixfmt_is_compressed(const struct v4l2_pixfmt *fmt)
 +{
 + return fmt-bpp_image == 0;
 +}
 +
  #endif /* V4L2_COMMON_H_ */
 

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Laurent Pinchart
On Monday 25 August 2014 13:38:45 Hans Verkuil wrote:
 Hi Philipp,
 
 I have to think a bit more about the format names, but in the meantime I
 have two other suggestions:
 
 On 08/25/2014 12:33 PM, Philipp Zabel wrote:
  This patch adds an array of V4L2 pixel formats and descriptions that can
  be used by drivers so that each driver doesn't have to provide its own
  slightly different format descriptions for VIDIOC_ENUM_FMT.

I've started working on this recently as well, so I can only agree with the 
idea.

  Each array entry also includes two bits per pixel values (for a single
  line and one for the whole image) that can be used to determine the
  v4l2_pix_format bytesperline and sizeimage values and whether the format
  is planar or compressed.
  
  Signed-off-by: Philipp Zabel p.za...@pengutronix.de
  ---
  I have started to convert some drivers on a boring train ride, but it
  occurred to me that I probably should get some feedback before carrying
  on with this:
  http://git.pengutronix.de/?p=pza/linux.git;a=shortlog;h=refs/heads/topic/
  media-pixfmt
  ---
  
   drivers/media/v4l2-core/v4l2-common.c | 488 +
   include/media/v4l2-common.h   |  44 +++
   2 files changed, 532 insertions(+)
  
  diff --git a/drivers/media/v4l2-core/v4l2-common.c
  b/drivers/media/v4l2-core/v4l2-common.c index ccaa38f..41692df 100644
  --- a/drivers/media/v4l2-core/v4l2-common.c
  +++ b/drivers/media/v4l2-core/v4l2-common.c
  @@ -533,3 +533,491 @@ void v4l2_get_timestamp(struct timeval *tv)
  
  tv-tv_usec = ts.tv_nsec / NSEC_PER_USEC;
   
   }
   EXPORT_SYMBOL_GPL(v4l2_get_timestamp);
  
  +
  +static const struct v4l2_pixfmt v4l2_pixfmts[] = {
 
 snip
 
  +};
  +
  +const struct v4l2_pixfmt *v4l2_pixfmt_by_fourcc(u32 fourcc)
  +{
  +   int i;
  +
  +   for (i = 0; i  ARRAY_SIZE(v4l2_pixfmts); i++) {
  +   if (v4l2_pixfmts[i].pixelformat == fourcc)
  +   return v4l2_pixfmts + i;
  +   }
  +
  +   return NULL;
  +}
  +EXPORT_SYMBOL_GPL(v4l2_pixfmt_by_fourcc);
  +
  +int v4l2_fill_fmtdesc(struct v4l2_fmtdesc *f, u32 fourcc)
  +{
  +   const struct v4l2_pixfmt *fmt;
  +
  +   fmt = v4l2_pixfmt_by_fourcc(fourcc);
  +   if (!fmt)
  +   return -EINVAL;
  +
  +   strlcpy((char *)f-description, fmt-name, sizeof(f-description));
  +   f-pixelformat = fmt-pixelformat;
  +   f-flags = (fmt-bpp_image == 0) ? V4L2_FMT_FLAG_COMPRESSED : 0;
  +   return 0;
  +}
  +EXPORT_SYMBOL_GPL(v4l2_fill_fmtdesc);
  diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
  index 48f9748..27b084f 100644
  --- a/include/media/v4l2-common.h
  +++ b/include/media/v4l2-common.h
  @@ -204,4 +204,48 @@ const struct v4l2_frmsize_discrete
  *v4l2_find_nearest_format( 
   void v4l2_get_timestamp(struct timeval *tv);
  
  +/**
  + * struct v4l2_pixfmt - internal V4L2 pixel format description
  + * @name: format description to be returned by enum_fmt
  + * @pixelformat: v4l2 pixel format fourcc
  + * @bpp_line: bits per pixel, averaged over a line (of the first plane
  + *for planar formats), used to calculate bytesperline
  + *Zero for compressed and macroblock tiled formats.
  + * @bpp_image: bits per pixel, averaged over the whole image. This is
  used to
  + * calculate sizeimage for uncompressed formats.
  + * Zero for compressed formats.
 
 I would add a 'planes' field as well for use with formats that use
 non-contiguous planes.
 
  + */
  +struct v4l2_pixfmt {
  +   const char  *name;
  +   u32 pixelformat;
  +   u8  bpp_line;
  +   u8  bpp_image;
  +};
  +
  +const struct v4l2_pixfmt *v4l2_pixfmt_by_fourcc(u32 fourcc);
  +int v4l2_fill_fmtdesc(struct v4l2_fmtdesc *f, u32 fourcc);
  +
  +static inline unsigned int v4l2_bytesperline(const struct v4l2_pixfmt
  *fmt, +  unsigned int width)
  +{
  +   return width * fmt-bpp_line / 8;
 
 Round up: return (width * fmt-bpp_line + 7) / 8;

DIV_ROUND_UP(width * fmt-bpp_line, 8) ?

  +}
  +
  +static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt *fmt,
  + unsigned int width,
  + unsigned int height)
  +{
  +   return width * height * fmt-bpp_image / 8;
 
 Ditto: return height * v4l2_bytesperline(fmt, width);

  +}
  +
  +static inline bool v4l2_pixfmt_is_planar(const struct v4l2_pixfmt *fmt)
  +{
  +   return fmt-bpp_line  (fmt-bpp_line != fmt-bpp_image);
  +}
  +
  +static inline bool v4l2_pixfmt_is_compressed(const struct v4l2_pixfmt
  *fmt)
  +{
  +   return fmt-bpp_image == 0;
  +}
  +
  
   #endif /* V4L2_COMMON_H_ */

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3] videobuf2-core: take mmap_sem before calling __qbuf_userptr

2014-08-25 Thread Hans Verkuil
(Changes since v2: dropped local variable as suggested by Laurent)

Commit f035eb4e976ef5a059e30bc91cfd310ff030a7d3 (videobuf2: fix lockdep warning)
unfortunately removed the mmap_sem lock that is needed around the call to
__qbuf_userptr. Amazingly nobody noticed this (especially me as the author)
until Jan Kara pointed this out to me.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reported-by: Jan Kara j...@suse.cz
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 5b808e2..ce59962b 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1627,7 +1627,9 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
ret = __qbuf_mmap(vb, b);
break;
case V4L2_MEMORY_USERPTR:
+   down_read(current-mm-mmap_sem);
ret = __qbuf_userptr(vb, b);
+   up_read(current-mm-mmap_sem);
break;
case V4L2_MEMORY_DMABUF:
ret = __qbuf_dmabuf(vb, b);
-- 
2.1.0.rc1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/6] V4L2: Add Renesas R-Car JPEG codec driver.

2014-08-25 Thread Mikhail Ulyanov
This patch contains driver for Renesas R-Car JPEG codec.

Cnanges since v1:
- s/g_fmt function simplified
- default format for queues added
- dumb vidioc functions added to be in compliance with standard api:
jpu_s_priority, jpu_g_priority
- standard v4l2_ctrl_subscribe_event and v4l2_event_unsubscribe
  now in use by the same reason

Signed-off-by: Mikhail Ulyanov mikhail.ulya...@cogentembedded.com
---
 drivers/media/platform/Kconfig  |   11 +
 drivers/media/platform/Makefile |2 +
 drivers/media/platform/jpu.c | 1628 ++
 3 files changed, 1641 insertions(+)
 create mode 100644 drivers/media/platform/jpu.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 6d86646..1b8c846 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -220,6 +220,17 @@ config VIDEO_RENESAS_VSP1
  To compile this driver as a module, choose M here: the module
  will be called vsp1.
 
+config VIDEO_RENESAS_JPU
+   tristate Renesas JPEG Processing Unit
+   depends on VIDEO_DEV  VIDEO_V4L2
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a V4L2 driver for the Renesas JPEG Processing Unit.
+
+ To compile this driver as a module, choose M here: the module
+ will be called jpu.
+
 config VIDEO_TI_VPE
tristate TI VPE (Video Processing Engine) driver
depends on VIDEO_DEV  VIDEO_V4L2  SOC_DRA7XX
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index e5269da..e438534 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -47,6 +47,8 @@ obj-$(CONFIG_SOC_CAMERA)  += soc_camera/
 
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
+obj-$(CONFIG_VIDEO_RENESAS_JPU)+= jpu.o
+
 obj-y  += davinci/
 
 obj-$(CONFIG_ARCH_OMAP)+= omap/
diff --git a/drivers/media/platform/jpu.c b/drivers/media/platform/jpu.c
new file mode 100644
index 000..da70491
--- /dev/null
+++ b/drivers/media/platform/jpu.c
@@ -0,0 +1,1628 @@
+/*
+ * Author: Mikhail Ulyanov  sou...@cogentembedded.com
+ * Copyright (C) 2014 Cogent Embedded, Inc.
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ *
+ * This is based on the drivers/media/platform/s5p-jpu driver by
+ * Andrzej Pietrasiewicz and Jacek Anaszewski.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/err.h
+#include linux/gfp.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/spinlock.h
+#include linux/string.h
+#include linux/videodev2.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-device.h
+#include media/v4l2-event.h
+#include media/v4l2-fh.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-ioctl.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+
+#define JPU_M2M_NAME jpu
+
+#define JPU_WIDTH_MIN  16
+#define JPU_HEIGHT_MIN 16
+#define JPU_WIDTH_MAX  4096
+#define JPU_HEIGHT_MAX 4096
+#define JPU_DEFAULT_WIDTH  640
+#define JPU_DEFAULT_HEIGHT 480
+
+#define JPU_ENCODE 0
+#define JPU_DECODE 1
+
+/* Flags that indicate a format can be used for capture/output */
+#define JPU_FMT_TYPE_OUTPUT0
+#define JPU_FMT_TYPE_CAPTURE   1
+#define JPU_ENC_CAPTURE(1  0)
+#define JPU_ENC_OUTPUT (1  1)
+#define JPU_DEC_CAPTURE(1  2)
+#define JPU_DEC_OUTPUT (1  3)
+
+/*
+ * JPEG registers and bits
+ */
+
+/* JPEG code mode register */
+#define JCMOD  0x00
+#define JCMOD_SOI_DISABLE  (1  8)
+#define JCMOD_SOI_ENABLE   (0  8)
+#define JCMOD_PCTR (1  7)
+#define JCMOD_MSKIP_DISABLE(0  5)
+#define JCMOD_MSKIP_ENABLE (1  5)
+#define JCMOD_DSP_ENC  (0  3)
+#define JCMOD_DSP_DEC  (1  3)
+#define JCMOD_REDU (7  0)
+#define JCMOD_REDU_422 (1  0)
+#define JCMOD_REDU_420 (2  0)
+
+/* JPEG code command register */
+#define JCCMD  0x04
+#define JCCMD_SRST (1  12)
+#define JCCMD_BRST (1  7)
+#define JCCMD_JEND (1  2)
+#define JCCMD_JSRT (1  0)
+
+/* JPEG code quantanization table number register */
+#define JCQTN  0x0C
+#define JCQTN_SHIFT(t) (((t) - 1)  1)
+
+/* JPEG code Huffman table number register */
+#define JCHTN  0x10
+#define JCHTN_AC_SHIFT(t)  (((t)  1) - 1)
+#define JCHTN_DC_SHIFT(t)  (((t) - 1)  1)
+
+#define JCDRIU 0x14 /* JPEG code DRI upper register */
+#define JCDRIL 0x18 /* JPEG code DRI lower register */
+#define JCVSZU 0x1C /* JPEG code vertical size upper register */
+#define JCVSZD 0x20 /* JPEG 

[PATCH v2 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Mikhail Ulyanov
Documentation for Renesas JPU devicetree node.

Changes since v1:
- First line typo fixed
- renesas,jpu-gen2 compatability option added

Signed-off-by: Mikhail Ulyanov mikhail.ulya...@cogentembedded.com
---
 .../devicetree/bindings/media/renesas,jpu.txt  | 23 ++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,jpu.txt

diff --git a/Documentation/devicetree/bindings/media/renesas,jpu.txt 
b/Documentation/devicetree/bindings/media/renesas,jpu.txt
new file mode 100644
index 000..44b07df
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,jpu.txt
@@ -0,0 +1,24 @@
+* Renesas JPEG processing unit.
+
+The JPEG processing unit (JPU) incorporates the JPEG codec with an encoding
+and decoding function conforming to the JPEG baseline process, so that the JPU
+can encode image data and decode JPEG data quickly.
+It can be found in the Renesas R-Car second generation SoCs.
+
+Required properties:
+  - compatible: should containg one of the following:
+   - renesas,jpu-r8a7790 for R-Car H2
+   - renesas,jpu-r8a7791 for R-Car M2
+   - renesas,jpu-gen2 for R-Car second generation
+
+  - reg: Base address and length of the registers block for the JPU.
+  - interrupts: JPU interrupt specifier.
+  - clocks: A phandle + clock-specifier pair for the JPU functional clock.
+
+Example: R8A7790 (R-Car H2) JPU node
+   jpeg-codec@fe98 {
+   compatible = renesas,jpu-r8a7790;
+   reg = 0 0xfe98 0 0x10300;
+   interrupts = 0 272 IRQ_TYPE_LEVEL_HIGH;
+   clocks = mstp1_clks R8A7790_CLK_JPU;
+   };
-- 
2.1.0.rc1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/6] V4L2: Add Renesas R-Car JPEG codec driver.

2014-08-25 Thread Hans Verkuil
On 08/25/2014 02:29 PM, Mikhail Ulyanov wrote:
 This patch contains driver for Renesas R-Car JPEG codec.
 
 Cnanges since v1:
 - s/g_fmt function simplified
 - default format for queues added
 - dumb vidioc functions added to be in compliance with standard api:
 jpu_s_priority, jpu_g_priority

Oops, that's a bug elsewhere. Don't add these empty prio ops, this needs to be
solved in the v4l2 core.

I'll post a patch for this.

Regards,

Hans

 - standard v4l2_ctrl_subscribe_event and v4l2_event_unsubscribe
   now in use by the same reason

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/6] V4L2: Add Renesas R-Car JPEG codec driver.

2014-08-25 Thread Hans Verkuil
On 08/25/2014 02:39 PM, Hans Verkuil wrote:
 On 08/25/2014 02:29 PM, Mikhail Ulyanov wrote:
 This patch contains driver for Renesas R-Car JPEG codec.

 Cnanges since v1:
 - s/g_fmt function simplified
 - default format for queues added
 - dumb vidioc functions added to be in compliance with standard api:
 jpu_s_priority, jpu_g_priority
 
 Oops, that's a bug elsewhere. Don't add these empty prio ops, this needs to be
 solved in the v4l2 core.
 
 I'll post a patch for this.

After some thought I've decided to allow prio handling for m2m devices. It is
actually useful if some application wants exclusive access to the m2m hardware.

So I will change v4l2-compliance instead.

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Philipp Zabel
Hi Hans,

Am Montag, den 25.08.2014, 13:38 +0200 schrieb Hans Verkuil:
 Hi Philipp,
 
 I have to think a bit more about the format names, but in the meantime I have
 two other suggestions:

Thank you, I haven't spent much thought about the actual descriptions
yet. Most are just transcribed from the comments in videodev2.h without
looking at the names used in the drivers.

[...]
  +/**
  + * struct v4l2_pixfmt - internal V4L2 pixel format description
  + * @name: format description to be returned by enum_fmt
  + * @pixelformat: v4l2 pixel format fourcc
  + * @bpp_line: bits per pixel, averaged over a line (of the first plane
  + *for planar formats), used to calculate bytesperline
  + *Zero for compressed and macroblock tiled formats.
  + * @bpp_image: bits per pixel, averaged over the whole image. This is used 
  to
  + * calculate sizeimage for uncompressed formats.
  + * Zero for compressed formats.
 
 I would add a 'planes' field as well for use with formats that use 
 non-contiguous
 planes.

Good point, I'll add that.

[...]
  +static inline unsigned int v4l2_bytesperline(const struct v4l2_pixfmt *fmt,
  +unsigned int width)
  +{
  +   return width * fmt-bpp_line / 8;
 
 Round up: return (width * fmt-bpp_line + 7) / 8;

Right, I should use DIV_ROUND_UP(width * fmt-bpp_line, 8) here.

  +}
  +
  +static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt *fmt,
  + unsigned int width,
  + unsigned int height)
  +{
  +   return width * height * fmt-bpp_image / 8;
 
 Ditto: return height * v4l2_bytesperline(fmt, width);

I can't use v4l2_bytesperline because that might be zero for macroblock
tiled formats and uses the wrong bpp value for planar formats with
subsampled chroma.

This nearly works:
return height * DIV_ROUND_UP(width * fmt-bpp_image, 8)

For the planar 4:2:0 subsampled formats and Y41P (bpp_image == 12),
width has to be even, so that is ok.
Most other formats have a bpp_image that is divisible by 8, but there
are the 4:1:0 subsampled formats (bpp_image == 9). Those would round up
width to a multiple of eight, even though it only has to be a multiple
of four. I'd fall back to:

if (fmt-bpp_image == fmt-bpp_line) {
return height * DIV_ROUND_UP(width * fmt-bpp_image, 8);
} else {
/* we know that v4l2_bytesperline doesn't round for planar */
return height * width * fmt-bpp_image / 8;
}

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Geert Uytterhoeven
Hi Mikhail,

On Mon, Aug 25, 2014 at 2:35 PM, Mikhail Ulyanov
mikhail.ulya...@cogentembedded.com wrote:
 +  - compatible: should containg one of the following:
 +   - renesas,jpu-r8a7790 for R-Car H2
 +   - renesas,jpu-r8a7791 for R-Car M2
 +   - renesas,jpu-gen2 for R-Car second generation

Isn't renesas,jpu-gen2 meant as a fallback?

I.e. the DTS should have one of '7790 and '7791, AND the gen2 fallback,
so we can make the driver match against '7790 and '7791 is we find
out about an incompatibility.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT

2014-08-25 Thread Michael Grzeschik
Hi Laurent,

On Wed, Aug 20, 2014 at 07:05:30PM +0200, Laurent Pinchart wrote:
 Hi Hans and Michael,
 
 On Wednesday 20 August 2014 02:06:54 Hans Verkuil wrote:
  On 08/19/2014 05:01 PM, Laurent Pinchart wrote:
   Hi Michael,
   
   Thank you for the patch.
   
   (CC'ing Hans Verkuil and the linux-media mailing list)
   
   On Friday 08 August 2014 17:38:58 Michael Grzeschik wrote:
   This patch adds ENUM_FMT as possible ioctl to the uvc v4l2 device.
   That makes userspace applications with a generic IOCTL calling
   convention make also use of it.
   
   Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
   ---
   
   v1 - v2:
- changed first switch case to simple if
- added separate function
- added description field
- bail out on array boundaries

drivers/usb/gadget/uvc_v4l2.c | 30 --
1 file changed, 28 insertions(+), 2 deletions(-)
   
   diff --git a/drivers/usb/gadget/uvc_v4l2.c
   b/drivers/usb/gadget/uvc_v4l2.c
   index ad48e81..58633bf 100644
   --- a/drivers/usb/gadget/uvc_v4l2.c
   +++ b/drivers/usb/gadget/uvc_v4l2.c
   @@ -55,14 +55,30 @@ struct uvc_format
{
u8 bpp;
u32 fcc;
   +char *description;
};

static struct uvc_format uvc_formats[] = {
   -{ 16, V4L2_PIX_FMT_YUYV  },
   -{ 0,  V4L2_PIX_FMT_MJPEG },
   +{ 16, V4L2_PIX_FMT_YUYV, YUV 4:2:2 },
   +{ 0,  V4L2_PIX_FMT_MJPEG, MJPEG },
   
   Format descriptions are currently duplicated in every driver, causing
   higher memory usage and different descriptions for the same format
   depending on the driver. Hans, should we try to fix this ?
  
  Yes, we should. It's been on my todo list for ages, but at a very low
  priority. I'm not planning to work on this in the near future, but if
  someone else wants to work on this, then just go ahead.
 
 Michael, would you like to give this a try, or should I do it ?

It seems Philipp is already taking the chance! :)

Regards,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT

2014-08-25 Thread Laurent Pinchart
Hi Michael,

On Monday 25 August 2014 15:59:57 Michael Grzeschik wrote:
 On Wed, Aug 20, 2014 at 07:05:30PM +0200, Laurent Pinchart wrote:
  On Wednesday 20 August 2014 02:06:54 Hans Verkuil wrote:
   On 08/19/2014 05:01 PM, Laurent Pinchart wrote:
Hi Michael,

Thank you for the patch.

(CC'ing Hans Verkuil and the linux-media mailing list)

On Friday 08 August 2014 17:38:58 Michael Grzeschik wrote:
This patch adds ENUM_FMT as possible ioctl to the uvc v4l2 device.
That makes userspace applications with a generic IOCTL calling
convention make also use of it.

Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
---

v1 - v2:
 - changed first switch case to simple if
 - added separate function
 - added description field
 - bail out on array boundaries
 
 drivers/usb/gadget/uvc_v4l2.c | 30 --
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/uvc_v4l2.c
b/drivers/usb/gadget/uvc_v4l2.c
index ad48e81..58633bf 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -55,14 +55,30 @@ struct uvc_format
 {
   u8 bpp;
   u32 fcc;
+  char *description;
 };
 
 static struct uvc_format uvc_formats[] = {
-  { 16, V4L2_PIX_FMT_YUYV  },
-  { 0,  V4L2_PIX_FMT_MJPEG },
+  { 16, V4L2_PIX_FMT_YUYV, YUV 4:2:2 },
+  { 0,  V4L2_PIX_FMT_MJPEG, MJPEG },

Format descriptions are currently duplicated in every driver, causing
higher memory usage and different descriptions for the same format
depending on the driver. Hans, should we try to fix this ?
   
   Yes, we should. It's been on my todo list for ages, but at a very low
   priority. I'm not planning to work on this in the near future, but if
   someone else wants to work on this, then just go ahead.
  
  Michael, would you like to give this a try, or should I do it ?
 
 It seems Philipp is already taking the chance! :)

Perfect timing, I wonder if that's just a coincidence ;-)

I don't think this patch is very urgent, would you be fine with rebasing it on 
top of Philipp's patch when it will be accepted ?

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/29] uvc: fix sparse warning

2014-08-25 Thread Laurent Pinchart
Hi Hans,

Thank you for the patch.

On Thursday 21 August 2014 00:59:15 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 drivers/media/usb/uvc/uvc_video.c:1466:38: warning: incorrect type in return
 expression (different base types)
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com

I assume you will push the patch yourself. Please let me know if you would 
like me to take it into my tree instead.

 ---
  drivers/media/usb/uvc/uvc_video.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/media/usb/uvc/uvc_video.c
 b/drivers/media/usb/uvc/uvc_video.c index 9144a2f..7e350d7 100644
 --- a/drivers/media/usb/uvc/uvc_video.c
 +++ b/drivers/media/usb/uvc/uvc_video.c
 @@ -1463,7 +1463,7 @@ static unsigned int uvc_endpoint_max_bpi(struct
 usb_device *dev,
 
   switch (dev-speed) {
   case USB_SPEED_SUPER:
 - return ep-ss_ep_comp.wBytesPerInterval;
 + return le16_to_cpu(ep-ss_ep_comp.wBytesPerInterval);
   case USB_SPEED_HIGH:
   psize = usb_endpoint_maxp(ep-desc);
   return (psize  0x07ff) * (1 + ((psize  11)  3));

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media-workshop] [ANNOUNCE] Linux Kernel Media mini-summit on Oct, 16-17 in Düsseldorf, Germany

2014-08-25 Thread Ralph Metzler
Guennadi Liakhovetski writes:
  I'll likely be able to attend too. ATM I'm working on camera support in 
  Android. I think Hans discussed related topics at the previous summit in 
  the US too, which I didn't manage to attend unfortunately. I'll try to 
  double-check results of those discussions and see which topics I'd be 
  interested in discussing further.

I'll also try to be there for the mini-summit.
So, if anybody wants to discuss APIs for DVB-T2/C2, CI, modulators,
DVB network streaming or anything else related to DVB drivers ...


  On a related note, since I live something like 80km from the venue, I was 
  thinking about possibly helping to organise a media event in my town - in 
  Aachen, or in Düsseldorf itself or in neighbouring Cologne (Köln). Let me 
  know if there's interest. We could use Saturday the 18th of October for 
  that.

I also live just 50km from the venue. 


Regards,
Ralph

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Laurent Pinchart
On Monday 25 August 2014 14:50:53 Philipp Zabel wrote:
 Hi Hans,
 
 Am Montag, den 25.08.2014, 13:38 +0200 schrieb Hans Verkuil:
  Hi Philipp,
  
  I have to think a bit more about the format names, but in the meantime I
  have
  two other suggestions:
 Thank you, I haven't spent much thought about the actual descriptions
 yet. Most are just transcribed from the comments in videodev2.h without
 looking at the names used in the drivers.
 
 [...]
 
   +/**
   + * struct v4l2_pixfmt - internal V4L2 pixel format description
   + * @name: format description to be returned by enum_fmt
   + * @pixelformat: v4l2 pixel format fourcc
   + * @bpp_line: bits per pixel, averaged over a line (of the first plane
   + *for planar formats), used to calculate bytesperline
   + *Zero for compressed and macroblock tiled formats.
   + * @bpp_image: bits per pixel, averaged over the whole image. This is
   used to
   + * calculate sizeimage for uncompressed formats.
   + * Zero for compressed formats.
  
  I would add a 'planes' field as well for use with formats that use
  non-contiguous planes.
 
 Good point, I'll add that.
 
 [...]
 
   +static inline unsigned int v4l2_bytesperline(const struct v4l2_pixfmt
   *fmt, +unsigned int width)
   +{
   + return width * fmt-bpp_line / 8;
  
  Round up: return (width * fmt-bpp_line + 7) / 8;
 
 Right, I should use DIV_ROUND_UP(width * fmt-bpp_line, 8) here.
 
   +}
   +
   +static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt
   *fmt,
   +   unsigned int width,
   +   unsigned int height)
   +{
   + return width * height * fmt-bpp_image / 8;
  
  Ditto: return height * v4l2_bytesperline(fmt, width);
 
 I can't use v4l2_bytesperline because that might be zero for macroblock
 tiled formats and uses the wrong bpp value for planar formats with
 subsampled chroma.
 
 This nearly works:
 return height * DIV_ROUND_UP(width * fmt-bpp_image, 8)

Isn't that exactly height * v4l2_bytesperline(fmt, width) ?

 For the planar 4:2:0 subsampled formats and Y41P (bpp_image == 12),
 width has to be even, so that is ok.
 Most other formats have a bpp_image that is divisible by 8, but there
 are the 4:1:0 subsampled formats (bpp_image == 9). Those would round up
 width to a multiple of eight, even though it only has to be a multiple
 of four. I'd fall back to:
 
 if (fmt-bpp_image == fmt-bpp_line) {
 return height * DIV_ROUND_UP(width * fmt-bpp_image, 8);
 } else {
 /* we know that v4l2_bytesperline doesn't round for planar */
 return height * width * fmt-bpp_image / 8;
 }

Isn't that growing slightly too big for an inline function ?

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT

2014-08-25 Thread Philipp Zabel
Hi Laurent,

Am Montag, den 25.08.2014, 16:48 +0200 schrieb Laurent Pinchart:
[...]
 Format descriptions are currently duplicated in every driver, causing
 higher memory usage and different descriptions for the same format
 depending on the driver. Hans, should we try to fix this ?

Yes, we should. It's been on my todo list for ages, but at a very low
priority. I'm not planning to work on this in the near future, but if
someone else wants to work on this, then just go ahead.
   
   Michael, would you like to give this a try, or should I do it ?
  
  It seems Philipp is already taking the chance! :)
 
 Perfect timing, I wonder if that's just a coincidence ;-)

It felt like my own idea this weekend, but I strongly suspect that I
took up enough information to trigger it, when scanning mail last week.

I shouldn't be so fast to dismiss uvc/gadget mails as Michael's
business...

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Philipp Zabel
Hi Laurent,

Am Montag, den 25.08.2014, 17:13 +0200 schrieb Laurent Pinchart:
[...]
+static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt
*fmt,
+ unsigned int width,
+ unsigned int height)
+{
+   return width * height * fmt-bpp_image / 8;
   
   Ditto: return height * v4l2_bytesperline(fmt, width);
  
  I can't use v4l2_bytesperline because that might be zero for macroblock
  tiled formats and uses the wrong bpp value for planar formats with
  subsampled chroma.
  
  This nearly works:
  return height * DIV_ROUND_UP(width * fmt-bpp_image, 8)
 
 Isn't that exactly height * v4l2_bytesperline(fmt, width) ?

Only if bpp_image == bpp_line ...

  For the planar 4:2:0 subsampled formats and Y41P (bpp_image == 12),
  width has to be even, so that is ok.
  Most other formats have a bpp_image that is divisible by 8, but there
  are the 4:1:0 subsampled formats (bpp_image == 9). Those would round up
  width to a multiple of eight, even though it only has to be a multiple
  of four. I'd fall back to:
  
  if (fmt-bpp_image == fmt-bpp_line) {
  return height * DIV_ROUND_UP(width * fmt-bpp_image, 8);

... as is the case here. I'll use v4l2_bytesperline, then.

  } else {
  /* we know that v4l2_bytesperline doesn't round for planar */
  return height * width * fmt-bpp_image / 8;
  }
 
 Isn't that growing slightly too big for an inline function ?

Yes, I think this is slightly over the edge. Is room for a function to
accompany the preexisting v4l2_fill_pix_format (say,
v4l2_fill_pix_format_size) to set both the bytesperline and sizeimage
values in a struct v4l2_pix_format?

Also, is anybody bothered by the v4l2_pix_format / v4l2_pixfmt
similarity in name?

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] [media] v4l2: add V4L2 pixel format array and helper functions

2014-08-25 Thread Laurent Pinchart
Hi Philipp,

On Monday 25 August 2014 17:41:17 Philipp Zabel wrote:
 Am Montag, den 25.08.2014, 17:13 +0200 schrieb Laurent Pinchart:
 [...]
 
  +static inline unsigned int v4l2_sizeimage(const struct v4l2_pixfmt
  *fmt,
  +  unsigned int width,
  +  unsigned int height)
  +{
  +return width * height * fmt-bpp_image / 8;
  
  Ditto: return height * v4l2_bytesperline(fmt, width);
  
  I can't use v4l2_bytesperline because that might be zero for macroblock
  tiled formats and uses the wrong bpp value for planar formats with
  subsampled chroma.
  
  This nearly works:
  return height * DIV_ROUND_UP(width * fmt-bpp_image, 8)
  
  Isn't that exactly height * v4l2_bytesperline(fmt, width) ?
 
 Only if bpp_image == bpp_line ...

Oops, I've missed that subtle difference, sorry.

  For the planar 4:2:0 subsampled formats and Y41P (bpp_image == 12),
  width has to be even, so that is ok.
  Most other formats have a bpp_image that is divisible by 8, but there
  are the 4:1:0 subsampled formats (bpp_image == 9). Those would round up
  width to a multiple of eight, even though it only has to be a multiple
  
  of four. I'd fall back to:
  if (fmt-bpp_image == fmt-bpp_line) {
  
  return height * DIV_ROUND_UP(width * fmt-bpp_image, 8);
 
 ... as is the case here. I'll use v4l2_bytesperline, then.
 
  } else {
  
  /* we know that v4l2_bytesperline doesn't round for planar */
  return height * width * fmt-bpp_image / 8;
  
  }
  
  Isn't that growing slightly too big for an inline function ?
 
 Yes, I think this is slightly over the edge. Is room for a function to
 accompany the preexisting v4l2_fill_pix_format (say,
 v4l2_fill_pix_format_size) to set both the bytesperline and sizeimage
 values in a struct v4l2_pix_format?

That sounds sensible to me, provided it would be used by drivers of course. I 
wouldn't remove v4l2_bytesperline() and v4l2_sizeimage(), as the values might 
be needed by drivers in places where a v4l2_pix_format structure isn't 
available.

 Also, is anybody bothered by the v4l2_pix_format / v4l2_pixfmt
 similarity in name?

How about renaming v4l2_pixfmt to v4l2_pix_format_info ?

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/12] msi001: logging changes

2014-08-25 Thread Antti Palosaari
Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/msi001.c | 56 ---
 1 file changed, 31 insertions(+), 25 deletions(-)

diff --git a/drivers/media/tuners/msi001.c b/drivers/media/tuners/msi001.c
index ee99e37..26019e7 100644
--- a/drivers/media/tuners/msi001.c
+++ b/drivers/media/tuners/msi001.c
@@ -67,7 +67,8 @@ static int msi001_set_gain(struct msi001 *s, int lna_gain, 
int mixer_gain,
 {
int ret;
u32 reg;
-   dev_dbg(s-spi-dev, %s: lna=%d mixer=%d if=%d\n, __func__,
+
+   dev_dbg(s-spi-dev, lna=%d mixer=%d if=%d\n,
lna_gain, mixer_gain, if_gain);
 
reg = 1  0;
@@ -83,7 +84,7 @@ static int msi001_set_gain(struct msi001 *s, int lna_gain, 
int mixer_gain,
 
return 0;
 err:
-   dev_dbg(s-spi-dev, %s: failed %d\n, __func__, ret);
+   dev_dbg(s-spi-dev, failed %d\n, ret);
return ret;
 };
 
@@ -94,6 +95,7 @@ static int msi001_set_tuner(struct msi001 *s)
u32 reg;
u64 f_vco, tmp64;
u8 mode, filter_mode, lo_div;
+
static const struct {
u32 rf;
u8 mode;
@@ -145,9 +147,7 @@ static int msi001_set_tuner(struct msi001 *s)
#define R_REF 4
#define F_OUT_STEP 1
 
-   dev_dbg(s-spi-dev,
-   %s: f_rf=%d f_if=%d\n,
-   __func__, f_rf, f_if);
+   dev_dbg(s-spi-dev, f_rf=%d f_if=%d\n, f_rf, f_if);
 
for (i = 0; i  ARRAY_SIZE(band_lut); i++) {
if (f_rf = band_lut[i].rf) {
@@ -198,8 +198,7 @@ static int msi001_set_tuner(struct msi001 *s)
 
s-bandwidth-val = bandwidth_lut[i].freq;
 
-   dev_dbg(s-spi-dev, %s: bandwidth selected=%d\n,
-   __func__, bandwidth_lut[i].freq);
+   dev_dbg(s-spi-dev, bandwidth selected=%d\n, bandwidth_lut[i].freq);
 
f_vco = (u64) (f_rf + f_if + f_if1) * lo_div;
tmp64 = f_vco;
@@ -225,9 +224,8 @@ static int msi001_set_tuner(struct msi001 *s)
tmp += 1ul * F_REF * R_REF * frac / thresh;
tmp /= lo_div;
 
-   dev_dbg(s-spi-dev,
-   %s: rf=%u:%u n=%d thresh=%d frac=%d\n,
-   __func__, f_rf, tmp, n, thresh, frac);
+   dev_dbg(s-spi-dev, rf=%u:%u n=%d thresh=%d frac=%d\n,
+   f_rf, tmp, n, thresh, frac);
 
ret = msi001_wreg(s, 0x0e);
if (ret)
@@ -276,7 +274,7 @@ static int msi001_set_tuner(struct msi001 *s)
 
return 0;
 err:
-   dev_dbg(s-spi-dev, %s: failed %d\n, __func__, ret);
+   dev_dbg(s-spi-dev, failed %d\n, ret);
return ret;
 };
 
@@ -284,7 +282,8 @@ static int msi001_s_power(struct v4l2_subdev *sd, int on)
 {
struct msi001 *s = sd_to_msi001(sd);
int ret;
-   dev_dbg(s-spi-dev, %s: on=%d\n, __func__, on);
+
+   dev_dbg(s-spi-dev, on=%d\n, on);
 
if (on)
ret = 0;
@@ -301,7 +300,8 @@ static const struct v4l2_subdev_core_ops msi001_core_ops = {
 static int msi001_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *v)
 {
struct msi001 *s = sd_to_msi001(sd);
-   dev_dbg(s-spi-dev, %s: index=%d\n, __func__, v-index);
+
+   dev_dbg(s-spi-dev, index=%d\n, v-index);
 
strlcpy(v-name, Mirics MSi001, sizeof(v-name));
v-type = V4L2_TUNER_RF;
@@ -315,14 +315,16 @@ static int msi001_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *v)
 static int msi001_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *v)
 {
struct msi001 *s = sd_to_msi001(sd);
-   dev_dbg(s-spi-dev, %s: index=%d\n, __func__, v-index);
+
+   dev_dbg(s-spi-dev, index=%d\n, v-index);
return 0;
 }
 
 static int msi001_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
 {
struct msi001 *s = sd_to_msi001(sd);
-   dev_dbg(s-spi-dev, %s: tuner=%d\n, __func__, f-tuner);
+
+   dev_dbg(s-spi-dev, tuner=%d\n, f-tuner);
f-frequency = s-f_tuner;
return 0;
 }
@@ -332,8 +334,9 @@ static int msi001_s_frequency(struct v4l2_subdev *sd,
 {
struct msi001 *s = sd_to_msi001(sd);
unsigned int band;
-   dev_dbg(s-spi-dev, %s: tuner=%d type=%d frequency=%u\n,
-   __func__, f-tuner, f-type, f-frequency);
+
+   dev_dbg(s-spi-dev, tuner=%d type=%d frequency=%u\n,
+   f-tuner, f-type, f-frequency);
 
if (f-frequency  ((bands[0].rangehigh + bands[1].rangelow) / 2))
band = 0;
@@ -349,8 +352,9 @@ static int msi001_enum_freq_bands(struct v4l2_subdev *sd,
struct v4l2_frequency_band *band)
 {
struct msi001 *s = sd_to_msi001(sd);
-   dev_dbg(s-spi-dev, %s: tuner=%d type=%d index=%d\n,
-   __func__, band-tuner, band-type, band-index);
+
+   dev_dbg(s-spi-dev, tuner=%d type=%d index=%d\n,
+   band-tuner, band-type, 

[PATCH 12/12] rtl2832_sdr: logging changes

2014-08-25 Thread Antti Palosaari
Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832_sdr.c | 98 ++-
 1 file changed, 45 insertions(+), 53 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c 
b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 4f75753..e5bc993 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -396,8 +396,8 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
struct rtl2832_sdr_frame_buf *fbuf;
 
dev_dbg_ratelimited(s-udev-dev,
-   %s: status=%d length=%d/%d errors=%d\n,
-   __func__, urb-status, urb-actual_length,
+   status=%d length=%d/%d errors=%d\n,
+   urb-status, urb-actual_length,
urb-transfer_buffer_length, urb-error_count);
 
switch (urb-status) {
@@ -445,7 +445,7 @@ static int rtl2832_sdr_kill_urbs(struct rtl2832_sdr_state 
*s)
int i;
 
for (i = s-urbs_submitted - 1; i = 0; i--) {
-   dev_dbg(s-udev-dev, %s: kill urb=%d\n, __func__, i);
+   dev_dbg(s-udev-dev, kill urb=%d\n, i);
/* stop the URB */
usb_kill_urb(s-urb_list[i]);
}
@@ -459,7 +459,7 @@ static int rtl2832_sdr_submit_urbs(struct rtl2832_sdr_state 
*s)
int i, ret;
 
for (i = 0; i  s-urbs_initialized; i++) {
-   dev_dbg(s-udev-dev, %s: submit urb=%d\n, __func__, i);
+   dev_dbg(s-udev-dev, submit urb=%d\n, i);
ret = usb_submit_urb(s-urb_list[i], GFP_ATOMIC);
if (ret) {
dev_err(s-udev-dev,
@@ -479,8 +479,7 @@ static int rtl2832_sdr_free_stream_bufs(struct 
rtl2832_sdr_state *s)
if (s-flags  USB_STATE_URB_BUF) {
while (s-buf_num) {
s-buf_num--;
-   dev_dbg(s-udev-dev, %s: free buf=%d\n,
-   __func__, s-buf_num);
+   dev_dbg(s-udev-dev, free buf=%d\n, s-buf_num);
usb_free_coherent(s-udev, s-buf_size,
  s-buf_list[s-buf_num],
  s-dma_addr[s-buf_num]);
@@ -496,24 +495,22 @@ static int rtl2832_sdr_alloc_stream_bufs(struct 
rtl2832_sdr_state *s)
s-buf_num = 0;
s-buf_size = BULK_BUFFER_SIZE;
 
-   dev_dbg(s-udev-dev,
-   %s: all in all I will use %u bytes for streaming\n,
-   __func__,  MAX_BULK_BUFS * BULK_BUFFER_SIZE);
+   dev_dbg(s-udev-dev, all in all I will use %u bytes for streaming\n,
+   MAX_BULK_BUFS * BULK_BUFFER_SIZE);
 
for (s-buf_num = 0; s-buf_num  MAX_BULK_BUFS; s-buf_num++) {
s-buf_list[s-buf_num] = usb_alloc_coherent(s-udev,
BULK_BUFFER_SIZE, GFP_ATOMIC,
s-dma_addr[s-buf_num]);
if (!s-buf_list[s-buf_num]) {
-   dev_dbg(s-udev-dev, %s: alloc buf=%d failed\n,
-   __func__, s-buf_num);
+   dev_dbg(s-udev-dev, alloc buf=%d failed\n,
+   s-buf_num);
rtl2832_sdr_free_stream_bufs(s);
return -ENOMEM;
}
 
-   dev_dbg(s-udev-dev, %s: alloc buf=%d %p (dma %llu)\n,
-   __func__, s-buf_num,
-   s-buf_list[s-buf_num],
+   dev_dbg(s-udev-dev, alloc buf=%d %p (dma %llu)\n,
+   s-buf_num, s-buf_list[s-buf_num],
(long long)s-dma_addr[s-buf_num]);
s-flags |= USB_STATE_URB_BUF;
}
@@ -529,8 +526,7 @@ static int rtl2832_sdr_free_urbs(struct rtl2832_sdr_state 
*s)
 
for (i = s-urbs_initialized - 1; i = 0; i--) {
if (s-urb_list[i]) {
-   dev_dbg(s-udev-dev, %s: free urb=%d\n,
-   __func__, i);
+   dev_dbg(s-udev-dev, free urb=%d\n, i);
/* free the URBs */
usb_free_urb(s-urb_list[i]);
}
@@ -546,10 +542,10 @@ static int rtl2832_sdr_alloc_urbs(struct 
rtl2832_sdr_state *s)
 
/* allocate the URBs */
for (i = 0; i  MAX_BULK_BUFS; i++) {
-   dev_dbg(s-udev-dev, %s: alloc urb=%d\n, __func__, i);
+   dev_dbg(s-udev-dev, alloc urb=%d\n, i);
s-urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
if (!s-urb_list[i]) {
-   dev_dbg(s-udev-dev, %s: failed\n, __func__);
+   dev_dbg(s-udev-dev, failed\n);
for (j = 0; j  i; j++)
   

[PATCH 06/12] msi2500: logging changes

2014-08-25 Thread Antti Palosaari
Kernel logging system needs pointer to usb interface device in
order to print names and bus numbers properly. There was wrong
device pointer given and log printings wasn't correct.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/msi2500/msi2500.c | 157 +++-
 1 file changed, 66 insertions(+), 91 deletions(-)

diff --git a/drivers/media/usb/msi2500/msi2500.c 
b/drivers/media/usb/msi2500/msi2500.c
index 26b1334..5e3be0e 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -120,6 +120,7 @@ struct msi2500_frame_buf {
 };
 
 struct msi2500_state {
+   struct device *dev;
struct video_device vdev;
struct v4l2_device v4l2_dev;
struct v4l2_subdev *v4l2_subdev;
@@ -153,7 +154,6 @@ struct msi2500_state {
u32 next_sample; /* for track lost packets */
u32 sample; /* for sample rate calc */
unsigned long jiffies_next;
-   unsigned int sample_ctrl_bit[4];
 };
 
 /* Private functions */
@@ -269,7 +269,7 @@ static int msi2500_convert_stream(struct msi2500_state *s, 
u8 *dst, u8 *src,
sample[i] = src[3]  24 | src[2]  16 | src[1]  8 |
src[0]  0;
if (i == 0  s-next_sample != sample[0]) {
-   dev_dbg_ratelimited(s-udev-dev,
+   dev_dbg_ratelimited(s-dev,
%d samples lost, %d %08x:%08x\n,
sample[0] - s-next_sample,
src_len, s-next_sample, sample[0]);
@@ -279,7 +279,7 @@ static int msi2500_convert_stream(struct msi2500_state *s, 
u8 *dst, u8 *src,
 * Dump all unknown 'garbage' data - maybe we will discover
 * someday if there is something rational...
 */
-   dev_dbg_ratelimited(s-udev-dev, %*ph\n, 12, src[4]);
+   dev_dbg_ratelimited(s-dev, %*ph\n, 12, src[4]);
 
src += 16; /* skip header */
 
@@ -322,8 +322,7 @@ static int msi2500_convert_stream(struct msi2500_state *s, 
u8 *dst, u8 *src,
}
case MSI2500_PIX_FMT_SDR_MSI2500_384: /* 384 x IQ samples */
/* Dump unknown 'garbage' data */
-   dev_dbg_ratelimited(s-udev-dev,
-   %*ph\n, 24, src[1000]);
+   dev_dbg_ratelimited(s-dev, %*ph\n, 24, src[1000]);
memcpy(dst, src, 984);
src += 984 + 24;
dst += 984;
@@ -365,8 +364,7 @@ static int msi2500_convert_stream(struct msi2500_state *s, 
u8 *dst, u8 *src,
 
s-jiffies_next = jiffies + msecs_to_jiffies(MSECS);
s-sample = s-next_sample;
-   dev_dbg(s-udev-dev,
-   size=%u samples=%u msecs=%u sample rate=%lu\n,
+   dev_dbg(s-dev, size=%u samples=%u msecs=%u sample rate=%lu\n,
src_len, samples, msecs,
samples * 1000UL / msecs);
}
@@ -387,19 +385,16 @@ static void msi2500_isoc_handler(struct urb *urb)
 
if (unlikely(urb-status == -ENOENT || urb-status == -ECONNRESET ||
urb-status == -ESHUTDOWN)) {
-   dev_dbg(s-udev-dev, URB (%p) unlinked %ssynchronuously\n,
+   dev_dbg(s-dev, URB (%p) unlinked %ssynchronuously\n,
urb, urb-status == -ENOENT ?  : a);
return;
}
 
if (unlikely(urb-status != 0)) {
-   dev_dbg(s-udev-dev,
-   msi2500_isoc_handler() called with status 
%d\n,
-   urb-status);
+   dev_dbg(s-dev, called with status %d\n, urb-status);
/* Give up after a number of contiguous errors */
if (++s-isoc_errors  MAX_ISOC_ERRORS)
-   dev_dbg(s-udev-dev,
-   Too many ISOC errors, bailing out\n);
+   dev_dbg(s-dev, Too many ISOC errors, bailing out\n);
goto handler_end;
} else {
/* Reset ISOC error counter. We did get here, after all. */
@@ -413,7 +408,7 @@ static void msi2500_isoc_handler(struct urb *urb)
/* Check frame error */
fstatus = urb-iso_frame_desc[i].status;
if (unlikely(fstatus)) {
-   dev_dbg_ratelimited(s-udev-dev,
+   dev_dbg_ratelimited(s-dev,
frame=%d/%d has error %d skipping\n,
i, urb-number_of_packets, fstatus);
continue;
@@ -430,7 +425,7 @@ static void msi2500_isoc_handler(struct urb *urb)
fbuf = msi2500_get_next_fill_buf(s);
if (unlikely(fbuf == NULL)) {
 

[PATCH 04/12] airspy: remove unneeded spinlock irq flags initialization

2014-08-25 Thread Antti Palosaari
There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is a macro which stores value to 'flags'.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/airspy/airspy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index de9fc52..994c991 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -223,7 +223,7 @@ err:
 /* Private functions */
 static struct airspy_frame_buf *airspy_get_next_fill_buf(struct airspy *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
struct airspy_frame_buf *buf = NULL;
 
spin_lock_irqsave(s-queued_bufs_lock, flags);
@@ -446,7 +446,7 @@ static int airspy_alloc_urbs(struct airspy *s)
 /* Must be called with vb_queue_lock hold */
 static void airspy_cleanup_queued_bufs(struct airspy *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
 
dev_dbg(s-dev, \n);
 
@@ -506,7 +506,7 @@ static void airspy_buf_queue(struct vb2_buffer *vb)
struct airspy *s = vb2_get_drv_priv(vb-vb2_queue);
struct airspy_frame_buf *buf =
container_of(vb, struct airspy_frame_buf, vb);
-   unsigned long flags = 0;
+   unsigned long flags;
 
/* Check the device has not disconnected between prep and queuing */
if (unlikely(!s-udev)) {
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/12] e4000: logging changes

2014-08-25 Thread Antti Palosaari
Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/e4000.c | 71 
 1 file changed, 32 insertions(+), 39 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 90d9334..92fde76 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -26,7 +26,7 @@ static int e4000_init(struct dvb_frontend *fe)
struct e4000 *s = fe-tuner_priv;
int ret;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
/* dummy I2C to ensure I2C wakes up */
ret = regmap_write(s-regmap, 0x02, 0x40);
@@ -87,7 +87,7 @@ static int e4000_init(struct dvb_frontend *fe)
s-active = true;
 err:
if (ret)
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;
 }
@@ -97,7 +97,7 @@ static int e4000_sleep(struct dvb_frontend *fe)
struct e4000 *s = fe-tuner_priv;
int ret;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
s-active = false;
 
@@ -106,7 +106,7 @@ static int e4000_sleep(struct dvb_frontend *fe)
goto err;
 err:
if (ret)
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;
 }
@@ -121,9 +121,8 @@ static int e4000_set_params(struct dvb_frontend *fe)
u8 buf[5], i_data[4], q_data[4];
 
dev_dbg(s-client-dev,
-   %s: delivery_system=%d frequency=%u bandwidth_hz=%u\n,
-   __func__, c-delivery_system, c-frequency,
-   c-bandwidth_hz);
+   delivery_system=%d frequency=%u bandwidth_hz=%u\n,
+   c-delivery_system, c-frequency, c-bandwidth_hz);
 
/* gain control manual */
ret = regmap_write(s-regmap, 0x1a, 0x00);
@@ -150,9 +149,8 @@ static int e4000_set_params(struct dvb_frontend *fe)
buf[3] = 0x00;
buf[4] = e4000_pll_lut[i].div;
 
-   dev_dbg(s-client-dev,
-   %s: f_vco=%llu pll div=%d sigma_delta=%04x\n,
-   __func__, f_vco, buf[0], sigma_delta);
+   dev_dbg(s-client-dev, f_vco=%llu pll div=%d sigma_delta=%04x\n,
+   f_vco, buf[0], sigma_delta);
 
ret = regmap_bulk_write(s-regmap, 0x09, buf, 5);
if (ret)
@@ -253,7 +251,7 @@ static int e4000_set_params(struct dvb_frontend *fe)
goto err;
 err:
if (ret)
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;
 }
@@ -262,7 +260,7 @@ static int e4000_get_if_frequency(struct dvb_frontend *fe, 
u32 *frequency)
 {
struct e4000 *s = fe-tuner_priv;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
*frequency = 0; /* Zero-IF */
 
@@ -276,10 +274,9 @@ static int e4000_set_lna_gain(struct dvb_frontend *fe)
int ret;
u8 u8tmp;
 
-   dev_dbg(s-client-dev, %s: lna auto=%d-%d val=%d-%d\n,
-   __func__, s-lna_gain_auto-cur.val,
-   s-lna_gain_auto-val, s-lna_gain-cur.val,
-   s-lna_gain-val);
+   dev_dbg(s-client-dev, lna auto=%d-%d val=%d-%d\n,
+   s-lna_gain_auto-cur.val, s-lna_gain_auto-val,
+   s-lna_gain-cur.val, s-lna_gain-val);
 
if (s-lna_gain_auto-val  s-if_gain_auto-cur.val)
u8tmp = 0x17;
@@ -301,7 +298,7 @@ static int e4000_set_lna_gain(struct dvb_frontend *fe)
}
 err:
if (ret)
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;
 }
@@ -312,10 +309,9 @@ static int e4000_set_mixer_gain(struct dvb_frontend *fe)
int ret;
u8 u8tmp;
 
-   dev_dbg(s-client-dev, %s: mixer auto=%d-%d val=%d-%d\n,
-   __func__, s-mixer_gain_auto-cur.val,
-   s-mixer_gain_auto-val, s-mixer_gain-cur.val,
-   s-mixer_gain-val);
+   dev_dbg(s-client-dev, mixer auto=%d-%d val=%d-%d\n,
+   s-mixer_gain_auto-cur.val, s-mixer_gain_auto-val,
+   s-mixer_gain-cur.val, s-mixer_gain-val);
 
if (s-mixer_gain_auto-val)
u8tmp = 0x15;
@@ -333,7 +329,7 @@ static int e4000_set_mixer_gain(struct dvb_frontend *fe)
}
 err:
if (ret)
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
 
return ret;
 }
@@ -345,10 +341,9 @@ static int e4000_set_if_gain(struct dvb_frontend *fe)
u8 buf[2];
u8 u8tmp;
 

[PATCH 11/12] rtl2832_sdr: enhance sample rate debug calculation precision

2014-08-25 Thread Antti Palosaari
Sample rate calculation gives a little bit too large results because
in real life there was around one milliseconds (~one usb packet) too
much data for given time. Calculate time more accurate in order to
provide better results.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832_sdr.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c 
b/drivers/media/dvb-frontends/rtl2832_sdr.c
index ba305a0..4f75753 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -365,17 +365,19 @@ static unsigned int rtl2832_sdr_convert_stream(struct 
rtl2832_sdr_state *s,
dst_len = 0;
}
 
-   /* calculate samping rate and output it in 10 seconds intervals */
+   /* calculate sample rate and output it in 10 seconds intervals */
if (unlikely(time_is_before_jiffies(s-jiffies_next))) {
-#define MSECS 1UL
+   #define MSECS 1UL
+   unsigned int msecs = jiffies_to_msecs(jiffies -
+   s-jiffies_next + msecs_to_jiffies(MSECS));
unsigned int samples = s-sample - s-sample_measured;
 
s-jiffies_next = jiffies + msecs_to_jiffies(MSECS);
s-sample_measured = s-sample;
dev_dbg(s-udev-dev,
-   slen=%d samples=%u msecs=%lu sampling 
rate=%lu\n,
-   src_len, samples, MSECS,
-   samples * 1000UL / MSECS);
+   slen=%u samples=%u msecs=%u sample rate=%lu\n,
+   src_len, samples, msecs,
+   samples * 1000UL / msecs);
}
 
/* total number of I+Q pairs */
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/12] rtl2832_sdr: remove unneeded spinlock irq flags initialization

2014-08-25 Thread Antti Palosaari
There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is macro which stores value to 'flags'

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832_sdr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c 
b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 023e0f4..ba305a0 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -329,7 +329,7 @@ static int rtl2832_sdr_rd_reg_mask(struct rtl2832_sdr_state 
*s, u16 reg,
 static struct rtl2832_sdr_frame_buf *rtl2832_sdr_get_next_fill_buf(
struct rtl2832_sdr_state *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
struct rtl2832_sdr_frame_buf *buf = NULL;
 
spin_lock_irqsave(s-queued_bufs_lock, flags);
@@ -570,7 +570,7 @@ static int rtl2832_sdr_alloc_urbs(struct rtl2832_sdr_state 
*s)
 /* Must be called with vb_queue_lock hold */
 static void rtl2832_sdr_cleanup_queued_bufs(struct rtl2832_sdr_state *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
 
dev_dbg(s-udev-dev, %s:\n, __func__);
 
@@ -659,7 +659,7 @@ static void rtl2832_sdr_buf_queue(struct vb2_buffer *vb)
struct rtl2832_sdr_state *s = vb2_get_drv_priv(vb-vb2_queue);
struct rtl2832_sdr_frame_buf *buf =
container_of(vb, struct rtl2832_sdr_frame_buf, vb);
-   unsigned long flags = 0;
+   unsigned long flags;
 
/* Check the device has not disconnected between prep and queuing */
if (!s-udev) {
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/12] airspy: coding style issues

2014-08-25 Thread Antti Palosaari
Fix issues reported by checkpatch.pl.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/airspy/airspy.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index 56a1ae0..dee1fe2 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -255,6 +255,7 @@ static unsigned int airspy_convert_stream(struct airspy *s,
if (unlikely(time_is_before_jiffies(s-jiffies_next))) {
#define MSECS 1UL
unsigned int samples = s-sample - s-sample_measured;
+
s-jiffies_next = jiffies + msecs_to_jiffies(MSECS);
s-sample_measured = s-sample;
dev_dbg(s-udev-dev,
@@ -462,6 +463,7 @@ static void airspy_cleanup_queued_bufs(struct airspy *s)
spin_lock_irqsave(s-queued_bufs_lock, flags);
while (!list_empty(s-queued_bufs)) {
struct airspy_frame_buf *buf;
+
buf = list_entry(s-queued_bufs.next,
struct airspy_frame_buf, list);
list_del(buf-list);
@@ -772,6 +774,7 @@ static int airspy_g_frequency(struct file *file, void *priv,
 {
struct airspy *s = video_drvdata(file);
int ret  = 0;
+
dev_dbg(s-udev-dev, %s: tuner=%d type=%d\n,
__func__, f-tuner, f-type);
 
@@ -829,6 +832,7 @@ static int airspy_enum_freq_bands(struct file *file, void 
*priv,
 {
struct airspy *s = video_drvdata(file);
int ret;
+
dev_dbg(s-udev-dev, %s: tuner=%d type=%d index=%d\n,
__func__, band-tuner, band-type, band-index);
 
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/12] airspy: fix error handling on start streaming

2014-08-25 Thread Antti Palosaari
Free all reserved USB buffers and URBs on failure. Return all queued
buffers to vb2 with state queued on error case.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/airspy/airspy.c | 36 +---
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index cb0e515..56a1ae0 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -540,27 +540,49 @@ static int airspy_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 
mutex_lock(s-v4l2_lock);
 
-   set_bit(POWER_ON, s-flags);
-
s-sequence = 0;
 
+   set_bit(POWER_ON, s-flags);
+
ret = airspy_alloc_stream_bufs(s);
if (ret)
-   goto err;
+   goto err_clear_bit;
 
ret = airspy_alloc_urbs(s);
if (ret)
-   goto err;
+   goto err_free_stream_bufs;
 
ret = airspy_submit_urbs(s);
if (ret)
-   goto err;
+   goto err_free_urbs;
 
/* start hardware streaming */
ret = airspy_ctrl_msg(s, CMD_RECEIVER_MODE, 1, 0, NULL, 0);
if (ret)
-   goto err;
-err:
+   goto err_kill_urbs;
+
+   goto exit_mutex_unlock;
+
+err_kill_urbs:
+   airspy_kill_urbs(s);
+err_free_urbs:
+   airspy_free_urbs(s);
+err_free_stream_bufs:
+   airspy_free_stream_bufs(s);
+err_clear_bit:
+   clear_bit(POWER_ON, s-flags);
+
+   /* return all queued buffers to vb2 */
+   {
+   struct airspy_frame_buf *buf, *tmp;
+
+   list_for_each_entry_safe(buf, tmp, s-queued_bufs, list) {
+   list_del(buf-list);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_QUEUED);
+   }
+   }
+
+exit_mutex_unlock:
mutex_unlock(s-v4l2_lock);
 
return ret;
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/12] airspy: enhance sample rate debug calculation precision

2014-08-25 Thread Antti Palosaari
Sample rate calculation gives a little bit too large results because
in real life there was around one milliseconds (~one usb packet) too
much data for given time. Calculate time more accurate in order to
provide better results.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/airspy/airspy.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index 994c991..4069234 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -250,16 +250,18 @@ static unsigned int airspy_convert_stream(struct airspy 
*s,
dst_len = 0;
}
 
-   /* calculate samping rate and output it in 10 seconds intervals */
+   /* calculate sample rate and output it in 10 seconds intervals */
if (unlikely(time_is_before_jiffies(s-jiffies_next))) {
#define MSECS 1UL
+   unsigned int msecs = jiffies_to_msecs(jiffies -
+   s-jiffies_next + msecs_to_jiffies(MSECS));
unsigned int samples = s-sample - s-sample_measured;
 
s-jiffies_next = jiffies + msecs_to_jiffies(MSECS);
s-sample_measured = s-sample;
-   dev_dbg(s-dev, slen=%d samples=%u msecs=%lu sample 
rate=%lu\n,
-   src_len, samples, MSECS,
-   samples * 1000UL / MSECS);
+   dev_dbg(s-dev, slen=%u samples=%u msecs=%u sample rate=%lu\n,
+   src_len, samples, msecs,
+   samples * 1000UL / msecs);
}
 
/* total number of samples */
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/12] airspy: logging changes

2014-08-25 Thread Antti Palosaari
Kernel logging system needs pointer to usb interface device in
order to print names and bus numbers properly. There was wrong
device pointer given and log printings wasn't correct.

Remove some debug logging from v4l2 ioctl functions. v4l2 core debug
prints almost same information when enabled.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/airspy/airspy.c | 172 ++
 1 file changed, 61 insertions(+), 111 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index dee1fe2..de9fc52 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -107,6 +107,7 @@ struct airspy {
 #define USB_STATE_URB_BUF  (1  3)
unsigned long flags;
 
+   struct device *dev;
struct usb_device *udev;
struct video_device vdev;
struct v4l2_device v4l2_dev;
@@ -154,16 +155,15 @@ struct airspy {
unsigned int sample_measured;
 };
 
-#define airspy_dbg_usb_control_msg(_udev, _r, _t, _v, _i, _b, _l) { \
+#define airspy_dbg_usb_control_msg(_dev, _r, _t, _v, _i, _b, _l) { \
char *_direction; \
if (_t  USB_DIR_IN) \
_direction = ; \
else \
_direction = ; \
-   dev_dbg(_udev-dev, %s: %02x %02x %02x %02x %02x %02x %02x %02x  \
-   %s %*ph\n,  __func__, _t, _r, _v  0xff, _v  8, \
-   _i  0xff, _i  8, _l  0xff, _l  8, _direction, \
-   _l, _b); \
+   dev_dbg(_dev, %02x %02x %02x %02x %02x %02x %02x %02x %s %*ph\n, \
+   _t, _r, _v  0xff, _v  8, _i  0xff, _i  8, \
+   _l  0xff, _l  8, _direction, _l, _b); \
 }
 
 /* execute firmware command */
@@ -192,7 +192,7 @@ static int airspy_ctrl_msg(struct airspy *s, u8 request, 
u16 value, u16 index,
requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
break;
default:
-   dev_err(s-udev-dev, Unknown command %02x\n, request);
+   dev_err(s-dev, Unknown command %02x\n, request);
ret = -EINVAL;
goto err;
}
@@ -203,11 +203,10 @@ static int airspy_ctrl_msg(struct airspy *s, u8 request, 
u16 value, u16 index,
 
ret = usb_control_msg(s-udev, pipe, request, requesttype, value,
index, s-buf, size, 1000);
-   airspy_dbg_usb_control_msg(s-udev, request, requesttype, value,
+   airspy_dbg_usb_control_msg(s-dev, request, requesttype, value,
index, s-buf, size);
if (ret  0) {
-   dev_err(s-udev-dev,
-   usb_control_msg() failed %d request %02x\n,
+   dev_err(s-dev, usb_control_msg() failed %d request %02x\n,
ret, request);
goto err;
}
@@ -258,8 +257,7 @@ static unsigned int airspy_convert_stream(struct airspy *s,
 
s-jiffies_next = jiffies + msecs_to_jiffies(MSECS);
s-sample_measured = s-sample;
-   dev_dbg(s-udev-dev,
-   slen=%d samples=%u msecs=%lu sample 
rate=%lu\n,
+   dev_dbg(s-dev, slen=%d samples=%u msecs=%lu sample 
rate=%lu\n,
src_len, samples, MSECS,
samples * 1000UL / MSECS);
}
@@ -279,9 +277,8 @@ static void airspy_urb_complete(struct urb *urb)
struct airspy *s = urb-context;
struct airspy_frame_buf *fbuf;
 
-   dev_dbg_ratelimited(s-udev-dev,
-   %s: status=%d length=%d/%d errors=%d\n,
-   __func__, urb-status, urb-actual_length,
+   dev_dbg_ratelimited(s-dev, status=%d length=%d/%d errors=%d\n,
+   urb-status, urb-actual_length,
urb-transfer_buffer_length, urb-error_count);
 
switch (urb-status) {
@@ -293,8 +290,7 @@ static void airspy_urb_complete(struct urb *urb)
case -ESHUTDOWN:
return;
default:/* error */
-   dev_err_ratelimited(s-udev-dev, URB failed %d\n,
-   urb-status);
+   dev_err_ratelimited(s-dev, URB failed %d\n, urb-status);
break;
}
 
@@ -305,7 +301,7 @@ static void airspy_urb_complete(struct urb *urb)
fbuf = airspy_get_next_fill_buf(s);
if (unlikely(fbuf == NULL)) {
s-vb_full++;
-   dev_notice_ratelimited(s-udev-dev,
+   dev_notice_ratelimited(s-dev,
videobuf is full, %d packets 
dropped\n,
s-vb_full);
goto skip;
@@ -329,7 +325,7 @@ static int airspy_kill_urbs(struct airspy *s)
int i;
 
for (i = s-urbs_submitted - 1; i = 0; i--) {
-   dev_dbg(s-udev-dev, %s: kill urb=%d\n, 

[PATCH 08/12] msi2500: remove unneeded spinlock irq flags initialization

2014-08-25 Thread Antti Palosaari
There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is macro which stores value to 'flags'.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/msi2500/msi2500.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/msi2500/msi2500.c 
b/drivers/media/usb/msi2500/msi2500.c
index 5e3be0e..9e160e8 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -160,7 +160,7 @@ struct msi2500_state {
 static struct msi2500_frame_buf *msi2500_get_next_fill_buf(
struct msi2500_state *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
struct msi2500_frame_buf *buf = NULL;
 
spin_lock_irqsave(s-queued_bufs_lock, flags);
@@ -559,7 +559,7 @@ static int msi2500_isoc_init(struct msi2500_state *s)
 /* Must be called with vb_queue_lock hold */
 static void msi2500_cleanup_queued_bufs(struct msi2500_state *s)
 {
-   unsigned long flags = 0;
+   unsigned long flags;
 
dev_dbg(s-dev, \n);
 
@@ -635,7 +635,7 @@ static void msi2500_buf_queue(struct vb2_buffer *vb)
struct msi2500_state *s = vb2_get_drv_priv(vb-vb2_queue);
struct msi2500_frame_buf *buf =
container_of(vb, struct msi2500_frame_buf, vb);
-   unsigned long flags = 0;
+   unsigned long flags;
 
/* Check the device has not disconnected between prep and queuing */
if (unlikely(!s-udev)) {
-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Video4Linux GNU Radio plugin (gr-linuxsdr)

2014-08-25 Thread Antti Palosaari

Moikka!
For those who wants to play with Linux kernel SDR, here is GNU Radio 
plugin for it:

http://git.linuxtv.org/cgit.cgi/anttip/gr-linuxsdr.git/

It was earlier named as a gr-kernel, but I decided to rename it gr-linuxsdr.

My next plan is to implement library to cover kernel API and stream 
conversions, like libv4l2 does for webcams.


regards
Antti

--
http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] si2157: avoid firmware loading if it has been loaded previously

2014-08-25 Thread Olli Salonen
Add a variable into state to keep track if firmware has been loaded or not. 
Skip firmware loading in case it is already loaded (resume from sleep).

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 11 +--
 drivers/media/tuners/si2157_priv.h |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index c84f7b8..5901484 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -89,7 +89,10 @@ static int si2157_init(struct dvb_frontend *fe)
 
dev_dbg(s-client-dev, \n);
 
-   /* configure? */
+   if (s-fw_loaded)
+   goto warm;
+
+   /* power up */
memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
cmd.wlen = 15;
cmd.rlen = 1;
@@ -176,9 +179,12 @@ skip_fw_download:
if (ret)
goto err;
 
-   s-active = true;
+   s-fw_loaded = true;
 
+warm:
+   s-active = true;
return 0;
+
 err:
if (fw)
release_firmware(fw);
@@ -320,6 +326,7 @@ static int si2157_probe(struct i2c_client *client,
s-client = client;
s-fe = cfg-fe;
s-inversion = cfg-inversion;
+   s-fw_loaded = false;
mutex_init(s-i2c_mutex);
 
/* check if the tuner is there */
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 3ddab5e..4080a57 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -26,6 +26,7 @@ struct si2157 {
struct i2c_client *client;
struct dvb_frontend *fe;
bool active;
+   bool fw_loaded;
bool inversion;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] si2157: change command for sleep

2014-08-25 Thread Olli Salonen
Instead of sending command 13 to the tuner, send command 16 when sleeping. This 
behaviour is observed when using manufacturer provided binary-only Linux driver 
for TechnoTrend CT2-4400 (Windows driver does not do power management).

The issue with command 13 is that firmware loading is necessary after that. 
This is not an issue with tuners that do not require firmware, but resuming 
from sleep on an Si2158 takes noticeable time as firmware is loaded on resume.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index efb5cce..c84f7b8 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -197,9 +197,10 @@ static int si2157_sleep(struct dvb_frontend *fe)
 
s-active = false;
 
-   memcpy(cmd.args, \x13, 1);
-   cmd.wlen = 1;
-   cmd.rlen = 0;
+   /* standby */
+   memcpy(cmd.args, \x16\x00, 2);
+   cmd.wlen = 2;
+   cmd.rlen = 1;
ret = si2157_cmd_execute(s, cmd);
if (ret)
goto err;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] si2168: avoid firmware loading if it has been loaded previously

2014-08-25 Thread Olli Salonen
Add a variable to keep track if firmware is loaded or not and skip parts of the 
initialization if fw is already loaded. Resume from sleep with a different 
command compared to initial power up and run command 85 after resume command. 
This behaviour is observed when using manufacturer provided binary-only si2168 
driver for TechnoTrend CT2-4400.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c  | 31 ---
 drivers/media/dvb-frontends/si2168_priv.h |  1 +
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 55a4212..a0797fd 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -363,6 +363,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
dev_dbg(s-client-dev, \n);
 
+   /* initialize */
memcpy(cmd.args, 
\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00, 13);
cmd.wlen = 13;
cmd.rlen = 0;
@@ -370,6 +371,26 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   if (s-fw_loaded) {
+   /* resume */
+   memcpy(cmd.args, \xc0\x06\x08\x0f\x00\x20\x21\x01, 8);
+   cmd.wlen = 8;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   memcpy(cmd.args, \x85, 1);
+   cmd.wlen = 1;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   goto warm;
+   }
+
+   /* power up */
memcpy(cmd.args, \xc0\x06\x01\x0f\x00\x20\x20\x01, 8);
cmd.wlen = 8;
cmd.rlen = 1;
@@ -466,9 +487,6 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   dev_info(s-client-dev, found a '%s' in warm state\n,
-   si2168_ops.info.name);
-
/* set ts mode */
memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
cmd.args[4] |= s-ts_mode;
@@ -478,6 +496,12 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   s-fw_loaded = true;
+
+warm:
+   dev_info(s-client-dev, found a '%s' in warm state\n,
+   si2168_ops.info.name);
+
s-active = true;
 
return 0;
@@ -645,6 +669,7 @@ static int si2168_probe(struct i2c_client *client,
*config-i2c_adapter = s-adapter;
*config-fe = s-fe;
s-ts_mode = config-ts_mode;
+   s-fw_loaded = false;
 
i2c_set_clientdata(client, s);
 
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 0f83284..e13983e 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -36,6 +36,7 @@ struct si2168 {
fe_delivery_system_t delivery_system;
fe_status_t fe_status;
bool active;
+   bool fw_loaded;
u8 ts_mode;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


strange empia device

2014-08-25 Thread Lorenzo Marcantonio
Just bought a roxio video capture dongle. Read around that it was an
easycap clone (supported, then); it seems it's not so anymore :(

It identifies as 1b80:e31d Roxio Video Capture USB

(it also uses audio class for audio)

Now comes the funny thing. Inside there is the usual E2P memory,
a regulator or two and an empia marked EM2980 (*not* em2890!); some
passive and nothing else.

Digging around in the driver cab (emBDA.inf) shows that it seems an
em28285 driver rebranded by roxio... it installs emBDAA.sys and
emOEMA.sys (pretty big: about 1.5MB combined!); also a 16KB merlinFW.rom
(presumably a firmware for the em chip?  I tought they were fixed
function); also the usual directshow .ax filter and some exe in
autorun (emmona.exe: firmware/setup loader?).

Looking in the em28xx gave me the idea that that thing is not
supported (at least in my current 3.6.6)... however the empia sites says
(here http://www.empiatech.com/wp/video-grabber-em282xx/) 28284 should
be linux supported. Nothing said about 28285. And the chip is marked
2980?! by the way, forcing the driver to load I get this:

[ 3439.787701] em28xx: New device  Roxio Video Capture USB @ 480 Mbps 
(1b80:e31d, interface 0, class 0)
[ 3439.787704] em28xx: Video interface 0 found
[ 3439.787705] em28xx: DVB interface 0 found
[ 3439.787866] em28xx #0: em28xx chip ID = 146

Is there any hope to make it work (even on git kernel there is nothing
for chip id 146...)?

-- 
Lorenzo Marcantonio
Logos Srl
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Simon Horman
On Mon, Aug 25, 2014 at 02:59:46PM +0200, Geert Uytterhoeven wrote:
 Hi Mikhail,
 
 On Mon, Aug 25, 2014 at 2:35 PM, Mikhail Ulyanov
 mikhail.ulya...@cogentembedded.com wrote:
  +  - compatible: should containg one of the following:
  +   - renesas,jpu-r8a7790 for R-Car H2
  +   - renesas,jpu-r8a7791 for R-Car M2
  +   - renesas,jpu-gen2 for R-Car second generation
 
 Isn't renesas,jpu-gen2 meant as a fallback?
 
 I.e. the DTS should have one of '7790 and '7791, AND the gen2 fallback,
 so we can make the driver match against '7790 and '7791 is we find
 out about an incompatibility.

Is there a document that clearly states that there is such a thing
as jpu-gen2 in hardware? If not I would prefer not to add a binding for it.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Laurent Pinchart
Hi Simon,

On Tuesday 26 August 2014 08:57:20 Simon Horman wrote:
 On Mon, Aug 25, 2014 at 02:59:46PM +0200, Geert Uytterhoeven wrote:
  On Mon, Aug 25, 2014 at 2:35 PM, Mikhail Ulyanov wrote:
  
   +  - compatible: should containg one of the following:
   +   - renesas,jpu-r8a7790 for R-Car H2
   +   - renesas,jpu-r8a7791 for R-Car M2
   +   - renesas,jpu-gen2 for R-Car second generation
  
  Isn't renesas,jpu-gen2 meant as a fallback?
  
  I.e. the DTS should have one of '7790 and '7791, AND the gen2 fallback,
  so we can make the driver match against '7790 and '7791 is we find
  out about an incompatibility.
 
 Is there a document that clearly states that there is such a thing
 as jpu-gen2 in hardware? If not I would prefer not to add a binding for it.

How about going the other way around and requesting that document ?

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL stable] IT9135 changes

2014-08-25 Thread Antti Palosaari

Mauro,
Could you pull these and send to stable as tagged per each patch. That 
patch set mainly increases sensitivity of the IT9135 chipset. It must be 
considered as a regression because IT9135 driver was replaced by AF9035 
(USB IF) + AF9033 (DVB-T demod) + IT913x (RF tuner) drivers starting 
from kernel 3.15.


I did a bunch of measurements with IT9135AX and IT9135BX devices. 
Sensitivity increases around 5 dB.


I measured -81dBm for IT9135BX and -79dBm for IT9135AX. Windows driver 
performs a little bit better still - for both chip versions around -82dBm.


I didn't noticed any sensitivity difference between old and new firmware.

regards
Antti


The following changes since commit b250392f7b5062cf026b1423e27265e278fd6b30:

  [media] media: ttpci: fix av7110 build to be compatible with 
CONFIG_INPUT_EVDEV (2014-08-21 15:25:38 -0500)


are available in the git repository at:

  git://linuxtv.org/anttip/media_tree.git it9135_sensitivity_regression

for you to fetch changes up to 4a6845470d614a857c507c8f212c3d4b2c4b3dca:

  af9035: new IDs: add support for PCTV 78e and PCTV 79e (2014-08-26 
03:15:30 +0300)



Antti Palosaari (1):
  af9033: feed clock to RF tuner

Bimow Chen (2):
  af9033: update IT9135 tuner inittabs
  it913x: init tuner on attach

Malcolm Priestley (1):
  af9035: new IDs: add support for PCTV 78e and PCTV 79e

 drivers/media/dvb-core/dvb-usb-ids.h  |  2 ++
 drivers/media/dvb-frontends/af9033.c  | 13 +
 drivers/media/dvb-frontends/af9033_priv.h | 20 +---
 drivers/media/tuners/tuner_it913x.c   |  6 ++
 drivers/media/usb/dvb-usb-v2/af9035.c |  4 
 5 files changed, 34 insertions(+), 11 deletions(-)


--
http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: WARNINGS

2014-08-25 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Tue Aug 26 04:00:18 CEST 2014
git branch: test
git hash:   b250392f7b5062cf026b1423e27265e278fd6b30
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-20-g7abd8a7
host hardware:  x86_64
host os:3.16-0.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16-i686: OK
linux-3.17-rc1-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16-x86_64: OK
linux-3.17-rc1-x86_64: OK
apps: WARNINGS
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/6] devicetree: bindings: Document Renesas JPEG Processing Unit.

2014-08-25 Thread Simon Horman
On Tue, Aug 26, 2014 at 02:02:00AM +0200, Laurent Pinchart wrote:
 Hi Simon,
 
 On Tuesday 26 August 2014 08:57:20 Simon Horman wrote:
  On Mon, Aug 25, 2014 at 02:59:46PM +0200, Geert Uytterhoeven wrote:
   On Mon, Aug 25, 2014 at 2:35 PM, Mikhail Ulyanov wrote:
   
+  - compatible: should containg one of the following:
+   - renesas,jpu-r8a7790 for R-Car H2
+   - renesas,jpu-r8a7791 for R-Car M2
+   - renesas,jpu-gen2 for R-Car second generation
   
   Isn't renesas,jpu-gen2 meant as a fallback?
   
   I.e. the DTS should have one of '7790 and '7791, AND the gen2 fallback,
   so we can make the driver match against '7790 and '7791 is we find
   out about an incompatibility.
  
  Is there a document that clearly states that there is such a thing
  as jpu-gen2 in hardware? If not I would prefer not to add a binding for it.
 
 How about going the other way around and requesting that document ?

Good idea, I will make a request.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html