Re: [RFCv2 PATCH 2/2] omap24xx/tcm825x: move to staging for future removal.

2013-12-13 Thread Sakari Ailus
Hi Hans,

On Thu, Dec 12, 2013 at 01:26:33PM +0100, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 The omap24xx driver and the tcm825x sensor driver are the only two
 remaining drivers to still use the old deprecated v4l2-int-device API.
 
 Nobody maintains these drivers anymore. But unfortunately the v4l2-int-device
 API is used by out-of-tree drivers (MXC platform). This is a very bad 
 situation
 since as long as this deprecated API stays in the kernel there is no reason 
 for
 those out-of-tree drivers to convert.
 
 This patch moves v4l2-int-device and the two drivers that depend on it to
 staging in preparation for their removal.

Do you think we should move these to staging instead of removing them right
away? These drivers have never been in a usable state in the mainline
kernel due to missing platform data. Currently they suffer from other
problems, too. I'd be surprised if they compile.

If I wanted to get them working again I'd start with this since it's not
very far from the state where they used to work:

URL:http://vihersipuli.retiisi.org.uk/cgi-bin/gitweb.cgi?p=~sailus/linux-omap/.git;a=summary

The branch is n800-cam . Porting to up-to-date APIs can then be done, and I
think David did some work to that end.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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/1] media: Include linux/kernel.h for DIV_ROUND_UP()

2013-12-13 Thread Sakari Ailus
DIV_ROUND_UP() is defined in kernel.h which was not included by
media-entity.h. Do exactly that.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/media/media-entity.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 10df551..e004591 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -24,6 +24,7 @@
 #define _MEDIA_ENTITY_H
 
 #include linux/bitops.h
+#include linux/kernel.h
 #include linux/list.h
 #include linux/media.h
 
-- 
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


[RFC 2/2] media: v4l: Only get module if it's different than the driver for v4l2_dev

2013-12-13 Thread Sakari Ailus
When the sub-device is registered, increment the use count of the sub-device
owner only if it's different from the owner of the driver for the media
device. This avoids increasing the use count by the module itself and thus
making it possible to unload it when it's not in use.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/v4l2-core/v4l2-device.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-device.c 
b/drivers/media/v4l2-core/v4l2-device.c
index 02d1b63..9f6d1ec 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -158,7 +158,8 @@ int v4l2_device_register_subdev(struct v4l2_device 
*v4l2_dev,
/* Warn if we apparently re-register a subdev */
WARN_ON(sd-v4l2_dev != NULL);
 
-   if (!try_module_get(sd-owner))
+   if (sd-owner != v4l2_dev-dev-driver-owner 
+   !try_module_get(sd-owner))
return -ENODEV;
 
sd-v4l2_dev = v4l2_dev;
@@ -192,7 +193,8 @@ error_unregister:
if (sd-internal_ops  sd-internal_ops-unregistered)
sd-internal_ops-unregistered(sd);
 error_module:
-   module_put(sd-owner);
+   if (sd-owner != v4l2_dev-dev-driver-owner)
+   module_put(sd-owner);
sd-v4l2_dev = NULL;
return err;
 }
@@ -280,6 +282,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
}
 #endif
video_unregister_device(sd-devnode);
-   module_put(sd-owner);
+   if (sd-owner != v4l2_dev-dev-driver-owner)
+   module_put(sd-owner);
 }
 EXPORT_SYMBOL_GPL(v4l2_device_unregister_subdev);
-- 
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


[RFC 1/2] media: Use a better owner for the media device

2013-12-13 Thread Sakari Ailus
mdev-fops-owner is actually the owner of the very same module which
implements media_device_register(), so it can't be unloaded anyway. Instead,
use THIS_MODULE through a macro as does video_register_device().

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/media-device.c  | 7 ---
 drivers/media/media-devnode.c | 5 +++--
 include/media/media-device.h  | 4 +++-
 include/media/media-devnode.h | 3 ++-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index d5a7a13..51217f0 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -372,7 +372,8 @@ static void media_device_release(struct media_devnode *mdev)
  * - dev must point to the parent device
  * - model must be filled with the device model name
  */
