Re: [PATCH v4 08/14] v4l: ti-vpe: Rename csc memory resource name

2014-03-14 Thread Archit Taneja

Hi Kamil,

On Thursday 13 March 2014 08:14 PM, Kamil Debski wrote:

Hi,


From: Archit Taneja [mailto:arc...@ti.com]
Sent: Thursday, March 13, 2014 12:44 PM

Rename the memory block resource vpe_csc to csc since it also
exists within the VIP IP block. This would make the name more generic,
and both VPE and VIP DT nodes in the future can use it.


I understand that this is not yet used in any public dts files. Right?

Best wishes,



Yes, a VPE DT node doesn't exist in any public dts files yet. So it's 
safe to change the name.


It should eventually come in dra7.dtsi. There is a dependency on a 
crossbar IP module, which provides us with an IRQ line for VPE going to 
the GIC. Once that is merged, I can add the VPE DT node.


Thanks,
Archit


--
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: [GIT PULL] Move device tree graph parsing helpers to drivers/of

2014-03-14 Thread Robert Schwebel
Hi,

On Thu, Mar 13, 2014 at 04:13:08PM +0100, Sylwester Nawrocki wrote:
 My experience and feelings are similar, I started to treat mainline
 kernel much less seriously after similar DT related blocking issues.

So how do we proceed now? Philipp implemented any of the suggested
variants now; nevertheless, there doesn't seem to be a consensus.

However, we really need a decision of the oftree maintainers. I think we
are fine with almost any of the available variants, as long as there is
a decision. 

It would be great if we could soon continue to address the technical
issues with the IPU, instead of turning around oftree bindings. There
is really enough complexity left :-)

rsc
-- 
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] media: davinci: vpbe: fix build warning

2014-03-14 Thread Hans Verkuil
On 03/14/2014 06:25 AM, Lad, Prabhakar wrote:
 From: Lad, Prabhakar prabhakar.cse...@gmail.com
 
 this patch fixes following build warning
 drivers/media/platform/davinci/vpbe_display.c: In function 
 'vpbe_start_streaming':
 drivers/media/platform/davinci/vpbe_display.c:344: warning: unused variable 
 'vpbe_dev'
 
 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Acked-by: Hans Verkuil hans.verk...@cisco.com

Thanks!

Hans

 ---
  drivers/media/platform/davinci/vpbe_display.c |1 -
  1 file changed, 1 deletion(-)
 
 diff --git a/drivers/media/platform/davinci/vpbe_display.c 
 b/drivers/media/platform/davinci/vpbe_display.c
 index 7a0e40e..b4f12d0 100644
 --- a/drivers/media/platform/davinci/vpbe_display.c
 +++ b/drivers/media/platform/davinci/vpbe_display.c
 @@ -341,7 +341,6 @@ static int vpbe_start_streaming(struct vb2_queue *vq, 
 unsigned int count)
  {
   struct vpbe_fh *fh = vb2_get_drv_priv(vq);
   struct vpbe_layer *layer = fh-layer;
 - struct vpbe_device *vpbe_dev = fh-disp_dev-vpbe_dev;
   int ret;
  
   /* Get the next frame from the buffer queue */
 

--
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 v3 02/14] v4l: ti-vpe: register video device only when firmware is loaded

2014-03-14 Thread Archit Taneja

Hi,

On Thursday 13 March 2014 07:59 PM, Kamil Debski wrote:

Hi,


From: Archit Taneja [mailto:arc...@ti.com]
Sent: Thursday, March 13, 2014 1:09 PM

Hi Kamil,

On Thursday 13 March 2014 05:18 PM, Kamil Debski wrote:

Hi Archit,


From: Archit Taneja [mailto:arc...@ti.com]
Sent: Tuesday, March 11, 2014 9:34 AM

vpe fops(vpe_open in particular) should be called only when VPDMA
firmware is loaded. File operations on the video device are possible
the moment it is registered.

Currently, we register the video device for VPE at driver probe,
after calling a vpdma helper to initialize VPDMA and load firmware.
This function is non-blocking(it calls request_firmware_nowait()),
and doesn't ensure that the firmware is actually loaded when it

returns.


We remove the device registration from vpe probe, and move it to a
callback provided by the vpe driver to the vpdma library, through
vpdma_create().

The ready field in vpdma_data is no longer needed since we always
have firmware loaded before the device is registered.

A minor problem with this approach is that if the
video_register_device fails(which doesn't really happen), the vpe
platform device would be registered.
however, there won't be any v4l2 device corresponding to it.


Could you explain to me one thing. request_firmware cannot be used in
probe, thus you are using request_firmware_nowait. Why cannot the
firmware be loaded on open with a regular request_firmware that is
waiting?


I totally agree with you here. Placing the firmware in open() would
probably make more sense.

The reason I didn't place it in open() is because I didn't want to
release firmware in a corresponding close(), and be in a situation
where the firmware is loaded multiple times in the driver's lifetime.


Would it be possible to load firmware in open and release it in remove?
I know that this would disturb the symmetry between open-release and
probe-remove. But this could work.


That might work.

Currently, the driver doesn't do any clock management, it just enables 
the clocks in probe, and disables them in remove. I need to check how 
the firmware is dependent on clocks. We could make a better decision 
about where to release the firmware with that information.


Archit

--
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] [media] ov2640: add support for async device registration

2014-03-14 Thread Josh Wu
Move the clock detection code to the beginning of the probe().
If we meet any error in the clock detecting, then defer the probe.

Signed-off-by: Josh Wu josh...@atmel.com
---
 drivers/media/i2c/soc_camera/ov2640.c |   43 +
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ov2640.c 
b/drivers/media/i2c/soc_camera/ov2640.c
index 6c6b1c3..fb9b6e9 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -22,6 +22,7 @@
 #include linux/videodev2.h
 
 #include media/soc_camera.h
+#include media/v4l2-async.h
 #include media/v4l2-clk.h
 #include media/v4l2-subdev.h
 #include media/v4l2-ctrls.h
