[GIT PATCHES FOR 2.6.36] gspca for_2.6.36

2010-07-29 Thread Jean-Francois Moine
The following changes since commit
906903f4c56f8dd74584a44d93d96df25d228786:

  V4L/DVB: gspca - vc032x: Move the first VC0321 settings to sd_init() 
(2010-07-25 17:16:25 -0300)

are available in the git repository at:
  git://linuxtv.org/jfrancois/gspca.git for_2.6.36

Jean-François Moine (14):
  gspca - sonixj / sq930x / t613: Remove unused variable in struct sd.
  gspca - main: Version change.
  gspca - sq930x: Bad init sequence for sensor mt9v111.
  gspca - sq930x: Change the gain value for Micron sensors.
  gspca - sq930x: Change the default values of gain and exposure.
  gspca - sq930x: Change image format to Bayer mode.
  gspca - sq930x: Change the horizontal blanking of sensor mt9v111.
  gspca - sq930x: Cleanup source, add comments..
  gspca - vc032x: Add more controls for po.
  gspca - vc032x: Do sensor probe at resume time.
  gspca - zc3xx: Cleanup source.
  gspca - zc3xx: Check the USB exchanges.
  gspca - vc032x: Force main register write at probe time (po).
  gspca - main: Fix a crash in gspca_frame_add().

 drivers/media/video/gspca/gspca.c  |   21 +-
 drivers/media/video/gspca/sonixj.c |   10 +-
 drivers/media/video/gspca/sq930x.c |  347 +-
 drivers/media/video/gspca/t613.c   |4 +-
 drivers/media/video/gspca/vc032x.c |  360 ++
 drivers/media/video/gspca/zc3xx.c  |  592 +++-
 6 files changed, 711 insertions(+), 623 deletions(-)

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
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 5/9] IR: extend interfaces to support more device settings

2010-07-29 Thread Christoph Bartelmus
Hi!

Maxim Levitsky maximlevit...@gmail.com wrote:

 Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE
 (LIRC_SET_LEARN_MODE will start carrier reports if possible, and
 tune receiver to wide band mode)

I don't like the rename of the ioctl. The ioctl should enable carrier
reports. Anything else is hardware specific. Learn mode gives a somewhat
wrong association to me. irrecord always has been using learn mode
without ever using this ioctl.

Christoph
--
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: kein Betreff

2010-07-29 Thread Christoph Bartelmus
Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]
 In addition to comments, I changed helper function that processes samples
 so it sends last space as soon as timeout is reached.
 This breaks somewhat lirc, because now it gets 2 spaces in row.
 However, if it uses timeout reports (which are now fully supported)
 it will get such report in middle.

 Note that I send timeout report with zero value.
 I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace  
and 2 spaces in a row will break decoding.

Christoph
--
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] V4L: fix a comment in a driver

2010-07-29 Thread Guennadi Liakhovetski
RJ54N1CB0C is a Sharp camera sensor.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/video/rj54n1cb0c.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/rj54n1cb0c.c b/drivers/media/video/rj54n1cb0c.c
index bbd9c11..6457d5a 100644
--- a/drivers/media/video/rj54n1cb0c.c
+++ b/drivers/media/video/rj54n1cb0c.c
@@ -1,5 +1,5 @@
 /*
- * Driver for RJ54N1CB0C CMOS Image Sensor from Micron
+ * Driver for RJ54N1CB0C CMOS Image Sensor from Sharp
  *
  * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
  *
-- 
1.7.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] V4L2: sh_vou: VOU does support the full PAL resolution too

2010-07-29 Thread Guennadi Liakhovetski
SH7724 datasheet specifies 480 pixels as the VOU maximum vertical resolution.
This is a bug in the datasheet, VOU also supports the full PAL resolution: 576
lines. Adjust the driver accordingly.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/video/sh_vou.c |   56 +
 1 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/sh_vou.c b/drivers/media/video/sh_vou.c
index e9d5e6a..80351db 100644
--- a/drivers/media/video/sh_vou.c
+++ b/drivers/media/video/sh_vou.c
@@ -57,7 +57,7 @@ enum sh_vou_status {
 };
 
 #define VOU_MAX_IMAGE_WIDTH720
-#define VOU_MAX_IMAGE_HEIGHT   480
+#define VOU_MAX_IMAGE_HEIGHT   576
 
 struct sh_vou_device {
struct v4l2_device v4l2_dev;
@@ -527,20 +527,17 @@ struct sh_vou_geometry {
 static void vou_adjust_input(struct sh_vou_geometry *geo, v4l2_std_id std)
 {
/* The compiler cannot know, that best and idx will indeed be set */
-   unsigned int best_err = UINT_MAX, best = 0, width_max, height_max;
+   unsigned int best_err = UINT_MAX, best = 0, img_height_max;
int i, idx = 0;
 
-   if (std  V4L2_STD_525_60) {
-   width_max = 858;
-   height_max = 262;
-   } else {
-   width_max = 864;
-   height_max = 312;
-   }
+   if (std  V4L2_STD_525_60)
+   img_height_max = 480;
+   else
+   img_height_max = 576;
 
/* Image width must be a multiple of 4 */
v4l_bound_align_image(geo-in_width, 0, VOU_MAX_IMAGE_WIDTH, 2,
- geo-in_height, 0, VOU_MAX_IMAGE_HEIGHT, 1, 0);
+ geo-in_height, 0, img_height_max, 1, 0);
 
/* Select scales to come as close as possible to the output image */
for (i = ARRAY_SIZE(vou_scale_h_num) - 1; i = 0; i--) {
@@ -573,7 +570,7 @@ static void vou_adjust_input(struct sh_vou_geometry *geo, 
v4l2_std_id std)
unsigned int found = geo-output.height * vou_scale_v_den[i] /
vou_scale_v_num[i];
 
-   if (found  VOU_MAX_IMAGE_HEIGHT)
+   if (found  img_height_max)
/* scales increase */
break;
 
@@ -597,15 +594,18 @@ static void vou_adjust_input(struct sh_vou_geometry *geo, 
v4l2_std_id std)
  */
 static void vou_adjust_output(struct sh_vou_geometry *geo, v4l2_std_id std)
 {
-   unsigned int best_err = UINT_MAX, best, width_max, height_max;
+   unsigned int best_err = UINT_MAX, best, width_max, height_max,
+   img_height_max;
int i, idx;
 
if (std  V4L2_STD_525_60) {
width_max = 858;
height_max = 262 * 2;
+   img_height_max = 480;
} else {
width_max = 864;
height_max = 312 * 2;
+   img_height_max = 576;
}
 
/* Select scales to come as close as possible to the output image */
@@ -644,7 +644,7 @@ static void vou_adjust_output(struct sh_vou_geometry *geo, 
v4l2_std_id std)
unsigned int found = geo-in_height * vou_scale_v_num[i] /
vou_scale_v_den[i];
 
-   if (found  VOU_MAX_IMAGE_HEIGHT)
+   if (found  img_height_max)
/* scales increase */
break;
 
@@ -673,6 +673,7 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
struct video_device *vdev = video_devdata(file);
struct sh_vou_device *vou_dev = video_get_drvdata(vdev);
struct v4l2_pix_format *pix = fmt-fmt.pix;
+   unsigned int img_height_max;
int pix_idx;
struct sh_vou_geometry geo;
struct v4l2_mbus_framefmt mbfmt = {
@@ -701,9 +702,14 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
if (pix_idx == ARRAY_SIZE(vou_fmt))
return -EINVAL;
 
+   if (vou_dev-std  V4L2_STD_525_60)
+   img_height_max = 480;
+   else
+   img_height_max = 576;
+
/* Image width must be a multiple of 4 */
v4l_bound_align_image(pix-width, 0, VOU_MAX_IMAGE_WIDTH, 2,
- pix-height, 0, VOU_MAX_IMAGE_HEIGHT, 1, 0);
+ pix-height, 0, img_height_max, 1, 0);
 
geo.in_width = pix-width;
geo.in_height = pix-height;
@@ -724,7 +730,7 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
 
/* Sanity checks */
if ((unsigned)mbfmt.width  VOU_MAX_IMAGE_WIDTH ||
-   (unsigned)mbfmt.height  VOU_MAX_IMAGE_HEIGHT ||
+   (unsigned)mbfmt.height  img_height_max ||
mbfmt.code != V4L2_MBUS_FMT_YUYV8_2X8)
return -EIO;
 
@@ -940,6 +946,7 @@ static int sh_vou_s_crop(struct file *file, void *fh, 
struct v4l2_crop *a)
.field = V4L2_FIELD_INTERLACED,
.colorspace = V4L2_COLORSPACE_SMPTE170M,
   

gspca_zc3xx module

2010-07-29 Thread Hasan SAHIN

 Hello Jean-Francois,

I am using Gentoo linux stable x86 with kernel 2.6.34-r1.
before the kernel update to 2.6.34-r1, I was using 2.6.32-r7 and there 
was no problem with webcam.
The webcam was working as good with kernel 2.6.32-r7(old gentoo stable 
kernel)
but right now it does not work with the kernel 2.6.34-r1 (new gentoo 
stable kernel)


And also I have tried with ubuntu 10.04 (kernel 2.6.32-25) and working 
good. I could not understood what is the problem. (Problem is : there is 
no output, no stream)


All test has been done with wxcam,cheese and your svv.c program.

Could you please help me?

Thanks and regards,
Hasan.

lsusb :
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 0ac8:303b Z-Star Microelectronics Corp. ZC0303 Webcam
Bus 001 Device 002: ID 04b3:310c IBM Corp. Wheel Mouse
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

lsmod
gspca_zc3xx34720  0
gspca_main 17677  1 gspca_zc3xx
videodev   27331  1 gspca_main
usbcore92279  7 
gspca_zc3xx,gspca_main,usbhid,usbmouse,ehci_hcd,ohci_hcd



this is the kernel message when I remove and re-plug the webcam :

dmesg | tail -30
gspca: isoc irq
gspca: found int in endpoint: 0x82, buffer_len=8, interval=10
gspca: stream off OK
gspca: [svv] close
gspca: frame free
gspca: close done
usb 1-8: USB disconnect, address 5
gspca: video0 disconnect
gspca: video0 released
usb 1-8: new full speed USB device using ohci_hcd and address 6
usb 1-8: New USB device found, idVendor=0ac8, idProduct=303b
usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-8: Product: PC Camera
usb 1-8: Manufacturer: Vimicro Corp.
gspca: probing 0ac8:303b
zc3xx: probe 2wr ov vga 0x
zc3xx: probe 3wr vga 1 0xc001
zc3xx: probe sensor - 0013
zc3xx: Find Sensor MI0360SOC. Chip revision c001
input: zc3xx as /devices/pci:00/:00:02.0/usb1/1-8/input/input7
gspca: video0 created
gspca: found int in endpoint: 0x82, buffer_len=8, interval=10
gspca: [v4l_id] open
gspca: open done
gspca: [v4l_id] close
gspca: close done
gspca: [hald-probe-vide] open
gspca: open done
gspca: [hald-probe-vide] close
gspca: close done





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


[PULL] soc-camera, sh-vou, v4l2 for 2.6.36

2010-07-29 Thread Guennadi Liakhovetski
Hi Mauro

The following changes since commit c57fd88318988f17731e446fe1d8498f506fdd44:

  V4L/DVB: uvcvideo: Add support for Manta MM-353 Plako (2010-07-05 19:47:16 
-0300)

are available in the git repository at:
  git://linuxtv.org/gliakhovetski/v4l-dvb.git for-2.6.36

Guennadi Liakhovetski (8):
  mediabus: fix ambiguous pixel code names
  V4L2: avoid name conflicts in macros
  V4L2: mediabus: add 12-bit Bayer and YUV420 pixel formats
  V4L2: soc-camera: export soc-camera bus type for notifications
  V4L2: soc-camera: add a MIPI CSI-2 driver for SH-Mobile platforms
  V4L2: sh_mobile_camera_ceu: add support for CSI2
  V4L2: sh_vou: VOU does support the full PAL resolution too
  V4L: fix a comment in a driver

 arch/sh/boards/mach-ap325rxa/setup.c   |2 +-
 drivers/media/video/Kconfig|6 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/ak881x.c   |6 +-
 drivers/media/video/mt9m111.c  |   16 +-
 drivers/media/video/mt9t112.c  |   12 +-
 drivers/media/video/ov772x.c   |8 +-
 drivers/media/video/ov9640.c   |   14 +-
 drivers/media/video/pxa_camera.c   |8 +-
 drivers/media/video/rj54n1cb0c.c   |   10 +-
 drivers/media/video/sh_mobile_ceu_camera.c |  147 ++--
 drivers/media/video/sh_mobile_csi2.c   |  354 
 drivers/media/video/sh_vou.c   |   64 +++--
 drivers/media/video/soc_camera.c   |3 +-
 drivers/media/video/soc_mediabus.c |8 +-
 drivers/media/video/tw9910.c   |8 +-
 include/media/sh_mobile_ceu.h  |3 +
 include/media/sh_mobile_csi2.h |   46 
 include/media/soc_camera.h |3 +
 include/media/v4l2-device.h|   22 +-
 include/media/v4l2-mediabus.h  |   13 +-
 21 files changed, 643 insertions(+), 111 deletions(-)
 create mode 100644 drivers/media/video/sh_mobile_csi2.c
 create mode 100644 include/media/sh_mobile_csi2.h

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


dvb-apps maintainer

2010-07-29 Thread Tomer Barletz
Does anybody know  who's dvb-apps current maintainer?

Thanks,
Tomer
--
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


signaling and / or clarification

2010-07-29 Thread Michele
from your Wiki:
http://linuxtv.org/wiki/index.php/DVB-T_USB_Devices#TwinhanDTV_Twister_.287049.29_DVB-T
In germany a similar device seems to be sold as dnt EuroMini200 [127].


But at http://skinflint.co.uk/a193550.html;
write that Euromin 200 is compatible with linux.

I have a Digitune-S that they say is equal to Euromin 200, then
solution is to use this device with my Linux?

Ciao
Michele Freschi



--
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: Can I expect in-kernel decoding to work out of box?

2010-07-29 Thread Jon Smirl
On Wed, Jul 28, 2010 at 10:36 PM, Andy Walls awa...@md.metrocast.net wrote:
 As an example of simple hardware glitch filter, here's an excerpt
 from the public CX25480/1/2/3 datasheet on the IR low-pass (glitch)
 filter that's in the hardware:

 the counter reloads using the value programmed to this register each
 time a qualified edge is detected [...]. Once the reload occurs, the
 counter begins decrementing. If the next programmed edge occurs before
 the counter reaches 0, the pulse measurement value is discarded, the
 filter modulus value is reloaded, and the next pulse measurement begins.
 Thus, any pulse measurement that ends before the counter reaches 0 is
 ignored.

You could make a small library that drivers could link in. That way we
won't get it implemented ten different ways. Devices that do the
filtering in firmware won't have to use the code.

There are lots of ways to design it. A simple one would be to sit on
each message until the next one arrives. Then make a decision to pass
the previous message up or declare the current edge a glitch and wait
for the next one.  It probably needs a timeout so that you don't sit
on long pulses forever waiting on the next one.

-- 
Jon Smirl
jonsm...@gmail.com
--
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] Fix possible memory leak in dvbca.c

2010-07-29 Thread Manu Abraham
On Tue, Jul 27, 2010 at 6:28 PM, Tomer Barletz barl...@gmail.com wrote:
 2010/7/25 Tomer Barletz barl...@gmail.com:
 Allocated memory will never get free when read fails.
 See attached patch.

 Tomer


 Attached a better patch... :)


Ok, thanks. Will apply.

Regards,
Manu
--
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: linux-next: Tree for July 28 (lirc #2)

2010-07-29 Thread Janne Grunau
On Thu, Jul 29, 2010 at 12:27:01AM -0400, Jarod Wilson wrote:
 On Wed, Jul 28, 2010 at 6:27 PM, Jarod Wilson ja...@wilsonet.com wrote:
  On Wed, Jul 28, 2010 at 6:16 PM, Randy Dunlap randy.dun...@oracle.com 
  wrote:
  On 07/28/10 15:04, Janne Grunau wrote:
  On Wed, Jul 28, 2010 at 10:24:17AM -0700, Randy Dunlap wrote:
  On Wed, 28 Jul 2010 16:28:55 +1000 Stephen Rothwell wrote:
 
  Hi all,
 
  Changes since 20100727:
 
 
  When USB_SUPPORT is not enabled and MEDIA_SUPPORT is not enabled:
 
 
  following patch should fix it
 
  Janne
 
  Acked-by: Randy Dunlap randy.dun...@oracle.com
 
  Thanks.
 
  Acked-by: Jarod Wilson ja...@redhat.com
 
  Indeed, thanks much, Janne!
 
 D'oh, I should have looked a bit closer... What if instead of making
 all the drivers depend on both LIRC  LIRC_STAGING, LIRC_STAGING just
 depends on LIRC?

I started adding LIRC to each driver by one. Adding LIRC as LIRC_STAGING
dependency is simpler. See updated patch.

 And there are a few depends lines with duplicate
 USB's in them and LIRC_IMON should have USB added to it (technically,

D'oh, I've must have stopped reading after LIRC_STAG...

fixed and added additional dependencies

Janne


From 45d384de90e3709a986700db14888eff77bb7e1f Mon Sep 17 00:00:00 2001
From: Janne Grunau j...@jannau.net
Date: Wed, 28 Jul 2010 23:53:35 +0200
Subject: [PATCH 1/2] V4L/DVB: staging/lirc: fix Kconfig dependencies

Signed-off-by: Janne Grunau j...@jannau.net
---
 drivers/staging/lirc/Kconfig |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lirc/Kconfig b/drivers/staging/lirc/Kconfig
index 968c2ade..ab30a09 100644
--- a/drivers/staging/lirc/Kconfig
+++ b/drivers/staging/lirc/Kconfig
@@ -3,6 +3,7 @@
 #
 menuconfig LIRC_STAGING
bool Linux Infrared Remote Control IR receiver/transmitter drivers
+   depends on LIRC
help
  Say Y here, and all supported Linux Infrared Remote Control IR and
  RF receiver and transmitter drivers will be displayed. When paired
@@ -13,13 +14,13 @@ if LIRC_STAGING
 
 config LIRC_BT829
 tristate BT829 based hardware
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  PCI
help
  Driver for the IR interface on BT829-based hardware
 
 config LIRC_ENE0100
tristate ENE KB3924/ENE0100 CIR Port Reciever
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  PNP
help
  This is a driver for CIR port handled by ENE KB3924 embedded
  controller found on some notebooks.
@@ -27,7 +28,7 @@ config LIRC_ENE0100
 
 config LIRC_I2C
tristate I2C Based IR Receivers
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  I2C
help
  Driver for I2C-based IR receivers, such as those commonly
  found onboard Hauppauge PVR-150/250/350 video capture cards
@@ -40,7 +41,7 @@ config LIRC_IGORPLUGUSB
 
 config LIRC_IMON
tristate Legacy SoundGraph iMON Receiver and Display
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  USB
help
  Driver for the original SoundGraph iMON IR Receiver and Display
 
@@ -48,7 +49,7 @@ config LIRC_IMON
 
 config LIRC_IT87
tristate ITE IT87XX CIR Port Receiver
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  PNP
help
  Driver for the ITE IT87xx IR Receiver
 
@@ -60,13 +61,13 @@ config LIRC_ITE8709
 
 config LIRC_PARALLEL
tristate Homebrew Parallel Port Receiver
-   depends on LIRC_STAGING  !SMP
+   depends on LIRC_STAGING  PARPORT  !SMP
help
  Driver for Homebrew Parallel Port Receivers
 
 config LIRC_SASEM
tristate Sasem USB IR Remote
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  USB
help
  Driver for the Sasem OnAir Remocon-V or Dign HV5 HTPC IR/VFD Module
 
@@ -91,7 +92,7 @@ config LIRC_SIR
 
 config LIRC_STREAMZAP
tristate Streamzap PC Receiver
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  USB
help
  Driver for the Streamzap PC Receiver
 
@@ -103,7 +104,7 @@ config LIRC_TTUSBIR
 
 config LIRC_ZILOG
tristate Zilog/Hauppauge IR Transmitter
-   depends on LIRC_STAGING
+   depends on LIRC_STAGING  I2C
help
  Driver for the Zilog/Hauppauge IR Transmitter, found on
  PVR-150/500, HVR-1200/1250/1700/1800, HD-PVR and other cards
-- 
1.7.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 v2]videobuf_dma_sg: a new implementation for mmap

2010-07-29 Thread Figo.zhang
hi Laurent,
would you like to test this patch?

btw, why i send the patch , patchwork websit display a part of my patch?
https://patchwork.kernel.org/patch/114760/

Best,
Figo.zhang