-int __must_check media_device_register(struct media_device *mdev)
+int __must_check __media_device_register(struct media_device *mdev,
+struct module *owner)
 {
int ret;
 
@@ -388,7 +389,7 @@ int __must_check media_device_register(struct media_device 
*mdev)
mdev-devnode.fops = media_device_fops;
mdev-devnode.parent = mdev-dev;
mdev-devnode.release = media_device_release;
-   ret = media_devnode_register(mdev-devnode);
+   ret = media_devnode_register(mdev-devnode, owner);
if (ret  0)
return ret;
 
@@ -400,7 +401,7 @@ int __must_check media_device_register(struct media_device 
*mdev)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(media_device_register);
+EXPORT_SYMBOL_GPL(__media_device_register);
 
 /**
  * media_device_unregister - unregister a media device
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index fb0f046..7acd19c 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -232,7 +232,8 @@ static const struct file_operations media_devnode_fops = {
  * the media_devnode structure is *not* called, so the caller is responsible 
for
  * freeing any data.
  */
-int __must_check media_devnode_register(struct media_devnode *mdev)
+int __must_check media_devnode_register(struct media_devnode *mdev,
+   struct module *owner)
 {
int minor;
int ret;
@@ -253,7 +254,7 @@ int __must_check media_devnode_register(struct 
media_devnode *mdev)
 
/* Part 2: Initialize and register the character device */
cdev_init(mdev-cdev, media_devnode_fops);
-   mdev-cdev.owner = mdev-fops-owner;
+   mdev-cdev.owner = owner;
 
ret = cdev_add(mdev-cdev, MKDEV(MAJOR(media_dev_t), mdev-minor), 1);
if (ret  0) {
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 12155a9..6e6db78 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -87,7 +87,9 @@ struct media_device {
 /* media_devnode to media_device */
 #define to_media_device(node) container_of(node, struct media_device, devnode)
 
-int __must_check media_device_register(struct media_device *mdev);
+int __must_check __media_device_register(struct media_device *mdev,
+struct module *owner);
+#define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
 void media_device_unregister(struct media_device *mdev);
 
 int __must_check media_device_register_entity(struct media_device *mdev,
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
index 3446af2..0dc7060 100644
--- a/include/media/media-devnode.h
+++ b/include/media/media-devnode.h
@@ -82,7 +82,8 @@ struct media_devnode {
 /* dev to media_devnode */
 #define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
 
-int __must_check media_devnode_register(struct media_devnode *mdev);
+int __must_check media_devnode_register(struct media_devnode *mdev,
+   struct module *owner);
 void media_devnode_unregister(struct media_devnode *mdev);
 
 static inline struct media_devnode *media_devnode_data(struct file *filp)
-- 
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: [RFCv2 PATCH 2/2] omap24xx/tcm825x: move to staging for future removal.

2013-12-13 Thread Hans Verkuil
On 12/13/2013 12:29 PM, Sakari Ailus wrote:
 Hi Hans,
 
 On Thu, Dec 12, 2013 at 01:26:33PM +0100, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The omap24xx driver and the tcm825x sensor driver are the only two
 remaining drivers to still use the old deprecated v4l2-int-device API.

 Nobody maintains these drivers anymore. But unfortunately the v4l2-int-device
 API is used by out-of-tree drivers (MXC platform). This is a very bad 
 situation
 since as long as this deprecated API stays in the kernel there is no reason 
 for
 those out-of-tree drivers to convert.

 This patch moves v4l2-int-device and the two drivers that depend on it to
 staging in preparation for their removal.
 
 Do you think we should move these to staging instead of removing them right
 away? These drivers have never been in a usable state in the mainline
 kernel due to missing platform data. Currently they suffer from other
 problems, too. I'd be surprised if they compile.

They do compile, they are part of my daily build.

 
 If I wanted to get them working again I'd start with this since it's not
 very far from the state where they used to work:
 
 URL:http://vihersipuli.retiisi.org.uk/cgi-bin/gitweb.cgi?p=~sailus/linux-omap/.git;a=summary
 
 The branch is n800-cam . Porting to up-to-date APIs can then be done, and I
 think David did some work to that end.
 

I think I prefer to keep them in staging for at least one kernel release (3.14)
and drop them in 3.15.

Although if the consensus is to just drop them, then I won't object :-)

Regards,

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


Re: [RFCv2 PATCH 2/2] omap24xx/tcm825x: move to staging for future removal.

2013-12-13 Thread Sakari Ailus
Hi Hans,

On Fri, Dec 13, 2013 at 01:02:33PM +0100, Hans Verkuil wrote:
 On 12/13/2013 12:29 PM, Sakari Ailus wrote:
  Hi Hans,
  
  On Thu, Dec 12, 2013 at 01:26:33PM +0100, Hans Verkuil wrote:
  From: Hans Verkuil hans.verk...@cisco.com
 
  The omap24xx driver and the tcm825x sensor driver are the only two
  remaining drivers to still use the old deprecated v4l2-int-device API.
 
  Nobody maintains these drivers anymore. But unfortunately the 
  v4l2-int-device
  API is used by out-of-tree drivers (MXC platform). This is a very bad 
  situation
  since as long as this deprecated API stays in the kernel there is no 
  reason for
  those out-of-tree drivers to convert.
 
  This patch moves v4l2-int-device and the two drivers that depend on it to
  staging in preparation for their removal.
  
  Do you think we should move these to staging instead of removing them right
  away? These drivers have never been in a usable state in the mainline
  kernel due to missing platform data. Currently they suffer from other
  problems, too. I'd be surprised if they compile.
 
 They do compile, they are part of my daily build.

If they compile they certainly do not function. :-)

  If I wanted to get them working again I'd start with this since it's not
  very far from the state where they used to work:
  
  URL:http://vihersipuli.retiisi.org.uk/cgi-bin/gitweb.cgi?p=~sailus/linux-omap/.git;a=summary
  
  The branch is n800-cam . Porting to up-to-date APIs can then be done, and I
  think David did some work to that end.
  
 
 I think I prefer to keep them in staging for at least one kernel release 
 (3.14)
 and drop them in 3.15.
 
 Although if the consensus is to just drop them, then I won't object :-)

Objections, anyone? :-)

I don't object to moving them to staging either but it'll be less hassle to
just remove them.

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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


[REVIEW PATCH 2/4] si470x: add check to test if this is really a si470x.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/radio/si470x/radio-si470x-usb.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c 
b/drivers/media/radio/si470x/radio-si470x-usb.c
index cd74025..07ef405 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -635,6 +635,30 @@ static int si470x_usb_driver_probe(struct usb_interface 
*intf,
}
 
radio-v4l2_dev.release = si470x_usb_release;
+
+   /*
+* The si470x SiLabs reference design uses the same USB IDs as
+* 'Thanko's Raremono' si4734 based receiver. So check here which we
+* have: attempt to read the device ID from the si470x: the lower 12
+* bits should be 0x0242 for the si470x.
+*
+* We use this check to determine which device we are dealing with.
+*/
+   if (id-idVendor == 0x10c4  id-idProduct == 0x818a) {
+   retval = usb_control_msg(radio-usbdev,
+   usb_rcvctrlpipe(radio-usbdev, 0),
+   HID_REQ_GET_REPORT,
+   USB_TYPE_CLASS | USB_RECIP_INTERFACE | 
USB_DIR_IN,
+   1, 2,
+   radio-usb_buf, 3, 500);
+   if (retval != 3 ||
+   (get_unaligned_be16(radio-usb_buf[1])  0xfff) != 0x0242) 
{
+   dev_info(intf-dev, this is not a si470x device.\n);
+   retval = -ENODEV;
+   goto err_urb;
+   }
+   }
+
retval = v4l2_device_register(intf-dev, radio-v4l2_dev);
if (retval  0) {
dev_err(intf-dev, couldn't register v4l2_device\n);
-- 
1.8.4.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


[REVIEW PATCH 3/4] radio-raremono: add support for 'Thanko's Raremono' AM/FM/SW USB device.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Dinesh Ram dinesh@cern.ch
---
 drivers/media/radio/Kconfig  |  14 ++
 drivers/media/radio/Makefile |   1 +
 drivers/media/radio/radio-raremono.c | 387 +++
 3 files changed, 402 insertions(+)
 create mode 100644 drivers/media/radio/radio-raremono.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 6ecdc39..45b7138 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -146,6 +146,20 @@ config USB_KEENE
  To compile this driver as a module, choose M here: the
  module will be called radio-keene.
 
+config USB_RAREMONO
+   tristate Thanko's Raremono AM/FM/SW radio support
+   depends on USB  VIDEO_V4L2
+   ---help---
+ The 'Thanko's Raremono' device contains the Si4734 chip from Silicon 
Labs Inc.
+ It is one of the very few or perhaps the only consumer USB radio 
device
+ to receive the AM/FM/SW bands.
+
+ Say Y here if you want to connect this type of AM/FM/SW receiver
+ to your computer's USB port.
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-raremono.
+
 config USB_MA901
tristate Masterkit MA901 USB FM radio support
depends on USB  VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 3b64560..77e1da0 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
 obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
 obj-$(CONFIG_RADIO_WL128X) += wl128x/
 obj-$(CONFIG_RADIO_TEA575X) += tea575x.o
+obj-$(CONFIG_USB_RAREMONO) += radio-raremono.o
 
 shark2-objs := radio-shark2.o radio-tea5777.o
 
diff --git a/drivers/media/radio/radio-raremono.c 
b/drivers/media/radio/radio-raremono.c
new file mode 100644
index 000..7b3bdbb
--- /dev/null
+++ b/drivers/media/radio/radio-raremono.c
@@ -0,0 +1,387 @@
+/*
+ * Copyright 2013 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/kernel.h
+#include linux/module.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/input.h
+#include linux/usb.h
+#include linux/hid.h
+#include linux/mutex.h
+#include linux/videodev2.h
+#include asm/unaligned.h
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-event.h
+
+/*
+ * 'Thanko's Raremono' is a Japanese si4734-based AM/FM/SW USB receiver:
+ *
+ * http://www.raremono.jp/product/484.html/
+ *
+ * The USB protocol has been reversed engineered using wireshark, initially
+ * by Dinesh Ram dinesh@cern.ch and finished by Hans Verkuil
+ * hverk...@xs4all.nl.
+ *
+ * Sadly the firmware used in this product hides lots of goodies since the
+ * si4734 has more features than are supported by the firmware. Oh well...
+ */
+
+/* driver and module definitions */
+MODULE_AUTHOR(Hans Verkuil hverk...@xs4all.nl);
+MODULE_DESCRIPTION(Thanko's Raremono AM/FM/SW Receiver USB driver);
+MODULE_LICENSE(GPL v2);
+
+/*
+ * The Device announces itself as Cygnal Integrated Products, Inc.
+ *
+ * The vendor and product IDs (and in fact all other lsusb information as
+ * well) are identical to the si470x Silicon Labs USB FM Radio Reference
+ * Design board, even though this card has a si4734 device. Clearly the
+ * designer of this product never bothered to change the USB IDs.
+ */
+
+/* USB Device ID List */
+static struct usb_device_id usb_raremono_device_table[] = {
+   {USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) },
+   { } /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, usb_raremono_device_table);
+
+#define BUFFER_LENGTH 64
+
+/* Timeout is set to a high value, could probably be reduced. Need more tests 
*/
+#define USB_TIMEOUT 1
+
+/* Frequency limits in KHz */
+#define FM_FREQ_RANGE_LOW  64000
+#define FM_FREQ_RANGE_HIGH 108000
+
+#define AM_FREQ_RANGE_LOW  520
+#define AM_FREQ_RANGE_HIGH 1710
+
+#define SW_FREQ_RANGE_LOW  2300
+#define SW_FREQ_RANGE_HIGH 26100
+
+enum { BAND_FM, BAND_AM, BAND_SW 

[REVIEW PATCH 1/4] si470x: don't use buffer on the stack for USB transfers.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

You shouldn't use buffers allocated on the stack for USB transfers,
always kmalloc them.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/radio/si470x/radio-si470x-usb.c | 57 +++
 drivers/media/radio/si470x/radio-si470x.h |  1 +
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c 
b/drivers/media/radio/si470x/radio-si470x-usb.c
index d6d4d60..cd74025 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -137,6 +137,8 @@ MODULE_PARM_DESC(max_rds_errors, RDS maximum block errors: 
*1*);
 /* interrupt out endpoint 2 every 1 millisecond */
 #define UNUSED_REPORT  23
 
+#define MAX_REPORT_SIZE64
+
 
 
 /**
@@ -208,7 +210,7 @@ MODULE_PARM_DESC(max_rds_errors, RDS maximum block errors: 
*1*);
  */
 static int si470x_get_report(struct si470x_device *radio, void *buf, int size)
 {
-   unsigned char *report = (unsigned char *) buf;
+   unsigned char *report = buf;
int retval;
 
retval = usb_control_msg(radio-usbdev,
@@ -231,7 +233,7 @@ static int si470x_get_report(struct si470x_device *radio, 
void *buf, int size)
  */
 static int si470x_set_report(struct si470x_device *radio, void *buf, int size)
 {
-   unsigned char *report = (unsigned char *) buf;
+   unsigned char *report = buf;
int retval;
 
retval = usb_control_msg(radio-usbdev,
@@ -254,15 +256,14 @@ static int si470x_set_report(struct si470x_device *radio, 
void *buf, int size)
  */
 int si470x_get_register(struct si470x_device *radio, int regnr)
 {
-   unsigned char buf[REGISTER_REPORT_SIZE];
int retval;
 
-   buf[0] = REGISTER_REPORT(regnr);
+   radio-usb_buf[0] = REGISTER_REPORT(regnr);
 
-   retval = si470x_get_report(radio, (void *) buf, sizeof(buf));
+   retval = si470x_get_report(radio, radio-usb_buf, REGISTER_REPORT_SIZE);
 
if (retval = 0)
-   radio-registers[regnr] = get_unaligned_be16(buf[1]);
+   radio-registers[regnr] = 
get_unaligned_be16(radio-usb_buf[1]);
 
return (retval  0) ? -EINVAL : 0;
 }
@@ -273,13 +274,12 @@ int si470x_get_register(struct si470x_device *radio, int 
regnr)
  */
 int si470x_set_register(struct si470x_device *radio, int regnr)
 {
-   unsigned char buf[REGISTER_REPORT_SIZE];
int retval;
 
-   buf[0] = REGISTER_REPORT(regnr);
-   put_unaligned_be16(radio-registers[regnr], buf[1]);
+   radio-usb_buf[0] = REGISTER_REPORT(regnr);
+   put_unaligned_be16(radio-registers[regnr], radio-usb_buf[1]);
 
-   retval = si470x_set_report(radio, (void *) buf, sizeof(buf));
+   retval = si470x_set_report(radio, radio-usb_buf, REGISTER_REPORT_SIZE);
 
return (retval  0) ? -EINVAL : 0;
 }
@@ -295,18 +295,17 @@ int si470x_set_register(struct si470x_device *radio, int 
regnr)
  */
 static int si470x_get_all_registers(struct si470x_device *radio)
 {
-   unsigned char buf[ENTIRE_REPORT_SIZE];
int retval;
unsigned char regnr;
 
-   buf[0] = ENTIRE_REPORT;
+   radio-usb_buf[0] = ENTIRE_REPORT;
 
-   retval = si470x_get_report(radio, (void *) buf, sizeof(buf));
+   retval = si470x_get_report(radio, radio-usb_buf, ENTIRE_REPORT_SIZE);
 
if (retval = 0)
for (regnr = 0; regnr  RADIO_REGISTER_NUM; regnr++)
radio-registers[regnr] = get_unaligned_be16(
-   buf[regnr * RADIO_REGISTER_SIZE + 1]);
+   radio-usb_buf[regnr * RADIO_REGISTER_SIZE + 
1]);
 
return (retval  0) ? -EINVAL : 0;
 }
@@ -323,14 +322,13 @@ static int si470x_get_all_registers(struct si470x_device 
*radio)
 static int si470x_set_led_state(struct si470x_device *radio,
unsigned char led_state)
 {
-   unsigned char buf[LED_REPORT_SIZE];
int retval;
 
-   buf[0] = LED_REPORT;
-   buf[1] = LED_COMMAND;
-   buf[2] = led_state;
+   radio-usb_buf[0] = LED_REPORT;
+   radio-usb_buf[1] = LED_COMMAND;
+   radio-usb_buf[2] = led_state;
 
-   retval = si470x_set_report(radio, (void *) buf, sizeof(buf));
+   retval = si470x_set_report(radio, radio-usb_buf, LED_REPORT_SIZE);
 
return (retval  0) ? -EINVAL : 0;
 }
@@ -346,19 +344,18 @@ static int si470x_set_led_state(struct si470x_device 
*radio,
  */
 static int si470x_get_scratch_page_versions(struct si470x_device *radio)
 {
-   unsigned char buf[SCRATCH_REPORT_SIZE];
int retval;
 
-   buf[0] = SCRATCH_REPORT;
+   radio-usb_buf[0] = SCRATCH_REPORT;
 
-   retval = si470x_get_report(radio, (void *) buf, sizeof(buf));
+   retval = si470x_get_report(radio, radio-usb_buf, SCRATCH_REPORT_SIZE);
 
if (retval  0)
dev_warn(radio-intf-dev, 

[REVIEW PATCH 4/4] MAINTAINERS: add entry for new radio-raremono radio driver.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8285ed4..cedf0df 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8480,6 +8480,14 @@ L:   linux-xte...@linux-xtensa.org
 S: Maintained
 F: arch/xtensa/
 
+THANKO'S RAREMONO AM/FM/SW RADIO RECEIVER USB DRIVER
+M: Hans Verkuil hverk...@xs4all.nl
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+W: http://linuxtv.org
+S: Maintained
+F: drivers/media/radio/radio-raremono.c
+
 THERMAL
 M:  Zhang Rui rui.zh...@intel.com
 M:  Eduardo Valentin eduardo.valen...@ti.com
-- 
1.8.4.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


[REVIEW PATCH 0/4] add radio-raremono driver

2013-12-13 Thread Hans Verkuil
This patch series adds the new radio-raremono driver for the USB
'Thanko's Raremono' AM/FM/SW receiver.

Since it (ab)uses the same USB IDs as the si470x SiLabs Reference
Design I had to add additional checks to si470x to tell the two apart.

While editing si470x I noticed that it passes USB buffers from the stack
instead of using kmalloc, so I fixed that as well.

I have tested the si470x checks, and the FM and AM receiver of the
Raremono device have been tested as well. I don't have a SW transmitter,
nor are there any SW transmitters here in Norway, so I couldn't test it.

All I can say is that it is definitely tuning since the white noise
changes when I change frequency. I'll try this nexy week in the Netherlands,
as I think there are still a few SW transmissions there I might receive.

The initial reverse engineering for this driver was done by Dinesh Ram
as part of his Cisco internship, so many thanks to Dinesh for doing that
work.

Regards,

Hans

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


Re: [PATCHv2 06/11] si4713: Added the USB driver for Si4713

2013-12-13 Thread Hans Verkuil
Hi Mauro,

On 12/09/2013 04:47 PM, Mauro Carvalho Chehab wrote:
 Em Fri,  6 Dec 2013 11:17:09 +0100
 Hans Verkuil hverk...@xs4all.nl escreveu:
 
 From: Dinesh Ram dinesh@cern.ch

 This is the USB driver for the Silicon Labs development board.
 It contains the Si4713 FM transmitter chip.

 Signed-off-by: Dinesh Ram dinesh@cern.ch
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 Tested-by: Eduardo Valentin edubez...@gmail.com
 Acked-by: Eduardo Valentin edubez...@gmail.com
 ---
  drivers/media/radio/si4713/Kconfig|  15 +
  drivers/media/radio/si4713/Makefile   |   1 +
  drivers/media/radio/si4713/radio-usb-si4713.c | 540 
 ++
  3 files changed, 556 insertions(+)
  create mode 100644 drivers/media/radio/si4713/radio-usb-si4713.c


snip

 diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c 
 b/drivers/media/radio/si4713/radio-usb-si4713.c
 new file mode 100644
 index 000..d978844
 --- /dev/null
 +++ b/drivers/media/radio/si4713/radio-usb-si4713.c

snip

 +if (time_is_before_jiffies(until_jiffies))
 +return -EIO;
 
 According with include/linux/jiffies.h:
 
   time_is_before_jiffies(a) return true if a is before jiffies.
 
 I suspect that you want to do just the opposite here: to return -EIO if
 you passed the timeout given by until_jiffies.

Don't confuse me :-)

Using before_jiffies is correct. If 'until_jiffies  jiffies', then we give up
and return -EIO. So until_jiffies is before jiffies. Or in other words:
jiffies is after until_jiffies.

I think that a macro like jiffies_is_after_time(a) would be easier to
understand.

snip

 +static int si4713_i2c_read(struct si4713_usb_device *radio, char *data, int 
 len)
 +{
 +unsigned long until_jiffies = jiffies + 
 usecs_to_jiffies(USB_RESP_TIMEOUT) + 1;
 +int retval;
 +
 +/* receive the response */
 +for (;;) {
 +retval = usb_control_msg(radio-usbdev,
 +usb_rcvctrlpipe(radio-usbdev, 0),
 +0x01, 0xa1, 0x033f, 0, radio-buffer,
 +BUFFER_LENGTH, USB_TIMEOUT);
 +if (retval  0)
 +return retval;
 +
 +/*
 + * Check that we get a valid reply back (buffer[1] == 0) and
 + * that CTS is set before returning, otherwise we wait and try
 + * again. The i2c driver also does the CTS check, but the 
 timeouts
 + * used there are much too small for this USB driver, so we wait
 + * for it here.
 + */
 +if (radio-buffer[1] == 0  (radio-buffer[2]  SI4713_CTS)) {
 +memcpy(data, radio-buffer + 2, len);
 +return 0;
 +}
 +if (time_is_before_jiffies(until_jiffies)) {
 +/* Zero the status value, ensuring CTS isn't set */
 +data[0] = 0;
 +return 0;
 +}
 
 Again, I think that the timeout condition is wrong here.

Ditto, the code is correct.

 
 +msleep(3);
 +}
 +}

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


[GIT PULL FOR v3.14] New si4713-usb driver

2013-12-13 Thread Hans Verkuil
Hi Mauro,

This patch series is identical to 
http://www.spinics.net/lists/linux-media/msg70312.html,
except that the last patch (coding style cleanups) is split into one whitespace 
clean
up patch and one time-related cleanup patch as you requested. It's also rebased 
to
the latest master.

Regards,

Hans

The following changes since commit 675722b0e3917c6c917f1aa5f6d005cd3a0479f5:

  Merge branch 'upstream-fixes' into patchwork (2013-12-13 05:04:00 -0200)

are available in the git repository at:


  git://linuxtv.org/hverkuil/media_tree.git si4713

for you to fetch changes up to 14ceedc35bdf41cf83ca3f732e4583206f5d716f:

  si4713: coding style time-related cleanups (2013-12-13 14:12:10 +0100)


Dinesh Ram (8):
  si4713: Reorganized drivers/media/radio directory
  si4713: Modified i2c driver to handle cases where interrupts are not used
  si4713: Reorganized includes in si4713.c/h
  si4713: Bug fix for si4713_tx_tune_power() method in the i2c driver
  si4713: HID blacklist Si4713 USB development board
  si4713: Added the USB driver for Si4713
  si4713: Added MAINTAINERS entry for radio-usb-si4713 driver
  si4713: move supply list to si4713_platform_data

Eduardo Valentin (1):
  si4713: print product number

Hans Verkuil (3):
  si4713: si4713_set_rds_radio_text overwrites terminating \0
  si4713: coding style whitespace cleanups
  si4713: coding style time-related cleanups

 MAINTAINERS|  12 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c   |   7 +
 drivers/hid/hid-core.c |   1 +
 drivers/hid/hid-ids.h  |   2 +
 drivers/media/radio/Kconfig|  29 
+--
 drivers/media/radio/Makefile   |   3 +-
 drivers/media/radio/si4713/Kconfig |  40 

 drivers/media/radio/si4713/Makefile|   7 +
 drivers/media/radio/{radio-si4713.c = si4713/radio-platform-si4713.c} |   0
 drivers/media/radio/si4713/radio-usb-si4713.c  | 540 
+
 drivers/media/radio/{si4713-i2c.c = si4713/si4713.c}  | 279 
++-
 drivers/media/radio/{si4713-i2c.h = si4713/si4713.h}  |   4 +-
 include/media/si4713.h |   2 +
 13 files changed, 771 insertions(+), 155 deletions(-)
 create mode 100644 drivers/media/radio/si4713/Kconfig
 create mode 100644 drivers/media/radio/si4713/Makefile
 rename drivers/media/radio/{radio-si4713.c = si4713/radio-platform-si4713.c} 
(100%)
 create mode 100644 drivers/media/radio/si4713/radio-usb-si4713.c
 rename drivers/media/radio/{si4713-i2c.c = si4713/si4713.c} (86%)
 rename drivers/media/radio/{si4713-i2c.h = si4713/si4713.h} (98%)
--
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 RFC 3/4] v4l: add new tuner types for SDR

2013-12-13 Thread Hans Verkuil
On 12/12/2013 06:12 PM, Antti Palosaari wrote:
 On 12.12.2013 09:50, Hans Verkuil wrote:
 On 12/12/2013 12:54 AM, Antti Palosaari wrote:
 Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_SDR for SDR usage.

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

 Another tuner type, SDR, is possible RF tuner. Is is used to
 down-convert RF frequency to range ADC could sample. It is optional
 for SDR device.

 Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and
 VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device
 type is SDR (VFL_TYPE_SDR).

 Shouldn't you also adapt s_hw_freq_seek?
 
 nope! I don't see how SDR could do hardware seek as demodulator is 
 needed to make decision if radio channel is valid or not. On SDR 
 receiver that demodulator is implemented by application software, DSP, 
 thus name software defined radio.
 
 Maybe it could be mapped to signal strength measurement, but it is 
 another story to think.

Fair enough, but in that case I would add:

/* s_hw_freq_seek is not supported for SDR for now */
if (vfd-vfl_type == VFL_TYPE_SDR)
return -EINVAL;

at the beginning of v4l_s_hw_freq_seek().

Regards,

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


Re: [PATCH RFC 4/4] v4l: 1 Hz resolution flag for tuners

2013-12-13 Thread Hans Verkuil
On 12/12/2013 06:22 PM, Antti Palosaari wrote:
 Hi Hans!
 
 On 12.12.2013 09:55, Hans Verkuil wrote:
 On 12/12/2013 12:54 AM, Antti Palosaari wrote:
 Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
   include/uapi/linux/videodev2.h | 1 +
   1 file changed, 1 insertion(+)

 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
 index 6c6a601..1bac6c4 100644
 --- a/include/uapi/linux/videodev2.h
 +++ b/include/uapi/linux/videodev2.h
 @@ -1349,6 +1349,7 @@ struct v4l2_modulator {
   #define V4L2_TUNER_CAP_RDS_CONTROLS   0x0200
   #define V4L2_TUNER_CAP_FREQ_BANDS 0x0400
   #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM0x0800
 +#define V4L2_TUNER_CAP_1HZ 0x1000

   /*  Flags for the 'rxsubchans' field */
   #define V4L2_TUNER_SUB_MONO   0x0001


 I was wondering, do the band modulation systems (V4L2_BAND_MODULATION_VSB 
 etc.) cover SDR?
 
 There is no such modulations defined for SDR hardware level. SDR 
 demodulation is done by software called DSP (digital signal processing) 
 in host computer.
 
 In ideal case, SDR receiver has only 1 property: ADC (analog to digital 
 converter) sampling rate.

So in that case the band modulation would be 0, right?

 
 But as digital signal processing is very CPU intensive when sampling 
 rates are increased, there is very often RF tuner used to down-convert 
 actual radio frequency to low-IF / BB. Then ADC is used to sample that 
 baseband / low-IF signal and only small sampling rate is needed = 
 stream is smaller = DSP does not need so much CPU.

How does the application know that there is an RF tuner? I assume that
the app needs to know this?

As you can probably tell, I basically know nothing about SDR, so forgive
me if I am asking stupid questions. I just want to make sure all bases
are covered when it comes to the V4L2 API.

Regards,

Hans

 Anyway, I'm happy with this patch series. As far as I am concerned, the next 
 step would
 be to add documention and I would also recommend updating v4l2-compliance. 
 Writing docs
 and adding compliance tests has proven useful in the past to discover 
 ambiguous API specs.
 
 I will do these at finally when I drivers and applications are tested to 
 be working.
 
 regards
 Antti
 

--
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] Add USB IDs for Winfast DTV Dongle Mini-D

2013-12-13 Thread Robert Backhaus
From: Robert Backhaus rob...@robbak.com
Date:   Fri Dec 13 22:59:10 2013 +1000

Add USB IDs for the WinFast DTV Dongle Mini.
Device is tested and works fine under MythTV

Signed-off-by: Robert Backhaus rob...@robbak.com

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 4a53454..6947621 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -317,6 +317,7 @@
 #define USB_PID_WINFAST_DTV_DONGLE_H   0x60f6
 #define USB_PID_WINFAST_DTV_DONGLE_STK7700P_2  0x6f01
 #define USB_PID_WINFAST_DTV_DONGLE_GOLD0x6029
+#define USB_PID_WINFAST_DTV_DONGLE_MINID   0x6f0f
 #define USB_PID_GENPIX_8PSK_REV_1_COLD 0x0200
 #define USB_PID_GENPIX_8PSK_REV_1_WARM 0x0201
 #define USB_PID_GENPIX_8PSK_REV_2  0x0202
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ecca036..fda5c64 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1407,6 +1407,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
rtl2832u_props, Dexatek DK DVB-T Dongle, NULL) },
{ DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6680,
rtl2832u_props, DigitalNow Quad DVB-T Receiver, NULL) },
+   { DVB_USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_MINID,
+   rtl2832u_props, Leadtek Winfast DTV Dongle Mini D, NULL) },
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3,
rtl2832u_props, TerraTec Cinergy T Stick RC (Rev. 3), NULL) 
},
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102,
--
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 RFC 3/4] v4l: add new tuner types for SDR

2013-12-13 Thread Hans Verkuil
On 12/12/2013 08:14 PM, Antti Palosaari wrote:
 On 12.12.2013 19:12, Antti Palosaari wrote:
 On 12.12.2013 09:50, Hans Verkuil wrote:
 On 12/12/2013 12:54 AM, Antti Palosaari wrote:
 
 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
 b/drivers/media/v4l2-core/v4l2-ioctl.c
 index bc10684..ee91a9f 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -1288,8 +1288,13 @@ static int v4l_g_frequency(const struct
 v4l2_ioctl_ops *ops,
   struct video_device *vfd = video_devdata(file);
   struct v4l2_frequency *p = arg;

 -p-type = (vfd-vfl_type == VFL_TYPE_RADIO) ?
 -V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 +if (vfd-vfl_type == VFL_TYPE_SDR) {
 +if (p-type != V4L2_TUNER_ADC  p-type != V4L2_TUNER_SDR)
 +return -EINVAL;

 This isn't right. p-type is returned by the driver, not set by the user.
 In the case of TYPE_SDR I would just set it to TUNER_SDR and let the
 driver
 update it for ADC tuners. You can also just leave it alone. This does
 make
 the assumption that SDR and ADC tuners are always separate tuners.
 I.e., not
 like radio and TV tuners that can be one physical tuner with two mutually
 exclusive modes. It's my understanding that that is by definition true
 for
 SDR.

 Aaah, so it is possible to use same tuner and that type is aimed for
 selecting tuner operation mode. Makes sense.

 So if I now understand V4L2 driver model correctly, there should be one
 tuner that implements different functionality by using tuner type field.

 I could change it easily, no problem.
 
 http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-g-frequency
 I still don't understand that. Why both index and type should be defined 
 for VIDIOC_S_FREQUENCY, but the opposite command VIDIOC_G_FREQUENCY 
 requires only index and returns type too? It does not sound correct 
 behavior.
 If S_FREQUENCY/G_FREQUENCY should be able to handle multiple tuner types 
 for same tuner index, then type must be also given that driver could 
 detect required mode.
 
 http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-g-tuner
 How I can enumerate tuners. There is G_TUNER/S_TUNER for enumerating, 
 but documentation of these IOCTLs looks like only one tuner type per 
 tuner index is supported. That offers enumeration per tuner index.

I can imagine it is confusing. According to the spec the ENUM_FREQ_BANDS,
S_HW_FREQ_SEEK and S_FREQUENCY ioctls all require the type field to be set
by the user before calling, but G_FREQUENCY and G/S_TUNER do not. And the
G/S_MODULATOR ioctls do not use a type field at all.

Frankly, I consider this a bug in the API. All of these ioctls should have
required that userspace sets the type field.

The idea behind the original API design was that a tuner can be in either
radio or TV mode, and that's determined by the type. The only ioctl that
can change the tuner mode is S_FREQUENCY where the type tells the tuner
whether to select radio or TV mode. Note that originally it didn't matter
whether S_FREQ was called on a radio or a video node, it was the type field
that determined the tuner mode, not the node it was called on. At least,
that was the theory.

In practice drivers often didn't check the type field and instead depended
on whether the ioctl came from a radio or a video node. Applications certainly
never mixed radio and video nodes. Also, calling e.g. S_STD would also switch
the tuner mode back to the TV mode, requiring drivers to keep track of the
last used radio and TV frequencies, to be restored when switching back and
forth between radio and TV mode. Frankly, the tuner type handling was a
major nightmare and few drivers handled it correctly.

The practical result of all this was that, even though an internal tuner
could operate in either TV or radio mode, from the outside world it would
look as two separate tuners. So calling G_FREQ from a radio node gives
back the last set radio frequency and from a video node the last set TV
frequency, regardless of the actual tuner mode. Ditto for G/S_TUNER: if
the tuner is in the wrong mode, the tuner data is just faked.

So the tuner type now depends on the device node that is used: it does
not have to be set by userspace (except for those ioctls where the spec
explicitly requires it) but it is filled in by the core based on the
device node used.

This scheme works fine as long as each tuner has either only one mode
or the mode can be deduced from the device node used to access it.

If we ever get tuners with multiple modes that can all be used from the
same device node, then we have a problem.

My understanding from your SDR proposal is that this doesn't happen:
you have only one or two tuners, and each tuner has only one mode.

I hope this helps instead of confusing you even more :-)

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  

Re: [PATCH] Add USB IDs for Winfast DTV Dongle Mini-D

2013-12-13 Thread Antti Palosaari

Acked-by: Antti Palosaari cr...@iki.fi
Reviewed-by: Antti Palosaari cr...@iki.fi

regards
Antti

On 13.12.2013 16:01, Robert Backhaus wrote:

From: Robert Backhaus rob...@robbak.com
Date:   Fri Dec 13 22:59:10 2013 +1000

 Add USB IDs for the WinFast DTV Dongle Mini.
 Device is tested and works fine under MythTV

 Signed-off-by: Robert Backhaus rob...@robbak.com

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 4a53454..6947621 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -317,6 +317,7 @@
  #define USB_PID_WINFAST_DTV_DONGLE_H  0x60f6
  #define USB_PID_WINFAST_DTV_DONGLE_STK7700P_2 0x6f01
  #define USB_PID_WINFAST_DTV_DONGLE_GOLD   0x6029
+#define USB_PID_WINFAST_DTV_DONGLE_MINID   0x6f0f
  #define USB_PID_GENPIX_8PSK_REV_1_COLD0x0200
  #define USB_PID_GENPIX_8PSK_REV_1_WARM0x0201
  #define USB_PID_GENPIX_8PSK_REV_2 0x0202
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ecca036..fda5c64 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1407,6 +1407,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
rtl2832u_props, Dexatek DK DVB-T Dongle, NULL) },
{ DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6680,
rtl2832u_props, DigitalNow Quad DVB-T Receiver, NULL) },
+   { DVB_USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_MINID,
+   rtl2832u_props, Leadtek Winfast DTV Dongle Mini D, NULL) },
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3,
rtl2832u_props, TerraTec Cinergy T Stick RC (Rev. 3), NULL) 
},
{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102,
--
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




--
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


Re: [PATCH RFC 1/2] v4l2: add stream format for SDR receiver

2013-12-13 Thread Hans Verkuil
On 12/12/2013 05:57 PM, Antti Palosaari wrote:
 Add new V4L2 stream format definition, named V4L2_BUF_TYPE_SDR_RX,
 for SDR receiver.
 
 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
  drivers/media/v4l2-core/v4l2-ioctl.c |  1 +
  include/trace/events/v4l2.h  |  1 +
  include/uapi/linux/videodev2.h   | 11 +++
  3 files changed, 13 insertions(+)
 
 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
 b/drivers/media/v4l2-core/v4l2-ioctl.c
 index ee91a9f..5b6e0e8 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -149,6 +149,7 @@ const char *v4l2_type_names[] = {
   [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = vid-out-overlay,
   [V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = vid-cap-mplane,
   [V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = vid-out-mplane,
 + [V4L2_BUF_TYPE_SDR_RX] = sdr-rx,

Make this SDR_CAPTURE and sdr-cap to be consistent with existing naming
conventions.

  };
  EXPORT_SYMBOL(v4l2_type_names);
  
 diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
 index ef94eca..d2ddd82 100644
 --- a/include/trace/events/v4l2.h
 +++ b/include/trace/events/v4l2.h
 @@ -18,6 +18,7 @@
   { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, VIDEO_OUTPUT_OVERLAY },\
   { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, VIDEO_CAPTURE_MPLANE },\
   { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  VIDEO_OUTPUT_MPLANE }, \
 + { V4L2_BUF_TYPE_SDR_RX,   SDR_RX }, \

SDR_CAPTURE

Regards,

Hans

   { V4L2_BUF_TYPE_PRIVATE,  PRIVATE })
  
  #define show_field(field)\
 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
 index 1bac6c4..694694a 100644
 --- a/include/uapi/linux/videodev2.h
 +++ b/include/uapi/linux/videodev2.h
 @@ -139,6 +139,7 @@ enum v4l2_buf_type {
  #endif
   V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
   V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
 + V4L2_BUF_TYPE_SDR_RX   = 11,
   /* Deprecated, do not use */
   V4L2_BUF_TYPE_PRIVATE  = 0x80,
  };
 @@ -1703,6 +1704,15 @@ struct v4l2_pix_format_mplane {
  } __attribute__ ((packed));
  
  /**
 + * struct v4l2_format_sdr - SDR format definition
 + * @pixelformat: little endian four character code (fourcc)
 + */
 +struct v4l2_format_sdr {
 + __u32   pixelformat;
 + __u8reserved[28];
 +} __attribute__ ((packed));
 +
 +/**
   * struct v4l2_format - stream data format
   * @type:enum v4l2_buf_type; type of the data stream
   * @pix: definition of an image format
 @@ -1720,6 +1730,7 @@ struct v4l2_format {
   struct v4l2_window  win; /* 
 V4L2_BUF_TYPE_VIDEO_OVERLAY */
   struct v4l2_vbi_format  vbi; /* 
 V4L2_BUF_TYPE_VBI_CAPTURE */
   struct v4l2_sliced_vbi_format   sliced;  /* 
 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
 + struct v4l2_format_sdr  sdr; /* 
 V4L2_BUF_TYPE_SDR_RX */
   __u8raw_data[200];   /* user-defined */
   } fmt;
  };
 

--
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 RFC 1/2] v4l2: add stream format for SDR receiver