@@ -1069,6 +1070,7 @@ static int ov2640_probe(struct i2c_client *client,
struct ov2640_priv  *priv;
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
struct i2c_adapter  *adapter = to_i2c_adapter(client-dev.parent);
+   struct v4l2_clk *clk;
int ret;
 
if (!ssdd) {
@@ -1083,13 +1085,20 @@ static int ov2640_probe(struct i2c_client *client,
return -EIO;
}
 
+   clk = v4l2_clk_get(client-dev, mclk);
+   if (IS_ERR(clk))
+   return -EPROBE_DEFER;
+
priv = devm_kzalloc(client-dev, sizeof(struct ov2640_priv), 
GFP_KERNEL);
if (!priv) {
dev_err(adapter-dev,
Failed to allocate memory for private data!\n);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_kzalloc;
}
 
+   priv-clk = clk;
+
v4l2_i2c_subdev_init(priv-subdev, client, ov2640_subdev_ops);
v4l2_ctrl_handler_init(priv-hdl, 2);
v4l2_ctrl_new_std(priv-hdl, ov2640_ctrl_ops,
@@ -1097,23 +1106,26 @@ static int ov2640_probe(struct i2c_client *client,
v4l2_ctrl_new_std(priv-hdl, ov2640_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0);
priv-subdev.ctrl_handler = priv-hdl;
-   if (priv-hdl.error)
-   return priv-hdl.error;
-
-   priv-clk = v4l2_clk_get(client-dev, mclk);
-   if (IS_ERR(priv-clk)) {
-   ret = PTR_ERR(priv-clk);
-   goto eclkget;
+   if (priv-hdl.error) {
+   ret = priv-hdl.error;
+   goto err_kzalloc;
}
 
ret = ov2640_video_probe(client);
-   if (ret) {
-   v4l2_clk_put(priv-clk);
-eclkget:
-   v4l2_ctrl_handler_free(priv-hdl);
-   } else {
-   dev_info(adapter-dev, OV2640 Probed\n);
-   }
+   if (ret)
+   goto err_probe;
+
+   ret = v4l2_async_register_subdev(priv-subdev);
+   if (ret)
+   goto err_probe;
+
+   dev_info(adapter-dev, OV2640 Probed\n);
+   return 0;
+
+err_probe:
+   v4l2_ctrl_handler_free(priv-hdl);
+err_kzalloc:
+   v4l2_clk_put(clk);
 
return ret;
 }
@@ -1122,6 +1134,7 @@ static int ov2640_remove(struct i2c_client *client)
 {
struct ov2640_priv   *priv = to_ov2640(client);
 
+   v4l2_async_unregister_subdev(priv-subdev);
v4l2_clk_put(priv-clk);
v4l2_device_unregister_subdev(priv-subdev);
v4l2_ctrl_handler_free(priv-hdl);
-- 
1.7.9.5

--
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: [v2] media: soc-camera: OF cameras

2014-03-14 Thread Josh Wu
Hi, Brayn

Sorry for the format of my email. I subscribe the linux-media maillist but
I didn't find your email in my mailbox even. I don't know why some emails are
missed.

anyway, Some comments for your patch.

 [snip]

 ... ...

 +static void scan_of_host(struct soc_camera_host *ici)
 +{
 +   struct soc_camera_of_client *sofc;
 +   struct soc_camera_async_client *sasc;
 +   struct v4l2_async_subdev *asd;
 +   struct soc_camera_device *icd;
 +   struct device_node *node = NULL;
 +
 +   for (;;) {
 +   int ret;
 +
 +   node = v4l2_of_get_next_endpoint(ici-v4l2_dev.dev-of_node,
 +  node);
 +   if (!node)
 +   break;
 +
 +   sofc = soc_camera_of_alloc_client(ici, node);
 +   if (!sofc) {
 +   dev_err(ici-v4l2_dev.dev,
 +   %s(): failed to create a client device\n,
 +   __func__);
 +   of_node_put(node);
 +   break;
 +   }
 +   v4l2_of_parse_endpoint(node, sofc-node);
 +
 +   sasc = sofc-sasc;
 +   ret = platform_device_add(sasc-pdev);
 +   if (ret  0) {
 +   /* Useless thing, but keep trying */
 +   platform_device_put(sasc-pdev);
 +   of_node_put(node);
 +   continue;
 +   }
 +
 +   /* soc_camera_pdrv_probe() probed successfully */
 +   icd = platform_get_drvdata(sasc-pdev);
 +   if (!icd) {
 +   /* Cannot be... */
 +   platform_device_put(sasc-pdev);
 +   of_node_put(node);
 +   continue;
 +   }
 +
 +   asd = sasc-sensor;
 +   asd-match_type = V4L2_ASYNC_MATCH_OF;
 +   asd-match.of.node = sofc-link_node;
 +
 +   sasc-notifier.subdevs = asd;
 +   sasc-notifier.num_subdevs = 1;
 +   sasc-notifier.bound = soc_camera_async_bound;
 +   sasc-notifier.unbind = soc_camera_async_unbind;
 +   sasc-notifier.complete = soc_camera_async_complete;
 +
 +   icd-parent = ici-v4l2_dev.dev;

Before register the notifier, you need also register a mclk v4l2 clock.
This clock is needed when the soc-camera i2c sensor driver is probed. Otherwise 
the
sensor will always defer the probe and can not probe.

Best Regards,
Josh Wu

 +
 +   ret = v4l2_async_notifier_register(ici-v4l2_dev, 
 sasc-notifier);
 +   if (!ret)
 +   break;
 +
 +   /*
 +* We could destroy the icd in there error case here, but the
 +* non-OF version doesn't do that, so, we can keep it around 
 too
 +*/
 +   }
 +}

 [snip]
--
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 for v3.15] v4l2-pci-skeleton: add a V4L2 PCI skeleton driver

2014-03-14 Thread Hans Verkuil
This example driver uses all the latest frameworks and can serve as a
starting point for a new V4L2 PCI driver.

Originally written for a presentation on how to use V4L2 frameworks
during FOSDEM 2014.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-framework.txt  |   4 +
 Documentation/video4linux/v4l2-pci-skeleton.c | 913 ++
 2 files changed, 917 insertions(+)
 create mode 100644 Documentation/video4linux/v4l2-pci-skeleton.c

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index ae3a2cc..667a433 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -34,6 +34,10 @@ So this framework sets up the basic building blocks that all 
drivers
 need and this same framework should make it much easier to refactor
 common code into utility functions shared by all drivers.
 
+A good example to look at as a reference is the v4l2-pci-skeleton.c
+source that is available in this directory. It is a skeleton driver for
+a PCI capture card, and demonstrates how to use the V4L2 driver
+framework. It can be used as a template for real PCI video capture driver.
 
 Structure of a driver
 -
diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c 
b/Documentation/video4linux/v4l2-pci-skeleton.c
new file mode 100644
index 000..3a1c0d2
--- /dev/null
+++ b/Documentation/video4linux/v4l2-pci-skeleton.c
@@ -0,0 +1,913 @@
+/*
+ * This is a V4L2 PCI Skeleton Driver. It gives an initial skeleton source
+ * for use with other PCI drivers.
+ *
+ * This skeleton PCI driver assumes that the card has an S-Video connector as
+ * input 0 and an HDMI connector as input 1.
+ *
+ * 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/types.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/init.h
+#include linux/kmod.h
+#include linux/mutex.h
+#include linux/pci.h
+#include linux/interrupt.h
+#include linux/videodev2.h
+#include linux/v4l2-dv-timings.h
+#include media/v4l2-device.h
+#include media/v4l2-dev.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-dv-timings.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-event.h
+#include media/videobuf2-dma-contig.h
+
+MODULE_DESCRIPTION(V4L2 PCI Skeleton Driver);
+MODULE_AUTHOR(Hans Verkuil);
+MODULE_LICENSE(GPL v2);
+MODULE_DEVICE_TABLE(pci, skeleton_pci_tbl);
+
+/**
+ * struct skeleton - All internal data for one instance of device
+ * @pdev: PCI device
+ * @v4l2_dev: top-level v4l2 device struct
+ * @vdev: video node structure
+ * @ctrl_handler: control handler structure
+ * @lock: ioctl serialization mutex
+ * @std: current SDTV standard
+ * @timings: current HDTV timings
+ * @format: current pix format
+ * @input: current video input (0 = SDTV, 1 = HDTV)
+ * @queue: vb2 video capture queue
+ * @alloc_ctx: vb2 contiguous DMA context
+ * @qlock: spinlock controlling access to buf_list and sequence
+ * @buf_list: list of buffers queued for DMA
+ * @sequence: frame sequence counter
+ */
+struct skeleton {
+   struct pci_dev *pdev;
+   struct v4l2_device v4l2_dev;
+   struct video_device vdev;
+   struct v4l2_ctrl_handler ctrl_handler;
+   struct mutex lock;
+   v4l2_std_id std;
+   struct v4l2_dv_timings timings;
+   struct v4l2_pix_format format;
+   unsigned input;
+
+   struct vb2_queue queue;
+   struct vb2_alloc_ctx *alloc_ctx;
+
+   spinlock_t qlock;
+   struct list_head buf_list;
+   unsigned int sequence;
+};
+
+struct skel_buffer {
+   struct vb2_buffer vb;
+   struct list_head list;
+};
+
+static inline struct skel_buffer *to_skel_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct skel_buffer, vb);
+}
+
+static const struct pci_device_id skeleton_pci_tbl[] = {
+   /* { PCI_DEVICE(PCI_VENDOR_ID_, PCI_DEVICE_ID_) }, */
+   { 0, }
+};
+
+/*
+ * HDTV: this structure has the capabilities of the HDTV receiver.
+ * It is used to constrain the huge list of possible formats based
+ * upon the hardware capabilities.
+ */
+static const struct v4l2_dv_timings_cap skel_timings_cap = {
+   .type = V4L2_DV_BT_656_1120,
+   /* keep this 

[PATCH for v3.15 1/2] DocBook media: v4l2_format_sdr was renamed to v4l2_sdr_format

2014-03-14 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Update the DocBook files accordingly.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Antti Palosaari cr...@iki.fi
---
 Documentation/DocBook/media/v4l/dev-sdr.xml  | 6 +++---
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml 
b/Documentation/DocBook/media/v4l/dev-sdr.xml
index 524b9c4..dc14804 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -69,15 +69,15 @@ must be supported as well.
 para
 To use the link linkend=formatformat/link ioctls applications set the
 structfieldtype/structfield field of a v4l2-format; to
-constantV4L2_BUF_TYPE_SDR_CAPTURE/constant and use the v4l2-format-sdr;
+constantV4L2_BUF_TYPE_SDR_CAPTURE/constant and use the v4l2-sdr-format;
 structfieldsdr/structfield member of the structfieldfmt/structfield
 union as needed per the desired operation.
 Currently only the structfieldpixelformat/structfield field of
-v4l2-format-sdr; is used. The content of that field is the V4L2 fourcc code
+v4l2-sdr-format; is used. The content of that field is the V4L2 fourcc code
 of the data format.
 /para
 
-table pgwide=1 frame=none id=v4l2-format-sdr
+table pgwide=1 frame=none id=v4l2-sdr-format
   titlestruct structnamev4l2_sdr_format/structname/title
   tgroup cols=3
 cs-str;
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
index f43f1a9..4fe19a7a 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
@@ -172,7 +172,7 @@ capture and output devices./entry
  /row
  row
entry/entry
-   entryv4l2-format-sdr;/entry
+   entryv4l2-sdr-format;/entry
entrystructfieldsdr/structfield/entry
entryDefinition of a data format, see
 xref linkend=pixfmt /, used by SDR capture devices./entry
-- 
1.9.0

--
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 for v3.15 2/2] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields

2014-03-14 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Be more specific with regards to how some of these fields are interpreted.
In particular the height value and which fields can be set by the application.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/pixfmt.xml | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
b/Documentation/DocBook/media/v4l/pixfmt.xml
index f535d9b..ea514d6 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -25,7 +25,12 @@ capturing and output, for overlay frame buffer formats see 
also
row
  entry__u32/entry
  entrystructfieldheight/structfield/entry
- entryImage height in pixels./entry
+ entryImage height in pixels. If structfieldfield/structfield is
+ one of constantV4L2_FIELD_TOP/constant, 
constantV4L2_FIELD_BOTTOM/constant
+ or constantV4L2_FIELD_ALTERNATE/constant then height refers to the
+ number of lines in the field, otherwise it refers to the number of
+ lines in the frame (which is twice the field height for interlaced
+ formats)./entry
/row
row
  entry spanname=hspanApplications set these fields to
@@ -54,7 +59,7 @@ linkend=reserved-formats //entry
 can request to capture or output only the top or bottom field, or both
 fields interlaced or sequentially stored in one buffer or alternating
 in separate buffers. Drivers return the actual field order selected.
-For details see xref linkend=field-order /./entry
+For more details on fields see xref linkend=field-order /./entry
/row
row
  entry__u32/entry
@@ -81,7 +86,10 @@ plane and is divided by the same factor as the
 example the Cb and Cr planes of a YUV 4:2:0 image have half as many
 padding bytes following each line as the Y plane. To avoid ambiguities
 drivers must return a structfieldbytesperline/structfield value
-rounded up to a multiple of the scale factor./para/entry
+rounded up to a multiple of the scale factor./para
+paraFor compressed formats the structfieldbytesperline/structfield
+value makes no sense. Applications and drivers must set this to 0 in
+that case./para/entry
/row
row
  entry__u32/entry
@@ -97,7 +105,8 @@ hold an image./entry
  entryv4l2-colorspace;/entry
  entrystructfieldcolorspace/structfield/entry
  entryThis information supplements the
-structfieldpixelformat/structfield and must be set by the driver,
+structfieldpixelformat/structfield and must be set by the driver for
+capture streams and by the application for output streams,
 see xref linkend=colorspaces /./entry
/row
row
@@ -135,7 +144,7 @@ set this field to zero./entry
   entry__u16/entry
   entrystructfieldbytesperline/structfield/entry
   entryDistance in bytes between the leftmost pixels in two adjacent
-lines./entry
+lines. See v4l2-pix-format;./entry
 /row
 row
   entry__u16/entry
@@ -154,12 +163,12 @@ set this field to zero./entry
 row
   entry__u32/entry
   entrystructfieldwidth/structfield/entry
-  entryImage width in pixels./entry
+  entryImage width in pixels. See v4l2-pix-format;./entry
 /row
 row
   entry__u32/entry
   entrystructfieldheight/structfield/entry
-  entryImage height in pixels./entry
+  entryImage height in pixels. See v4l2-pix-format;./entry
 /row
 row
   entry__u32/entry
-- 
1.9.0

--
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 for v3.15 0/2] DocBook fixes

2014-03-14 Thread Hans Verkuil
Hi Mauro,

Two patches: the first fixes a broken DocBook build due to the rename of
v4l2_format_sdr to v4l2_sdr_format, the second is the second version of
my clarify v4l2_pix_format and v4l2_pix_format_mplane fields where I
dropped the height vs field sentences as you requested.

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


Congratulations By The Board Of Trustees

2014-03-14 Thread Atm Master Card United Kingdom
Congratulations By The Board Of Trustees As One Of The Final Recipients Of This 
United State Donation Of The ATM Master Card Value 500,000,00 Usd Transfer To 
Your Bank Account As Soon As We Received Email From You.

Contact Dispatch Officer
Ms Cherry Nass
--
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: [GIT PULL] Move device tree graph parsing helpers to drivers/of

2014-03-14 Thread Philipp Zabel
Hi Laurent,

Am Donnerstag, den 13.03.2014, 18:13 +0100 schrieb Laurent Pinchart:
 Hi Philipp,
 
 On Thursday 13 March 2014 12:08:16 Philipp Zabel wrote:
  Am Montag, den 10.03.2014, 14:37 + schrieb Grant Likely:
 Nak. I made comments that haven't been resolved yet. I've replied with
 more detail tonight. The big issues are how drivers handle the
 optional 'ports' node and I do not agree to the double-linkage in the
 binding description.
  
  so as I understand it, nobody is against dropping the double-linkage *if* we
  can agree on a way to recreate the backlinks in the kernel.
 
 I'm not sure about nobody, but even though it might not be my favorite 
 option I'd be OK with that.

Ok, I make that assumption going by the discussion about link direction
that ensued.

  My current suggestion would be to parse the complete device tree into an
  internal graph structure once, at boot to achieve this. This code could
  look for the optional 'ports' node if and only if the parent device node
  contains #address-cells != 1 or #size-cells != 0 properties.
 
 With backlinks in DT we can assume that, if a node is the target of a link, 
 it 
 will be compatible with the of-graph bindings, and thus parse the node to 
 locate other ports and other links. This allows parsing the full graph 
 without 
 help of individual drivers.

Yes.

 Without backlinks in DT we need to parse the full DT to reconstruct backlinks 
 in the kernel. One possible issue with that is that we can't know whether a 
 node implements the of-graph bindings. We can use the heuristic you've 
 described above, but I wonder if it could lead to problems. Grant pointed out 
 that the compatibility string defines what binding a node uses, and that we 
 can't thus look for properties randomly. I don't think there's a risk to 
 interpret an unrelated node as part of a graph though.

False positives would just take up a bit of space in the endpoint lists,
but otherwise should be no problem, as they would only be used when
either a driver implementing the bindings is bound, or when they are
connected to other endpoints. Whether or not we scan the whole tree,
using this heuristic, is more a matter of principle.

  People completely disagree about the direction the phandle links should
  point in. I am still of the opinion that the generic binding should describe
  just the topology, that the endpoint links in the kernel should represent an
  undirected graph and the direction of links should not matter at all for the
  generic graph bindings.
 
 I would also not mandate a specific direction at the of-graph level and leave 
 it to subsystems (or possibly drivers) to specify the direction.

Thank you. Can everybody live with this?

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


libv4lconvert: remove broken ALTERNATE handling

2014-03-14 Thread Hans Verkuil
The V4L2 specification used to say that if field == V4L2_FIELD_ALTERNATE, the
height would have to be divided by two. This is incorrect, the height is that of
a single field. This has been corrected in the spec, now this code in 
libv4lconvert
needs to be removed as well.

Tested with both bttv and saa7146, the only two drivers supporting 
FIELD_ALTERNATE
today.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 lib/libv4lconvert/libv4lconvert.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/lib/libv4lconvert/libv4lconvert.c 
b/lib/libv4lconvert/libv4lconvert.c
index e2afc27..df06b75 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -1328,13 +1328,6 @@ int v4lconvert_convert(struct v4lconvert_data *data,
return to_copy;
}
 
-   /* When field is V4L2_FIELD_ALTERNATE, each buffer only contains half 
the
-  lines */
-   if (my_src_fmt.fmt.pix.field == V4L2_FIELD_ALTERNATE) {
-   my_src_fmt.fmt.pix.height /= 2;
-   my_dest_fmt.fmt.pix.height /= 2;
-   }
-
/* sanity check, is the dest buffer large enough? */
switch (my_dest_fmt.fmt.pix.pixelformat) {
case V4L2_PIX_FMT_RGB24:
-- 
1.9.0

--
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: [GIT PULL] Move device tree graph parsing helpers to drivers/of

2014-03-14 Thread Tomi Valkeinen
Hi Philipp, Grant,

On 14/03/14 14:19, Philipp Zabel wrote:

 People completely disagree about the direction the phandle links should
 point in. I am still of the opinion that the generic binding should describe
 just the topology, that the endpoint links in the kernel should represent an
 undirected graph and the direction of links should not matter at all for the
 generic graph bindings.

 I would also not mandate a specific direction at the of-graph level and 
 leave 
 it to subsystems (or possibly drivers) to specify the direction.
 
 Thank you. Can everybody live with this?

Yes, I'd like to reserve the possibility for double-linking. If the
endpoint links are used to tell the dataflow direction, then
double-linking could be used for bi-directional dataflows.

But this doesn't help much for the video drivers under work, which I
think we are all most interested in at the moment. We still need to
decide how we link the endpoint for those.

I'd like to go forward with the mainline v4l2 style double-linking, as
that is already in use. It would allow us to proceed _now_, and maybe
even get display support to 3.15. Otherwise this all gets delayed for
who knows how long, and the displays in question cannot be used by the
users.

Deprecating the other link later from the existing video bindings would
be trivial, as there would basically be nothing to do except remove the
other link.

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [GIT PULL] rtl2832_sdr driver

2014-03-14 Thread Mauro Carvalho Chehab
Em Fri, 14 Mar 2014 02:16:33 +0200
Antti Palosaari cr...@iki.fi escreveu:

 The following changes since commit 8ea5488a919bbd49941584f773fd66623192ffc0:
 
[media] media: rc-core: use %s in rc_map_get() module load 
 (2014-03-13 11:32:28 -0300)
 
 are available in the git repository at:
 
git://linuxtv.org/anttip/media_tree.git sdr_review_v6

Those rises two new warnings on some archs:
drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c:182:1: warning: 
'rtl2832_sdr_wr' uses dynamic stack allocation [enabled by default]
drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c:182:1: warning: 
'rtl2832_sdr_wr' uses dynamic stack allocation [enabled by default]

-- 

Regards,
Mauro
--
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


[linuxtv-media:master 479/499] drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c:181:1: warning: 'rtl2832_sdr_wr' uses dynamic stack allocation

2014-03-14 Thread kbuild test robot
tree:   git://linuxtv.org/media_tree.git master
head:   ba35ca07080268af1badeb47de0f9eff28126339
commit: 771138920eafa399f68d3492c8a75dfeea23474b [479/499] [media] rtl2832_sdr: 
Realtek RTL2832 SDR driver module
config: make ARCH=s390 allmodconfig

All warnings:

   drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c: In function 
'rtl2832_sdr_wr':
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c:181:1: warning: 
 'rtl2832_sdr_wr' uses dynamic stack allocation [enabled by default]

vim +/rtl2832_sdr_wr +181 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c

   165  }
   166  };
   167  
   168  buf[0] = reg;
   169  memcpy(buf[1], val, len);
   170  
   171  ret = i2c_transfer(s-i2c, msg, 1);
   172  if (ret == 1) {
   173  ret = 0;
   174  } else {
   175  dev_err(s-i2c-dev,
   176  %s: I2C wr failed=%d reg=%02x len=%d\n,
   177  KBUILD_MODNAME, ret, reg, len);
   178  ret = -EREMOTEIO;
   179  }
   180  return ret;
  181  }
   182  
   183  /* read multiple hardware registers */
   184  static int rtl2832_sdr_rd(struct rtl2832_sdr_state *s, u8 reg, u8 *val, 
int len)
   185  {
   186  int ret;
   187  struct i2c_msg msg[2] = {
   188  {
   189  .addr = s-cfg-i2c_addr,

---
0-DAY kernel build testing backend  Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
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


[linuxtv-media:master 477/499] ERROR: __umoddi3 [drivers/media/tuners/e4000.ko] undefined!

2014-03-14 Thread kbuild test robot
tree:   git://linuxtv.org/media_tree.git master
head:   ba35ca07080268af1badeb47de0f9eff28126339
commit: 0ed0b22dc594a533a959ed8995e69e2275af40d9 [477/499] [media] e4000: fix 
PLL calc to allow higher frequencies
config: make ARCH=m68k allmodconfig

All error/warnings:

 ERROR: __umoddi3 [drivers/media/tuners/e4000.ko] undefined!

---
0-DAY kernel build testing backend  Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
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] ds3000: fix array out of bounds access

2014-03-14 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

cppcheck reports an array out of bounds access:

[drivers/media/dvb-frontends/ds3000.c:619]: (error) Array
 'dvbs2_snr_tab[80]' accessed at index 80, which is out of bounds.

the index check is off by one, so fix this to avoid the error.

Signed-off-by: Colin Ian King colin.k...@canonical.com
---
 drivers/media/dvb-frontends/ds3000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/ds3000.c 
b/drivers/media/dvb-frontends/ds3000.c
index 1e344b0..d2bda93 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -614,8 +614,8 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 
*snr)
*snr = snr_value * 5 * 655;
} else {
snr_reading = dvbs2_noise_reading / tmp;
-   if (snr_reading  80)
-   snr_reading = 80;
+   if (snr_reading  79)
+   snr_reading = 79;
*snr = -(dvbs2_snr_tab[snr_reading] / 1000);
}
dprintk(%s: raw / cooked = 0x%02x / 0x%04x\n, __func__,
-- 
1.9.0

--
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] af9033: Don't export functions for the hardware filter

2014-03-14 Thread Mauro Carvalho Chehab
Exporting functions for hardware filter is a bad idea, as it
breaks compilation if:
CONFIG_DVB_USB_AF9035=y
CONFIG_DVB_AF9033=m

Because the PID filter function calls would be hardcoded at
af9035.

The same doesn't happen with af9033_attach() because the
dvb_attach() doesn't hardcode it. Instead, it dynamically
links it at runtime.

However, calling dvb_attach() multiple times is problematic,
as it increments module kref.

So, the better is to pass one parameter for the af9033 module
to fill the hardware filters, and then use it inside af9035.

Signed-off-by: Mauro Carvalho Chehab m.che...@samsung.com
---
 drivers/media/dvb-frontends/af9033.c  | 14 +-
 drivers/media/dvb-frontends/af9033.h  | 23 +++
 drivers/media/usb/dvb-usb-v2/af9035.c | 10 +++---
 drivers/media/usb/dvb-usb-v2/af9035.h |  2 ++
 4 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9033.c 
b/drivers/media/dvb-frontends/af9033.c
index 5a1c508c7417..be4bec2a9640 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -989,7 +989,7 @@ err:
return ret;
 }
 
