[PATCH] media: i2c: mt9p031: Check return value of clk_prepare_enable/clk_set_rate

2014-01-17 Thread Prabhakar Lad
From: Lad, Prabhakar prabhakar.cse...@gmail.com

clk_set_rate(), clk_prepare_enable() functions can fail, so check the return
values to avoid surprises.

Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
---
 drivers/media/i2c/mt9p031.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index e5ddf47..dbe34d7 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -222,12 +222,15 @@ static int mt9p031_clk_setup(struct mt9p031 *mt9p031)
 
struct i2c_client *client = v4l2_get_subdevdata(mt9p031-subdev);
struct mt9p031_platform_data *pdata = mt9p031-pdata;
+   int ret;
 
mt9p031-clk = devm_clk_get(client-dev, NULL);
if (IS_ERR(mt9p031-clk))
return PTR_ERR(mt9p031-clk);
 
-   clk_set_rate(mt9p031-clk, pdata-ext_freq);
+   ret = clk_set_rate(mt9p031-clk, pdata-ext_freq);
+   if (ret  0)
+   return ret;
 
mt9p031-pll.ext_clock = pdata-ext_freq;
mt9p031-pll.pix_clock = pdata-target_freq;
@@ -286,8 +289,11 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
return ret;
 
/* Emable clock */
-   if (mt9p031-clk)
-   clk_prepare_enable(mt9p031-clk);
+   if (mt9p031-clk) {
+   ret = clk_prepare_enable(mt9p031-clk);
+   if (ret)
+   return ret;
+   }
 
/* Now RESET_BAR must be high */
if (gpio_is_valid(mt9p031-reset)) {
-- 
1.7.9.5

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


Re: [RFC PATCH 3/6] DocBook media: partial rewrite of Opening and Closing Devices

2014-01-17 Thread Hans Verkuil
Hi Mauro,

On 01/13/2014 06:23 PM, Mauro Carvalho Chehab wrote:
 Em Mon, 13 Jan 2014 17:15:40 +0100
 Hans Verkuil hverk...@xs4all.nl escreveu:
 
 On 01/13/2014 04:20 PM, Mauro Carvalho Chehab wrote:
 Em Tue,  7 Jan 2014 14:06:54 +0100
 Hans Verkuil hverk...@xs4all.nl escreveu:

 From: Hans Verkuil hans.verk...@cisco.com

 This section was horribly out of date. A lot of references to old and
 obsolete behavior have been dropped.
 
 Forgot to mention, put patches 1 and 2 are ok. I'll review the patches 4-6
 later this week.
 

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  Documentation/DocBook/media/v4l/common.xml | 188 
 ++---
  1 file changed, 67 insertions(+), 121 deletions(-)

 diff --git a/Documentation/DocBook/media/v4l/common.xml 
 b/Documentation/DocBook/media/v4l/common.xml
 index 1ddf354..da08df9 100644
 --- a/Documentation/DocBook/media/v4l/common.xml
 +++ b/Documentation/DocBook/media/v4l/common.xml

snip

 +  paraDevices can support several functions. For example
 +video capturing, VBI capturing and radio support./para

 function seems to be a poor choice of word here. Ok, it comes from the
 original text, but it is still not clear.

 I would use another word, like broadcast type, in order to refer to
 radio, software defined radio, VBI and video.

 I agree that it is not the best word, but neither is (IMHO) broadcast type.
 This would be something for a follow-up patch.
 
 I think we should use the right word here on this fix. Other suggestions:
   stream type, media type.
 
 In any case, we should enumerate all those types here, maybe even putting
 them into a table, in order to define precisely to what we're referring to.

I'm not going to do this now. I need to think about this some more, and this
might also require changes in a lot of other places in the documentation.

So as far as I am concerned this is something for a future patch.

 
 +
 +  paraThe V4L2 API creates different nodes for each of these 
 functions.
 +One exception to this rule is the overlay function: this is shared
 +with the video capture node (or video output node for output 
 overlays)./para

 The mention to overlay here is completely out of context, and proofs
 my point that function is a very bad choice: overlay is not a
 broadcast type. It is just one of the ways to output the data. The same
 device node can support multiple delivery types:
 - overlay;
 - dma-buf;
 - mmap;
 - read or write.

 Let's not mix those two concepts in the new text.

 Also, the delivery type has nothing to do with Opening and closing 
 devices.

 I like the word delivery type in this context and I agree with you here.
 I'll see if I can improve this text.
 
 Thanks!

I decided to just drop this paragraph. It doesn't belong here and it doesn't
add anything useful.

  

 +
 +  paraThe V4L2 API was designed with the idea that one device node 
 could support
 +all functions. However, in practice this never worked: this 'feature'
 +was never used by applications and many drivers did not support it and if
 +they did it was certainly never tested. In addition, switching a device
 +node between different functions only works when using the streaming I/O
 +API, not with the read()/write() API./para
 +
 +  paraToday each device node supports just one function, with the
 +exception of overlay support./para
  
paraBesides video input or output the hardware may also
  support audio sampling or playback. If so, these functions are
 -implemented as OSS or ALSA PCM devices and eventually OSS or ALSA
 -audio mixer. The V4L2 API makes no provisions yet to find these
 -related devices. If you have an idea please write to the linux-media
 -mailing list: v4l-ml;./para
 +implemented as ALSA PCM devices with optional ALSA audio mixer
 +devices./para
 +
 +  paraOne problem with all these devices is that the V4L2 API
 +makes no provisions to find these related devices. Some really
 +complex devices use the Media Controller (see xref 
 linkend=media_controller /)
 +which can be used for this purpose. But most drivers do not use it,
 +and while some code exists that uses sysfs to discover related devices,
 +there is no standard library yet. If you want to work on this please write
 +to the linux-media mailing list: v4l-ml;./para

 Not true. It is there at v4l-utils. Ok, patches are always welcome.

 Well, sort of. That library only handles sysfs, not the mc.
 
 Yes, but that covers almost all devices, as the ones that use mc (except for
 uvc) have more serious issues, as libv4l still don't work with them. So, they
 demand dedicated applications anyway.
 
 I know Laurent
 has been working on a better replacement, but that's been stalled for ages.
 In other words, someone needs to spend time on this and create a proper
 library for this.
 
 True, but, again, media controller based devices also need the libv4l
 pieces that Sakari is working (also stalled).
 
 Let's not mix things: 

[PATCH] media: i2c: mt9v032: Check return value of clk_prepare_enable/clk_set_rate

2014-01-17 Thread Prabhakar Lad
From: Lad, Prabhakar prabhakar.cse...@gmail.com

clk_set_rate(), clk_prepare_enable() functions can fail, so check the return
values to avoid surprises.

Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
---
 drivers/media/i2c/mt9v032.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 36c504b..40172b8 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -317,8 +317,14 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
struct i2c_client *client = v4l2_get_subdevdata(mt9v032-subdev);
int ret;
 
-   clk_set_rate(mt9v032-clk, mt9v032-sysclk);
-   clk_prepare_enable(mt9v032-clk);
+   ret = clk_set_rate(mt9v032-clk, mt9v032-sysclk);
+   if (ret  0)
+   return ret;
+
+   ret = clk_prepare_enable(mt9v032-clk);
+   if (ret)
+   return ret;
+
udelay(1);
 
/* Reset the chip and stop data read out */
-- 
1.7.9.5

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


[RFCv2 PATCH 3/6] DocBook media: partial rewrite of Opening and Closing Devices

2014-01-17 Thread Hans Verkuil
This section was horribly out of date. A lot of references to old and
obsolete behavior have been dropped.

Updated as per Mauro's suggestions (well, most of them anyway :-) ).

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/common.xml | 192 +++--
 1 file changed, 70 insertions(+), 122 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/common.xml 
b/Documentation/DocBook/media/v4l/common.xml
index 1ddf354..07dad76 100644
--- a/Documentation/DocBook/media/v4l/common.xml
+++ b/Documentation/DocBook/media/v4l/common.xml
@@ -38,70 +38,41 @@ the basic concepts applicable to all devices./para
 
   paraV4L2 drivers are implemented as kernel modules, loaded
 manually by the system administrator or automatically when a device is
-first opened. The driver modules plug into the videodev kernel
+first discovered. The driver modules plug into the videodev kernel
 module. It provides helper functions and a common application
 interface specified in this document./para
 
   paraEach driver thus loaded registers one or more device nodes
-with major number 81 and a minor number between 0 and 255. Assigning
-minor numbers to V4L2 devices is entirely up to the system administrator,
-this is primarily intended to solve conflicts between devices.footnote
- paraAccess permissions are associated with character
-device special files, hence we must ensure device numbers cannot
-change with the module load order. To this end minor numbers are no
-longer automatically assigned by the videodev module as in V4L but
-requested by the driver. The defaults will suffice for most people
-unless two drivers compete for the same minor numbers./para
-   /footnote The module options to select minor numbers are named
-after the device special file with a _nr suffix. For example video_nr
-for filename/dev/video/filename video capture devices. The number is
-an offset to the base minor number associated with the device type.
-footnote
- paraIn earlier versions of the V4L2 API the module options
-where named after the device special file with a unit_ prefix, expressing
-the minor number itself, not an offset. Rationale for this change is unknown.
-Lastly the naming and semantics are just a convention among driver writers,
-the point to note is that minor numbers are not supposed to be hardcoded
-into drivers./para
-   /footnote When the driver supports multiple devices of the same
-type more than one minor number can be assigned, separated by commas:
-informalexample
+with major number 81 and a minor number between 0 and 255. Minor numbers
+are allocated dynamically unless the kernel is compiled with the kernel
+option CONFIG_VIDEO_FIXED_MINOR_RANGES. In that case minor numbers are
+allocated in ranges depending on the device node type (video, radio, 
etc.)./para
+
+  paraMany drivers support video_nr, radio_nr or vbi_nr
+module options to select specific video/radio/vbi node numbers. This allows
+the user to request that the device node is named e.g. /dev/video5 instead
+of leaving it to chance. When the driver supports multiple devices of the same
+type more than one device node number can be assigned, separated by commas:
+   informalexample
  screen
-gt; insmod mydriver.o video_nr=0,1 radio_nr=0,1/screen
+gt; modprobe mydriver video_nr=0,1 radio_nr=0,1/screen
/informalexample/para
 
   paraIn filename/etc/modules.conf/filename this may be
 written as: informalexample
  screen
-alias char-major-81-0 mydriver
-alias char-major-81-1 mydriver
-alias char-major-81-64 mydriver  co id=alias /
-options mydriver video_nr=0,1 radio_nr=0,1   co id=options /
+options mydriver video_nr=0,1 radio_nr=0,1
  /screen
- calloutlist
-   callout arearefs=alias
- paraWhen an application attempts to open a device
-special file with major number 81 and minor number 0, 1, or 64, load
-mydriver (and the videodev module it depends upon)./para
-   /callout
-   callout arearefs=options
- paraRegister the first two video capture devices with
-minor number 0 and 1 (base number is 0), the first two radio device
-with minor number 64 and 65 (base 64)./para
-   /callout
- /calloutlist
-   /informalexample When no minor number is given as module
-option the driver supplies a default. xref linkend=devices /
-recommends the base minor numbers to be used for the various device
-types. Obviously minor numbers must be unique. When the number is
-already in use the emphasisoffending device/emphasis will not be
-registered. !-- Blessed by Linus Torvalds on
-linux-ker...@vger.kernel.org, 2002-11-20. --/para
-
-  paraBy convention system administrators create various
-character device special files with these major and minor numbers in
-the filename/dev/filename directory. The names recommended for the
-different V4L2 device types are listed in xref 

Re: [PATCH 6/6] v4l: disable lockdep on vb2_fop_mmap()

2014-01-17 Thread Hans Verkuil
Hi Antti,

Is this still needed after this commit was merged?

http://git.linuxtv.org/media_tree.git/commit/b18a8ff29d80b132018d33479e86ab8ecaee6b46

Regards,

Hans

On 12/29/2013 05:51 AM, Antti Palosaari wrote:
 Avoid that lockdep warning:
 
 [ INFO: possible circular locking dependency detected ]
 3.13.0-rc1+ #77 Tainted: G C O
 ---
 video_source:sr/32072 is trying to acquire lock:
  (dev-mutex#2){+.+.+.}, at: [a073fde3] vb2_fop_mmap+0x33/0x90 
 [videobuf2_core]
 
 but task is already holding 
 lock:
  (mm-mmap_sem){++}, at: [8117825f] vm_mmap_pgoff+0x6f/0xc0
 
  Possible unsafe locking scenario:
CPU0CPU1

   lock(mm-mmap_sem);
lock(dev-mutex#2);
lock(mm-mmap_sem);
   lock(dev-mutex#2);
  *** DEADLOCK ***
 
 Signed-off-by: Antti Palosaari cr...@iki.fi
 ---
  drivers/media/v4l2-core/videobuf2-core.c | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 12df9fd..2a74295 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -2641,12 +2641,24 @@ int vb2_fop_mmap(struct file *file, struct 
 vm_area_struct *vma)
   struct video_device *vdev = video_devdata(file);
   struct mutex *lock = vdev-queue-lock ? vdev-queue-lock : vdev-lock;
   int err;
 + /*
 +  * FIXME: Ugly hack. Disable possible lockdep as it detects possible
 +  * deadlock. INFO: possible circular locking dependency detected
 +  */
 + lockdep_off();
  
 - if (lock  mutex_lock_interruptible(lock))
 + if (lock  mutex_lock_interruptible(lock)) {
 + lockdep_on();
   return -ERESTARTSYS;
 + }
 +
   err = vb2_mmap(vdev-queue, vma);
 +
   if (lock)
   mutex_unlock(lock);
 +
 + lockdep_on();
 +
   return err;
  }
  EXPORT_SYMBOL_GPL(vb2_fop_mmap);
 

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


Re: [PATCH] media: rc: only turn on LED if keypress generated

2014-01-17 Thread Sean Young
On Thu, Jan 16, 2014 at 10:56:22PM +, James Hogan wrote:
 Since v3.12, specifically 153a60bb0fac ([media] rc: add feedback led
 trigger for rc keypresses), an LED trigger is activated on IR keydown
 whether or not a keypress is generated (i.e. even if there's no matching
 keycode). However the repeat and keyup logic isn't used unless there is
 a keypress, which results in non-keypress keydown events turning on the
 LED and not turning it off again.

Yes, this is a bug. I have a similar patch waiting to be submitted but
you beat me to it. 

Acked-by: Sean Young s...@mess.org

 
 On the assumption that the intent was for the LED only to light up on
 valid key presses (you probably don't want it lighting up for the wrong
 remote control for example), move the led_trigger_event() call inside
 the keycode check.
 
 Signed-off-by: James Hogan james.ho...@imgtec.com
 Cc: Sean Young s...@mess.org
 Cc: Mauro Carvalho Chehab m.che...@samsung.com
 Cc: linux-media@vger.kernel.org
 ---
 Was that the original intent? If not it could be tweaked to set
 dev-keypressed in either case instead, so that they LED trigger works
 for unmapped scancodes too.

I'd say that the feedback led should only be activated if a valid key is
pressed; doing this for for unmapped scancodes is jus going to cause confusion.

 ---
  drivers/media/rc/rc-main.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
 index 46da365..cff9d53 100644
 --- a/drivers/media/rc/rc-main.c
 +++ b/drivers/media/rc/rc-main.c
 @@ -649,9 +649,10 @@ static void ir_do_keydown(struct rc_dev *dev, int 
 scancode,
  key 0x%04x, scancode 0x%04x\n,
  dev-input_name, keycode, scancode);
   input_report_key(dev-input_dev, keycode, 1);
 +
 + led_trigger_event(led_feedback, LED_FULL);
   }
  
 - led_trigger_event(led_feedback, LED_FULL);
   input_sync(dev-input_dev);
  }
  
 -- 
 1.8.3.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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 05/30] [media] omap_vout: avoid sleep_on race