2013-12-13 Thread Antti Palosaari

Thanks for the comments Hans!

On 13.12.2013 16:36, Hans Verkuil wrote:

On 12/12/2013 05:57 PM, Antti Palosaari wrote:

+   [V4L2_BUF_TYPE_SDR_RX] = sdr-rx,





Make this SDR_CAPTURE and sdr-cap to be consistent with existing naming
conventions.



+   { V4L2_BUF_TYPE_SDR_RX,   SDR_RX }, \


SDR_CAPTURE


I will change device name to from RX to CAP/CAPTURE in order to keep it 
like existing devices. I actually thought that name too, but decided to 
use RX (and TX for SDR transmitter) is it sounds more suitable for radio 
devices. But capture is not bad at all.



regards
Antti

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


Re: [PATCH RFC 2/2] v4l2: enable FMT IOCTLs for SDR

2013-12-13 Thread Hans Verkuil
On 12/12/2013 05:57 PM, Antti Palosaari wrote:
 Enable format IOCTLs for SDR use. There are used for negotiate used
 data stream format.
 
 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
  drivers/media/v4l2-core/v4l2-dev.c   | 12 
  drivers/media/v4l2-core/v4l2-ioctl.c | 26 ++
  2 files changed, 38 insertions(+)
 
 diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
 b/drivers/media/v4l2-core/v4l2-dev.c
 index c9cf54c..d67286ba 100644
 --- a/drivers/media/v4l2-core/v4l2-dev.c
 +++ b/drivers/media/v4l2-core/v4l2-dev.c
 @@ -563,6 +563,7 @@ static void determine_valid_ioctls(struct video_device 
 *vdev)
   bool is_vid = vdev-vfl_type == VFL_TYPE_GRABBER;
   bool is_vbi = vdev-vfl_type == VFL_TYPE_VBI;
   bool is_radio = vdev-vfl_type == VFL_TYPE_RADIO;
 + bool is_sdr = vdev-vfl_type == VFL_TYPE_SDR;
   bool is_rx = vdev-vfl_dir != VFL_DIR_TX;
   bool is_tx = vdev-vfl_dir != VFL_DIR_RX;
  
 @@ -612,6 +613,17 @@ static void determine_valid_ioctls(struct video_device 
 *vdev)
   if (ops-vidioc_enum_freq_bands || ops-vidioc_g_tuner || 
 ops-vidioc_g_modulator)
   set_bit(_IOC_NR(VIDIOC_ENUM_FREQ_BANDS), valid_ioctls);
  
 + if (is_sdr  is_rx) {

I would drop the is_rx part. If there even is something like a SDR transmitter,
then I would still expect that the same ioctls are needed.

 + /* SDR specific ioctls */
 + if (ops-vidioc_enum_fmt_vid_cap)
 + set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
 + if (ops-vidioc_g_fmt_vid_cap)
 + set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
 + if (ops-vidioc_s_fmt_vid_cap)
 + set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
 + if (ops-vidioc_try_fmt_vid_cap)
 + set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);

We need sdr-specific ops: vidioc_enum/g/s/try_sdr_cap.

 + }
   if (is_vid) {
   /* video specific ioctls */
   if ((is_rx  (ops-vidioc_enum_fmt_vid_cap ||

You also need to split up the large 'if (!is_radio)' part:

if (!is_radio) {
/* ioctls valid for video, vbi or sdr */
SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
SET_VALID_IOCTL(ops, VIDIOC_EXPBUF, vidioc_expbuf);
SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
}
if (!is_radio  !is_sdr) {

Regards,

Hans

 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
 b/drivers/media/v4l2-core/v4l2-ioctl.c
 index 5b6e0e8..2471179 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -879,6 +879,7 @@ static int check_fmt(struct file *file, enum 
 v4l2_buf_type type)
   const struct v4l2_ioctl_ops *ops = vfd-ioctl_ops;
   bool is_vid = vfd-vfl_type == VFL_TYPE_GRABBER;
   bool is_vbi = vfd-vfl_type == VFL_TYPE_VBI;
 + bool is_sdr = vfd-vfl_type == VFL_TYPE_SDR;
   bool is_rx = vfd-vfl_dir != VFL_DIR_TX;
   bool is_tx = vfd-vfl_dir != VFL_DIR_RX;
  
 @@ -928,6 +929,10 @@ static int check_fmt(struct file *file, enum 
 v4l2_buf_type type)
   if (is_vbi  is_tx  ops-vidioc_g_fmt_sliced_vbi_out)
   return 0;
   break;
 + case V4L2_BUF_TYPE_SDR_RX:
 + if (is_sdr  is_rx  ops-vidioc_g_fmt_vid_cap)
 + return 0;
 + break;
   default:
   break;
   }
 @@ -1047,6 +1052,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops 
 *ops,
   if (unlikely(!is_tx || !ops-vidioc_enum_fmt_vid_out_mplane))
   break;
   return ops-vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
 + case V4L2_BUF_TYPE_SDR_RX:
 + if (unlikely(!is_rx || !ops-vidioc_enum_fmt_vid_cap))
 + break;
 + return ops-vidioc_enum_fmt_vid_cap(file, fh, arg);
   }
   return -EINVAL;
  }
 @@ -1057,6 +1066,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
   struct v4l2_format *p = arg;
   struct video_device *vfd = video_devdata(file);
   bool is_vid = vfd-vfl_type == VFL_TYPE_GRABBER;
 + bool is_sdr = vfd-vfl_type == VFL_TYPE_SDR;
   bool is_rx = vfd-vfl_dir != VFL_DIR_TX;
   bool is_tx = vfd-vfl_dir != VFL_DIR_RX;
  
 @@ -1101,6 +,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
   if (unlikely(!is_tx || is_vid || 
 !ops-vidioc_g_fmt_sliced_vbi_out))
   break;
   return ops-vidioc_g_fmt_sliced_vbi_out(file, fh, arg);
 + case V4L2_BUF_TYPE_SDR_RX:
 + if 

Dear Western Union Beneficiary,

2013-12-13 Thread Western Union Money Transfer
You have been awarded $1.5m from UN/Western Union. Contact Mrs. Pamela Lee with 
your Full Name,Full Address,Phone Number,Sex,Age, [ westernunion...@mail.mn ] 
OR dial +60164802057 for more information.

Yours truly,

Mr. Allen Modderman
--
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 RFC 2/2] v4l2: enable FMT IOCTLs for SDR

2013-12-13 Thread Antti Palosaari

On 13.12.2013 16:45, Hans Verkuil wrote:

On 12/12/2013 05:57 PM, Antti Palosaari wrote:

Enable format IOCTLs for SDR use. There are used for negotiate used
data stream format.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
  drivers/media/v4l2-core/v4l2-dev.c   | 12 
  drivers/media/v4l2-core/v4l2-ioctl.c | 26 ++
  2 files changed, 38 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index c9cf54c..d67286ba 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -563,6 +563,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
bool is_vid = vdev-vfl_type == VFL_TYPE_GRABBER;
bool is_vbi = vdev-vfl_type == VFL_TYPE_VBI;
bool is_radio = vdev-vfl_type == VFL_TYPE_RADIO;
+   bool is_sdr = vdev-vfl_type == VFL_TYPE_SDR;
bool is_rx = vdev-vfl_dir != VFL_DIR_TX;
bool is_tx = vdev-vfl_dir != VFL_DIR_RX;

@@ -612,6 +613,17 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
if (ops-vidioc_enum_freq_bands || ops-vidioc_g_tuner || 
ops-vidioc_g_modulator)
set_bit(_IOC_NR(VIDIOC_ENUM_FREQ_BANDS), valid_ioctls);

+   if (is_sdr  is_rx) {


I would drop the is_rx part. If there even is something like a SDR transmitter,
then I would still expect that the same ioctls are needed.


There is TX devices too, I am looking it later, maybe on March at earliest.


+   /* SDR specific ioctls */
+   if (ops-vidioc_enum_fmt_vid_cap)
+   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+   if (ops-vidioc_g_fmt_vid_cap)
+   set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+   if (ops-vidioc_s_fmt_vid_cap)
+   set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+   if (ops-vidioc_try_fmt_vid_cap)
+   set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);


We need sdr-specific ops: vidioc_enum/g/s/try_sdr_cap.


Yes. But it could be done very easily later as it does not have effect 
to V4L2 API.





+   }
if (is_vid) {
/* video specific ioctls */
if ((is_rx  (ops-vidioc_enum_fmt_vid_cap ||


You also need to split up the large 'if (!is_radio)' part:

 if (!is_radio) {
 /* ioctls valid for video, vbi or sdr */
 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
 SET_VALID_IOCTL(ops, VIDIOC_EXPBUF, vidioc_expbuf);
 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
 SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
 SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
}
if (!is_radio  !is_sdr) {


I will change it to limit only to those relevant VB2 IOCTLs.

regards
Antti



Regards,

Hans


diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 5b6e0e8..2471179 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -879,6 +879,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type 
type)
const struct v4l2_ioctl_ops *ops = vfd-ioctl_ops;
bool is_vid = vfd-vfl_type == VFL_TYPE_GRABBER;
bool is_vbi = vfd-vfl_type == VFL_TYPE_VBI;
+   bool is_sdr = vfd-vfl_type == VFL_TYPE_SDR;
bool is_rx = vfd-vfl_dir != VFL_DIR_TX;
bool is_tx = vfd-vfl_dir != VFL_DIR_RX;

@@ -928,6 +929,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type 
type)
if (is_vbi  is_tx  ops-vidioc_g_fmt_sliced_vbi_out)
return 0;
break;
+   case V4L2_BUF_TYPE_SDR_RX:
+   if (is_sdr  is_rx  ops-vidioc_g_fmt_vid_cap)
+   return 0;
+   break;
default:
break;
}
@@ -1047,6 +1052,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!is_tx || !ops-vidioc_enum_fmt_vid_out_mplane))
break;
return ops-vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
+   case V4L2_BUF_TYPE_SDR_RX:
+   if (unlikely(!is_rx || !ops-vidioc_enum_fmt_vid_cap))
+   break;
+   return ops-vidioc_enum_fmt_vid_cap(file, fh, arg);
}
return -EINVAL;
  }
@@ -1057,6 +1066,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
struct v4l2_format *p = arg;
struct video_device *vfd = video_devdata(file);
bool is_vid = vfd-vfl_type == VFL_TYPE_GRABBER;
+   bool is_sdr = vfd-vfl_type == VFL_TYPE_SDR;
bool is_rx = vfd-vfl_dir != VFL_DIR_TX;
bool is_tx = vfd-vfl_dir != VFL_DIR_RX;

@@ 

[PATCH 10/11] media: rc: img-ir: add Sharp decoder module

2013-12-13 Thread James Hogan
Add an img-ir module for decoding the Sharp infrared protocol.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/Kconfig|   7 ++
 drivers/media/rc/img-ir/Makefile   |   1 +
 drivers/media/rc/img-ir/img-ir-sharp.c | 115 +
 3 files changed, 123 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-sharp.c

diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
index 38505188df0e..24e0966a3220 100644
--- a/drivers/media/rc/img-ir/Kconfig
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -45,3 +45,10 @@ config IR_IMG_SONY
help
   Say Y or M here to enable support for the Sony protocol in the ImgTec
   infrared decoder block.
+
+config IR_IMG_SHARP
+   tristate Sharp protocol support
+   depends on IR_IMG  IR_IMG_HW
+   help
+  Say Y or M here to enable support for the Sharp protocol in the
+  ImgTec infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
index f3e7cc4f32e4..3c3ab4f1a9f1 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_IR_IMG)+= img-ir.o
 obj-$(CONFIG_IR_IMG_NEC)   += img-ir-nec.o
 obj-$(CONFIG_IR_IMG_JVC)   += img-ir-jvc.o
 obj-$(CONFIG_IR_IMG_SONY)  += img-ir-sony.o
+obj-$(CONFIG_IR_IMG_SHARP) += img-ir-sharp.o
diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c 
b/drivers/media/rc/img-ir/img-ir-sharp.c
new file mode 100644
index ..4d70abc088b4
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sharp.c
@@ -0,0 +1,115 @@
+/*
+ * ImgTec IR Decoder setup for Sharp protocol.
+ *
+ * Copyright 2012-2013 Imagination Technologies Ltd.
+ */
+
+#include linux/module.h
+
+#include img-ir-hw.h
+
+/* Convert Sharp data to a scancode */
+static int img_ir_sharp_scancode(int len, u64 raw, u64 protocols)
+{
+   unsigned int addr, cmd, exp, chk;
+
+   if (len != 15)
+   return IMG_IR_ERR_INVALID;
+
+   addr = (raw0)  0x1f;
+   cmd  = (raw5)  0xff;
+   exp  = (raw   13)   0x1;
+   chk  = (raw   14)   0x1;
+
+   /* validate data */
+   if (!exp)
+   return IMG_IR_ERR_INVALID;
+   if (chk)
+   /* probably the second half of the message */
+   return IMG_IR_ERR_INVALID;
+
+   return addr  8 | cmd;
+}
+
+/* Convert Sharp scancode to Sharp data filter */
+static int img_ir_sharp_filter(const struct img_ir_sc_filter *in,
+  struct img_ir_filter *out, u64 protocols)
+{
+   unsigned int addr, cmd, exp = 0, chk = 0;
+   unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0;
+
+   addr   = (in-data  8)  0x1f;
+   addr_m = (in-mask  8)  0x1f;
+   cmd= (in-data  0)  0xff;
+   cmd_m  = (in-mask  0)  0xff;
+   if (cmd_m) {
+   /* if filtering commands, we can only match the first part */
+   exp   = 1;
+   exp_m = 1;
+   chk   = 0;
+   chk_m = 1;
+   }
+
+   out-data = addr|
+   cmd 5 |
+   exp13 |
+   chk14;
+   out-mask = addr_m  |
+   cmd_m   5 |
+   exp_m  13 |
+   chk_m  14;
+
+   return 0;
+}
+
+/*
+ * Sharp decoder
+ * See also http://www.sbprojects.com/knowledge/ir/sharp.php
+ */
+static struct img_ir_decoder img_ir_sharp = {
+   .type = RC_BIT_SHARP,
+   .control = {
+   .decoden = 0,
+   .decodend2 = 1,
+   .code_type = IMG_IR_CODETYPE_PULSEDIST,
+   .d1validsel = 1,
+   },
+   /* main timings */
+   .timings = {
+   /* 0 symbol */
+   .s10 = {
+   .pulse = { 320  /* 320 us */ },
+   .space = { 680  /* 1 ms period */ },
+   },
+   /* 1 symbol */
+   .s11 = {
+   .pulse = { 320  /* 230 us */ },
+   .space = { 1680 /* 2 ms period */ },
+   },
+   /* free time */
+   .ft = {
+   .minlen = 15,
+   .maxlen = 15,
+   .ft_min = 5000, /* 5 ms */
+   },
+   },
+   /* scancode logic */
+   .scancode = img_ir_sharp_scancode,
+   .filter = img_ir_sharp_filter,
+};
+
+static int __init img_ir_sharp_init(void)
+{
+   return img_ir_register_decoder(img_ir_sharp);
+}
+module_init(img_ir_sharp_init);
+
+static void __exit img_ir_sharp_exit(void)
+{
+   img_ir_unregister_decoder(img_ir_sharp);
+}
+module_exit(img_ir_sharp_exit);
+
+MODULE_AUTHOR(Imagination Technologies Ltd.);
+MODULE_DESCRIPTION(ImgTec IR Sharp protocol support);
+MODULE_LICENSE(GPL);
-- 
1.8.1.2