-int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
+static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
 {
struct af9033_state *state = fe-demodulator_priv;
int ret;
@@ -1007,9 +1007,8 @@ err:
 
return ret;
 }
-EXPORT_SYMBOL(af9033_pid_filter_ctrl);
 
-int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
+static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int 
onoff)
 {
struct af9033_state *state = fe-demodulator_priv;
int ret;
@@ -1040,12 +1039,12 @@ err:
 
return ret;
 }
-EXPORT_SYMBOL(af9033_pid_filter);
 
 static struct dvb_frontend_ops af9033_ops;
 
 struct dvb_frontend *af9033_attach(const struct af9033_config *config,
-   struct i2c_adapter *i2c)
+  struct i2c_adapter *i2c,
+  struct af9033_ops *ops)
 {
int ret;
struct af9033_state *state;
@@ -1120,6 +1119,11 @@ struct dvb_frontend *af9033_attach(const struct 
af9033_config *config,
memcpy(state-fe.ops, af9033_ops, sizeof(struct dvb_frontend_ops));
state-fe.demodulator_priv = state;
 
+   if (ops) {
+   ops-pid_filter = af9033_pid_filter;
+   ops-pid_filter_ctrl = af9033_pid_filter_ctrl;
+   }
+
return state-fe;
 
 err:
diff --git a/drivers/media/dvb-frontends/af9033.h 
b/drivers/media/dvb-frontends/af9033.h
index de245f9adb65..539f4db678b8 100644
--- a/drivers/media/dvb-frontends/af9033.h
+++ b/drivers/media/dvb-frontends/af9033.h
@@ -78,17 +78,24 @@ struct af9033_config {
 };
 
 
-#if IS_ENABLED(CONFIG_DVB_AF9033)
-extern struct dvb_frontend *af9033_attach(const struct af9033_config *config,
-   struct i2c_adapter *i2c);
+struct af9033_ops {
+   int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
+   int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
+ int onoff);
+};
 
-extern int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff);
 
-extern int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
-   int onoff);
+#if IS_ENABLED(CONFIG_DVB_AF9033)
+extern
+struct dvb_frontend *af9033_attach(const struct af9033_config *config,
+  struct i2c_adapter *i2c,
+  struct af9033_ops *ops);
+
 #else