2014-01-17 Thread Hans Verkuil
Hi Arnd,

On 01/02/2014 01:07 PM, Arnd Bergmann wrote:
 sleep_on and its variants are broken and going away soon. This changes
 the omap vout driver to use interruptible_sleep_on_timeout instead,

I assume you mean wait_event_interruptible_timeout here :-)

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

If there are no other comments, then I plan to merge this next week.

Regards,

Hans

 which fixes potential race where the dma is complete before we
 schedule.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Mauro Carvalho Chehab m.che...@samsung.com
 Cc: linux-media@vger.kernel.org
 ---
  drivers/media/platform/omap/omap_vout_vrfb.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c 
 b/drivers/media/platform/omap/omap_vout_vrfb.c
 index cf1c437..62e7e57 100644
 --- a/drivers/media/platform/omap/omap_vout_vrfb.c
 +++ b/drivers/media/platform/omap/omap_vout_vrfb.c
 @@ -270,7 +270,8 @@ int omap_vout_prepare_vrfb(struct omap_vout_device *vout,
   omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE, 0x20, 0);
  
   omap_start_dma(tx-dma_ch);
 - interruptible_sleep_on_timeout(tx-wait, VRFB_TX_TIMEOUT);
 + wait_event_interruptible_timeout(tx-wait, tx-tx_status == 1,
 +  VRFB_TX_TIMEOUT);
  
   if (tx-tx_status == 0) {
   omap_stop_dma(tx-dma_ch);
 

--
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 06/30] [media] usbvision: remove bogus sleep_on_timeout

2014-01-17 Thread Hans Verkuil
On 01/02/2014 01:07 PM, Arnd Bergmann wrote:
 There is no reason to use sleep_on_timeout here, and we want to get
 rid of that interface. Use the simpler msleep_interruptible instead.

Since this define is unused anyway, lets just remove it completely.

I'll post a patch for this.

Regards,

Hans

 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Hans Verkuil hverk...@xs4all.nl
 Cc: Mauro Carvalho Chehab m.che...@samsung.com
 Cc: linux-media@vger.kernel.org
 ---
  drivers/media/usb/usbvision/usbvision.h | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/drivers/media/usb/usbvision/usbvision.h 
 b/drivers/media/usb/usbvision/usbvision.h
 index 8a25876..eb6dc8a 100644
 --- a/drivers/media/usb/usbvision/usbvision.h
 +++ b/drivers/media/usb/usbvision/usbvision.h
 @@ -205,10 +205,8 @@ enum {
  
  /* Debugging aid */
  #define USBVISION_SAY_AND_WAIT(what) { \
 - wait_queue_head_t wq; \
 - init_waitqueue_head(wq); \
   printk(KERN_INFO Say: %s\n, what); \
 - interruptible_sleep_on_timeout(wq, HZ * 3); \
 + msleep_interruptible(3000); \
  }
  
  /*
 

--
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] usbvision: drop unused define USBVISION_SAY_AND_WAIT

2014-01-17 Thread Hans Verkuil
This define uses the deprecated interruptible_sleep_on_timeout
function. Since this define is unused anyway we just remove it.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Arnd Bergmann a...@arndb.de
---
 drivers/media/usb/usbvision/usbvision.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/media/usb/usbvision/usbvision.h 
b/drivers/media/usb/usbvision/usbvision.h
index 8a25876..a0c73cf 100644
--- a/drivers/media/usb/usbvision/usbvision.h
+++ b/drivers/media/usb/usbvision/usbvision.h
@@ -203,14 +203,6 @@ enum {
mr = LIMIT_RGB(mm_r); \
 }
 
-/* Debugging aid */
-#define USBVISION_SAY_AND_WAIT(what) { \
-   wait_queue_head_t wq; \
-   init_waitqueue_head(wq); \
-   printk(KERN_INFO Say: %s\n, what); \
-   interruptible_sleep_on_timeout(wq, HZ * 3); \
-}
-
 /*
  * This macro checks if usbvision is still operational. The 'usbvision'
  * pointer must be valid, usbvision-dev must be valid, we are not
-- 
1.8.5.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 07/30] [media] radio-cadet: avoid interruptible_sleep_on race

2014-01-17 Thread Hans Verkuil
Hi Arnd!

On 01/02/2014 01:07 PM, Arnd Bergmann wrote:
 interruptible_sleep_on is racy and going away. This replaces
 one use in the radio-cadet driver with an open-coded
 wait loop that lets us check the condition under the mutex
 but sleep without it.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Hans Verkuil hverk...@xs4all.nl
 Cc: Mauro Carvalho Chehab m.che...@samsung.com
 Cc: linux-media@vger.kernel.org
 ---
  drivers/media/radio/radio-cadet.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/radio/radio-cadet.c 
 b/drivers/media/radio/radio-cadet.c
 index 545c04c..67b5bbf 100644
 --- a/drivers/media/radio/radio-cadet.c
 +++ b/drivers/media/radio/radio-cadet.c
 @@ -39,6 +39,7 @@
  #include linux/pnp.h
  #include linux/sched.h
  #include linux/io.h/* outb, outb_p */
 +#include linux/wait.h
  #include media/v4l2-device.h
  #include media/v4l2-ioctl.h
  #include media/v4l2-ctrls.h
 @@ -323,25 +324,32 @@ static ssize_t cadet_read(struct file *file, char 
 __user *data, size_t count, lo
   struct cadet *dev = video_drvdata(file);
   unsigned char readbuf[RDS_BUFFER];
   int i = 0;
 + DEFINE_WAIT(wait);
  
   mutex_lock(dev-lock);
   if (dev-rdsstat == 0)
   cadet_start_rds(dev);
 - if (dev-rdsin == dev-rdsout) {
 + while (1) {
 + prepare_to_wait(dev-read_queue, wait, TASK_INTERRUPTIBLE);
 + if (dev-rdsin != dev-rdsout)
 + break;
 +
   if (file-f_flags  O_NONBLOCK) {
   i = -EWOULDBLOCK;
   goto unlock;
   }
   mutex_unlock(dev-lock);
 - interruptible_sleep_on(dev-read_queue);
 + schedule();
   mutex_lock(dev-lock);
   }
 +

This seems overly complicated. Isn't it enough to replace interruptible_sleep_on
by 'wait_event_interruptible(dev-read_queue, dev-rdsin != dev-rdsout);'?

Or am I missing something subtle?

Regards,

Hans

   while (i  count  dev-rdsin != dev-rdsout)
   readbuf[i++] = dev-rdsbuf[dev-rdsout++];
  
   if (i  copy_to_user(data, readbuf, i))
   i = -EFAULT;
  unlock:
 + finish_wait(dev-read_queue, wait);
   mutex_unlock(dev-lock);
   return i;
  }
 

--
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 08/30] [media] arv: fix sleep_on race

2014-01-17 Thread Hans Verkuil
On 01/02/2014 01:07 PM, Arnd Bergmann wrote:
 interruptible_sleep_on is racy and going away. In the arv driver that
 race has probably never caused problems since it would require a whole
 video frame to be captured before the read function has a chance to
 go to sleep, but using wait_event_interruptible lets us kill off the
 old interface. In order to do this, we have to slightly adapt the
 meaning of the ar-start_capture field to distinguish between not having
 started a frame and having completed it.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Mauro Carvalho Chehab m.che...@samsung.com
 Cc: linux-media@vger.kernel.org
 ---
  drivers/media/platform/arv.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/platform/arv.c b/drivers/media/platform/arv.c
 index e346d32d..32f6d70 100644
 --- a/drivers/media/platform/arv.c
 +++ b/drivers/media/platform/arv.c
 @@ -307,11 +307,11 @@ static ssize_t ar_read(struct file *file, char *buf, 
 size_t count, loff_t *ppos)
   /*
* Okay, kick AR LSI to invoke an interrupt
*/
 - ar-start_capture = 0;
 + ar-start_capture = -1;

start_capture is defined as an unsigned. Can you make a new patch that changes
the type of start_capture to int?

Otherwise it looks fine.

Regards,

Hans

   ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1);
   local_irq_restore(flags);
   /*  AR interrupts  */
 - interruptible_sleep_on(ar-wait);
 + wait_event_interruptible(ar-wait, ar-start_capture == 0);
   if (signal_pending(current)) {
   printk(KERN_ERR arv: interrupted while get frame data.\n);
   ret = -EINTR;
 


--
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/3.15] usbtv: add audio support

2014-01-17 Thread Hans Verkuil
The following changes since commit 587d1b06e07b4a079453c74ba9edf17d21931049:

  [media] rc-core: reuse device numbers (2014-01-15 11:46:37 -0200)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v3.14d

for you to fetch changes up to 6e44e5938e3e964748e0d4b76f476c3215e32aab:

  usbtv: add audio support (2014-01-17 10:55:39 +0100)


Federico Simoncelli (2):
  usbtv: split core and video implementation
  usbtv: add audio support

 drivers/media/usb/usbtv/Makefile   |   4 +
 drivers/media/usb/usbtv/usbtv-audio.c  | 384 
+
 drivers/media/usb/usbtv/usbtv-core.c   | 144 

 drivers/media/usb/usbtv/{usbtv.c = usbtv-video.c} | 172 
+++--
 drivers/media/usb/usbtv/usbtv.h| 117 ++
 5 files changed, 663 insertions(+), 158 deletions(-)
 create mode 100644 drivers/media/usb/usbtv/usbtv-audio.c
 create mode 100644 drivers/media/usb/usbtv/usbtv-core.c
 rename drivers/media/usb/usbtv/{usbtv.c = usbtv-video.c} (82%)
 create mode 100644 drivers/media/usb/usbtv/usbtv.h
--
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] Repost: various v4l2 fixes

2014-01-17 Thread Hans Verkuil
For some reason this didn't appear in patchwork, so I repost this pull request.

Regards,

Hans

The following changes since commit d20e4ed6d30c6ecee315eea0efb3449c3591d09e:

  [media] em28xx: use a better value for I2C timeouts (2014-01-10 06:10:07 
-0200)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v3.14c

for you to fetch changes up to 190a7f631e1f972912d1777aadbaa6854be00085:

  vb2: Check if there are buffers before streamon (2014-01-10 16:09:53 +0100)


Alexey Khoroshilov (1):
  go7007-loader: fix usb_dev leak

Hans Verkuil (1):
  Revert [media] videobuf_vm_{open,close} race fixes

Levente Kurusa (1):
  media: bt8xx: add missing put_device call

Ricardo Ribalda (1):
  vb2: Check if there are buffers before streamon

 drivers/media/pci/bt8xx/bttv-gpio.c   |  2 +-
 drivers/media/v4l2-core/videobuf-dma-contig.c | 12 +---
 drivers/media/v4l2-core/videobuf-dma-sg.c | 10 --
 drivers/media/v4l2-core/videobuf-vmalloc.c| 10 --
 drivers/media/v4l2-core/videobuf2-core.c  |  5 +
 drivers/staging/media/go7007/go7007-loader.c  |  4 +++-
 6 files changed, 22 insertions(+), 21 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/15] media: rc: add raw decoder for Sharp protocol

2014-01-17 Thread James Hogan
Add a raw decoder for the Sharp protocol. It uses a pulse distance
modulation with a pulse of 320us and a bit period of 2ms for a logical 1
and 1ms for a logical 0. The first part of the message consists of a
5-bit address, an 8-bit command, and two other bits, followed by a 40ms
gap before the echo message which is an inverted version of the main
message except for the address bits.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
v2:
- new patch (suggested by Mauro).
---
 drivers/media/rc/Kconfig|   9 ++
 drivers/media/rc/Makefile   |   1 +
 drivers/media/rc/ir-sharp-decoder.c | 200 
 drivers/media/rc/rc-core-priv.h |   6 ++
 4 files changed, 216 insertions(+)
 create mode 100644 drivers/media/rc/ir-sharp-decoder.c

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 904f113..3b25887 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -106,6 +106,15 @@ config IR_SANYO_DECODER
   uses the Sanyo protocol (Sanyo, Aiwa, Chinon remotes),
   and you need software decoding support.
 
+config IR_SHARP_DECODER
+   tristate Enable IR raw decoder for the Sharp protocol
+   depends on RC_CORE
+   default y
+
+   ---help---
+  Enable this option if you have an infrared remote control which
+  uses the Sharp protocol, and you need software decoding support.
+
 config IR_MCE_KBD_DECODER
tristate Enable IR raw decoder for the MCE keyboard/mouse protocol
depends on RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index f4eb32c..36dafed 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_IR_JVC_DECODER) += ir-jvc-decoder.o
 obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o
 obj-$(CONFIG_IR_RC5_SZ_DECODER) += ir-rc5-sz-decoder.o
 obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o
+obj-$(CONFIG_IR_SHARP_DECODER) += ir-sharp-decoder.o
 obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o
 obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o
 