--
To 

[PATCH 03/11] media: rc: img-ir: add raw driver

2013-12-13 Thread James Hogan
Add raw IR remote control input driver for the ImgTec Infrared decoder
block raw edge interrupts. Generic software protocol decoders are used
to allow multiple protocols to be supported at a time, including those
not supported by the hardware decoder.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/img-ir-raw.c | 107 +++
 drivers/media/rc/img-ir/img-ir-raw.h |  58 +++
 2 files changed, 165 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-raw.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-raw.h

diff --git a/drivers/media/rc/img-ir/img-ir-raw.c 
b/drivers/media/rc/img-ir/img-ir-raw.c
new file mode 100644
index ..7e90300d6daf
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-raw.c
@@ -0,0 +1,107 @@
+/*
+ * ImgTec IR Raw Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2013 Imagination Technologies Ltd.
+ *
+ * This ties into the input subsystem using the RC-core in raw mode. Raw IR
+ * signal edges are reported and decoded by generic software decoders.
+ */
+
+#include linux/spinlock.h
+#include media/rc-core.h
+#include img-ir.h
+
+void img_ir_isr_raw(struct img_ir_priv *priv, u32 irq_status)
+{
+   struct img_ir_priv_raw *raw = priv-raw;
+   struct rc_dev *rc_dev = priv-raw.rdev;
+   int multiple;
+   u32 ir_status;
+
+   /* find whether both rise and fall was detected */
+   multiple = ((irq_status  IMG_IR_IRQ_EDGE) == IMG_IR_IRQ_EDGE);
+   /*
+* If so, we need to see if the level has actually changed.
+* If it's just noise that we didn't have time to process,
+* there's no point reporting it.
+*/
+   ir_status = img_ir_read(priv, IMG_IR_STATUS)  IMG_IR_IRRXD;
+   if (multiple  ir_status == raw-last_status)
+   return;
+   raw-last_status = ir_status;
+
+   /* report the edge to the IR raw decoders */
+   if (ir_status) /* low */
+   ir_raw_event_store_edge(rc_dev, IR_SPACE);
+   else /* high */
+   ir_raw_event_store_edge(rc_dev, IR_PULSE);
+   ir_raw_event_handle(rc_dev);
+}
+
+void img_ir_setup_raw(struct img_ir_priv *priv)
+{
+   u32 irq_en;
+   unsigned long flags;
+
+   if (!priv-raw.rdev)
+   return;
+
+   /* clear and enable edge interrupts */
+   spin_lock_irqsave(priv-lock, flags);
+   irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
+   irq_en |= IMG_IR_IRQ_EDGE;
+   img_ir_write(priv, IMG_IR_IRQ_CLEAR, IMG_IR_IRQ_EDGE);
+   img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en);
+   spin_unlock_irqrestore(priv-lock, flags);
+}
+
+int img_ir_probe_raw(struct img_ir_priv *priv)
+{
+   struct img_ir_priv_raw *raw = priv-raw;
+   struct rc_dev *rdev;
+   int error;
+
+   /* Allocate raw decoder */
+   raw-rdev = rdev = rc_allocate_device();
+   if (!rdev) {
+   dev_err(priv-dev, cannot allocate raw input device\n);
+   return -ENOMEM;
+   }
+   rdev-priv = priv;
+   rdev-map_name = RC_MAP_EMPTY;
+   rdev-input_name = IMG Infrared Decoder Raw;
+   rdev-driver_type = RC_DRIVER_IR_RAW;
+
+   /* Register raw decoder */
+   error = rc_register_device(rdev);
+   if (error) {
+   dev_err(priv-dev, failed to register raw IR input device\n);
+   rc_free_device(rdev);
+   raw-rdev = NULL;
+   return error;
+   }
+
+   return 0;
+}
+
+void img_ir_remove_raw(struct img_ir_priv *priv)
+{
+   struct img_ir_priv_raw *raw = priv-raw;
+   struct rc_dev *rdev = raw-rdev;
+   unsigned long flags;
+   u32 irq_en;
+
+   if (!rdev)
+   return;
+
+   /* switch off and disable raw (edge) interrupts */
+   spin_lock_irqsave(priv-lock, flags);
+   raw-rdev = NULL;
+   irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
+   irq_en = ~IMG_IR_IRQ_EDGE;
+   img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en);
+   img_ir_write(priv, IMG_IR_IRQ_CLEAR, IMG_IR_IRQ_EDGE);
+   spin_unlock_irqrestore(priv-lock, flags);
+
+   rc_unregister_device(rdev);
+}
diff --git a/drivers/media/rc/img-ir/img-ir-raw.h 
b/drivers/media/rc/img-ir/img-ir-raw.h
new file mode 100644
index ..d302a65e19dc
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-raw.h
@@ -0,0 +1,58 @@
+/*
+ * ImgTec IR Raw Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2013 Imagination Technologies Ltd.
+ */
+
+#ifndef _IMG_IR_RAW_H_
+#define _IMG_IR_RAW_H_
+
+struct img_ir_priv;
+
+#ifdef CONFIG_IR_IMG_RAW
+
+/**
+ * struct img_ir_priv_raw - Private driver data for raw decoder.
+ * @rdev:  Raw remote control device
+ * @last_status:   Last raw status bits.
+ */
+struct img_ir_priv_raw {
+   struct rc_dev   *rdev;
+   u32 last_status;
+};
+
+static inline bool 

[PATCH 06/11] media: rc: img-ir: add NEC decoder module

2013-12-13 Thread James Hogan
Add an img-ir module for decoding the NEC and extended NEC infrared
protocols.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/Kconfig  |   7 ++
 drivers/media/rc/img-ir/Makefile |   1 +
 drivers/media/rc/img-ir/img-ir-nec.c | 149 +++
 3 files changed, 157 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-nec.c

diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
index 60eaba6a0843..44d00227c6c4 100644
--- a/drivers/media/rc/img-ir/Kconfig
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -24,3 +24,10 @@ config IR_IMG_HW
   signals in hardware. This is more reliable, consumes less processing
   power since only a single interrupt is received for each scancode,
   and allows an IR scancode to be used as a wake event.