On Wed, 2010-07-28 at 21:08 +0800, Figo.zhang wrote:
 a mmap issue for videobuf-dma-sg: it will alloc a new page for mmaping
 when it encounter page fault at video_vm_ops-fault().
 
 a new implementation for mmap, it translate the vmalloc to page at
 video_vm_ops-fault().
 
 in v2, if mem-dma.vmalloc is NULL at video_vm_ops-fault(), it will
 alloc memory by vmalloc_32().
 
 Signed-off-by: Figo.zhang figo1...@gmail.com
 ---
 drivers/media/video/videobuf-dma-sg.c |   51
 +++--
  1 files changed, 42 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/media/video/videobuf-dma-sg.c
 b/drivers/media/video/videobuf-dma-sg.c
 index 8359e6b..767483d 100644
 --- a/drivers/media/video/videobuf-dma-sg.c
 +++ b/drivers/media/video/videobuf-dma-sg.c
 @@ -201,10 +201,11 @@ int videobuf_dma_init_kernel(struct
 videobuf_dmabuf *dma, int direction,
   dprintk(1, init kernel [%d pages]\n, nr_pages);
  
   dma-direction = direction;
 - dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
 - if (NULL == dma-vmalloc) {
 - dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
 - return -ENOMEM;
 + if (!dma-vmalloc)
 + dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
 + if (NULL == dma-vmalloc) {
 + dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
 + return -ENOMEM;
   }
  
   dprintk(1, vmalloc is at addr 0x%08lx, size=%d\n,
 @@ -397,16 +398,48 @@ static void videobuf_vm_close(struct
 vm_area_struct *vma)
   */
  static int videobuf_vm_fault(struct vm_area_struct *vma, struct
 vm_fault *vmf)
  {
 - struct page *page;
 + struct page *page = NULL;
 + struct videobuf_mapping *map = vma-vm_private_data;
 + struct videobuf_queue *q = map-q;
 + struct videobuf_dma_sg_memory *mem = NULL;
 +
 + unsigned long offset;
 + unsigned long page_nr;
 + int first;
  
   dprintk(3, fault: fault @ %08lx [vma %08lx-%08lx]\n,
   (unsigned long)vmf-virtual_address,
   vma-vm_start, vma-vm_end);
  
 - page = alloc_page(GFP_USER | __GFP_DMA32);
 - if (!page)
 - return VM_FAULT_OOM;
 - clear_user_highpage(page, (unsigned long)vmf-virtual_address);
 + mutex_lock(q-vb_lock);
 +
 + offset = (unsigned long)vmf-virtual_address - vma-vm_start;
 + page_nr = offset  PAGE_SHIFT;
 +
 + for (first = 0; first  VIDEO_MAX_FRAME; first++) {
 + if (NULL == q-bufs[first])
 + continue;
 +
 + MAGIC_CHECK(mem-magic, MAGIC_SG_MEM);
 +
 + if (q-bufs[first]-map == map)
 + break;
 + }
 +
 + mem = q-bufs[first]-priv;
 + if (!mem)
 + return VM_FAULT_SIGBUS;
 + if (!mem-dma.vmalloc) {
 + mem-dma.vmalloc = vmalloc_32(PAGE_ALIGN(q-bufs[first]-size));
 + if (NULL == mem-dma.vmalloc) {
 + dprintk(1, %s: vmalloc_32() failed\n, __func__);
 + return VM_FAULT_OOM;
 + }
 + } else
 + page = vmalloc_to_page(mem-dma.vmalloc+
 + (offset  (~PAGE_MASK)));
 + mutex_unlock(q-vb_lock);
 +
   vmf-page = page;
  
   return 0;
 


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


[PATCH 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote: 
 Hi Maxim,
 
 on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
 [...]
  In addition to comments, I changed helper function that processes samples
  so it sends last space as soon as timeout is reached.
  This breaks somewhat lirc, because now it gets 2 spaces in row.
  However, if it uses timeout reports (which are now fully supported)
  it will get such report in middle.
 
  Note that I send timeout report with zero value.
  I don't think that this value is importaint.
 
 This does not sound good. Of course the value is important to userspace  
 and 2 spaces in a row will break decoding.
 
 Christoph

Could you explain exactly how timeout reports work?

Lirc interface isn't set to stone, so how about a reasonable compromise.
After reasonable long period of inactivity (200 ms for example), space
is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I
could rip of the logic that deals with remembering the time?

Best regards,
Maxim Levitsky

--
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: linux-next: Tree for July 28 (lirc #2)

2010-07-29 Thread Jarod Wilson
On Thu, Jul 29, 2010 at 8:39 AM, Janne Grunau j...@jannau.net wrote:
 On Thu, Jul 29, 2010 at 12:27:01AM -0400, Jarod Wilson wrote:
 On Wed, Jul 28, 2010 at 6:27 PM, Jarod Wilson ja...@wilsonet.com wrote:
  On Wed, Jul 28, 2010 at 6:16 PM, Randy Dunlap randy.dun...@oracle.com 
  wrote:
  On 07/28/10 15:04, Janne Grunau wrote:
  On Wed, Jul 28, 2010 at 10:24:17AM -0700, Randy Dunlap wrote:
  On Wed, 28 Jul 2010 16:28:55 +1000 Stephen Rothwell wrote:
 
  Hi all,
 
  Changes since 20100727:
 
 
  When USB_SUPPORT is not enabled and MEDIA_SUPPORT is not enabled:
 
 
  following patch should fix it
 
  Janne
 
  Acked-by: Randy Dunlap randy.dun...@oracle.com
 
  Thanks.
 
  Acked-by: Jarod Wilson ja...@redhat.com
 
  Indeed, thanks much, Janne!

 D'oh, I should have looked a bit closer... What if instead of making
 all the drivers depend on both LIRC  LIRC_STAGING, LIRC_STAGING just
 depends on LIRC?

 I started adding LIRC to each driver by one. Adding LIRC as LIRC_STAGING
 dependency is simpler. See updated patch.

 And there are a few depends lines with duplicate
 USB's in them and LIRC_IMON should have USB added to it (technically,

 D'oh, I've must have stopped reading after LIRC_STAG...

 fixed and added additional dependencies

Yeah, that looks better, thanks! (And this time I looked more carefully).

Acked-by: Jarod Wilson ja...@redhat.com

-- 
Jarod Wilson
ja...@wilsonet.com
--
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 5/9] IR: extend interfaces to support more device settings

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 09:25 +0200, Christoph Bartelmus wrote: 
 Hi!
 
 Maxim Levitsky maximlevit...@gmail.com wrote:
 
  Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE
  (LIRC_SET_LEARN_MODE will start carrier reports if possible, and
  tune receiver to wide band mode)
 
 I don't like the rename of the ioctl. The ioctl should enable carrier
 reports. Anything else is hardware specific. Learn mode gives a somewhat
 wrong association to me. irrecord always has been using learn mode
 without ever using this ioctl.

Why?

Carrier measure (if supported by hardware I think should always be
enabled, because it can help in-kernel decoders).
(Which raises seperate question on how to do so. I guess I will need to
make ir_raw_event 64 bit after all...)


Another thing is reporting these results to lirc.
By default lirc shouldn't get carrier reports, but as soon as irrecord
starts, it can place device in special mode that allows it to capture
input better, and optionally do carrier reports.

Do you think carrier reports are needed by lircd?

Best regards,
Maxim Levitsky

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Wed, 2010-07-28 at 23:52 -0400, Jarod Wilson wrote: 
 On Thu, Jul 29, 2010 at 02:40:43AM +0300, Maxim Levitsky wrote:
  Hi,
  This is second version of the patchset.
  Hopefully, I didn't forget to address all comments.
  
  In addition to comments, I changed helper function that processes samples
  so it sends last space as soon as timeout is reached.
  This breaks somewhat lirc, because now it gets 2 spaces in row.
  However, if it uses timeout reports (which are now fully supported)
  it will get such report in middle.
  
  Note that I send timeout report with zero value.
  I don't think that this value is importaint.
 
 I just patched the entire series into a branch here and tested, no
 regressions with an mceusb transceiver with in-kernel decode, lirc decode
 or lirc tx. Only issue I had (which I neglected to mention earlier) was
 some pedantic issues w/whitespace. Here's the tree I built and tested:
 
 http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/maxim
 
 7486d6ae3 addresses all the whitespace/formatting issues I had. Could
 either merge that into your patches, or I can just send it along as an
 additional patch after the fact. In either case, for 1-7 v2:
About whitespace, I usually fix what checkpacth.pl tells me.
Nothing beyond that :-)


 
 Tested-by: Jarod Wilson ja...@redhat.com
 
 I have no ene hardware to actually test with, but it did build. :)
 
 For 1-9 v2:
 
 Acked-by: Jarod Wilson ja...@redhat.com
 

Best regards,
Maxim Levitsky

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Jarod Wilson
On Thu, Jul 29, 2010 at 06:30:28PM +0300, Maxim Levitsky wrote:
 On Wed, 2010-07-28 at 23:52 -0400, Jarod Wilson wrote: 
  On Thu, Jul 29, 2010 at 02:40:43AM +0300, Maxim Levitsky wrote:
   Hi,
   This is second version of the patchset.
   Hopefully, I didn't forget to address all comments.
   
   In addition to comments, I changed helper function that processes samples
   so it sends last space as soon as timeout is reached.
   This breaks somewhat lirc, because now it gets 2 spaces in row.
   However, if it uses timeout reports (which are now fully supported)
   it will get such report in middle.
   
   Note that I send timeout report with zero value.
   I don't think that this value is importaint.
  
  I just patched the entire series into a branch here and tested, no
  regressions with an mceusb transceiver with in-kernel decode, lirc decode
  or lirc tx. Only issue I had (which I neglected to mention earlier) was
  some pedantic issues w/whitespace. Here's the tree I built and tested:
  
  http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/maxim
  
  7486d6ae3 addresses all the whitespace/formatting issues I had. Could
  either merge that into your patches, or I can just send it along as an
  additional patch after the fact. In either case, for 1-7 v2:
 About whitespace, I usually fix what checkpacth.pl tells me.
 Nothing beyond that :-)

Yeah, I don't think any of them violate checkpatch.pl's rules, they were
more for consistency with the rest of the code being patched.

-- 
Jarod Wilson
ja...@redhat.com

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Andy Walls
On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote: 
  Hi Maxim,
  
  on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
  [...]
   In addition to comments, I changed helper function that processes samples
   so it sends last space as soon as timeout is reached.
   This breaks somewhat lirc, because now it gets 2 spaces in row.
   However, if it uses timeout reports (which are now fully supported)
   it will get such report in middle.
  
   Note that I send timeout report with zero value.
   I don't think that this value is importaint.
  
  This does not sound good. Of course the value is important to userspace  
  and 2 spaces in a row will break decoding.
  
  Christoph
 
 Could you explain exactly how timeout reports work?
 
 Lirc interface isn't set to stone, so how about a reasonable compromise.
 After reasonable long period of inactivity (200 ms for example), space
 is sent, and then next report starts with a pulse.
 So gaps between keypresses will be maximum of 200 ms, and as a bonus I
 could rip of the logic that deals with remembering the time?
 
 Best regards,
 Maxim Levitsky

Just for some context, the Conexant hardware generates such reports on
it's hardware Rx FIFO:

From section 3.8.2.3 of 

http://dl.ivtvdriver.org/datasheets/video/cx25840.pdf

When the demodulated input signal no longer transitions, the RX pulse
width timer overflows, which indicates the end of data transmission.
When this occurs, the timer value contains all 1s. This value can be
stored to the RX FIFO, to indicate the end of the transmission [...].
Additionally, a status bit is set which can interrupt the
microprocessor, [...].

So the value in the hardware RX FIFO is the maximum time measurable
given the current hardware clock divider settings, plus a flag bit
indicating overflow.

The CX2388[58] IR implementation currently translates that hardware
notification into V4L2_SUBDEV_IR_PULSE_RX_SEQ_END:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx23885/cx23888-ir.c;h=51f21636e639330bcf528568c0f08c7a4a674f42;hb=094fc94360cf01960da3311698fedfca566d4712#l678

which is defined here:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=include/media/v4l2-subdev.h;h=bacd52568ef9fd17787554aa347f46ca6f23bdb2;hb=094fc94360cf01960da3311698fedfca566d4712#l366

as

#define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0x


I didn't look too hard at it, but IIRC the in kernel decoders would have
interpreted this value incorrectly (the longest possible mark).
Instead, I just pass along the longest possible space:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx23885/cx23885-input.c;h=3f924e21b9575f7d67d99d71c8585d41828aabfe;hb=094fc94360cf01960da3311698fedfca566d4712#l49

so it acts as in band signaling if anyone is looking for it, and the in
kernel decoders happily treat it like a long space.

With a little work, I could pass the actual time it took for the Rx
timer to timeout as well (Provide the space measurement *and* the in
band signal), if needed.


Regards,
Andy

--
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] staging/lirc: fix non-CONFIG_MODULES build horkage

2010-07-29 Thread Jarod Wilson
Fix when CONFIG_MODULES is not enabled:

drivers/staging/lirc/lirc_parallel.c:243: error: implicit declaration of 
function 'module_refcount'
drivers/staging/lirc/lirc_it87.c:150: error: implicit declaration of function 
'module_refcount'
drivers/built-in.o: In function `it87_probe':
lirc_it87.c:(.text+0x4079b0): undefined reference to `init_chrdev'
lirc_it87.c:(.text+0x4079cc): undefined reference to `drop_chrdev'
drivers/built-in.o: In function `lirc_it87_exit':
lirc_it87.c:(.exit.text+0x38a5): undefined reference to `drop_chrdev'

Its a quick hack and untested beyond building, since I don't have the
hardware, but it should do the trick.

Signed-off-by: Jarod Wilson ja...@redhat.com
---
 drivers/staging/lirc/lirc_it87.c |9 ++---
 drivers/staging/lirc/lirc_parallel.c |4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c
index 781abc3..72f07f1 100644
--- a/drivers/staging/lirc/lirc_it87.c
+++ b/drivers/staging/lirc/lirc_it87.c
@@ -109,6 +109,7 @@ static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue);
 
 static DEFINE_SPINLOCK(hardware_lock);
 static DEFINE_SPINLOCK(dev_lock);
+static bool device_open;
 
 static int rx_buf[RBUF_LEN];
 unsigned int rx_tail, rx_head;
@@ -147,10 +148,11 @@ static void drop_port(void);
 static int lirc_open(struct inode *inode, struct file *file)
 {
spin_lock(dev_lock);
-   if (module_refcount(THIS_MODULE)) {
+   if (device_open) {
spin_unlock(dev_lock);
return -EBUSY;
}
+   device_open = true;
spin_unlock(dev_lock);
return 0;
 }
@@ -158,6 +160,9 @@ static int lirc_open(struct inode *inode, struct file *file)
 
 static int lirc_close(struct inode *inode, struct file *file)
 {
+   spin_lock(dev_lock);
+   device_open = false;
+   spin_unlock(dev_lock);
return 0;
 }
 
@@ -363,7 +368,6 @@ static struct lirc_driver driver = {
 };
 
 
-#ifdef MODULE
 static int init_chrdev(void)
 {
driver.minor = lirc_register_driver(driver);
@@ -380,7 +384,6 @@ static void drop_chrdev(void)
 {
lirc_unregister_driver(driver.minor);
 }
-#endif
 
 
 /* SECTION: Hardware */
diff --git a/drivers/staging/lirc/lirc_parallel.c 
b/drivers/staging/lirc/lirc_parallel.c
index df12e7b..04ce97713 100644
--- a/drivers/staging/lirc/lirc_parallel.c
+++ b/drivers/staging/lirc/lirc_parallel.c
@@ -240,7 +240,7 @@ static void irq_handler(void *blah)
unsigned int level, newlevel;
unsigned int timeout;
 
-   if (!module_refcount(THIS_MODULE))
+   if (!is_open)
return;
 
if (!is_claimed)
@@ -515,7 +515,7 @@ static long lirc_ioctl(struct file *filep, unsigned int 
cmd, unsigned long arg)
 
 static int lirc_open(struct inode *node, struct file *filep)
 {
-   if (module_refcount(THIS_MODULE) || !lirc_claim())
+   if (is_open || !lirc_claim())
return -EBUSY;
 
parport_enable_irq(pport);


-- 
Jarod Wilson
ja...@redhat.com

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


[RFC/PATCH v3 00/10] Media controller (core and V4L2)

2010-07-29 Thread Laurent Pinchart
Hi everybody,

Here's the third version of the media controller patches. All comments received
on the first and second versions have (hopefully) been incorporated.

The rebased V4L2 API additions and OMAP3 ISP patches will follow. Once again
please consider them as sample code only.

Laurent Pinchart (8):
  media: Media device node support
  media: Media device
  media: Entities, pads and links
  media: Entities, pads and links enumeration
  media: Links setup
  v4l: Add a media_device pointer to the v4l2_device structure
  v4l: Make video_device inherit from media_entity
  v4l: Make v4l2_subdev inherit from media_entity

Sakari Ailus (2):
  media: Entity graph traversal
  media: Reference count and power handling

 Documentation/media-framework.txt|  481 
 Documentation/video4linux/v4l2-framework.txt |   71 +++-
 drivers/media/Makefile   |8 +-
 drivers/media/media-device.c |  327 ++
 drivers/media/media-devnode.c|  326 ++
 drivers/media/media-entity.c |  613 ++
 drivers/media/video/v4l2-dev.c   |   35 ++-
 drivers/media/video/v4l2-device.c|   45 ++-
 drivers/media/video/v4l2-subdev.c|   27 ++-
 include/linux/media.h|   78 
 include/media/media-device.h |   70 +++
 include/media/media-devnode.h|   84 
 include/media/media-entity.h |  107 +
 include/media/v4l2-dev.h |6 +
 include/media/v4l2-device.h  |2 +
 include/media/v4l2-subdev.h  |7 +
 16 files changed, 2265 insertions(+), 22 deletions(-)
 create mode 100644 Documentation/media-framework.txt
 create mode 100644 drivers/media/media-device.c
 create mode 100644 drivers/media/media-devnode.c
 create mode 100644 drivers/media/media-entity.c
 create mode 100644 include/linux/media.h
 create mode 100644 include/media/media-device.h
 create mode 100644 include/media/media-devnode.h
 create mode 100644 include/media/media-entity.h

-- 
Regards,

Laurent Pinchart

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


[RFC/PATCH v3 01/10] media: Media device node support

2010-07-29 Thread Laurent Pinchart
The media_devnode structure provides support for registering and
unregistering character devices using a dynamic major number. Reference
counting is handled internally, making device drivers easier to write
without having to solve the open/disconnect race condition issue over
and over again.

The code is based on video/v4l2-dev.c.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/Makefile|8 +-
 drivers/media/media-devnode.c |  326 +
 include/media/media-devnode.h |   84 +++
 3 files changed, 416 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/media-devnode.c
 create mode 100644 include/media/media-devnode.h

diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 499b081..c1b5938 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,7 +2,11 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
+media-objs := media-devnode.o
+
+obj-$(CONFIG_MEDIA_SUPPORT)+= media.o
+
 obj-y += common/ IR/ video/
 
-obj-$(CONFIG_VIDEO_DEV) += radio/
-obj-$(CONFIG_DVB_CORE)  += dvb/
+obj-$(CONFIG_VIDEO_DEV)+= radio/
+obj-$(CONFIG_DVB_CORE) += dvb/
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
new file mode 100644
index 000..6f5558c
--- /dev/null
+++ b/drivers/media/media-devnode.c
@@ -0,0 +1,326 @@
+/*
+ * Media device node
+ *
+ * Generic media device node infrastructure to register and unregister
+ * character devices using a dynamic major number and proper reference
+ * counting.
+ *
+ * Copyright 2010 Laurent Pinchart laurent.pinch...@ideasonboard.com
+ *
+ * Based on drivers/media/video/v4l2_dev.c code authored by
+ *
+ * Mauro Carvalho Chehab mche...@infradead.org (version 2)
+ * Alan Cox, a...@lxorguk.ukuu.org.uk (version 1)
+ *
+ * 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; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include linux/errno.h
+#include linux/init.h
+#include linux/module.h
+#include linux/kernel.h
+#include linux/kmod.h
+#include linux/slab.h
+#include linux/mm.h
+#include linux/smp_lock.h
+#include linux/string.h
+#include linux/types.h
+#include linux/uaccess.h
+#include asm/system.h
+
+#include media/media-devnode.h
+
+#define MEDIA_NUM_DEVICES  256
+#define MEDIA_NAME media
+
+static dev_t media_dev_t;
+
+/*
+ * sysfs stuff
+ */
+
+static ssize_t show_name(struct device *cd,
+struct device_attribute *attr, char *buf)
+{
+   struct media_devnode *mdev = to_media_devnode(cd);
+
+   return sprintf(buf, %.*s\n, (int)sizeof(mdev-name), mdev-name);
+}
+
+static struct device_attribute media_devnode_attrs[] = {
+   __ATTR(name, S_IRUGO, show_name, NULL),
+   __ATTR_NULL
+};
+
+/*
+ * Active devices
+ */
+static DEFINE_MUTEX(media_devnode_lock);
+static DECLARE_BITMAP(media_devnode_nums, MEDIA_NUM_DEVICES);
+
+/* Called when the last user of the media device exits. */
+static void media_devnode_release(struct device *cd)
+{
+   struct media_devnode *mdev = to_media_devnode(cd);
+
+   mutex_lock(media_devnode_lock);
+
+   /* Delete the cdev on this minor as well */
+   cdev_del(mdev-cdev);
+
+   /* Mark device node number as free */
+   clear_bit(mdev-minor, media_devnode_nums);
+
+   mutex_unlock(media_devnode_lock);
+
+   /* Release media_devnode and perform other cleanups as needed. */
+   if (mdev-release)
+   mdev-release(mdev);
+}
+
+static struct class media_class = {
+   .name = MEDIA_NAME,
+   .dev_attrs = media_devnode_attrs,
+};
+
+static ssize_t media_read(struct file *filp, char __user *buf,
+   size_t sz, loff_t *off)
+{
+   struct media_devnode *mdev = media_devnode_data(filp);
+
+   if (!mdev-fops-read)
+   return -EINVAL;
+   if (!media_devnode_is_registered(mdev))
+   return -EIO;
+   return mdev-fops-read(filp, buf, sz, off);
+}
+
+static ssize_t media_write(struct file *filp, const char __user *buf,
+   size_t sz, loff_t *off)
+{
+   struct media_devnode *mdev = media_devnode_data(filp);
+
+   if (!mdev-fops-write)
+   return -EINVAL;
+   if (!media_devnode_is_registered(mdev))
+   return -EIO;
+   return mdev-fops-write(filp, buf, sz, off);
+}
+
+static unsigned int media_poll(struct file *filp,
+  struct poll_table_struct *poll)
+{
+   struct media_devnode *mdev = media_devnode_data(filp);
+
+   if (!mdev-fops-poll || !media_devnode_is_registered(mdev))
+   return DEFAULT_POLLMASK;
+   return mdev-fops-poll(filp, poll);
+}
+
+static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+   struct 

[RFC/PATCH v3 03/10] media: Entities, pads and links

2010-07-29 Thread Laurent Pinchart
As video hardware pipelines become increasingly complex and
configurable, the current hardware description through v4l2 subdevices
reaches its limits. In addition to enumerating and configuring
subdevices, video camera drivers need a way to discover and modify at
runtime how those subdevices are connected. This is done through new
elements called entities, pads and links.

An entity is a basic media hardware building block. It can correspond to
a large variety of logical blocks such as physical hardware devices
(CMOS sensor for instance), logical hardware devices (a building block
in a System-on-Chip image processing pipeline), DMA channels or physical
connectors.

A pad is a connection endpoint through which an entity can interact with
other entities. Data (not restricted to video) produced by an entity
flows from the entity's output to one or more entity inputs. Pads should
not be confused with physical pins at chip boundaries.

A link is a point-to-point oriented connection between two pads, either
on the same entity or on different entities. Data flows from a source
pad to a sink pad.

Links are stored in the source entity. To make backwards graph walk
faster, a copy of all links is also stored in the sink entity. The copy
is known as a backlink and is only used to help graph traversal.

The entity API is made of three functions:

- media_entity_init() initializes an entity. The caller must provide an
array of pads as well as an estimated number of links. The links array
is allocated dynamically and will be reallocated if it grows beyond the
initial estimate.

- media_entity_cleanup() frees resources allocated for an entity. It
must be called during the cleanup phase after unregistering the entity
and before freeing it.

- media_entity_create_link() creates a link between two entities. An
entry in the link array of each entity is allocated and stores pointers
to source and sink pads.

When a media device is unregistered, all its entities are unregistered
automatically.

The code is based on Hans Verkuil hverk...@xs4all.nl initial work.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 Documentation/media-framework.txt |  130 +
 drivers/media/Makefile|2 +-
 drivers/media/media-device.c  |   53 ++
 drivers/media/media-entity.c  |  144 +
 include/media/media-device.h  |   16 
 include/media/media-entity.h  |   85 ++
 6 files changed, 429 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/media-entity.c
 create mode 100644 include/media/media-entity.h

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index b942c8f..5bd7216 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -35,6 +35,30 @@ belong to userspace.
 The media kernel API aims at solving those problems.
 
 
+Abstract media device model
+---
+
+Discovering a device internal topology, and configuring it at runtime, is one
+of the goals of the media framework. To achieve this, hardware devices are
+modeled as an oriented graph of building blocks called entities connected
+through pads.
+
+An entity is a basic media hardware building block. It can correspond to
+a large variety of logical blocks such as physical hardware devices
+(CMOS sensor for instance), logical hardware devices (a building block
+in a System-on-Chip image processing pipeline), DMA channels or physical
+connectors.
+
+A pad is a connection endpoint through which an entity can interact with
+other entities. Data (not restricted to video) produced by an entity
+flows from the entity's output to one or more entity inputs. Pads should
+not be confused with physical pins at chip boundaries.
+
+A link is a point-to-point oriented connection between two pads, either
+on the same entity or on different entities. Data flows from a source
+pad to a sink pad.
+
+
 Media device
 
 
@@ -66,3 +90,109 @@ Drivers unregister media device instances by calling
 
 Unregistering a media device that hasn't been registered is *NOT* safe.
 
+
+Entities, pads and links
+
+
+- Entities
+
+Entities are represented by a struct media_entity instance, defined in
+include/media/media-entity.h. The structure is usually embedded into a
+higher-level structure, such as a v4l2_subdev or video_device instance,
+although drivers can allocate entities directly.
+
+Drivers initialize entities by calling
+
+   media_entity_init(struct media_entity *entity, u8 num_pads,
+ struct media_pad *pads, u8 extra_links);
+
+The media_entity name and type fields can be initialized before or after
+calling media_entity_init. Entities embedded in higher-level standard
+structures have those fields set by the higher-level framework.
+
+As 

[RFC/PATCH v3 04/10] media: Entity graph traversal

2010-07-29 Thread Laurent Pinchart
From: Sakari Ailus sakari.ai...@maxwell.research.nokia.com

Add media entity graph traversal. The traversal follows active links by
depth first. Traversing graph backwards is prevented by comparing the next
possible entity in the graph with the previous one. Multiply connected
graphs are thus not supported.

Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Vimarsh Zutshi vimarsh.zut...@nokia.com
---
 Documentation/media-framework.txt |   40 +
 drivers/media/media-entity.c  |  115 +
 include/media/media-entity.h  |   15 +
 3 files changed, 170 insertions(+), 0 deletions(-)

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index 5bd7216..4fe3b32 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -196,3 +196,43 @@ Links have flags that describe the link capabilities and 
state.
MEDIA_LINK_FLAG_ACTIVE must also be set since an immutable link is
always active.
 
+
+Graph traversal
+---
+
+The media framework provides APIs to iterate over entities in a graph.
+
+To iterate over all entities belonging to a media device, drivers can use the
+media_device_for_each_entity macro, defined in include/media/media-device.h.
+
+   struct media_entity *entity;
+
+   media_device_for_each_entity(entity, mdev) {
+   /* entity will point to each entity in turn */
+   ...
+   }
+
+Drivers might also need to iterate over all entities in a graph that can be
+reached only through active links starting at a given entity. The media
+framework provides a depth-first graph traversal API for that purpose.
+
+Note that graphs with cycles (whether directed or undirected) are *NOT*
+supported by the graph traversal API.
+
+Drivers initiate a graph traversal by calling
+
+   media_entity_graph_walk_start(struct media_entity_graph *graph,
+ struct media_entity *entity);
+
+The graph structure, provided by the caller, is initialized to start graph
+traversal at the given entity.
+
+Drivers can then retrieve the next entity by calling
+
+   media_entity_graph_walk_next(struct media_entity_graph *graph);
+
+When the graph traversal is complete the function will return NULL.
+
+Graph traversal can be interrupted at any moment. No cleanup function call is
+required and the graph structure can be freed normally.
+
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index a2f9ad9..443c5c9 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -81,6 +81,121 @@ media_entity_cleanup(struct media_entity *entity)
 }
 EXPORT_SYMBOL(media_entity_cleanup);
 
+/* 
-
+ * Graph traversal
+ */
+
+static struct media_entity *
+media_entity_other(struct media_entity *entity, struct media_link *link)
+{
+   if (link-source-entity == entity)
+   return link-sink-entity;
+   else
+   return link-source-entity;
+}
+
+/* push an entity to traversal stack */
+static void stack_push(struct media_entity_graph *graph,
+  struct media_entity *entity)
+{
+   if (graph-top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) {
+   WARN_ON(1);
+   return;
+   }
+   graph-top++;
+   graph-stack[graph-top].link = 0;
+   graph-stack[graph-top].entity = entity;
+}
+
+static struct media_entity *stack_pop(struct media_entity_graph *graph)
+{
+   struct media_entity *entity;
+
+   entity = graph-stack[graph-top].entity;
+   graph-top--;
+
+   return entity;
+}
+
+#define stack_peek(en) ((en)-stack[(en)-top - 1].entity)
+#define link_top(en)   ((en)-stack[(en)-top].link)
+#define stack_top(en)  ((en)-stack[(en)-top].entity)
+
+/**
+ * media_entity_graph_walk_start - Start walking the media graph at a given 
entity
+ * @graph: Media graph structure that will be used to walk the graph
+ * @entity: Starting entity
+ *
+ * This function initializes the graph traversal structure to walk the entities
+ * graph starting at the given entity. The traversal structure must not be
+ * modified by the caller during graph traversal. When done the structure can
+ * safely be freed.
+ */
+void media_entity_graph_walk_start(struct media_entity_graph *graph,
+  struct media_entity *entity)
+{
+   graph-top = 0;
+   graph-stack[graph-top].entity = NULL;
+   stack_push(graph, entity);
+}
+EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
+
+/**
+ * media_entity_graph_walk_next - Get the next entity in the graph
+ * @graph: Media graph structure
+ *
+ * Perform a depth-first traversal of the given media entities graph.
+ *
+ * The graph structure must have been previously initialized with a call to
+ * 

[RFC/PATCH v3 05/10] media: Reference count and power handling

2010-07-29 Thread Laurent Pinchart
From: Sakari Ailus sakari.ai...@maxwell.research.nokia.com

Basically these are the interface functions:

media_entity_get() - acquire entity
media_entity_put() - release entity

If the entity is of node type, the power change is distributed to
all connected entities. For non-nodes it only affects that very
node. A mutex is used to serialise access to the entity graph.

In the background there's a depth-first search algorithm that traverses the
active links in the graph. All these functions parse the graph to implement
whatever they're to do.

The module counters are increased/decreased in media_entity_get/put to
prevent module unloading when an entity is referenced.

Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
---
 Documentation/media-framework.txt |   37 +
 drivers/media/media-device.c  |1 +
 drivers/media/media-entity.c  |  146 +
 include/media/media-device.h  |3 +
 include/media/media-entity.h  |   15 
 5 files changed, 202 insertions(+), 0 deletions(-)

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index 4fe3b32..6d680c6 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -236,3 +236,40 @@ When the graph traversal is complete the function will 
return NULL.
 Graph traversal can be interrupted at any moment. No cleanup function call is
 required and the graph structure can be freed normally.
 
+
+Reference counting and power handling
+-
+
+Before accessing type-specific entities operations (such as the V4L2
+sub-device operations), drivers must acquire a reference to the entity. This
+ensures that the entity will be powered on and ready to accept requests.
+Similarly, after being done with an entity, drivers must release the
+reference.
+
+   media_entity_get(struct media_entity *entity)
+
+The function will increase the entity reference count. If the entity is a node
+(MEDIA_ENTITY_TYPE_NODE type), the reference count of all entities it is
+connected to, both directly or indirectly, through active links is increased.
+This ensures that the whole media pipeline will be ready to process
+
+Acquiring a reference to an entity increases the media device module reference
+count to prevent module unloading when an entity is being used.
+
+media_entity_get will return a pointer to the entity if successful, or NULL
+otherwise.
+
+   media_entity_put(struct media_entity *entity)
+
+The function will decrease the entity reference count and, for node entities,
+like media_entity_get, the reference count of all connected entities. Calling
+media_entity_put with a NULL argument is valid and will return immediately.
+
+When the first reference to an entity is acquired, or the last reference
+released, the entity's set_power operation is called. Entity drivers must
+implement the operation if they need to perform any power management task,
+such as turning powers or clocks on or off. If no power management is
+required, drivers don't need to provide a set_power operation. The operation
+is allowed to fail when turning power on, in which case the media_entity_get
+function will return NULL.
+
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index ed64b4a..6fb2e26 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -51,6 +51,7 @@ int __must_check media_device_register(struct media_device 
*mdev)
mdev-entity_id = 1;
INIT_LIST_HEAD(mdev-entities);
spin_lock_init(mdev-lock);
+   mutex_init(mdev-graph_mutex);
 
/* If dev == NULL, then name must be filled in by the caller */
if (mdev-dev == NULL  WARN_ON(!mdev-devnode.name[0]))
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 443c5c9..e091bc8 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -21,6 +21,7 @@
 #include linux/module.h
 #include linux/slab.h
 #include media/media-entity.h
+#include media/media-device.h
 
 /**
  * media_entity_init - Initialize a media entity
@@ -193,6 +194,151 @@ media_entity_graph_walk_next(struct media_entity_graph 
*graph)
 EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
 
 /* 
-
+ * Power state handling
+ */
+
+/* Apply use count to an entity. */
+static void media_entity_use_apply_one(struct media_entity *entity, int change)
+{
+   entity-use_count += change;
+   WARN_ON(entity-use_count  0);
+}
+
+/*
+ * Apply use count change to an entity and change power state based on
+ * new use count.
+ */
+static int media_entity_power_apply_one(struct media_entity *entity, int 
change)
+{
+   int ret;
+
+   if (entity-use_count == 0  change  0 
+  

[RFC/PATCH v3 06/10] media: Entities, pads and links enumeration

2010-07-29 Thread Laurent Pinchart
Create the following two ioctls and implement them at the media device
level to enumerate entities, pads and links.

- MEDIA_IOC_ENUM_ENTITIES: Enumerate entities and their properties
- MEDIA_IOC_ENUM_LINKS: Enumerate all pads and links for a given entity

Entity IDs can be non-contiguous. Userspace applications should
enumerate entities using the MEDIA_ENTITY_ID_FLAG_NEXT flag. When the
flag is set in the entity ID, the MEDIA_IOC_ENUM_ENTITIES will return
the next entity with an ID bigger than the requested one.

Only forward links that originate at one of the entity's source pads are
returned during the enumeration process.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 Documentation/media-framework.txt |  131 +++
 drivers/media/media-device.c  |  152 +
 include/linux/media.h |   77 +++
 include/media/media-device.h  |3 +
 include/media/media-entity.h  |   18 +
 5 files changed, 364 insertions(+), 17 deletions(-)
 create mode 100644 include/linux/media.h

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index 6d680c6..1192feb 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -273,3 +273,134 @@ required, drivers don't need to provide a set_power 
operation. The operation
 is allowed to fail when turning power on, in which case the media_entity_get
 function will return NULL.
 
+
+Userspace application API
+-
+
+Media devices offer an API to userspace application to discover the device
+internal topology through ioctls.
+
+   MEDIA_IOC_ENUM_ENTITIES - Enumerate entities and their properties
+   -
+
+   ioctl(int fd, int request, struct media_entity_desc *argp);
+
+To query the attributes of an entity, applications set the id field of a
+media_entity_desc structure and call the MEDIA_IOC_ENUM_ENTITIES ioctl with a
+pointer to this structure. The driver fills the rest of the structure or
+returns a EINVAL error code when the id is invalid.
+
+Entities can be enumerated by or'ing the id with the MEDIA_ENTITY_ID_FLAG_NEXT
+flag. The driver will return information about the entity with the smallest id
+strictly larger than the requested one ('next entity'), or EINVAL if there is
+none.
+
+Entity IDs can be non-contiguous. Applications must *not* try to enumerate
+entities by calling MEDIA_IOC_ENUM_ENTITIES with increasing id's until they
+get an error.
+
+The media_entity_desc structure is defined as
+
+- struct media_entity_desc
+
+__u32  id  Entity id, set by the application. When the id is
+   or'ed with MEDIA_ENTITY_ID_FLAG_NEXT, the driver
+   clears the flag and returns the first entity with a
+   larger id.
+char   name[32]Entity name. UTF-8 NULL-terminated string.
+__u32  typeEntity type.
+__u8   padsNumber of pads.
+__u32  links   Total number of outbound links. Inbound links are not
+   counted in this field.
+/* union */
+   /* struct v4l, Valid for V4L sub-devices and nodes only */
+__u32  major   V4L device node major number. For V4L sub-devices with
+   no device node, set by the driver to 0.
+__u32  minor   V4L device node minor number. For V4L sub-devices with
+   no device node, set by the driver to 0.
+   /* struct fb, Valid for frame buffer nodes only */
+__u32  major   FB device node major number
+__u32  minor   FB device node minor number
+   /* Valid for ALSA devices only */
+intalsaALSA card number
+   /* Valid for DVB devices only */
+intdvb DVB card number
+
+Valid entity types are
+
+   MEDIA_ENTITY_TYPE_NODE - Unknown device node
+   MEDIA_ENTITY_TYPE_NODE_V4L - V4L video, radio or vbi device node
+   MEDIA_ENTITY_TYPE_NODE_FB - Frame buffer device node
+   MEDIA_ENTITY_TYPE_NODE_ALSA - ALSA card
+   MEDIA_ENTITY_TYPE_NODE_DVB - DVB card
+
+   MEDIA_ENTITY_TYPE_SUBDEV - Unknown V4L sub-device
+   MEDIA_ENTITY_TYPE_SUBDEV_VID_DECODER - Video decoder
+   MEDIA_ENTITY_TYPE_SUBDEV_VID_ENCODER - Video encoder
+   MEDIA_ENTITY_TYPE_SUBDEV_MISC - Unspecified entity subtype
+
+
+   MEDIA_IOC_ENUM_LINKS - Enumerate all pads and links for a given entity
+   --
+
+   ioctl(int fd, int request, struct media_links_enum *argp);
+
+Only forward links that originate at one of the entity's source pads are
+returned during the enumeration process.
+
+To enumerate pads and/or links for a given entity, applications set the entity
+field of a media_links_enum structure 

[SAMPLE v3 00/12] V4L2 API additions and OMAP3 ISP driver

2010-07-29 Thread Laurent Pinchart
Here's the OMAP3 ISP driver along with V4L2 API additions/enhancements that
it depends on, rebased on top of the media controller v3 patches. Once again
please don't review this set, but use it as sample code for the media
controller.

Antti Koskipaa (1):
  v4l: Add crop ioctl to V4L2 subdev API

Laurent Pinchart (8):
  v4l: Move the media/v4l2-mediabus.h header to include/linux
  v4l: Add 16 bit YUYV and SGRBG10 media bus format codes
  v4l-subdev: Add pads operations
  v4l: v4l2_subdev userspace format API
  v4l: Add subdev userspace API to enumerate and configure frame
interval
  v4l: subdev: Generic ioctl support
  omap34xxcam: Register the ISP platform device during omap34xxcam
probe
  OMAP3 ISP driver

Stanimir Varbanov (2):
  v4l: Create v4l2 subdev file handle structure
  omap3: Export omap3isp platform device structure

Tuukka Toivonen (1):
  ARM: OMAP3: Update Camera ISP definitions for OMAP3630

 Documentation/video4linux/v4l2-framework.txt |5 +
 arch/arm/mach-omap2/devices.c|   46 +-
 arch/arm/mach-omap2/devices.h|   17 +
 arch/arm/plat-omap/include/mach/isp_user.h   |  637 
 arch/arm/plat-omap/include/plat/omap34xx.h   |   16 +-
 drivers/media/video/Kconfig  |9 +
 drivers/media/video/Makefile |4 +
 drivers/media/video/isp/Makefile |   14 +
 drivers/media/video/isp/bluegamma_table.h| 1040 
 drivers/media/video/isp/cfa_coef_table.h |  603 +++
 drivers/media/video/isp/greengamma_table.h   | 1040 
 drivers/media/video/isp/isp.c| 1686 +++
 drivers/media/video/isp/isp.h|  402 +
 drivers/media/video/isp/ispccdc.c| 2042 +++
 drivers/media/video/isp/ispccdc.h|  177 ++
 drivers/media/video/isp/ispccp2.c| 1036 
 drivers/media/video/isp/ispccp2.h|   89 +
 drivers/media/video/isp/ispcsi2.c| 1215 ++
 drivers/media/video/isp/ispcsi2.h|  158 ++
 drivers/media/video/isp/ispcsiphy.c  |  245 +++
 drivers/media/video/isp/ispcsiphy.h  |   72 +
 drivers/media/video/isp/isph3a.h |  111 ++
 drivers/media/video/isp/isph3a_aewb.c|  307 
 drivers/media/video/isp/isph3a_af.c  |  358 
 drivers/media/video/isp/isphist.c|  505 ++
 drivers/media/video/isp/isphist.h|   34 +
 drivers/media/video/isp/isppreview.c | 2264 ++
 drivers/media/video/isp/isppreview.h |  259 +++
 drivers/media/video/isp/ispqueue.c   | 1074 
 drivers/media/video/isp/ispqueue.h   |  175 ++
 drivers/media/video/isp/ispreg.h | 1802 
 drivers/media/video/isp/ispresizer.c | 1638 +++
 drivers/media/video/isp/ispresizer.h |  136 ++
 drivers/media/video/isp/ispstat.c|  971 +++
 drivers/media/video/isp/ispstat.h|  161 ++
 drivers/media/video/isp/ispvideo.c   | 1241 ++
 drivers/media/video/isp/ispvideo.h   |  139 ++
 drivers/media/video/isp/luma_enhance_table.h |  144 ++
 drivers/media/video/isp/noise_filter_table.h |   79 +
 drivers/media/video/isp/redgamma_table.h | 1040 
 drivers/media/video/omap34xxcam.c| 1562 ++
 drivers/media/video/omap34xxcam.h|  137 ++
 drivers/media/video/v4l2-subdev.c|  177 ++-
 include/linux/v4l2-mediabus.h|   70 +
 include/linux/v4l2-subdev.h  |  102 ++
 include/media/soc_mediabus.h |3 +-
 include/media/v4l2-mediabus.h|   48 +-
 include/media/v4l2-subdev.h  |   53 +
 48 files changed, 25056 insertions(+), 87 deletions(-)
 create mode 100644 arch/arm/mach-omap2/devices.h
 create mode 100644 arch/arm/plat-omap/include/mach/isp_user.h
 create mode 100644 drivers/media/video/isp/Makefile
 create mode 100644 drivers/media/video/isp/bluegamma_table.h
 create mode 100644 drivers/media/video/isp/cfa_coef_table.h
 create mode 100644 drivers/media/video/isp/greengamma_table.h
 create mode 100644 drivers/media/video/isp/isp.c
 create mode 100644 drivers/media/video/isp/isp.h
 create mode 100644 drivers/media/video/isp/ispccdc.c
 create mode 100644 drivers/media/video/isp/ispccdc.h
 create mode 100644 drivers/media/video/isp/ispccp2.c
 create mode 100644 drivers/media/video/isp/ispccp2.h
 create mode 100644 drivers/media/video/isp/ispcsi2.c
 create mode 100644 drivers/media/video/isp/ispcsi2.h
 create mode 100644 drivers/media/video/isp/ispcsiphy.c
 create mode 100644 drivers/media/video/isp/ispcsiphy.h
 create mode 100644 drivers/media/video/isp/isph3a.h
 create mode 100644 drivers/media/video/isp/isph3a_aewb.c
 create mode 100644 drivers/media/video/isp/isph3a_af.c
 create mode 100644 drivers/media/video/isp/isphist.c
 create 

[SAMPLE v3 01/12] v4l: Move the media/v4l2-mediabus.h header to include/linux

2010-07-29 Thread Laurent Pinchart
The header defines the v4l2_mbus_framefmt structure which will be used
by the V4L2 subdevs userspace API.

Change the type of the v4l2_mbus_framefmt::code field to __u32, as enum
sizes can differ between different ABIs on the same architectures.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/linux/v4l2-mediabus.h |   64 +
 include/media/soc_mediabus.h  |3 +-
 include/media/v4l2-mediabus.h |   48 +--
 3 files changed, 66 insertions(+), 49 deletions(-)
 create mode 100644 include/linux/v4l2-mediabus.h

diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
new file mode 100644
index 000..17219c3
--- /dev/null
+++ b/include/linux/v4l2-mediabus.h
@@ -0,0 +1,64 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_V4L2_MEDIABUS_H
+#define __LINUX_V4L2_MEDIABUS_H
+
+#include linux/videodev2.h
+
+/*
+ * These pixel codes uniquely identify data formats on the media bus. Mostly
+ * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
+ * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
+ * data format is fixed. Additionally, 2X8 means that one pixel is 
transferred
+ * in two 8-bit samples, BE or LE specify in which order those samples are
+ * transferred over the bus: LE means that the least significant bits are
+ * transferred first, BE means that the most significant bits are transferred
+ * first, and PADHI and PADLO define which bits - low or high, in the
+ * incomplete high byte, are filled with padding bits.
+ */
+enum v4l2_mbus_pixelcode {
+   V4L2_MBUS_FMT_FIXED = 1,
+   V4L2_MBUS_FMT_YUYV8_2X8_LE,
+   V4L2_MBUS_FMT_YVYU8_2X8_LE,
+   V4L2_MBUS_FMT_YUYV8_2X8_BE,
+   V4L2_MBUS_FMT_YVYU8_2X8_BE,
+   V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
+   V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
+   V4L2_MBUS_FMT_RGB565_2X8_LE,
+   V4L2_MBUS_FMT_RGB565_2X8_BE,
+   V4L2_MBUS_FMT_SBGGR8_1X8,
+   V4L2_MBUS_FMT_SBGGR10_1X10,
+   V4L2_MBUS_FMT_GREY8_1X8,
+   V4L2_MBUS_FMT_Y10_1X10,
+   V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
+   V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE,
+   V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
+   V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
+   V4L2_MBUS_FMT_SGRBG8_1X8,
+};
+
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width: frame width
+ * @height:frame height
+ * @code:  data format code
+ * @field: used interlacing type
+ * @colorspace:colorspace of the data
+ */
+struct v4l2_mbus_framefmt {
+   __u32   width;
+   __u32   height;
+   __u32   code;
+   enum v4l2_field field;
+   enum v4l2_colorspacecolorspace;
+};
+
+#endif
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h
index 037cd7b..6243147 100644
--- a/include/media/soc_mediabus.h
+++ b/include/media/soc_mediabus.h
@@ -12,8 +12,7 @@
 #define SOC_MEDIABUS_H
 
 #include linux/videodev2.h
-
-#include media/v4l2-mediabus.h
+#include linux/v4l2-mediabus.h
 
 /**
  * enum soc_mbus_packing - data packing types on the media-bus
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 865cda7..971c7fa 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -11,53 +11,7 @@
 #ifndef V4L2_MEDIABUS_H
 #define V4L2_MEDIABUS_H
 
-/*
- * These pixel codes uniquely identify data formats on the media bus. Mostly
- * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
- * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
- * data format is fixed. Additionally, 2X8 means that one pixel is 
transferred
- * in two 8-bit samples, BE or LE specify in which order those samples are
- * transferred over the bus: LE means that the least significant bits are
- * transferred first, BE means that the most significant bits are transferred
- * first, and PADHI and PADLO define which bits - low or high, in the
- * incomplete high byte, are filled with padding bits.
- */
-enum v4l2_mbus_pixelcode {
-   V4L2_MBUS_FMT_FIXED = 1,
-   V4L2_MBUS_FMT_YUYV8_2X8_LE,
-   V4L2_MBUS_FMT_YVYU8_2X8_LE,
-   V4L2_MBUS_FMT_YUYV8_2X8_BE,
-   V4L2_MBUS_FMT_YVYU8_2X8_BE,
-   V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
-   V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
-   V4L2_MBUS_FMT_RGB565_2X8_LE,
-   V4L2_MBUS_FMT_RGB565_2X8_BE,
-   V4L2_MBUS_FMT_SBGGR8_1X8,
-   V4L2_MBUS_FMT_SBGGR10_1X10,
-   V4L2_MBUS_FMT_GREY8_1X8,
-   V4L2_MBUS_FMT_Y10_1X10,
-   V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
-   

[SAMPLE v3 02/12] v4l: Add 16 bit YUYV and SGRBG10 media bus format codes

2010-07-29 Thread Laurent Pinchart
Add the following media bus format code definitions:

- V4L2_MBUS_FMT_SGRBG10_1X10 for 10-bit GRBG Bayer
- V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8 for 10-bit DPCM compressed GRBG Bayer
- V4L2_MBUS_FMT_YUYV16_1X16 for 16-bit YUYV
- V4L2_MBUS_FMT_UYVY16_1X16 for 16-bit UYVY
- V4L2_MBUS_FMT_YVYU16_1X16 for 16-bit YVYU
- V4L2_MBUS_FMT_VYUY16_1X16 for 16-bit VYUY

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/linux/v4l2-mediabus.h |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
index 17219c3..34dd708 100644
--- a/include/linux/v4l2-mediabus.h
+++ b/include/linux/v4l2-mediabus.h
@@ -43,6 +43,12 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
V4L2_MBUS_FMT_SGRBG8_1X8,
+   V4L2_MBUS_FMT_SGRBG10_1X10,
+   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
+   V4L2_MBUS_FMT_YUYV16_1X16,
+   V4L2_MBUS_FMT_UYVY16_1X16,
+   V4L2_MBUS_FMT_YVYU16_1X16,
+   V4L2_MBUS_FMT_VYUY16_1X16,
 };
 
 /**
-- 
1.7.1

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


[SAMPLE v3 03/12] v4l: Create v4l2 subdev file handle structure

2010-07-29 Thread Laurent Pinchart
From: Stanimir Varbanov svarba...@mm-sol.com

Used for storing subdev information per file handle and hold V4L2 file
handle.

Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/video/v4l2-subdev.c |   76 -
 include/media/v4l2-subdev.h   |   18 +
 2 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/drivers/media/video/v4l2-subdev.c 
b/drivers/media/video/v4l2-subdev.c
index 1efa267..2fe3818 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -28,38 +28,60 @@
 #include media/v4l2-fh.h
 #include media/v4l2-event.h
 
+static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
+{
+   fh-probe_fmt = kzalloc(sizeof(*fh-probe_fmt) *
+   sd-entity.num_pads, GFP_KERNEL);
+   if (fh-probe_fmt == NULL)
+   return -ENOMEM;
+
+   return 0;
+}
+
+static void subdev_fh_free(struct v4l2_subdev_fh *fh)
+{
+   kfree(fh-probe_fmt);
+   fh-probe_fmt = NULL;
+}
+
 static int subdev_open(struct file *file)
 {
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
+   struct v4l2_subdev_fh *subdev_fh;
struct media_entity *entity;
-   struct v4l2_fh *vfh = NULL;
int ret;
 
if (!sd-initialized)
return -EAGAIN;
 
-   if (sd-flags  V4L2_SUBDEV_FL_HAS_EVENTS) {
-   vfh = kzalloc(sizeof(*vfh), GFP_KERNEL);
-   if (vfh == NULL)
-   return -ENOMEM;
+   subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL);
+   if (subdev_fh == NULL)
+   return -ENOMEM;
 
-   ret = v4l2_fh_init(vfh, vdev);
-   if (ret)
-   goto err;
+   ret = subdev_fh_init(subdev_fh, sd);
+   if (ret) {
+   kfree(subdev_fh);
+   return ret;
+   }
+
+   ret = v4l2_fh_init(subdev_fh-vfh, vdev);
+   if (ret)
+   goto err;
 
-   ret = v4l2_event_init(vfh);
+   if (sd-flags  V4L2_SUBDEV_FL_HAS_EVENTS) {
+   ret = v4l2_event_init(subdev_fh-vfh);
if (ret)
goto err;
 
-   ret = v4l2_event_alloc(vfh, sd-nevents);
+   ret = v4l2_event_alloc(subdev_fh-vfh, sd-nevents);
if (ret)
goto err;
-
-   v4l2_fh_add(vfh);
-   file-private_data = vfh;
}
 
+   v4l2_fh_add(subdev_fh-vfh);
+   file-private_data = subdev_fh-vfh;
+
entity = media_entity_get(sd-entity);
if (!entity) {
ret = -EBUSY;
@@ -69,11 +91,10 @@ static int subdev_open(struct file *file)
return 0;
 
 err:
-   if (vfh != NULL) {
-   v4l2_fh_del(vfh);
-   v4l2_fh_exit(vfh);
-   kfree(vfh);
-   }
+   v4l2_fh_del(subdev_fh-vfh);
+   v4l2_fh_exit(subdev_fh-vfh);
+   subdev_fh_free(subdev_fh);
+   kfree(subdev_fh);
 
return ret;
 }
@@ -83,14 +104,15 @@ static int subdev_close(struct file *file)
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
struct v4l2_fh *vfh = file-private_data;
+   struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
 
media_entity_put(sd-entity);
 
-   if (vfh != NULL) {
-   v4l2_fh_del(vfh);
-   v4l2_fh_exit(vfh);
-   kfree(vfh);
-   }
+   v4l2_fh_del(vfh);
+   v4l2_fh_exit(vfh);
+   subdev_fh_free(subdev_fh);
+   kfree(subdev_fh);
+   file-private_data = NULL;
 
return 0;
 }
@@ -99,7 +121,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int 
cmd, void *arg)
 {
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
-   struct v4l2_fh *fh = file-private_data;
+   struct v4l2_fh *vfh = file-private_data;
 
switch (cmd) {
case VIDIOC_QUERYCTRL:
@@ -127,13 +149,13 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
if (!(sd-flags  V4L2_SUBDEV_FL_HAS_EVENTS))
return -ENOIOCTLCMD;
 
-   return v4l2_event_dequeue(fh, arg, file-f_flags  O_NONBLOCK);
+   return v4l2_event_dequeue(vfh, arg, file-f_flags  O_NONBLOCK);
 
case VIDIOC_SUBSCRIBE_EVENT:
-   return v4l2_subdev_call(sd, core, subscribe_event, fh, arg);
+   return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);
 
case VIDIOC_UNSUBSCRIBE_EVENT:
-   return v4l2_subdev_call(sd, core, unsubscribe_event, fh, arg);
+   return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);
 
default:
return -ENOIOCTLCMD;
diff 

[SAMPLE v3 09/12] ARM: OMAP3: Update Camera ISP definitions for OMAP3630

2010-07-29 Thread Laurent Pinchart
From: Tuukka Toivonen tuukka.o.toivo...@nokia.com

Add new/changed base address definitions and resources for
OMAP3630 ISP.

The OMAP3430 CSI2PHY block is same as the OMAP3630 CSIPHY2
block. But the later name is chosen as it gives more symmetry
to the names.

Signed-off-by: Tuukka Toivonen tuukka.o.toivo...@nokia.com
Signed-off-by: Vimarsh Zutshi vimarsh.zut...@nokia.com
---
 arch/arm/mach-omap2/devices.c  |   28 
 arch/arm/plat-omap/include/plat/omap34xx.h |   16 
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 03e6c9e..46b0b4b 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -107,13 +107,33 @@ static struct resource omap3isp_resources[] = {
.flags  = IORESOURCE_MEM,
},
{
-   .start  = OMAP3430_ISP_CSI2A_BASE,
-   .end= OMAP3430_ISP_CSI2A_END,
+   .start  = OMAP3430_ISP_CSI2A_REGS1_BASE,
+   .end= OMAP3430_ISP_CSI2A_REGS1_END,
.flags  = IORESOURCE_MEM,
},
{
-   .start  = OMAP3430_ISP_CSI2PHY_BASE,
-   .end= OMAP3430_ISP_CSI2PHY_END,
+   .start  = OMAP3430_ISP_CSIPHY2_BASE,
+   .end= OMAP3430_ISP_CSIPHY2_END,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = OMAP3630_ISP_CSI2A_REGS2_BASE,
+   .end= OMAP3630_ISP_CSI2A_REGS2_END,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = OMAP3630_ISP_CSI2C_REGS1_BASE,
+   .end= OMAP3630_ISP_CSI2C_REGS1_END,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = OMAP3630_ISP_CSIPHY1_BASE,
+   .end= OMAP3630_ISP_CSIPHY1_END,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .start  = OMAP3630_ISP_CSI2C_REGS2_BASE,
+   .end= OMAP3630_ISP_CSI2C_REGS2_END,
.flags  = IORESOURCE_MEM,
},
{
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h 
b/arch/arm/plat-omap/include/plat/omap34xx.h
index 98fc8b4..b9e8588 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -56,8 +56,12 @@
 #define OMAP3430_ISP_RESZ_BASE (OMAP3430_ISP_BASE + 0x1000)
 #define OMAP3430_ISP_SBL_BASE  (OMAP3430_ISP_BASE + 0x1200)
 #define OMAP3430_ISP_MMU_BASE  (OMAP3430_ISP_BASE + 0x1400)
-#define OMAP3430_ISP_CSI2A_BASE(OMAP3430_ISP_BASE + 0x1800)
-#define OMAP3430_ISP_CSI2PHY_BASE  (OMAP3430_ISP_BASE + 0x1970)
+#define OMAP3430_ISP_CSI2A_REGS1_BASE  (OMAP3430_ISP_BASE + 0x1800)
+#define OMAP3430_ISP_CSIPHY2_BASE  (OMAP3430_ISP_BASE + 0x1970)
+#define OMAP3630_ISP_CSI2A_REGS2_BASE  (OMAP3430_ISP_BASE + 0x19C0)
+#define OMAP3630_ISP_CSI2C_REGS1_BASE  (OMAP3430_ISP_BASE + 0x1C00)
+#define OMAP3630_ISP_CSIPHY1_BASE  (OMAP3430_ISP_BASE + 0x1D70)
+#define OMAP3630_ISP_CSI2C_REGS2_BASE  (OMAP3430_ISP_BASE + 0x1DC0)
 
 #define OMAP3430_ISP_END   (OMAP3430_ISP_BASE + 0x06F)
 #define OMAP3430_ISP_CBUFF_END (OMAP3430_ISP_CBUFF_BASE   + 0x077)
@@ -69,8 +73,12 @@
 #define OMAP3430_ISP_RESZ_END  (OMAP3430_ISP_RESZ_BASE+ 0x0AB)
 #define OMAP3430_ISP_SBL_END   (OMAP3430_ISP_SBL_BASE + 0x0FB)
 #define OMAP3430_ISP_MMU_END   (OMAP3430_ISP_MMU_BASE + 0x06F)
-#define OMAP3430_ISP_CSI2A_END (OMAP3430_ISP_CSI2A_BASE   + 0x16F)
-#define OMAP3430_ISP_CSI2PHY_END   (OMAP3430_ISP_CSI2PHY_BASE + 0x007)
+#define OMAP3430_ISP_CSI2A_REGS1_END   (OMAP3430_ISP_CSI2A_REGS1_BASE + 0x16F)
+#define OMAP3430_ISP_CSIPHY2_END   (OMAP3430_ISP_CSIPHY2_BASE + 0x00B)
+#define OMAP3630_ISP_CSI2A_REGS2_END   (OMAP3630_ISP_CSI2A_REGS2_BASE + 0x3F)
+#define OMAP3630_ISP_CSI2C_REGS1_END   (OMAP3630_ISP_CSI2C_REGS1_BASE + 0x16F)
+#define OMAP3630_ISP_CSIPHY1_END   (OMAP3630_ISP_CSIPHY1_BASE + 0x00B)
+#define OMAP3630_ISP_CSI2C_REGS2_END   (OMAP3630_ISP_CSI2C_REGS2_BASE + 0x3F)
 
 #define OMAP34XX_HSUSB_OTG_BASE(L4_34XX_BASE + 0xAB000)
 #define OMAP34XX_USBTLL_BASE   (L4_34XX_BASE + 0x62000)
-- 
1.7.1

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


[SAMPLE v3 10/12] omap3: Export omap3isp platform device structure

2010-07-29 Thread Laurent Pinchart
From: Stanimir Varbanov svarba...@mm-sol.com

omap3isp platform device structure pointer is needed from camera board
files for subdevs registration and calls.

Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
---
 arch/arm/mach-omap2/devices.c |5 -
 arch/arm/mach-omap2/devices.h |   17 +
 2 files changed, 21 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/devices.h

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 46b0b4b..ae465ce 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -32,6 +32,8 @@
 
 #include mux.h
 
+#include devices.h
+
 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
 
 static struct resource cam_resources[] = {
@@ -142,12 +144,13 @@ static struct resource omap3isp_resources[] = {
}
 };
 
-static struct platform_device omap3isp_device = {
+struct platform_device omap3isp_device = {
.name   = omap3isp,
.id = -1,
.num_resources  = ARRAY_SIZE(omap3isp_resources),
.resource   = omap3isp_resources,
 };
+EXPORT_SYMBOL_GPL(omap3isp_device);
 
 static inline void omap_init_camera(void)
 {
diff --git a/arch/arm/mach-omap2/devices.h b/arch/arm/mach-omap2/devices.h
new file mode 100644
index 000..f312d49
--- /dev/null
+++ b/arch/arm/mach-omap2/devices.h
@@ -0,0 +1,17 @@
+/*
+ * arch/arm/mach-omap2/devices.h
+ *
+ * OMAP2 platform device setup/initialization
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ARCH_ARM_MACH_OMAP_DEVICES_H
+#define __ARCH_ARM_MACH_OMAP_DEVICES_H
+
+extern struct platform_device omap3isp_device;
+
+#endif
-- 
1.7.1

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


[SAMPLE v3 11/12] omap34xxcam: Register the ISP platform device during omap34xxcam probe

2010-07-29 Thread Laurent Pinchart
In order to properly clean up all resources allocated by the isp-mod
driver, the ISP platform device needs to be unregistered when the
omap34xxcam driver is unloaded.

Move the ISP platform device registration from omap_init_camera to
omap34xxcam_probe. This fixes many memory leaks when unloading and
reloading the omap34xxcam driver.

Platform device registration should be moved back to omap_init_camera
when (if) the omap34xxcam and isp-mod drivers will be merged.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 arch/arm/mach-omap2/devices.c |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index ae465ce..61e5136 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -144,17 +144,28 @@ static struct resource omap3isp_resources[] = {
}
 };
 
+static void omap3isp_release(struct device *dev)
+{
+   /* Zero the device structure to avoid re-initialization complaints from
+* kobject when the device will be re-registered.
+*/
+   memset(dev, 0, sizeof(*dev));
+   dev-release = omap3isp_release;
+}
+
 struct platform_device omap3isp_device = {
.name   = omap3isp,
.id = -1,
.num_resources  = ARRAY_SIZE(omap3isp_resources),
.resource   = omap3isp_resources,
+   .dev = {
+   .release= omap3isp_release,
+   },
 };
 EXPORT_SYMBOL_GPL(omap3isp_device);
 
 static inline void omap_init_camera(void)
 {
-   platform_device_register(omap3isp_device);
 }
 #else
 static inline void omap_init_camera(void)
-- 
1.7.1

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


[SAMPLE v3 08/12] v4l: subdev: Generic ioctl support

2010-07-29 Thread Laurent Pinchart
Instead of returning an error when receiving an ioctl call with an
unsupported command, forward the call to the subdev core::ioctl handler.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/video4linux/v4l2-framework.txt |5 +
 drivers/media/video/v4l2-subdev.c|2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index f7b72a9..bdcf4bb 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -401,6 +401,11 @@ VIDIOC_UNSUBSCRIBE_EVENT
To properly support events, the poll() file operation is also
implemented.
 
+Private ioctls
+
+   All ioctls not in the above list are passed directly to the sub-device
+   driver through the core::ioctl operation.
+
 
 I2C sub-device drivers
 --
diff --git a/drivers/media/video/v4l2-subdev.c 
b/drivers/media/video/v4l2-subdev.c
index ad4b95e..887cd88 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -257,7 +257,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int 
cmd, void *arg)
}
 
default:
-   return -ENOIOCTLCMD;
+   return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
}
 
return 0;
-- 
1.7.1

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


[SAMPLE v3 07/12] v4l: Add crop ioctl to V4L2 subdev API

2010-07-29 Thread Laurent Pinchart
From: Antti Koskipaa antti.koski...@nokia.com

This patch adds the VIDIOC_SUBDEV_S_CROP and G_CROP ioctls to the
userland API. CROPCAP is not implemented because it's redundant.

Signed-off-by: Antti Koskipaa antti.koski...@nokia.com
---
 drivers/media/video/v4l2-subdev.c |   36 ++--
 include/linux/v4l2-subdev.h   |   12 
 include/media/v4l2-subdev.h   |   11 +++
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/v4l2-subdev.c 
b/drivers/media/video/v4l2-subdev.c
index 8ddb2fb..ad4b95e 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -30,11 +30,16 @@
 
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
-   fh-probe_fmt = kzalloc(sizeof(*fh-probe_fmt) *
-   sd-entity.num_pads, GFP_KERNEL);
+   /* Allocate probe format and crop in the same memory block */
+   fh-probe_fmt = kzalloc((sizeof(*fh-probe_fmt) +
+   sizeof(*fh-probe_crop)) * sd-entity.num_pads,
+   GFP_KERNEL);
if (fh-probe_fmt == NULL)
return -ENOMEM;
 
+   fh-probe_crop = (struct v4l2_rect *)
+   (fh-probe_fmt + sd-entity.num_pads);
+
return 0;
 }
 
@@ -42,6 +47,7 @@ static void subdev_fh_free(struct v4l2_subdev_fh *fh)
 {
kfree(fh-probe_fmt);
fh-probe_fmt = NULL;
+   fh-probe_crop = NULL;
 }
 
 static int subdev_open(struct file *file)
@@ -188,6 +194,32 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
format-which);
}
 
+   case VIDIOC_SUBDEV_G_CROP: {
+   struct v4l2_subdev_pad_crop *crop = arg;
+
+   if (crop-which != V4L2_SUBDEV_FORMAT_PROBE 
+   crop-which != V4L2_SUBDEV_FORMAT_ACTIVE)
+   return -EINVAL;
+
+   if (crop-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
+   }
+
+   case VIDIOC_SUBDEV_S_CROP: {
+   struct v4l2_subdev_pad_crop *crop = arg;
+
+   if (crop-which != V4L2_SUBDEV_FORMAT_PROBE 
+   crop-which != V4L2_SUBDEV_FORMAT_ACTIVE)
+   return -EINVAL;
+
+   if (crop-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
+   }
+
case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
struct v4l2_subdev_pad_mbus_code_enum *code = arg;
 
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index e3362aa..5738e81 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -36,6 +36,16 @@ struct v4l2_subdev_pad_format {
 };
 
 /**
+ * struct v4l2_subdev_pad_crop
+ */
+struct v4l2_subdev_pad_crop {
+   __u32 pad;
+   __u32 which;
+   struct v4l2_rect rect;
+   __u32 reserved[10];
+};
+
+/**
  * struct v4l2_subdev_pad_mbus_code_enum
  */
 struct v4l2_subdev_pad_mbus_code_enum {
@@ -86,5 +96,7 @@ struct v4l2_subdev_frame_interval_enum {
_IOWR('V', 9, struct v4l2_subdev_frame_size_enum)
 #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
_IOWR('V', 10, struct v4l2_subdev_frame_interval_enum)
+#define VIDIOC_SUBDEV_S_CROP   _IOWR('V', 11, struct v4l2_subdev_pad_crop)
+#define VIDIOC_SUBDEV_G_CROP   _IOWR('V', 12, struct v4l2_subdev_pad_crop)
 
 #endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 58ef923..41183ab 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -419,6 +419,10 @@ struct v4l2_subdev_pad_ops {
int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
   unsigned int pad, struct v4l2_mbus_framefmt *fmt,
   enum v4l2_subdev_format which);
+   int (*set_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+  struct v4l2_subdev_pad_crop *crop);
+   int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+  struct v4l2_subdev_pad_crop *crop);
 };
 
 struct v4l2_subdev_ops {
@@ -478,6 +482,7 @@ struct v4l2_subdev {
 struct v4l2_subdev_fh {
struct v4l2_fh vfh;
struct v4l2_mbus_framefmt *probe_fmt;
+   struct v4l2_rect *probe_crop;
 };
 
 #define to_v4l2_subdev_fh(fh)  \
@@ -489,6 +494,12 @@ v4l2_subdev_get_probe_format(struct v4l2_subdev_fh *fh, 
unsigned int pad)
return fh-probe_fmt[pad];
 }
 
+static inline struct v4l2_rect *
+v4l2_subdev_get_probe_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
+{
+   return fh-probe_crop[pad];
+}
+
 extern const struct v4l2_file_operations v4l2_subdev_fops;
 
 static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
-- 
1.7.1

--
To 

[SAMPLE v3 06/12] v4l: Add subdev userspace API to enumerate and configure frame interval

2010-07-29 Thread Laurent Pinchart
The three new ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL,
VIDIOC_SUBDEV_G_FRAME_INTERVAL and VIDIOC_SUBDEV_S_FRAME_INTERVAL can be
used to enumerate and configure a subdev's frame rate from userspace.

Two new video::g/s_frame_interval subdev operations are introduced to
support those ioctls. The existing video::g/s_parm operations are
deprecated and shouldn't be used anymore.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 drivers/media/video/v4l2-subdev.c |   16 
 include/linux/v4l2-subdev.h   |   24 
 include/media/v4l2-subdev.h   |7 +++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/v4l2-subdev.c 
b/drivers/media/video/v4l2-subdev.c
index d8b261f..8ddb2fb 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -208,6 +208,22 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
fse);
}
 
+   case VIDIOC_SUBDEV_G_FRAME_INTERVAL:
+   return v4l2_subdev_call(sd, video, g_frame_interval, arg);
+
+   case VIDIOC_SUBDEV_S_FRAME_INTERVAL:
+   return v4l2_subdev_call(sd, video, s_frame_interval, arg);
+
+   case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
+   struct v4l2_subdev_frame_interval_enum *fie = arg;
+
+   if (fie-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh,
+   fie);
+   }
+
default:
return -ENOIOCTLCMD;
}
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index 6504f22..e3362aa 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -56,11 +56,35 @@ struct v4l2_subdev_frame_size_enum {
__u32 reserved[9];
 };
 
+/**
+ * struct v4l2_subdev_pad_frame_rate
+ */
+struct v4l2_subdev_frame_interval {
+   struct v4l2_fract interval;
+   __u32 reserved[6];
+};
+
+struct v4l2_subdev_frame_interval_enum {
+   __u32 index;
+   __u32 pad;
+   __u32 code;
+   __u32 width;
+   __u32 height;
+   struct v4l2_fract interval;
+   __u32 reserved[9];
+};
+
 #define VIDIOC_SUBDEV_G_FMT_IOWR('V',  4, struct v4l2_subdev_pad_format)
 #define VIDIOC_SUBDEV_S_FMT_IOWR('V',  5, struct v4l2_subdev_pad_format)
+#define VIDIOC_SUBDEV_G_FRAME_INTERVAL \
+   _IOWR('V', 6, struct v4l2_subdev_frame_interval)
+#define VIDIOC_SUBDEV_S_FRAME_INTERVAL \
+   _IOWR('V', 7, struct v4l2_subdev_frame_interval)
 #define VIDIOC_SUBDEV_ENUM_MBUS_CODE \
_IOWR('V', 8, struct v4l2_subdev_pad_mbus_code_enum)
 #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
_IOWR('V', 9, struct v4l2_subdev_frame_size_enum)
+#define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
+   _IOWR('V', 10, struct v4l2_subdev_frame_interval_enum)
 
 #endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index acbcd8f..58ef923 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -245,6 +245,10 @@ struct v4l2_subdev_video_ops {
int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
+   int (*g_frame_interval)(struct v4l2_subdev *sd,
+   struct v4l2_subdev_frame_interval *interval);
+   int (*s_frame_interval)(struct v4l2_subdev *sd,
+   struct v4l2_subdev_frame_interval *interval);
int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum 
*fsize);
int (*enum_frameintervals)(struct v4l2_subdev *sd, struct 
v4l2_frmivalenum *fival);
int (*enum_dv_presets) (struct v4l2_subdev *sd,
@@ -406,6 +410,9 @@ struct v4l2_subdev_pad_ops {
int (*enum_frame_size)(struct v4l2_subdev *sd,
   struct v4l2_subdev_fh *fh,
   struct v4l2_subdev_frame_size_enum *fse);
+   int (*enum_frame_interval)(struct v4l2_subdev *sd,
+  struct v4l2_subdev_fh *fh,
+  struct v4l2_subdev_frame_interval_enum *fie);
int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
   unsigned int pad, struct v4l2_mbus_framefmt *fmt,
   enum v4l2_subdev_format which);
-- 
1.7.1

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


[SAMPLE v3 05/12] v4l: v4l2_subdev userspace format API

2010-07-29 Thread Laurent Pinchart
Add a userspace API to get, set and enumerate the media format on a
subdev pad.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 drivers/media/video/v4l2-subdev.c |   51 
 include/linux/v4l2-subdev.h   |   66 +
 include/media/v4l2-subdev.h   |6 +---
 3 files changed, 118 insertions(+), 5 deletions(-)
 create mode 100644 include/linux/v4l2-subdev.h

diff --git a/drivers/media/video/v4l2-subdev.c 
b/drivers/media/video/v4l2-subdev.c
index 2fe3818..d8b261f 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -122,6 +122,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int 
cmd, void *arg)
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
struct v4l2_fh *vfh = file-private_data;
+   struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
 
switch (cmd) {
case VIDIOC_QUERYCTRL:
@@ -157,6 +158,56 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
case VIDIOC_UNSUBSCRIBE_EVENT:
return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);
 
+   case VIDIOC_SUBDEV_G_FMT: {
+   struct v4l2_subdev_pad_format *format = arg;
+
+   if (format-which != V4L2_SUBDEV_FORMAT_PROBE 
+   format-which != V4L2_SUBDEV_FORMAT_ACTIVE)
+   return -EINVAL;
+
+   if (format-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh,
+   format-pad, format-format,
+   format-which);
+   }
+
+   case VIDIOC_SUBDEV_S_FMT: {
+   struct v4l2_subdev_pad_format *format = arg;
+
+   if (format-which != V4L2_SUBDEV_FORMAT_PROBE 
+   format-which != V4L2_SUBDEV_FORMAT_ACTIVE)
+   return -EINVAL;
+
+   if (format-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh,
+   format-pad, format-format,
+   format-which);
+   }
+
+   case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
+   struct v4l2_subdev_pad_mbus_code_enum *code = arg;
+
+   if (code-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh,
+   code);
+   }
+
+   case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
+   struct v4l2_subdev_frame_size_enum *fse = arg;
+
+   if (fse-pad = sd-entity.num_pads)
+   return -EINVAL;
+
+   return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh,
+   fse);
+   }
+
default:
return -ENOIOCTLCMD;
}
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
new file mode 100644
index 000..6504f22
--- /dev/null
+++ b/include/linux/v4l2-subdev.h
@@ -0,0 +1,66 @@
+/*
+ * V4L2 subdev userspace API
+ *
+ * Copyright (C) 2010 Nokia
+ *
+ * Contributors:
+ * Laurent Pinchart laurent.pinch...@ideasonboard.com
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef __LINUX_V4L2_SUBDEV_H
+#define __LINUX_V4L2_SUBDEV_H
+
+#include linux/ioctl.h
+#include linux/v4l2-mediabus.h
+
+enum v4l2_subdev_format {
+   V4L2_SUBDEV_FORMAT_PROBE = 0,
+   V4L2_SUBDEV_FORMAT_ACTIVE = 1,
+};
+
+/**
+ * struct v4l2_subdev_pad_format
+ */
+struct v4l2_subdev_pad_format {
+   __u32 which;
+   __u32 pad;
+   struct v4l2_mbus_framefmt format;
+};
+
+/**
+ * struct v4l2_subdev_pad_mbus_code_enum
+ */
+struct v4l2_subdev_pad_mbus_code_enum {
+   __u32 pad;
+   __u32 index;
+   __u32 code;
+   __u32 reserved[5];
+};
+
+struct v4l2_subdev_frame_size_enum {
+   __u32 index;
+   __u32 pad;
+   __u32 code;
+   __u32 min_width;
+   __u32 max_width;
+   __u32 min_height;
+   __u32 max_height;
+   __u32 reserved[9];
+};
+
+#define VIDIOC_SUBDEV_G_FMT_IOWR('V',  4, struct v4l2_subdev_pad_format)
+#define VIDIOC_SUBDEV_S_FMT_IOWR('V',  5, struct v4l2_subdev_pad_format)
+#define VIDIOC_SUBDEV_ENUM_MBUS_CODE \
+ 

[SAMPLE v3 04/12] v4l-subdev: Add pads operations

2010-07-29 Thread Laurent Pinchart
Add a v4l2_subdev_pad_ops structure for the operations that need to be
performed at the pad level such as format-related operations.

The format at the output of a subdev usually depends on the format at
its input(s). The try format operation is thus not suitable for probing
format at individual pads, as it can't modify the device state and thus
can't remember the format probed at the input to compute the output
format.

To fix the problem, pass an extra argument to the get/set format
operations to select the 'probe' or 'active' format.

The probe format is used when probing the subdev. Setting the probe
format must not change the device configuration but can store data for
later reuse. Data storage is provided at the file-handle level so
applications probing the subdev concurently won't interfere with each
other.

The active format is used when configuring the subdev. It's identical to
the format handled by the usual get/set operations.

Pad format-related operations use v4l2_mbus_framefmt instead of
v4l2_format.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/media/v4l2-subdev.h |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 01b4135..684ab60 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -41,6 +41,7 @@ struct v4l2_device;
 struct v4l2_event_subscription;
 struct v4l2_fh;
 struct v4l2_subdev;
+struct v4l2_subdev_fh;
 struct tuner_setup;
 
 /* decode_vbi_line */
@@ -398,6 +399,25 @@ struct v4l2_subdev_ir_ops {
struct v4l2_subdev_ir_parameters *params);
 };
 
+enum v4l2_subdev_format {
+   V4L2_SUBDEV_FORMAT_PROBE = 0,
+   V4L2_SUBDEV_FORMAT_ACTIVE = 1,
+};
+
+struct v4l2_subdev_pad_ops {
+   int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_pad_mbus_code_enum *code);
+   int (*enum_frame_size)(struct v4l2_subdev *sd,
+  struct v4l2_subdev_fh *fh,
+  struct v4l2_subdev_frame_size_enum *fse);
+   int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+  unsigned int pad, struct v4l2_mbus_framefmt *fmt,
+  enum v4l2_subdev_format which);
+   int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+  unsigned int pad, struct v4l2_mbus_framefmt *fmt,
+  enum v4l2_subdev_format which);
+};
+
 struct v4l2_subdev_ops {
const struct v4l2_subdev_core_ops   *core;
const struct v4l2_subdev_tuner_ops  *tuner;
@@ -406,6 +426,7 @@ struct v4l2_subdev_ops {
const struct v4l2_subdev_vbi_ops*vbi;
const struct v4l2_subdev_ir_ops *ir;
const struct v4l2_subdev_sensor_ops *sensor;
+   const struct v4l2_subdev_pad_ops*pad;
 };
 
 #define V4L2_SUBDEV_NAME_SIZE 32
-- 
1.7.1

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


[RFC/PATCH v3 09/10] v4l: Make video_device inherit from media_entity

2010-07-29 Thread Laurent Pinchart
V4L2 devices are media entities. As such they need to inherit from
(include) the media_entity structure.

When registering/unregistering the device, the media entity is
automatically registered/unregistered. The entity is acquired on device
open and released on device close.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 Documentation/video4linux/v4l2-framework.txt |   38 +++--
 drivers/media/video/v4l2-dev.c   |   35 ++-
 include/media/v4l2-dev.h |6 
 3 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index 8a3f14e..7ff4016 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -71,6 +71,10 @@ sub-device instances, the video_device struct stores V4L2 
device node data
 and in the future a v4l2_fh struct will keep track of filehandle instances
 (this is not yet implemented).
 
+The V4L2 framework also optionally integrates with the media framework. If a
+driver sets the struct v4l2_device mdev field, sub-devices and video nodes
+will automatically appear in the media framework as entities.
+
 
 struct v4l2_device
 --
@@ -84,11 +88,14 @@ You must register the device instance:
v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
 
 Registration will initialize the v4l2_device struct. If the dev-driver_data
-field is NULL, it will be linked to v4l2_dev. Drivers that use the media
-device framework in addition to the V4L2 framework need to set
+field is NULL, it will be linked to v4l2_dev.
+
+Drivers that want integration with the media device framework need to set
 dev-driver_data manually to point to the driver-specific device structure
 that embed the struct v4l2_device instance. This is achieved by a
-dev_set_drvdata() call before registering the V4L2 device instance.
+dev_set_drvdata() call before registering the V4L2 device instance. They must
+also set the struct v4l2_device mdev field to point to a properly initialized
+and registered media_device instance.
 
 If v4l2_dev-name is empty then it will be set to a value derived from dev
 (driver name followed by the bus_id, to be precise). If you set it up before
@@ -523,6 +530,21 @@ If you use v4l2_ioctl_ops, then you should set either 
.unlocked_ioctl or
 The v4l2_file_operations struct is a subset of file_operations. The main
 difference is that the inode argument is omitted since it is never used.
 
+If integration with the media framework is needed, you must initialize the
+media_entity struct embedded in the video_device struct (entity field) by
+calling media_entity_init():
+
+   struct media_pad *pad = my_vdev-pad;
+   int err;
+
+   err = media_entity_init(vdev-entity, 1, pad, 0);
+
+The pads array must have been previously initialized. There is no need to
+manually set the struct media_entity type and name fields.
+
+A reference to the entity will be automatically acquired/released when the
+video device is opened/closed.
+
 
 video_device registration
 -
@@ -536,6 +558,9 @@ for you.
return err;
}
 
+If the v4l2_device parent device has a non-NULL mdev field, the video device
+entity will be automatically registered with the media device.
+
 Which device is registered depends on the type argument. The following
 types exist:
 
@@ -613,6 +638,13 @@ those will still be passed on since some buffer ioctls may 
still be needed.
 When the last user of the video device node exits, then the vdev-release()
 callback is called and you can do the final cleanup there.
 
+Don't forget to cleanup the media entity associated with the video device if
+it has been initialized:
+
+   media_entity_cleanup(vdev-entity);
+
+This can be done from the release callback.
+
 
 video_device helper functions
 -
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index bcd47a0..0cbd3e6 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -269,6 +269,7 @@ static int v4l2_mmap(struct file *filp, struct 
vm_area_struct *vm)
 static int v4l2_open(struct inode *inode, struct file *filp)
 {
struct video_device *vdev;
+   struct media_entity *entity = NULL;
int ret = 0;
 
/* Check if the video device is available */
@@ -283,12 +284,23 @@ static int v4l2_open(struct inode *inode, struct file 
*filp)
/* and increase the device refcount */
video_get(vdev);
mutex_unlock(videodev_lock);
+   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev) {
+   entity = media_entity_get(vdev-entity);
+   if (!entity) {
+   ret = -EBUSY;
+   video_put(vdev);
+

[RFC/PATCH v3 08/10] v4l: Add a media_device pointer to the v4l2_device structure

2010-07-29 Thread Laurent Pinchart
The pointer will later be used to register/unregister media entities
when registering/unregistering a v4l2_subdev or a video_device.

With the introduction of media devices, device drivers need to store a
pointer to a driver-specific structure in the device's drvdata.
v4l2_device can't claim ownership of the drvdata anymore.

To maintain compatibility with drivers that rely on v4l2_device storing
a pointer to itself in the device's drvdata, v4l2_device_register() will
keep doing so if the drvdata is NULL.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/video4linux/v4l2-framework.txt |   17 -
 drivers/media/video/v4l2-device.c|   13 +++--
 include/media/v4l2-device.h  |2 ++
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index 89bd881..8a3f14e 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -83,11 +83,17 @@ You must register the device instance:
 
v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
 
-Registration will initialize the v4l2_device struct and link dev-driver_data
-to v4l2_dev. If v4l2_dev-name is empty then it will be set to a value derived
-from dev (driver name followed by the bus_id, to be precise). If you set it
-up before calling v4l2_device_register then it will be untouched. If dev is
-NULL, then you *must* setup v4l2_dev-name before calling v4l2_device_register.
+Registration will initialize the v4l2_device struct. If the dev-driver_data
+field is NULL, it will be linked to v4l2_dev. Drivers that use the media
+device framework in addition to the V4L2 framework need to set
+dev-driver_data manually to point to the driver-specific device structure
+that embed the struct v4l2_device instance. This is achieved by a
+dev_set_drvdata() call before registering the V4L2 device instance.
+
+If v4l2_dev-name is empty then it will be set to a value derived from dev
+(driver name followed by the bus_id, to be precise). If you set it up before
+calling v4l2_device_register then it will be untouched. If dev is NULL, then
+you *must* setup v4l2_dev-name before calling v4l2_device_register.
 
 You can use v4l2_device_set_name() to set the name based on a driver name and
 a driver-global atomic_t instance. This will generate names like ivtv0, ivtv1,
@@ -108,6 +114,7 @@ You unregister with:
 
v4l2_device_unregister(struct v4l2_device *v4l2_dev);
 
+If the dev-driver_data field points to v4l2_dev, it will be reset to NULL.
 Unregistering will also automatically unregister all subdevs from the device.
 
 If you have a hotpluggable device (e.g. a USB device), then when a disconnect
diff --git a/drivers/media/video/v4l2-device.c 
b/drivers/media/video/v4l2-device.c
index b287aaa..91452cd 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -45,9 +45,8 @@ int v4l2_device_register(struct device *dev, struct 
v4l2_device *v4l2_dev)
if (!v4l2_dev-name[0])
snprintf(v4l2_dev-name, sizeof(v4l2_dev-name), %s %s,
dev-driver-name, dev_name(dev));
-   if (dev_get_drvdata(dev))
-   v4l2_warn(v4l2_dev, Non-NULL drvdata on register\n);
-   dev_set_drvdata(dev, v4l2_dev);
+   if (!dev_get_drvdata(dev))
+   dev_set_drvdata(dev, v4l2_dev);
return 0;
 }
 EXPORT_SYMBOL_GPL(v4l2_device_register);
@@ -70,10 +69,12 @@ EXPORT_SYMBOL_GPL(v4l2_device_set_name);
 
 void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)
 {
-   if (v4l2_dev-dev) {
+   if (v4l2_dev-dev == NULL)
+   return;
+
+   if (dev_get_drvdata(v4l2_dev-dev) == v4l2_dev)
dev_set_drvdata(v4l2_dev-dev, NULL);
-   v4l2_dev-dev = NULL;
-   }
+   v4l2_dev-dev = NULL;
 }
 EXPORT_SYMBOL_GPL(v4l2_device_disconnect);
 
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 5d5d550..83b5966 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -21,6 +21,7 @@
 #ifndef _V4L2_DEVICE_H
 #define _V4L2_DEVICE_H
 
+#include media/media-device.h
 #include media/v4l2-subdev.h
 
 /* Each instance of a V4L2 device should create the v4l2_device struct,
@@ -37,6 +38,7 @@ struct v4l2_device {
   Note: dev might be NULL if there is no parent device
   as is the case with e.g. ISA devices. */
struct device *dev;
+   struct media_device *mdev;
/* used to keep track of the registered subdevs */
struct list_head subdevs;
/* lock this struct; can be used by the driver as well if this
-- 
1.7.1

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


[RFC/PATCH v3 07/10] media: Links setup

2010-07-29 Thread Laurent Pinchart
Create the following ioctl and implement it at the media device level to
setup links.

- MEDIA_IOC_SETUP_LINK: Modify the properties of a given link

The only property that can currently be modified is the ACTIVE link flag
to activate/deactivate a link. Links marked with the IMMUTABLE link flag
can not be activated or deactivated.

Activating and deactivating a link has effects on entities' use count.
Those changes are automatically propagated through the graph.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Stanimir Varbanov svarba...@mm-sol.com
Signed-off-by: Sakari Ailus sakari.ai...@maxwell.research.nokia.com
---
 Documentation/media-framework.txt |   83 ++-
 drivers/media/media-device.c  |   45 
 drivers/media/media-entity.c  |  208 +
 include/linux/media.h |1 +
 include/media/media-entity.h  |8 ++
 5 files changed, 341 insertions(+), 4 deletions(-)

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index 1192feb..7001a94 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -236,6 +236,16 @@ When the graph traversal is complete the function will 
return NULL.
 Graph traversal can be interrupted at any moment. No cleanup function call is
 required and the graph structure can be freed normally.
 
+Helper functions can be used to find a link between two given pads, or a pad
+connected to another pad through an active link
+
+   media_entity_find_link(struct media_pad *source,
+  struct media_pad *sink);
+
+   media_entity_remote_pad(struct media_pad *pad);
+
+Refer to the kerneldoc documentation for more information.
+
 
 Reference counting and power handling
 -
@@ -274,11 +284,51 @@ is allowed to fail when turning power on, in which case 
the media_entity_get
 function will return NULL.
 
 
+Links setup
+---
+
+Link properties can be modified at runtime by calling
+
+   media_entity_setup_link(struct media_link *link, u32 flags);
+
+The flags argument contains the requested new link flags.
+
+The only configurable property is the ACTIVE link flag to activate/deactivate
+a link. Links marked with the IMMUTABLE link flag can not be activated or
+deactivated.
+
+When a link is activated or deactivated, the media framework calls the
+link_setup operation for the two entities at the source and sink of the link,
+in that order. If the second link_setup call fails, another link_setup call is
+made on the first entity to restore the original link flags.
+
+Entity drivers must implement the link_setup operation if any of their links
+is non-immutable. The operation must either configure the hardware or store
+the configuration information to be applied later.
+
+Link activation must not have any side effect on other links. If an active
+link at a sink pad prevents another link at the same pad from being
+deactivated, the link_setup operation must return -EBUSY and can't implicitly
+deactivate the first active link.
+
+Activating and deactivating a link has effects on entities' reference counts.
+When two sub-graphs are connected, the reference count of each of them is
+incremented by the total reference count of all node entities in the other
+sub-graph. When two sub-graphs are disconnected, the reverse operation is
+performed. In both cases the set_power operations are called accordingly,
+ensuring that the link_setup calls are made with power active on the source
+and sink entities.
+
+In other words, activating or deactivating a link propagates reference count
+changes through the graph, and the final state is identical to what it would
+have been if the link had been active or inactive from the start.
+
+
 Userspace application API
 -
 
 Media devices offer an API to userspace application to discover the device
-internal topology through ioctls.
+internal topology and setup links through ioctls.
 
MEDIA_IOC_ENUM_ENTITIES - Enumerate entities and their properties
-
@@ -345,9 +395,6 @@ Valid entity types are
 
ioctl(int fd, int request, struct media_links_enum *argp);
 
-Only forward links that originate at one of the entity's source pads are
-returned during the enumeration process.
-
 To enumerate pads and/or links for a given entity, applications set the entity
 field of a media_links_enum structure and initialize the media_pad_desc and
 media_link_desc structure arrays pointed by the pads and links fields. They 
then
@@ -363,6 +410,9 @@ information about the entity's outbound links. The array 
must have enough room
 to store all the entity's outbound links. The number of outbound links can be
 retrieved with the MEDIA_IOC_ENUM_ENTITIES ioctl.
 
+Only outbound (forward) links that originate at one of the entity's source

[RFC/PATCH v3 02/10] media: Media device

2010-07-29 Thread Laurent Pinchart
The media_device structure abstracts functions common to all kind of
media devices (v4l2, dvb, alsa, ...). It manages media entities and
offers a userspace API to discover and configure the media device
internal topology.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/media-framework.txt |   68 +
 drivers/media/Makefile|2 +-
 drivers/media/media-device.c  |   76 +
 include/media/media-device.h  |   48 +++
 4 files changed, 193 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/media-framework.txt
 create mode 100644 drivers/media/media-device.c
 create mode 100644 include/media/media-device.h

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
new file mode 100644
index 000..b942c8f
--- /dev/null
+++ b/Documentation/media-framework.txt
@@ -0,0 +1,68 @@
+Linux kernel media framework
+
+
+This document describes the Linux kernel media framework, its data structures,
+functions and their usage.
+
+
+Introduction
+
+
+Media devices increasingly handle multiple related functions. Many USB cameras
+include microphones, video capture hardware can also output video, or SoC
+camera interfaces also perform memory-to-memory operations similar to video
+codecs.
+
+Independent functions, even when implemented in the same hardware, can be
+modeled by separate devices. A USB camera with a microphone will be presented
+to userspace applications as V4L2 and ALSA capture devices. The devices
+relationships (when using a webcam, end-users shouldn't have to manually
+select the associated USB microphone), while not made available directly to
+applications by the drivers, can usually be retrieved from sysfs.
+
+With more and more advanced SoC devices being introduced, the current approach
+will not scale. Device topologies are getting increasingly complex and can't
+always be represented by a tree structure. Hardware blocks are shared between
+different functions, creating dependencies between seemingly unrelated
+devices.
+
+Kernel abstraction APIs such as V4L2 and ALSA provide means for applications
+to access hardware parameters. As newer hardware expose an increasingly high
+number of those parameters, drivers need to guess what applications really
+require based on limited information, thereby implementing policies that
+belong to userspace.
+
+The media kernel API aims at solving those problems.
+
+
+Media device
+
+
+A media device is represented by a struct media_device instance, defined in
+include/media/media-device.h. Allocation of the structure is handled by the
+media device driver, usually by embedding the media_device instance in a
+larger driver-specific structure.
+
+Drivers register media device instances by calling
+
+   media_device_register(struct media_device *mdev);
+
+The caller is responsible for initializing the media_device structure before
+registration. The following fields must be set:
+
+ - dev should point to the parent device (usually a pci_dev, usb_interface or
+   platform_device instance). In the rare case when no parent device is
+   available (with ISA devices for instance), the field can be set to NULL.
+ - name should be set to the device name. If the name is empty a parent device
+   must be set. In that case the name will be set to the parent device driver
+   name followed by a space and the parent device name.
+
+Upon successful registration a character device named media[0-9]+ is created.
+The device major and minor numbers are dynamic.
+
+Drivers unregister media device instances by calling
+
+   media_device_unregister(struct media_device *mdev);
+
+Unregistering a media device that hasn't been registered is *NOT* safe.
+
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index c1b5938..f8d8dcb 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
-media-objs := media-devnode.o
+media-objs := media-device.o media-devnode.o
 
 obj-$(CONFIG_MEDIA_SUPPORT)+= media.o
 
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
new file mode 100644
index 000..75eaccd
--- /dev/null
+++ b/drivers/media/media-device.c
@@ -0,0 +1,76 @@
+/*
+ *  Media device support.
+ *
+ *  Copyright (C) 2010  Laurent Pinchart laurent.pinch...@ideasonboard.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; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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
+ 

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 11:38 -0400, Andy Walls wrote: 
 On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote: 
   Hi Maxim,
   
   on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
   [...]
In addition to comments, I changed helper function that processes 
samples
so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row.
However, if it uses timeout reports (which are now fully supported)
it will get such report in middle.
   
Note that I send timeout report with zero value.
I don't think that this value is importaint.
   
   This does not sound good. Of course the value is important to userspace  
   and 2 spaces in a row will break decoding.
   
   Christoph
  
  Could you explain exactly how timeout reports work?
  
  Lirc interface isn't set to stone, so how about a reasonable compromise.
  After reasonable long period of inactivity (200 ms for example), space
  is sent, and then next report starts with a pulse.
  So gaps between keypresses will be maximum of 200 ms, and as a bonus I
  could rip of the logic that deals with remembering the time?
  
  Best regards,
  Maxim Levitsky

So, timeout report is just another sample, with a mark attached, that
this is last sample? right?

Christoph, right?

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report.
Then next keypress will start with pulse.

I think this is the best solution.

Best regards,
Maxim Levitsky

--
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: linux-next: Tree for July 28 (lirc #2)

2010-07-29 Thread Randy Dunlap
On 07/29/10 05:39, Janne Grunau wrote:
 On Thu, Jul 29, 2010 at 12:27:01AM -0400, Jarod Wilson wrote:
 On Wed, Jul 28, 2010 at 6:27 PM, Jarod Wilson ja...@wilsonet.com wrote:
 On Wed, Jul 28, 2010 at 6:16 PM, Randy Dunlap randy.dun...@oracle.com 
 wrote:
 On 07/28/10 15:04, Janne Grunau wrote:
 On Wed, Jul 28, 2010 at 10:24:17AM -0700, Randy Dunlap wrote:
 On Wed, 28 Jul 2010 16:28:55 +1000 Stephen Rothwell wrote:

 Hi all,

 Changes since 20100727:


 When USB_SUPPORT is not enabled and MEDIA_SUPPORT is not enabled:


 following patch should fix it

 Janne

 Acked-by: Randy Dunlap randy.dun...@oracle.com

 Thanks.

 Acked-by: Jarod Wilson ja...@redhat.com

 Indeed, thanks much, Janne!

 D'oh, I should have looked a bit closer... What if instead of making
 all the drivers depend on both LIRC  LIRC_STAGING, LIRC_STAGING just
 depends on LIRC?
 
 I started adding LIRC to each driver by one. Adding LIRC as LIRC_STAGING
 dependency is simpler. See updated patch.
 
 And there are a few depends lines with duplicate
 USB's in them and LIRC_IMON should have USB added to it (technically,
 
 D'oh, I've must have stopped reading after LIRC_STAG...
 
 fixed and added additional dependencies
 
 Janne

Yes, this one works also.  Thanks for the update.

 
 From 45d384de90e3709a986700db14888eff77bb7e1f Mon Sep 17 00:00:00 2001
 From: Janne Grunau j...@jannau.net
 Date: Wed, 28 Jul 2010 23:53:35 +0200
 Subject: [PATCH 1/2] V4L/DVB: staging/lirc: fix Kconfig dependencies
 
 Signed-off-by: Janne Grunau j...@jannau.net
 ---
  drivers/staging/lirc/Kconfig |   19 ++-
  1 files changed, 10 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/staging/lirc/Kconfig b/drivers/staging/lirc/Kconfig
 index 968c2ade..ab30a09 100644
 --- a/drivers/staging/lirc/Kconfig
 +++ b/drivers/staging/lirc/Kconfig
 @@ -3,6 +3,7 @@
  #
  menuconfig LIRC_STAGING
   bool Linux Infrared Remote Control IR receiver/transmitter drivers
 + depends on LIRC
   help
 Say Y here, and all supported Linux Infrared Remote Control IR and
 RF receiver and transmitter drivers will be displayed. When paired
 @@ -13,13 +14,13 @@ if LIRC_STAGING
  
  config LIRC_BT829
  tristate BT829 based hardware
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  PCI
   help
 Driver for the IR interface on BT829-based hardware
  
  config LIRC_ENE0100
   tristate ENE KB3924/ENE0100 CIR Port Reciever
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  PNP
   help
 This is a driver for CIR port handled by ENE KB3924 embedded
 controller found on some notebooks.
 @@ -27,7 +28,7 @@ config LIRC_ENE0100
  
  config LIRC_I2C
   tristate I2C Based IR Receivers
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  I2C
   help
 Driver for I2C-based IR receivers, such as those commonly
 found onboard Hauppauge PVR-150/250/350 video capture cards
 @@ -40,7 +41,7 @@ config LIRC_IGORPLUGUSB
  
  config LIRC_IMON
   tristate Legacy SoundGraph iMON Receiver and Display
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  USB
   help
 Driver for the original SoundGraph iMON IR Receiver and Display
  
 @@ -48,7 +49,7 @@ config LIRC_IMON
  
  config LIRC_IT87
   tristate ITE IT87XX CIR Port Receiver
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  PNP
   help
 Driver for the ITE IT87xx IR Receiver
  
 @@ -60,13 +61,13 @@ config LIRC_ITE8709
  
  config LIRC_PARALLEL
   tristate Homebrew Parallel Port Receiver
 - depends on LIRC_STAGING  !SMP
 + depends on LIRC_STAGING  PARPORT  !SMP
   help
 Driver for Homebrew Parallel Port Receivers
  
  config LIRC_SASEM
   tristate Sasem USB IR Remote
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  USB
   help
 Driver for the Sasem OnAir Remocon-V or Dign HV5 HTPC IR/VFD Module
  
 @@ -91,7 +92,7 @@ config LIRC_SIR
  
  config LIRC_STREAMZAP
   tristate Streamzap PC Receiver
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  USB
   help
 Driver for the Streamzap PC Receiver
  
 @@ -103,7 +104,7 @@ config LIRC_TTUSBIR
  
  config LIRC_ZILOG
   tristate Zilog/Hauppauge IR Transmitter
 - depends on LIRC_STAGING
 + depends on LIRC_STAGING  I2C
   help
 Driver for the Zilog/Hauppauge IR Transmitter, found on
 PVR-150/500, HVR-1200/1250/1700/1800, HD-PVR and other cards


-- 
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
--
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] staging/lirc: fix non-CONFIG_MODULES build horkage

2010-07-29 Thread Randy Dunlap
On 07/29/10 08:35, Jarod Wilson wrote:
 Fix when CONFIG_MODULES is not enabled:
 
 drivers/staging/lirc/lirc_parallel.c:243: error: implicit declaration of 
 function 'module_refcount'
 drivers/staging/lirc/lirc_it87.c:150: error: implicit declaration of function 
 'module_refcount'
 drivers/built-in.o: In function `it87_probe':
 lirc_it87.c:(.text+0x4079b0): undefined reference to `init_chrdev'
 lirc_it87.c:(.text+0x4079cc): undefined reference to `drop_chrdev'
 drivers/built-in.o: In function `lirc_it87_exit':
 lirc_it87.c:(.exit.text+0x38a5): undefined reference to `drop_chrdev'
 
 Its a quick hack and untested beyond building, since I don't have the
 hardware, but it should do the trick.
 
 Signed-off-by: Jarod Wilson ja...@redhat.com

Acked-by: Randy Dunlap randy.dun...@oracle.com

Thanks.

 ---
  drivers/staging/lirc/lirc_it87.c |9 ++---
  drivers/staging/lirc/lirc_parallel.c |4 ++--
  2 files changed, 8 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/staging/lirc/lirc_it87.c 
 b/drivers/staging/lirc/lirc_it87.c
 index 781abc3..72f07f1 100644
 --- a/drivers/staging/lirc/lirc_it87.c
 +++ b/drivers/staging/lirc/lirc_it87.c
 @@ -109,6 +109,7 @@ static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue);
  
  static DEFINE_SPINLOCK(hardware_lock);
  static DEFINE_SPINLOCK(dev_lock);
 +static bool device_open;
  
  static int rx_buf[RBUF_LEN];
  unsigned int rx_tail, rx_head;
 @@ -147,10 +148,11 @@ static void drop_port(void);
  static int lirc_open(struct inode *inode, struct file *file)
  {
   spin_lock(dev_lock);
 - if (module_refcount(THIS_MODULE)) {
 + if (device_open) {
   spin_unlock(dev_lock);
   return -EBUSY;
   }
 + device_open = true;
   spin_unlock(dev_lock);
   return 0;
  }
 @@ -158,6 +160,9 @@ static int lirc_open(struct inode *inode, struct file 
 *file)
  
  static int lirc_close(struct inode *inode, struct file *file)
  {
 + spin_lock(dev_lock);
 + device_open = false;
 + spin_unlock(dev_lock);
   return 0;
  }
  
 @@ -363,7 +368,6 @@ static struct lirc_driver driver = {
  };
  
  
 -#ifdef MODULE
  static int init_chrdev(void)
  {
   driver.minor = lirc_register_driver(driver);
 @@ -380,7 +384,6 @@ static void drop_chrdev(void)
  {
   lirc_unregister_driver(driver.minor);
  }
 -#endif
  
  
  /* SECTION: Hardware */
 diff --git a/drivers/staging/lirc/lirc_parallel.c 
 b/drivers/staging/lirc/lirc_parallel.c
 index df12e7b..04ce97713 100644
 --- a/drivers/staging/lirc/lirc_parallel.c
 +++ b/drivers/staging/lirc/lirc_parallel.c
 @@ -240,7 +240,7 @@ static void irq_handler(void *blah)
   unsigned int level, newlevel;
   unsigned int timeout;
  
 - if (!module_refcount(THIS_MODULE))
 + if (!is_open)
   return;
  
   if (!is_claimed)
 @@ -515,7 +515,7 @@ static long lirc_ioctl(struct file *filep, unsigned int 
 cmd, unsigned long arg)
  
  static int lirc_open(struct inode *node, struct file *filep)
  {
 - if (module_refcount(THIS_MODULE) || !lirc_claim())
 + if (is_open || !lirc_claim())
   return -EBUSY;
  
   parport_enable_irq(pport);
 
 


-- 
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2]videobuf_dma_sg: a new implementation for mmap

2010-07-29 Thread Mauro Carvalho Chehab
Em 29-07-2010 10:38, Figo.zhang escreveu:

 btw, why i send the patch , patchwork websit display a part of my patch?
 https://patchwork.kernel.org/patch/114760/

Because your emailer broke long lines, mangling part of your patch. The way
you sent, it will fail to apply.

Please, re-send it, being sure that your emailer won't break long lines.

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


Re: gspca_zc3xx module

2010-07-29 Thread Jean-Francois Moine
On Thu, 29 Jul 2010 12:21:21 +
Hasan SAHIN hasan.sa...@gmx.com wrote:

   Hello Jean-Francois,
 
 I am using Gentoo linux stable x86 with kernel 2.6.34-r1.
 before the kernel update to 2.6.34-r1, I was using 2.6.32-r7 and
 there was no problem with webcam.
 The webcam was working as good with kernel 2.6.32-r7(old gentoo
 stable kernel)
 but right now it does not work with the kernel 2.6.34-r1 (new gentoo 
 stable kernel)
 
 And also I have tried with ubuntu 10.04 (kernel 2.6.32-25) and
 working good. I could not understood what is the problem. (Problem
 is : there is no output, no stream)
[snip]
 gspca: probing 0ac8:303b
 zc3xx: probe 2wr ov vga 0x
 zc3xx: probe 3wr vga 1 0xc001
 zc3xx: probe sensor - 0013
 zc3xx: Find Sensor MI0360SOC. Chip revision c001
[snip]

Hello Hasan,

In the kernel 2.6.34, the sensor mi0360soc sequences have been changed
to make the webcams 0ac8:301b work, but these sequences are wrong for
the webcams 0ac8:303b.

An other user is testing the fix which is in my test tarball (see my
home page below - current version 2.10.4). There is just one remaining
problem: the image is mirrored, and I have not found yet how to set it
normal...

Best regards.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/
--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Andy Walls
On Thu, 2010-07-29 at 19:26 +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 11:38 -0400, Andy Walls wrote: 
  On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
   On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote: 
Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]
 In addition to comments, I changed helper function that processes 
 samples
 so it sends last space as soon as timeout is reached.
 This breaks somewhat lirc, because now it gets 2 spaces in row.
 However, if it uses timeout reports (which are now fully supported)
 it will get such report in middle.

 Note that I send timeout report with zero value.
 I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace 
 
and 2 spaces in a row will break decoding.

Christoph
   
   Could you explain exactly how timeout reports work?
   
   Lirc interface isn't set to stone, so how about a reasonable compromise.
   After reasonable long period of inactivity (200 ms for example), space
   is sent, and then next report starts with a pulse.
   So gaps between keypresses will be maximum of 200 ms, and as a bonus I
   could rip of the logic that deals with remembering the time?
   
   Best regards,
   Maxim Levitsky
 
 So, timeout report is just another sample, with a mark attached, that
 this is last sample? right?

On a measurement timeout, the Conexant hardware RX FIFO has this special
timer overflow value in it as the last measurement:

value = 0x1 = a mark with a measurement of 65535 * 4 clocks

(and the measurement before this one in the FIFO is usually the last
actual mark received). 

I ultimately translate that to

pulse = false;  /* a space */
duration = 0x7fff;  /* 2.147 seconds */

to give the in kernel decoders a final space.

What is lost is the actual space measurement by the hardware (whatever
65535 * 4 Rx clocks is), before the timeout.

If LIRC likes to measure intertransmission gaps, what I am currently
doing will not give LIRC a reasonable gap estimate/measurement, if the
timeout is shorter than the actual gap.

 Christoph, right?
 
 In that case, lets do that this way:
 
 As soon as timeout is reached, I just send lirc the timeout report.
 Then next keypress will start with pulse.
 
 I think this is the best solution.

I'm flexible.  I don't know LIRC internals well enough to know what's
best.  I suspect sending a valid space measurement of the timeout,
before the timeout report, may be useful for LIRC to obtain information
on the gaps that are longer than the hardware timeout.

Regards,
Andy

 Best regards,
 Maxim Levitsky
 


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


Re: [PATCH v2]videobuf_dma_sg: a new implementation for mmap

2010-07-29 Thread Laurent Pinchart
Hi,
On Wednesday 28 July 2010 15:08:24 Figo.zhang wrote:
 a mmap issue for videobuf-dma-sg: it will alloc a new page for mmaping
 when it encounter page fault at video_vm_ops-fault().
 
 a new implementation for mmap, it translate the vmalloc to page at
 video_vm_ops-fault().
 
 in v2, if mem-dma.vmalloc is NULL at video_vm_ops-fault(), it will
 alloc memory by vmalloc_32().


Can you please elaborate on what you're trying to do ? What problem is this 
patch supposed to fix ?

 Signed-off-by: Figo.zhang figo1...@gmail.com
 ---
 drivers/media/video/videobuf-dma-sg.c |   51
 +++--
  1 files changed, 42 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/media/video/videobuf-dma-sg.c
 b/drivers/media/video/videobuf-dma-sg.c
 index 8359e6b..767483d 100644
 --- a/drivers/media/video/videobuf-dma-sg.c
 +++ b/drivers/media/video/videobuf-dma-sg.c
 @@ -201,10 +201,11 @@ int videobuf_dma_init_kernel(struct
 videobuf_dmabuf *dma, int direction,
   dprintk(1, init kernel [%d pages]\n, nr_pages);
 
   dma-direction = direction;
 - dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
 - if (NULL == dma-vmalloc) {
 - dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
 - return -ENOMEM;
 + if (!dma-vmalloc)
 + dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
 + if (NULL == dma-vmalloc) {
 + dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
 + return -ENOMEM;
   }
 
   dprintk(1, vmalloc is at addr 0x%08lx, size=%d\n,
 @@ -397,16 +398,48 @@ static void videobuf_vm_close(struct
 vm_area_struct *vma)
   */
  static int videobuf_vm_fault(struct vm_area_struct *vma, struct
 vm_fault *vmf)
  {
 - struct page *page;
 + struct page *page = NULL;
 + struct videobuf_mapping *map = vma-vm_private_data;
 + struct videobuf_queue *q = map-q;
 + struct videobuf_dma_sg_memory *mem = NULL;
 +
 + unsigned long offset;
 + unsigned long page_nr;
 + int first;
 
   dprintk(3, fault: fault @ %08lx [vma %08lx-%08lx]\n,
   (unsigned long)vmf-virtual_address,
   vma-vm_start, vma-vm_end);
 
 - page = alloc_page(GFP_USER | __GFP_DMA32);
 - if (!page)
 - return VM_FAULT_OOM;
 - clear_user_highpage(page, (unsigned long)vmf-virtual_address);
 + mutex_lock(q-vb_lock);
 +
 + offset = (unsigned long)vmf-virtual_address - vma-vm_start;
 + page_nr = offset  PAGE_SHIFT;
 +
 + for (first = 0; first  VIDEO_MAX_FRAME; first++) {
 + if (NULL == q-bufs[first])
 + continue;
 +
 + MAGIC_CHECK(mem-magic, MAGIC_SG_MEM);
 +
 + if (q-bufs[first]-map == map)
 + break;
 + }
 +
 + mem = q-bufs[first]-priv;
 + if (!mem)
 + return VM_FAULT_SIGBUS;
 + if (!mem-dma.vmalloc) {
 + mem-dma.vmalloc = vmalloc_32(PAGE_ALIGN(q-bufs[first]-size));
 + if (NULL == mem-dma.vmalloc) {
 + dprintk(1, %s: vmalloc_32() failed\n, __func__);
 + return VM_FAULT_OOM;
 + }
 + } else
 + page = vmalloc_to_page(mem-dma.vmalloc+
 + (offset  (~PAGE_MASK)));
 + mutex_unlock(q-vb_lock);
 +
   vmf-page = page;
 
   return 0;

-- 
Regards,

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


Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Christoph Bartelmus
Hi Andy,

on 29 Jul 10 at 11:38, Andy Walls wrote:
 On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote:
 Hi Maxim,

 on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
 [...]
 In addition to comments, I changed helper function that processes samples
 so it sends last space as soon as timeout is reached.
 This breaks somewhat lirc, because now it gets 2 spaces in row.
 However, if it uses timeout reports (which are now fully supported)
 it will get such report in middle.

 Note that I send timeout report with zero value.
 I don't think that this value is importaint.

 This does not sound good. Of course the value is important to userspace
 and 2 spaces in a row will break decoding.

 Christoph

 Could you explain exactly how timeout reports work?

 Lirc interface isn't set to stone, so how about a reasonable compromise.
 After reasonable long period of inactivity (200 ms for example), space
 is sent, and then next report starts with a pulse.
 So gaps between keypresses will be maximum of 200 ms, and as a bonus I
 could rip of the logic that deals with remembering the time?

 Best regards,
 Maxim Levitsky

 Just for some context, the Conexant hardware generates such reports on
 it's hardware Rx FIFO:

 From section 3.8.2.3 of

 http://dl.ivtvdriver.org/datasheets/video/cx25840.pdf

 When the demodulated input signal no longer transitions, the RX pulse
 width timer overflows, which indicates the end of data transmission.
 When this occurs, the timer value contains all 1s. This value can be
 stored to the RX FIFO, to indicate the end of the transmission [...].
 Additionally, a status bit is set which can interrupt the
 microprocessor, [...].

 So the value in the hardware RX FIFO is the maximum time measurable
 given the current hardware clock divider settings, plus a flag bit
 indicating overflow.

 The CX2388[58] IR implementation currently translates that hardware
 notification into V4L2_SUBDEV_IR_PULSE_RX_SEQ_END:

 http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx238
 85/cx23888-ir.c;h=51f21636e639330bcf528568c0f08c7a4a674f42;hb=094fc94360cf01
 960da3311698fedfca566d4712#l678

 which is defined here:

 http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=include/media/v4l2-subdev
 .h;h=bacd52568ef9fd17787554aa347f46ca6f23bdb2;hb=094fc94360cf01960da3311698f
 edfca566d4712#l366

 as

 #define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0x


 I didn't look too hard at it, but IIRC the in kernel decoders would have
 interpreted this value incorrectly (the longest possible mark).
 Instead, I just pass along the longest possible space:

 http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx238
 85/cx23885-input.c;h=3f924e21b9575f7d67d99d71c8585d41828aabfe;hb=094fc94360c
 f01960da3311698fedfca566d4712#l49

 so it acts as in band signaling if anyone is looking for it, and the in
 kernel decoders happily treat it like a long space.

 With a little work, I could pass the actual time it took for the Rx
 timer to timeout as well (Provide the space measurement *and* the in
 band signal), if needed.

The value for LIRC_MODE2_TIMEOUT needs to be the exact value of the acutal  
time passed since the last pulse. When you just send the longest possible  
space instead, you'll make repeat detection impossible.

Christoph

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Christoph Bartelmus
Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]
 Note that I send timeout report with zero value.
 I don't think that this value is importaint.

 This does not sound good. Of course the value is important to userspace
 and 2 spaces in a row will break decoding.

 Christoph

 Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably  
can point you where it can be found.
Timeout reports can only be generated by the hardware because only the  
hardware can know the exact amount of time passed since the last pulse  
when any kind of buffering is used by the hardware. You see this esp. with  
USB devices.

 Lirc interface isn't set to stone, so how about a reasonable compromise.
 After reasonable long period of inactivity (200 ms for example), space
 is sent, and then next report starts with a pulse.
 So gaps between keypresses will be maximum of 200 ms, and as a bonus I
 could rip of the logic that deals with remembering the time?

For sure I will not agree to any constant introduced here. And I also  
don't see why. Can you explain why you are trying to change the lirc  
interface here?

Christoph
--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Christoph Bartelmus
Hi Maxim,

on 29 Jul 10 at 19:26, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 11:38 -0400, Andy Walls wrote:
 On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote:
 Hi Maxim,

 on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
 [...]
 In addition to comments, I changed helper function that processes
 samples so it sends last space as soon as timeout is reached.
 This breaks somewhat lirc, because now it gets 2 spaces in row.
 However, if it uses timeout reports (which are now fully supported)
 it will get such report in middle.

 Note that I send timeout report with zero value.
 I don't think that this value is importaint.

 This does not sound good. Of course the value is important to userspace
 and 2 spaces in a row will break decoding.

 Christoph

 Could you explain exactly how timeout reports work?

 Lirc interface isn't set to stone, so how about a reasonable compromise.
 After reasonable long period of inactivity (200 ms for example), space
 is sent, and then next report starts with a pulse.
 So gaps between keypresses will be maximum of 200 ms, and as a bonus I
 could rip of the logic that deals with remembering the time?

 Best regards,
 Maxim Levitsky

 So, timeout report is just another sample, with a mark attached, that
 this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a  
specific amount of time has passed since the last pulse _now_.

[...]
 In that case, lets do that this way:

 As soon as timeout is reached, I just send lirc the timeout report.
 Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
pulse timeout space pulse
where timeout is optional.

lircd will not work when you leave out the space. It must know the exact  
time between the pulses. Some hardware generates timeout reports that are  
too short to distinguish between spaces that are so short that the next  
sequence can be interpreted as a repeat or longer spaces which indicate  
that this is a new key press.

Christoph
--
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 5/9] IR: extend interfaces to support more device settings

2010-07-29 Thread Christoph Bartelmus
Hi Maxim,

on 29 Jul 10 at 18:27, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 09:25 +0200, Christoph Bartelmus wrote:
 Hi!

 Maxim Levitsky maximlevit...@gmail.com wrote:

 Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE
 (LIRC_SET_LEARN_MODE will start carrier reports if possible, and
 tune receiver to wide band mode)

 I don't like the rename of the ioctl. The ioctl should enable carrier
 reports. Anything else is hardware specific. Learn mode gives a somewhat
 wrong association to me. irrecord always has been using learn mode
 without ever using this ioctl.

 Why?

If an ioctl enables/disables measuring of the carrier, then call it  
LIRC_SET_MEASURE_CARRIER_MODE and not LIRC_SET_LEARN_MODE.

Whether we need a LIRC_ENABLE_WIDE_BAND_RECEIVER ioctl is another  
question.

 Carrier measure (if supported by hardware I think should always be
 enabled, because it can help in-kernel decoders).

That does not work in the real-world scenario. All receivers with a high  
range demodulate the signal and you won't get the carrier.

[...]
 Another thing is reporting these results to lirc.
 By default lirc shouldn't get carrier reports, but as soon as irrecord
 starts, it can place device in special mode that allows it to capture
 input better, and optionally do carrier reports.

And that's what LIRC_SET_MEASURE_CARRIER_MODE is made for.

 Do you think carrier reports are needed by lircd?

No.

Christoph
--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 19:15 +0200, Christoph Bartelmus wrote: 
 Hi Maxim,
 
 on 29 Jul 10 at 19:26, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 11:38 -0400, Andy Walls wrote:
  On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote:
  Hi Maxim,
 
  on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
  [...]
  In addition to comments, I changed helper function that processes
  samples so it sends last space as soon as timeout is reached.
  This breaks somewhat lirc, because now it gets 2 spaces in row.
  However, if it uses timeout reports (which are now fully supported)
  it will get such report in middle.
 
  Note that I send timeout report with zero value.
  I don't think that this value is importaint.
 
  This does not sound good. Of course the value is important to userspace
  and 2 spaces in a row will break decoding.
 
  Christoph
 
  Could you explain exactly how timeout reports work?
 
  Lirc interface isn't set to stone, so how about a reasonable compromise.
  After reasonable long period of inactivity (200 ms for example), space
  is sent, and then next report starts with a pulse.
  So gaps between keypresses will be maximum of 200 ms, and as a bonus I
  could rip of the logic that deals with remembering the time?
 
  Best regards,
  Maxim Levitsky
 
  So, timeout report is just another sample, with a mark attached, that
  this is last sample? right?
 
 No, a timeout report is just an additional hint for the decoder that a  
 specific amount of time has passed since the last pulse _now_.
 
 [...]
  In that case, lets do that this way:
 
  As soon as timeout is reached, I just send lirc the timeout report.
  Then next keypress will start with pulse.
 
 When timeout reports are enabled the sequence must be:
 pulse timeout space pulse
 where timeout is optional.
 
 lircd will not work when you leave out the space. It must know the exact  
 time between the pulses. Some hardware generates timeout reports that are  
 too short to distinguish between spaces that are so short that the next  
 sequence can be interpreted as a repeat or longer spaces which indicate  
 that this is a new key press.

Let me give an example to see if I got that right.


Suppose we have this sequence of reports from the driver:

500 (pulse)
20 (timeout)
1 (space)
500 (pulse)


Is that correct that time between first and second pulse is
'10020' ?

Best regards,
Maxim Levitsky

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 18:58 +0200, Christoph Bartelmus wrote: 
 Hi Maxim,
 
 on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
 [...]
  Note that I send timeout report with zero value.
  I don't think that this value is importaint.
 
  This does not sound good. Of course the value is important to userspace
  and 2 spaces in a row will break decoding.
 
  Christoph
 
  Could you explain exactly how timeout reports work?
 
 It all should be documented in the interface description. Jarod probably  
 can point you where it can be found.
 Timeout reports can only be generated by the hardware because only the  
 hardware can know the exact amount of time passed since the last pulse  
 when any kind of buffering is used by the hardware. You see this esp. with  
 USB devices.
In my case hardware doesn't have that capability.
However, I though that timeout reports are useful to stop hardware as
soon at timeout it hit.


 
  Lirc interface isn't set to stone, so how about a reasonable compromise.
  After reasonable long period of inactivity (200 ms for example), space
  is sent, and then next report starts with a pulse.
  So gaps between keypresses will be maximum of 200 ms, and as a bonus I
  could rip of the logic that deals with remembering the time?
 
 For sure I will not agree to any constant introduced here. And I also  
 don't see why. Can you explain why you are trying to change the lirc  
 interface here?

Currently, to comply with strict lirc requirements I have to send one
big space between keypresses. Of course I can send it only when I get
next pulse, which might happen much later.

However, the in-kernel decoders depend on the last space to be sent
right away.
that it I need to and a keypress with a space, but currently it ends
with pulse.

So my idea was to wait reasonable time for next pulse, and if it doesn't
arrive, send a space mark even though no new pulse is registered.

Of course the size of that space can be configured.


Best regards,
Maxim Levitsky



--
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] v4l-dvb daily build 2.6.22 and up: ERRORS, 2.6.16-2.6.21: ERRORS

2010-07-29 Thread Hans Verkuil
This message is generated daily by a cron job that builds v4l-dvb for
the kernels and architectures in the list below.

Results of the daily build of v4l-dvb:

date:Thu Jul 29 19:00:16 CEST 2010
path:http://www.linuxtv.org/hg/v4l-dvb
changeset:   14993:9652f85e688a
git master:   f6760aa024199cfbce564311dc4bc4d47b6fb349
git media-master: 1c1371c2fe53ded8ede3a0404c9415fbf3321328
gcc version:  i686-linux-gcc (GCC) 4.4.3
host hardware:x86_64
host os:  2.6.32.5

linux-2.6.32.6-armv5: OK
linux-2.6.33-armv5: OK
linux-2.6.34-armv5: WARNINGS
linux-2.6.35-rc1-armv5: ERRORS
linux-2.6.32.6-armv5-davinci: OK
linux-2.6.33-armv5-davinci: OK
linux-2.6.34-armv5-davinci: WARNINGS
linux-2.6.35-rc1-armv5-davinci: ERRORS
linux-2.6.32.6-armv5-ixp: WARNINGS
linux-2.6.33-armv5-ixp: WARNINGS
linux-2.6.34-armv5-ixp: WARNINGS
linux-2.6.35-rc1-armv5-ixp: ERRORS
linux-2.6.32.6-armv5-omap2: OK
linux-2.6.33-armv5-omap2: OK
linux-2.6.34-armv5-omap2: WARNINGS
linux-2.6.35-rc1-armv5-omap2: ERRORS
linux-2.6.22.19-i686: ERRORS
linux-2.6.23.17-i686: ERRORS
linux-2.6.24.7-i686: WARNINGS
linux-2.6.25.20-i686: WARNINGS
linux-2.6.26.8-i686: WARNINGS
linux-2.6.27.44-i686: WARNINGS
linux-2.6.28.10-i686: WARNINGS
linux-2.6.29.1-i686: WARNINGS
linux-2.6.30.10-i686: WARNINGS
linux-2.6.31.12-i686: OK
linux-2.6.32.6-i686: OK
linux-2.6.33-i686: OK
linux-2.6.34-i686: WARNINGS
linux-2.6.35-rc1-i686: ERRORS
linux-2.6.32.6-m32r: OK
linux-2.6.33-m32r: OK
linux-2.6.34-m32r: WARNINGS
linux-2.6.35-rc1-m32r: ERRORS
linux-2.6.32.6-mips: OK
linux-2.6.33-mips: OK
linux-2.6.34-mips: WARNINGS
linux-2.6.35-rc1-mips: ERRORS
linux-2.6.32.6-powerpc64: OK
linux-2.6.33-powerpc64: OK
linux-2.6.34-powerpc64: WARNINGS
linux-2.6.35-rc1-powerpc64: ERRORS
linux-2.6.22.19-x86_64: ERRORS
linux-2.6.23.17-x86_64: ERRORS
linux-2.6.24.7-x86_64: WARNINGS
linux-2.6.25.20-x86_64: WARNINGS
linux-2.6.26.8-x86_64: WARNINGS
linux-2.6.27.44-x86_64: WARNINGS
linux-2.6.28.10-x86_64: WARNINGS
linux-2.6.29.1-x86_64: WARNINGS
linux-2.6.30.10-x86_64: WARNINGS
linux-2.6.31.12-x86_64: OK
linux-2.6.32.6-x86_64: OK
linux-2.6.33-x86_64: OK
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35-rc1-x86_64: ERRORS
linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-x86_64: WARNINGS
spec: ERRORS
spec-git: OK
sparse: ERRORS
linux-2.6.16.62-i686: ERRORS
linux-2.6.17.14-i686: ERRORS
linux-2.6.18.8-i686: ERRORS
linux-2.6.19.7-i686: ERRORS
linux-2.6.20.21-i686: ERRORS
linux-2.6.21.7-i686: ERRORS
linux-2.6.16.62-x86_64: ERRORS
linux-2.6.17.14-x86_64: ERRORS
linux-2.6.18.8-x86_64: ERRORS
linux-2.6.19.7-x86_64: ERRORS
linux-2.6.20.21-x86_64: ERRORS
linux-2.6.21.7-x86_64: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The V4L-DVB specification from this daily build is here:

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


Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 21:42 +0200, Christoph Bartelmus wrote: 
 Hi!
 
 Maxim Levitsky maximlevit...@gmail.com wrote:
 
  On Thu, 2010-07-29 at 18:58 +0200, Christoph Bartelmus wrote:
  Hi Maxim,
 
  on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
  [...]
  Note that I send timeout report with zero value.
  I don't think that this value is importaint.
 
  This does not sound good. Of course the value is important to userspace
  and 2 spaces in a row will break decoding.
 
  Could you explain exactly how timeout reports work?
 
  It all should be documented in the interface description. Jarod probably
  can point you where it can be found.
  Timeout reports can only be generated by the hardware because only the
  hardware can know the exact amount of time passed since the last pulse
  when any kind of buffering is used by the hardware. You see this esp. with
  USB devices.
  In my case hardware doesn't have that capability.
  However, I thought that timeout reports are useful to stop hardware as
  soon as timeout is hit.
 
 You are starting a software timer for this? That's not the intention of  
 timeout reports. It's just a hint to the decoder which needs to run it's  
 own timer anyway. Having to stop the hardware is something very specific  
 to your driver.
 
  Lirc interface isn't set to stone, so how about a reasonable compromise.
  After reasonable long period of inactivity (200 ms for example), space
  is sent, and then next report starts with a pulse.
  So gaps between keypresses will be maximum of 200 ms, and as a bonus I
  could rip of the logic that deals with remembering the time?
 
  For sure I will not agree to any constant introduced here. And I also
  don't see why. Can you explain why you are trying to change the lirc
  interface here?
 
  Currently, to comply with strict lirc requirements I have to send one
  big space between keypresses. Of course I can send it only when I get
  next pulse, which might happen much later.
 
  However, the in-kernel decoders depend on the last space to be sent
  right away.
 
 Ugh. What's the most polite way to express my disgust? ;)
That what I think lately about that too.
A space is really a space. After which a pulse is received.
Therefore, lets just remove that cruft from in-kernel decoders?
Anyway, even a 200 ms is still time. Its useless to add unnecessary
latency to input.


 
  that it I need to and a keypress with a space, but currently it ends
  with pulse.
 
  So my idea was to wait reasonable time for next pulse, and if it doesn't
  arrive, send a space mark even though no new pulse is registered.
 
  Of course the size of that space can be configured.
 
 The reasonable time is protocol specific and must be handled by the  
 decoder IMHO and not by the driver.
It can't do that. Due to requirement of alternation between pulses and
spaces, decoder doesn't see a hide nor hair of the last space, even
though internally it keeps growing because hardware continues to send
spaces.


I am now confident that its just a decoder fault, and must be fixed.

Best regards,
Maxim Levitsky

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 21:35 +0200, Christoph Bartelmus wrote: 
 Hi!
 
 Maxim Levitsky maximlevit...@gmail.com wrote:
 [...]
  Could you explain exactly how timeout reports work?
 [...]
  So, timeout report is just another sample, with a mark attached, that
  this is last sample? right?
 
  No, a timeout report is just an additional hint for the decoder that a
  specific amount of time has passed since the last pulse _now_.
 
  [...]
  In that case, lets do that this way:
 
  As soon as timeout is reached, I just send lirc the timeout report.
  Then next keypress will start with pulse.
 
  When timeout reports are enabled the sequence must be:
  pulse timeout space pulse
  where timeout is optional.
 
  lircd will not work when you leave out the space. It must know the exact
  time between the pulses. Some hardware generates timeout reports that are
  too short to distinguish between spaces that are so short that the next
  sequence can be interpreted as a repeat or longer spaces which indicate
  that this is a new key press.
 
  Let me give an example to see if I got that right.
 
 
  Suppose we have this sequence of reports from the driver:
 
  500 (pulse)
  20 (timeout)
  1 (space)
  500 (pulse)
 
 
  Is that correct that time between first and second pulse is
  '10020' ?
 
 No, it's 1. The timeout is optional and just a hint to the decoder  
 how much time has passed already since the last pulse. It does not change  
 the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

So, I really don't need to send/support timeout reports because hw
doesn't support that.

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to
adjust threshold upon which I stop the hardware, and remember current
time.
I can put that in generic function for ene like hardware
(hw that sends small packs of samples very often)


Best regards,
Maxim Levitsky




--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Jarod Wilson
On Thu, Jul 29, 2010 at 11:04:47PM +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 21:35 +0200, Christoph Bartelmus wrote: 
  Hi!
  
  Maxim Levitsky maximlevit...@gmail.com wrote:
  [...]
   Could you explain exactly how timeout reports work?
  [...]
   So, timeout report is just another sample, with a mark attached, that
   this is last sample? right?
  
   No, a timeout report is just an additional hint for the decoder that a
   specific amount of time has passed since the last pulse _now_.
  
   [...]
   In that case, lets do that this way:
  
   As soon as timeout is reached, I just send lirc the timeout report.
   Then next keypress will start with pulse.
  
   When timeout reports are enabled the sequence must be:
   pulse timeout space pulse
   where timeout is optional.
  
   lircd will not work when you leave out the space. It must know the exact
   time between the pulses. Some hardware generates timeout reports that are
   too short to distinguish between spaces that are so short that the next
   sequence can be interpreted as a repeat or longer spaces which indicate
   that this is a new key press.
  
   Let me give an example to see if I got that right.
  
  
   Suppose we have this sequence of reports from the driver:
  
   500 (pulse)
   20 (timeout)
   1 (space)
   500 (pulse)
  
  
   Is that correct that time between first and second pulse is
   '10020' ?
  
  No, it's 1. The timeout is optional and just a hint to the decoder  
  how much time has passed already since the last pulse. It does not change  
  the meaning of the next space.
 
 its like a carrier report then I guess.
 Its clear to me now.
 
 So, I really don't need to send/support timeout reports because hw
 doesn't support that.
 
 I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to
 adjust threshold upon which I stop the hardware, and remember current
 time.
 I can put that in generic function for ene like hardware
 (hw that sends small packs of samples very often)

So... I presume this means a v3 patchset? And/or, is it worth merging
patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

-- 
Jarod Wilson
ja...@redhat.com

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Jarod Wilson
On Thu, Jul 29, 2010 at 5:28 PM, Jarod Wilson ja...@redhat.com wrote:
 On Thu, Jul 29, 2010 at 11:04:47PM +0300, Maxim Levitsky wrote:
 On Thu, 2010-07-29 at 21:35 +0200, Christoph Bartelmus wrote:
  Hi!
 
  Maxim Levitsky maximlevit...@gmail.com wrote:
  [...]
   Could you explain exactly how timeout reports work?
  [...]
   So, timeout report is just another sample, with a mark attached, that
   this is last sample? right?
  
   No, a timeout report is just an additional hint for the decoder that a
   specific amount of time has passed since the last pulse _now_.
  
   [...]
   In that case, lets do that this way:
  
   As soon as timeout is reached, I just send lirc the timeout report.
   Then next keypress will start with pulse.
  
   When timeout reports are enabled the sequence must be:
   pulse timeout space pulse
   where timeout is optional.
  
   lircd will not work when you leave out the space. It must know the exact
   time between the pulses. Some hardware generates timeout reports that 
   are
   too short to distinguish between spaces that are so short that the next
   sequence can be interpreted as a repeat or longer spaces which indicate
   that this is a new key press.
 
   Let me give an example to see if I got that right.
  
  
   Suppose we have this sequence of reports from the driver:
  
   500 (pulse)
   20 (timeout)
   1 (space)
   500 (pulse)
  
  
   Is that correct that time between first and second pulse is
   '10020' ?
 
  No, it's 1. The timeout is optional and just a hint to the decoder
  how much time has passed already since the last pulse. It does not change
  the meaning of the next space.

 its like a carrier report then I guess.
 Its clear to me now.

 So, I really don't need to send/support timeout reports because hw
 doesn't support that.

 I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to
 adjust threshold upon which I stop the hardware, and remember current
 time.
 I can put that in generic function for ene like hardware
 (hw that sends small packs of samples very often)

 So... I presume this means a v3 patchset? And/or, is it worth merging
 patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv
staging/other plus a few outstanding patches and your patches 1, 2, 3,
6 and 7:

http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/staging

-- 
Jarod Wilson
ja...@wilsonet.com
--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Thu, 2010-07-29 at 17:57 -0400, Jarod Wilson wrote: 
 On Thu, Jul 29, 2010 at 5:28 PM, Jarod Wilson ja...@redhat.com wrote:
  On Thu, Jul 29, 2010 at 11:04:47PM +0300, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 21:35 +0200, Christoph Bartelmus wrote:
   Hi!
  
   Maxim Levitsky maximlevit...@gmail.com wrote:
   [...]
Could you explain exactly how timeout reports work?
   [...]
So, timeout report is just another sample, with a mark attached, that
this is last sample? right?
   
No, a timeout report is just an additional hint for the decoder that a
specific amount of time has passed since the last pulse _now_.
   
[...]
In that case, lets do that this way:
   
As soon as timeout is reached, I just send lirc the timeout report.
Then next keypress will start with pulse.
   
When timeout reports are enabled the sequence must be:
pulse timeout space pulse
where timeout is optional.
   
lircd will not work when you leave out the space. It must know the 
exact
time between the pulses. Some hardware generates timeout reports that 
are
too short to distinguish between spaces that are so short that the 
next
sequence can be interpreted as a repeat or longer spaces which 
indicate
that this is a new key press.
  
Let me give an example to see if I got that right.
   
   
Suppose we have this sequence of reports from the driver:
   
500 (pulse)
20 (timeout)
1 (space)
500 (pulse)
   
   
Is that correct that time between first and second pulse is
'10020' ?
  
   No, it's 1. The timeout is optional and just a hint to the 
   decoder
   how much time has passed already since the last pulse. It does not change
   the meaning of the next space.
 
  its like a carrier report then I guess.
  Its clear to me now.
 
  So, I really don't need to send/support timeout reports because hw
  doesn't support that.
 
  I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to
  adjust threshold upon which I stop the hardware, and remember current
  time.
  I can put that in generic function for ene like hardware
  (hw that sends small packs of samples very often)
 
  So... I presume this means a v3 patchset? And/or, is it worth merging
  patches 1, 2, 3, 6 and 7 now, then having you work on top of that?
 
 This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv
 staging/other plus a few outstanding patches and your patches 1, 2, 3,
 6 and 7:

I am surely send V3 and likely V4.
I changed many of my patches, 

I now  am chasing a very strange leak of samples I see. (sometimes,
randomaly a sample goes missing, and that breaks in-kernel decoding...)
It appears to be not my driver fault, nor fifo overflow...

Best regards,
Maxim Levitsky

--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
On Fri, 2010-07-30 at 01:07 +0300, Maxim Levitsky wrote: 
 On Thu, 2010-07-29 at 17:57 -0400, Jarod Wilson wrote: 
  On Thu, Jul 29, 2010 at 5:28 PM, Jarod Wilson ja...@redhat.com wrote:
   On Thu, Jul 29, 2010 at 11:04:47PM +0300, Maxim Levitsky wrote:
   On Thu, 2010-07-29 at 21:35 +0200, Christoph Bartelmus wrote:
Hi!
   
Maxim Levitsky maximlevit...@gmail.com wrote:
[...]
 Could you explain exactly how timeout reports work?
[...]
 So, timeout report is just another sample, with a mark attached, 
 that
 this is last sample? right?

 No, a timeout report is just an additional hint for the decoder 
 that a
 specific amount of time has passed since the last pulse _now_.

 [...]
 In that case, lets do that this way:

 As soon as timeout is reached, I just send lirc the timeout report.
 Then next keypress will start with pulse.

 When timeout reports are enabled the sequence must be:
 pulse timeout space pulse
 where timeout is optional.

 lircd will not work when you leave out the space. It must know the 
 exact
 time between the pulses. Some hardware generates timeout reports 
 that are
 too short to distinguish between spaces that are so short that the 
 next
 sequence can be interpreted as a repeat or longer spaces which 
 indicate
 that this is a new key press.
   
 Let me give an example to see if I got that right.


 Suppose we have this sequence of reports from the driver:

 500 (pulse)
 20 (timeout)
 1 (space)
 500 (pulse)


 Is that correct that time between first and second pulse is
 '10020' ?
   
No, it's 1. The timeout is optional and just a hint to the 
decoder
how much time has passed already since the last pulse. It does not 
change
the meaning of the next space.
  
   its like a carrier report then I guess.
   Its clear to me now.
  
   So, I really don't need to send/support timeout reports because hw
   doesn't support that.
  
   I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to
   adjust threshold upon which I stop the hardware, and remember current
   time.
   I can put that in generic function for ene like hardware
   (hw that sends small packs of samples very often)
  
   So... I presume this means a v3 patchset? And/or, is it worth merging
   patches 1, 2, 3, 6 and 7 now, then having you work on top of that?
  
  This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv
  staging/other plus a few outstanding patches and your patches 1, 2, 3,
  6 and 7:
 
 I am surely send V3 and likely V4.
 I changed many of my patches, 
 
 I now  am chasing a very strange leak of samples I see. (sometimes,
 randomaly a sample goes missing, and that breaks in-kernel decoding...)
 It appears to be not my driver fault, nor fifo overflow...


Rolls eyes 


void ir_raw_event_handle(struct input_dev *input_dev)
{
struct ir_input_dev *ir = input_get_drvdata(input_dev);

if (!ir-raw)
return;

schedule_work(ir-raw-rx_work);
}
EXPORT_SYMBOL_GPL(ir_raw_event_handle);


This is workqueue, so who said two of them can run at same time.

Best regards,
Maxim Levitsky

--
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]Resend:videobuf_dma_sg: a new implementation for mmap

2010-07-29 Thread Figo.zhang
a mmap issue for videobuf-dma-sg: it will alloc a new page for mmaping when it 
encounter
page fault at video_vm_ops-fault(). pls see 
http://www.spinics.net/lists/linux-media/msg21243.html

a new implementation for mmap, it translate to vmalloc to page at 
video_vm_ops-fault().

in v2, if mem-dma.vmalloc is NULL at video_vm_ops-fault(), it will alloc 
memory by 
vmlloc_32().

Signed-off-by: Figo.zhang figo1...@gmail.com
---
drivers/media/video/videobuf-dma-sg.c |   50 +++--
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/media/video/videobuf-dma-sg.c 
b/drivers/media/video/videobuf-dma-sg.c
index 8359e6b..f7295da 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -201,10 +201,11 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, 
int direction,
dprintk(1, init kernel [%d pages]\n, nr_pages);
 
dma-direction = direction;
-   dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
-   if (NULL == dma-vmalloc) {
-   dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
-   return -ENOMEM;
+   if (!dma-vmalloc)
+   dma-vmalloc = vmalloc_32(nr_pages  PAGE_SHIFT);
+   if (NULL == dma-vmalloc) {
+   dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
+   return -ENOMEM;
}
 
dprintk(1, vmalloc is at addr 0x%08lx, size=%d\n,
@@ -397,16 +398,47 @@ static void videobuf_vm_close(struct vm_area_struct *vma)
  */
 static int videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
-   struct page *page;
+   struct page *page = NULL;
+   struct videobuf_mapping *map = vma-vm_private_data;
+   struct videobuf_queue *q = map-q;
+   struct videobuf_dma_sg_memory *mem = NULL;
+
+   unsigned long offset;
+   unsigned long page_nr;
+   int first;
 
dprintk(3, fault: fault @ %08lx [vma %08lx-%08lx]\n,
(unsigned long)vmf-virtual_address,
vma-vm_start, vma-vm_end);
 
-   page = alloc_page(GFP_USER | __GFP_DMA32);
-   if (!page)
-   return VM_FAULT_OOM;
-   clear_user_highpage(page, (unsigned long)vmf-virtual_address);
+   mutex_lock(q-vb_lock);
+   offset = (unsigned long)vmf-virtual_address - vma-vm_start;
+   page_nr = offset  PAGE_SHIFT;
+
+   for (first = 0; first  VIDEO_MAX_FRAME; first++) {
+   if (NULL == q-bufs[first])
+   continue;
+
+   MAGIC_CHECK(mem-magic, MAGIC_SG_MEM);
+
+   if (q-bufs[first]-map == map)
+   break;
+   }
+
+   mem = q-bufs[first]-priv;
+   if (!mem)
+   return VM_FAULT_SIGBUS;
+   if (!mem-dma.vmalloc) {
+   mem-dma.vmalloc = vmalloc_32(PAGE_ALIGN(q-bufs[first]-size));
+   if (NULL == mem-dma.vmalloc) {
+   dprintk(1, %s: vmalloc_32() failed\n, __func__);
+   return VM_FAULT_OOM;
+   }
+   } else
+   page = vmalloc_to_page(mem-dma.vmalloc+
+   (offset  (~PAGE_MASK)));
+   mutex_unlock(q-vb_lock);
+
vmf-page = page;
 
return 0;


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


Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Andy Walls
On Thu, 2010-07-29 at 19:15 +0200, Christoph Bartelmus wrote:
 on 29 Jul 10 at 19:26, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 11:38 -0400, Andy Walls wrote:
  On Thu, 2010-07-29 at 17:41 +0300, Maxim Levitsky wrote:
  On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote:

Hi Christoph, Mauro, and Jarrod

 When timeout reports are enabled the sequence must be:
 pulse timeout space pulse
 where timeout is optional.

OK.  This is some of the detail I needed.

I'm looking at the master branch of Jarrod's wip git repo, but:


1. I don't see how a timeout report is going to make it through 

drivers/media/IR/ir-lirc-codec.c:lir_lirc_decode()

I guess I'll have to add a flags field (or something) to 

include/media/ir_core.h:struct ir_raw_event

to modify the events beyond just mark or space reports.

Mauro, do you have any preferences or comments here?



2. The in-kernel decoders normally need a the final space to close out
the decoding, so the above sequence will cause them to wait.  It would
only really be noticiable if no repeat came from the remote, but it
still would be annoying.

If I send a space for the timeout to get the in kernel decoders to close
out decoding, then I end up sending a double space out to LIRC, which I
just read will confuse LIRC.  

So...

If I'm going to add a timeout event flag to struct ir_raw_event, I
suppose we could either:

a. have the current in kernel decoders interpret an
   ir_raw_event with a timeout event as a cue to conclude
   decoding the current pulse train

b. add a finish decode flag and have the in kernel decoders
   respond to that.

I beleive this will also let the in-kernel decoders still respond to
final space as they currently do.

Objections? comments?


3.  When my hardware times out, it stops measuring anything, until it
sees a new edge.  For short timeout settings (smaller than the
intertransmission gap), I will have generate a space in software to
provide the length of the gap.

I'll have to store the time of reading the timeout flag of the hardware
Rx FIFO, compute an approximate gap length when the next mark
measurement comes in, and insert a the space.  The gaps space time will
only be approximate, as the Rx FIFO watermark is set to interrupt at 4
measurements in the FIFO.



If I can't do #1  #2 above, I'm not sure how I can send any in band
signaling out to user space.

Regards,
Andy

 lircd will not work when you leave out the space. It must know the exact  
 time between the pulses. Some hardware generates timeout reports that are  
 too short to distinguish between spaces that are so short that the next  
 sequence can be interpreted as a repeat or longer spaces which indicate  
 that this is a new key press.
 
 Christoph


--
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 0/9 v2] IR: few fixes, additions and ENE driver

2010-07-29 Thread Maxim Levitsky
Hi,

This is third revision of my patchset.

Notable changes:

* Added whitespace fixes from Jarod Wilson
* 4 new bugs fixed (patches 04-07). Now in-kernel decoding
  works perfectly with all protocols it supports.
* lirc interface additions cleaned up.
  no more wrong support for timeout reports
  new ioctl for learning mode
  still need to add carrier detect, timeout reports, and rx filter
* replaced int with bool in my driver, plus few cleanups.
* added myself to maintainers of the ene driver
* added another PNP ID to ene driver

Best regards,
Maxim Levitsky


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


[PATCH 01/13] IR: Kconfig fixes

2010-07-29 Thread Maxim Levitsky
Move IR drives below separate menu.
This allows to disable them.
Also correct a typo.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/Kconfig |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/media/IR/Kconfig b/drivers/media/IR/Kconfig
index e557ae0..fc48a3f 100644
--- a/drivers/media/IR/Kconfig
+++ b/drivers/media/IR/Kconfig
@@ -1,8 +1,10 @@
-config IR_CORE
-   tristate
+menuconfig IR_CORE
+   tristate Infrared remote controller adapters
depends on INPUT
default INPUT
 
+if IR_CORE
+
 config VIDEO_IR
tristate
depends on IR_CORE
@@ -16,7 +18,7 @@ config LIRC
   Enable this option to build the Linux Infrared Remote
   Control (LIRC) core device interface driver. The LIRC
   interface passes raw IR to and from userspace, where the
-  LIRC daemon handles protocol decoding for IR reception ann
+  LIRC daemon handles protocol decoding for IR reception and
   encoding for IR transmitting (aka blasting).
 
 source drivers/media/IR/keymaps/Kconfig
@@ -102,3 +104,5 @@ config IR_MCEUSB
 
   To compile this driver as a module, choose M here: the
   module will be called mceusb.
+
+endif #IR_CORE
-- 
1.7.0.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 02/13] IR: minor fixes:

2010-07-29 Thread Maxim Levitsky
* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be 
pulse
* Make TO_US macro actualy print what it should.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-core-priv.h  |4 +---
 drivers/media/IR/ir-lirc-codec.c |   14 --
 drivers/media/IR/ir-raw-event.c  |3 +++
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index babd520..dc26e2b 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {
struct lirc_codec {
struct ir_input_dev *ir_dev;
struct lirc_driver *drv;
-   int lircdata;
} lirc;
 };
 
@@ -104,10 +103,9 @@ static inline void decrease_duration(struct ir_raw_event 
*ev, unsigned duration)
ev-duration -= duration;
 }
 