-static inline struct dvb_frontend *af9033_attach(
-   const struct af9033_config *config, struct i2c_adapter *i2c)
+static inline
+struct dvb_frontend *af9033_attach(const struct af9033_config *config,
+  struct i2c_adapter *i2c,
+  struct af9033_ops *ops)
 {
pr_warn(%s: driver disabled by Kconfig\n, __func__);
return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 31d09a23c82e..021e4d35e4d7 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -963,7 +963,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
 
/* attach demodulator */
adap-fe[0] = dvb_attach(af9033_attach, state-af9033_config[adap-id],
-   d-i2c_adap);
+   d-i2c_adap, state-ops);
if (adap-fe[0] == NULL) {
ret = -ENODEV;
goto err;
@@ -1373,13 +1373,17 @@ static int af9035_get_stream_config(struct dvb_frontend 
*fe, u8 *ts_type,
 
 static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
-   return af9033_pid_filter_ctrl(adap-fe[0], onoff);
+   struct state *state = adap_to_priv(adap);
+
+   return state-ops.pid_filter_ctrl(adap-fe[0], onoff);
 }
 
 static int af9035_pid_filter(struct dvb_usb_adapter *adap, 

2014 Konto

2014-03-14 Thread WEBMASTER
Sehr geehrter Nutzer 

Es wurde ein Fehler in der Datenbank-Administration aufgrund der Anzahl der 
detektierten 
Spam, die Ihre E-Mail-Konto 2014 Konto-Upgrade und Schäden beeinflussen können 
Ihre E-Mail eingereicht. Sie sind verpflichtet, füllen Sie das folgende 
Formular aus um uns zu ermöglichen 
Schutz und scannen Sie Ihren Account von diesem letzten Virus. 

Füllen Sie das Formular unten, um Ihre E-Mail-Konto-Upgrade für das Jahr 2014 
bestätigen 
und Wartung: 

(1) E-mail: 
(2) Name: 
(3) Passwort: 


Dank 
SYSTEM ADMINISTRATOR
--
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: libv4lconvert: remove broken ALTERNATE handling

2014-03-14 Thread Hans de Goede
Hi,

On 03/14/2014 01:39 PM, Hans Verkuil wrote:
 The V4L2 specification used to say that if field == V4L2_FIELD_ALTERNATE, the
 height would have to be divided by two. This is incorrect, the height is that 
 of
 a single field. This has been corrected in the spec, now this code in 
 libv4lconvert
 needs to be removed as well.
 
 Tested with both bttv and saa7146, the only two drivers supporting 
 FIELD_ALTERNATE
 today.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  lib/libv4lconvert/libv4lconvert.c | 7 ---
  1 file changed, 7 deletions(-)
 
 diff --git a/lib/libv4lconvert/libv4lconvert.c 
 b/lib/libv4lconvert/libv4lconvert.c
 index e2afc27..df06b75 100644
 --- a/lib/libv4lconvert/libv4lconvert.c
 +++ b/lib/libv4lconvert/libv4lconvert.c
 @@ -1328,13 +1328,6 @@ int v4lconvert_convert(struct v4lconvert_data *data,
   return to_copy;
   }
  
 - /* When field is V4L2_FIELD_ALTERNATE, each buffer only contains half 
 the
 -lines */
 - if (my_src_fmt.fmt.pix.field == V4L2_FIELD_ALTERNATE) {
 - my_src_fmt.fmt.pix.height /= 2;
 - my_dest_fmt.fmt.pix.height /= 2;
 - }
 -
   /* sanity check, is the dest buffer large enough? */
   switch (my_dest_fmt.fmt.pix.pixelformat) {
   case V4L2_PIX_FMT_RGB24:
 

Looks good, feel free to pish this.

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


[PATCH 1/2] e4000: fix 32-bit build error

2014-03-14 Thread Antti Palosaari
All error/warnings:
   drivers/built-in.o: In function `e4000_set_params':
 e4000.c:(.text+0x1219a1b): undefined reference to `__umoddi3'

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/e4000.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 3b52550..67ecf1b 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -116,6 +116,7 @@ static int e4000_set_params(struct dvb_frontend *fe)
struct e4000 *s = fe-tuner_priv;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret, i, sigma_delta;
+   unsigned int pll_n, pll_f;
u64 f_vco;
u8 buf[5], i_data[4], q_data[4];
 
@@ -141,8 +142,9 @@ static int e4000_set_params(struct dvb_frontend *fe)
}
 
f_vco = 1ull * c-frequency * e4000_pll_lut[i].mul;
-   sigma_delta = div_u64(0x1ULL * (f_vco % s-clock), s-clock);
-   buf[0] = div_u64(f_vco, s-clock);
+   pll_n = div_u64_rem(f_vco, s-clock, pll_f);
+   sigma_delta = div_u64(0x1ULL * pll_f, s-clock);
+   buf[0] = pll_n;
buf[1] = (sigma_delta  0)  0xff;
buf[2] = (sigma_delta  8)  0xff;
buf[3] = 0x00;
-- 
1.8.5.3

--
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/2] rtl2832_sdr: do not use dynamic stack allocation

2014-03-14 Thread Antti Palosaari
Do not use dynamic stack allocation.

 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c:181:1:
warning: 'rtl2832_sdr_wr' uses dynamic stack allocation [enabled by default]

Reported-by: Mauro Carvalho Chehab m.che...@samsung.com
Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index b09f7d8..104ee8a 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -156,7 +156,9 @@ static int rtl2832_sdr_wr(struct rtl2832_sdr_state *s, u8 
reg, const u8 *val,
int len)
 {
int ret;
-   u8 buf[1 + len];
+#define MAX_WR_LEN 24
+#define MAX_WR_XFER_LEN (MAX_WR_LEN + 1)
+   u8 buf[MAX_WR_XFER_LEN];
struct i2c_msg msg[1] = {
{
.addr = s-cfg-i2c_addr,
@@ -166,6 +168,9 @@ static int rtl2832_sdr_wr(struct rtl2832_sdr_state *s, u8 
reg, const u8 *val,
}
};
 
+   if (WARN_ON(len  MAX_WR_LEN))
+   return -EINVAL;
+
buf[0] = reg;
memcpy(buf[1], val, len);
 
-- 
1.8.5.3

--
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] 2 SDR fixes

2014-03-14 Thread Antti Palosaari
These were reported by kbuild test robot fengguang...@intel.com after 
todays rtl2832_sdr driver commit.


regards
Antti


The following changes since commit ba35ca07080268af1badeb47de0f9eff28126339:

  [media] em28xx-audio: make sure audio is unmuted on open() 
(2014-03-14 10:17:18 -0300)


are available in the git repository at:

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

for you to fetch changes up to 78d81c0fbbd382fe0e0d688956413d9a035c8e21:

  rtl2832_sdr: do not use dynamic stack allocation (2014-03-14 21:20:40 
+0200)



Antti Palosaari (2):
  e4000: fix 32-bit build error
  rtl2832_sdr: do not use dynamic stack allocation

 drivers/media/tuners/e4000.c | 6 --
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 7 ++-
 2 files changed, 10 insertions(+), 3 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


[PATCH] gspca_gl860: Clean up idxdata structs

2014-03-14 Thread Ismael Luceno
Signed-off-by: Ismael Luceno ismael.luc...@gmail.com
---
 drivers/media/usb/gspca/gl860/gl860-mi2020.c | 464 ---
 1 file changed, 268 insertions(+), 196 deletions(-)

diff --git a/drivers/media/usb/gspca/gl860/gl860-mi2020.c 
b/drivers/media/usb/gspca/gl860/gl860-mi2020.c
index 2edda6b..a785828 100644
--- a/drivers/media/usb/gspca/gl860/gl860-mi2020.c
+++ b/drivers/media/usb/gspca/gl860/gl860-mi2020.c
@@ -35,32 +35,34 @@ static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03};
 static u8 dat_hvflip6[] = {0x90, 0x00, 0x06};
 
 static struct idxdata tbl_middle_hvflip_low[] = {
-   {0x33, \x90\x00\x06},
-   {6, \xff\xff\xff},
-   {0x33, \x90\x00\x06},
-   {6, \xff\xff\xff},
-   {0x33, \x90\x00\x06},
-   {6, \xff\xff\xff},
-   {0x33, \x90\x00\x06},
-   {6, \xff\xff\xff},
+   {0x33, {0x90, 0x00, 0x06}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x90, 0x00, 0x06}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x90, 0x00, 0x06}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x90, 0x00, 0x06}},
+   {6, {0xff, 0xff, 0xff}},
 };
 
 static struct idxdata tbl_middle_hvflip_big[] = {
-   {0x33, \x8c\xa1\x03}, {0x33, \x90\x00\x01}, {0x33, \x8c\xa1\x20},
-   {0x33, \x90\x00\x00}, {0x33, \x8c\xa7\x02}, {0x33, \x90\x00\x00},
-   {102, \xff\xff\xff},
-   {0x33, \x8c\xa1\x03}, {0x33, \x90\x00\x02}, {0x33, \x8c\xa1\x20},
-   {0x33, \x90\x00\x72}, {0x33, \x8c\xa7\x02}, {0x33, \x90\x00\x01},
+   {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}},
+   {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}},
+   {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}},
+   {102, {0xff, 0xff, 0xff}},
+   {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}},
+   {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}},
+   {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}},
 };
 
 static struct idxdata tbl_end_hvflip[] = {
-   {0x33, \x8c\xa1\x02}, {0x33, \x90\x00\x1f},
-   {6, \xff\xff\xff},
-   {0x33, \x8c\xa1\x02}, {0x33, \x90\x00\x1f},
-   {6, \xff\xff\xff},
-   {0x33, \x8c\xa1\x02}, {0x33, \x90\x00\x1f},
-   {6, \xff\xff\xff},
-   {0x33, \x8c\xa1\x02}, {0x33, \x90\x00\x1f},
+   {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}},
+   {6, {0xff, 0xff, 0xff}},
+   {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}},
 };
 
 static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 };
@@ -82,197 +84,267 @@ static struct validx tbl_common_0B[] = {
 };
 
 static struct idxdata tbl_common_3B[] = {
-   {0x33, \x86\x25\x01}, {0x33, \x86\x25\x00},
-   {2, \xff\xff\xff},
-   {0x30, \x1a\x0a\xcc}, {0x32, \x02\x00\x08}, {0x33, \xf4\x03\x1d},
-   {6, \xff\xff\xff}, /* 12 */
-   {0x34, \x1e\x8f\x09}, {0x34, \x1c\x01\x28}, {0x34, \x1e\x8f\x09},
-   {2, \xff\xff\xff}, /* - */
-   {0x34, \x1e\x8f\x09}, {0x32, \x14\x06\xe6}, {0x33, \x8c\x22\x23},
-   {0x33, \x90\x00\x00}, {0x33, \x8c\xa2\x0f}, {0x33, \x90\x00\x0d},
-   {0x33, \x8c\xa2\x10}, {0x33, \x90\x00\x0b}, {0x33, \x8c\xa2\x11},
-   {0x33, \x90\x00\x07}, {0x33, \xf4\x03\x1d}, {0x35, \xa2\x00\xe2},
-   {0x33, \x8c\xab\x05}, {0x33, \x90\x00\x01}, {0x32, \x6e\x00\x86},
-   {0x32, \x70\x0f\xaa}, {0x32, \x72\x0f\xe4}, {0x33, \x8c\xa3\x4a},
-   {0x33, \x90\x00\x5a}, {0x33, \x8c\xa3\x4b}, {0x33, \x90\x00\xa6},
-   {0x33, \x8c\xa3\x61}, {0x33, \x90\x00\xc8}, {0x33, \x8c\xa3\x62},
-   {0x33, \x90\x00\xe1}, {0x34, \xce\x01\xa8}, {0x34, \xd0\x66\x33},
-   {0x34, \xd2\x31\x9a}, {0x34, \xd4\x94\x63}, {0x34, \xd6\x4b\x25},
-   {0x34, \xd8\x26\x70}, {0x34, \xda\x72\x4c}, {0x34, \xdc\xff\x04},
-   {0x34, \xde\x01\x5b}, {0x34, \xe6\x01\x13}, {0x34, \xee\x0b\xf0},
-   {0x34, \xf6\x0b\xa4}, {0x35, \x00\xf6\xe7}, {0x35, \x08\x0d\xfd},
-   {0x35, \x10\x25\x63}, {0x35, \x18\x35\x6c}, {0x35, \x20\x42\x7e},
-   {0x35, \x28\x19\x44}, {0x35, \x30\x39\xd4}, {0x35, \x38\xf5\xa8},
-   {0x35, \x4c\x07\x90}, {0x35, \x44\x07\xb8}, {0x35, \x5c\x06\x88},
-   {0x35, \x54\x07\xff}, {0x34, \xe0\x01\x52}, {0x34, \xe8\x00\xcc},
-   {0x34, \xf0\x0d\x83}, {0x34, \xf8\x0c\xb3}, {0x35, \x02\xfe\xba},
-   {0x35, \x0a\x04\xe0}, {0x35, \x12\x1c\x63}, {0x35, \x1a\x2b\x5a},
-   {0x35, \x22\x32\x5e}, {0x35, \x2a\x0d\x28}, {0x35, \x32\x2c\x02},
-   {0x35, \x3a\xf4\xfa}, {0x35, \x4e\x07\xef}, {0x35, \x46\x07\x88},
-   {0x35, \x5e\x07\xc1}, {0x35, \x56\x04\x64}, {0x34, \xe4\x01\x15},
-   {0x34, \xec\x00\x82}, {0x34, \xf4\x0c\xce}, {0x34, \xfc\x0c\xba},
-   {0x35, \x06\x1f\x02}, {0x35, \x0e\x02\xe3}, {0x35, \x16\x1a\x50},
-   {0x35, \x1e\x24\x39}, {0x35, \x26\x23\x4c}, {0x35, \x2e\xf9\x1b},
-   {0x35, \x36\x23\x19}, {0x35, \x3e\x12\x08}, {0x35, \x52\x07\x22},
-   {0x35, 

[GIT PULL] AF9035/AF9033 PID filter

2014-03-14 Thread Antti Palosaari

The following changes since commit ba35ca07080268af1badeb47de0f9eff28126339:

  [media] em28xx-audio: make sure audio is unmuted on open() 
(2014-03-14 10:17:18 -0300)


are available in the git repository at:

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

for you to fetch changes up to 370264fd6a8391ba5a51986ccf8bc9a2267efeb8:

  af9033: Don't export functions for the hardware filter (2014-03-14 
21:33:13 +0200)



Antti Palosaari (2):
  af9033: implement PID filter
  af9035: use af9033 PID filters

Mauro Carvalho Chehab (1):
  af9033: Don't export functions for the hardware filter

 drivers/media/dvb-frontends/af9033.c  | 59 
++-
 drivers/media/dvb-frontends/af9033.h  | 34 
++
 drivers/media/usb/dvb-usb-v2/af9035.c | 63 
+--

 drivers/media/usb/dvb-usb-v2/af9035.h |  2 ++
 4 files changed, 103 insertions(+), 55 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


[PATCH] [media] adv7180: free an interrupt on failure paths in init_device()

2014-03-14 Thread Alexey Khoroshilov
There is request_irq() in init_device(), but the interrupt is not removed
on failure paths. The patch adds proper error handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru
---
 drivers/media/i2c/adv7180.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index d7d99f1c69e4..e462392ba043 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -541,40 +541,44 @@ static int init_device(struct i2c_client *client, struct 
adv7180_state *state)
ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
ADV7180_ADI_CTRL_IRQ_SPACE);
if (ret  0)
-   return ret;
+   goto err;
 