+
+config IR_IMG_NEC
+   tristate NEC protocol support
+   depends on IR_IMG  IR_IMG_HW
+   help
+  Say Y or M here to enable support for the NEC and extended NEC
+  protocols in the ImgTec infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
index 4ef86edec873..f3052878f092 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -4,3 +4,4 @@ img-ir-$(CONFIG_IR_IMG_HW)  += img-ir-hw.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
+obj-$(CONFIG_IR_IMG_NEC)   += img-ir-nec.o
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c 
b/drivers/media/rc/img-ir/img-ir-nec.c
new file mode 100644
index ..ba376caafaf2
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -0,0 +1,149 @@
+/*
+ * ImgTec IR Decoder setup for NEC protocol.
+ *
+ * Copyright 2010-2013 Imagination Technologies Ltd.
+ */
+
+#include linux/module.h
+
+#include img-ir-hw.h
+
+/* Convert NEC data to a scancode */
+static int img_ir_nec_scancode(int len, u64 raw, u64 protocols)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+   int scancode;
+   /* a repeat code has no data */
+   if (!len)
+   return IMG_IR_REPEATCODE;
+   if (len != 32)
+   return IMG_IR_ERR_INVALID;
+   addr = (raw   0)  0xff;
+   addr_inv = (raw   8)  0xff;
+   data = (raw  16)  0xff;
+   data_inv = (raw  24)  0xff;
+   /* Validate data */
+   if ((data_inv ^ data) != 0xff)
+   return IMG_IR_ERR_INVALID;
+
+   if ((addr_inv ^ addr) != 0xff) {
+   /* Extended NEC */
+   scancode = addr  16 |
+  addr_inv   8 |
+  data;
+   } else {
+   /* Normal NEC */
+   scancode = addr  8 |
+  data;
+   }
+   return scancode;
+}
+
+/* Convert NEC scancode to NEC data filter */
+static int img_ir_nec_filter(const struct img_ir_sc_filter *in,
+struct img_ir_filter *out, u64 protocols)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+   unsigned int addr_m, addr_inv_m, data_m;
+
+   data = in-data  0xff;
+   data_m   = in-mask  0xff;
+   data_inv = data ^ 0xff;
+
+   if (in-data  0xff00)
+   return -EINVAL;
+
+   if (in-data  0x00ff) {
+   /* Extended NEC */
+   addr   = (in-data  16)  0xff;
+   addr_m = (in-mask  16)  0xff;
+   addr_inv   = (in-data   8)  0xff;
+   addr_inv_m = (in-mask   8)  0xff;
+   } else {
+   /* Normal NEC */
+   addr   = (in-data   8)  0xff;
+   addr_m = (in-mask   8)  0xff;
+   addr_inv   = addr ^ 0xff;
+   addr_inv_m = addr_m;
+   }
+
+   out-data = data_inv  24 |
+   data  16 |
+   addr_inv   8 |
+   addr;
+   out-mask = data_m  24 |
+   data_m  16 |
+   addr_inv_m   8 |
+   addr_m;
+   return 0;
+}
+
+/*
+ * NEC decoder
+ * See also http://www.sbprojects.com/knowledge/ir/nec.php
+ *
http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol
+ */
+static struct img_ir_decoder img_ir_nec = {
+   .type = RC_BIT_NEC,
+   .control = {
+   .decoden = 1,
+   .code_type = IMG_IR_CODETYPE_PULSEDIST,
+   },
+   /* main timings */
+   .unit = 562500, /* 562.5 us */
+   .timings = {
+   /* leader symbol */
+   .ldr = {
+   .pulse = { 16   /* 9ms */ },
+   .space = { 8/* 4.5ms */ },
+   },
+   /* 0 symbol */
+   .s00 = {
+   .pulse = { 1/* 562.5 us */ },
+   .space = { 1/* 562.5 us */ },
+   

[PATCH 02/11] media: rc: img-ir: add base driver

2013-12-13 Thread James Hogan
Add base driver for the ImgTec Infrared decoder block. The driver is
split into separate components for raw (software) decode and hardware
decoder which are in following commits.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
Cc: Grant Likely grant.lik...@linaro.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: devicet...@vger.kernel.org
---
 drivers/media/rc/img-ir/img-ir-core.c | 172 ++
 drivers/media/rc/img-ir/img-ir.h  | 170 +
 2 files changed, 342 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-core.c
 create mode 100644 drivers/media/rc/img-ir/img-ir.h

diff --git a/drivers/media/rc/img-ir/img-ir-core.c 
b/drivers/media/rc/img-ir/img-ir-core.c
new file mode 100644
index ..a577217aa739
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-core.c
@@ -0,0 +1,172 @@
+/*
+ * ImgTec IR Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2013 Imagination Technologies Ltd.
+ *
+ * This contains core img-ir code for setting up the driver. The two interfaces
+ * (raw and hardware decode) are handled separately.
+ */
+
+#include linux/clk.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/spinlock.h
+#include img-ir.h
+
+static irqreturn_t img_ir_isr(int irq, void *dev_id)
+{
+   struct img_ir_priv *priv = dev_id;
+   u32 irq_status;
+
+   spin_lock(priv-lock);
+   /* we have to clear irqs before reading */
+   irq_status = img_ir_read(priv, IMG_IR_IRQ_STATUS);
+   img_ir_write(priv, IMG_IR_IRQ_CLEAR, irq_status);
+
+   /* don't handle valid data irqs if we're only interested in matches */
+   irq_status = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
+
+   /* hand off edge interrupts to raw decode handler */
+   if (irq_status  IMG_IR_IRQ_EDGE  img_ir_raw_enabled(priv-raw))
+   img_ir_isr_raw(priv, irq_status);
+
+   /* hand off hardware match interrupts to hardware decode handler */
+   if (irq_status  (IMG_IR_IRQ_DATA_MATCH |
+ IMG_IR_IRQ_DATA_VALID |
+ IMG_IR_IRQ_DATA2_VALID) 
+   img_ir_hw_enabled(priv-hw))
+   img_ir_isr_hw(priv, irq_status);
+
+   spin_unlock(priv-lock);
+   return IRQ_HANDLED;
+}
+
+static void img_ir_setup(struct img_ir_priv *priv)
+{
+   /* start off with interrupts disabled */
+   img_ir_write(priv, IMG_IR_IRQ_ENABLE, 0);
+
+   img_ir_setup_raw(priv);
+   img_ir_setup_hw(priv);
+
+   if (!IS_ERR(priv-clk))
+   clk_prepare_enable(priv-clk);
+}
+
+static void img_ir_ident(struct img_ir_priv *priv)
+{
+   u32 core_rev = img_ir_read(priv, IMG_IR_CORE_REV);
+
+   dev_info(priv-dev,
+IMG IR Decoder (%d.%d.%d.%d) probed successfully\n,
+(core_rev  IMG_IR_DESIGNER)  IMG_IR_DESIGNER_SHIFT,
+(core_rev  IMG_IR_MAJOR_REV)  IMG_IR_MAJOR_REV_SHIFT,
+(core_rev  IMG_IR_MINOR_REV)  IMG_IR_MINOR_REV_SHIFT,
+(core_rev  IMG_IR_MAINT_REV)  IMG_IR_MAINT_REV_SHIFT);
+   dev_info(priv-dev, Modes:%s%s\n,
+img_ir_hw_enabled(priv-hw) ?  hardware : ,
+img_ir_raw_enabled(priv-raw) ?  raw : );
+}
+
+static int img_ir_probe(struct platform_device *pdev)
+{
+   struct img_ir_priv *priv;
+   struct resource *res_regs;
+   int irq, error, error2;
+
+   /* Get resources from platform device */
+   irq = platform_get_irq(pdev, 0);
+   if (irq  0) {
+   dev_err(pdev-dev, cannot find IRQ resource\n);
+   return irq;
+   }
+
+   /* Private driver data */
+   priv = devm_kzalloc(pdev-dev, sizeof(*priv), GFP_KERNEL);
+   if (!priv) {
+   dev_err(pdev-dev, cannot allocate device data\n);
+   return -ENOMEM;
+   }
+   platform_set_drvdata(pdev, priv);
+   priv-dev = pdev-dev;
+   spin_lock_init(priv-lock);
+
+   /* Ioremap the registers */
+   res_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   priv-reg_base = devm_ioremap_resource(pdev-dev, res_regs);
+   if (IS_ERR(priv-reg_base))
+   return PTR_ERR(priv-reg_base);
+
+   /* Get clock */
+   priv-clk = devm_clk_get(pdev-dev, NULL);
+   if (IS_ERR(priv-clk))
+   dev_warn(pdev-dev, cannot get clock resource\n);
+
+   /* Set up raw  hw decoder */
+   error = img_ir_probe_raw(priv);
+   error2 = img_ir_probe_hw(priv);
+   if (error  error2)
+   return (error == -ENODEV) ? error2 : error;
+
+   /* Get the IRQ */
+   priv-irq = irq;
+   error = request_irq(priv-irq, img_ir_isr, 0, img-ir, priv);
+   if (error) {
+   dev_err(pdev-dev, cannot register IRQ %u\n,
+   

[PATCH 11/11] media: rc: img-ir: add Sanyo decoder module

2013-12-13 Thread James Hogan
Add an img-ir module for decoding the Sanyo infrared protocol.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/Kconfig|   7 ++
 drivers/media/rc/img-ir/Makefile   |   1 +
 drivers/media/rc/img-ir/img-ir-sanyo.c | 139 +
 3 files changed, 147 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-sanyo.c

diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
index 24e0966a3220..8c035b7c34e8 100644
--- a/drivers/media/rc/img-ir/Kconfig
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -52,3 +52,10 @@ config IR_IMG_SHARP
help
   Say Y or M here to enable support for the Sharp protocol in the
   ImgTec infrared decoder block.
+
+config IR_IMG_SANYO
+   tristate Sanyo protocol support
+   depends on IR_IMG  IR_IMG_HW
+   help
+  Say Y or M here to enable support for the Sanyo protocol (used by
+  Sanyo, Aiwa, Chinon remotes) in the ImgTec infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
index 3c3ab4f1a9f1..4f1e4305870d 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_IR_IMG_NEC)+= img-ir-nec.o
 obj-$(CONFIG_IR_IMG_JVC)   += img-ir-jvc.o
 obj-$(CONFIG_IR_IMG_SONY)  += img-ir-sony.o
 obj-$(CONFIG_IR_IMG_SHARP) += img-ir-sharp.o
+obj-$(CONFIG_IR_IMG_SANYO) += img-ir-sanyo.o
diff --git a/drivers/media/rc/img-ir/img-ir-sanyo.c 
b/drivers/media/rc/img-ir/img-ir-sanyo.c
new file mode 100644
index ..bfd44b4fd468
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sanyo.c
@@ -0,0 +1,139 @@
+/*
+ * ImgTec IR Decoder setup for Sanyo protocol.
+ *
+ * Copyright 2012-2013 Imagination Technologies Ltd.
+ *
+ * From ir-sanyo-decoder.c:
+ *
+ * This protocol uses the NEC protocol timings. However, data is formatted as:
+ * 13 bits Custom Code
+ * 13 bits NOT(Custom Code)
+ * 8 bits Key data
+ * 8 bits NOT(Key data)
+ *
+ * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon
+ * Information for this protocol is available at the Sanyo LC7461 datasheet.
+ */
+
+#include linux/module.h
+
+#include img-ir-hw.h
+
+/* Convert Sanyo data to a scancode */
+static int img_ir_sanyo_scancode(int len, u64 raw, u64 protocols)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+   /* a repeat code has no data */
+   if (!len)
+   return IMG_IR_REPEATCODE;
+   if (len != 42)
+   return IMG_IR_ERR_INVALID;
+   addr = (raw   0)  0x1fff;
+   addr_inv = (raw  13)  0x1fff;
+   data = (raw  26)  0xff;
+   data_inv = (raw  34)  0xff;
+   /* Validate data */
+   if ((data_inv ^ data) != 0xff)
+   return IMG_IR_ERR_INVALID;
+   /* Validate address */
+   if ((addr_inv ^ addr) != 0x1fff)
+   return IMG_IR_ERR_INVALID;
+
+   /* Normal Sanyo */
+   return addr  8 | data;
+}
+
+/* Convert Sanyo scancode to Sanyo data filter */
+static int img_ir_sanyo_filter(const struct img_ir_sc_filter *in,
+  struct img_ir_filter *out, u64 protocols)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+   unsigned int addr_m, data_m;
+
+   data = in-data  0xff;
+   data_m = in-mask  0xff;
+   data_inv = data ^ 0xff;
+
+   if (in-data  0xff70)
+   return -EINVAL;
+
+   addr   = (in-data  8)  0x1fff;
+   addr_m = (in-mask  8)  0x1fff;
+   addr_inv   = addr ^ 0x1fff;
+
+   out-data = (u64)data_inv  34 |
+   (u64)data  26 |
+addr_inv  13 |
+addr;
+   out-mask = (u64)data_m  34 |
+   (u64)data_m  26 |
+addr_m  13 |
+addr_m;
+   return 0;
+}
+
+/* Sanyo decoder */
+static struct img_ir_decoder img_ir_sanyo = {
+   .type = RC_BIT_SANYO,
+   .control = {
+   .decoden = 1,
+   .code_type = IMG_IR_CODETYPE_PULSEDIST,
+   },
+   /* main timings */
+   .unit = 562500, /* 562.5 us */
+   .timings = {
+   /* leader symbol */
+   .ldr = {
+   .pulse = { 16   /* 9ms */ },
+   .space = { 8/* 4.5ms */ },
+   },
+   /* 0 symbol */
+   .s00 = {
+   .pulse = { 1/* 562.5 us */ },
+   .space = { 1/* 562.5 us */ },
+   },
+   /* 1 symbol */
+   .s01 = {
+   .pulse = { 1/* 562.5 us */ },
+   .space = { 3/* 1687.5 us */ },
+   },
+   /* free time */
+   .ft = {
+   .minlen = 42,
+   

[PATCH 08/11] media: rc: img-ir: add Sony decoder module

2013-12-13 Thread James Hogan
Add an img-ir module for decoding the Sony infrared protocol.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/Kconfig   |   7 ++
 drivers/media/rc/img-ir/Makefile  |   1 +
 drivers/media/rc/img-ir/img-ir-sony.c | 163 ++
 3 files changed, 171 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-sony.c

diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
index b7774a30509f..38505188df0e 100644
--- a/drivers/media/rc/img-ir/Kconfig
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -38,3 +38,10 @@ config IR_IMG_JVC
help
   Say Y or M here to enable support for the JVC protocol in the ImgTec
   infrared decoder block.
+
+config IR_IMG_SONY
+   tristate Sony protocol support
+   depends on IR_IMG  IR_IMG_HW
+   help
+  Say Y or M here to enable support for the Sony protocol in the ImgTec
+  infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
index 1d9643801f02..f3e7cc4f32e4 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -6,3 +6,4 @@ img-ir-objs := $(img-ir-y)
 obj-$(CONFIG_IR_IMG)   += img-ir.o
 obj-$(CONFIG_IR_IMG_NEC)   += img-ir-nec.o
 obj-$(CONFIG_IR_IMG_JVC)   += img-ir-jvc.o
+obj-$(CONFIG_IR_IMG_SONY)  += img-ir-sony.o
diff --git a/drivers/media/rc/img-ir/img-ir-sony.c 
b/drivers/media/rc/img-ir/img-ir-sony.c
new file mode 100644
index ..964ab242d384
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -0,0 +1,163 @@
+/*
+ * ImgTec IR Decoder setup for Sony (SIRC) protocol.
+ *
+ * Copyright 2012-2013 Imagination Technologies Ltd.
+ */
+
+#include linux/module.h
+
+#include img-ir-hw.h
+
+/* Convert Sony data to a scancode */
+static int img_ir_sony_scancode(int len, u64 raw, u64 protocols)
+{
+   unsigned int dev, subdev, func;
+
+   switch (len) {
+   case 12:
+   if (!(protocols  RC_BIT_SONY12))
+   goto invalid;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0x1f;/* next 5 bits */
+   subdev = 0;
+   break;
+   case 15:
+   if (!(protocols  RC_BIT_SONY15))
+   goto invalid;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0xff;/* next 8 bits */
+   subdev = 0;
+   break;
+   case 20:
+   if (!(protocols  RC_BIT_SONY20))
+   goto invalid;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0x1f;/* next 5 bits */
+   raw= 5;
+   subdev = raw  0xff;/* next 8 bits */
+   break;
+   default:
+invalid:
+   return IMG_IR_ERR_INVALID;
+   }
+   return dev  16 | subdev  8 | func;
+}
+
+/* Convert NEC scancode to NEC data filter */
+static int img_ir_sony_filter(const struct img_ir_sc_filter *in,
+ struct img_ir_filter *out, u64 protocols)
+{
+   unsigned int dev, subdev, func;
+   unsigned int dev_m, subdev_m, func_m;
+   unsigned int len = 0;
+
+   dev  = (in-data  16)  0xff;
+   dev_m= (in-mask  16)  0xff;
+   subdev   = (in-data  8)   0xff;
+   subdev_m = (in-mask  8)   0xff;
+   func = (in-data  0)   0x7f;
+   func_m   = (in-mask  0)   0x7f;
+
+   if (subdev  subdev_m) {
+   /* can't encode subdev and higher device bits */
+   if (dev  dev_m  0xe0)
+   return -EINVAL;
+   /* subdevice (extended) bits only in 20 bit encoding */
+   if (!(protocols  RC_BIT_SONY20))
+   return -EINVAL;
+   len = 20;
+   dev_m = 0x1f;
+   } else if (dev  dev_m  0xe0) {
+   /* upper device bits only in 15 bit encoding */
+   if (!(protocols  RC_BIT_SONY15))
+   return -EINVAL;
+   len = 15;
+   subdev_m = 0;
+   } else {
+   /*
+* The hardware mask cannot distinguish high device bits and low
+* extended bits, so logically AND those bits of the masks
+* together.
+*/
+   subdev_m = (dev_m  5) | 0xf8;
+   dev_m = 0x1f;
+   }
+
+   /* ensure there aren't any bits straying between fields */
+   dev = dev_m;
+   subdev = subdev_m;
+
+   /* write the hardware filter */
+   out-data = func  |
+   dev   7 |
+   subdev15;
+   out-mask = func_m|
+   dev_m 7 |

[PATCH 00/11] media: rc: ImgTec IR decoder driver

2013-12-13 Thread James Hogan
Add driver for the ImgTec Infrared decoder block. Two separate rc input
devices are exposed depending on kernel configuration. One uses the
hardware decoder which is set up with timings for a specific protocol
and supports mask/value filtering and wake events. The other uses raw
edge interrupts and the generic software protocol decoders to allow
multiple protocols to be supported, including those not supported by the
hardware decoder.

The hardware decoder timing values, raw data to scan code conversion
function and scan code filter to raw data filter conversion function are
provided as separate modules for each protocol which the main driver can
use. The scan code filter value and mask (and the same again for wake
from sleep) are specified via sysfs files in /sys/class/rc/rcX/.

Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
Cc: Grant Likely grant.lik...@linaro.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: devicet...@vger.kernel.org

James Hogan (11):
  dt: binding: add binding for ImgTec IR block
  media: rc: img-ir: add base driver
  media: rc: img-ir: add raw driver
  media: rc: img-ir: add hardware decoder driver
  media: rc: img-ir: add to build
  media: rc: img-ir: add NEC decoder module
  media: rc: img-ir: add JVC decoder module
  media: rc: img-ir: add Sony decoder module
  media: rc: add Sharp infrared protocol
  media: rc: img-ir: add Sharp decoder module
  media: rc: img-ir: add Sanyo decoder module

 Documentation/devicetree/bindings/media/img-ir.txt |   20 +
 drivers/media/rc/Kconfig   |2 +
 drivers/media/rc/Makefile  |1 +
 drivers/media/rc/img-ir/Kconfig|   61 +
 drivers/media/rc/img-ir/Makefile   |   11 +
 drivers/media/rc/img-ir/img-ir-core.c  |  172 +++
 drivers/media/rc/img-ir/img-ir-hw.c| 1277 
 drivers/media/rc/img-ir/img-ir-hw.h|  284 +
 drivers/media/rc/img-ir/img-ir-jvc.c   |  109 ++
 drivers/media/rc/img-ir/img-ir-nec.c   |  149 +++
 drivers/media/rc/img-ir/img-ir-raw.c   |  107 ++
 drivers/media/rc/img-ir/img-ir-raw.h   |   58 +
 drivers/media/rc/img-ir/img-ir-sanyo.c |  139 +++
 drivers/media/rc/img-ir/img-ir-sharp.c |  115 ++
 drivers/media/rc/img-ir/img-ir-sony.c  |  163 +++
 drivers/media/rc/img-ir/img-ir.h   |  170 +++
 drivers/media/rc/rc-main.c |1 +
 include/media/rc-map.h |4 +-
 18 files changed, 2842 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/img-ir.txt
 create mode 100644 drivers/media/rc/img-ir/Kconfig
 create mode 100644 drivers/media/rc/img-ir/Makefile
 create mode 100644 drivers/media/rc/img-ir/img-ir-core.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-hw.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-hw.h
 create mode 100644 drivers/media/rc/img-ir/img-ir-jvc.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-nec.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-raw.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-raw.h
 create mode 100644 drivers/media/rc/img-ir/img-ir-sanyo.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-sharp.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-sony.c
 create mode 100644 drivers/media/rc/img-ir/img-ir.h

-- 
1.8.1.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 01/11] dt: binding: add binding for ImgTec IR block

2013-12-13 Thread James Hogan
Add device tree binding for ImgTec Consumer Infrared block.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Stephen Warren swar...@wwwdotorg.org
Cc: Ian Campbell ijc+devicet...@hellion.org.uk
Cc: devicet...@vger.kernel.org
Cc: Rob Landley r...@landley.net
Cc: linux-...@vger.kernel.org
---
 Documentation/devicetree/bindings/media/img-ir.txt | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/img-ir.txt

diff --git a/Documentation/devicetree/bindings/media/img-ir.txt 
b/Documentation/devicetree/bindings/media/img-ir.txt
new file mode 100644
index ..6f623b094ea6
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/img-ir.txt
@@ -0,0 +1,20 @@
+* ImgTec Infrared (IR) decoder
+
+Required properties:
+- compatible:  Should be img,ir
+- reg: Physical base address of the controller and length of
+   memory mapped region.
+- interrupts:  The interrupt specifier to the cpu.
+
+Optional properties:
+- clocks:  Clock specifier for base clock.
+   Defaults to 32.768KHz if not specified.
+
+Example:
+
+   ir@02006200 {
+   compatible = img,ir;
+   reg = 0x02006200 0x100;
+   interrupts = 29 4;
+   clocks = clk_32khz;
+   };
-- 
1.8.1.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 04/11] media: rc: img-ir: add hardware decoder driver

2013-12-13 Thread James Hogan
Add remote control input driver for the ImgTec Infrared block hardware
decoder, which is set up with timings for a specific protocol and
supports mask/value filtering and wake events.

The hardware decoder timing values, raw data to scan code conversion
function and scan code filter to raw data filter conversion function are
provided as separate modules for each protocol which this part of the
driver can use. The scan code filter value and mask (and the same again
for wake from sleep) are specified via sysfs files in
/sys/class/rc/rcX/.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/img-ir-hw.c | 1277 +++
 drivers/media/rc/img-ir/img-ir-hw.h |  284 
 2 files changed, 1561 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-hw.c
 create mode 100644 drivers/media/rc/img-ir/img-ir-hw.h

diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
new file mode 100644
index ..917d9a076a8c
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -0,0 +1,1277 @@
+/*
+ * ImgTec IR Hardware Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2013 Imagination Technologies Ltd.
+ *
+ * This ties into the input subsystem using the RC-core. Protocol support is
+ * provided in separate modules which provide the parameters and scancode
+ * translation functions to set up the hardware decoder and interpret the
+ * resulting input.
+ */
+
+#include linux/clk.h
+#include linux/interrupt.h
+#include linux/spinlock.h
+#include linux/timer.h
+#include media/rc-core.h
+#include img-ir.h
+
+/* Decoder list */
+static DEFINE_SPINLOCK(img_ir_decoders_lock);
+static struct img_ir_decoder *img_ir_decoders;
+static struct img_ir_priv *img_ir_privs;
+
+#define IMG_IR_F_FILTER0x0001  /* enable filtering */
+#define IMG_IR_F_WAKE  0x0002  /* enable waking */
+
+/* code type quirks */
+
+#define IMG_IR_QUIRK_CODE_BROKEN   0x1 /* Decode is broken */
+#define IMG_IR_QUIRK_CODE_LEN_INCR 0x2 /* Bit length needs increment */
+
+/* functions for preprocessing timings, ensuring max is set */
+
+static void img_ir_timing_preprocess(struct img_ir_timing_range *range,
+unsigned int unit)
+{
+   if (range-max  range-min)
+   range-max = range-min;
+   if (unit) {
+   /* multiply by unit and convert to microseconds */
+   range-min = (range-min*unit)/1000;
+   range-max = (range-max*unit + 999)/1000; /* round up */
+   }
+}
+
+static void img_ir_symbol_timing_preprocess(struct img_ir_symbol_timing 
*timing,
+   unsigned int unit)
+{
+   img_ir_timing_preprocess(timing-pulse, unit);
+   img_ir_timing_preprocess(timing-space, unit);
+}
+
+static void img_ir_timings_preprocess(struct img_ir_timings *timings,
+ unsigned int unit)
+{
+   img_ir_symbol_timing_preprocess(timings-ldr, unit);
+   img_ir_symbol_timing_preprocess(timings-s00, unit);
+   img_ir_symbol_timing_preprocess(timings-s01, unit);
+   img_ir_symbol_timing_preprocess(timings-s10, unit);
+   img_ir_symbol_timing_preprocess(timings-s11, unit);
+   /* default s10 and s11 to s00 and s01 if no leader */
+   if (unit)
+   /* multiply by unit and convert to microseconds (round up) */
+   timings-ft.ft_min = (timings-ft.ft_min*unit + 999)/1000;
+}
+
+/* functions for filling empty fields with defaults */
+
+static void img_ir_timing_defaults(struct img_ir_timing_range *range,
+  struct img_ir_timing_range *defaults)
+{
+   if (!range-min)
+   range-min = defaults-min;
+   if (!range-max)
+   range-max = defaults-max;
+}
+
+static void img_ir_symbol_timing_defaults(struct img_ir_symbol_timing *timing,
+ struct img_ir_symbol_timing *defaults)
+{
+   img_ir_timing_defaults(timing-pulse, defaults-pulse);
+   img_ir_timing_defaults(timing-space, defaults-space);
+}
+
+static void img_ir_timings_defaults(struct img_ir_timings *timings,
+   struct img_ir_timings *defaults)
+{
+   img_ir_symbol_timing_defaults(timings-ldr, defaults-ldr);
+   img_ir_symbol_timing_defaults(timings-s00, defaults-s00);
+   img_ir_symbol_timing_defaults(timings-s01, defaults-s01);
+   img_ir_symbol_timing_defaults(timings-s10, defaults-s10);
+   img_ir_symbol_timing_defaults(timings-s11, defaults-s11);
+   if (!timings-ft.ft_min)
+   timings-ft.ft_min = defaults-ft.ft_min;
+}
+
+/* functions for converting timings to register values */
+
+/**
+ * img_ir_control() - Convert control struct to control register value.
+ * @control:   Control data
+ *
+ * 

[PATCH 05/11] media: rc: img-ir: add to build

2013-12-13 Thread James Hogan
Add ImgTec IR decoder driver to the build system.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/Kconfig |  2 ++
 drivers/media/rc/Makefile|  1 +
 drivers/media/rc/img-ir/Kconfig  | 26 ++
 drivers/media/rc/img-ir/Makefile |  6 ++
 4 files changed, 35 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/Kconfig
 create mode 100644 drivers/media/rc/img-ir/Makefile

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 904f11367c29..43b71813862e 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -300,6 +300,8 @@ config IR_RX51
   The driver uses omap DM timers for generating the carrier
   wave and pulses.
 
+source drivers/media/rc/img-ir/Kconfig
+
 config RC_LOOPBACK
tristate Remote Control Loopback Driver
depends on RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index f4eb32c0a455..cbe3d44f7fab 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
 obj-$(CONFIG_IR_IGUANA) += iguanair.o
 obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
 obj-$(CONFIG_RC_ST) += st_rc.o
+obj-$(CONFIG_IR_IMG) += img-ir/
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
new file mode 100644
index ..60eaba6a0843
--- /dev/null
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -0,0 +1,26 @@
+config IR_IMG
+   tristate ImgTec IR Decoder
+   depends on RC_CORE
+   select IR_IMG_HW if !IR_IMG_RAW
+   help
+  Say Y or M here if you want to use the ImgTec infrared decoder
+  functionality found in SoCs such as TZ1090.
+
+config IR_IMG_RAW
+   bool Raw decoder
+   depends on IR_IMG
+   help
+  Say Y here to enable the raw mode driver which passes raw IR signal
+  changes to the IR raw decoders for software decoding. This is much
+  less reliable (due to lack of timestamps) and consumes more
+  processing power than using hardware decode, but can be useful for
+  testing, debug, and to make more protocols available.
+
+config IR_IMG_HW
+   bool Hardware decoder
+   depends on IR_IMG
+   help
+  Say Y here to enable the hardware decode driver which decodes the IR
+  signals in hardware. This is more reliable, consumes less processing
+  power since only a single interrupt is received for each scancode,
+  and allows an IR scancode to be used as a wake event.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
new file mode 100644
index ..4ef86edec873
--- /dev/null
+++ b/drivers/media/rc/img-ir/Makefile
@@ -0,0 +1,6 @@
+img-ir-y   := img-ir-core.o
+img-ir-$(CONFIG_IR_IMG_RAW)+= img-ir-raw.o
+img-ir-$(CONFIG_IR_IMG_HW) += img-ir-hw.o
+img-ir-objs:= $(img-ir-y)
+
+obj-$(CONFIG_IR_IMG)   += img-ir.o
-- 
1.8.1.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 07/11] media: rc: img-ir: add JVC decoder module

2013-12-13 Thread James Hogan
Add an img-ir module for decoding the JVC infrared protocol.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/Kconfig  |   7 +++
 drivers/media/rc/img-ir/Makefile |   1 +
 drivers/media/rc/img-ir/img-ir-jvc.c | 109 +++
 3 files changed, 117 insertions(+)
 create mode 100644 drivers/media/rc/img-ir/img-ir-jvc.c

diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
index 44d00227c6c4..b7774a30509f 100644
--- a/drivers/media/rc/img-ir/Kconfig
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -31,3 +31,10 @@ config IR_IMG_NEC
help
   Say Y or M here to enable support for the NEC and extended NEC
   protocols in the ImgTec infrared decoder block.
+
+config IR_IMG_JVC
+   tristate JVC protocol support
+   depends on IR_IMG  IR_IMG_HW
+   help
+  Say Y or M here to enable support for the JVC protocol in the ImgTec
+  infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
index f3052878f092..1d9643801f02 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -5,3 +5,4 @@ img-ir-objs := $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
 obj-$(CONFIG_IR_IMG_NEC)   += img-ir-nec.o
+obj-$(CONFIG_IR_IMG_JVC)   += img-ir-jvc.o
diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c 
b/drivers/media/rc/img-ir/img-ir-jvc.c
new file mode 100644
index ..a6f383afd2b3
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-jvc.c
@@ -0,0 +1,109 @@
+/*
+ * ImgTec IR Decoder setup for JVC protocol.
+ *
+ * Copyright 2012-2013 Imagination Technologies Ltd.
+ */
+
+#include linux/module.h
+
+#include img-ir-hw.h
+
+/* Convert JVC data to a scancode */
+static int img_ir_jvc_scancode(int len, u64 raw, u64 protocols)
+{
+   unsigned int cust, data;
+
+   if (len != 16)
+   return IMG_IR_ERR_INVALID;
+
+   cust = (raw  0)  0xff;
+   data = (raw  8)  0xff;
+
+   return cust  8 | data;
+}
+
+/* Convert JVC scancode to JVC data filter */
+static int img_ir_jvc_filter(const struct img_ir_sc_filter *in,
+struct img_ir_filter *out, u64 protocols)
+{
+   unsigned int cust, data;
+   unsigned int cust_m, data_m;
+
+   cust   = (in-data  8)  0xff;
+   cust_m = (in-mask  8)  0xff;
+   data   = (in-data  0)  0xff;
+   data_m = (in-mask  0)  0xff;
+
+   out-data = cust   | data  8;
+   out-mask = cust_m | data_m  8;
+
+   return 0;
+}
+
+/*
+ * JVC decoder
+ * See also http://www.sbprojects.com/knowledge/ir/jvc.php
+ *  http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf
+ */
+static struct img_ir_decoder img_ir_jvc = {
+   .type = RC_BIT_JVC,
+   .control = {
+   .decoden = 1,
+   .code_type = IMG_IR_CODETYPE_PULSEDIST,
+   .decodend2 = 1,
+   },
+   /* main timings */
+   .unit = 527500, /* 527.5 us */
+   .timings = {
+   /* leader symbol */
+   .ldr = {
+   .pulse = { 16   /* 8.44 ms */ },
+   .space = { 8/* 4.22 ms */ },
+   },
+   /* 0 symbol */
+   .s00 = {
+   .pulse = { 1/* 527.5 us +-60 us */ },
+   .space = { 1/* 527.5 us */ },
+   },
+   /* 1 symbol */
+   .s01 = {
+   .pulse = { 1/* 527.5 us +-60 us */ },
+   .space = { 3/* 1.5825 ms +-40 us */ },
+   },
+   /* 0 symbol (no leader) */
+   .s00 = {
+   .pulse = { 1/* 527.5 us +-60 us */ },
+   .space = { 1/* 527.5 us */ },
+   },
+   /* 1 symbol (no leader) */
+   .s01 = {
+   .pulse = { 1/* 527.5 us +-60 us */ },
+   .space = { 3/* 1.5825 ms +-40 us */ },
+   },
+   /* free time */
+   .ft = {
+   .minlen = 16,
+   .maxlen = 16,
+   .ft_min = 10,   /* 5.275 ms */
+   },
+   },
+   /* scancode logic */
+   .scancode = img_ir_jvc_scancode,
+   .filter = img_ir_jvc_filter,
+};
+
+static int __init img_ir_jvc_init(void)
+{
+   return img_ir_register_decoder(img_ir_jvc);
+}
+module_init(img_ir_jvc_init);
+
+static void __exit img_ir_jvc_exit(void)
+{
+   img_ir_unregister_decoder(img_ir_jvc);
+}
+module_exit(img_ir_jvc_exit);
+
+MODULE_AUTHOR(Imagination Technologies Ltd.);
+MODULE_DESCRIPTION(ImgTec IR JVC protocol support);
+MODULE_LICENSE(GPL);
-- 
1.8.1.2


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a 

[PATCH 09/11] media: rc: add Sharp infrared protocol

2013-12-13 Thread James Hogan
Add Sharp infrared protocol constants RC_TYPE_SHARP and RC_BIT_SHARP.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/rc-main.c | 1 +
 include/media/rc-map.h | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 46da365c9c84..a1b90ef45910 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -786,6 +786,7 @@ static struct {
  RC_BIT_SONY20,sony  },
{ RC_BIT_RC5_SZ,rc-5-sz   },
{ RC_BIT_SANYO, sanyo },
+   { RC_BIT_SHARP, sharp },
{ RC_BIT_MCE_KBD,   mce_kbd   },
{ RC_BIT_LIRC,  lirc  },
 };
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a20ed97d7d8a..b3224edf1b46 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -30,6 +30,7 @@ enum rc_type {
RC_TYPE_RC6_6A_24   = 15,   /* Philips RC6-6A-24 protocol */
RC_TYPE_RC6_6A_32   = 16,   /* Philips RC6-6A-32 protocol */
RC_TYPE_RC6_MCE = 17,   /* MCE (Philips RC6-6A-32 subtype) 
protocol */
+   RC_TYPE_SHARP   = 18,   /* Sharp protocol */
 };
 
 #define RC_BIT_NONE0
@@ -51,6 +52,7 @@ enum rc_type {
 #define RC_BIT_RC6_6A_24   (1  RC_TYPE_RC6_6A_24)
 #define RC_BIT_RC6_6A_32   (1  RC_TYPE_RC6_6A_32)
 #define RC_BIT_RC6_MCE (1  RC_TYPE_RC6_MCE)
+#define RC_BIT_SHARP   (1  RC_TYPE_SHARP)
 
 #define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \
 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
@@ -58,7 +60,7 @@ enum rc_type {
 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
-RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)
+RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP)
 
 struct rc_map_table {
u32 scancode;
-- 
1.8.1.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 RFC 2/2] v4l2: enable FMT IOCTLs for SDR

2013-12-13 Thread Hans Verkuil
On 12/13/2013 04:04 PM, Antti Palosaari wrote:
 On 13.12.2013 16:45, Hans Verkuil wrote:
 On 12/12/2013 05:57 PM, Antti Palosaari wrote:
 Enable format IOCTLs for SDR use. There are used for negotiate used
 data stream format.

 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
   drivers/media/v4l2-core/v4l2-dev.c   | 12 
   drivers/media/v4l2-core/v4l2-ioctl.c | 26 ++
   2 files changed, 38 insertions(+)

 diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
 b/drivers/media/v4l2-core/v4l2-dev.c
 index c9cf54c..d67286ba 100644
 --- a/drivers/media/v4l2-core/v4l2-dev.c
 +++ b/drivers/media/v4l2-core/v4l2-dev.c
 @@ -563,6 +563,7 @@ static void determine_valid_ioctls(struct video_device 
 *vdev)
 bool is_vid = vdev-vfl_type == VFL_TYPE_GRABBER;
 bool is_vbi = vdev-vfl_type == VFL_TYPE_VBI;
 bool is_radio = vdev-vfl_type == VFL_TYPE_RADIO;
 +   bool is_sdr = vdev-vfl_type == VFL_TYPE_SDR;
 bool is_rx = vdev-vfl_dir != VFL_DIR_TX;
 bool is_tx = vdev-vfl_dir != VFL_DIR_RX;

 @@ -612,6 +613,17 @@ static void determine_valid_ioctls(struct video_device 
 *vdev)
 if (ops-vidioc_enum_freq_bands || ops-vidioc_g_tuner || 
 ops-vidioc_g_modulator)
 set_bit(_IOC_NR(VIDIOC_ENUM_FREQ_BANDS), valid_ioctls);

 +   if (is_sdr  is_rx) {

 I would drop the is_rx part. If there even is something like a SDR 
 transmitter,
 then I would still expect that the same ioctls are needed.
 
 There is TX devices too, I am looking it later, maybe on March at earliest.
 
 +   /* SDR specific ioctls */
 +   if (ops-vidioc_enum_fmt_vid_cap)
 +   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
 +   if (ops-vidioc_g_fmt_vid_cap)
 +   set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
 +   if (ops-vidioc_s_fmt_vid_cap)
 +   set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
 +   if (ops-vidioc_try_fmt_vid_cap)
 +   set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);

 We need sdr-specific ops: vidioc_enum/g/s/try_sdr_cap.
 
 Yes. But it could be done very easily later as it does not have effect 
 to V4L2 API.

It's much easier to do it right the first time, then to add it in later :-)

Spoken from personal experience...

Anyway, this really should be implemented like that. Things can get very
confusing otherwise.

Regards,

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


Re: [PATCH RFC 4/4] v4l: 1 Hz resolution flag for tuners

2013-12-13 Thread Antti Palosaari

On 13.12.2013 16:05, Hans Verkuil wrote:

On 12/12/2013 06:22 PM, Antti Palosaari wrote:

Hi Hans!

On 12.12.2013 09:55, Hans Verkuil wrote:

On 12/12/2013 12:54 AM, Antti Palosaari wrote:

Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
   include/uapi/linux/videodev2.h | 1 +
   1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 6c6a601..1bac6c4 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1349,6 +1349,7 @@ struct v4l2_modulator {
   #define V4L2_TUNER_CAP_RDS_CONTROLS  0x0200
   #define V4L2_TUNER_CAP_FREQ_BANDS0x0400
   #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM   0x0800
+#define V4L2_TUNER_CAP_1HZ 0x1000

   /*  Flags for the 'rxsubchans' field */
   #define V4L2_TUNER_SUB_MONO  0x0001



I was wondering, do the band modulation systems (V4L2_BAND_MODULATION_VSB etc.) 
cover SDR?


There is no such modulations defined for SDR hardware level. SDR
demodulation is done by software called DSP (digital signal processing)
in host computer.

In ideal case, SDR receiver has only 1 property: ADC (analog to digital
converter) sampling rate.


So in that case the band modulation would be 0, right?


Yes. If you split that radio receiver to some logic blocs, from antenna 
to host computer:

1. Antenna is here
2. RF tuner (RF frontend): tuner band belongs here
3. ADC: sampling rate
4. demodulator (modulation lives here)

In a case of traditional hw based demodulator PC/host computer is 
located as a number 5. In a case of a software defined radio receiver 
host computer is next to ADC, between 3-4. Demodulator itself is DSP 
software running on host computer.




But as digital signal processing is very CPU intensive when sampling
rates are increased, there is very often RF tuner used to down-convert
actual radio frequency to low-IF / BB. Then ADC is used to sample that
baseband / low-IF signal and only small sampling rate is needed =
stream is smaller = DSP does not need so much CPU.


How does the application know that there is an RF tuner? I assume that
the app needs to know this?


Yes, that indeed needs to be know. It is one key issue to resolve. 
Something like a capability flag works or application could test it 
when. Like if tuner type is ADC then enumerate if there is tuner type 
SDR also. Or expect there is always RF tuner and frequency is 
programmed as a 0 Hz when it is not really there. Enumeration of RF 
tuner returns only supported frequency as a 0Hz to tell there is only ADC.




As you can probably tell, I basically know nothing about SDR, so forgive
me if I am asking stupid questions. I just want to make sure all bases
are covered when it comes to the V4L2 API.


I really appreciate that as simply has no enough knowledge from V4L2 API 
and API changes are needed. I will try to list here shortly some SDR 
devices in general level enough.


ant = antenna
host = host computer, PC (SW modulator/demodulator)
ADC = analog to digital converter
DAC = digital to analog converter
amp = amplifier
mixer = TX tuner

receiver:
ant  RF tuner  ADC  bridge  host
ant ADC  bridge  host
ant  up-converter  RF tuner  ADC  bridge  host

transmitter:
ant  amp  mixer  DAC  bridge  host
ant  mixer  DAC  bridge  host
ant  DAC  bridge  host

Those are the used building blocks in some general view. ADC (DAC) is 
most important hardware block, but RF tuner is also critical in practice.


So what I understood, V4L2 API tuner is kinda logical entity that 
represent single radio device, containing RF tuner, demodulator and so. 
That same logical entity in DVB API side is frontend, which is mostly 
implemented by demodulator with a help of RF tuner.


So what is needed is to make V4L2 API entity (tuner I guess) that could 
represent both ADC and RF tuner.


regards
Antti

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


Re: [PATCH RFC 4/4] v4l: 1 Hz resolution flag for tuners

2013-12-13 Thread Hans Verkuil
On 12/13/2013 04:42 PM, Antti Palosaari wrote:
 On 13.12.2013 16:05, Hans Verkuil wrote:
 On 12/12/2013 06:22 PM, Antti Palosaari wrote:
 Hi Hans!

 On 12.12.2013 09:55, Hans Verkuil wrote:
 On 12/12/2013 12:54 AM, Antti Palosaari wrote:
 Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
include/uapi/linux/videodev2.h | 1 +
1 file changed, 1 insertion(+)

 diff --git a/include/uapi/linux/videodev2.h 
 b/include/uapi/linux/videodev2.h
 index 6c6a601..1bac6c4 100644
 --- a/include/uapi/linux/videodev2.h
 +++ b/include/uapi/linux/videodev2.h
 @@ -1349,6 +1349,7 @@ struct v4l2_modulator {
#define V4L2_TUNER_CAP_RDS_CONTROLS0x0200
#define V4L2_TUNER_CAP_FREQ_BANDS  0x0400
#define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800
 +#define V4L2_TUNER_CAP_1HZ   0x1000

/*  Flags for the 'rxsubchans' field */
#define V4L2_TUNER_SUB_MONO0x0001


 I was wondering, do the band modulation systems (V4L2_BAND_MODULATION_VSB 
 etc.) cover SDR?

 There is no such modulations defined for SDR hardware level. SDR
 demodulation is done by software called DSP (digital signal processing)
 in host computer.

 In ideal case, SDR receiver has only 1 property: ADC (analog to digital
 converter) sampling rate.

 So in that case the band modulation would be 0, right?
 
 Yes. If you split that radio receiver to some logic blocs, from antenna 
 to host computer:
 1. Antenna is here
 2. RF tuner (RF frontend): tuner band belongs here
 3. ADC: sampling rate
 4. demodulator (modulation lives here)
 
 In a case of traditional hw based demodulator PC/host computer is 
 located as a number 5. In a case of a software defined radio receiver 
 host computer is next to ADC, between 3-4. Demodulator itself is DSP 
 software running on host computer.
 
 
 But as digital signal processing is very CPU intensive when sampling
 rates are increased, there is very often RF tuner used to down-convert
 actual radio frequency to low-IF / BB. Then ADC is used to sample that
 baseband / low-IF signal and only small sampling rate is needed =
 stream is smaller = DSP does not need so much CPU.

 How does the application know that there is an RF tuner? I assume that
 the app needs to know this?
 
 Yes, that indeed needs to be know. It is one key issue to resolve. 
 Something like a capability flag works or application could test it 
 when. Like if tuner type is ADC then enumerate if there is tuner type 
 SDR also.

Instead of calling it TUNER_TYPE_SDR, shouldn't it be called TUNER_TYPE_RF?
Or perhaps _SDR_RF?

 Or expect there is always RF tuner and frequency is 
 programmed as a 0 Hz when it is not really there. Enumeration of RF 
 tuner returns only supported frequency as a 0Hz to tell there is only ADC.

I think just enumerating tuners to see if there is a RF tuner would be
sufficient.

 
 
 As you can probably tell, I basically know nothing about SDR, so forgive
 me if I am asking stupid questions. I just want to make sure all bases
 are covered when it comes to the V4L2 API.
 
 I really appreciate that as simply has no enough knowledge from V4L2 API 
 and API changes are needed. I will try to list here shortly some SDR 
 devices in general level enough.
 
 ant = antenna
 host = host computer, PC (SW modulator/demodulator)
 ADC = analog to digital converter
 DAC = digital to analog converter
 amp = amplifier
 mixer = TX tuner
 
 receiver:
 ant  RF tuner  ADC  bridge  host
 ant ADC  bridge  host
 ant  up-converter  RF tuner  ADC  bridge  host
 
 transmitter:
 ant  amp  mixer  DAC  bridge  host
 ant  mixer  DAC  bridge  host
 ant  DAC  bridge  host
 
 Those are the used building blocks in some general view. ADC (DAC) is 
 most important hardware block, but RF tuner is also critical in practice.
 
 So what I understood, V4L2 API tuner is kinda logical entity that 
 represent single radio device, containing RF tuner, demodulator and so. 
 That same logical entity in DVB API side is frontend, which is mostly 
 implemented by demodulator with a help of RF tuner.
 
 So what is needed is to make V4L2 API entity (tuner I guess) that could 
 represent both ADC and RF tuner.

Well, a V4L2 tuner represents the hardware that requires a frequency.
Which for typical radio and TV devices means the RF tuner + demodulator
combo. So externally you see only one tuner, but internally there are
often two devices (tuner and modulator) that have to be controlled.

For SDR you have an RF Tuner with a frequency and an ADC with a frequency,
and the two frequencies can be set independently. So representing that
as two tuners seems like a sensible mapping to me.

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


[REVIEW PATCH 0/9] vb2: various cleanups and improvements

2013-12-13 Thread Hans Verkuil
This patch series does some cleanups in the qbuf/prepare_buf handling
(the first three patches). The fourth patch removes the 'fileio = NULL'
hack. That hack no longer works when dealing with asynchronous calls
from a kernel thread so it had to be fixed.

The next three patches implement retrying start_streaming() if there are
not enough buffers queued for the DMA engine to start. I know that there
are more drivers that can be simplified with this feature available in
the core. Those drivers do the retry of start_streaming in the buf_queue
op which frankly defeats the purpose of having a central start_streaming
op. But I leave it to the driver developers to decide whether or not to
cleanup their drivers.

The big advantage is that apps can just call STREAMON first, then start
queuing buffers without having to know the minimum number of buffers that
have to be queued before the DMA engine will kick in. It always annoyed
me that vb2 didn't take care of that for me as it is easy enough to do.

The eighth patch adds a fix based on a patch from Andy that removes the
file I/O emulation assumption that buffers are dequeued in the same
order that they were enqueued.

The final patch makes a slight change to the STREAMON documentation to
bring it in line with reality.

Regards,

Hans

Changes since RFCv4:

- Replaced ENODATA by ENOBUFS
- Added DocBook fix

--
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


[REVIEW PATCH 8/9] vb2: Improve file I/O emulation to handle buffers in any order

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

videobuf2 file I/O emulation assumed that buffers dequeued from the
driver would return in the order they were enqueued in the driver.

Improve the file I/O emulator's book-keeping to remove this assumption.

Also set the buf-size properly if a write() dequeues a buffer and the
VB2_FILEIO_WRITE_IMMEDIATELY flag is set.

Based on an initial patch by Andy Walls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Andy Walls awa...@md.metrocast.net
---
 drivers/media/v4l2-core/videobuf2-core.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 8d61e6d..08c4a87 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2354,6 +2354,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
goto err_reqbufs;
fileio-bufs[i].queued = 1;
}
+   fileio-index = q-num_buffers;
}
 
/*
@@ -2429,15 +2430,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
}
fileio = q-fileio;
 
-   index = fileio-index;
-   buf = fileio-bufs[index];
-
/*
 * Check if we need to dequeue the buffer.
 */
-   if (buf-queued) {
-   struct vb2_buffer *vb;
-
+   index = fileio-index;
+   if (index = q-num_buffers) {
/*
 * Call vb2_dqbuf to get buffer back.
 */
@@ -2450,12 +2447,18 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
return ret;
fileio-dq_count += 1;
 
+   index = fileio-b.index;
+   buf = fileio-bufs[index];
+
/*
 * Get number of bytes filled by the driver
 */
-   vb = q-bufs[index];
-   buf-size = vb2_get_plane_payload(vb, 0);
+   buf-pos = 0;
buf-queued = 0;
+   buf-size = read ? vb2_get_plane_payload(q-bufs[index], 0)
+: vb2_plane_size(q-bufs[index], 0);
+   } else {
+   buf = fileio-bufs[index];
}
 
/*
@@ -2518,13 +2521,10 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 */
buf-pos = 0;
buf-queued = 1;
-   buf-size = q-bufs[0]-v4l2_planes[0].length;
+   buf-size = vb2_plane_size(q-bufs[index], 0);
fileio-q_count += 1;
-
-   /*
-* Switch to the next buffer
-*/
-   fileio-index = (index + 1) % q-num_buffers;
+   if (fileio-index  q-num_buffers)
+   fileio-index++;
}
 
/*
-- 
1.8.4.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


[REVIEW PATCH 6/9] vb2: don't set index, don't start streaming for write()

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Two fixes:

- there is no need to set the index when calling dqbuf: dqbuf will
  overwrite it.
- __vb2_init_fileio already starts streaming for write(), so there is
  no need to do it again in __vb2_perform_fileio. It can never have
  worked anyway: either __vb2_init_fileio succeeds in starting streaming
  or it is never going to happen.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 28e64b1..8d61e6d 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2444,7 +2444,6 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
memset(fileio-b, 0, sizeof(fileio-b));
fileio-b.type = q-type;
fileio-b.memory = q-memory;
-   fileio-b.index = index;
ret = vb2_internal_dqbuf(q, fileio-b, nonblock);
dprintk(5, file io: vb2_dqbuf result: %d\n, ret);
if (ret)
@@ -2526,15 +2525,6 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 * Switch to the next buffer
 */
fileio-index = (index + 1) % q-num_buffers;
-
-   /*
-* Start streaming if required.
-*/
-   if (!read  !q-streaming) {
-   ret = vb2_internal_streamon(q, q-type);
-   if (ret)
-   return ret;
-   }
}
 
/*
-- 
1.8.4.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


[REVIEW PATCH 4/9] vb2: remove the 'fileio = NULL' hack.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The read/write implementation in vb2 reuses existing vb2 functions, but
it sets q-fileio to NULL before calling them in order to skip the
'q-fileio != NULL' check.

This works today due to the synchronous nature of read/write, but it
1) is ugly, and 2) will fail in an asynchronous use-case such as a
thread queuing and dequeuing buffers. This last example will be necessary
in order to implement vb2 DVB support.

This patch removes the hack by splitting up the dqbuf/qbuf/streamon/streamoff
functions into an external and an internal version. The external version
checks q-fileio and then calls the internal version. The read/write
implementation now just uses the internal version, removing the need to
set q-fileio to NULL.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 223 ---
 1 file changed, 112 insertions(+), 111 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index a537094..2096a0d 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1306,11 +1306,6 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
const char *opname)
 {
-   if (q-fileio) {
-   dprintk(1, %s(): file io in progress\n, opname);
-   return -EBUSY;
-   }
-
if (b-type != q-type) {
dprintk(1, %s(): invalid buffer type\n, opname);
return -EINVAL;
@@ -1352,9 +1347,15 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
  */
 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   int ret = vb2_queue_or_prepare_buf(q, b, prepare_buf);
struct vb2_buffer *vb;
+   int ret;
+
+   if (q-fileio) {
+   dprintk(1, %s(): file io in progress\n, __func__);
+   return -EBUSY;
+   }
 
+   ret = vb2_queue_or_prepare_buf(q, b, prepare_buf);
if (ret)
return ret;
 
@@ -1376,24 +1377,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
-/**
- * vb2_qbuf() - Queue a buffer from userspace
- * @q: videobuf2 queue
- * @b: buffer structure passed from userspace to vidioc_qbuf handler
- * in driver
- *
- * Should be called from vidioc_qbuf ioctl handler of a driver.
- * This function:
- * 1) verifies the passed buffer,
- * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
- *which driver-specific buffer initialization can be performed,
- * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
- *callback for processing.
- *
- * The return values from this function are intended to be directly returned
- * from vidioc_qbuf handler in driver.
- */
-int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
+static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
int ret = vb2_queue_or_prepare_buf(q, b, qbuf);
struct vb2_buffer *vb;
@@ -1444,6 +1428,33 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
dprintk(1, %s() of buffer %d succeeded\n, __func__, 
vb-v4l2_buf.index);
return 0;
 }
+
+/**
+ * vb2_qbuf() - Queue a buffer from userspace
+ * @q: videobuf2 queue
+ * @b: buffer structure passed from userspace to vidioc_qbuf handler
+ * in driver
+ *
+ * Should be called from vidioc_qbuf ioctl handler of a driver.
+ * This function:
+ * 1) verifies the passed buffer,
+ * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
+ *which driver-specific buffer initialization can be performed,
+ * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
+ *callback for processing.
+ *
+ * The return values from this function are intended to be directly returned
+ * from vidioc_qbuf handler in driver.
+ */
+int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
+{
+   if (q-fileio) {
+   dprintk(1, %s(): file io in progress\n, __func__);
+   return -EBUSY;
+   }
+
+   return vb2_internal_qbuf(q, b);
+}
 EXPORT_SYMBOL_GPL(vb2_qbuf);
 
 /**
@@ -1592,37 +1603,11 @@ static void __vb2_dqbuf(struct vb2_buffer *vb)
}
 }
 
-/**
- * vb2_dqbuf() - Dequeue a buffer to the userspace
- * @q: videobuf2 queue
- * @b: buffer structure passed from userspace to vidioc_dqbuf handler
- * in driver
- * @nonblocking: if true, this call will not sleep waiting for a buffer if no
- *  buffers ready for dequeuing are present. Normally the driver
- *  would be passing (file-f_flags  O_NONBLOCK) here
- *
- * Should be called from vidioc_dqbuf ioctl handler of a 

[REVIEW PATCH 3/9] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

When preparing a buffer the queue lock is released for a short while
if the memory mode is USERPTR (see __buf_prepare for the details), which
would allow a race with a REQBUFS which can free the buffers. Removing the
buffers from underneath __buf_prepare is obviously a bad idea, so we
check if any of the buffers is in the state PREPARING, and if so we
just return -EAGAIN.

If this happens, then the application does something really strange. The
REQBUFS call can be retried safely, since this situation is transient.

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

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 08ad883..a537094 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -298,10 +298,28 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned 
int buffers)
  * related information, if no buffers are left return the queue to an
  * uninitialized state. Might be called even if the queue has already been 
freed.
  */
-static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
+static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
 {
unsigned int buffer;
 
+   /*
+* Sanity check: when preparing a buffer the queue lock is released for
+* a short while (see __buf_prepare for the details), which would allow
+* a race with a reqbufs which can call this function. Removing the
+* buffers from underneath __buf_prepare is obviously a bad idea, so we
+* check if any of the buffers is in the state PREPARING, and if so we
+* just return -EAGAIN.
+*/
+   for (buffer = q-num_buffers - buffers; buffer  q-num_buffers;
+++buffer) {
+   if (q-bufs[buffer] == NULL)
+   continue;
+   if (q-bufs[buffer]-state == VB2_BUF_STATE_PREPARING) {
+   dprintk(1, reqbufs: preparing buffers, cannot free\n);
+   return -EAGAIN;
+   }
+   }
+
/* Call driver-provided cleanup function for each buffer, if provided */
if (q-ops-buf_cleanup) {
for (buffer = q-num_buffers - buffers; buffer  q-num_buffers;
@@ -326,6 +344,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned 
int buffers)
if (!q-num_buffers)
q-memory = 0;
INIT_LIST_HEAD(q-queued_list);
+   return 0;
 }
 
 /**
@@ -658,7 +677,9 @@ static int __reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
return -EBUSY;
}
 
-   __vb2_queue_free(q, q-num_buffers);
+   ret = __vb2_queue_free(q, q-num_buffers);
+   if (ret)
+   return ret;
 
/*
 * In case of REQBUFS(0) return immediately without calling
-- 
1.8.4.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


[REVIEW PATCH 5/9] vb2: retry start_streaming in case of insufficient buffers.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

If start_streaming returns -ENOBUFS, then it will be retried the next time
a buffer is queued. This means applications no longer need to know how many
buffers need to be queued before STREAMON can be called. This is particularly
useful for output stream I/O.

If a DMA engine needs at least X buffers before it can start streaming, then
for applications to get a buffer out as soon as possible they need to know
the minimum number of buffers to queue before STREAMON can be called. You can't
just try STREAMON after every buffer since on failure STREAMON will dequeue
all your buffers. (Is that a bug or a feature? Frankly, I'm not sure).

This patch simplifies applications substantially: they can just call STREAMON
at the beginning and then start queuing buffers and the DMA engine will
kick in automagically once enough buffers are available.

This also fixes using write() to stream video: the fileio implementation
calls streamon without having any queued buffers, which will fail today for
any driver that requires a minimum number of buffers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Marek Szyprowski m.szyprow...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 68 ++--
 include/media/videobuf2-core.h   | 15 +--
 2 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 2096a0d..28e64b1 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1377,6 +1377,39 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
+/**
+ * vb2_start_streaming() - Attempt to start streaming.
+ * @q: videobuf2 queue
+ *
+ * If there are not enough buffers, then retry_start_streaming is set to
+ * 1 and 0 is returned. The next time a buffer is queued and
+ * retry_start_streaming is 1, this function will be called again to
+ * retry starting the DMA engine.
+ */
+static int vb2_start_streaming(struct vb2_queue *q)
+{
+   int ret;
+
+   /* Tell the driver to start streaming */
+   ret = call_qop(q, start_streaming, q, atomic_read(q-queued_count));
+
+   /*
+* If there are not enough buffers queued to start streaming, then
+* the start_streaming operation will return -ENOBUFS and you have to
+* retry when the next buffer is queued.
+*/
+   if (ret == -ENOBUFS) {
+   dprintk(1, qbuf: not enough buffers, retry when more buffers 
are queued.\n);
+   q-retry_start_streaming = 1;
+   return 0;
+   }
+   if (ret)
+   dprintk(1, qbuf: driver refused to start streaming\n);
+   else
+   q-retry_start_streaming = 0;
+   return ret;
+}
+
 static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
int ret = vb2_queue_or_prepare_buf(q, b, qbuf);
@@ -1425,6 +1458,12 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
/* Fill buffer information for the userspace */
__fill_v4l2_buffer(vb, b);
 
+   if (q-retry_start_streaming) {
+   ret = vb2_start_streaming(q);
+   if (ret)
+   return ret;
+   }
+
dprintk(1, %s() of buffer %d succeeded\n, __func__, 
vb-v4l2_buf.index);
return 0;
 }
@@ -1574,7 +1613,8 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q)
return -EINVAL;
}
 