-#define TO_US(duration)(((duration) + 500) / 1000)
+#define TO_US(duration)DIV_ROUND_CLOSEST((duration), 
1000)
 #define TO_STR(is_pulse)   ((is_pulse) ? pulse : space)
 #define IS_RESET(ev)   (ev.duration == 0)
-
 /*
  * Routines from ir-sysfs.c - Meant to be called only internally inside
  * ir-core
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c
index 3ba482d..8ca01fd 100644
--- a/drivers/media/IR/ir-lirc-codec.c
+++ b/drivers/media/IR/ir-lirc-codec.c
@@ -32,6 +32,7 @@
 static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+   int sample;
 
if (!(ir_dev-raw-enabled_protocols  IR_TYPE_LIRC))
return 0;
@@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, 
struct ir_raw_event ev)
if (!ir_dev-raw-lirc.drv || !ir_dev-raw-lirc.drv-rbuf)
return -EINVAL;
 
+   if (IS_RESET(ev))
+   return 0;
+
IR_dprintk(2, LIRC data transfer started (%uus %s)\n,
   TO_US(ev.duration), TO_STR(ev.pulse));
 
-   ir_dev-raw-lirc.lircdata += ev.duration / 1000;
+
+   sample = ev.duration / 1000;
if (ev.pulse)
-   ir_dev-raw-lirc.lircdata |= PULSE_BIT;
+   sample |= PULSE_BIT;
 
lirc_buffer_write(ir_dev-raw-lirc.drv-rbuf,
- (unsigned char *) ir_dev-raw-lirc.lircdata);
+ (unsigned char *) sample);
wake_up(ir_dev-raw-lirc.drv-rbuf-wait_poll);
 
-   ir_dev-raw-lirc.lircdata = 0;
 
return 0;
 }
@@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev)
 
ir_dev-raw-lirc.drv = drv;
ir_dev-raw-lirc.ir_dev = ir_dev;
-   ir_dev-raw-lirc.lircdata = PULSE_MASK;
-
return 0;
 
 lirc_register_failed:
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 6f192ef..51f65da 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct 
ir_raw_event *ev)
if (!ir-raw)
return -EINVAL;
 
+   IR_dprintk(2, sample: (05%dus %s)\n,
+   TO_US(ev-duration), TO_STR(ev-pulse));
+
if (kfifo_in(ir-raw-kfifo, ev, sizeof(*ev)) != sizeof(*ev))
return -ENOMEM;
 
-- 
1.7.0.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 03/13] IR: replace spinlock with mutex.

2010-07-29 Thread Maxim Levitsky
Some handlers (lirc for example) allocates memory on initialization,
doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-raw-event.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 51f65da..9d5c029 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -13,7 +13,7 @@
  */
 
 #include linux/workqueue.h