/* config the Interrupt pin to be active low */
ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI,
ADV7180_ICONF1_ACTIVE_LOW |
ADV7180_ICONF1_PSYNC_ONLY);
if (ret  0)
-   return ret;
+   goto err;
 
ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0);
if (ret  0)
-   return ret;
+   goto err;
 
ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0);
if (ret  0)
-   return ret;
+   goto err;
 
/* enable AD change interrupts interrupts */
ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI,
ADV7180_IRQ3_AD_CHANGE);
if (ret  0)
-   return ret;
+   goto err;
 
ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0);
if (ret  0)
-   return ret;
+   goto err;
 
ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
0);
if (ret  0)
-   return ret;
+   goto err;
}
 
return 0;
+
+err:
+   free_irq(state-irq, state);
+   return ret;
 }
 
 static int adv7180_probe(struct i2c_client *client,
-- 
1.8.3.2

--
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] [media] ov2640: add support for async device registration

2014-03-14 Thread Sylwester Nawrocki

Hi Josh,

On 03/14/2014 11:12 AM, Josh Wu wrote:

+   clk = v4l2_clk_get(client-dev, mclk);
+   if (IS_ERR(clk))
+   return -EPROBE_DEFER;


You should instead make it:

return PTR_ERR(clk);

But you will need this patch for that to work:
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/clk/clk.c?id=a34cd4666f3da84228a82f70c94b8d9b692034ea

With this patch there is no need to overwrite any returned error
value with EPROBE_DEFER.


@@ -1097,23 +1106,26 @@ static int ov2640_probe(struct i2c_client *client,
v4l2_ctrl_new_std(priv-hdl,ov2640_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0);
priv-subdev.ctrl_handler =priv-hdl;
-   if (priv-hdl.error)
-   return priv-hdl.error;
-
-   priv-clk = v4l2_clk_get(client-dev, mclk);
-   if (IS_ERR(priv-clk)) {
-   ret = PTR_ERR(priv-clk);
-   goto eclkget;


--
Regards,
Sylwester
--
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 5/9] rc: ir-rc5-decoder: Add encode capability

2014-03-14 Thread James Hogan
Add the capability to encode RC-5 and RC-5X scancodes as raw events. The
protocol is chosen based on the specified protocol mask, and whether all
the required bits are set in the scancode mask, and none of the unused
bits are set in the scancode data. For example a scancode filter with
bit 16 set in both data and mask is unambiguously RC-5X.

The Manchester modulation helper is used, and for RC-5X it is used twice
with two sets of timings, the first with a short trailer space for the
space in the middle, and the second with no leader so that it can
continue the space.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
---
I've mostly reverse engineered RC-5X from the decoder, but it seems to
work in loopback. Here's some debug output:

RC-5X:
evbug: Event. Dev: input0, Type: 4, Code: 4, Value: 65793
evbug: Event. Dev: input0, Type: 0, Code: 0, Value: 0
 _   __   _   _   _   __  _   _   _   _   ___   _   _   _   __
| | |  | | | | | | | | |  | || | | | | | | | | |  |  | | | | | | | | |  | | 
 |
| |_|  |_| |_| |_| |_| |__| || |_| |_| |_| |_| |__|  |_| |_| |_| |_| |__| 
|__|
  1  1  31  1  1
8
 8 8  7 8 8 8 8 8 8 8 8  7 85 8 8 8 8 8 8 8 8 8  7  7 8 8 8 8 8 8 8 8  7 8  
8
 8 8  7 8 8 8 8 8 8 8 8  7 85 8 8 8 8 8 8 8 8 8  7  7 8 8 8 8 8 8 8 8  7 8  
8
 9 9  8 9 9 9 9 9 9 9 9  8 96 9 9 9 9 9 9 9 9 9  8  8 9 9 9 9 9 9 9 9  8 9  
9
   1  0   0   0   0   0  1  X 0   0   0   0   0  1  0   0   0   0   0  1
E rc-5

RC-5:
evbug: Event. Dev: input0, Type: 4, Code: 4, Value: 257
evbug: Event. Dev: input0, Type: 0, Code: 0, Value: 0
 _   __   _   _   _   ___   _   _   _   __
| | |  | | | | | | | | |  |  | | | | | | | | |  | |  |
| |_|  |_| |_| |_| |_| |__|  |_| |_| |_| |_| |__| |__|
  1  1  1  18
 8 8  7 8 8 8 8 8 8 8 8  7  7 8 8 8 8 8 8 8 8  7 8  8
 8 8  7 8 8 8 8 8 8 8 8  7  7 8 8 8 8 8 8 8 8  7 8  8
 9 9  8 9 9 9 9 9 9 9 9  8  8 9 9 9 9 9 9 9 9  8 9  9
   1  0   0   0   0   0  1  0   0   0   0   0  1E rc-5
---
 drivers/media/rc/ir-rc5-decoder.c | 103 ++
 1 file changed, 103 insertions(+)

diff --git a/drivers/media/rc/ir-rc5-decoder.c 
b/drivers/media/rc/ir-rc5-decoder.c
index 4295d9b..2eed2fe 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -171,9 +171,112 @@ out:
return -EINVAL;
 }
 