-   wait_event(q-done_wq, !atomic_read(q-queued_count));
+   if (!q-retry_start_streaming)
+   wait_event(q-done_wq, !atomic_read(q-queued_count));
return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);
@@ -1688,6 +1728,11 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 {
unsigned int i;
 
+   if (q-retry_start_streaming) {
+   q-retry_start_streaming = 0;
+   q-streaming = 0;
+   }
+
/*
 * Tell driver to stop all transactions and release all queued
 * buffers.
@@ -1737,12 +1782,9 @@ static int vb2_internal_streamon(struct vb2_queue *q, 
enum v4l2_buf_type type)
list_for_each_entry(vb, q-queued_list, queued_entry)
__enqueue_in_driver(vb);
 
-   /*
-* Let driver notice that streaming state has been enabled.
-*/
-   ret = call_qop(q, start_streaming, q, atomic_read(q-queued_count));
+   /* Tell driver to start streaming. */
+   ret = vb2_start_streaming(q);
if (ret) {
-   dprintk(1, streamon: driver refused to start streaming\n);
__vb2_queue_cancel(q);
return ret;
}
@@ -2312,15 +2354,15 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
goto err_reqbufs;

[REVIEW PATCH 7/9] vb2: return ENOBUFS in start_streaming in case of too few buffers.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This works together with the retry_start_streaming mechanism to allow userspace
to start streaming even if not all required buffers have been queued.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com
Cc: Tomasz Stanislawski t.stanisl...@samsung.com
Cc: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Kamil Debski k.deb...@samsung.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/davinci/vpbe_display.c   | 2 +-
 drivers/media/platform/davinci/vpif_capture.c   | 2 +-
 drivers/media/platform/davinci/vpif_display.c   | 2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 2 +-
 drivers/media/platform/s5p-tv/mixer_video.c | 2 +-
 drivers/media/platform/soc_camera/mx2_camera.c  | 2 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 ++
 7 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index eac472b..b02aba4 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -347,7 +347,7 @@ static int vpbe_start_streaming(struct vb2_queue *vq, 
unsigned int count)
/* If buffer queue is empty, return error */
if (list_empty(layer-dma_queue)) {
v4l2_err(vpbe_dev-v4l2_dev, buffer queue is empty\n);
-   return -EINVAL;
+   return -ENOBUFS;
}
/* Get the next frame from the buffer queue */
layer-next_frm = layer-cur_frm = list_entry(layer-dma_queue.next,
diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 52ac5e6..735ec47 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -277,7 +277,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
if (list_empty(common-dma_queue)) {
spin_unlock_irqrestore(common-irqlock, flags);
vpif_dbg(1, debug, buffer queue is empty\n);
-   return -EIO;
+   return -ENOBUFS;
}
 
/* Get the next frame from the buffer queue */
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index c31bcf1..9d115cd 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -239,7 +239,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
if (list_empty(common-dma_queue)) {
spin_unlock_irqrestore(common-irqlock, flags);
vpif_err(buffer queue is empty\n);
-   return -EIO;
+   return -ENOBUFS;
}
 
/* Get the next frame from the buffer queue */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4ff3b6c..f0b41f8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1863,7 +1863,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, 
unsigned int count)
if (ctx-src_bufs_cnt  ctx-pb_count) {
mfc_err(Need minimum %d OUTPUT buffers\n,
ctx-pb_count);
-   return -EINVAL;
+   return -ENOBUFS;
}
}
 
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c 
b/drivers/media/platform/s5p-tv/mixer_video.c
index 81b97db..c5059ba 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -948,7 +948,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned 
int count)
 