diff --git a/drivers/media/rc/ir-sharp-decoder.c 
b/drivers/media/rc/ir-sharp-decoder.c
new file mode 100644
index 000..4c17be5
--- /dev/null
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -0,0 +1,200 @@
+/* ir-sharp-decoder.c - handle Sharp IR Pulse/Space protocol
+ *
+ * Copyright (C) 2013-2014 Imagination Technologies Ltd.
+ *
+ * Based on NEC decoder:
+ * Copyright (C) 2010 by Mauro Carvalho Chehab mche...@redhat.com
+ *
+ * This program is free software; you can 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.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+#include linux/bitrev.h
+#include linux/module.h
+#include rc-core-priv.h
+
+#define SHARP_NBITS15
+#define SHARP_UNIT 4  /* ns */
+#define SHARP_BIT_PULSE(8* SHARP_UNIT) /* 320us */
+#define SHARP_BIT_0_PERIOD (25   * SHARP_UNIT) /* 1ms (680us space) */
+#define SHARP_BIT_1_PERIOD (50   * SHARP_UNIT) /* 2ms (1680ms space) */
+#define SHARP_ECHO_SPACE   (1000 * SHARP_UNIT) /* 40 ms */
+#define SHARP_TRAILER_SPACE(125  * SHARP_UNIT) /* 5 ms (even longer) */
+
+enum sharp_state {
+   STATE_INACTIVE,
+   STATE_BIT_PULSE,
+   STATE_BIT_SPACE,
+   STATE_TRAILER_PULSE,
+   STATE_ECHO_SPACE,
+   STATE_TRAILER_SPACE,
+};
+
+/**
+ * ir_sharp_decode() - Decode one Sharp pulse or space
+ * @dev:   the struct rc_dev descriptor of the device
+ * @duration:  the struct ir_raw_event descriptor of the pulse/space
+ *
+ * This function returns -EINVAL if the pulse violates the state machine
+ */
+static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
+{
+   struct sharp_dec *data = dev-raw-sharp;
+   u32 msg, echo, address, command, scancode;
+
+   if (!(dev-enabled_protocols  RC_BIT_SHARP))
+   return 0;
+
+   if (!is_timing_event(ev)) {
+   if (ev.reset)
+   data-state = STATE_INACTIVE;
+   return 0;
+   }
+
+   IR_dprintk(2, Sharp decode started at state %d (%uus %s)\n,
+  data-state, TO_US(ev.duration), TO_STR(ev.pulse));
+
+   switch (data-state) {
+
+   case STATE_INACTIVE:
+   if (!ev.pulse)
+   break;
+
+   if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
+  SHARP_BIT_PULSE / 2))
+   break;
+
+   data-count = 0;
+   data-pulse_len = ev.duration;
+   data-state 

[PATCH v2 05/15] media: rc: change 32bit NEC scancode format

2014-01-17 Thread James Hogan
Change 32bit NEC scancode format (used by Apple and TiVo remotes) to
encode the data with the correct bit order. Previously the raw bits were
used without being bit reversed, now each 16bit half is bit reversed
compared to before.

So for the raw NEC data:
  (LSB/First) 0xAAaaCCcc (MSB/Last)
(where traditionally AA=address, aa=~address, CC=command, cc=~command)

We now generate the scancodes:
  (MSB) 0xAACC (LSB) (normal NEC)
  (MSB) 0x00AAaaCC (LSB) (extended NEC, address check wrong)
  (MSB) 0xaaAAccCC (LSB) (32-bit NEC, command check wrong)

Note that the address byte order in 32-bit NEC scancodes is different to
that of the extended NEC scancodes. I chose this way as it maintains the
order of the bits in the address/command fields, and CC is clearly
intended to be the LSB of the command if the TiVo codes are anything to
go by so it makes sense for AA to also be the LSB.

The TiVo keymap is updated accordingly.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Jarod Wilson ja...@redhat.com
Cc: linux-media@vger.kernel.org
---
v2:
- New patch.
---
 drivers/media/rc/ir-nec-decoder.c  |  5 ++-
 drivers/media/rc/keymaps/rc-tivo.c | 86 +++---
 2 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c