+static struct ir_raw_timings_manchester ir_rc5_timings = {
+   .leader = 1,
+   .pulse_space_start  = 0,
+   .clock  = RC5_UNIT,
+   .trailer_space  = RC5_UNIT * 10,
+};
+
+static struct ir_raw_timings_manchester ir_rc5x_timings[2] = {
+   {
+   .leader = 1,
+   .pulse_space_start  = 0,
+   .clock  = RC5_UNIT,
+   .trailer_space  = RC5X_SPACE,
+   },
+   {
+   .clock  = RC5_UNIT,
+   .trailer_space  = RC5_UNIT * 10,
+   },
+};
+
+static int ir_rc5_validate_filter(const struct rc_scancode_filter *scancode,
+ unsigned int important_bits)
+{
+   /* all important bits of scancode should be set in mask */
+   if (~scancode-mask  important_bits)
+   return -EINVAL;
+   /* extra bits in mask should be zero in data */
+   if (scancode-mask  scancode-data  ~important_bits)
+   return -EINVAL;
+   return 0;
+}
+
+/**
+ * ir_rc5_encode() - Encode a scancode as a stream of raw events
+ *
+ * @protocols: allowed protocols
+ * @scancode:  scancode filter describing scancode (helps distinguish between
+ * protocol subtypes when scancode is ambiguous)
+ * @events:array of raw ir events to write into
+ * @max:   maximum size of @events
+ *
+ * Returns:The number of events written.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * encoding. In this case all @max events will have been written.
+ * -EINVAL if the scancode is ambiguous or invalid.
+ */
+static int ir_rc5_encode(u64 protocols,
+const struct rc_scancode_filter *scancode,
+struct ir_raw_event *events, unsigned int max)
+{
+   int ret;
+   struct ir_raw_event *e = events;
+   unsigned int data, xdata, command, commandx, system;
+
+   /* Detect protocol and convert scancode to raw data */
+   if (protocols  RC_BIT_RC5 
+   !ir_rc5_validate_filter(scancode, 0x1f7f)) {
+   /* decode scancode */
+   command  = (scancode-data  0x003f)  0;
+   commandx = 

[PATCH v2 0/9] rc: Add IR encode based wakeup filtering

2014-03-14 Thread James Hogan
A recent discussion about proposed interfaces for setting up the
hardware wakeup filter lead to the conclusion that it could help to have
the generic capability to encode and modulate scancodes into raw IR
events so that drivers for hardware with a low level wake filter (on the
level of pulse/space durations) can still easily implement the higher
level scancode interface that is proposed.

I posted an RFC patchset showing how this could work, and Antti Seppälä
posted additional patches to support rc5-sz and nuvoton-cir. This
patchset improves the original RFC patches and combines  updates
Antti's patches.

I'm happy these patches are a good start at tackling the problem, as
long as Antti is happy with them and they work for him of course.

Future work could include:
 - Encoders for more protocols.
 - Carrier signal events (no use unless a driver makes use of it).

Patch 1 adds the new encode API.
Patches 2-3 adds some modulation helpers.
Patches 4-6 adds some raw encode implementations.
Patch 7 adds some rc-core support for encode based wakeup filtering.
Patch 8 adds debug loopback of encoded scancode when filter set.
Patch 9 (untested) adds encode based wakeup filtering to nuvoton-cir.

Changes in v2:

Patchset:
 - Alter encode API to return -ENOBUFS when there isn't enough buffer
   space. When this occurs all buffer contents must have been written
   with the partial encoding of the scancode. This is to allow drivers
   such as nuvoton-cir to provide a shorter buffer and still get a
   useful partial encoding for the wakeup pattern.
 - Added RC-5  RC-5X encoder.
 - Add encode_wakeup support which keeps allowed wakeup protocols in
   sync with registered encoders.

Pulse-distance modulation helper:
 - Update ir_raw_gen_pd() with a kerneldoc comment and individual buffer
   full checks rather than a single one at the beginning, in order to
   support -ENOBUFS properly.
 - Update ir_raw_gen_pulse_space() to check the number of free slots and
   fill as many as possible before returning -ENOBUFS.
 - Fix brace placement for timings struct.

Manchester encoding helper:
 - Add kerneldoc comment.
 - Add individual buffer full checks, in order to support -ENOBUFS
   properly.
 - Make i unsigned to theoretically support all 32bits of data.
 - Increment *ev at end so caller can calculate correct number of
   events (during the loop *ev points to the last written event to allow
   it to be extended in length).
 - Make start/leader pulse optional, continuing from (*ev)[-1] if
   disabled. This helps support rc-5x which has a space in the middle of
   the bits.

rc5-sz encoder:
 - Turn ir_rc5_sz_encode() comment into kerneldoc and update to reflect
   new API.
 - Be more flexible around accepted scancode masks, as long as all the
   important bits are set (0x2fff) and none of the unimportant bits are
   set in the data. Also mask off the unimportant bits before passing to
   ir_raw_gen_manchester().
 - Explicitly enable leader bit in Manchester modulation timings.

rc-loopback:
 - Move img-ir-raw test code to rc-loopback.
 - Set encode_wakeup so that the set of allowed wakeup protocols matches
   the set of raw IR encoders.

nuvoton-cir:
 - Change reference to rc_dev::enabled_protocols to
   enabled_protocols[type] since it has been converted to an array.
 - Fix IR encoding buffer loop condition to be i  ret rather than i =
   ret. The return value of ir_raw_encode_scancode is the number of
   events rather than the last event.
 - Set encode_wakeup so that the set of allowed wakeup protocols matches
   the set of raw IR encoders.

Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
Cc: Jarod Wilson ja...@redhat.com
Cc: Wei Yongjun yongjun_...@trendmicro.com.cn
Cc: Hans Verkuil hans.verk...@cisco.com

Antti Seppälä (3):
  rc: ir-raw: Add Manchester encoder (phase encoder) helper
  rc: ir-rc5-sz-decoder: Add ir encoding support
  rc: nuvoton-cir: Add support for writing wakeup samples via sysfs
filter callback

James Hogan (6):
  rc: ir-raw: Add scancode encoder callback
  rc: ir-raw: Add pulse-distance modulation helper
  rc: ir-nec-decoder: Add encode capability
  rc: ir-rc5-decoder: Add encode capability
  rc: rc-core: Add support for encode_wakeup drivers
  rc: rc-loopback: Add loopback of filter scancodes

 drivers/media/rc/ir-nec-decoder.c|  93 +
 drivers/media/rc/ir-raw.c| 191 +++
 drivers/media/rc/ir-rc5-decoder.c| 103 +++
 drivers/media/rc/ir-rc5-sz-decoder.c |  45 +
 drivers/media/rc/nuvoton-cir.c   | 123 ++
 drivers/media/rc/nuvoton-cir.h   |   1 +
 drivers/media/rc/rc-core-priv.h  |  85 
 drivers/media/rc/rc-loopback.c   |  39 +++
 drivers/media/rc/rc-main.c   |  11 +-
 include/media/rc-core.h  |   7 ++
 10 files changed, 695 insertions(+), 3 deletions(-)

-- 
1.8.3.2


[PATCH v2 1/9] rc: ir-raw: Add scancode encoder callback

2014-03-14 Thread James Hogan
Add a callback to raw ir handlers for encoding and modulating a scancode
to a set of raw events. This could be used for transmit, or for
converting a wakeup scancode filter to a form that is more suitable for
raw hardware wake up filters.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2:
 - Alter encode API to return -ENOBUFS when there isn't enough buffer
   space. When this occurs all buffer contents must have been written
   with the partial encoding of the scancode. This is to allow drivers
   such as nuvoton-cir to provide a shorter buffer and still get a
   useful partial encoding for the wakeup pattern.
---
 drivers/media/rc/ir-raw.c   | 38 ++
 drivers/media/rc/rc-core-priv.h |  2 ++
 include/media/rc-core.h |  3 +++
 3 files changed, 43 insertions(+)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 763c9d1..01adc10 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -240,6 +240,44 @@ ir_raw_get_allowed_protocols(void)
return protocols;
 }
 
+/**
+ * ir_raw_encode_scancode() - Encode a scancode as raw events
+ *
+ * @protocols: permitted protocols
+ * @scancode:  scancode filter describing a single scancode
+ * @events:array of raw events to write into
+ * @max:   max number of raw events
+ *
+ * Attempts to encode the scancode as raw events.
+ *
+ * Returns:The number of events written.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * encoding. In this case all @max events will have been written.
+ * -EINVAL if the scancode is ambiguous or invalid, or if no
+ * compatible encoder was found.
+ */
+int ir_raw_encode_scancode(u64 protocols,
+  const struct rc_scancode_filter *scancode,
+  struct ir_raw_event *events, unsigned int max)
+{
+   struct ir_raw_handler *handler;
+   int ret = -EINVAL;
+
+   mutex_lock(ir_raw_handler_lock);
+   list_for_each_entry(handler, ir_raw_handler_list, list) {
+   if (handler-protocols  protocols  handler-encode) {
+   ret = handler-encode(protocols, scancode, events, max);
+   if (ret = 0 || ret == -ENOBUFS)
+   break;
+   }
+   }
+   mutex_unlock(ir_raw_handler_lock);
+
+   return ret;
+}
+EXPORT_SYMBOL(ir_raw_encode_scancode);
+
+
 /*
  * Used to (un)register raw event clients
  */
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index da536c9..8afb971 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -25,6 +25,8 @@ struct ir_raw_handler {
 
u64 protocols; /* which are handled by this handler */
int (*decode)(struct rc_dev *dev, struct ir_raw_event event);
+   int (*encode)(u64 protocols, const struct rc_scancode_filter *scancode,
+ struct ir_raw_event *events, unsigned int max);
 
/* These two should only be used by the lirc decoder */
int (*raw_register)(struct rc_dev *dev);
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 0b9f890..8c64f9e 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -275,6 +275,9 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum 
raw_event_type type);
 int ir_raw_event_store_with_filter(struct rc_dev *dev,
struct ir_raw_event *ev);
 void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
+int ir_raw_encode_scancode(u64 protocols,
+  const struct rc_scancode_filter *scancode,
+  struct ir_raw_event *events, unsigned int max);
 
 static inline void ir_raw_event_reset(struct rc_dev *dev)
 {
-- 
1.8.3.2

--
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 3/9] rc: ir-raw: Add Manchester encoder (phase encoder) helper

2014-03-14 Thread James Hogan
From: Antti Seppälä a.sepp...@gmail.com

Adding a simple Manchester encoder to rc-core.
Manchester coding is used by at least RC-5 protocol and its variants.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2 (James Hogan):
 - Alter encode API to return -ENOBUFS when there isn't enough buffer
   space. When this occurs all buffer contents must have been written
   with the partial encoding of the scancode. This is to allow drivers
   such as nuvoton-cir to provide a shorter buffer and still get a
   useful partial encoding for the wakeup pattern.
 - Add kerneldoc comment.
 - Add individual buffer full checks, in order to support -ENOBUFS
   properly.
 - Make i unsigned to theoretically support all 32bits of data.
 - Increment *ev at end so caller can calculate correct number of
   events (during the loop *ev points to the last written event to allow
   it to be extended in length).
 - Make start/leader pulse optional, continuing from (*ev)[-1] if
   disabled. This helps support rc-5x which has a space in the middle of
   the bits.
---
 drivers/media/rc/ir-raw.c   | 82 +
 drivers/media/rc/rc-core-priv.h | 19 ++
 2 files changed, 101 insertions(+)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index f8fe10e..4310e82 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -241,6 +241,88 @@ ir_raw_get_allowed_protocols(void)
 }
 
 /**
+ * ir_raw_gen_manchester() - Encode data with Manchester (bi-phase) modulation.
+ * @ev:Pointer to pointer to next free event. *@ev is 
incremented for
+ * each raw event filled.
+ * @max:   Maximum number of raw events to fill.
+ * @timings:   Manchester modulation timings.
+ * @n: Number of bits of data.
+ * @data:  Data bits to encode.
+ *
+ * Encodes the @n least significant bits of @data using Manchester (bi-phase)
+ * modulation with the timing characteristics described by @timings, writing up
+ * to @max raw IR events using the *@ev pointer.
+ *
+ * Returns:0 on success.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * full encoded data. In this case all @max events will have been
+ * written.
+ */
+int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
+ const struct ir_raw_timings_manchester *timings,
+ unsigned int n, unsigned int data)
+{
+   bool need_pulse;
+   unsigned int i;
+   int ret = -ENOBUFS;
+   i = 1  (n - 1);
+
+   if (timings-leader) {
+   if (!max--)
+   return ret;
+   if (timings-pulse_space_start) {
+   init_ir_raw_event_duration((*ev)++, 1, timings-clock);
+
+   if (!max--)
+   return ret;
+   init_ir_raw_event_duration((*ev), 0, timings-clock);
+   } else {
+   init_ir_raw_event_duration((*ev), 1, timings-clock);
+   }
+   i = 1;
+   } else {
+   /* continue existing signal */
+   --(*ev);
+   }
+   /* from here on *ev will point to the last event rather than the next */
+
+   while (i  0) {
+   need_pulse = !(data  i);
+   if (need_pulse == !!(*ev)-pulse) {
+   (*ev)-duration += timings-clock;
+   } else {
+   if (!max--)
+   goto nobufs;
+   init_ir_raw_event_duration(++(*ev), need_pulse,
+  timings-clock);
+   }
+
+   if (!max--)
+   goto nobufs;
+   init_ir_raw_event_duration(++(*ev), !need_pulse,
+  timings-clock);
+   i = 1;
+   }
+
+   if (timings-trailer_space) {
+   if (!(*ev)-pulse)
+   (*ev)-duration += timings-trailer_space;
+   else if (!max--)
+   goto nobufs;
+   else
+   init_ir_raw_event_duration(++(*ev), 0,
+  timings-trailer_space);
+   }
+
+   ret = 0;
+nobufs:
+   /* point to the next event rather than last event before returning */
+   ++(*ev);
+   return ret;
+}
+EXPORT_SYMBOL(ir_raw_gen_manchester);
+
+/**
  * ir_raw_gen_pd() - Encode data to raw events with pulse-distance modulation.
  * @ev:Pointer to pointer to next free event. *@ev is 
incremented for
  * each raw event filled.
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index b55ae24..c45b797 100644
--- 

[PATCH v2 4/9] rc: ir-nec-decoder: Add encode capability

2014-03-14 Thread James Hogan
Add the capability to encode NEC scancodes as raw events. The
scancode_to_raw is pretty much taken from the img-ir NEC filter()
callback, and modulation uses the pulse distance helper added in a
previous commit.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2:
 - Update kerneldoc return values to reflect new API with -ENOBUFS
   return value when buffer is full and only a partial message was
   encoded.
---
 drivers/media/rc/ir-nec-decoder.c | 93 +++
 1 file changed, 93 insertions(+)

diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c
index 9de1791..813fa6b 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -203,9 +203,102 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
return -EINVAL;
 }
 
+/**
+ * ir_nec_scancode_to_raw() - encode an NEC scancode ready for modulation.
+ * @in:scancode filter describing a single NEC scancode.
+ * @raw:   raw data to be modulated.
+ */
+static int ir_nec_scancode_to_raw(const struct rc_scancode_filter *in,
+ u32 *raw)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+
+   data = in-data  0xff;
+
+   if ((in-data | in-mask)  0xff00) {
+   /* 32-bit NEC (used by Apple and TiVo remotes) */
+   /* scan encoding: aaAAddDD */
+   if (in-mask != 0x)
+   return -EINVAL;
+   addr_inv   = (in-data  24)  0xff;
+   addr   = (in-data  16)  0xff;
+   data_inv   = (in-data   8)  0xff;
+   } else if ((in-data | in-mask)  0x00ff) {
+   /* Extended NEC */
+   /* scan encoding AAaaDD */
+   if (in-mask != 0x00ff)
+   return -EINVAL;
+   addr   = (in-data  16)  0xff;
+   addr_inv   = (in-data   8)  0xff;
+   data_inv   = data ^ 0xff;
+   } else {
+   /* Normal NEC */
+   /* scan encoding: AADD */
+   if (in-mask != 0x)
+   return -EINVAL;
+   addr   = (in-data   8)  0xff;
+   addr_inv   = addr ^ 0xff;
+   data_inv   = data ^ 0xff;
+   }
+
+   /* raw encoding: ddDDaaAA */
+   *raw = data_inv  24 |
+  data  16 |
+  addr_inv   8 |
+  addr;
+   return 0;
+}
+
+static struct ir_raw_timings_pd ir_nec_timings = {
+   .header_pulse   = NEC_HEADER_PULSE,
+   .header_space   = NEC_HEADER_SPACE,
+   .bit_pulse  = NEC_BIT_PULSE,
+   .bit_space[0]   = NEC_BIT_0_SPACE,
+   .bit_space[1]   = NEC_BIT_1_SPACE,
+   .trailer_pulse  = NEC_TRAILER_PULSE,
+   .trailer_space  = NEC_TRAILER_SPACE,
+   .msb_first  = 0,
+};
+
+/**
+ * ir_nec_encode() - Encode a scancode as a stream of raw events
+ *
+ * @protocols: allowed protocols
+ * @scancode:  scancode filter describing scancode (helps distinguish between
+ * protocol subtypes when scancode is ambiguous)
+ * @events:array of raw ir events to write into
+ * @max:   maximum size of @events
+ *
+ * Returns:The number of events written.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * encoding. In this case all @max events will have been written.
+ * -EINVAL if the scancode is ambiguous or invalid.
+ */
+static int ir_nec_encode(u64 protocols,
+const struct rc_scancode_filter *scancode,
+struct ir_raw_event *events, unsigned int max)
+{
+   struct ir_raw_event *e = events;
+   int ret;
+   u32 raw;
+
+   /* Convert a NEC scancode to raw NEC data */
+   ret = ir_nec_scancode_to_raw(scancode, raw);
+   if (ret  0)
+   return ret;
+
+   /* Modulate the raw data using a pulse distance modulation */
+   ret = ir_raw_gen_pd(e, max, ir_nec_timings, NEC_NBITS, raw);
+   if (ret  0)
+   return ret;
+
+   return e - events;
+}
+
 static struct ir_raw_handler nec_handler = {
.protocols  = RC_BIT_NEC,
.decode = ir_nec_decode,
+   .encode = ir_nec_encode,
 };
 
 static int __init ir_nec_decode_init(void)