if (count == 0) {
mxr_dbg(mdev, no output buffers queued\n);
-   return -EINVAL;
+   return -ENOBUFS;
}
 
/* block any changes in output configuration */
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index 45a0276..d73abca 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -659,7 +659,7 @@ static int mx2_start_streaming(struct vb2_queue *q, 
unsigned int count)
unsigned long flags;
 
if (count  2)
-   return -EINVAL;
+   return -ENOBUFS;
 
spin_lock_irqsave(pcdev-lock, flags);
 
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 24d98a6..c1a4625 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1201,6 +1201,8 @@ static int vpfe_start_streaming(struct vb2_queue *vq, 
unsigned int count)
unsigned long addr;
int ret;
 
+   if (count == 0)
+  

[REVIEW PATCH 1/9] vb2: push the mmap semaphore down to __buf_prepare()

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Rather than taking the mmap semaphore at a relatively high-level function,
push it down to the place where it is really needed.

It was placed in vb2_queue_or_prepare_buf() to prevent racing with other
vb2 calls. The only way I can see that a race can happen is when two
threads queue the same buffer. The solution for that it to introduce
a PREPARING state.

Moving it down offers opportunities to simplify the code.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 82 ++--
 include/media/videobuf2-core.h   |  2 +
 2 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 12df9fd..d3f7e8a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -481,6 +481,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
case VB2_BUF_STATE_PREPARED:
b-flags |= V4L2_BUF_FLAG_PREPARED;
break;
+   case VB2_BUF_STATE_PREPARING:
case VB2_BUF_STATE_DEQUEUED:
/* nothing */
break;
@@ -1228,6 +1229,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
 static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
 {
struct vb2_queue *q = vb-vb2_queue;
+   struct rw_semaphore *mmap_sem;
int ret;
 
ret = __verify_length(vb, b);
@@ -1237,12 +1239,31 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
return ret;
}
 
+   vb-state = VB2_BUF_STATE_PREPARING;
switch (q-memory) {
case V4L2_MEMORY_MMAP:
ret = __qbuf_mmap(vb, b);
break;
case V4L2_MEMORY_USERPTR:
+   /*
+* In case of user pointer buffers vb2 allocators need to get 
direct
+* access to userspace pages. This requires getting the mmap 
semaphore
+* for read access in the current process structure. The same 
semaphore
+* is taken before calling mmap operation, while both 
qbuf/prepare_buf
+* and mmap are called by the driver or v4l2 core with the 
driver's lock
+* held. To avoid an AB-BA deadlock (mmap_sem then driver's 
lock in mmap
+* and driver's lock then mmap_sem in qbuf/prepare_buf) the 
videobuf2
+* core releases the driver's lock, takes mmap_sem and then 
takes the
+* driver's lock again.
+*/
+   mmap_sem = current-mm-mmap_sem;
+   call_qop(q, wait_prepare, q);
+   down_read(mmap_sem);
+   call_qop(q, wait_finish, q);
+
ret = __qbuf_userptr(vb, b);
+
+   up_read(mmap_sem);
break;
case V4L2_MEMORY_DMABUF:
ret = __qbuf_dmabuf(vb, b);
@@ -1256,8 +1277,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
ret = call_qop(q, buf_prepare, vb);
if (ret)
dprintk(1, qbuf: buffer preparation failed: %d\n, ret);
-   else
-   vb-state = VB2_BUF_STATE_PREPARED;
+   vb-state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED;
 
return ret;
 }
@@ -1268,80 +1288,47 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue 
*q, struct v4l2_buffer *b,
   struct v4l2_buffer *,
   struct vb2_buffer *))
 {
-   struct rw_semaphore *mmap_sem = NULL;
struct vb2_buffer *vb;
int ret;
 
-   /*
-* In case of user pointer buffers vb2 allocators need to get direct
-* access to userspace pages. This requires getting the mmap semaphore
-* for read access in the current process structure. The same semaphore
-* is taken before calling mmap operation, while both qbuf/prepare_buf
-* and mmap are called by the driver or v4l2 core with the driver's lock
-* held. To avoid an AB-BA deadlock (mmap_sem then driver's lock in mmap
-* and driver's lock then mmap_sem in qbuf/prepare_buf) the videobuf2
-* core releases the driver's lock, takes mmap_sem and then takes the
-* driver's lock again.
-*
-* To avoid racing with other vb2 calls, which might be called after
-* releasing the driver's lock, this operation is performed at the
-* beginning of qbuf/prepare_buf processing. This way the queue status
-* is consistent after getting the driver's lock back.
-*/
-   if (q-memory == V4L2_MEMORY_USERPTR) {
-   mmap_sem = current-mm-mmap_sem;
-   call_qop(q, wait_prepare, q);
- 

[REVIEW PATCH 9/9] DocBook: drop the word 'only'.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

There are already video output drivers that allow STREAMON without
any buffers queued, and with the change in vb2 there are now more
drivers like that.

So saying The ioctl will succeed only when at least one output
buffer is in the incoming queue. isn't true. Just drop the word
'only'. We cannot say that it will also work if no output buffers are
queued as long as not all drivers are converted to vb2.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/vidioc-streamon.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-streamon.xml 
b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
index 716ea15..65dff55 100644
--- a/Documentation/DocBook/media/v4l/vidioc-streamon.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
@@ -59,7 +59,7 @@ buffers are filled (if there are any empty buffers in the 
incoming
 queue) until constantVIDIOC_STREAMON/constant has been called.
 Accordingly the output hardware is disabled, no video signal is
 produced until constantVIDIOC_STREAMON/constant has been called.
-The ioctl will succeed only when at least one output buffer is in the
+The ioctl will succeed when at least one output buffer is in the
 incoming queue./para
 
 paraThe constantVIDIOC_STREAMOFF/constant ioctl, apart of
-- 
1.8.4.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


[REVIEW PATCH 2/9] vb2: simplify qbuf/prepare_buf by removing callback.

2013-12-13 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The callback used to merge the common code of the qbuf/prepare_buf
code can be removed now that the mmap_sem handling is pushed down to
__buf_prepare(). This makes the code more readable.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 118 +++
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index d3f7e8a..08ad883 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1283,14 +1283,8 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
 }
 
 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
-   const char *opname,
-   int (*handler)(struct vb2_queue *,
-  struct v4l2_buffer *,
-  struct vb2_buffer *))
+   const char *opname)
 {
-   struct vb2_buffer *vb;
-   int ret;
-
if (q-fileio) {
dprintk(1, %s(): file io in progress\n, opname);
return -EBUSY;
@@ -1306,8 +1300,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
return -EINVAL;
}
 
-   vb = q-bufs[b-index];
-   if (NULL == vb) {
+   if (q-bufs[b-index] == NULL) {
/* Should never happen */
dprintk(1, %s(): buffer is NULL\n, opname);
return -EINVAL;
@@ -1318,30 +1311,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
return -EINVAL;
}
 
-   ret = __verify_planes_array(vb, b);
-   if (ret)
-   return ret;
-
-   ret = handler(q, b, vb);
-   if (!ret) {
-   /* Fill buffer information for the userspace */
-   __fill_v4l2_buffer(vb, b);
-
-   dprintk(1, %s() of buffer %d succeeded\n, opname, 
vb-v4l2_buf.index);
-   }
-   return ret;
-}
-
-static int __vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
-struct vb2_buffer *vb)
-{
-   if (vb-state != VB2_BUF_STATE_DEQUEUED) {
-   dprintk(1, %s(): invalid buffer state %d\n, __func__,
-   vb-state);
-   return -EINVAL;
-   }
-
-   return __buf_prepare(vb, b);
+   return __verify_planes_array(q-bufs[b-index], b);
 }
 
 /**
@@ -1361,20 +1331,68 @@ static int __vb2_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
  */
 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   return vb2_queue_or_prepare_buf(q, b, prepare_buf, __vb2_prepare_buf);