index 9a90094..1bab7ea 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -172,7 +172,10 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
if (send_32bits) {
/* NEC transport, but modified protocol, used by at
 * least Apple and TiVo remotes */
-   scancode = data-bits;
+   scancode = not_address  24 |
+  address  16 |
+  not_command   8 |
+  command;
IR_dprintk(1, NEC (modified) scancode 0x%08x\n, 
scancode);
} else if ((address ^ not_address) != 0xff) {
/* Extended NEC */
diff --git a/drivers/media/rc/keymaps/rc-tivo.c 
b/drivers/media/rc/keymaps/rc-tivo.c
index 454e062..5cc1b45 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -15,62 +15,62 @@
  * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle,
  * which also ships with a TiVo-branded IR transceiver, supported by the mceusb
  * driver. Note that the remote uses an NEC-ish protocol, but instead of having
- * a command/not_command pair, it has a vendor ID of 0xa10c, but some keys, the
+ * a command/not_command pair, it has a vendor ID of 0x3085, but some keys, the
  * NEC extended checksums do pass, so the table presently has the intended
  * values and the checksum-passed versions for those keys.
  */
 static struct rc_map_table tivo[] = {
-   { 0xa10c900f, KEY_MEDIA },  /* TiVo Button */
-   { 0xa10c0807, KEY_POWER2 }, /* TV Power */
-   { 0xa10c8807, KEY_TV }, /* Live TV/Swap */
-   { 0xa10c2c03, KEY_VIDEO_NEXT }, /* TV Input */
-   { 0xa10cc807, KEY_INFO },
-   { 0xa10cfa05, KEY_CYCLEWINDOWS }, /* Window */
+   { 0x3085f009, KEY_MEDIA },  /* TiVo Button */
+   { 0x3085e010, KEY_POWER2 }, /* TV Power */
+   { 0x3085e011, KEY_TV }, /* Live TV/Swap */
+   { 0x3085c034, KEY_VIDEO_NEXT }, /* TV Input */
+   { 0x3085e013, KEY_INFO },
+   { 0x3085a05f, KEY_CYCLEWINDOWS }, /* Window */
{ 0x0085305f, KEY_CYCLEWINDOWS },
-   { 0xa10c6c03, KEY_EPG },/* Guide */
+   { 0x3085c036, KEY_EPG },/* Guide */
 
-   { 0xa10c2807, KEY_UP },
-   { 0xa10c6807, KEY_DOWN },
-   { 0xa10ce807, KEY_LEFT },
-   { 0xa10ca807, KEY_RIGHT },
+   { 0x3085e014, KEY_UP },
+   { 0x3085e016, KEY_DOWN },
+   { 0x3085e017, KEY_LEFT },
+   { 0x3085e015, KEY_RIGHT },
 
-   { 0xa10c1807, KEY_SCROLLDOWN }, /* Red Thumbs Down */
-   { 0xa10c9807, KEY_SELECT },
-   { 0xa10c5807, KEY_SCROLLUP },   /* Green Thumbs Up */
+   { 0x3085e018, KEY_SCROLLDOWN }, /* Red Thumbs Down */
+   { 0x3085e019, KEY_SELECT },
+   { 0x3085e01a, KEY_SCROLLUP },   /* Green Thumbs Up */
 
-   { 0xa10c3807, KEY_VOLUMEUP },
-   { 0xa10cb807, KEY_VOLUMEDOWN },
-   { 0xa10cd807, KEY_MUTE },
-   { 0xa10c040b, KEY_RECORD },
-   { 0xa10c7807, KEY_CHANNELUP },
-   { 0xa10cf807, KEY_CHANNELDOWN },
+   { 0x3085e01c, KEY_VOLUMEUP },
+   { 0x3085e01d, KEY_VOLUMEDOWN },
+   { 0x3085e01b, KEY_MUTE },
+   { 0x3085d020, KEY_RECORD },
+   { 0x3085e01e, KEY_CHANNELUP },
+   { 0x3085e01f, KEY_CHANNELDOWN },
{ 0x0085301f, KEY_CHANNELDOWN },
 
-   { 0xa10c840b, KEY_PLAY },
-   { 0xa10cc40b, KEY_PAUSE },
-   { 0xa10ca40b, KEY_SLOW },
-   { 0xa10c440b, 

[PATCH v2 04/15] media: rc: add sysfs scancode filtering interface

2014-01-17 Thread James Hogan
Add and document a generic sysfs based scancode filtering interface for
making use of IR data matching hardware to filter out uninteresting
scancodes. Two filters exist, one for normal operation and one for
filtering scancodes which are permitted to wake the system from suspend.

The following files are added to /sys/class/rc/rc?/:
 - filter: normal scancode filter value
 - filter_mask: normal scancode filter mask
 - wakeup_filter: wakeup scancode filter value
 - wakeup_filter_mask: wakeup scancode filter mask

A new s_filter() driver callback is added which must arrange for the
specified filter to be applied at the right time. Drivers can convert
the scancode filter into a raw IR data filter, which can be applied
immediately or later (for wake up filters).

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 Landley r...@landley.net
Cc: linux-...@vger.kernel.org
---
v2:
- new patch.
---
 Documentation/ABI/testing/sysfs-class-rc |  58 +
 drivers/media/rc/rc-main.c   | 136 +++
 include/media/rc-core.h  |  29 +++
 3 files changed, 223 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-rc 
b/Documentation/ABI/testing/sysfs-class-rc
index 52bc057..c0e1d14 100644
--- a/Documentation/ABI/testing/sysfs-class-rc
+++ b/Documentation/ABI/testing/sysfs-class-rc
@@ -32,3 +32,61 @@ Description:
Writing none will disable all protocols.
Write fails with EINVAL if an invalid protocol combination or
unknown protocol name is used.
+
+What:  /sys/class/rc/rcN/filter
+Date:  Jan 2014
+KernelVersion: 3.15
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   Sets the scancode filter expected value.
+   Use in combination with /sys/class/rc/rcN/filter_mask to set the
+   expected value of the bits set in the filter mask.
+   If the hardware supports it then scancodes which do not match
+   the filter will be ignored. Otherwise the write will fail with
+   an error.
+   This value may be reset to 0 if the current protocol is altered.
+
+What:  /sys/class/rc/rcN/filter_mask
+Date:  Jan 2014
+KernelVersion: 3.15
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   Sets the scancode filter mask of bits to compare.
+   Use in combination with /sys/class/rc/rcN/filter to set the bits
+   of the scancode which should be compared against the expected
+   value. A value of 0 disables the filter to allow all valid
+   scancodes to be processed.
+   If the hardware supports it then scancodes which do not match
+   the filter will be ignored. Otherwise the write will fail with
+   an error.
+   This value may be reset to 0 if the current protocol is altered.
+
+What:  /sys/class/rc/rcN/wakeup_filter
+Date:  Jan 2014
+KernelVersion: 3.15
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   Sets the scancode wakeup filter expected value.
+   Use in combination with /sys/class/rc/rcN/wakeup_filter_mask to
+   set the expected value of the bits set in the wakeup filter mask
+   to trigger a system wake event.
+   If the hardware supports it and wakeup_filter_mask is not 0 then
+   scancodes which match the filter will wake the system from e.g.
+   suspend to RAM or power off.
+   Otherwise the write will fail with an error.
+   This value may be reset to 0 if the current protocol is altered.
+
+What:  /sys/class/rc/rcN/wakeup_filter_mask
+Date:  Jan 2014
+KernelVersion: 3.15
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   Sets the scancode wakeup filter mask of bits to compare.
+   Use in combination with /sys/class/rc/rcN/wakeup_filter to set
+   the bits of the scancode which should be compared against the
+   expected value to trigger a system wake event.
+   If the hardware supports it and wakeup_filter_mask is not 0 then
+   scancodes which match the filter will wake the system from e.g.
+   suspend to RAM or power off.
+   Otherwise the write will fail with an error.
+   This value may be reset to 0 if the current protocol is altered.
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index d3ac83e..b0079eb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -965,6 +965,130 @@ out:
return ret;
 }
 
+/**
+ * struct rc_filter_attribute - Device attribute relating to a filter type.
+ * @attr:  Device 

[PATCH v2 01/15] media: rc: document rc class sysfs API

2014-01-17 Thread James Hogan
Briefly document /sys/class/rc/ API for remote controller devices in
Documentation/ABI/teting.

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 Landley r...@landley.net
Cc: linux-...@vger.kernel.org
---
v2:
- New patch.
---
 Documentation/ABI/testing/sysfs-class-rc | 34 
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-rc

diff --git a/Documentation/ABI/testing/sysfs-class-rc 
b/Documentation/ABI/testing/sysfs-class-rc
new file mode 100644
index 000..52bc057
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-rc
@@ -0,0 +1,34 @@
+What:  /sys/class/rc/
+Date:  Apr 2010
+KernelVersion: 2.6.35
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   The rc/ class sub-directory belongs to the Remote Controller
+   core and provides a sysfs interface for configuring infrared
+   remote controller receivers.
+
+What:  /sys/class/rc/rcN/
+Date:  Apr 2010
+KernelVersion: 2.6.35
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   A /sys/class/rc/rcN directory is created for each remote
+   control receiver device where N is the number of the receiver.
+
+What:  /sys/class/rc/rcN/protocols
+Date:  Jun 2010
+KernelVersion: 2.6.36
+Contact:   Mauro Carvalho Chehab m.che...@samsung.com
+Description:
+   Reading this file returns a list of available protocols,
+   something like:
+   rc5 [rc6] nec jvc [sony]
+   Enabled protocols are shown in [] brackets.
+   Writing +proto will add a protocol to the list of enabled
+   protocols.
+   Writing -proto will remove a protocol from the list of enabled
+   protocols.
+   Writing proto will enable only proto.
+   Writing none will disable all protocols.
+   Write fails with EINVAL if an invalid protocol combination or
+   unknown protocol name is used.
-- 
1.8.3.2


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


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

2014-01-17 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
---
v2:
- Update scancode and filter callbacks to handle 32-bit NEC as used by
  Apple and TiVo remotes (the new 32-bit NEC scancode format is used,
  with the correct bit orientation).
- Update to new scancode interface so that 32-bit NEC scancodes can be
  returned reliably.
- Update to new filtering interface (generic struct rc_scancode_filter).
- Make it possible to set the filter to extended NEC even when the high
  bits of the scancode value aren't set, by taking the mask into account
  too. My TV remote happens to use extended NEC with address 0x7f00,
  which unfortunately maps to scancodes 0x007f** which looks like normal
  NEC and couldn't previously be filtered.
- Remove modularity and dynamic registration/unregistration, adding NEC
  directly to the list of decoders in img-ir-hw.c.
---
 drivers/media/rc/img-ir/Kconfig  |   7 ++
 drivers/media/rc/img-ir/Makefile |   1 +
 drivers/media/rc/img-ir/img-ir-hw.c  |   5 ++
 drivers/media/rc/img-ir/img-ir-nec.c | 148 +++
 4 files changed, 161 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 60eaba6..28498a2 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
+   bool NEC protocol support
+   depends on IR_IMG_HW
+   help
+  Say Y here to enable support for the NEC, extended NEC, and 32-bit
+  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 4ef86ed..c409197 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -1,6 +1,7 @@
 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-$(CONFIG_IR_IMG_NEC)+= img-ir-nec.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index a7c7481..79ec495 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -20,8 +20,13 @@
 /* Decoders lock (only modified to preprocess them) */
 static DEFINE_SPINLOCK(img_ir_decoders_lock);
 
+extern struct img_ir_decoder img_ir_nec;
+
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
+#ifdef CONFIG_IR_IMG_NEC
+   img_ir_nec,
+#endif
NULL
 };
 
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 000..e7a731b
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -0,0 +1,148 @@
+/*
+ * ImgTec IR Decoder setup for NEC protocol.
+ *
+ * Copyright 2010-2014 Imagination Technologies Ltd.
+ */
+
+#include img-ir-hw.h
+
+/* Convert NEC data to a scancode */
+static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
+{
+   unsigned int addr, addr_inv, data, data_inv;
+   /* a repeat code has no data */
+   if (!len)
+   return IMG_IR_REPEATCODE;
+   if (len != 32)
+   return -EINVAL;
+   /* raw encoding: ddDDaaAA */
+   addr = (raw   0)  0xff;
+   addr_inv = (raw   8)  0xff;
+   data = (raw  16)  0xff;
+   data_inv = (raw  24)  0xff;
+   if ((data_inv ^ data) != 0xff) {
+   /* 32-bit NEC (used by Apple and TiVo remotes) */
+   /* scan encoding: aaAAddDD */
+   *scancode = addr_inv  24 |
+   addr  16 |
+   data_inv   8 |
+   data;
+   } else if ((addr_inv ^ addr) != 0xff) {
+   /* Extended NEC */
+   /* scan encoding: AAaaDD */
+   *scancode = addr  16 |
+   addr_inv   8 |
+   data;
+   } else {
+   /* Normal NEC */
+   /* scan encoding: AADD */
+   *scancode = addr  8 |
+   data;
+   }
+   return IMG_IR_SCANCODE;
+}
+
+/* Convert NEC scancode to NEC data filter */
+static int img_ir_nec_filter(const struct rc_scancode_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_inv_m;
+
+   data   = 

[PATCH v2 12/15] media: rc: img-ir: add JVC decoder module

2014-01-17 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
---
v2:
- Update to new scancode interface (32-bit NEC).
- Update to new filtering interface (generic struct rc_scancode_filter).
- Remove modularity and dynamic registration/unregistration, adding JVC
  directly to the list of decoders in img-ir-hw.c.
---
 drivers/media/rc/img-ir/Kconfig  |  7 +++
 drivers/media/rc/img-ir/Makefile |  1 +
 drivers/media/rc/img-ir/img-ir-hw.c  |  4 ++
 drivers/media/rc/img-ir/img-ir-jvc.c | 92 
 4 files changed, 104 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 28498a2..96006fbf 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 here to enable support for the NEC, extended NEC, and 32-bit
   NEC protocols in the ImgTec infrared decoder block.
+
+config IR_IMG_JVC
+   bool JVC protocol support
+   depends on IR_IMG_HW
+   help
+  Say Y 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 c409197..c5f8f06 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -2,6 +2,7 @@ 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-$(CONFIG_IR_IMG_NEC)+= img-ir-nec.o
+img-ir-$(CONFIG_IR_IMG_JVC)+= img-ir-jvc.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index 79ec495..fc8a58b 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -21,12 +21,16 @@
 static DEFINE_SPINLOCK(img_ir_decoders_lock);
 
 extern struct img_ir_decoder img_ir_nec;
+extern struct img_ir_decoder img_ir_jvc;
 
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
 #ifdef CONFIG_IR_IMG_NEC
img_ir_nec,
 #endif
+#ifdef CONFIG_IR_IMG_JVC
+   img_ir_jvc,
+#endif
NULL
 };
 
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 000..ae55867
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-jvc.c
@@ -0,0 +1,92 @@
+/*
+ * ImgTec IR Decoder setup for JVC protocol.
+ *
+ * Copyright 2012-2014 Imagination Technologies Ltd.
+ */
+
+#include img-ir-hw.h
+
+/* Convert JVC data to a scancode */
+static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
+{
+   unsigned int cust, data;
+
+   if (len != 16)
+   return -EINVAL;
+
+   cust = (raw  0)  0xff;
+   data = (raw  8)  0xff;
+
+   *scancode = cust  8 | data;
+   return IMG_IR_SCANCODE;
+}
+
+/* Convert JVC scancode to JVC data filter */
+static int img_ir_jvc_filter(const struct rc_scancode_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
+ */
+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) */
+  

[PATCH v2 13/15] media: rc: img-ir: add Sony decoder module

2014-01-17 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
---
v2:
- Update to new scancode interface (32-bit NEC).
- Update to new filtering interface (generic struct rc_scancode_filter).
- Remove modularity and dynamic registration/unregistration, adding Sony
  directly to the list of decoders in img-ir-hw.c.
---
 drivers/media/rc/img-ir/Kconfig   |   7 ++
 drivers/media/rc/img-ir/Makefile  |   1 +
 drivers/media/rc/img-ir/img-ir-hw.c   |   4 +
 drivers/media/rc/img-ir/img-ir-sony.c | 145 ++
 4 files changed, 157 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 96006fbf..ab36577 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 here to enable support for the JVC protocol in the ImgTec
   infrared decoder block.
+
+config IR_IMG_SONY
+   bool Sony protocol support
+   depends on IR_IMG_HW
+   help
+  Say Y 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 c5f8f06..978c0c6 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -3,6 +3,7 @@ img-ir-$(CONFIG_IR_IMG_RAW) += img-ir-raw.o
 img-ir-$(CONFIG_IR_IMG_HW) += img-ir-hw.o
 img-ir-$(CONFIG_IR_IMG_NEC)+= img-ir-nec.o
 img-ir-$(CONFIG_IR_IMG_JVC)+= img-ir-jvc.o
+img-ir-$(CONFIG_IR_IMG_SONY)   += img-ir-sony.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index fc8a58b..17fb527 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -22,6 +22,7 @@ static DEFINE_SPINLOCK(img_ir_decoders_lock);
 
 extern struct img_ir_decoder img_ir_nec;
 extern struct img_ir_decoder img_ir_jvc;
+extern struct img_ir_decoder img_ir_sony;
 
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
@@ -31,6 +32,9 @@ static struct img_ir_decoder *img_ir_decoders[] = {
 #ifdef CONFIG_IR_IMG_JVC
img_ir_jvc,
 #endif
+#ifdef CONFIG_IR_IMG_SONY
+   img_ir_sony,
+#endif
NULL
 };
 
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 000..993409a
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -0,0 +1,145 @@
+/*
+ * ImgTec IR Decoder setup for Sony (SIRC) protocol.
+ *
+ * Copyright 2012-2014 Imagination Technologies Ltd.
+ */
+
+#include img-ir-hw.h
+
+/* Convert Sony data to a scancode */
+static int img_ir_sony_scancode(int len, u64 raw, int *scancode, u64 protocols)
+{
+   unsigned int dev, subdev, func;
+
+   switch (len) {
+   case 12:
+   if (!(protocols  RC_BIT_SONY12))
+   return -EINVAL;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0x1f;/* next 5 bits */
+   subdev = 0;
+   break;
+   case 15:
+   if (!(protocols  RC_BIT_SONY15))
+   return -EINVAL;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0xff;/* next 8 bits */
+   subdev = 0;
+   break;
+   case 20:
+   if (!(protocols  RC_BIT_SONY20))
+   return -EINVAL;
+   func   = raw  0x7f;/* first 7 bits */
+   raw= 7;
+   dev= raw  0x1f;/* next 5 bits */
+   raw= 5;
+   subdev = raw  0xff;/* next 8 bits */
+   break;
+   default:
+   return -EINVAL;
+   }
+   *scancode = dev  16 | subdev  8 | func;
+   return IMG_IR_SCANCODE;
+}
+
+/* Convert NEC scancode to NEC data filter */
+static int img_ir_sony_filter(const struct rc_scancode_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 */

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

2014-01-17 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
---
v2:
- Update to new scancode interface (32-bit NEC).
- Update to new filtering interface (generic struct rc_scancode_filter).
- Remove modularity and dynamic registration/unregistration, adding
  Sanyo directly to the list of decoders in img-ir-hw.c.
---
 drivers/media/rc/img-ir/Kconfig|   7 ++
 drivers/media/rc/img-ir/Makefile   |   1 +
 drivers/media/rc/img-ir/img-ir-hw.c|   4 ++
 drivers/media/rc/img-ir/img-ir-sanyo.c | 122 +
 4 files changed, 134 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 48627f9..03ba9fc 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 here to enable support for the Sharp protocol in the ImgTec
   infrared decoder block.
+
+config IR_IMG_SANYO
+   bool Sanyo protocol support
+   depends on IR_IMG_HW
+   help
+  Say Y 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 792a3c4..92a459d 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -5,6 +5,7 @@ img-ir-$(CONFIG_IR_IMG_NEC) += img-ir-nec.o
 img-ir-$(CONFIG_IR_IMG_JVC)+= img-ir-jvc.o
 img-ir-$(CONFIG_IR_IMG_SONY)   += img-ir-sony.o
 img-ir-$(CONFIG_IR_IMG_SHARP)  += img-ir-sharp.o
+img-ir-$(CONFIG_IR_IMG_SANYO)  += img-ir-sanyo.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index fc84b75..0e71426 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -24,6 +24,7 @@ extern struct img_ir_decoder img_ir_nec;
 extern struct img_ir_decoder img_ir_jvc;
 extern struct img_ir_decoder img_ir_sony;
 extern struct img_ir_decoder img_ir_sharp;
+extern struct img_ir_decoder img_ir_sanyo;
 
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
@@ -39,6 +40,9 @@ static struct img_ir_decoder *img_ir_decoders[] = {
 #ifdef CONFIG_IR_IMG_SHARP
img_ir_sharp,
 #endif
+#ifdef CONFIG_IR_IMG_SANYO
+   img_ir_sanyo,
+#endif
NULL
 };
 
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 000..c2c763e
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sanyo.c
@@ -0,0 +1,122 @@
+/*
+ * ImgTec IR Decoder setup for Sanyo protocol.
+ *
+ * Copyright 2012-2014 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 img-ir-hw.h
+
+/* Convert Sanyo data to a scancode */
+static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, 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 -EINVAL;
+   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 -EINVAL;
+   /* Validate address */
+   if ((addr_inv ^ addr) != 0x1fff)
+   return -EINVAL;
+
+   /* Normal Sanyo */
+   *scancode = addr  8 | data;
+   return IMG_IR_SCANCODE;
+}
+
+/* Convert Sanyo scancode to Sanyo data filter */
+static int img_ir_sanyo_filter(const struct rc_scancode_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 |
+   

[PATCH v2 06/15] dt: binding: add binding for ImgTec IR block

2014-01-17 Thread James Hogan
Add device tree binding for ImgTec Consumer Infrared block, specifically
major revision 1 of the hardware.

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 robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian Campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Cc: devicet...@vger.kernel.org
Cc: Rob Landley r...@landley.net
Cc: linux-...@vger.kernel.org
Cc: Tomasz Figa tomasz.f...@gmail.com
---
v2:
- Future proof compatible string from img,ir to img,ir1, where the 1
  corresponds to the major revision number of the hardware (Tomasz
  Figa).
- Added clock-names property and three specific clock names described in
  the manual, only one of which is used by the current driver (Tomasz
  Figa).
---
 .../devicetree/bindings/media/img-ir1.txt  | 30 ++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/img-ir1.txt

diff --git a/Documentation/devicetree/bindings/media/img-ir1.txt 
b/Documentation/devicetree/bindings/media/img-ir1.txt
new file mode 100644
index 000..ace5fd9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/img-ir1.txt
@@ -0,0 +1,30 @@
+* ImgTec Infrared (IR) decoder version 1
+
+This binding is for Imagination Technologies' Infrared decoder block,
+specifically major revision 1.
+
+Required properties:
+- compatible:  Should be img,ir1
+- reg: Physical base address of the controller and length of
+   memory mapped region.
+- interrupts:  The interrupt specifier to the cpu.
+
+Optional properties:
+- clocks:  List of clock specifiers as described in standard
+   clock bindings.
+- clock-names: List of clock names corresponding to the clocks
+   specified in the clocks property.
+   Accepted clock names are:
+   core: Core clock (defaults to 32.768KHz if omitted).
+   sys:  System side (fast) clock.
+   mod:  Power modulation clock.
+
+Example:
+
+   ir@02006200 {
+   compatible = img,ir1;
+   reg = 0x02006200 0x100;
+   interrupts = 29 4;
+   clocks = clk_32khz;
+   clock-names =  core;
+   };
-- 
1.8.3.2


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


[PATCH v2 08/15] media: rc: img-ir: add raw driver

2014-01-17 Thread James Hogan
Add raw IR remote control input driver for the ImgTec Infrared decoder
block's 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
---
v2:
- Echo the last sample after 150ms if no edges have been detected. This
  allows the soft decoder state machines to recognise the final space
  when no repeat code is received.
- Use spin_lock_irq() instead of spin_lock_irqsave() in various bits of
  code that aren't accessible from hard interrupt context.
- Avoid removal race by checking for RC device in ISR.
---
 drivers/media/rc/img-ir/img-ir-raw.c | 151 +++
 drivers/media/rc/img-ir/img-ir-raw.h |  60 ++
 2 files changed, 211 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 000..cfb01d9
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-raw.c
@@ -0,0 +1,151 @@
+/*
+ * ImgTec IR Raw Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2014 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
+
+#define ECHO_TIMEOUT_MS 150/* ms between echos */
+
+/* must be called with priv-lock held */
+static void img_ir_refresh_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);
+}
+
+/* called with priv-lock held */
+void img_ir_isr_raw(struct img_ir_priv *priv, u32 irq_status)
+{
+   struct img_ir_priv_raw *raw = priv-raw;
+
+   /* check not removing */
+   if (!raw-rdev)
+   return;
+
+   img_ir_refresh_raw(priv, irq_status);
+
+   /* start / push back the echo timer */
+   mod_timer(raw-timer, jiffies + msecs_to_jiffies(ECHO_TIMEOUT_MS));
+}
+
+/*
+ * Echo timer callback function.
+ * The raw decoders expect to get a final sample even if there are no edges, in
+ * order to be assured of the final space. If there are no edges for a certain
+ * time we use this timer to emit a final sample to satisfy them.
+ */
+static void img_ir_echo_timer(unsigned long arg)
+{
+   struct img_ir_priv *priv = (struct img_ir_priv *)arg;
+
+   spin_lock_irq(priv-lock);
+
+   /* check not removing */
+   if (priv-raw.rdev)
+   /*
+* It's safe to pass irq_status=0 since it's only used to check
+* for double edges.
+*/
+   img_ir_refresh_raw(priv, 0);
+
+   spin_unlock_irq(priv-lock);
+}
+
+void img_ir_setup_raw(struct img_ir_priv *priv)
+{
+   u32 irq_en;
+
+   if (!priv-raw.rdev)
+   return;
+
+   /* clear and enable edge interrupts */
+   spin_lock_irq(priv-lock);
+   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_irq(priv-lock);
+}
+
+int img_ir_probe_raw(struct img_ir_priv *priv)
+{
+   struct img_ir_priv_raw *raw = priv-raw;
+   struct rc_dev *rdev;
+   int error;
+
+   /* Set up the echo timer */
+   setup_timer(raw-timer, img_ir_echo_timer, (unsigned long)priv);
+
+   /* 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 = 

[PATCH v2 07/15] media: rc: img-ir: add base driver

2014-01-17 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 robh...@kernel.org
Cc: devicet...@vger.kernel.org
---
v2:
- Use new DT binding, with a different compatibility string and get core
  clock by name.
- Remove next pointer from struct img_ir_priv. This is related to the
  removal of dynamic registration/unregistration of protocol decode
  timings from later patches.
- Add io.h include to img-ir.h.
---
 drivers/media/rc/img-ir/img-ir-core.c | 176 ++
 drivers/media/rc/img-ir/img-ir.h  | 166 
 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 000..d510213
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-core.c
@@ -0,0 +1,176 @@
+/*
+ * ImgTec IR Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2014 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 core clock */
+   priv-clk = devm_clk_get(pdev-dev, core);
+   if (IS_ERR(priv-clk))
+   dev_warn(pdev-dev, cannot get core clock resource\n);
+   /*
+* The driver doesn't need to know about the system (sys) or power
+* modulation (mod) clocks yet
+*/
+

[PATCH v2 09/15] media: rc: img-ir: add hardware decoder driver

2014-01-17 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
will be provided in separate files for each protocol which this part of
the driver can use. The new generic scan code filter interface is made
use of to reduce interrupts and control wake events.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
v2:
- Fix typo in img_ir_enable_wake (s/RC_FILTER_WAKUP/RC_FILTER_WAKEUP/).
- Use the new generic filtering interface rather than creating the sysfs
  files in the driver. This rearranges the code a bit, so as to use an
  array of 2 filters (normal and wake) rather than separate struct
  members for each, and passes the array index around between functions
  rather than the pointer to the filter.
- Make tolerance of hardware decoder timings configurable per protocol
  rather than being fixed at 10% for all protocols. This allows the
  tolerance of the Sharp protocol timings in particular to be increased.
- Extend the scancode() decoder callback to handle full 32bit scancodes.
  Previously negative scancodes were treated specially, and indicated
  repeat codes or invalid raw data, but 32bit NEC may result in a
  scancode with the top bit set. Therefore change the scancode() return
  value to simply indicate success/fail/repeat, and add an extra
  scancode output pointer parameter that must have been written by the
  callback if it returns IMG_IR_SCANCODE.
- Add a debug message for when the scancode() callback rejects the data.
- Remove the dynamic registration and unregistration of protocol decoder
  timings. It didn't really get us much and it complicated locking and
  load ordering.
- Separate clock rate specific data in the decoder timings structure so
  that it can be more easily shared between instantiations of the
  driver. A new struct img_ir_reg_timings stores the calculated clock
  rate specific register values for the timings. This allows us to make
  more widespread use of const on decoder timings.
- Simplify locking of decoders, they're now only modified when
  preprocessed, and all other use is after that, so preprocessing is the
  only place locking is required.
- Minor cosmetic changes (variable naming e.g. s/ir_dev/rdev/ in
  img_ir_set_protocol).
- Use spin_lock_irq() instead of spin_lock_irqsave() in various bits of
  code that aren't accessible from hard interrupt context.
- Fix rc_map.rc_type initialisation to use __ffs64(proto_mask).
- Fix img_ir_allowed_protos() to return a protocol mask in a u64 rather
  than an unsigned long.
- Fix change_protocol to accept a zero protocol mask (for when none is
  written to /sys/class/rc/rcX/protocols).
- Use setup_timer() macro for the end timer rather than using
  init_timer() and setting function pointer and data explicitly.
- Stop the end_timer (for keyups after repeat code timeout) safely on
  removal and protocol switch.
---
 drivers/media/rc/img-ir/img-ir-hw.c | 1019 +++
 drivers/media/rc/img-ir/img-ir-hw.h |  269 +
 2 files changed, 1288 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 000..a7c7481
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -0,0 +1,1019 @@
+/*
+ * ImgTec IR Hardware Decoder found in PowerDown Controller.
+ *
+ * Copyright 2010-2014 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/bitops.h
+#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
+
+/* Decoders lock (only modified to preprocess them) */
+static DEFINE_SPINLOCK(img_ir_decoders_lock);
+
+static bool img_ir_decoders_preprocessed;
+static struct img_ir_decoder *img_ir_decoders[] = {
+   NULL
+};
+
+#define IMG_IR_F_FILTERBIT(RC_FILTER_NORMAL)   /* enable 
filtering */
+#define IMG_IR_F_WAKE  BIT(RC_FILTER_WAKEUP)   /* 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)
+{

[PATCH v2 14/15] media: rc: img-ir: add Sharp decoder module

2014-01-17 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
---
v2:
- Update to new scancode interface (32-bit NEC).
- Update to new filtering interface (generic struct rc_scancode_filter).
- Remove modularity and dynamic registration/unregistration, adding
  Sharp directly to the list of decoders in img-ir-hw.c.
- Fix typo in logic 1 pulse width comment.
- Set tolerance to 20%, which seemed to be needed for the cases I have.
---
 drivers/media/rc/img-ir/Kconfig|  7 +++
 drivers/media/rc/img-ir/Makefile   |  1 +
 drivers/media/rc/img-ir/img-ir-hw.c|  4 ++
 drivers/media/rc/img-ir/img-ir-sharp.c | 99 ++
 4 files changed, 111 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 ab36577..48627f9 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 here to enable support for the Sony protocol in the ImgTec
   infrared decoder block.
+
+config IR_IMG_SHARP
+   bool Sharp protocol support
+   depends on IR_IMG_HW
+   help
+  Say Y 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 978c0c6..792a3c4 100644
--- a/drivers/media/rc/img-ir/Makefile
+++ b/drivers/media/rc/img-ir/Makefile
@@ -4,6 +4,7 @@ img-ir-$(CONFIG_IR_IMG_HW)  += img-ir-hw.o
 img-ir-$(CONFIG_IR_IMG_NEC)+= img-ir-nec.o
 img-ir-$(CONFIG_IR_IMG_JVC)+= img-ir-jvc.o
 img-ir-$(CONFIG_IR_IMG_SONY)   += img-ir-sony.o
+img-ir-$(CONFIG_IR_IMG_SHARP)  += img-ir-sharp.o
 img-ir-objs:= $(img-ir-y)
 
 obj-$(CONFIG_IR_IMG)   += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index 17fb527..fc84b75 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -23,6 +23,7 @@ static DEFINE_SPINLOCK(img_ir_decoders_lock);
 extern struct img_ir_decoder img_ir_nec;
 extern struct img_ir_decoder img_ir_jvc;
 extern struct img_ir_decoder img_ir_sony;
+extern struct img_ir_decoder img_ir_sharp;
 
 static bool img_ir_decoders_preprocessed;
 static struct img_ir_decoder *img_ir_decoders[] = {
@@ -35,6 +36,9 @@ static struct img_ir_decoder *img_ir_decoders[] = {
 #ifdef CONFIG_IR_IMG_SONY
img_ir_sony,
 #endif
+#ifdef CONFIG_IR_IMG_SHARP
+   img_ir_sharp,
+#endif
NULL
 };
 
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 000..3397cc5
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sharp.c
@@ -0,0 +1,99 @@
+/*
+ * ImgTec IR Decoder setup for Sharp protocol.
+ *
+ * Copyright 2012-2014 Imagination Technologies Ltd.
+ */
+
+#include img-ir-hw.h
+
+/* Convert Sharp data to a scancode */
+static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 
protocols)
+{
+   unsigned int addr, cmd, exp, chk;
+
+   if (len != 15)
+   return -EINVAL;
+
+   addr = (raw0)  0x1f;
+   cmd  = (raw5)  0xff;
+   exp  = (raw   13)   0x1;
+   chk  = (raw   14)   0x1;
+
+   /* validate data */
+   if (!exp)
+   return -EINVAL;
+   if (chk)
+   /* probably the second half of the message */
+   return -EINVAL;
+
+   *scancode = addr  8 | cmd;
+   return IMG_IR_SCANCODE;
+}
+
+/* Convert Sharp scancode to Sharp data filter */
+static int img_ir_sharp_filter(const struct rc_scancode_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
+ */
+struct img_ir_decoder img_ir_sharp = {
+   .type = RC_BIT_SHARP,
+   .control = {
+   .decoden = 0,
+   .decodend2 = 1,
+   .code_type = IMG_IR_CODETYPE_PULSEDIST,
+   .d1validsel = 1,
+   

[PATCH v2 10/15] media: rc: img-ir: add to build

2014-01-17 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 3b25887..8fbd377 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -309,6 +309,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 36dafed..f8b54ff 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -32,3 +32,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 000..60eaba6
--- /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 000..4ef86ed
--- /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.3.2


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


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

2014-01-17 Thread James Hogan
A few generic changes (patches 1-5) and then add a driver for the ImgTec
Infrared decoder block (patches 6-15). 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 in separate files for each protocol which the main driver can
use. The new generic scan code filter interface is made use of to reduce
interrupts and control wake events.

Changes in v2:

Patchset:
- New generic patches 1, 3-5:
  - Patch 1 adds sysfs documentation which is extended by patch 4.
  - Patch 3 adds a raw decoder for the Sharp protocol.
  - Patch 4 adds the scancode filtering sysfs interface generically (bit
of an RFC really).
  - Patch 5 changes the scancode format for 32-bit NEC (bit of an RFC
really - can we get away with this?).

DT bindings:
- Future proof compatible string from img,ir to img,ir1, where the 1
  corresponds to the major revision number of the hardware (Tomasz
  Figa).
- Added clock-names property and three specific clock names described in
  the manual, only one of which is used by the current driver (Tomasz
  Figa).

Misc:
- Use spin_lock_irq() instead of spin_lock_irqsave() in various bits of
  code that aren't accessible from hard interrupt context.
- Add io.h include to img-ir.h.

Raw Decoder:
- Echo the last sample after 150ms if no edges have been detected. This
  allows the soft decoder state machines to recognise the final space
  when no repeat code is received.
- Avoid removal race by checking for RC device in ISR.

Hardware Decoder:
- Remove the dynamic registration and unregistration of protocol decoder
  timings. It didn't really get us much and it complicated locking and
  load ordering.
- Simplify locking of decoders, they're now only modified when
  preprocessed, and all other use is after that, so preprocessing is the
  only place locking is required.
- Use the new generic filtering interface rather than creating the sysfs
  files in the driver. This rearranges the code a bit, so as to use an
  array of 2 filters (normal and wake) rather than separate struct
  members for each, and passes the array index around between functions
  rather than the pointer to the filter.
- Extend the scancode() decoder callback to handle full 32bit scancodes.
  Previously negative scancodes were treated specially, and indicated
  repeat codes or invalid raw data, but 32bit NEC may result in a
  scancode with the top bit set. Therefore change the scancode() return
  value to simply indicate success/fail/repeat, and add an extra
  scancode output pointer parameter that must have been written by the
  callback if it returns IMG_IR_SCANCODE.
- Separate clock rate specific data in the decoder timings structure so
  that it can be more easily shared between instantiations of the
  driver. A new struct img_ir_reg_timings stores the calculated clock
  rate specific register values for the timings. This allows us to make
  more widespread use of const on decoder timings.
- Make tolerance of hardware decoder timings configurable per protocol
  rather than being fixed at 10% for all protocols. This allows the
  tolerance of the Sharp protocol timings in particular to be increased.
- Fix typo in img_ir_enable_wake (s/RC_FILTER_WAKUP/RC_FILTER_WAKEUP/).
- Fix change_protocol to accept a zero protocol mask (for when none is
  written to /sys/class/rc/rcX/protocols).
- Stop the end_timer (for keyups after repeat code timeout) safely on
  removal and protocol switch.
- Fix rc_map.rc_type initialisation to use __ffs64(proto_mask).
- Fix img_ir_allowed_protos() to return a protocol mask in a u64 rather
  than an unsigned long.
- Use setup_timer() macro for the end timer rather than using
  init_timer() and setting function pointer and data explicitly.
- Add a debug message for when the scancode() callback rejects the data.
- Minor cosmetic changes (variable naming e.g. s/ir_dev/rdev/ in
  img_ir_set_protocol).

NEC decoder:
- Update scancode and filter callbacks to handle 32-bit NEC as used by
  Apple and TiVo remotes (the new 32-bit NEC scancode format is used,
  with the correct bit orientation).
- Make it possible to set the filter to extended NEC even when the high
  bits of the scancode value aren't set, by taking the mask into account
  too. My TV remote happens to use extended NEC with address 0x7f00,
  which unfortunately maps to scancodes 0x007f** which looks like normal
  NEC and couldn't previously be filtered.

Sharp decoder:
- Fix typo in logic 1 pulse width comment.
- Set tolerance to 20%, which seemed to be needed for the cases I 

Re: [PATCH] usbvision: drop unused define USBVISION_SAY_AND_WAIT

2014-01-17 Thread Arnd Bergmann
On Friday 17 January 2014, Hans Verkuil wrote:
 This define uses the deprecated interruptible_sleep_on_timeout
 function. Since this define is unused anyway we just remove it.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 Cc: Arnd Bergmann a...@arndb.de

Acked-by: Arnd Bergmann a...@arndb.de

Clearly better than my patch, thanks!
--
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 07/30] [media] radio-cadet: avoid interruptible_sleep_on race

2014-01-17 Thread Arnd Bergmann
On Friday 17 January 2014, Hans Verkuil wrote:
  @@ -323,25 +324,32 @@ static ssize_t cadet_read(struct file *file, char 
  __user *data, size_t count, lo
struct cadet *dev = video_drvdata(file);
unsigned char readbuf[RDS_BUFFER];
int i = 0;
  + DEFINE_WAIT(wait);
   
mutex_lock(dev-lock);
if (dev-rdsstat == 0)
cadet_start_rds(dev);
  - if (dev-rdsin == dev-rdsout) {
  + while (1) {
  + prepare_to_wait(dev-read_queue, wait, TASK_INTERRUPTIBLE);
  + if (dev-rdsin != dev-rdsout)
  + break;
  +
if (file-f_flags  O_NONBLOCK) {
i = -EWOULDBLOCK;
goto unlock;
}
mutex_unlock(dev-lock);
  - interruptible_sleep_on(dev-read_queue);
  + schedule();
mutex_lock(dev-lock);
}
  +
 
 This seems overly complicated. Isn't it enough to replace 
 interruptible_sleep_on
 by 'wait_event_interruptible(dev-read_queue, dev-rdsin != dev-rdsout);'?
 
 Or am I missing something subtle?

The existing code sleeps with dev-lock released because the cadet_handler()
function needs to grab (and release) the same lock before it can wake up
the reader thread.

Doing the simple wait_event_interruptible() would result in a deadlock here.

Arnd
--
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: ov3640 sensor - CCDC won't become idle!

2014-01-17 Thread Peter Meerwald
Hello,

 as the subject says I got a problem with the ccdc.
 
 My pipeline is: sensor - ccdc - memory
 
 By doing some research I found a appropriate answer from Laurent:
 
 The OMAP3 ISP is quite picky about its input signals and doesn't gracefully 
 handle missing or extra sync pulses for instance. A CCDC won't become idle! 
 message usually indicates that the CCDC received a frame of unexpected size 
 (this can happen if the sensor stops in the middle of a frame for instance), 
 or that the driver had no time to process the end of frame interrupt before 
 the next frame arrived (either because of an unsually long interrupt delay on 
 the system, or because of too low vertical blanking).
 
 That sounds logical, but whatever I do nothing works for me. 
 
 Can anyone who had that problem share what you did to solve that problem?
 Or does anyone have a hint for me how to solve this?

I think I've stumbled upon a solution for this problem (stream doesn't 
start properly, resulting in 'CCDC won't become idle') today; the idea is 
to delay ccdc_enable() and SYN_MODE_VDHDEN after the first VSYNC has been 
received

the assumption is that the ov3640 outputs HSYNC/VSYNC in some 
weird/undeterministic way when started, but stabilizes afterwards; the 
OMAP3 ISP gets confused by inproper HSYNC/VSYNC and never recovers...

OMAP3 ISP observations:
SYN_MODE_VDHDEN enables the VSYNC/HSYNC processing of the CCDC (when 
VSYNC/HSYNC configured as input) of the ISP, i.e. the ISP starts counting
horizontal lines needed to trigger VDINT0/VDINT1

the VS_HS_IRQ can be configured to trigger on VSYNC, this is independent 
from SYN_MODE_VDHDEN and VDINT0/VDINT1 and works even when neither 
SYN_MODE_VDHDEN nor CCDC_PCR_EN is set (i.e. before starting the CCDC)

so ccdc_hs_vs_isr() can be used to trigger on the first (maybe n-th) VSYNC 
(when the ov3640 has stabilized); at this point SYN_MODE_VDHDEN and 
CCDC_PCR_EN can be turn on

so the workflow is as follows:

1. configure ISP: ccdc_set_stream() but no ccdc_enable() and no 
SYN_MODE_VDHDEN
2. start ov3640: ov3640_set_stream()
3. wait for VSYNC to trigger, enable SYN_MODE_VDHDEN and ccdc_enable() in 
ccdc_hs_vs_isr()

works for me :)
tested with beagle-xm, ov3640 (Laurent's patches) in YUV 640x480, ISP 
direct to memory, kernel 3.7

the patch below illustrates this

regards, p.


diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index aa9df9d..7d587ee 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -976,7 +976,8 @@ static void ccdc_config_sync_if(struct isp_ccdc_device 
*ccdc,
 {
struct isp_device *isp = to_isp_device(ccdc);
const struct v4l2_mbus_framefmt *format;
-   u32 syn_mode = ISPCCDC_SYN_MODE_VDHDEN;
+   u32 syn_mode = 0; // ISPCCDC_SYN_MODE_VDHDEN;
+   ccdc-vdhden = 0;
 
format = ccdc-formats[CCDC_PAD_SINK];
 
@@ -1416,9 +1417,19 @@ static int __ccdc_handle_stopping(struct isp_ccdc_device 
*ccdc, u32 event)
 static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc)
 {
struct isp_pipeline *pipe = to_isp_pipeline(ccdc-subdev.entity);
+   struct isp_device *isp = to_isp_device(ccdc);
struct video_device *vdev = ccdc-subdev.devnode;
struct v4l2_event event;
 
+   if (!ccdc-vdhden) {
+   isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE,
+   ISPCCDC_SYN_MODE_VDHDEN);
+   ccdc_enable(ccdc);
+   ccdc-vdhden = 1;
+
+   return;
+   }
+
/* Frame number propagation */
atomic_inc(pipe-frame_number);
 
@@ -1765,8 +1776,9 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int 
enable)
if (ccdc-output  CCDC_OUTPUT_MEMORY)
omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CCDC_WRITE);
 
-   if (ccdc-underrun || !(ccdc-output  CCDC_OUTPUT_MEMORY))
-   ccdc_enable(ccdc);
+   if (ccdc-underrun || !(ccdc-output  CCDC_OUTPUT_MEMORY)) {
+// ccdc_enable(ccdc);
+   }
 
ccdc-underrun = 0;
break;
diff --git a/drivers/media/platform/omap3isp/ispccdc.h 
b/drivers/media/platform/omap3isp/ispccdc.h
index a5da9e1..a502bc3 100644
--- a/drivers/media/platform/omap3isp/ispccdc.h
+++ b/drivers/media/platform/omap3isp/ispccdc.h
@@ -146,6 +146,7 @@ struct isp_ccdc_device {
struct ispccdc_lsc lsc;
unsigned int update;
unsigned int shadow_update;
+   unsigned int vdhden;
 
unsigned int underrun:1;
enum isp_pipeline_stream_state state;


-- 

Peter Meerwald
+43-664-218 (mobile)
--
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: Regression inside omap3isp/resizer

2014-01-17 Thread Florian Vaussard
Hi Laurent and Sakari,

On 01/17/2014 08:15 AM, Sakari Ailus wrote:
 Hi Laurent and Florian,
 
 Laurent Pinchart wrote:
 Hi Florian,

 On Thursday 09 January 2014 19:09:48 Florian Vaussard wrote:
 On 12/31/2013 09:51 AM, Laurent Pinchart wrote:
 Hi Florian,

 Sorry for the late reply.

 Now it is my turn to be late.

 On Monday 23 December 2013 22:47:45 Florian Vaussard wrote:
 On 12/17/2013 11:42 AM, Florian Vaussard wrote:
 Hello Laurent,

 I was working on having a functional IOMMU/ISP for 3.14, and had an
 issue with an image completely distorted. Comparing with another kernel,
 I saw that PRV_HORZ_INFO and PRV_VERT_INFO differed. On the newer
 kernel, sph, eph, svl, and slv were all off-by 2, causing my final image
 to miss 4 pixels on each line, thus distorting the result.

 Your commit 3fdfedaaa7f243f3347084231c64f6c1be0ba131 '[media] omap3isp:
 preview: Lower the crop margins' indeed changes PRV_HORZ_INFO and
 PRV_VERT_INFO by removing the if() condition. Reverting it made my image
 to be valid again.

 FYI, my pipeline is:

 MT9V032 (SGRBG10 752x480) - CCDC - PREVIEW (UYVY 752x480) - RESIZER
 - out

 Just an XMAS ping on this :-) Do you have any idea how to solve this
 without reverting the patch?

 The patch indeed changed the preview engine margins, but the change is
 supposed to be handled by applications. As a base for this discussion
 could you please provide the media-ctl -p output before and after applying
 the patch ? You can strip the unrelated media entities out of the output.

 Ok, so I understand the rationale behind this patch, but I am a bit
 concerned. If this patch requires a change in userspace, this is somehow
 breaking the userspace, isn't? For example in my case, I will have to
 change my initialization scripts in order to pass the correct resolution
 to the pipeline. Most people have probably hard-coded the resolution
 into their script / application.

 But they shouldn't have. This has never been considered as an ABI. Userspace 
 needs to computes and propagates resolutions through the pipeline 
 dynamically, 
 no hardcode them.

 If your initialization script read the kernel version and aborted for any 
 version other than v3.6, an upgrade to a newer kernel would break the system 
 but you wouldn't call it a kernel regression :-)

 Problems with pipeline configuration shouldn't result in distorted images 
 though. The driver is supposed to refuse to start streaming when the 
 pipeline 
 is misconfigured by making sure that resolutions on connected source and 
 sink 
 pads are identical. A valid pipeline should not distort the image.

 After a quick look at the code the problem we're dealing with seems to be 
 different and shouldn't affect userspace scripts if solved properly. I 
 haven't 
 touched the preview engine crop configuration code for some time now, so 
 I'll 
 need to refresh my memory, but it seems that the removal of

 -   if (format-code != V4L2_MBUS_FMT_Y8_1X8 
 -   format-code != V4L2_MBUS_FMT_Y10_1X10) {
 -   sph -= 2;
 -   eph += 2;
 -   slv -= 2;
 -   elv += 2;
 -   }

 was wrong. The change to the margins and to preview_try_crop() seem correct, 
 but the preview_config_input_size() function should probably have been kept 
 unmodified. Could you please test reverting that part of the patch only ?

 Sakari, if you have time, could you please have a look at the code and give 
 me 
 your opinion ?
 
 I reviewed the code mostly raw bayer - yuv in mind; that appeared
 correct to me. Now, reading the code again, I agree with you --- the
 four above variables are how much additional cropping is performed on
 hardware, and if the CFA is enabled, the cropping is implicit rather
 than explicit.
 
 It might have been cleaner to add cropping when pixels or lines need to
 be dropped rather than the other way around, but just adding the above
 lines back is probably the best way forward right now.
 
 The patch itself (excluding the bug) seems fine. Cropping extra pixels
 when it wasn't needed for a reason was worth fixing IMO.
 

I added the mentioned lines back, and it works fine again. The patch
below fixes the issue (sorry, probably corrupted by my mail client. I
can do a proper post if you are ok with it).

8---

Subject: [PATCH 1/1] [media] omap3isp: preview: Fix the crop margins

Commit 3fdfedaaa [media] omap3isp: preview: Lower the crop margins
accidentally changed the previewer's cropping, causing the previewer
to miss four pixels on each line, thus corrupting the final image.
Restored the removed setting.

Signed-off-by: Florian Vaussard florian.vauss...@epfl.ch
---
 drivers/media/platform/omap3isp/isppreview.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/platform/omap3isp/isppreview.c
b/drivers/media/platform/omap3isp/isppreview.c
index cd8831a..e2e4610 100644
--- 

Re: [PATCH 6/6] v4l: disable lockdep on vb2_fop_mmap()

2014-01-17 Thread Antti Palosaari

Hi Hans

On 17.01.2014 12:04, Hans Verkuil wrote:

Hi Antti,

Is this still needed after this commit was merged?

http://git.linuxtv.org/media_tree.git/commit/b18a8ff29d80b132018d33479e86ab8ecaee6b46


It didn't fix the problem.

I could reproduce that issue easily using vivi and Cheese (webcam app).

1) Compile Kernel with lockdep debug. For me these seems to be enabled:
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_LOCKDEP=y
CONFIG_DEBUG_LOCKDEP=y

2) Load virtual video driver (vivi)
# modprobe vivi

3) Start Cheese
$ cheese

Lockdep error appears to system log just after Cheese is started. I 
think it is related to mmap.


regards
Antti


tammi 17 17:07:38 localhost.localdomain kernel: media: Linux media 
interface: v0.10
tammi 17 17:07:38 localhost.localdomain kernel: Linux video capture 
interface: v2.00
tammi 17 17:07:38 localhost.localdomain kernel: vivi-000: V4L2 device 
registered as video0
tammi 17 17:07:38 localhost.localdomain kernel: Video Technology 
Magazine Virtual Video Capture Board ver 0.8.1 successfully loaded.
tammi 17 17:07:50 localhost.localdomain /etc/gdm/Xsession[1521]: Window 
manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a 
timestamp of 0 for 0x3200024 (Cheese)
tammi 17 17:07:50 localhost.localdomain /etc/gdm/Xsession[1521]: Window 
manager warning: meta_window_activate called by a pager with a 0 
timestamp; the pager needs to be fixed.
tammi 17 17:07:50 localhost.localdomain kernel: tammi 17 17:07:50 
localhost.localdomain kernel: 
==
tammi 17 17:07:50 localhost.localdomain kernel: [ INFO: possible 
circular locking dependency detected ]
tammi 17 17:07:50 localhost.localdomain kernel: 3.13.0-rc1+ #79 Tainted: 
G C O
tammi 17 17:07:50 localhost.localdomain kernel: 
---
tammi 17 17:07:50 localhost.localdomain kernel: video_source:sr/8871 is 
trying to acquire lock:
tammi 17 17:07:50 localhost.localdomain kernel: 
(dev-mutex#2){+.+.+.}, at: [a06a8df3] vb2_fop_mmap+0x33/0x90 
[videobuf2_core]

tammi 17 17:07:50 localhost.localdomain kernel:
but task is already 
holding lock:
tammi 17 17:07:50 localhost.localdomain kernel: 
(mm-mmap_sem){++}, at: [8117825f] vm_mmap_pgoff+0x6f/0xc0

tammi 17 17:07:50 localhost.localdomain kernel:
which lock already 
depends on the new lock.

tammi 17 17:07:50 localhost.localdomain kernel:
the existing dependency 
chain (in reverse order) is:

tammi 17 17:07:50 localhost.localdomain kernel:
- #1 
(mm-mmap_sem){++}:
tammi 17 17:07:50 localhost.localdomain kernel: 
[810bb386] __lock_acquire+0x3d6/0xc40
tammi 17 17:07:50 localhost.localdomain kernel: 
[810bbca0] lock_acquire+0xb0/0x150
tammi 17 17:07:50 localhost.localdomain kernel: 
[81181f3c] might_fault+0x8c/0xb0
tammi 17 17:07:50 localhost.localdomain kernel: 
[a067dc15] video_usercopy+0x375/0x5e0 [videodev]
tammi 17 17:07:50 localhost.localdomain kernel: 
[a067de95] video_ioctl2+0x15/0x20 [videodev]
tammi 17 17:07:50 localhost.localdomain kernel: 
[a0677703] v4l2_ioctl+0x123/0x160 [videodev]
tammi 17 17:07:50 localhost.localdomain kernel: 
[811e0590] do_vfs_ioctl+0x300/0x520
tammi 17 17:07:50 localhost.localdomain kernel: 
[811e0831] SyS_ioctl+0x81/0xa0
tammi 17 17:07:50 localhost.localdomain kernel: 
[816ca729] system_call_fastpath+0x16/0x1b

tammi 17 17:07:50 localhost.localdomain kernel:
- #0 
(dev-mutex#2){+.+.+.}:
tammi 17 17:07:50 localhost.localdomain kernel: 
[810b96b7] validate_chain.isra.36+0x10d7/0x1130
tammi 17 17:07:50 localhost.localdomain kernel: 
[810bb386] __lock_acquire+0x3d6/0xc40
tammi 17 17:07:50 localhost.localdomain kernel: 
[810bbca0] lock_acquire+0xb0/0x150
tammi 17 17:07:50 localhost.localdomain kernel: 
[816bf1c7] mutex_lock_interruptible_nested+0x77/0x460
tammi 17 17:07:50 localhost.localdomain kernel: 
[a06a8df3] vb2_fop_mmap+0x33/0x90 [videobuf2_core]
tammi 17 17:07:50 localhost.localdomain kernel: 
[a067711a] v4l2_mmap+0x5a/0xa0 [videodev]
tammi 17 17:07:50 localhost.localdomain kernel: 
[8118da7d] mmap_region+0x3cd/0x5a0
tammi 17 17:07:50 localhost.localdomain kernel: 
[8118dfa7] do_mmap_pgoff+0x357/0x3e0
tammi 17 17:07:50 localhost.localdomain kernel: 
[81178280] vm_mmap_pgoff+0x90/0xc0
tammi 17 17:07:50 localhost.localdomain kernel: 
[8118c553] SyS_mmap_pgoff+0x1d3/0x270
tammi 17 17:07:50 localhost.localdomain kernel: 
[810191a2] SyS_mmap+0x22/0x30
tammi 17 17:07:50 localhost.localdomain kernel: 
[816ca729] system_call_fastpath+0x16/0x1b

tammi 17 17:07:50 localhost.localdomain kernel:
  

Re: ov3640 sensor - CCDC won't become idle!

2014-01-17 Thread Tom
Peter Meerwald pmeerw at pmeerw.net writes:

Hello Peter,

Many thanks for posting your solution. Your idea sounds great and I'll give 
it a try on next monday.

Thanks again.

Best Regards, Tom



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


[PATCH] [media] hdpvr: Fix memory leak in debug

2014-01-17 Thread Masanari Iida
cppcheck reported memory leak in device_authorizatio()
within hdpvr-core.c.
When the debug option is specified and the code jump to
unlock: label, print_buf was not freed.
Confirm the module succesfully compiled without error.

Signed-off-by: Masanari Iida standby2...@gmail.com
---
 drivers/media/usb/hdpvr/hdpvr-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c 
b/drivers/media/usb/hdpvr/hdpvr-core.c
index 2f0c89c..c563896 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -198,7 +198,6 @@ static int device_authorization(struct hdpvr_device *dev)
hex_dump_to_buffer(response, 8, 16, 1, print_buf, 5*buf_size+1, 0);
v4l2_dbg(MSG_INFO, hdpvr_debug, dev-v4l2_dev,  response: %s\n,
 print_buf);
-   kfree(print_buf);
 #endif
 
msleep(100);
@@ -214,6 +213,9 @@ static int device_authorization(struct hdpvr_device *dev)
retval = ret != 8;
 unlock:
mutex_unlock(dev-usbc_mutex);
+#ifdef HDPVR_DEBUG
+   kfree(print_buf);
+#endif
return retval;
 }
 
-- 
1.8.5.2.309.ga25014b

--
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: [RFT PATCH] em28xx-audio: don't overwrite the usb alt setting made by the video part

2014-01-17 Thread Frank Schäfer

Am 16.01.2014 00:11, schrieb Mauro Carvalho Chehab:

Em Wed, 15 Jan 2014 22:36:25 +0100
Frank Schäferfschaefer@googlemail.com  escreveu:


Am 15.01.2014 22:31, schrieb Frank Schäfer:

em28xx-audio currently switches to usb alternate setting #7 in case of a mixed
interface. This may overwrite the setting made by the video part and break video
streaming.
As far as we know, there is no difference between the alt settings with regards
to the audio endpoint if the interface is a mixed interface, the audio part only
has to make sure that alt is  0, which is fortunately only the case when video
streaming is off.

Signed-off-by: Frank Schäferfschaefer@googlemail.com
---
  drivers/media/usb/em28xx/em28xx-audio.c |   41 ---
  1 Datei geändert, 16 Zeilen hinzugefügt(+), 25 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-audio.c 
b/drivers/media/usb/em28xx/em28xx-audio.c
index 05e9bd1..2e7a3ad 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -266,33 +266,30 @@ static int snd_em28xx_capture_open(struct 
snd_pcm_substream *substream)
dprintk(opening device and trying to acquire exclusive lock\n);
  
  	runtime-hw = snd_em28xx_hw_capture;

-   if ((dev-alt == 0 || dev-is_audio_only)  dev-adev.users == 0) {
-   int nonblock = !!(substream-f_flags  O_NONBLOCK);
  
+	if (dev-adev.users == 0) {

+   int nonblock = !!(substream-f_flags  O_NONBLOCK);
if (nonblock) {
if (!mutex_trylock(dev-lock))
return -EAGAIN;
} else
mutex_lock(dev-lock);
-   if (dev-is_audio_only)
-   /* vendor audio is on a separate interface */
+
+   /* Select initial alternate setting (if necessary) */
+   if (dev-alt == 0) {
dev-alt = 1;
-   else
-   /* vendor audio is on the same interface as video */
-   dev-alt = 7;
/*
-* FIXME: The intention seems to be to select the alt
-* setting with the largest wMaxPacketSize for the video
-* endpoint.
-* At least dev-alt should be used instead, but we
-* should probably not touch it at all if it is
-* already 0, because wMaxPacketSize of the audio
-* endpoints seems to be the same for all.
+* NOTE: in case of a mixed (audio+video) interface, we
+* don't want to touch the alt setting made by the video
+* part. There is no difference between the alt settings
+* with regards to the audio endpoint.
+* TODO: in case of a pure audio interface, this could
+* be improved. The alt settings are different here.
 */
-
-   dprintk(changing alternate number on interface %d to %d\n,
-   dev-ifnum, dev-alt);
-   usb_set_interface(dev-udev, dev-ifnum, dev-alt);
+   dprintk(changing alternate number on interface %d to 
%d\n,
+   dev-ifnum, dev-alt);
+   usb_set_interface(dev-udev, dev-ifnum, dev-alt);
+   }
  
  		/* Sets volume, mute, etc */

dev-mute = 0;
@@ -740,15 +737,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
struct usb_endpoint_descriptor *e, *ep = NULL;
int i, ep_size, interval, num_urb, npackets;
int urb_size, bytes_per_transfer;
-   u8 alt;
-
-   if (dev-ifnum)
-   alt = 1;
-   else
-   alt = 7;
+   u8 alt = 1;
  
  	intf = usb_ifnum_to_if(dev-udev, dev-ifnum);

-
if (intf-num_altsetting = alt) {
em28xx_errdev(alt %d doesn't exist on interface %d\n,
  dev-ifnum, alt);

Please note that this is actually just a minor fix.
What's really evil with the current alternate setting code is that the
video part may switch the alt setting while audio streaming is in progress.
I'm not sure how to fix this. Maybe we shouldn't start audio streaming
before video streaming.

This patch will very likely break em28xx audio. The change to use alt=7
was added there because em28xx can only deliver a certain number of URBs
per a given period of time. In other words, if the video-only calculated
alternate is used, when audio starts, the em28xx DMA engine half-fills
some video URBs.

In case of a mixed (audio+video) interface:
If the audio part changes the alt setting and starts streaming before 
the video part, it doesn't matter which alt setting is selected as long 
as it is  0.
If the video part changes the alt 

[PATCH 2/2] em28xx-audio: make sure audio is unmuted on open()

2014-01-17 Thread Frank Schäfer
Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-audio.c |   42 ---
 1 Datei geändert, 22 Zeilen hinzugefügt(+), 20 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-audio.c 
b/drivers/media/usb/em28xx/em28xx-audio.c
index dfdfa77..a3daf07 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -273,26 +273,28 @@ static int snd_em28xx_capture_open(struct 
snd_pcm_substream *substream)
mutex_lock(dev-lock);
 
runtime-hw = snd_em28xx_hw_capture;
-   if ((dev-alt == 0 || dev-is_audio_only)  dev-adev.users == 0) {
-   if (dev-is_audio_only)
-   /* vendor audio is on a separate interface */
-   dev-alt = 1;
-   else
-   /* vendor audio is on the same interface as video */
-   dev-alt = 7;
-   /*
-* FIXME: The intention seems to be to select the alt
-* setting with the largest wMaxPacketSize for the video
-* endpoint.
-* At least dev-alt should be used instead, but we
-* should probably not touch it at all if it is
-* already 0, because wMaxPacketSize of the audio
-* endpoints seems to be the same for all.
-*/
-
-   dprintk(changing alternate number on interface %d to %d\n,
-   dev-ifnum, dev-alt);
-   usb_set_interface(dev-udev, dev-ifnum, dev-alt);
+
+   if (dev-adev.users == 0) {
+   if (dev-alt == 0 || dev-is_audio_only) {
+   if (dev-is_audio_only)
+   /* audio is on a separate interface */
+   dev-alt = 1;
+   else
+   /* audio is on the same interface as video */
+   dev-alt = 7;
+   /*
+* FIXME: The intention seems to be to select
+* the alt setting with the largest
+* wMaxPacketSize for the video endpoint.
+* At least dev-alt should be used instead, but
+* we should probably not touch it at all if it
+* is already 0, because wMaxPacketSize of the
+* audio endpoints seems to be the same for all.
+*/
+   dprintk(changing alternate number on interface %d to 
%d\n,
+   dev-ifnum, dev-alt);
+   usb_set_interface(dev-udev, dev-ifnum, dev-alt);
+   }
 
/* Sets volume, mute, etc */
dev-mute = 0;
-- 
1.7.10.4

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


[PATCH 1/2] em28xx-audio: fix user counting in snd_em28xx_capture_open()

2014-01-17 Thread Frank Schäfer
dev-adev.users always needs to be increased when snd_em28xx_capture_open() is
called and succeeds.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-audio.c |   22 +++---
 1 Datei geändert, 11 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-audio.c 
b/drivers/media/usb/em28xx/em28xx-audio.c
index 05e9bd1..dfdfa77 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -252,7 +252,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream 
*substream)
 {
struct em28xx *dev = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream-runtime;
-   int ret = 0;
+   int nonblock, ret = 0;
 
if (!dev) {
em28xx_err(BUG: em28xx can't find device struct.
@@ -265,15 +265,15 @@ static int snd_em28xx_capture_open(struct 
snd_pcm_substream *substream)
 
dprintk(opening device and trying to acquire exclusive lock\n);
 
+   nonblock = !!(substream-f_flags  O_NONBLOCK);
+   if (nonblock) {
+   if (!mutex_trylock(dev-lock))
+   return -EAGAIN;
+   } else
+   mutex_lock(dev-lock);
+
runtime-hw = snd_em28xx_hw_capture;
if ((dev-alt == 0 || dev-is_audio_only)  dev-adev.users == 0) {
-   int nonblock = !!(substream-f_flags  O_NONBLOCK);
-
-   if (nonblock) {
-   if (!mutex_trylock(dev-lock))
-   return -EAGAIN;
-   } else
-   mutex_lock(dev-lock);
if (dev-is_audio_only)
/* vendor audio is on a separate interface */
dev-alt = 1;
@@ -299,11 +299,11 @@ static int snd_em28xx_capture_open(struct 
snd_pcm_substream *substream)
ret = em28xx_audio_analog_set(dev);
if (ret  0)
goto err;
-
-   dev-adev.users++;
-   mutex_unlock(dev-lock);
}
 
+   dev-adev.users++;
+   mutex_unlock(dev-lock);
+
/* Dynamically adjust the period size */
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
-- 
1.7.10.4

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


[PATCH 2/3] em28xx-camera: fix return value checks on sensor probing

2014-01-17 Thread Frank Schäfer
Since commit e63b009d6e the returned error code in case of not 
connected/responding
i2c clients is ENXIO isntead of ENODEV, which causes several error messages on
sensor probing.
Fix the i2c return value checks on sensor probing to silence these warnings.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-camera.c |4 ++--
 1 Datei geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index c29f5c4..505e050 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -120,7 +120,7 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
reg = 0x00;
ret = i2c_master_send(client, reg, 1);
if (ret  0) {
-   if (ret != -ENODEV)
+   if (ret != -ENXIO)
em28xx_errdev(couldn't read from i2c device 
0x%02x: error %i\n,
  client.addr  1, ret);
continue;
@@ -218,7 +218,7 @@ static int em28xx_probe_sensor_omnivision(struct em28xx 
*dev)
reg = 0x1c;
ret = i2c_smbus_read_byte_data(client, reg);
if (ret  0) {
-   if (ret != -ENODEV)
+   if (ret != -ENXIO)
em28xx_errdev(couldn't read from i2c device 
0x%02x: error %i\n,
  client.addr  1, ret);
continue;
-- 
1.7.10.4

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


[PATCH 3/3] em28xx-v4l: do not call em28xx_init_camera() if the device has no sensor

2014-01-17 Thread Frank Schäfer
This avoids the unnecessary temporary registration of a dummy V4L2 clock.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-video.c |3 ++-
 1 Datei geändert, 2 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 09e18da..2775c90 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -2273,7 +2273,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
}
 
em28xx_tuner_setup(dev);
-   em28xx_init_camera(dev);
+   if (dev-em28xx_sensor != EM28XX_NOSENSOR)
+   em28xx_init_camera(dev);
 
/* Configure audio */
ret = em28xx_audio_setup(dev);
-- 
1.7.10.4

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


[PATCH 1/3] em28xx-video: do not unregister the v4l2 dummy clock before v4l2_device_unregister() has been called

2014-01-17 Thread Frank Schäfer
Otherwiese the core refuses to unregister the clock and the following warning
appears in the system log:

WARNING: ... at drivers/media/v4l2-core/v4l2-clk.c:231 
v4l2_clk_unregister+0x8a/0x90 [videodev]()
 v4l2_clk_unregister(): Refusing to unregister ref-counted 11-0030:mclk clock!

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-video.c |6 +++---
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index c3c9289..09e18da 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1918,14 +1918,14 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
video_unregister_device(dev-vdev);
}
 
+   v4l2_ctrl_handler_free(dev-ctrl_handler);
+   v4l2_device_unregister(dev-v4l2_dev);
+
if (dev-clk) {
v4l2_clk_unregister_fixed(dev-clk);
dev-clk = NULL;
}
 
-   v4l2_ctrl_handler_free(dev-ctrl_handler);
-   v4l2_device_unregister(dev-v4l2_dev);
-
if (dev-users)
em28xx_warn(Device is open ! Memory deallocation is deferred 
on last close.\n);
mutex_unlock(dev-lock);
-- 
1.7.10.4

--
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: Regression inside omap3isp/resizer

2014-01-17 Thread Laurent Pinchart
Hi Florian,

On Friday 17 January 2014 15:45:12 Florian Vaussard wrote:
 On 01/17/2014 08:15 AM, Sakari Ailus wrote:
  Laurent Pinchart wrote:
  On Thursday 09 January 2014 19:09:48 Florian Vaussard wrote:
  On 12/31/2013 09:51 AM, Laurent Pinchart wrote:
  On Monday 23 December 2013 22:47:45 Florian Vaussard wrote:
  On 12/17/2013 11:42 AM, Florian Vaussard wrote:
  Hello Laurent,
  
  I was working on having a functional IOMMU/ISP for 3.14, and had an
  issue with an image completely distorted. Comparing with another
  kernel, I saw that PRV_HORZ_INFO and PRV_VERT_INFO differed. On the
  newer kernel, sph, eph, svl, and slv were all off-by 2, causing my
  final image to miss 4 pixels on each line, thus distorting the
  result.
  
  Your commit 3fdfedaaa7f243f3347084231c64f6c1be0ba131 '[media]
  omap3isp: preview: Lower the crop margins' indeed changes
  PRV_HORZ_INFO and PRV_VERT_INFO by removing the if() condition.
  Reverting it made my image to be valid again.
  
  FYI, my pipeline is:
  
  MT9V032 (SGRBG10 752x480) - CCDC - PREVIEW (UYVY 752x480) -
  RESIZER
  - out
  
  Just an XMAS ping on this :-) Do you have any idea how to solve this
  without reverting the patch?
  
  The patch indeed changed the preview engine margins, but the change is
  supposed to be handled by applications. As a base for this discussion
  could you please provide the media-ctl -p output before and after
  applying the patch ? You can strip the unrelated media entities out of
  the output.
  
  Ok, so I understand the rationale behind this patch, but I am a bit
  concerned. If this patch requires a change in userspace, this is somehow
  breaking the userspace, isn't? For example in my case, I will have to
  change my initialization scripts in order to pass the correct resolution
  to the pipeline. Most people have probably hard-coded the resolution
  into their script / application.
  
  But they shouldn't have. This has never been considered as an ABI.
  Userspace needs to computes and propagates resolutions through the
  pipeline dynamically, no hardcode them.
  
  If your initialization script read the kernel version and aborted for any
  version other than v3.6, an upgrade to a newer kernel would break the
  system but you wouldn't call it a kernel regression :-)
  
  Problems with pipeline configuration shouldn't result in distorted images
  though. The driver is supposed to refuse to start streaming when the
  pipeline is misconfigured by making sure that resolutions on connected
  source and sink pads are identical. A valid pipeline should not distort
  the image.
  
  After a quick look at the code the problem we're dealing with seems to be
  different and shouldn't affect userspace scripts if solved properly. I
  haven't touched the preview engine crop configuration code for some time
  now, so I'll need to refresh my memory, but it seems that the removal of
  
  -   if (format-code != V4L2_MBUS_FMT_Y8_1X8 
  -   format-code != V4L2_MBUS_FMT_Y10_1X10) {
  -   sph -= 2;
  -   eph += 2;
  -   slv -= 2;
  -   elv += 2;
  -   }
  
  was wrong. The change to the margins and to preview_try_crop() seem
  correct, but the preview_config_input_size() function should probably
  have been kept unmodified. Could you please test reverting that part of
  the patch only ?
  
  Sakari, if you have time, could you please have a look at the code and
  give me your opinion ?
  
  I reviewed the code mostly raw bayer - yuv in mind; that appeared
  correct to me. Now, reading the code again, I agree with you --- the
  four above variables are how much additional cropping is performed on
  hardware, and if the CFA is enabled, the cropping is implicit rather
  than explicit.
  
  It might have been cleaner to add cropping when pixels or lines need to
  be dropped rather than the other way around, but just adding the above
  lines back is probably the best way forward right now.
  
  The patch itself (excluding the bug) seems fine. Cropping extra pixels
  when it wasn't needed for a reason was worth fixing IMO.
 
 I added the mentioned lines back, and it works fine again. The patch
 below fixes the issue (sorry, probably corrupted by my mail client. I
 can do a proper post if you are ok with it).
 
 8---
 
 Subject: [PATCH 1/1] [media] omap3isp: preview: Fix the crop margins
 
 Commit 3fdfedaaa [media] omap3isp: preview: Lower the crop margins
 accidentally changed the previewer's cropping, causing the previewer
 to miss four pixels on each line, thus corrupting the final image.
 Restored the removed setting.
 
 Signed-off-by: Florian Vaussard florian.vauss...@epfl.ch

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

Could you please submit an uncorrupted patch ?

 ---
  drivers/media/platform/omap3isp/isppreview.c | 9 +
  1 file changed, 9 insertions(+)
 
 diff --git 

Re: dvb-usb-dib0700-1.20.fw Issues.

2014-01-17 Thread Ray Image
I have tried this now on Debian 32 and 64 bit versions with no joy.
The sticks are fine as they work on Windows 7 perfectly. Any advice?

On 15 January 2014 20:02, Ray Image imagemagi...@gmail.com wrote:
 I have tried a couple of USB sticks which use the
 dvb-usb-dib0700-1.20.fw firmware in a number of machines running
 different linux distros (CentOS, Debian and Raspbian) and I simply
 can't get them to work. I have put dvb-usb-dib0700-1.20.fw in
 /lib/firmware. Both USB sticks are recognised and loaded (see dmesg
 below) but won't tune. I have a PCTV 290e which works perfectly.

 Can anyone please help?

 Dmesg for Nova-T (this device fails):
 [  850.170729] usb 1-2: Product: Nova-T Stick
 [  850.170730] usb 1-2: Manufacturer: Hauppauge
 [  850.170731] usb 1-2: SerialNumber: 4027796501
 [  850.181622] dvb-usb: found a 'Hauppauge Nova-T Stick' in cold
 state, will try to load a firmware
 [  850.185487] usb 1-2: firmware: agent loaded dvb-usb-dib0700-1.20.fw
 into memory
 [  853.291628] dib0700: firmware started successfully.
 [  853.794138] dvb-usb: found a 'Hauppauge Nova-T Stick' in warm state.
 [  853.794255] dvb-usb: will pass the complete MPEG2 transport stream
 to the software demuxer.
 [  853.795277] DVB: registering new adapter (Hauppauge Nova-T Stick)
 [  854.350077] DVB: registering adapter 1 frontend 0 (DiBcom 7000PC)...
 [  854.359052] MT2060: successfully identified (IF1 = 1220)
 [  854.999066] dvb-usb: Hauppauge Nova-T Stick successfully
 initialized and connected.

 Dmesg for MyTV.t (this device fails):
 [  505.753256] usb 1-1: Product: myTV.t
 [  505.753257] usb 1-1: Manufacturer: Eskape Labs
 [  505.753258] usb 1-1: SerialNumber: 4030928317
 [  505.861413] dib0700: loaded with support for 21 different device-types
 [  510.853328] dvb-usb: found a 'Hauppauge Nova-T MyTV.t' in cold
 state, will try to load a firmware
 [  510.924679] usb 1-1: firmware: agent loaded dvb-usb-dib0700-1.20.fw
 into memory
 [  514.327591] dib0700: firmware started successfully.
 [  514.830712] dvb-usb: found a 'Hauppauge Nova-T MyTV.t' in warm state.
 [  514.830796] dvb-usb: will pass the complete MPEG2 transport stream
 to the software demuxer.
 [  514.832785] DVB: registering new adapter (Hauppauge Nova-T MyTV.t)
 [  515.335819] DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)...
 [  515.789061] DiB0070: successfully identified
 [  515.789065] dvb-usb: Hauppauge Nova-T MyTV.t successfully
 initialized and connected.
 [  515.790175] usbcore: registered new interface driver dvb_usb_dib0700

 Dmesg for PCTV290e (this device works):
 [  314.918928] em28xx: New device PCTV Systems PCTV 290e @ 480 Mbps
 (2013:024f, interface 0, class 0)
 [  314.920018] em28xx #0: chip ID is em28174
 [  315.251613] em28xx #0: Identified as PCTV nanoStick T2 290e (card=78)
 [  315.331134] Registered IR keymap rc-pinnacle-pctv-hd
 [  315.331262] input: em28xx IR (em28xx #0) as
 /devices/pci:00/:00:11.0/:02:03.0/usb1/1-1/rc/rc0/input6
 [  315.331726] rc0: em28xx IR (em28xx #0) as
 /devices/pci:00/:00:11.0/:02:03.0/usb1/1-1/rc/rc0
 [  315.338297] em28xx #0: v4l2 driver version 0.1.3
 [  315.408548] em28xx #0: V4L2 video device registered as video0
 [  315.408572] usbcore: registered new interface driver em28xx
 [  315.408573] em28xx driver loaded
 [  315.510762] tda18271 0-0060: creating new instance
 [  315.540382] TDA18271HD/C2 detected @ 0-0060
 [  316.283833] tda18271 0-0060: attaching existing instance
 [  316.283836] DVB: registering new adapter (em28xx #0)
 [  316.283838] DVB: registering adapter 0 frontend 0 (Sony CXD2820R
 (DVB-T/T2))...
 [  316.284044] DVB: registering adapter 0 frontend 1 (Sony CXD2820R 
 (DVB-C))...
 [  316.284947] em28xx #0: Successfully loaded em28xx-dvb
 [  316.284950] Em28xx: Initialized (Em28xx dvb Extension) extension

 Output of scan for Nova-T and MyTV.t:
 scanning /usr/share/dvb/dvb-t/uk-Hannington
 using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
 initial transponder 70600 0 3 9 1 0 0 0
 initial transponder 650167000 0 2 9 3 0 0 0
 initial transponder 626167000 0 2 9 3 0 0 0
 initial transponder 674167000 0 3 9 1 0 0 0
 initial transponder 658167000 0 3 9 1 0 0 0
 initial transponder 634167000 0 3 9 1 0 0 0
 tune to: 
 70600:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
 WARNING:  tuning failed!!!
 tune to: 
 70600:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
  (tuning failed)
 WARNING:  tuning failed!!!
 tune to: 
 650167000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
 WARNING:  tuning failed!!!
 tune to: 
 650167000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
  (tuning failed)
 WARNING:  tuning failed!!!
 tune to: 
 

[PATCH] [media] omap3isp: preview: Fix the crop margins

2014-01-17 Thread Florian Vaussard
Commit 3fdfedaaa [media] omap3isp: preview: Lower the crop margins
accidentally changed the previewer's cropping, causing the previewer
to miss four pixels on each line, thus corrupting the final image.
Restored the removed setting.

Signed-off-by: Florian Vaussard florian.vauss...@epfl.ch
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/platform/omap3isp/isppreview.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/platform/omap3isp/isppreview.c 
b/drivers/media/platform/omap3isp/isppreview.c
index cd8831a..e2e4610 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -1079,6 +1079,7 @@ static void preview_config_input_format(struct 
isp_prev_device *prev,
  */
 static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
 {
+   const struct v4l2_mbus_framefmt *format = prev-formats[PREV_PAD_SINK];
struct isp_device *isp = to_isp_device(prev);
unsigned int sph = prev-crop.left;
unsigned int eph = prev-crop.left + prev-crop.width - 1;
@@ -1086,6 +1087,14 @@ static void preview_config_input_size(struct 
isp_prev_device *prev, u32 active)
unsigned int elv = prev-crop.top + prev-crop.height - 1;
u32 features;
 
+   if (format-code != V4L2_MBUS_FMT_Y8_1X8 
+   format-code != V4L2_MBUS_FMT_Y10_1X10) {
+   sph -= 2;
+   eph += 2;
+   slv -= 2;
+   elv += 2;
+   }
+
features = (prev-params.params[0].features  active)
 | (prev-params.params[1].features  ~active);
 
-- 
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


cron job: media_tree daily build: WARNINGS

2014-01-17 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 Jan 18 04:00:22 CET 2014
git branch: test
git hash:   587d1b06e07b4a079453c74ba9edf17d21931049
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-6.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: WARNINGS
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.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: OK
linux-3.12-i686: OK
linux-3.13-rc1-i686: OK
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: OK
linux-3.12-x86_64: OK
linux-3.13-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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