-#include linux/spinlock.h
+#include linux/mutex.h
 #include linux/sched.h
 #include ir-core-priv.h
 
@@ -24,7 +24,7 @@
 static LIST_HEAD(ir_raw_client_list);
 
 /* Used to handle IR raw handler extensions */
-static DEFINE_SPINLOCK(ir_raw_handler_lock);
+static DEFINE_MUTEX(ir_raw_handler_lock);
 static LIST_HEAD(ir_raw_handler_list);
 static u64 available_protocols;
 
@@ -41,10 +41,10 @@ static void ir_raw_event_work(struct work_struct *work)
container_of(work, struct ir_raw_event_ctrl, rx_work);
 
while (kfifo_out(raw-kfifo, ev, sizeof(ev)) == sizeof(ev)) {
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
list_for_each_entry(handler, ir_raw_handler_list, list)
handler-decode(raw-input_dev, ev);
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
raw-prev_ev = ev;
}
 }
@@ -150,9 +150,9 @@ u64
 ir_raw_get_allowed_protocols()
 {
u64 protocols;
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
protocols = available_protocols;
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
return protocols;
 }
 
@@ -180,12 +180,12 @@ int ir_raw_event_register(struct input_dev *input_dev)
return rc;
}
 
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
list_add_tail(ir-raw-list, ir_raw_client_list);
list_for_each_entry(handler, ir_raw_handler_list, list)
if (handler-raw_register)
handler-raw_register(ir-raw-input_dev);
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
 