+   int ret = vb2_queue_or_prepare_buf(q, b, prepare_buf);
+   struct vb2_buffer *vb;
+
+   if (ret)
+   return ret;
+
+   vb = q-bufs[b-index];
+   if (vb-state != VB2_BUF_STATE_DEQUEUED) {
+   dprintk(1, %s(): invalid buffer state %d\n, __func__,
+   vb-state);
+   return -EINVAL;
+   }
+
+   ret = __buf_prepare(vb, b);
+   if (!ret) {
+   /* Fill buffer information for the userspace */
+   __fill_v4l2_buffer(vb, b);
+
+   dprintk(1, %s() of buffer %d succeeded\n, __func__, 
vb-v4l2_buf.index);
+   }
+   return ret;
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
-static int __vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b,
- struct vb2_buffer *vb)
+/**
+ * vb2_qbuf() - Queue a buffer from userspace
+ * @q: videobuf2 queue
+ * @b: buffer structure passed from userspace to vidioc_qbuf handler
+ * in driver
+ *
+ * Should be called from vidioc_qbuf ioctl handler of a driver.
+ * This function:
+ * 1) verifies the passed buffer,
+ * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
+ *which driver-specific buffer initialization can be performed,
+ * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
+ *callback for processing.
+ *
+ * The return values from this function are intended to be directly returned
+ * from vidioc_qbuf handler in driver.
+ */
+int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   int ret;
+   int ret = vb2_queue_or_prepare_buf(q, b, qbuf);
+   struct vb2_buffer *vb;
+
+   if (ret)
+   return ret;
+
+   vb = q-bufs[b-index];
+   if (vb-state != VB2_BUF_STATE_DEQUEUED) {
+   dprintk(1, %s(): invalid buffer state %d\n, __func__,
+   vb-state);
+   return -EINVAL;
+   }
 
switch (vb-state) {
case VB2_BUF_STATE_DEQUEUED:

Hello Dear Friend,,

2013-12-13 Thread Kuku Gift
Hello Dear Friend,,
I am Gift. Please, I will like to be your friend only if you don't mind,
contact me for my picture
and more about me,
Thanks in advance and remain blessed!
Gift.
--
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 RFC 4/4] v4l: 1 Hz resolution flag for tuners

2013-12-13 Thread Antti Palosaari

On 13.12.2013 18:08, Hans Verkuil wrote:

On 12/13/2013 04:42 PM, Antti Palosaari wrote:

On 13.12.2013 16:05, Hans Verkuil wrote:

On 12/12/2013 06:22 PM, Antti Palosaari wrote:



I really appreciate that as simply has no enough knowledge from V4L2 API
and API changes are needed. I will try to list here shortly some SDR
devices in general level enough.

ant = antenna
host = host computer, PC (SW modulator/demodulator)
ADC = analog to digital converter
DAC = digital to analog converter
amp = amplifier
mixer = TX tuner

receiver:
ant  RF tuner  ADC  bridge  host
ant ADC  bridge  host
ant  up-converter  RF tuner  ADC  bridge  host

transmitter:
ant  amp  mixer  DAC  bridge  host
ant  mixer  DAC  bridge  host
ant  DAC  bridge  host

Those are the used building blocks in some general view. ADC (DAC) is
most important hardware block, but RF tuner is also critical in practice.

So what I understood, V4L2 API tuner is kinda logical entity that
represent single radio device, containing RF tuner, demodulator and so.
That same logical entity in DVB API side is frontend, which is mostly
implemented by demodulator with a help of RF tuner.

So what is needed is to make V4L2 API entity (tuner I guess) that could
represent both ADC and RF tuner.


Well, a V4L2 tuner represents the hardware that requires a frequency.
Which for typical radio and TV devices means the RF tuner + demodulator
combo. So externally you see only one tuner, but internally there are
often two devices (tuner and modulator) that have to be controlled.

For SDR you have an RF Tuner with a frequency and an ADC with a frequency,
and the two frequencies can be set independently. So representing that
as two tuners seems like a sensible mapping to me.


Correct. Both RF tuner and ADC are independent each others and both must 
be possible to adjust runtime.


Shortly, all-in-all, I will implement those as a tuner#0 is ADC and 
tuner#1 is RF tuner. Patches with corrections follow soon.


regards
Antti

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


Exportation

2013-12-13 Thread Kim
Hello,

The Project is about the exportation of 100,000 barrels of Light Crude
Oil daily out from Iraq to Turkey through my clients company in Iraq
at the rate of $92.00 a barrel. This amount to $9,200,000 daily. I ask
for your support as a foreigner to handle this business project with my
client and you are not expected to invest in Iraq

If yes, let me know and we will discuss this project proper.

Kim.
--
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


stable regression: tda18271_read_regs: [1-0060|M] ERROR: i2c_transfer returned: -19

2013-12-13 Thread Frederik Himpe
[My excuses for multiposting, it seems gmane does not permit posting to all
the relevant lists]

Since upgrading my system from Linux 3.12 to 3.12.3, my PCTV Systems
nanoStick T2 290e does not work anymore.

This happens with 3.12.3:

[3.778817] em28174 #0: i2c eeprom : 26 00 01 00 02 09 d8 85 80 80 e5 80 
f4 f5 94 90
[3.779741] em28174 #0: i2c eeprom 0010: 78 0d e4 f0 f5 46 12 00 5a c2 eb c2 
e8 30 e9 03
[3.780643] em28174 #0: i2c eeprom 0020: 12 09 de 30 eb 03 12 09 10 30 ec f1 
12 07 72 80
[3.781562] em28174 #0: i2c eeprom 0030: ec 00 60 00 e5 f5 64 01 60 09 e5 f5 
64 09 60 03
[3.782473] em28174 #0: i2c eeprom 0040: c2 c6 22 e5 f7 b4 03 13 e5 f6 b4 87 
03 02 09 92
[3.783406] em28174 #0: i2c eeprom 0050: e5 f6 b4 93 03 02 07 e6 c2 c6 22 c2 
c6 22 12 09
[3.784314] em28174 #0: i2c eeprom 0060: cf 02 06 19 1a eb 67 95 13 20 4f 02 
c0 13 6b 10
[3.785213] em28174 #0: i2c eeprom 0070: a0 1a ba 14 ce 1a 39 57 00 5c 18 00 
00 00 00 00
[3.786140] em28174 #0: i2c eeprom 0080: 00 00 00 00 44 36 00 00 f0 10 02 00 
00 00 00 00
[3.787057] em28174 #0: i2c eeprom 0090: 5b 23 c0 00 00 00 20 40 20 80 02 20 
01 01 00 00
[3.787970] em28174 #0: i2c eeprom 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00
[3.788879] em28174 #0: i2c eeprom 00b0: c6 40 00 00 00 00 a7 00 00 00 00 00 
00 00 00 00
[3.789790] em28174 #0: i2c eeprom 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 38 32
[3.790709] em28174 #0: i2c eeprom 00d0: 34 31 30 31 31 36 36 30 31 37 31 32 
32 31 46 4b
[3.791625] em28174 #0: i2c eeprom 00e0: 4a 31 00 4f 53 49 30 30 33 30 38 44 
30 31 31 30
[3.792531] em28174 #0: i2c eeprom 00f0: 46 4b 4a 31 00 00 00 00 00 00 00 00 
00 00 31 30
[3.793444] em28174 #0: i2c eeprom 0100: ... (skipped)
[3.793502] em28174 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0xfcf432bb
[3.793559] em28174 #0: EEPROM info:
[3.793616] em28174 #0:  microcode start address = 0x0004, boot 
configuration = 0x01
[3.804741] scsi 8:0:0:0: Direct-Access Generic  Ultra HS-SD/MMC  1.82 
PQ: 0 ANSI: 0
[3.805345] sd 8:0:0:0: Attached scsi generic sg3 type 0
[3.818139] em28174 #0:  No audio on board.
[3.818194] em28174 #0:  500mA max power
[3.818247] em28174 #0:  Table at offset 0x39, strings=0x1aa0, 0x14ba, 
0x1ace
[3.818318] em28174 #0: Identified as PCTV nanoStick T2 290e (card=78)
[3.818374] em28174 #0: v4l2 driver version 0.2.0
[3.821522] sd 8:0:0:0: [sdc] Attached SCSI removable disk
[3.823606] em28174 #0: V4L2 video device registered as video0
[3.823662] em28174 #0: dvb set to isoc mode.
[3.823972] usbcore: registered new interface driver em28xx
[3.844020] tda18271 1-0060: creating new instance
[3.868422] tda18271_read_regs: [1-0060|M] ERROR: i2c_transfer returned: -19
[3.868492] Error reading device ID @ 1-0060, bailing out.
[3.868548] tda18271_attach: [1-0060|M] error -5 on line 1285
[3.868603] tda18271 1-0060: destroying instance
[3.868666] Em28xx: Initialized (Em28xx dvb Extension) extension
[3.894687] Registered IR keymap rc-pinnacle-pctv-hd
[3.894819] input: em28xx IR (em28174 #0) as 
/devices/pci:00/:00:1d.0/usb2/2-1/2-1.7/rc/rc0/input23
[3.894979] rc0: em28xx IR (em28174 #0) as 
/devices/pci:00/:00:1d.0/usb2/2-1/2-1.7/rc/rc0
[3.895570] Em28xx: Initialized (Em28xx Input Extension) extension

I see the same problem reported here:
https://github.com/Hexxeh/rpi-firmware/issues/38 where it is mentioned
that this regression also appeared in 3.10 stable series recently.

I noticed upstream commit 8393796dfa4cf5dffcceec464c7789bec3a2f471
(media: dvb-frontends: Don't use dynamic static allocation)
entered both 3.10.22 (which is the first version introducing the
regression in 3.10 stable according to the linked bug), and 3.12.3.
This file contains stuff related to tda18271. Could this be the 
culprit?

-- 
Frederik Himpe


--
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: stable regression: tda18271_read_regs: [1-0060|M] ERROR: i2c_transfer returned: -19

2013-12-13 Thread Mauro Carvalho Chehab
Em Fri, 13 Dec 2013 22:19:39 +0100
Frederik Himpe fhi...@telenet.be escreveu:

 [My excuses for multiposting, it seems gmane does not permit posting to all
 the relevant lists]
 
 Since upgrading my system from Linux 3.12 to 3.12.3, my PCTV Systems
 nanoStick T2 290e does not work anymore.
 
 This happens with 3.12.3:
 
 [3.778817] em28174 #0: i2c eeprom : 26 00 01 00 02 09 d8 85 80 80 e5 
 80 f4 f5 94 90
 [3.779741] em28174 #0: i2c eeprom 0010: 78 0d e4 f0 f5 46 12 00 5a c2 eb 
 c2 e8 30 e9 03
 [3.780643] em28174 #0: i2c eeprom 0020: 12 09 de 30 eb 03 12 09 10 30 ec 
 f1 12 07 72 80
 [3.781562] em28174 #0: i2c eeprom 0030: ec 00 60 00 e5 f5 64 01 60 09 e5 
 f5 64 09 60 03
 [3.782473] em28174 #0: i2c eeprom 0040: c2 c6 22 e5 f7 b4 03 13 e5 f6 b4 
 87 03 02 09 92
 [3.783406] em28174 #0: i2c eeprom 0050: e5 f6 b4 93 03 02 07 e6 c2 c6 22 
 c2 c6 22 12 09
 [3.784314] em28174 #0: i2c eeprom 0060: cf 02 06 19 1a eb 67 95 13 20 4f 
 02 c0 13 6b 10
 [3.785213] em28174 #0: i2c eeprom 0070: a0 1a ba 14 ce 1a 39 57 00 5c 18 
 00 00 00 00 00
 [3.786140] em28174 #0: i2c eeprom 0080: 00 00 00 00 44 36 00 00 f0 10 02 
 00 00 00 00 00
 [3.787057] em28174 #0: i2c eeprom 0090: 5b 23 c0 00 00 00 20 40 20 80 02 
 20 01 01 00 00
 [3.787970] em28174 #0: i2c eeprom 00a0: 00 00 00 00 00 00 00 00 00 00 00 
 00 00 00 00 00
 [3.788879] em28174 #0: i2c eeprom 00b0: c6 40 00 00 00 00 a7 00 00 00 00 
 00 00 00 00 00
 [3.789790] em28174 #0: i2c eeprom 00c0: 00 00 00 00 00 00 00 00 00 00 00 
 00 00 00 38 32
 [3.790709] em28174 #0: i2c eeprom 00d0: 34 31 30 31 31 36 36 30 31 37 31 
 32 32 31 46 4b
 [3.791625] em28174 #0: i2c eeprom 00e0: 4a 31 00 4f 53 49 30 30 33 30 38 
 44 30 31 31 30
 [3.792531] em28174 #0: i2c eeprom 00f0: 46 4b 4a 31 00 00 00 00 00 00 00 
 00 00 00 31 30
 [3.793444] em28174 #0: i2c eeprom 0100: ... (skipped)
 [3.793502] em28174 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0xfcf432bb
 [3.793559] em28174 #0: EEPROM info:
 [3.793616] em28174 #0:microcode start address = 0x0004, boot 
 configuration = 0x01
 [3.804741] scsi 8:0:0:0: Direct-Access Generic  Ultra HS-SD/MMC  1.82 
 PQ: 0 ANSI: 0
 [3.805345] sd 8:0:0:0: Attached scsi generic sg3 type 0
 [3.818139] em28174 #0:No audio on board.
 [3.818194] em28174 #0:500mA max power
 [3.818247] em28174 #0:Table at offset 0x39, strings=0x1aa0, 0x14ba, 
 0x1ace
 [3.818318] em28174 #0: Identified as PCTV nanoStick T2 290e (card=78)
 [3.818374] em28174 #0: v4l2 driver version 0.2.0
 [3.821522] sd 8:0:0:0: [sdc] Attached SCSI removable disk
 [3.823606] em28174 #0: V4L2 video device registered as video0
 [3.823662] em28174 #0: dvb set to isoc mode.
 [3.823972] usbcore: registered new interface driver em28xx
 [3.844020] tda18271 1-0060: creating new instance
 [3.868422] tda18271_read_regs: [1-0060|M] ERROR: i2c_transfer returned: 
 -19
 [3.868492] Error reading device ID @ 1-0060, bailing out.
 [3.868548] tda18271_attach: [1-0060|M] error -5 on line 1285
 [3.868603] tda18271 1-0060: destroying instance
 [3.868666] Em28xx: Initialized (Em28xx dvb Extension) extension
 [3.894687] Registered IR keymap rc-pinnacle-pctv-hd
 [3.894819] input: em28xx IR (em28174 #0) as 
 /devices/pci:00/:00:1d.0/usb2/2-1/2-1.7/rc/rc0/input23
 [3.894979] rc0: em28xx IR (em28174 #0) as 
 /devices/pci:00/:00:1d.0/usb2/2-1/2-1.7/rc/rc0
 [3.895570] Em28xx: Initialized (Em28xx Input Extension) extension
 
 I see the same problem reported here:
 https://github.com/Hexxeh/rpi-firmware/issues/38 where it is mentioned
 that this regression also appeared in 3.10 stable series recently.
 
 I noticed upstream commit 8393796dfa4cf5dffcceec464c7789bec3a2f471
 (media: dvb-frontends: Don't use dynamic static allocation)
 entered both 3.10.22 (which is the first version introducing the
 regression in 3.10 stable according to the linked bug), and 3.12.3.
 This file contains stuff related to tda18271. Could this be the 
 culprit?

I'll analyze it better tomorrow, but commit 8393796dfa4cf5 touches only
on tda18271c2dd driver. The only em28xx device that uses this driver 
variant is Terratec H5, which is not your case.

Besides that, with commit 8393796dfa4c it should be returning -EINVAL
and printing a msg that it would look like:

tda18271: i2c wr reg=: len=65 is too big!

However, on your report:

 [3.868422] tda18271_read_regs: [1-0060|M] ERROR: i2c_transfer returned: 
 -19

it is returning ENODEV:
#define ENODEV  19  /* No such device */

So, it seems that the regression was caused by some other patch.

are you using vanilla Kernel 3.12.3?

-- 

Cheers,
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


[GIT PULL FOR v3.14] Atmel ISI patches

2013-12-13 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 675722b0e3917c6c917f1aa5f6d005cd3a0479f5:

  Merge branch 'upstream-fixes' into patchwork (2013-12-13 05:04:00 -0200)

are available in the git repository at:


  git://linuxtv.org/pinchartl/media.git atmel/isi

for you to fetch changes up to 8f94dee5c528d1334fd1cb548966757ba2cf1431:

  v4l: atmel-isi: Should clear bits before set the hardware register 
(2013-12-14 03:46:39 +0100)


Josh Wu (2):
  v4l: atmel-isi: remove SOF wait in start_streaming()
  v4l: atmel-isi: Should clear bits before set the hardware register

Laurent Pinchart (5):
  v4l: atmel-isi: Use devm_* managed allocators
  v4l: atmel-isi: Defer clock (un)preparation to enable/disable time
  v4l: atmel-isi: Reset the ISI when starting the stream
  v4l: atmel-isi: Make the MCK clock optional
  v4l: atmel-isi: Fix color component ordering

 drivers/media/platform/soc_camera/atmel-isi.c | 179 +++--
 include/media/atmel-isi.h |   2 +
 2 files changed, 55 insertions(+), 126 deletions(-)

-- 
Regards,

Laurent Pinchart

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


cron job: media_tree daily build: ERRORS

2013-12-13 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 Dec 14 04:00:32 CET 2013
git branch: test
git hash:   675722b0e3917c6c917f1aa5f6d005cd3a0479f5
gcc version:i686-linux-gcc (GCC) 4.8.1
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-0.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: ERRORS
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: WARNINGS
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: WARNINGS
linux-2.6.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: WARNINGS
linux-3.12-i686: WARNINGS
linux-3.13-rc1-i686: WARNINGS
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: WARNINGS
linux-3.12-x86_64: WARNINGS
linux-3.13-rc1-x86_64: WARNINGS
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


Re: [GIT PULL FOR v3.14] Atmel ISI patches

2013-12-13 Thread Guennadi Liakhovetski
Hi Laurent,

On Sat, 14 Dec 2013, Laurent Pinchart wrote:

 Hi Mauro,
 
 The following changes since commit 675722b0e3917c6c917f1aa5f6d005cd3a0479f5:
 
   Merge branch 'upstream-fixes' into patchwork (2013-12-13 05:04:00 -0200)
 
 are available in the git repository at:
 
 
   git://linuxtv.org/pinchartl/media.git atmel/isi

Thanks for your patches. Any specific reason you're asking Mauro to pull 
directly from you instead of letting them go via my tree as usual for 
soc-camera patches?

Thanks
Guennadi

 
 for you to fetch changes up to 8f94dee5c528d1334fd1cb548966757ba2cf1431:
 
   v4l: atmel-isi: Should clear bits before set the hardware register 
 (2013-12-14 03:46:39 +0100)
 
 
 Josh Wu (2):
   v4l: atmel-isi: remove SOF wait in start_streaming()
   v4l: atmel-isi: Should clear bits before set the hardware register
 
 Laurent Pinchart (5):
   v4l: atmel-isi: Use devm_* managed allocators
   v4l: atmel-isi: Defer clock (un)preparation to enable/disable time
   v4l: atmel-isi: Reset the ISI when starting the stream
   v4l: atmel-isi: Make the MCK clock optional
   v4l: atmel-isi: Fix color component ordering
 
  drivers/media/platform/soc_camera/atmel-isi.c | 179 +++--
  include/media/atmel-isi.h |   2 +
  2 files changed, 55 insertions(+), 126 deletions(-)
 
 -- 
 Regards,
 
 Laurent Pinchart
 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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