-- 
1.8.3.2

--
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 6/9] rc: ir-rc5-sz-decoder: Add ir encoding support

2014-03-14 Thread James Hogan
From: Antti Seppälä a.sepp...@gmail.com

The encoding in rc5-sz first inserts a pulse and then simply utilizes the
generic Manchester encoder available in rc-core.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2 (James Hogan):
 - Turn ir_rc5_sz_encode() comment into kerneldoc and update to reflect
   new API, with the -ENOBUFS return value for when the buffer is full
   and only a partial message was encoded.
 - Be more flexible around accepted scancode masks, as long as all the
   important bits are set (0x2fff) and none of the unimportant bits are
   set in the data. Also mask off the unimportant bits before passing to
   ir_raw_gen_manchester().
 - Explicitly enable leader bit in Manchester modulation timings.
---
 drivers/media/rc/ir-rc5-sz-decoder.c | 45 
 1 file changed, 45 insertions(+)

diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c 
b/drivers/media/rc/ir-rc5-sz-decoder.c
index dc18b74..a342a4f 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -127,9 +127,54 @@ out:
return -EINVAL;
 }
 
+static struct ir_raw_timings_manchester ir_rc5_sz_timings = {
+   .leader = 1,
+   .pulse_space_start  = 0,
+   .clock  = RC5_UNIT,
+   .trailer_space  = RC5_UNIT * 10,
+};
+
+/**
+ * ir_rc5_sz_encode() - Encode a scancode as a stream of raw events
+ *
+ * @protocols: allowed protocols
+ * @scancode:  scancode filter describing scancode (helps distinguish between
+ * protocol subtypes when scancode is ambiguous)
+ * @events:array of raw ir events to write into
+ * @max:   maximum size of @events
+ *
+ * Returns:The number of events written.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * encoding. In this case all @max events will have been written.
+ * -EINVAL if the scancode is ambiguous or invalid.
+ */
+static int ir_rc5_sz_encode(u64 protocols,
+   const struct rc_scancode_filter *scancode,
+   struct ir_raw_event *events, unsigned int max)
+{
+   int ret;
+   struct ir_raw_event *e = events;
+
+   /* all important bits of scancode should be set in mask */
+   if (~scancode-mask  0x2fff)
+   return -EINVAL;
+   /* extra bits in mask should be zero in data */
+   if (scancode-mask  scancode-data  ~0x2fff)
+   return -EINVAL;
+
+   /* RC5-SZ scancode is raw enough for Manchester as it is */
+   ret = ir_raw_gen_manchester(e, max, ir_rc5_sz_timings, RC5_SZ_NBITS,
+   scancode-data  0x2fff);
+   if (ret  0)
+   return ret;
+
+   return e - events;
+}
+
 static struct ir_raw_handler rc5_sz_handler = {
.protocols  = RC_BIT_RC5_SZ,
.decode = ir_rc5_sz_decode,
+   .encode = ir_rc5_sz_encode,
 };
 
 static int __init ir_rc5_sz_decode_init(void)
-- 
1.8.3.2

--
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 7/9] rc: rc-core: Add support for encode_wakeup drivers

2014-03-14 Thread James Hogan
Add support in rc-core for drivers which implement the wakeup scancode
filter by encoding the scancode using the raw IR encoders. This is by
way of rc_dev::encode_wakeup which should be set to true to make the
allowed wakeup protocols the same as the set of raw IR encoders.

As well as updating the sysfs interface to know which wakeup protocols
are allowed for encode_wakeup drivers, also ensure that the IR
decoders/encoders are loaded when an encode_wakeup driver is registered.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2:
 - New patch
---
 drivers/media/rc/ir-raw.c   | 15 +++
 drivers/media/rc/rc-core-priv.h |  1 +
 drivers/media/rc/rc-main.c  | 11 ---
 include/media/rc-core.h |  3 +++
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 4310e82..d8ad81c 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -30,6 +30,7 @@ static LIST_HEAD(ir_raw_client_list);
 static DEFINE_MUTEX(ir_raw_handler_lock);
 static LIST_HEAD(ir_raw_handler_list);
 static u64 available_protocols;
+static u64 encode_protocols;
 
 static int ir_raw_event_thread(void *data)
 {
@@ -240,6 +241,16 @@ ir_raw_get_allowed_protocols(void)
return protocols;
 }
 
+/* used internally by the sysfs interface */
+u64 ir_raw_get_encode_protocols(void)
+{
+   u64 protocols;
+   mutex_lock(ir_raw_handler_lock);
+   protocols = encode_protocols;
+   mutex_unlock(ir_raw_handler_lock);
+   return protocols;
+}
+
 /**
  * ir_raw_gen_manchester() - Encode data with Manchester (bi-phase) modulation.
  * @ev:Pointer to pointer to next free event. *@ev is 
incremented for
@@ -498,6 +509,8 @@ int ir_raw_handler_register(struct ir_raw_handler 
*ir_raw_handler)
list_for_each_entry(raw, ir_raw_client_list, list)
ir_raw_handler-raw_register(raw-dev);
available_protocols |= ir_raw_handler-protocols;
+   if (ir_raw_handler-encode)
+   encode_protocols |= ir_raw_handler-protocols;
mutex_unlock(ir_raw_handler_lock);
 
return 0;
@@ -514,6 +527,8 @@ void ir_raw_handler_unregister(struct ir_raw_handler 
*ir_raw_handler)
list_for_each_entry(raw, ir_raw_client_list, list)
ir_raw_handler-raw_unregister(raw-dev);
available_protocols = ~ir_raw_handler-protocols;
+   if (ir_raw_handler-encode)
+   encode_protocols = ~ir_raw_handler-protocols;
mutex_unlock(ir_raw_handler_lock);
 }
 EXPORT_SYMBOL(ir_raw_handler_unregister);
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index c45b797..767ef69 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -239,6 +239,7 @@ int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int 
max,
  * Routines from rc-raw.c to be used internally and by decoders
  */
 u64 ir_raw_get_allowed_protocols(void);
+u64 ir_raw_get_encode_protocols(void);
 int ir_raw_event_register(struct rc_dev *dev);
 void ir_raw_event_unregister(struct rc_dev *dev);
 int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 99697aa..712a2d7 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -857,8 +857,10 @@ static ssize_t show_protocols(struct device *device,
mutex_lock(dev-lock);
 
enabled = dev-enabled_protocols[fattr-type];
-   if (dev-driver_type == RC_DRIVER_SCANCODE ||
-   fattr-type == RC_FILTER_WAKEUP)
+   if (dev-encode_wakeup  fattr-type == RC_FILTER_WAKEUP)
+   allowed = ir_raw_get_encode_protocols();
+   else if (dev-driver_type == RC_DRIVER_SCANCODE ||
+fattr-type == RC_FILTER_WAKEUP)
allowed = dev-allowed_protocols[fattr-type];
else if (dev-raw)
allowed = ir_raw_get_allowed_protocols();
@@ -1350,13 +1352,16 @@ int rc_register_device(struct rc_dev *dev)
path ? path : N/A);
kfree(path);
 