return 0;
 }
@@ -200,12 +200,12 @@ void ir_raw_event_unregister(struct input_dev *input_dev)
 
cancel_work_sync(ir-raw-rx_work);
 
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
list_del(ir-raw-list);
list_for_each_entry(handler, ir_raw_handler_list, list)
if (handler-raw_unregister)
handler-raw_unregister(ir-raw-input_dev);
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
 
kfifo_free(ir-raw-kfifo);
kfree(ir-raw);
@@ -220,13 +220,13 @@ int ir_raw_handler_register(struct ir_raw_handler 
*ir_raw_handler)
 {
struct ir_raw_event_ctrl *raw;
 
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
list_add_tail(ir_raw_handler-list, ir_raw_handler_list);
if (ir_raw_handler-raw_register)
list_for_each_entry(raw, ir_raw_client_list, list)
ir_raw_handler-raw_register(raw-input_dev);
available_protocols |= ir_raw_handler-protocols;
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
 
return 0;
 }
@@ -236,13 +236,13 @@ void ir_raw_handler_unregister(struct ir_raw_handler 
*ir_raw_handler)
 {
struct ir_raw_event_ctrl *raw;
 
-   spin_lock(ir_raw_handler_lock);
+   mutex_lock(ir_raw_handler_lock);
list_del(ir_raw_handler-list);
if (ir_raw_handler-raw_unregister)
list_for_each_entry(raw, ir_raw_client_list, list)
ir_raw_handler-raw_unregister(raw-input_dev);
available_protocols = ~ir_raw_handler-protocols;
-   spin_unlock(ir_raw_handler_lock);
+   mutex_unlock(ir_raw_handler_lock);
 }
 EXPORT_SYMBOL(ir_raw_handler_unregister);
 
-- 
1.7.0.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 04/13] IR: fix locking in ir_raw_event_work

2010-07-29 Thread Maxim Levitsky
It is prefectly possible to have ir_raw_event_work
running concurently on two cpus, thus we must protect
it from that situation.

Maybe better solution is to ditch the workqueue at all
and use good 'ol thread per receiver, and just wake it up...

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-raw-event.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 9d5c029..4098748 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -40,13 +40,16 @@ static void ir_raw_event_work(struct work_struct *work)
struct ir_raw_event_ctrl *raw =
container_of(work, struct ir_raw_event_ctrl, rx_work);
 
+   mutex_lock(ir_raw_handler_lock);
+
while (kfifo_out(raw-kfifo, ev, sizeof(ev)) == sizeof(ev)) {
-   mutex_lock(ir_raw_handler_lock);
list_for_each_entry(handler, ir_raw_handler_list, list)
handler-decode(raw-input_dev, ev);
-   mutex_unlock(ir_raw_handler_lock);
raw-prev_ev = ev;
}
+
+   mutex_unlock(ir_raw_handler_lock);
+
 }
 
 /**
-- 
1.7.0.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 05/13] IR: JVC: make repeat work

2010-07-29 Thread Maxim Levitsky
Currently, jvc decoder will attempt misdetect next press as a repeat
of last keypress, therefore second keypress isn't detected.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-jvc-decoder.c |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/media/IR/ir-jvc-decoder.c 
b/drivers/media/IR/ir-jvc-decoder.c
index 8894d8b..77a89c4 100644
--- a/drivers/media/IR/ir-jvc-decoder.c
+++ b/drivers/media/IR/ir-jvc-decoder.c
@@ -32,6 +32,7 @@ enum jvc_state {
STATE_BIT_SPACE,
STATE_TRAILER_PULSE,
STATE_TRAILER_SPACE,
+   STATE_CHECK_REPEAT,
 };
 
 /**
@@ -60,6 +61,7 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct 
ir_raw_event ev)
IR_dprintk(2, JVC decode started at state %d (%uus %s)\n,
   data-state, TO_US(ev.duration), TO_STR(ev.pulse));
 
+again:
switch (data-state) {
 
case STATE_INACTIVE:
@@ -149,8 +151,18 @@ static int ir_jvc_decode(struct input_dev *input_dev, 
struct ir_raw_event ev)
}
 
data-count = 0;
-   data-state = STATE_BIT_PULSE;
+   data-state = STATE_CHECK_REPEAT;
return 0;
+
+   case STATE_CHECK_REPEAT:
+   if (!ev.pulse)
+   break;
+
+   if (eq_margin(ev.duration, JVC_HEADER_PULSE, JVC_UNIT / 2))
+   data-state = STATE_INACTIVE;
+  else
+   data-state = STATE_BIT_PULSE;
+   goto again;
}
 
 out:
-- 
1.7.0.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 06/13] IR: nec decoder: fix repeat.

2010-07-29 Thread Maxim Levitsky
Repeat space is 4 units, not 8.
Current code would never trigger a repeat.

However that isn't true for NECX, so repeat there
must be handled differently.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-nec-decoder.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/IR/ir-nec-decoder.c 
b/drivers/media/IR/ir-nec-decoder.c
index 52e0f37..1c0cf03 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -20,7 +20,7 @@
 #define NEC_HEADER_PULSE   (16 * NEC_UNIT)
 #define NECX_HEADER_PULSE  (8  * NEC_UNIT) /* Less common NEC variant */
 #define NEC_HEADER_SPACE   (8  * NEC_UNIT)