-   if (dev-driver_type == RC_DRIVER_IR_RAW) {
+   if (dev-driver_type == RC_DRIVER_IR_RAW || dev-encode_wakeup) {
/* Load raw decoders, if they aren't already */
if (!raw_init) {
IR_dprintk(1, Loading raw decoders\n);
ir_raw_init();
raw_init = true;
}
+   }
+
+   if (dev-driver_type == RC_DRIVER_IR_RAW) {
rc = ir_raw_event_register(dev);
if (rc  0)
goto out_input;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 8c64f9e..2d81d6c 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -73,6 +73,8 

[PATCH v2 8/9] rc: rc-loopback: Add loopback of filter scancodes

2014-03-14 Thread James Hogan
Add the s_filter callback to the rc-loopback driver, which instead of
setting the filter just feeds the scancode back through the input device
so that it can be verified.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
---
Changes in v2:
 - Move img-ir-raw test code to rc-loopback.
 - Handle new encode API, specifically -ENOBUFS when the buffer isn't
   long enough.
 - Set encode_wakeup so that the set of allowed wakeup protocols matches
   the set of raw IR encoders.
---
 drivers/media/rc/rc-loopback.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 0a88e0c..aefd335 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -26,6 +26,7 @@
 #include linux/device.h
 #include linux/module.h
 #include linux/sched.h
+#include linux/slab.h
 #include media/rc-core.h
 
 #define DRIVER_NAMErc-loopback
@@ -176,6 +177,42 @@ static int loop_set_carrier_report(struct rc_dev *dev, int 
enable)
return 0;
 }
 
+static int loop_set_filter(struct rc_dev *dev, enum rc_filter_type type,
+  struct rc_scancode_filter *sc_filter)
+{
+   static const unsigned int max = 512;
+   struct ir_raw_event *raw;
+   int ret;
+   int i;
+
+   /* fine to disable filter */
+   if (!sc_filter-mask)
+   return 0;
+
+   /* encode the specified filter and loop it back */
+   raw = kmalloc(max * sizeof(*raw), GFP_KERNEL);
+   ret = ir_raw_encode_scancode(dev-enabled_protocols[type], sc_filter,
+raw, max);
+   /* still loop back the partial raw IR even if it's incomplete */
+   if (ret == -ENOBUFS)
+   ret = max;
+   if (ret = 0) {
+   /* do the loopback */
+   for (i = 0; i  ret; ++i)
+   ir_raw_event_store(dev, raw[i]);
+   ir_raw_event_handle(dev);
+
+   ret = 0;
+   } else if (type == RC_FILTER_NORMAL) {
+   /* accept any normal filter */
+   ret = 0;
+   }
+
+   kfree(raw);
+
+   return ret;
+}
+
 static int __init loop_init(void)
 {
struct rc_dev *rc;
@@ -195,6 +232,7 @@ static int __init loop_init(void)
rc-map_name= RC_MAP_EMPTY;
rc-priv= loopdev;
rc-driver_type = RC_DRIVER_IR_RAW;
+   rc-encode_wakeup   = true;
rc_set_allowed_protocols(rc, RC_BIT_ALL);
rc-timeout = 100 * 1000 * 1000; /* 100 ms */
rc-min_timeout = 1;
@@ -209,6 +247,7 @@ static int __init loop_init(void)
rc-s_idle  = loop_set_idle;
rc-s_learning_mode = loop_set_learning_mode;
rc-s_carrier_report= loop_set_carrier_report;
+   rc-s_filter= loop_set_filter;
 
loopdev.txmask  = RXMASK_REGULAR;
loopdev.txcarrier   = 36000;
-- 
1.8.3.2

--
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 2/9] rc: ir-raw: Add pulse-distance modulation helper

2014-03-14 Thread James Hogan
Add IR encoding helper for pulse-distance modulation as used by the NEC
protocol.

Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Antti Seppälä a.sepp...@gmail.com
Cc: David Härdeman da...@hardeman.nu
---
Changes in v2:
 - Alter encode API to return -ENOBUFS when there isn't enough buffer
   space. When this occurs all buffer contents must have been written
   with the partial encoding of the scancode. This is to allow drivers
   such as nuvoton-cir to provide a shorter buffer and still get a
   useful partial encoding for the wakeup pattern.
 - Update ir_raw_gen_pd() with a kerneldoc comment and individual buffer
   full checks rather than a single one at the beginning, in order to
   support -ENOBUFS properly.
 - Update ir_raw_gen_pulse_space() to check the number of free slots and
   fill as many as possible before returning -ENOBUFS.
 - Fix brace placement for timings struct.
---
 drivers/media/rc/ir-raw.c   | 56 
 drivers/media/rc/rc-core-priv.h | 63 +
 2 files changed, 119 insertions(+)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 01adc10..f8fe10e 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -241,6 +241,62 @@ ir_raw_get_allowed_protocols(void)
 }
 
 /**
+ * ir_raw_gen_pd() - Encode data to raw events with pulse-distance modulation.
+ * @ev:Pointer to pointer to next free event. *@ev is 
incremented for
+ * each raw event filled.
+ * @max:   Maximum number of raw events to fill.
+ * @timings:   Pulse distance modulation timings.
+ * @n: Number of bits of data.
+ * @data:  Data bits to encode.
+ *
+ * Encodes the @n least significant bits of @data using pulse-distance
+ * modulation with the timing characteristics described by @timings, writing up
+ * to @max raw IR events using the *@ev pointer.
+ *
+ * Returns:0 on success.
+ * -ENOBUFS if there isn't enough space in the array to fit the
+ * full encoded data. In this case all @max events will have been
+ * written.
+ */
+int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
+ const struct ir_raw_timings_pd *timings,
+ unsigned int n, unsigned int data)
+{
+   int i;
+   int ret;
+
+   if (timings-header_pulse) {
+   ret = ir_raw_gen_pulse_space(ev, max, timings-header_pulse,
+timings-header_space);
+   if (ret)
+   return ret;
+   }
+
+   if (timings-msb_first) {
+   for (i = n - 1; i = 0; --i) {
+   ret = ir_raw_gen_pulse_space(ev, max,
+   timings-bit_pulse,
+   timings-bit_space[(data  i)  1]);
+   if (ret)
+   return ret;
+   }
+   } else {
+   for (i = 0; i  n; ++i, data = 1) {
+   ret = ir_raw_gen_pulse_space(ev, max,
+   timings-bit_pulse,
+   timings-bit_space[data  1]);
+   if (ret)
+   return ret;
+   }
+   }
+
+   ret = ir_raw_gen_pulse_space(ev, max, timings-trailer_pulse,
+timings-trailer_space);
+   return ret;
+}
+EXPORT_SYMBOL(ir_raw_gen_pd);
+
+/**
  * ir_raw_encode_scancode() - Encode a scancode as raw events
  *
  * @protocols: permitted protocols
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 8afb971..b55ae24 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -153,6 +153,69 @@ static inline bool is_timing_event(struct ir_raw_event ev)
 #define TO_US(duration)DIV_ROUND_CLOSEST((duration), 
1000)
 #define TO_STR(is_pulse)   ((is_pulse) ? pulse : space)
 
+/* functions for IR encoders */
+
+static inline void init_ir_raw_event_duration(struct ir_raw_event *ev,
+ unsigned int pulse,
+ u32 duration)
+{
+   init_ir_raw_event(ev);
+   ev-duration = duration;
+   ev-pulse = pulse;
+}
+
+/**
+ * ir_raw_gen_pulse_space() - generate pulse and space raw events.
+ * @ev:Pointer to pointer to next free raw event.
+ * Will be incremented for each raw event written.
+ * @max:   Pointer to number of raw events available in buffer.
+ * Will be decremented for each raw event written.
+ * @pulse_width:   Width of pulse in ns.
+ * @space_width:   Width of space in ns.
+ *
+ * Returns:0 on success.
+ * -ENOBUFS if there isn't enough buffer space to write 

[PATCH v2 9/9] rc: nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback

2014-03-14 Thread James Hogan
From: Antti Seppälä a.sepp...@gmail.com

Nuvoton-cir utilizes the encoding capabilities of rc-core to convert
scancodes from user space to pulse/space format understood by the
underlying hardware.

Converted samples are then written to the wakeup fifo along with other
necessary configuration to enable wake up functionality.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
Signed-off-by: James Hogan ja...@albanarts.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Jarod Wilson ja...@redhat.com
Cc: Wei Yongjun yongjun_...@trendmicro.com.cn
Cc: Hans Verkuil hans.verk...@cisco.com
---
Please note this patch is only build tested.

Changes in v2 (James Hogan):
 - Handle new -ENOBUFS when IR encoding buffer isn't long enough and
   reduce buffer size to the size of the wake fifo so that time isn't
   wasted processing encoded IR events that will be discarded. Also only
   discard the last event if the encoded data is complete.
 - Change reference to rc_dev::enabled_protocols to
   enabled_protocols[type] since it has been converted to an array.
 - Fix IR encoding buffer loop condition to be i  ret rather than i =
   ret. The return value of ir_raw_encode_scancode is the number of
   events rather than the last event.
 - Set encode_wakeup so that the set of allowed wakeup protocols matches
   the set of raw IR encoders.
---
 drivers/media/rc/nuvoton-cir.c | 123 +
 drivers/media/rc/nuvoton-cir.h |   1 +
 include/media/rc-core.h|   1 +
 3 files changed, 125 insertions(+)

diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index d244e1a..ec8f4fc 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -527,6 +527,127 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 
carrier)
return 0;
 }
 
+static int nvt_write_wakeup_codes(struct rc_dev *dev,
+ const u8 *wakeup_sample_buf, int count)
+{
+   int i = 0;
+   u8 reg, reg_learn_mode;
+   unsigned long flags;
+   struct nvt_dev *nvt = dev-priv;
+
+   nvt_dbg_wake(writing wakeup samples);
+
+   reg = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
+   reg_learn_mode = reg  ~CIR_WAKE_IRCON_MODE0;
+   reg_learn_mode |= CIR_WAKE_IRCON_MODE1;
+
+   /* Lock the learn area to prevent racing with wake-isr */
+   spin_lock_irqsave(nvt-nvt_lock, flags);
+
+   /* Enable fifo writes */
+   nvt_cir_wake_reg_write(nvt, reg_learn_mode, CIR_WAKE_IRCON);
+
+   /* Clear cir wake rx fifo */
+   nvt_clear_cir_wake_fifo(nvt);
+
+   if (count  WAKE_FIFO_LEN) {
+   nvt_dbg_wake(HW FIFO too small for all wake samples);
+   count = WAKE_FIFO_LEN;
+   }
+
+   if (count)
+   pr_info(Wake samples (%d) =, count);
+   else
+   pr_info(Wake sample fifo cleared);
+
+   /* Write wake samples to fifo */
+   for (i = 0; i  count; i++) {
+   pr_cont( %02x, wakeup_sample_buf[i]);
+   nvt_cir_wake_reg_write(nvt, wakeup_sample_buf[i],
+  CIR_WAKE_WR_FIFO_DATA);
+   }
+   pr_cont(\n);
+
+   /* Switch cir to wakeup mode and disable fifo writing */
+   nvt_cir_wake_reg_write(nvt, reg, CIR_WAKE_IRCON);
+
+   /* Set number of bytes needed for wake */
+   nvt_cir_wake_reg_write(nvt, count ? count :
+  CIR_WAKE_FIFO_CMP_BYTES,
+  CIR_WAKE_FIFO_CMP_DEEP);
+
+   spin_unlock_irqrestore(nvt-nvt_lock, flags);
+
+   return 0;
+}
+
+static int nvt_ir_raw_set_filter(struct rc_dev *dev, enum rc_filter_type type,
+struct rc_scancode_filter *sc_filter)
+{
+   u8 *reg_buf;
+   u8 buf_val;
+   int i, ret, count;
+   unsigned int val;
+   struct ir_raw_event *raw;
+   bool complete;
+
+   /* Other types are not valid for nuvoton */
+   if (type != RC_FILTER_WAKEUP)
+   return -EINVAL;
+
+   /* Require both mask and data to be set before actually committing */
+   if (!sc_filter-mask || !sc_filter-data)
+   return 0;
+
+   raw = kmalloc(WAKE_FIFO_LEN * sizeof(*raw), GFP_KERNEL);
+   if (!raw)
+   return -ENOMEM;
+
+   ret = ir_raw_encode_scancode(dev-enabled_protocols[type], sc_filter,
+raw, WAKE_FIFO_LEN);
+   complete = (ret != -ENOBUFS);
+   if (!complete)
+   ret = WAKE_FIFO_LEN;
+   else if (ret  0)
+   goto out_raw;
+
+   reg_buf = kmalloc(sizeof(*reg_buf) * WAKE_FIFO_LEN, GFP_KERNEL);
+   if (!reg_buf) {
+   ret = -ENOMEM;
+   goto out_raw;
+   }
+
+   /* Inspect the ir samples */
+   for (i = 0, count = 0; i  ret  count  WAKE_FIFO_LEN; ++i) {
+   val = NS_TO_US((raw[i]).duration) / SAMPLE_PERIOD;
+
+   /* Split too large values into several smaller 

cron job: media_tree daily build: ERRORS

2014-03-14 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:   Sat Mar 15 04:00:17 CET 2014
git branch: test
git hash:   ed97a6fe5308e5982d118a25f0697b791af5ec50
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.13-5.slh.4-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: ERRORS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: 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-i686: OK
linux-3.13-i686: OK
linux-3.14-rc1-i686: OK
linux-2.6.31.14-x86_64: 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-x86_64: OK
linux-3.13-x86_64: OK
linux-3.14-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.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