-#define NEC_REPEAT_SPACE   (8  * NEC_UNIT)
+#define NEC_REPEAT_SPACE   (4  * NEC_UNIT)
 #define NEC_BIT_PULSE  (1  * NEC_UNIT)
 #define NEC_BIT_0_SPACE(1  * NEC_UNIT)
 #define NEC_BIT_1_SPACE(3  * NEC_UNIT)
-- 
1.7.0.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 07/13] IR: NECX: support repeat

2010-07-29 Thread Maxim Levitsky
This adds support for repeat detecting for NECX variant
Tested with uneversal remote

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-core-priv.h   |1 +
 drivers/media/IR/ir-nec-decoder.c |   16 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index dc26e2b..494e1f8 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -45,6 +45,7 @@ struct ir_raw_event_ctrl {
int state;
unsigned count;
u32 bits;
+   bool is_nec_x;
} nec;
struct rc5_dec {
int state;
diff --git a/drivers/media/IR/ir-nec-decoder.c 
b/drivers/media/IR/ir-nec-decoder.c
index 1c0cf03..59127b1 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -26,6 +26,7 @@
 #define NEC_BIT_1_SPACE(3  * NEC_UNIT)
 #defineNEC_TRAILER_PULSE   (1  * NEC_UNIT)
 #defineNEC_TRAILER_SPACE   (10 * NEC_UNIT) /* even longer in 
reality */
+#define NECX_REPEAT_BITS   1
 
 enum nec_state {
STATE_INACTIVE,
@@ -67,8 +68,11 @@ static int ir_nec_decode(struct input_dev *input_dev, struct 
ir_raw_event ev)
if (!ev.pulse)
break;
 
-   if (!eq_margin(ev.duration, NEC_HEADER_PULSE, NEC_UNIT / 2) 
-   !eq_margin(ev.duration, NECX_HEADER_PULSE, NEC_UNIT / 2))
+   if (eq_margin(ev.duration, NEC_HEADER_PULSE, NEC_UNIT / 2))
+   data-is_nec_x = false;
+   else if (eq_margin(ev.duration, NECX_HEADER_PULSE, NEC_UNIT / 
2))
+   data-is_nec_x = true;
+   else
break;
 
data-count = 0;
@@ -105,6 +109,14 @@ static int ir_nec_decode(struct input_dev *input_dev, 
struct ir_raw_event ev)
if (ev.pulse)
break;
 
+   if (geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2) 
+   data-is_nec_x  data-count == NECX_REPEAT_BITS) {
+   IR_dprintk(1, Repeat last key\n);
+   ir_repeat(input_dev);
+   data-state = STATE_INACTIVE;
+   return 0;
+   }
+
data-bits = 1;
if (eq_margin(ev.duration, NEC_BIT_1_SPACE, NEC_UNIT / 2))
data-bits |= 1;
-- 
1.7.0.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 08/13] IR: Allow not to compile keymaps in.

2010-07-29 Thread Maxim Levitsky
Currently, ir device registration fails if keymap requested by driver is not 
found.
Fix that by always compiling in the empty keymap, and using it as a failback.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-core-priv.h |3 +-
 drivers/media/IR/ir-sysfs.c |2 +
 drivers/media/IR/keymaps/Makefile   |1 -
 drivers/media/IR/keymaps/rc-empty.c |   44 ---
 drivers/media/IR/rc-map.c   |   23 ++
 include/media/ir-core.h |8 -
 6 files changed, 33 insertions(+), 48 deletions(-)
 delete mode 100644 drivers/media/IR/keymaps/rc-empty.c

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 494e1f8..fe84374 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -125,7 +125,8 @@ int ir_raw_handler_register(struct ir_raw_handler 
*ir_raw_handler);
 void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
 void ir_raw_init(void);
 
-
+int ir_rcmap_init(void);
+void ir_rcmap_cleanup(void);
 /*
  * Decoder initialization code
  *
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index a841e51..936dff8 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -341,6 +341,7 @@ static int __init ir_core_init(void)
 
/* Initialize/load the decoders/keymap code that will be used */
ir_raw_init();
+   ir_rcmap_init();
 
return 0;
 }
@@ -348,6 +349,7 @@ static int __init ir_core_init(void)
 static void __exit ir_core_exit(void)
 {
class_unregister(ir_input_class);
+   ir_rcmap_cleanup();
 }
 
 module_init(ir_core_init);
diff --git a/drivers/media/IR/keymaps/Makefile 
b/drivers/media/IR/keymaps/Makefile
index 86d3d1f..24992cd 100644
--- a/drivers/media/IR/keymaps/Makefile
+++ b/drivers/media/IR/keymaps/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-dm1105-nec.o \
rc-dntv-live-dvb-t.o \
rc-dntv-live-dvbt-pro.o \
-   rc-empty.o \
rc-em-terratec.o \
rc-encore-enltv2.o \
rc-encore-enltv.o \
diff --git a/drivers/media/IR/keymaps/rc-empty.c 
b/drivers/media/IR/keymaps/rc-empty.c
deleted file mode 100644
index 3b338d8..000
--- a/drivers/media/IR/keymaps/rc-empty.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* empty.h - Keytable for empty Remote Controller
- *
- * keymap imported from ir-keymaps.c
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include media/rc-map.h
-
-/* empty keytable, can be used as placeholder for not-yet created keytables */
-
-static struct ir_scancode empty[] = {
-   { 0x2a, KEY_COFFEE },
-};
-
-static struct rc_keymap empty_map = {
-   .map = {
-   .scan= empty,
-   .size= ARRAY_SIZE(empty),
-   .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */
-   .name= RC_MAP_EMPTY,
-   }
-};
-
-static int __init init_rc_map_empty(void)
-{
-   return ir_register_map(empty_map);
-}
-
-static void __exit exit_rc_map_empty(void)
-{
-   ir_unregister_map(empty_map);
-}
-
-module_init(init_rc_map_empty)
-module_exit(exit_rc_map_empty)
-
-MODULE_LICENSE(GPL);
-MODULE_AUTHOR(Mauro Carvalho Chehab mche...@redhat.com);
diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c
index 46a8f15..689143f 100644
--- a/drivers/media/IR/rc-map.c
+++ b/drivers/media/IR/rc-map.c
@@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map)
 }
 EXPORT_SYMBOL_GPL(ir_unregister_map);
 
+
+static struct ir_scancode empty[] = {
+   { 0x2a, KEY_COFFEE },
+};
+
+static struct rc_keymap empty_map = {
+   .map = {
+   .scan= empty,
+   .size= ARRAY_SIZE(empty),
+   .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */
+   .name= RC_MAP_EMPTY,
+   }
+};
+
+int ir_rcmap_init(void)
+{
+   return ir_register_map(empty_map);
+}
+
+void ir_rcmap_cleanup(void)
+{
+   ir_unregister_map(empty_map);
+}
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index 513e60d..197d05a 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -110,8 +110,12 @@ static inline int ir_input_register(struct input_dev *dev,
return -EINVAL;
 
ir_codes = get_rc_map(map_name);
-   if (!ir_codes)
-   return -EINVAL;
+   if (!ir_codes) {
+   ir_codes = get_rc_map(RC_MAP_EMPTY);
+
+   if (!ir_codes)
+   return -EINVAL;
+   }
 
rc = 

[PATCH 09/13] IR: add helper function for hardware with small o/b buffer.

2010-07-29 Thread Maxim Levitsky
Some ir input devices have small buffer, and interrupt the host
each time it is full (or half full)

Add a helper that automaticly handles timeouts, and also
automaticly merges samples of same time (space-space)
Such samples might be placed by hardware because size of
sample in the buffer is small (a byte for example).

Also remove constness from ir_dev_props, because it now contains timeout
settings that driver might want to change

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-core-priv.h |1 +
 drivers/media/IR/ir-keytable.c  |2 +-
 drivers/media/IR/ir-raw-event.c |   84 +++
 include/media/ir-core.h |   23 +-
 4 files changed, 106 insertions(+), 4 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index fe84374..841b76c 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -41,6 +41,7 @@ struct ir_raw_event_ctrl {
 
/* raw decoder state follows */
struct ir_raw_event prev_ev;
+   struct ir_raw_event this_ev;
struct nec_dec {
int state;
unsigned count;
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 94a8577..34b9c07 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -428,7 +428,7 @@ static void ir_close(struct input_dev *input_dev)
  */
 int __ir_input_register(struct input_dev *input_dev,
  const struct ir_scancode_table *rc_tab,
- const struct ir_dev_props *props,
+ struct ir_dev_props *props,
  const char *driver_name)
 {
struct ir_input_dev *ir_dev;
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 4098748..5a6f8ce 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -132,6 +132,90 @@ int ir_raw_event_store_edge(struct input_dev *input_dev, 
enum raw_event_type typ
 EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
 
 /**
+ * ir_raw_event_store_with_filter() - pass next pulse/space to decoders with 
some processing
+ * @input_dev: the struct input_dev device descriptor
+ * @type:  the type of the event that has occurred
+ *
+ * This routine (which may be called from an interrupt context) works
+ * in similiar manner to ir_raw_event_store_edge.
+ * This routine is intended for devices with limited internal buffer
+ * It automerges samples of same type, and handles timeouts
+ */
+int ir_raw_event_store_with_filter(struct input_dev *input_dev,
+   struct ir_raw_event *ev)
+{
+   struct ir_input_dev *ir = input_get_drvdata(input_dev);
+   struct ir_raw_event_ctrl *raw = ir-raw;
+
+   if (!raw || !ir-props)
+   return -EINVAL;
+
+   /* Ignore spaces in idle mode */
+   if (ir-idle  !ev-pulse)
+   return 0;
+   else if (ir-idle)
+   ir_raw_event_set_idle(input_dev, 0);
+
+   if (!raw-this_ev.duration) {
+   raw-this_ev = *ev;
+   } else if (ev-pulse == raw-this_ev.pulse) {
+   raw-this_ev.duration += ev-duration;
+   } else {
+   ir_raw_event_store(input_dev, raw-this_ev);
+   raw-this_ev = *ev;
+   }
+
+   /* Enter idle mode if nessesary */
+   if (!ev-pulse  ir-props-timeout 
+   raw-this_ev.duration = ir-props-timeout)
+   ir_raw_event_set_idle(input_dev, 1);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter);
+
+void ir_raw_event_set_idle(struct input_dev *input_dev, int idle)
+{
+   struct ir_input_dev *ir = input_get_drvdata(input_dev);
+   struct ir_raw_event_ctrl *raw = ir-raw;
+   ktime_t now;
+   u64 delta;
+
+   if (!ir-props)
+   return;
+
+   if (!ir-raw)
+   goto out;
+
+   if (idle) {
+   IR_dprintk(2, enter idle mode\n);
+   raw-last_event = ktime_get();
+   } else {
+   IR_dprintk(2, exit idle mode\n);
+
+   now = ktime_get();
+   delta = ktime_to_ns(ktime_sub(now, ir-raw-last_event));
+
+   WARN_ON(raw-this_ev.pulse);
+
+   raw-this_ev.duration =
+   min(raw-this_ev.duration + delta,
+   (u64)IR_MAX_DURATION);
+
+   ir_raw_event_store(input_dev, raw-this_ev);
+
+   if (raw-this_ev.duration == IR_MAX_DURATION)
+   ir_raw_event_reset(input_dev);
+
+   raw-this_ev.duration = 0;
+   }
+out:
+   if (ir-props-s_idle)
+   ir-props-s_idle(ir-props-priv, idle);
+   ir-idle = idle;
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_set_idle);
+
+/**
  * ir_raw_event_handle() - schedules the decoding of stored ir data
  * @input_dev: the struct input_dev device descriptor
  *

[PATCH 10/13] IR: extend interfaces to support more device settings LIRC: add new IOCTL that enables learning mode (wide band receiver)

2010-07-29 Thread Maxim Levitsky
Still missing features: carrier report  timeout reports.
Will need to pack these into ir_raw_event


Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-core-priv.h  |1 +
 drivers/media/IR/ir-lirc-codec.c |  112 +++---
 include/media/ir-core.h  |   14 +
 include/media/lirc.h |5 ++-
 4 files changed, 112 insertions(+), 20 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 841b76c..068807d 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -78,6 +78,7 @@ struct ir_raw_event_ctrl {
struct lirc_codec {
struct ir_input_dev *ir_dev;
struct lirc_driver *drv;
+   int carrier_low;
} lirc;
 };
 
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c
index 8ca01fd..5d5150f 100644
--- a/drivers/media/IR/ir-lirc-codec.c
+++ b/drivers/media/IR/ir-lirc-codec.c
@@ -46,7 +46,6 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct 
ir_raw_event ev)
IR_dprintk(2, LIRC data transfer started (%uus %s)\n,
   TO_US(ev.duration), TO_STR(ev.pulse));
 
-
sample = ev.duration / 1000;
if (ev.pulse)
sample |= PULSE_BIT;
@@ -96,13 +95,14 @@ out:
return ret;
 }
 
-static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long 
arg)
+static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
+   unsigned long __user arg)
 {
struct lirc_codec *lirc;
struct ir_input_dev *ir_dev;
int ret = 0;
void *drv_data;
-   unsigned long val;
+   unsigned long val = 0;
 
lirc = lirc_get_pdata(filep);
if (!lirc)
@@ -114,47 +114,106 @@ static long ir_lirc_ioctl(struct file *filep, unsigned 
int cmd, unsigned long ar
 
drv_data = ir_dev-props-priv;
 
-   switch (cmd) {
-   case LIRC_SET_TRANSMITTER_MASK:
+   if (_IOC_DIR(cmd)  _IOC_WRITE) {
ret = get_user(val, (unsigned long *)arg);
if (ret)
return ret;
+   }
+
+   switch (cmd) {
+
+   /* legacy support */
+   case LIRC_GET_SEND_MODE:
+   val = LIRC_CAN_SEND_PULSE  LIRC_CAN_SEND_MASK;
+   break;
+
+   case LIRC_SET_SEND_MODE:
+   if (val != (LIRC_MODE_PULSE  LIRC_CAN_SEND_MASK))
+   return -EINVAL;
+   break;
 
-   if (ir_dev-props  ir_dev-props-s_tx_mask)
+   /* TX settings */
+   case LIRC_SET_TRANSMITTER_MASK:
+   if (ir_dev-props-s_tx_mask)
ret = ir_dev-props-s_tx_mask(drv_data, (u32)val);
else
return -EINVAL;
break;
 
case LIRC_SET_SEND_CARRIER:
-   ret = get_user(val, (unsigned long *)arg);
-   if (ret)
-   return ret;
-
-   if (ir_dev-props  ir_dev-props-s_tx_carrier)
+   if (ir_dev-props-s_tx_carrier)
ir_dev-props-s_tx_carrier(drv_data, (u32)val);
else
return -EINVAL;
break;
 
-   case LIRC_GET_SEND_MODE:
-   val = LIRC_CAN_SEND_PULSE  LIRC_CAN_SEND_MASK;
-   ret = put_user(val, (unsigned long *)arg);
+   case LIRC_SET_SEND_DUTY_CYCLE:
+   if (!ir_dev-props-s_tx_duty_cycle)
+   return -ENOSYS;
+
+   if (val = 0 || val = 100)
+   return -EINVAL;
+
+   ir_dev-props-s_tx_duty_cycle(ir_dev-props-priv, val);
break;
 
-   case LIRC_SET_SEND_MODE:
-   ret = get_user(val, (unsigned long *)arg);
-   if (ret)
-   return ret;
+   /* RX settings */
+   case LIRC_SET_REC_CARRIER:
+   if (ir_dev-props-s_rx_carrier_range)
+   ret = ir_dev-props-s_rx_carrier_range(
+   ir_dev-props-priv,
+   ir_dev-raw-lirc.carrier_low, val);
+   else
+   return -ENOSYS;
 
-   if (val != (LIRC_MODE_PULSE  LIRC_CAN_SEND_MASK))
+   if (!ret)
+   ir_dev-raw-lirc.carrier_low = 0;
+   break;
+
+   case LIRC_SET_REC_CARRIER_RANGE:
+   if (val = 0)
+   ir_dev-raw-lirc.carrier_low = val;
+   break;
+
+
+   case LIRC_GET_REC_RESOLUTION:
+   val = ir_dev-props-rx_resolution;
+   break;
+
+   case LIRC_SET_WIDEBAND_RECEIVER:
+   if (ir_dev-props-s_learning_mode)
+   return ir_dev-props-s_learning_mode(
+   ir_dev-props-priv, !!val);
+   else
+   return -ENOSYS;
+
+   /* 

[PATCH 11/13] IR: report unknown scancodes the in-kernel decoders found.

2010-07-29 Thread Maxim Levitsky
This way it is possible to use evtest to create keymap for unknown remote.

Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
---
 drivers/media/IR/ir-keytable.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 34b9c07..ba7678a 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -339,6 +339,8 @@ void ir_repeat(struct input_dev *dev)
 
spin_lock_irqsave(ir-keylock, flags);
 
+   input_event(dev, EV_MSC, MSC_SCAN, ir-last_scancode);
+
if (!ir-keypressed)
goto out;
 
@@ -370,6 +372,8 @@ void ir_keydown(struct input_dev *dev, int scancode, u8 
toggle)
 
spin_lock_irqsave(ir-keylock, flags);
 
+   input_event(dev, EV_MSC, MSC_SCAN, scancode);
+
/* Repeat event? */
if (ir-keypressed 
ir-last_scancode == scancode 
@@ -383,9 +387,11 @@ void ir_keydown(struct input_dev *dev, int scancode, u8 
toggle)
ir-last_toggle = toggle;
ir-last_keycode = keycode;
 
+
if (keycode == KEY_RESERVED)
goto out;
 
+
/* Register a keypress */
ir-keypressed = true;
IR_dprintk(1, %s: key down event, key 0x%04x, scancode 0x%04x\n,
@@ -480,6 +486,8 @@ int __ir_input_register(struct input_dev *input_dev,
 
set_bit(EV_KEY, input_dev-evbit);
set_bit(EV_REP, input_dev-evbit);
+   set_bit(EV_MSC, input_dev-evbit);
+   set_bit(MSC_SCAN, input_dev-mscbit);
 
if (ir_setkeytable(input_dev, ir_dev-rc_tab, rc_tab)) {
rc = -ENOMEM;
-- 
1.7.0.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: [PATCH 13/13] IR: Port ene driver to new IR subsystem and enable it.

2010-07-29 Thread Jon Smirl
On Thu, Jul 29, 2010 at 10:17 PM, Maxim Levitsky
maximlevit...@gmail.com wrote:
 note that error_adjustment module option is added.
 This allows to reduce input samples by a percent.
 This makes input on my system more correct.

 Default is 4% as it works best here.

 Note that only normal input is adjusted. I don't know
 what adjustments to apply to fan tachometer input.
 Maybe it is accurate already.

Do you have the manual for the ENE chip in English? or do you read Chinese?

Maybe you can figure out why the readings are off by 4%. I suspect
that someone has set a clock divider wrong when programming the chip.
For example setting the divider for a 25Mhz clock when the clock is
actually 26Mhz would cause the error you are seeing. Or they just made
a mistake in computing the divisor. It is probably a bug in the BIOS
of your laptop.  If that's the case you could add a quirk in the
system boot code to fix the register setting.

-- 
Jon Smirl
jonsm...@gmail.com
--
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 04/13] IR: fix locking in ir_raw_event_work

2010-07-29 Thread Andy Walls
On Fri, 2010-07-30 at 05:17 +0300, Maxim Levitsky wrote:
 It is prefectly possible to have ir_raw_event_work
 running concurently on two cpus, thus we must protect
 it from that situation.

Yup, the work is marked as not pending (and hence reschedulable) just
before the work handler is run.


 Maybe better solution is to ditch the workqueue at all
 and use good 'ol thread per receiver, and just wake it up...

I suppose you could also use a single threaded workqueue instead of a
mutex, and let a bit test provide exclusivity.  With the mutex, when the
second thread finally obtains the lock, there will likely not be
anything for it to do.

Regards,
Andy


 Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
 ---
  drivers/media/IR/ir-raw-event.c |7 +--
  1 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
 index 9d5c029..4098748 100644
 --- a/drivers/media/IR/ir-raw-event.c
 +++ b/drivers/media/IR/ir-raw-event.c
 @@ -40,13 +40,16 @@ static void ir_raw_event_work(struct work_struct *work)
   struct ir_raw_event_ctrl *raw =
   container_of(work, struct ir_raw_event_ctrl, rx_work);
  
 + mutex_lock(ir_raw_handler_lock);
 +
   while (kfifo_out(raw-kfifo, ev, sizeof(ev)) == sizeof(ev)) {
 - mutex_lock(ir_raw_handler_lock);
   list_for_each_entry(handler, ir_raw_handler_list, list)
   handler-decode(raw-input_dev, ev);
 - mutex_unlock(ir_raw_handler_lock);
   raw-prev_ev = ev;
   }
 +
 + mutex_unlock(ir_raw_handler_lock);
 +
  }
  
  /**


--
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 06/13] IR: nec decoder: fix repeat.

2010-07-29 Thread Andy Walls
On Fri, 2010-07-30 at 05:17 +0300, Maxim Levitsky wrote:
 Repeat space is 4 units, not 8.
 Current code would never trigger a repeat.


Yup.  Page 11, line (4)

http://www.datasheetcatalog.org/datasheet/nec/UPD6122G-002.pdf

Reviewed-by: Andy Walls awa...@md.metrocast.net

Regards,
Andy

 However that isn't true for NECX, so repeat there
 must be handled differently.
 
 Signed-off-by: Maxim Levitsky maximlevit...@gmail.com
 ---
  drivers/media/IR/ir-nec-decoder.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/IR/ir-nec-decoder.c 
 b/drivers/media/IR/ir-nec-decoder.c
 index 52e0f37..1c0cf03 100644
 --- a/drivers/media/IR/ir-nec-decoder.c
 +++ b/drivers/media/IR/ir-nec-decoder.c
 @@ -20,7 +20,7 @@
  #define NEC_HEADER_PULSE (16 * NEC_UNIT)
  #define NECX_HEADER_PULSE(8  * NEC_UNIT) /* Less common NEC variant */
  #define NEC_HEADER_SPACE (8  * NEC_UNIT)
 -#define NEC_REPEAT_SPACE (8  * NEC_UNIT)
 +#define NEC_REPEAT_SPACE (4  * NEC_UNIT)
  #define NEC_BIT_PULSE(1  * NEC_UNIT)
  #define NEC_BIT_0_SPACE  (1  * NEC_UNIT)
  #define NEC_BIT_1_SPACE  (3  * NEC_UNIT)


--
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 13/13] IR: Port ene driver to new IR subsystem and enable it.

2010-07-29 Thread Andy Walls
On Thu, 2010-07-29 at 22:39 -0400, Jon Smirl wrote:
 On Thu, Jul 29, 2010 at 10:17 PM, Maxim Levitsky
 maximlevit...@gmail.com wrote:
  note that error_adjustment module option is added.
  This allows to reduce input samples by a percent.
  This makes input on my system more correct.
 
  Default is 4% as it works best here.
 
  Note that only normal input is adjusted. I don't know
  what adjustments to apply to fan tachometer input.
  Maybe it is accurate already.
 
 Do you have the manual for the ENE chip in English? or do you read Chinese?

The datasheet for a similar chip, the KB3700, is out there in English,
but it doesn't have CIR.

You might find these links mildly interesting:

http://www.coreboot.org/Embedded_controller
http://wiki.laptop.org/go/Embedded_controller
http://lists.laptop.org/pipermail/openec/2008-July/000108.html

Regards,
Andy

 Maybe you can figure out why the readings are off by 4%. I suspect
 that someone has set a clock divider wrong when programming the chip.
 For example setting the divider for a 25Mhz clock when the clock is
 actually 26Mhz would cause the error you are seeing. Or they just made
 a mistake in computing the divisor. It is probably a bug in the BIOS
 of your laptop.  If that's the case you could add a quirk in the
 system boot code to fix the register setting.
 


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