Re: [PATCH v4 2/6] drivers:staging: ti-st: fmdrv_v4l2 sources

2010-11-17 Thread Hans Verkuil
On Tuesday, November 16, 2010 14:18:10 manjunatha_ha...@ti.com wrote:
> From: Manjunatha Halli 
> 
> This module interfaces V4L2 subsystem and FM common
> module. It registers itself with V4L2 as Radio module.
> 
> Signed-off-by: Manjunatha Halli 
> ---
>  drivers/staging/ti-st/fmdrv_v4l2.c |  757 
> 
>  drivers/staging/ti-st/fmdrv_v4l2.h |   32 ++
>  2 files changed, 789 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h
> 
> diff --git a/drivers/staging/ti-st/fmdrv_v4l2.c 
> b/drivers/staging/ti-st/fmdrv_v4l2.c
> new file mode 100644
> index 000..687d10f
> --- /dev/null
> +++ b/drivers/staging/ti-st/fmdrv_v4l2.c
> @@ -0,0 +1,757 @@
> +/*
> + *  FM Driver for Connectivity chip of Texas Instruments.
> + *  This file provides interfaces to V4L2 subsystem.
> + *
> + *  This module registers with V4L2 subsystem as Radio
> + *  data system interface (/dev/radio). During the registration,
> + *  it will expose two set of function pointers.
> + *
> + *1) File operation related API (open, close, read, write, poll...etc).
> + *2) Set of V4L2 IOCTL complaint API.
> + *
> + *  Copyright (C) 2010 Texas Instruments
> + *  Author: Raja Mani 
> + *
> + *  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.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + */
> +
> +#include "fmdrv.h"
> +#include "fmdrv_v4l2.h"
> +#include "fmdrv_common.h"
> +#include "fmdrv_rx.h"
> +#include "fmdrv_tx.h"
> +
> +static struct video_device *gradio_dev;
> +static unsigned char radio_disconnected;
> +
> +/* Query control */
> +static struct v4l2_queryctrl fmdrv_v4l2_queryctrl[] = {
> + {
> +  .id = V4L2_CID_AUDIO_VOLUME,
> +  .type = V4L2_CTRL_TYPE_INTEGER,
> +  .name = "Volume",
> +  .minimum = FM_RX_VOLUME_MIN,
> +  .maximum = FM_RX_VOLUME_MAX,
> +  .step = 1,
> +  .default_value = FM_DEFAULT_RX_VOLUME,
> +  },
> + {
> +  .id = V4L2_CID_AUDIO_BALANCE,
> +  .flags = V4L2_CTRL_FLAG_DISABLED,
> +  },
> + {
> +  .id = V4L2_CID_AUDIO_BASS,
> +  .flags = V4L2_CTRL_FLAG_DISABLED,
> +  },
> + {
> +  .id = V4L2_CID_AUDIO_TREBLE,
> +  .flags = V4L2_CTRL_FLAG_DISABLED,
> +  },
> + {
> +  .id = V4L2_CID_AUDIO_MUTE,
> +  .type = V4L2_CTRL_TYPE_BOOLEAN,
> +  .name = "Mute",
> +  .minimum = 0,
> +  .maximum = 2,
> +  .step = 1,
> +  .default_value = FM_MUTE_OFF,
> +  },
> + {
> +  .id = V4L2_CID_AUDIO_LOUDNESS,
> +  .flags = V4L2_CTRL_FLAG_DISABLED,
> +  },
> +};

Please use the control framework. See 
Documentation/video4linux/v4l2-controls.txt.
It's much easier to use and should be used for new drivers.

Regards,

Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco
--
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 v4 1/6] drivers:staging: ti-st: fmdrv common header file

2010-11-17 Thread Hans Verkuil
On Tuesday, November 16, 2010 14:18:09 manjunatha_ha...@ti.com wrote:
> From: Manjunatha Halli 
> 
> These are common headers used in FM submodules (FM V4L2, FM common,
> FM Rx,and FM TX).
> 
> Signed-off-by: Manjunatha Halli 
> ---
>  drivers/staging/ti-st/fmdrv.h |  259 
> +
>  1 files changed, 259 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/staging/ti-st/fmdrv.h
> 
> diff --git a/drivers/staging/ti-st/fmdrv.h b/drivers/staging/ti-st/fmdrv.h
> new file mode 100644
> index 000..68ed44c
> --- /dev/null
> +++ b/drivers/staging/ti-st/fmdrv.h
> @@ -0,0 +1,259 @@
> +/*
> + *  FM Driver for Connectivity chip of Texas Instruments.
> + *
> + *  Common header for all FM driver sub-modules.
> + *
> + *  Copyright (C) 2009 Texas Instruments
> + *
> + *  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.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + */
> +
> +#ifndef _FM_DRV_H
> +#define _FM_DRV_H
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define FM_DRV_VERSION"0.01"
> +/* Should match with FM_DRV_VERSION */
> +#define FM_DRV_RADIO_VERSION  KERNEL_VERSION(0, 0, 1)
> +#define FM_DRV_NAME   "ti_fmdrv"
> +#define FM_DRV_CARD_SHORT_NAME"TI FM Radio"
> +#define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio"
> +
> +/* Flag info */
> +#define FM_INTTASK_RUNNING0
> +#define FM_INTTASK_SCHEDULE_PENDING   1
> +#define FM_FIRMWARE_DW_INPROGRESS 2
> +#define FM_CORE_READY 3
> +#define FM_CORE_TRANSPORT_READY   4
> +#define FM_AF_SWITCH_INPROGRESS5
> +#define FM_CORE_TX_XMITING 6
> +
> +#define FM_TUNE_COMPLETE   0x1
> +#define FM_BAND_LIMIT  0x2
> +
> +#define FM_DRV_TX_TIMEOUT  (5*HZ)/* 5 seconds */
> +#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ)   /* 20 seconds */
> +
> +#define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0]))
> +
> +enum {
> + FM_MODE_OFF,
> + FM_MODE_TX,
> + FM_MODE_RX,
> + FM_MODE_ENTRY_MAX
> +};
> +
> +#define FM_RX_RDS_INFO_FIELD_MAX 8   /* 4 Group * 2 Bytes */
> +
> +/* TODO:
> + * move the following CIDs to videodev2.h upon acceptance
> + */
> +#define V4L2_CTRL_CLASS_FM_RX 0x009c /* FM Tuner control class */
> +/* FM Tuner class control IDs */
> +#define V4L2_CID_FM_RX_CLASS_BASE(V4L2_CTRL_CLASS_FM_RX | 0x900)
> +#define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1)
> +#define V4L2_CID_RSSI_THRESHOLD  (V4L2_CID_FM_RX_CLASS_BASE + 2)
> +#define V4L2_CID_TUNE_AF (V4L2_CID_FM_RX_CLASS_BASE + 3)

Please post an RFC describing these new controls.

> +enum v4l2_tune_af {
> + V4L2_FM_AF_OFF  = 0,
> + V4L2_FM_AF_ON   = 1
> +};

Huh? If it is an on/off type of controls, then it should be a boolean.

> +#define V4L2_CID_FM_BAND (V4L2_CID_FM_RX_CLASS_BASE + 1)
> +enum v4l2_fm_band {
> + V4L2_FM_BAND_OTHER  = 0,
> + V4L2_FM_BAND_JAPAN  = 1,
> + V4L2_FM_BAND_OIRT   = 2

This was proposed and rejected for the wl1273 driver. Instead the driver should
hide this complexity. See the wl1273 driver.

> +};
> +
> +/*
> + * define private CIDs for V4L2
> + */
> +#define V4L2_CID_CHANNEL_SPACING (V4L2_CID_PRIVATE_BASE + 0)

The wl1273 driver has defined a new standard channel spacing control. So that
should be used.

> +
> +/* RX RDS data format */
> +struct fm_rdsdata_format {
> + union {
> + struct {
> + unsigned char rdsbuff[FM_RX_RDS_INFO_FIELD_MAX];
> + } groupdatabuff;
> + struct {
> + unsigned short pidata;
> + unsigned char block_b_byte1;
> + unsigned char block_b_byte2;
> + unsigned char block_c_byte1;
> + unsigned char block_c_byte2;
> + unsigned char block_d_byte1;
> + unsigned char block_d_byte2;
> + } groupgeneral;
> + struct {
> + unsigned short pidata;
> + unsigned char block_b_byte1;
> + unsigned char block_b_byte2;
> + unsigned char firstaf;
> + unsigned char secondaf;
> + unsigned char firstpsbyte;
> 

Re: [PATCH] V4L/DVB: cx88: Add module parameter to disable IR

2010-11-17 Thread Jeremy Kerr
Hi Mariusz,

> AFAIK we have disable support in cx88:
> http://git.linuxtv.org/media_tree.git?a=commit;h=89c3bc78075042ae1f4452687f
> 626acce06b3b21

Ah, my bad - I was working off Linus' tree, and looks like that patch hasn't 
hit mainline yet.

As an aside, that patch has a problem: the MODULE_PARAM_DESC line uses 
'latency', not 'disable_ir'.

Cheers,


Jeremy
--
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] V4L/DVB: cx88: Add module parameter to disable IR

2010-11-17 Thread Mariusz Białończyk

On 2010-11-18 07:43, Jeremy Kerr wrote:

Currently, the cx88-input code unconditionally establishes an input
device for IR events. On some cards, this sets up a hrtimer to poll the
IR status frequently - I get around 200 wakeups per second from this
polling, and don't use the IR ports.

Although the hrtimer is only run when the input device is opened, the
device is actually unconditionally opened by kbd_connect, because we
have the EV_KEY bit set in the input device descriptor. In effect, the
IR device is always opened (and so polling) if CONFIG_VT.

This change adds a module parameter, 'ir_disable' to disable the IR
code, and not register this input device at all. This drastically
reduces the number of wakeups per second for me.


AFAIK we have disable support in cx88:
http://git.linuxtv.org/media_tree.git?a=commit;h=89c3bc78075042ae1f4452687f626acce06b3b21

isn't it related with your patch?

--
Mariusz Białończyk
jabber/e-mail: ma...@skyboo.net
http://manio.skyboo.net
--
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 v4 0/6] FM V4L2 drivers for WL128x

2010-11-17 Thread Hans Verkuil
On Thursday, November 18, 2010 06:54:16 Pavan Savoy wrote:
> Hans, Mauro, Ohad,
> 
> On Wed, Nov 17, 2010 at 6:32 PM, Ohad Ben-Cohen  wrote:
> > Hi Manjunatha,
> >
> > On Tue, Nov 16, 2010 at 3:18 PM,   wrote:
> >>  drivers/staging/ti-st/Kconfig|   10 +
> >>  drivers/staging/ti-st/Makefile   |2 +
> >>  drivers/staging/ti-st/fmdrv.h|  259 
> >>  drivers/staging/ti-st/fmdrv_common.c | 2141 
> >> ++
> >>  drivers/staging/ti-st/fmdrv_common.h |  458 
> >>  drivers/staging/ti-st/fmdrv_rx.c |  979 
> >>  drivers/staging/ti-st/fmdrv_rx.h |   59 +
> >>  drivers/staging/ti-st/fmdrv_tx.c |  461 
> >>  drivers/staging/ti-st/fmdrv_tx.h |   37 +
> >>  drivers/staging/ti-st/fmdrv_v4l2.c   |  757 
> >>  drivers/staging/ti-st/fmdrv_v4l2.h   |   32 +
> >>  11 files changed, 5195 insertions(+), 0 deletions(-)
> >
> > Usually when a driver is added to staging, it should also have a TODO
> > file specifying what needs to be done before the driver can be taken
> > out of staging (at least as far as the author knows of today).
> >
> > It helps keeping track of the open issues in the driver, which is good
> > for everyone - the author, the random contributor/observer, and
> > probably even the staging maintainer.
> >
> > Can you please add such a TODO file ?
> >
> > Thanks,
> > Ohad.
> 
> Thanks Ohad, for the comments, We do have an internal TODO.
> In terms of functionality we have stuff like TX RDS which already has
> few CIDs in the extended controls.
> extend V4L2 for complete-scan, add in stop search during hw_seek .. etc...
> But I just wanted to ask whether this is good enough to be staged.
> Because as we begin to implement and add in the items in TODO - the
> patch set will keep continuing to grow.
> 
> So Hans, Mauro, What do you think ?
> It would be real helpful - if this can be staged, it is becoming
> difficult to maintain for us.

I have no problem with it going to staging. It is not yet ready for the
mainline. I'll try to do a quick review and point out what needs to be
changed.

Regards,

Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco
--
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 4/7] v4l: videobuf2: add DMA coherent allocator

2010-11-17 Thread Sewoon Park
Hi Marek~ 

Marek Szyprowski wrote:
> Sent: Wednesday, November 17, 2010 5:40 PM
> To: linux-media@vger.kernel.org
> Cc: m.szyprow...@samsung.com; pa...@osciak.com; kyungmin.p...@samsung.com
> Subject: [PATCH 4/7] v4l: videobuf2: add DMA coherent allocator
> 
> From: Pawel Osciak 
> 
> Add an implementation of DMA coherent memory allocator and handling
> routines for videobuf2, implemented on top of dma_alloc_coherent() call.
> 
> Signed-off-by: Pawel Osciak 
> Signed-off-by: Kyungmin Park 
> Signed-off-by: Marek Szyprowski 
> CC: Pawel Osciak 
> ---
>  drivers/media/video/Kconfig  |5 +
>  drivers/media/video/Makefile |1 +
>  drivers/media/video/videobuf2-dma-coherent.c |  208
> ++
>  include/media/videobuf2-dma-coherent.h   |   27 
>  4 files changed, 241 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/videobuf2-dma-coherent.c
>  create mode 100644 include/media/videobuf2-dma-coherent.h
> 
> diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
> index 9351423..e7752ee1 100644
> --- a/drivers/media/video/Kconfig
> +++ b/drivers/media/video/Kconfig
> @@ -55,6 +55,11 @@ config VIDEOBUF2_CORE
>  config VIDEOBUF2_MEMOPS
>   tristate
> 
> +config VIDEOBUF2_DMA_COHERENT
> + select VIDEOBUF2_CORE
> + select VIDEOBUF2_MEMOPS
> + tristate
> +
>  config VIDEOBUF2_VMALLOC
>   select VIDEOBUF2_CORE
>   select VIDEOBUF2_MEMOPS
> diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
> index 538bee9..baa74e7 100644
> --- a/drivers/media/video/Makefile
> +++ b/drivers/media/video/Makefile
> @@ -117,6 +117,7 @@ obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
>  obj-$(CONFIG_VIDEOBUF2_CORE) += videobuf2-core.o
>  obj-$(CONFIG_VIDEOBUF2_MEMOPS)   += videobuf2-memops.o
>  obj-$(CONFIG_VIDEOBUF2_VMALLOC)  += videobuf2-vmalloc.o
> +obj-$(CONFIG_VIDEOBUF2_DMA_COHERENT) += videobuf2-dma_coherent.o
> 
>  obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
> 
> diff --git a/drivers/media/video/videobuf2-dma-coherent.c
> b/drivers/media/video/videobuf2-dma-coherent.c
> new file mode 100644
> index 000..761f366
> --- /dev/null
> +++ b/drivers/media/video/videobuf2-dma-coherent.c
> @@ -0,0 +1,208 @@
> +/*
> + * videobuf2-dma-coherent.c - DMA coherent memory allocator for videobuf2
> + *
> + * Copyright (C) 2010 Samsung Electronics
> + *
> + * Author: Pawel Osciak 
> + *
> + * 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.
> + */
> +
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +struct vb2_dc_conf {
> + struct vb2_alloc_ctxalloc_ctx;
> + struct device   *dev;
> +};

(snip)

> +static void vb2_dma_coherent_put_userptr(void *mem_priv)
> +{
> + struct vb2_dc_buf *buf = mem_priv;
> +
> + if (!buf)
> + return;
> +
> + vb2_put_userptr(buf->vma);
> + kfree(buf);
> +}
> +
> +const struct vb2_mem_ops vb2_dma_coherent_ops = {
> + .alloc  = vb2_dma_coherent_alloc,
> + .put= vb2_dma_coherent_put,
> + .paddr  = vb2_dma_coherent_paddr,

The "paddr" is not exist in vb2_mem_ops after [PATCH v4 xxx] lists.
I think you should fix from paddr to cookie like CMA allocator.

> + .mmap   = vb2_dma_coherent_mmap,
> + .get_userptr= vb2_dma_coherent_get_userptr,
> + .put_userptr= vb2_dma_coherent_put_userptr,
> + .num_users  = vb2_dma_coherent_num_users,
> +};
> +

(snip)

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

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


[PATCH] V4L/DVB: cx88: Add module parameter to disable IR

2010-11-17 Thread Jeremy Kerr
From: Jeremy Kerr 

Currently, the cx88-input code unconditionally establishes an input
device for IR events. On some cards, this sets up a hrtimer to poll the
IR status frequently - I get around 200 wakeups per second from this
polling, and don't use the IR ports.

Although the hrtimer is only run when the input device is opened, the
device is actually unconditionally opened by kbd_connect, because we
have the EV_KEY bit set in the input device descriptor. In effect, the
IR device is always opened (and so polling) if CONFIG_VT.

This change adds a module parameter, 'ir_disable' to disable the IR
code, and not register this input device at all. This drastically
reduces the number of wakeups per second for me.

Signed-off-by: Jeremy Kerr 

---
 drivers/media/video/cx88/cx88-input.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/video/cx88/cx88-input.c 
b/drivers/media/video/cx88/cx88-input.c
index fc777bc..d49af18 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -67,6 +67,10 @@ static int ir_debug;
 module_param(ir_debug, int, 0644); /* debug level [IR] */
 MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
 
+static int ir_disable;
+module_param(ir_disable, int, 0644);
+MODULE_PARM_DESC(ir_disable, "disable IR support");
+
 #define ir_dprintk(fmt, arg...)if (ir_debug) \
printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg)
 
@@ -244,6 +248,9 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev 
*pci)
 * used with a full-code IR table
 */
 
+   if (ir_disable)
+   return 0;
+
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
input_dev = input_allocate_device();
if (!ir || !input_dev)
--
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 38/51] ARM: imx: move mx25 support to mach-imx

2010-11-17 Thread Baruch Siach
Hi Uwe,

Tanks for all this work.

Once this get merged we can get rid of the ugly '#ifdef CONFIG_MACH_MX27' in 
drivers/media/video/mx2_camera.c. Should such a patch go via Sascha's tree or 
the V4L tree?

baruch

On Wed, Nov 17, 2010 at 10:30:06PM +0100, Uwe Kleine-König wrote:
> Signed-off-by: Uwe Kleine-König 
> ---
>  arch/arm/Makefile  |2 +-
>  arch/arm/mach-imx/Kconfig  |   85 +--
>  arch/arm/mach-imx/Makefile |6 +
>  arch/arm/mach-imx/Makefile.boot|4 +
>  arch/arm/mach-imx/clock-imx25.c|  332 
> 
>  arch/arm/mach-imx/devices-imx25.h  |   86 ++
>  arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c |  296 +
>  arch/arm/mach-imx/mach-eukrea_cpuimx25.c   |  161 
>  arch/arm/mach-imx/mach-mx25_3ds.c  |  223 
>  arch/arm/mach-imx/mm-imx25.c   |   62 +
>  arch/arm/mach-mx25/Kconfig |   43 ---
>  arch/arm/mach-mx25/Makefile|5 -
>  arch/arm/mach-mx25/Makefile.boot   |3 -
>  arch/arm/mach-mx25/clock.c |  332 
> 
>  arch/arm/mach-mx25/devices-imx25.h |   86 --
>  arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c  |  296 -
>  arch/arm/mach-mx25/mach-cpuimx25.c |  161 
>  arch/arm/mach-mx25/mach-mx25_3ds.c |  223 
>  arch/arm/mach-mx25/mm.c|   62 -
>  arch/arm/plat-mxc/Kconfig  |5 -
>  20 files changed, 1240 insertions(+), 1233 deletions(-)
>  create mode 100644 arch/arm/mach-imx/clock-imx25.c
>  create mode 100644 arch/arm/mach-imx/devices-imx25.h
>  create mode 100644 arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c
>  create mode 100644 arch/arm/mach-imx/mach-eukrea_cpuimx25.c
>  create mode 100644 arch/arm/mach-imx/mach-mx25_3ds.c
>  create mode 100644 arch/arm/mach-imx/mm-imx25.c
>  delete mode 100644 arch/arm/mach-mx25/Kconfig
>  delete mode 100644 arch/arm/mach-mx25/Makefile
>  delete mode 100644 arch/arm/mach-mx25/Makefile.boot
>  delete mode 100644 arch/arm/mach-mx25/clock.c
>  delete mode 100644 arch/arm/mach-mx25/devices-imx25.h
>  delete mode 100644 arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
>  delete mode 100644 arch/arm/mach-mx25/mach-cpuimx25.c
>  delete mode 100644 arch/arm/mach-mx25/mach-mx25_3ds.c
>  delete mode 100644 arch/arm/mach-mx25/mm.c

[snip]

-- 
 ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
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 v4 0/6] FM V4L2 drivers for WL128x

2010-11-17 Thread Pavan Savoy
Hans, Mauro, Ohad,

On Wed, Nov 17, 2010 at 6:32 PM, Ohad Ben-Cohen  wrote:
> Hi Manjunatha,
>
> On Tue, Nov 16, 2010 at 3:18 PM,   wrote:
>>  drivers/staging/ti-st/Kconfig        |   10 +
>>  drivers/staging/ti-st/Makefile       |    2 +
>>  drivers/staging/ti-st/fmdrv.h        |  259 
>>  drivers/staging/ti-st/fmdrv_common.c | 2141 
>> ++
>>  drivers/staging/ti-st/fmdrv_common.h |  458 
>>  drivers/staging/ti-st/fmdrv_rx.c     |  979 
>>  drivers/staging/ti-st/fmdrv_rx.h     |   59 +
>>  drivers/staging/ti-st/fmdrv_tx.c     |  461 
>>  drivers/staging/ti-st/fmdrv_tx.h     |   37 +
>>  drivers/staging/ti-st/fmdrv_v4l2.c   |  757 
>>  drivers/staging/ti-st/fmdrv_v4l2.h   |   32 +
>>  11 files changed, 5195 insertions(+), 0 deletions(-)
>
> Usually when a driver is added to staging, it should also have a TODO
> file specifying what needs to be done before the driver can be taken
> out of staging (at least as far as the author knows of today).
>
> It helps keeping track of the open issues in the driver, which is good
> for everyone - the author, the random contributor/observer, and
> probably even the staging maintainer.
>
> Can you please add such a TODO file ?
>
> Thanks,
> Ohad.

Thanks Ohad, for the comments, We do have an internal TODO.
In terms of functionality we have stuff like TX RDS which already has
few CIDs in the extended controls.
extend V4L2 for complete-scan, add in stop search during hw_seek .. etc...
But I just wanted to ask whether this is good enough to be staged.
Because as we begin to implement and add in the items in TODO - the
patch set will keep continuing to grow.

So Hans, Mauro, What do you think ?
It would be real helpful - if this can be staged, it is becoming
difficult to maintain for us.

Thanks,
Pavan

>>  create mode 100644 drivers/staging/ti-st/fmdrv.h
>>  create mode 100644 drivers/staging/ti-st/fmdrv_common.c
>>  create mode 100644 drivers/staging/ti-st/fmdrv_common.h
>>  create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
>>  create mode 100644 drivers/staging/ti-st/fmdrv_rx.h
>>  create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
>>  create mode 100644 drivers/staging/ti-st/fmdrv_tx.h
>>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
>>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] [media] cx231xx: stray unlock on error path

2010-11-17 Thread Dan Carpenter
The lock isn't held here and doesn't need to be unlocked.  The code has
been like this since the driver was merged. 

Signed-off-by: Dan Carpenter 

diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c 
b/drivers/media/video/cx231xx/cx231xx-cards.c
index 56c2d81..b7b905f 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -731,16 +731,12 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, 
struct usb_device *udev,
retval = cx231xx_register_analog_devices(dev);
if (retval < 0) {
cx231xx_release_resources(dev);
-   goto fail_reg_devices;
+   return retval;
}
 
cx231xx_init_extension(dev);
 
return 0;
-
-fail_reg_devices:
-   mutex_unlock(&dev->lock);
-   return retval;
 }
 
 #if defined(CONFIG_MODULES) && defined(MODULE)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] [media] bt8xx: missing unlock in bttv_overlay()

2010-11-17 Thread Dan Carpenter
There is a missing unlock here.  This was introduced as part of BKL
removal in c37db91fd0d4 "V4L/DVB: bttv: fix driver lock and remove
explicit calls to BKL"

Signed-off-by: Dan Carpenter 

diff --git a/drivers/media/video/bt8xx/bttv-driver.c 
b/drivers/media/video/bt8xx/bttv-driver.c
index 3da6e80..aca755c 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2779,16 +2779,14 @@ static int bttv_overlay(struct file *file, void *f, 
unsigned int on)
mutex_lock(&fh->cap.vb_lock);
/* verify args */
if (unlikely(!btv->fbuf.base)) {
-   mutex_unlock(&fh->cap.vb_lock);
-   return -EINVAL;
-   }
-   if (unlikely(!fh->ov.setup_ok)) {
+   retval = -EINVAL;
+   } else if (unlikely(!fh->ov.setup_ok)) {
dprintk("bttv%d: overlay: !setup_ok\n", btv->c.nr);
retval = -EINVAL;
}
+   mutex_unlock(&fh->cap.vb_lock);
if (retval)
return retval;
-   mutex_unlock(&fh->cap.vb_lock);
}
 
if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY))
--
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: Translation faults with OMAP ISP

2010-11-17 Thread Lane Brooks

On 11/17/2010 04:09 PM, Laurent Pinchart wrote:

Hi Lane,

On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:

Laurent,

I am getting iommu translation errors when I try to use the CCDC output
after using the Resizer output.

If I use the CCDC output to stream some video, then close it down,
switch to the Resizer output and open it up and try to stream, I get the
following errors spewing out:

omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00 translation
fault
omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
*pgd:

and the select times out.

  From a fresh boot, I can stream just fine from the Resizer and then
switch to the CCDC output just fine. It is only when I go from the CCDC
to the Resizer that I get this problem. Furthermore, when it gets into
this state, then anything dev node I try to use has the translation
errors and the only way to recover is to reboot.

Any ideas on the problem?

Ouch. First of all, could you please make sure you run the latest code ? Many
bugs have been fixed in the last few months


I had a pretty good idea that this would be your response, but I was 
hoping otherwise as merging has become more and more difficult to keep 
up with. Anyway, until I have a chance to merge in everything, I just 
found a work around for our usage needs, and that is to always use the 
resizer output and just change the resizer format between full 
resolution and preview resolution. This has turned out to be much more 
stable than switching between the CCDC and RESIZER dev nodes.


Thanks again for your feedback.

Lane
--
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: Translation faults with OMAP ISP

2010-11-17 Thread Laurent Pinchart
Hi Lane,

On Wednesday 17 November 2010 00:46:27 Lane Brooks wrote:
> Laurent,
> 
> I am getting iommu translation errors when I try to use the CCDC output
> after using the Resizer output.
> 
> If I use the CCDC output to stream some video, then close it down,
> switch to the Resizer output and open it up and try to stream, I get the
> following errors spewing out:
> 
> omap-iommu omap-iommu.0: omap2_iommu_fault_isr: da:00d0ef00 translation
> fault
> omap-iommu omap-iommu.0: iommu_fault_handler: da:00d0ef00 pgd:ce664034
> *pgd:
> 
> and the select times out.
> 
>  From a fresh boot, I can stream just fine from the Resizer and then
> switch to the CCDC output just fine. It is only when I go from the CCDC
> to the Resizer that I get this problem. Furthermore, when it gets into
> this state, then anything dev node I try to use has the translation
> errors and the only way to recover is to reboot.
> 
> Any ideas on the problem?

Ouch. First of all, could you please make sure you run the latest code ? Many 
bugs have been fixed in the last few months.

-- 
Regards,

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


[PATCH] rc: fix sysfs entry for mceusb and streamzap

2010-11-17 Thread Jarod Wilson
>From 4c13334d96e667dfbad90882ffe671d598d30d7f Mon Sep 17 00:00:00 2001
From: Paul Bender 
Date: Wed, 17 Nov 2010 14:56:17 -0500
Subject: [PATCH] rc: fix sysfs entry for mceusb and streamzap

When trying to create persistent device names for mceusb and streamzap
devices, I noticed that their respective drivers are not creating the rc
device as a child of the USB device. Rather it creates it as virtual
device. As a result, udev cannot use the USB device information to
create persistent device names for event and lirc devices associated
with the rc device. Not having persistent device names makes it more
difficult to make use of the devices in userspace as their names can
change.

Signed-off-by: Paul Bender 

Forward-ported to media_tree staging/for_v2.6.38 and tested with
both streamzap and mceusb devices:

$ ll /dev/input/by-id/
...
lrwxrwxrwx. 1 root root 9 Nov 17 17:06 
usb-Streamzap__Inc._Streamzap_Remote_Control-event-if00 -> ../event6
lrwxrwxrwx. 1 root root 9 Nov 17 17:05 
usb-Topseed_Technology_Corp._eHome_Infrared_Transceiver_TS000BzY-event-if00 -> 
../event5

Previously, nada.

Tested-by: Jarod Wilson 
Signed-off-by: Jarod Wilson 
---
 drivers/media/rc/mceusb.c|5 -
 drivers/media/rc/streamzap.c |3 +++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 968cf1f..2cca983 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define DRIVER_VERSION "1.91"
@@ -1044,7 +1045,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct 
mceusb_dev *ir)
 
snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)",
 mceusb_model[ir->model].name ?
-   mceusb_model[ir->model].name :
+   mceusb_model[ir->model].name :
"Media Center Ed. eHome Infrared Remote Transceiver",
 le16_to_cpu(ir->usbdev->descriptor.idVendor),
 le16_to_cpu(ir->usbdev->descriptor.idProduct));
@@ -1053,6 +1054,8 @@ static struct rc_dev *mceusb_init_rc_dev(struct 
mceusb_dev *ir)
 
rc->input_name = ir->name;
rc->input_phys = ir->phys;
+   usb_to_input_id(ir->usbdev, &rc->input_id);
+   rc->dev.parent = dev;
rc->priv = ir;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protos = IR_TYPE_ALL;
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 19652d4..b2eef51 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define DRIVER_VERSION "1.61"
@@ -315,6 +316,8 @@ static struct rc_dev *streamzap_init_rc_dev(struct 
streamzap_ir *sz)
 
rdev->input_name = sz->name;
rdev->input_phys = sz->phys;
+   usb_to_input_id(sz->usbdev, &rdev->input_id);
+   rdev->dev.parent = dev;
rdev->priv = sz;
rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protos = IR_TYPE_ALL;
-- 
1.7.1


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


HVR900H : analog audio input

2010-11-17 Thread Massis Sirapian

Hi,

In parallel of my IR investigations, I've tried to capture audio+video 
through RCA+S-VIDEO.


tvtime works perfectly to show the video stream, but it complains about 
a mute card for audio.


Loading tm6000-alsa doesn't change anything and alsamixer says device 
has no control.


dmesg says
[ 8289.655732] tm6000_alsa: module is from the staging directory, the 
quality is unknown, you have been warned.
[ 8289.657114] tm6000 #0/1: Registered audio driver for TM5600/60x0 
Audio at bus 2 device 5

[ 8289.657116] tm6000 #0: Initialized (TM6000 Audio Extension) extension
[ 8289.680811] tm6000 #0/1: Stopping audio DMA
[ 8289.714352] tm6000 #0/1: Stopping audio DMA
[ 8289.750136] tm6000 #0/1: Stopping audio DMA
[ 8289.786166] tm6000 #0/1: Stopping audio DMA
[ 8289.822196] tm6000 #0/1: Stopping audio DMA
[ 8289.857689] tm6000 #0/1: Stopping audio DMA
[ 8289.897843] tm6000 #0/1: Starting audio DMA
[ 8294.973206] tm6000 #0/1: Stopping audio DMA
[ 8295.008157] tm6000 #0/1: Stopping audio DMA
[ 8295.044065] tm6000 #0/1: Stopping audio DMA

I also have a lot of :
[ 8433.752545] tm6000 tm6000_irq_callback :urb resubmit failed (error=-1)

Is it normal (analog audio not implemented) ?

Another symptom is also that modprobing tm6000 takes like 1 minute to 
load, and opening TV (DVB or analog) takes 20-30 sec the first time 
(switching channels is faster then). Is it an expected behaviour (looks 
like it takes time after having loaded the firmware) ?


Thanks

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


Re: [GIT PATCHES FOR 2.6.38] mantis for_2.6.38

2010-11-17 Thread Mauro Carvalho Chehab
Em 17-11-2010 17:43, Marko Ristola escreveu:
> 
> Hi Bjørn Mork and Mauro Carvalho Chehab.
> 
> The following patch was an experiment and wasn't actually meant for inclusion 
> into the Kernel.
> 
 Jul,10 2010: Mantis driver patch: use interrupt for I2C traffic instead of 
 busy reg http://patchwork.kernel.org/patch/111245  Marko Ristola 
 
> 
> Would you please drop it from the Patchwork?

Updated, thanks.

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: [patch 3/3] [media] lirc_dev: fixes in lirc_dev_fop_read()

2010-11-17 Thread Jarod Wilson
On Wed, Nov 17, 2010 at 08:20:15AM +0300, Dan Carpenter wrote:
> This makes several changes but they're in one function and sort of
> related:
> 
> "buf" was leaked on error.  The leak if we try to read an invalid
> length is the main concern because it could be triggered over and
> over.
> 
> If the copy_to_user() failed, then the original code returned the 
> number of bytes remaining.  read() is supposed to be the opposite way,
> where we return the number of bytes copied.  I changed it to just return
> -EFAULT on errors.
> 
> Also I changed the debug output from "-EFAULT" to just "" because
> it isn't -EFAULT necessarily.  And since we go though that path if the
> length is invalid now, there was another debug print that I removed.
> 
> Signed-off-by: Dan Carpenter 

Looks good, thanks much.

Reviewed-by: Jarod Wilson 
Acked-by: Jarod Wilson 

-- 
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 2/3] [media] lirc_dev: add some __user annotations

2010-11-17 Thread Jarod Wilson
On Wed, Nov 17, 2010 at 08:13:39AM +0300, Dan Carpenter wrote:
> Sparse complains because there are no __user annotations.
> 
> drivers/media/IR/lirc_dev.c:156:27: warning:
>   incorrect type in initializer (incompatible argument 2 (different 
> address spaces))
> drivers/media/IR/lirc_dev.c:156:27:expected int ( *read )( ... )
> drivers/media/IR/lirc_dev.c:156:27:got int ( extern [toplevel] * 
> )( ... )
> 
> Signed-off-by: Dan Carpenter 

Acked-by: Jarod Wilson 

-- 
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 1/3] [media] lirc_dev: stray unlock in lirc_dev_fop_poll()

2010-11-17 Thread Jarod Wilson
On Wed, Nov 17, 2010 at 08:12:23AM +0300, Dan Carpenter wrote:
> We shouldn't unlock here.  I think this was a cut and paste error.

Yeah, looks like it.

Acked-by: Jarod Wilson 

-- 
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: [cron job] v4l-dvb daily build: WARNINGS

2010-11-17 Thread Hans Verkuil
On Wednesday, November 17, 2010 19:51:22 Anca Emanuel wrote:
> On Wed, Nov 17, 2010 at 8:27 PM, Hans Verkuil  wrote:
> > 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:Wed Nov 17 19:00:17 CET 2010
> > path:http://www.linuxtv.org/hg/v4l-dvb
> > changeset:   15167:abd3aac6644e
> > git master:   3e6dce76d99b328716b43929b9195adfee1de00c
> > git media-master: a348e9110ddb5d494e060d989b35dd1f35359d58
> > gcc version:  i686-linux-gcc (GCC) 4.5.1
> > host hardware:x86_64
> > host os:  2.6.32.5
> >
> > 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: WARNINGS
> > linux-git-mips: WARNINGS
> > linux-git-powerpc64: WARNINGS
> > linux-git-x86_64: WARNINGS
> > spec-git: OK
> > sparse: ERRORS
> >
> > Detailed results are available here:
> >
> > http://www.xs4all.nl/~hverkuil/logs/Wednesday.log
> >
> > Full logs are available here:
> >
> > http://www.xs4all.nl/~hverkuil/logs/Wednesday.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
> >
> 
> Is somebody take care of this ?

In what respect? I maintain the daily build, although I am well aware that
it needs more attention than I can give. The intention was to provide full
coverage of all drivers, but I know some boards are currently not covered.

I no longer have time to fix warnings/errors reported by the build, so if
someone would do that, then that would be great.

BTW, the build was still doing the 2.6.37 branch. I've just switched it to
the for_v2.6.38 branch. So tomorrow it will build from there.

Regards,

Hans

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


Re: [GIT PATCHES FOR 2.6.38] mantis for_2.6.38

2010-11-17 Thread Marko Ristola

Hi Bjørn Mork and Mauro Carvalho Chehab.

The following patch was an experiment and wasn't actually meant for inclusion 
into the Kernel.

>>> Jul,10 2010: Mantis driver patch: use interrupt for I2C traffic instead of 
>>> busy reg http://patchwork.kernel.org/patch/111245  Marko Ristola 
>>> 

Would you please drop it from the Patchwork?
Would you Bjørn remove it from your Git repository?
The patch is ugly and it doesn't work, the broken part is active only with 
vp2033.

I'm sorry for the hassle.
Cheers, Marko Ristola

13.11.2010 16:26, Mauro Carvalho Chehab wrote:
> Em 12-11-2010 12:43, Bjørn Mork escreveu:
>> Hello, 
>>
>> I've been waiting for this list of patchwork patches to be included for
>> quite a while, and have now taken the liberty to clean them up as
>> necessary and add them to a git tree, based on the current media_tree
>> for_v2.6.38 branch, with exceptions as noted below:
>>
>>> == mantis patches - Waiting for Manu Abraham 
>>>  == 
>>>
>>> Jul,10 2010: Mantis driver patch: use interrupt for I2C traffic instead of 
>>> busy reg http://patchwork.kernel.org/patch/111245  Marko Ristola 
>>> 

>> The following changes since commit 
>>
>> af9f14f7fc31f0d7b7cdf8f7f7f15a3c3794aea3[media] IR: add tv power 
>> scancode to rc6 mce keymap
>>
>> are available in the git repository at:
>>
>>   git://git.mork.no/mantis.git for_2.6.38
> 
--
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: HVR900H : IR Remote Control

2010-11-17 Thread Massis Sirapian



load the tm6000 module with the parameter "ir_debug=1". (not the
tm6000_dvb), and check dmsg after you pressed a button. Have the
received code the same from the map?


I have only
[ 5232.133592] tm5600/60x0 IR (tm6000 #0)/ir: ir->get_key result
data=
endlessly, and nothing seems to change when I press a button.

can you test a little change in tm6000-input.c. The dprintk line "this
line" move to "here", and then testing it.

return;
}

dprintk("ir->get_key result data=%04x\n", poll_result.rc_data); // this
line

if (ir->key) {
// here
ir_keydown(ir->rc, poll_result.rc_data, 0);
ir->key = 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


I've just tested the new kernel compiled with the modifie tm6000-cards.c

Nothing happens when I press a button :

[  227.643920] input: tm5600/60x0 IR (tm6000 #0) as 
/devices/pci:00/:00:1d.0/usb2/2-1/2-1.4/rc/rc0/input7
[  227.643965] rc0: tm5600/60x0 IR (tm6000 #0) as 
/devices/pci:00/:00:1d.0/usb2/2-1/2-1.4/rc/rc0

[  227.759492] usbcore: registered new interface driver tm6000
[  229.015963] tm6000: open called (dev=video1)

are the last lines of dmesg, and my pressing any button doesn't change 
anything.


Massis

--
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/10] [media] Rename all public generic RC functions from ir_ to rc_

2010-11-17 Thread Mauro Carvalho Chehab
Those functions are not InfraRed specific. So, rename them to properly
reflect it.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/dvb/dm1105/dm1105.c 
b/drivers/media/dvb/dm1105/dm1105.c
index e9cacf6..2d8b404 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -531,7 +531,7 @@ static void dm1105_emit_key(struct work_struct *work)
 
data = (ircom >> 8) & 0x7f;
 
-   ir_keydown(ir->dev, data, 0);
+   rc_keydown(ir->dev, data, 0);
 }
 
 /* work handler */
diff --git a/drivers/media/dvb/dvb-usb/af9015.c 
b/drivers/media/dvb/dvb-usb/af9015.c
index 8b9ab30..bc2a6e4 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -1041,13 +1041,13 @@ static int af9015_rc_query(struct dvb_usb_device *d)
priv->rc_keycode = buf[12] << 16 |
buf[13] << 8 | buf[14];
}
-   ir_keydown(d->rc_dev, priv->rc_keycode, 0);
+   rc_keydown(d->rc_dev, priv->rc_keycode, 0);
} else {
priv->rc_keycode = 0; /* clear just for sure */
}
} else if (priv->rc_repeat != buf[6] || buf[0]) {
deb_rc("%s: key repeated\n", __func__);
-   ir_keydown(d->rc_dev, priv->rc_keycode, 0);
+   rc_keydown(d->rc_dev, priv->rc_keycode, 0);
} else {
deb_rc("%s: no key press\n", __func__);
}
diff --git a/drivers/media/dvb/dvb-usb/anysee.c 
b/drivers/media/dvb/dvb-usb/anysee.c
index c6e4ba5..5e12488 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -394,7 +394,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)
 
if (ircode[0]) {
deb_rc("%s: key pressed %02x\n", __func__, ircode[1]);
-   ir_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0);
+   rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0);
}
 
return 0;
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c 
b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 3b58f45..1dd119e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -600,7 +600,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
goto resubmit;
}
 
-   ir_keydown(d->rc_dev, keycode, toggle);
+   rc_keydown(d->rc_dev, keycode, toggle);
 
 resubmit:
/* Clean the buffer before we requeue */
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c 
b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index be167f2..9ac920d 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -520,13 +520,13 @@ static int dib0700_rc_query_old_firmware(struct 
dvb_usb_device *d)
d->last_event = keycode;
}
 
-   ir_keydown(d->rc_dev, keycode, 0);
+   rc_keydown(d->rc_dev, keycode, 0);
break;
default:
/* RC-5 protocol changes toggle bit on new keypress */
keycode = key[3-2] << 8 | key[3-3];
toggle = key[3-1];
-   ir_keydown(d->rc_dev, keycode, toggle);
+   rc_keydown(d->rc_dev, keycode, toggle);
 
break;
}
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c 
b/drivers/media/dvb/dvb-usb/lmedm04.c
index f0c0308..1455c23 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -198,7 +198,7 @@ static int lme2510_remote_keypress(struct dvb_usb_adapter 
*adap, u16 keypress)
deb_info(1, "INT Key Keypress =%04x", keypress);
 
if (keypress > 0)
-   ir_keydown(d->rc_dev, keypress, 0);
+   rc_keydown(d->rc_dev, keypress, 0);
 
return 0;
 }
diff --git a/drivers/media/dvb/ttpci/budget-ci.c 
b/drivers/media/dvb/ttpci/budget-ci.c
index 32caa9b..8ae67c1 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -159,7 +159,7 @@ static void msp430_ir_interrupt(unsigned long data)
budget_ci->ir.rc5_device != (command & 0x1f))
return;
 
-   ir_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
+   rc_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
 }
 
 static int msp430_ir_init(struct budget_ci *budget_ci)
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index b6ba3c7..d67573e 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1146,14 +1146,14 @@ static u32 imon_remote_key_lookup(struct imon_context 
*ictx, u32 scancode)
bool is_release_code = false;
 
/* Look for the initial press of a button */
-   keycode = ir_g_keycode_from_table(ictx->rdev, scancode);
+   keycode = rc_g_keycode_from_table(ictx->rdev, scancode);
ictx->rc_toggle = 0x0;
ictx-

[PATCH 03/10] [media] rc: rename the remaining things to rc_core

2010-11-17 Thread Mauro Carvalho Chehab
The Remote Controller subsystem is meant to be used not only by Infra Red
but also for similar types of Remote Controllers. The core is not specific
to Infra Red. As such, rename:
- ir-core.h to rc-core.h
- IR_CORE to RC_CORE
- namespace inside rc-core.c/rc-core.h

To be consistent with the other changes.

No functional change on this patch.

Signed-off-by: Mauro Carvalho Chehab 

 delete mode 100644 include/media/ir-core.h
 create mode 100644 include/media/rc-core.h

diff --git a/drivers/media/dvb/dm1105/Kconfig b/drivers/media/dvb/dm1105/Kconfig
index 576f3b7..f3de0a4 100644
--- a/drivers/media/dvb/dm1105/Kconfig
+++ b/drivers/media/dvb/dm1105/Kconfig
@@ -8,7 +8,7 @@ config DVB_DM1105
select DVB_CX24116 if !DVB_FE_CUSTOMISE
select DVB_SI21XX if !DVB_FE_CUSTOMISE
select DVB_DS3000 if !DVB_FE_CUSTOMISE
-   depends on IR_CORE
+   depends on RC_CORE
help
  Support for cards based on the SDMC DM1105 PCI chip like
  DvbWorld 2002
diff --git a/drivers/media/dvb/dm1105/dm1105.c 
b/drivers/media/dvb/dm1105/dm1105.c
index d1a4385..e9cacf6 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "demux.h"
 #include "dmxdev.h"
diff --git a/drivers/media/dvb/dvb-usb/Kconfig 
b/drivers/media/dvb/dvb-usb/Kconfig
index 2525d3b..3d48ba0 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,6 +1,6 @@
 config DVB_USB
tristate "Support for various USB DVB devices"
-   depends on DVB_CORE && USB && I2C && IR_CORE
+   depends on DVB_CORE && USB && I2C && RC_CORE
help
  By enabling this you will be able to choose the various supported
  USB1.1 and USB2.0 DVB devices.
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h 
b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 83aa982..18828cb 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "dvb_frontend.h"
 #include "dvb_demux.h"
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c 
b/drivers/media/dvb/dvb-usb/lmedm04.c
index d8f1b15..f0c0308 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -61,7 +61,7 @@
 #define DVB_USB_LOG_PREFIX "LME2510(C)"
 #include 
 #include 
-#include 
+#include 
 
 #include "dvb-usb.h"
 #include "lmedm04.h"
diff --git a/drivers/media/dvb/mantis/Kconfig b/drivers/media/dvb/mantis/Kconfig
index fd0830e..a13a505 100644
--- a/drivers/media/dvb/mantis/Kconfig
+++ b/drivers/media/dvb/mantis/Kconfig
@@ -1,6 +1,6 @@
 config MANTIS_CORE
tristate "Mantis/Hopper PCI bridge based devices"
-   depends on PCI && I2C && INPUT && IR_CORE
+   depends on PCI && I2C && INPUT && RC_CORE
 
help
  Support for PCI cards based on the Mantis and Hopper PCi bridge.
diff --git a/drivers/media/dvb/mantis/mantis_input.c 
b/drivers/media/dvb/mantis/mantis_input.c
index 209f211..e030b18 100644
--- a/drivers/media/dvb/mantis/mantis_input.c
+++ b/drivers/media/dvb/mantis/mantis_input.c
@@ -18,7 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include 
+#include 
 #include 
 
 #include "dmxdev.h"
diff --git a/drivers/media/dvb/siano/Kconfig b/drivers/media/dvb/siano/Kconfig
index e520bce..bc6456e 100644
--- a/drivers/media/dvb/siano/Kconfig
+++ b/drivers/media/dvb/siano/Kconfig
@@ -4,7 +4,7 @@
 
 config SMS_SIANO_MDTV
tristate "Siano SMS1xxx based MDTV receiver"
-   depends on DVB_CORE && IR_CORE && HAS_DMA
+   depends on DVB_CORE && RC_CORE && HAS_DMA
---help---
  Choose Y or M here if you have MDTV receiver with a Siano chipset.
 
diff --git a/drivers/media/dvb/siano/smsir.h b/drivers/media/dvb/siano/smsir.h
index c2f68a4..ae92b3a 100644
--- a/drivers/media/dvb/siano/smsir.h
+++ b/drivers/media/dvb/siano/smsir.h
@@ -28,7 +28,7 @@ along with this program.  If not, see 
.
 #define __SMS_IR_H__
 
 #include 
-#include 
+#include 
 
 #define IR_DEFAULT_TIMEOUT 100
 
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 0ffd694..44afab2 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -97,7 +97,7 @@ config DVB_BUDGET_CI
select DVB_LNBP21 if !DVB_FE_CUSTOMISE
select DVB_TDA10023 if !DVB_FE_CUSTOMISE
select MEDIA_TUNER_TDA827X if !MEDIA_TUNER_CUSTOMISE
-   depends on IR_CORE
+   depends on RC_CORE
help
  Support for simple SAA7146 based DVB cards
  (so called Budget- or Nova-PCI cards) without onboard
diff --git a/drivers/media/dvb/ttpci/budget-ci.c 
b/drivers/media/dvb/ttpci/budget-ci.c
index 9aca0f3..32caa9b 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -34,7 +34,

[PATCH 02/10] [media] rc: Remove ir-common.h

2010-11-17 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 

 delete mode 100644 include/media/ir-common.h

diff --git a/drivers/media/video/bt8xx/bttv-input.c 
b/drivers/media/video/bt8xx/bttv-input.c
index e8f60ab..e4df7f8 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -147,6 +147,11 @@ static void bttv_input_timer(unsigned long data)
  * testing.
  */
 
+#define RC5_START(x)   (((x) >> 12) & 3)
+#define RC5_TOGGLE(x)  (((x) >> 11) & 1)
+#define RC5_ADDR(x)(((x) >> 6) & 31)
+#define RC5_INSTR(x)   ((x) & 63)
+
 /* decode raw bit pattern to RC5 code */
 static u32 bttv_rc5_decode(unsigned int code)
 {
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index 6fd2a8e..fd62bf1 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/media/video/bt8xx/bttvp.h 
b/drivers/media/video/bt8xx/bttvp.h
index 157285b..0bbdd48 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -41,7 +41,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include "bt848.h"
@@ -120,6 +120,47 @@ struct bttv_format {
int  hshift,vshift;   /* for planar modes   */
 };
 
+struct card_ir {
+   struct rc_dev   *dev;
+
+   charname[32];
+   charphys[32];
+#if 0
+   int users;
+   u32 running:1;
+#endif
+   /* Usual gpio signalling */
+   u32 mask_keycode;
+   u32 mask_keydown;
+   u32 mask_keyup;
+   u32 polling;
+   u32 last_gpio;
+   int shift_by;
+   int start; // What should RC5_START() be
+   int addr; // What RC5_ADDR() should be.
+   int rc5_remote_gap;
+   struct work_struct  work;
+   struct timer_list   timer;
+
+   /* RC5 gpio */
+   u32 rc5_gpio;
+   struct timer_list timer_end;/* timer_end for code completion */
+   u32 last_bit;   /* last raw bit seen */
+   u32 code;   /* raw code under construction */
+   struct timeval base_time;   /* time of last seen code */
+   int active; /* building raw code */
+
+#if 0
+   /* NEC decoding */
+   u32 nec_gpio;
+   struct tasklet_struct   tlet;
+
+   /* IR core raw decoding */
+   u32 raw_decode;
+#endif
+};
+
+
 /* -- */
 
 struct bttv_geometry {
diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 72562b8..900e798 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -61,7 +61,7 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
 
 static int build_key(struct saa7134_dev *dev)
 {
-   struct card_ir *ir = dev->remote;
+   struct saa7134_card_ir *ir = dev->remote;
u32 gpio, data;
 
/* here comes the additional handshake steps for some cards */
@@ -385,7 +385,7 @@ static int get_key_pinnacle_color(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw)
 
 void saa7134_input_irq(struct saa7134_dev *dev)
 {
-   struct card_ir *ir;
+   struct saa7134_card_ir *ir;
 
if (!dev || !dev->remote)
return;
@@ -404,7 +404,7 @@ void saa7134_input_irq(struct saa7134_dev *dev)
 static void saa7134_input_timer(unsigned long data)
 {
struct saa7134_dev *dev = (struct saa7134_dev *)data;
-   struct card_ir *ir = dev->remote;
+   struct saa7134_card_ir *ir = dev->remote;
 
build_key(dev);
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
@@ -413,17 +413,17 @@ static void saa7134_input_timer(unsigned long data)
 static void ir_raw_decode_timer_end(unsigned long data)
 {
struct saa7134_dev *dev = (struct saa7134_dev *)data;
-   struct card_ir *ir = dev->remote;
+   struct saa7134_card_ir *ir = dev->remote;
 
ir_raw_event_handle(dev->remote->dev);
 
-   ir->active = 0;
+   ir->active = false;
 }
 
 static int __saa7134_ir_start(void *priv)
 {
struct saa7134_dev *dev = priv;
-   struct card_ir *ir;
+   struct saa7134_card_ir *ir;
 
if (!dev)
return -EINVAL;
@@ -435,7 +435,7 @@ static int __saa7134_ir_start(void *priv)
if (ir->running)
return 0;
 
-   ir->running = 1;
+   ir->running = true;
if (ir->polling) {
setup_timer(&ir->timer, saa7134_input_timer,
(unsigned long)dev);
@@ -446,7 +446,7 @@ static int __saa7134_ir_start(void *priv)
  

[PATCH 01/10] [media] rc: remove ir-common module

2010-11-17 Thread Mauro Carvalho Chehab
Something weird happened with commit 740069e6e043403199dbe2b42256722fb814f6ae.
Instead of dong the right thing, it got somehow corrupted and reverted the
rc changes.

Thanks to David Härdeman for pointing me about the problem.

This patch should be merged with 740069e6e04 before sending upstream.

Signed-off-by: Mauro Carvalho Chehab 

 delete mode 100644 drivers/media/rc/ir-functions.c

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 2d15468..ef19375 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -10,11 +10,6 @@ menuconfig IR_CORE
  if you don't need IR, as otherwise, you may not be able to
  compile the driver for your adapter.
 
-config IR_LEGACY
-   tristate
-   depends on IR_CORE
-   default IR_CORE
-
 if IR_CORE
 
 config LIRC
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 859c12c..8c0e4cb 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -1,10 +1,8 @@
-ir-common-objs  := ir-functions.o
 rc-core-objs   := rc-main.o rc-raw.o
 
 obj-y += keymaps/
 
 obj-$(CONFIG_IR_CORE) += rc-core.o
-obj-$(CONFIG_IR_LEGACY) += ir-common.o
 obj-$(CONFIG_LIRC) += lirc_dev.o
 obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
 obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o
diff --git a/drivers/media/rc/ir-functions.c b/drivers/media/rc/ir-functions.c
deleted file mode 100644
index 14397d0..000
--- a/drivers/media/rc/ir-functions.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * some common functions to handle infrared remote protocol decoding for
- * drivers which have not yet been (or can't be) converted to use the
- * regular protocol decoders...
- *
- * (c) 2003 Gerd Knorr  [SuSE Labs]
- *
- *  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
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include 
-#include 
-#include 
-#include 
-#include "rc-core-priv.h"
-
-/* -- 
*/
-
-MODULE_AUTHOR("Gerd Knorr  [SuSE Labs]");
-MODULE_LICENSE("GPL");
-
-/* RC5 decoding stuff, moved from bttv-input.c to share it with
- * saa7134 */
-
-/* decode raw bit pattern to RC5 code */
-static u32 ir_rc5_decode(unsigned int code)
-{
-   unsigned int org_code = code;
-   unsigned int pair;
-   unsigned int rc5 = 0;
-   int i;
-
-   for (i = 0; i < 14; ++i) {
-   pair = code & 0x3;
-   code >>= 2;
-
-   rc5 <<= 1;
-   switch (pair) {
-   case 0:
-   case 2:
-   break;
-   case 1:
-   rc5 |= 1;
-   break;
-   case 3:
-   IR_dprintk(1, "ir-common: ir_rc5_decode(%x) bad 
code\n", org_code);
-   return 0;
-   }
-   }
-   IR_dprintk(1, "ir-common: code=%x, rc5=%x, start=%x, toggle=%x, 
address=%x, "
-   "instr=%x\n", rc5, org_code, RC5_START(rc5),
-   RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
-   return rc5;
-}
-
-void ir_rc5_timer_end(unsigned long data)
-{
-   struct card_ir *ir = (struct card_ir *)data;
-   struct timeval tv;
-   unsigned long current_jiffies;
-   u32 gap;
-   u32 rc5 = 0;
-
-   /* get time */
-   current_jiffies = jiffies;
-   do_gettimeofday(&tv);
-
-   /* avoid overflow with gap >1s */
-   if (tv.tv_sec - ir->base_time.tv_sec > 1) {
-   gap = 20;
-   } else {
-   gap = 100 * (tv.tv_sec - ir->base_time.tv_sec) +
-   tv.tv_usec - ir->base_time.tv_usec;
-   }
-
-   /* signal we're ready to start a new code */
-   ir->active = 0;
-
-   /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
-   if (gap < 28000) {
-   IR_dprintk(1, "ir-common: spurious timer_end\n");
-   return;
-   }
-
-   if (ir->last_bit < 20) {
-   /* ignore spurious codes (caused by light/other remotes) */
-   IR_dprintk(1, "ir-common: short code: %x\n", ir->code);
-   } else {
-   ir->code = (ir->code << ir->shift_by) | 1;
-   rc5 = ir_rc5_decode(ir->code);
-
-   /* two start bits? */
-   if (RC5_START(rc5) != ir->start) {
-  

[PATCH 00/10] rc: rc cleanup/renaming patches

2010-11-17 Thread Mauro Carvalho Chehab
The patch that removed ir-common.h were broken. After fixing it, I noticed
that some cleanups were required. I ended by doing a large renaming stuff
to compliment the changes made so far.

The logic I used for the renaming logic at RC subsystem is:

- All non-IR specific stuff is called rc_*;
- All IR-specific stuff (e. g. IR raw decoding) uses ir_*;
- All keycode/scancode map stuff is called rc_map_*;

I didn't went that far, but it could be a good idea to split ir_raw into
a different module and to create a ir_raw.h with the IR raw stuff.

Mauro Carvalho Chehab (10):
  [media] rc: remove ir-common module
  [media] rc: Remove ir-common.h
  [media] rc: rename the remaining things to rc_core
  [media] Rename all public generic RC functions from ir_ to rc_
  [media] cx231xx: Properly name rc_map name
  [media] rc: Rename remote controller type to rc_type instead of
ir_type
  [media] rc: Properly name the rc_map struct
  [media] rc: Name RC keymap tables as rc_map_table
  [media] rc: use rc_map_ prefix for all rc map tables
  [media] rc: Rename IR raw interface to ir-raw.c

 drivers/media/dvb/dm1105/Kconfig   |2 +-
 drivers/media/dvb/dm1105/dm1105.c  |4 +-
 drivers/media/dvb/dvb-usb/Kconfig  |2 +-
 drivers/media/dvb/dvb-usb/a800.c   |6 +-
 drivers/media/dvb/dvb-usb/af9005-remote.c  |   16 +-
 drivers/media/dvb/dvb-usb/af9005.c |   16 +-
 drivers/media/dvb/dvb-usb/af9005.h |4 +-
 drivers/media/dvb/dvb-usb/af9015.c |   16 +-
 drivers/media/dvb/dvb-usb/anysee.c |4 +-
 drivers/media/dvb/dvb-usb/az6027.c |6 +-
 drivers/media/dvb/dvb-usb/cinergyT2-core.c |6 +-
 drivers/media/dvb/dvb-usb/cxusb.c  |   62 ++--
 drivers/media/dvb/dvb-usb/dib0700.h|2 +-
 drivers/media/dvb/dvb-usb/dib0700_core.c   |   14 +-
 drivers/media/dvb/dvb-usb/dib0700_devices.c|   90 +++---
 drivers/media/dvb/dvb-usb/dibusb-common.c  |4 +-
 drivers/media/dvb/dvb-usb/dibusb-mb.c  |   16 +-
 drivers/media/dvb/dvb-usb/dibusb-mc.c  |4 +-
 drivers/media/dvb/dvb-usb/dibusb.h |2 +-
 drivers/media/dvb/dvb-usb/digitv.c |   14 +-
 drivers/media/dvb/dvb-usb/dtt200u.c|   18 +-
 drivers/media/dvb/dvb-usb/dvb-usb-remote.c |   26 +-
 drivers/media/dvb/dvb-usb/dvb-usb.h|   18 +-
 drivers/media/dvb/dvb-usb/dw2102.c |   54 ++--
 drivers/media/dvb/dvb-usb/lmedm04.c|4 +-
 drivers/media/dvb/dvb-usb/m920x.c  |   24 +-
 drivers/media/dvb/dvb-usb/nova-t-usb2.c|   18 +-
 drivers/media/dvb/dvb-usb/opera1.c |   16 +-
 drivers/media/dvb/dvb-usb/vp702x.c |   12 +-
 drivers/media/dvb/dvb-usb/vp7045.c |   12 +-
 drivers/media/dvb/mantis/Kconfig   |2 +-
 drivers/media/dvb/mantis/mantis_input.c|   14 +-
 drivers/media/dvb/siano/Kconfig|2 +-
 drivers/media/dvb/siano/smsir.c|2 +-
 drivers/media/dvb/siano/smsir.h|2 +-
 drivers/media/dvb/ttpci/Kconfig|2 +-
 drivers/media/dvb/ttpci/budget-ci.c|4 +-
 drivers/media/rc/Kconfig   |   40 +--
 drivers/media/rc/Makefile  |6 +-
 drivers/media/rc/ene_ir.c  |4 +-
 drivers/media/rc/imon.c|   50 ++--
 drivers/media/rc/ir-functions.c|  120 ---
 drivers/media/rc/ir-jvc-decoder.c  |8 +-
 drivers/media/rc/ir-lirc-codec.c   |6 +-
 drivers/media/rc/ir-nec-decoder.c  |   10 +-
 drivers/media/rc/ir-raw.c  |  371 
 drivers/media/rc/ir-rc5-decoder.c  |6 +-
 drivers/media/rc/ir-rc5-sz-decoder.c   |6 +-
 drivers/media/rc/ir-rc6-decoder.c  |6 +-
 drivers/media/rc/ir-sony-decoder.c |6 +-
 drivers/media/rc/keymaps/Kconfig   |2 +-
 drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c|   10 +-
 drivers/media/rc/keymaps/rc-alink-dtu-m.c  |   10 +-
 drivers/media/rc/keymaps/rc-anysee.c   |   10 +-
 drivers/media/rc/keymaps/rc-apac-viewcomp.c|   10 +-
 drivers/media/rc/keymaps/rc-asus-pc39.c|   10 +-
 drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c |   10 +-
 drivers/media/rc/keymaps/rc-avermedia-a16d.c   |   10 +-
 drivers/media/rc/keymaps/rc-avermedia-cardbus.c|   10 +-
 drivers/media/rc/keymaps/rc-avermedia-dvbt.c   |   10 +-
 drivers/media/rc/keymaps/rc-avermedia-m135a.c  |   10 +-
 .../media/rc/keymaps/rc-avermedia-m733a-rm-k6.c|   10 +-
 driv

[PATCH 10/10] [media] rc: Rename IR raw interface to ir-raw.c

2010-11-17 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 

 create mode 100644 drivers/media/rc/ir-raw.c
 delete mode 100644 drivers/media/rc/rc-raw.c

diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 21251ba..78ac8c5 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -1,4 +1,4 @@
-rc-core-objs   := rc-main.o rc-raw.o
+rc-core-objs   := rc-main.o ir-raw.o
 
 obj-y += keymaps/
 
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
new file mode 100644
index 000..165412f
--- /dev/null
+++ b/drivers/media/rc/ir-raw.c
@@ -0,0 +1,371 @@
+/* ir-raw-event.c - handle IR Pulse/Space event
+ *
+ * Copyright (C) 2010 by Mauro Carvalho Chehab 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "rc-core-priv.h"
+
+/* Define the max number of pulse/space transitions to buffer */
+#define MAX_IR_EVENT_SIZE  512
+
+/* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */
+static LIST_HEAD(ir_raw_client_list);
+
+/* Used to handle IR raw handler extensions */
+static DEFINE_MUTEX(ir_raw_handler_lock);
+static LIST_HEAD(ir_raw_handler_list);
+static u64 available_protocols;
+
+#ifdef MODULE
+/* Used to load the decoders */
+static struct work_struct wq_load;
+#endif
+
+static int ir_raw_event_thread(void *data)
+{
+   struct ir_raw_event ev;
+   struct ir_raw_handler *handler;
+   struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data;
+   int retval;
+
+   while (!kthread_should_stop()) {
+
+   spin_lock_irq(&raw->lock);
+   retval = kfifo_out(&raw->kfifo, &ev, sizeof(ev));
+
+   if (!retval) {
+   set_current_state(TASK_INTERRUPTIBLE);
+
+   if (kthread_should_stop())
+   set_current_state(TASK_RUNNING);
+
+   spin_unlock_irq(&raw->lock);
+   schedule();
+   continue;
+   }
+
+   spin_unlock_irq(&raw->lock);
+
+
+   BUG_ON(retval != sizeof(ev));
+
+   mutex_lock(&ir_raw_handler_lock);
+   list_for_each_entry(handler, &ir_raw_handler_list, list)
+   handler->decode(raw->dev, ev);
+   raw->prev_ev = ev;
+   mutex_unlock(&ir_raw_handler_lock);
+   }
+
+   return 0;
+}
+
+/**
+ * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
+ * @dev:   the struct rc_dev device descriptor
+ * @ev:the struct ir_raw_event descriptor of the pulse/space
+ *
+ * This routine (which may be called from an interrupt context) stores a
+ * pulse/space duration for the raw ir decoding state machines. Pulses are
+ * signalled as positive values and spaces as negative values. A zero value
+ * will reset the decoding state machines.
+ */
+int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
+{
+   if (!dev->raw)
+   return -EINVAL;
+
+   IR_dprintk(2, "sample: (%05dus %s)\n",
+  TO_US(ev->duration), TO_STR(ev->pulse));
+
+   if (kfifo_in(&dev->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
+   return -ENOMEM;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_store);
+
+/**
+ * ir_raw_event_store_edge() - notify raw ir decoders of the start of a 
pulse/space
+ * @dev:   the struct rc_dev device descriptor
+ * @type:  the type of the event that has occurred
+ *
+ * This routine (which may be called from an interrupt context) is used to
+ * store the beginning of an ir pulse or space (or the start/end of ir
+ * reception) for the raw ir decoding state machines. This is used by
+ * hardware which does not provide durations directly but only interrupts
+ * (or similar events) on state change.
+ */
+int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type)
+{
+   ktime_t now;
+   s64 delta; /* ns */
+   struct ir_raw_event ev;
+   int rc = 0;
+
+   if (!dev->raw)
+   return -EINVAL;
+
+   now = ktime_get();
+   delta = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
+
+   /* Check for a long duration since last event or if we're
+* being called for the first time, note that delta can't
+* possibly be negative.
+*/
+   ev.duration = 0;
+   if (delta > IR_MAX_DURATION || !dev->raw->last_type)
+   type |= IR_START_EVENT;
+   else
+ 

[PATCH 07/10] [media] rc: Properly name the rc_map struct

2010-11-17 Thread Mauro Carvalho Chehab
The struct that describes a rc mapping had an weird and long name.
We should properly name it, to make easier for developers to work
with it, and to avoid confusion.

Basically, generated by this script:

for i in `find drivers/staging -type f -name *.[ch]` `find include/media -type 
f -name *.[ch]` `find drivers/media -type f -name *.[ch]`; do sed 
s,ir_scancode_table,rc_map,g <$i >a && mv a $i; done
for i in `find drivers/staging -type f -name *.[ch]` `find include/media -type 
f -name *.[ch]` `find drivers/media -type f -name *.[ch]`; do sed 
s,rc_tab,rc_map,g <$i >a && mv a $i; done

(and manually fixed where needed)

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index f3244eb..caa8d70 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -47,7 +47,7 @@ static struct rc_keymap *seek_rc_map(const char *name)
return NULL;
 }
 
-struct ir_scancode_table *get_rc_map(const char *name)
+struct rc_map *get_rc_map(const char *name)
 {
 
struct rc_keymap *map;
@@ -109,71 +109,71 @@ static struct rc_keymap empty_map = {
 
 /**
  * ir_create_table() - initializes a scancode table
- * @rc_tab:the ir_scancode_table to initialize
+ * @rc_map:the rc_map to initialize
  * @name:  name to assign to the table
  * @rc_type:   ir type to assign to the new table
  * @size:  initial size of the table
  * @return:zero on success or a negative error code
  *
- * This routine will initialize the ir_scancode_table and will allocate
+ * This routine will initialize the rc_map and will allocate
  * memory to hold at least the specified number of elements.
  */
-static int ir_create_table(struct ir_scancode_table *rc_tab,
+static int ir_create_table(struct rc_map *rc_map,
   const char *name, u64 rc_type, size_t size)
 {
-   rc_tab->name = name;
-   rc_tab->rc_type = rc_type;
-   rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));
-   rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);
-   rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL);
-   if (!rc_tab->scan)
+   rc_map->name = name;
+   rc_map->rc_type = rc_type;
+   rc_map->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));
+   rc_map->size = rc_map->alloc / sizeof(struct ir_scancode);
+   rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL);
+   if (!rc_map->scan)
return -ENOMEM;
 
IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
-  rc_tab->size, rc_tab->alloc);
+  rc_map->size, rc_map->alloc);
return 0;
 }
 
 /**
  * ir_free_table() - frees memory allocated by a scancode table
- * @rc_tab:the table whose mappings need to be freed
+ * @rc_map:the table whose mappings need to be freed
  *
  * This routine will free memory alloctaed for key mappings used by given
  * scancode table.
  */
-static void ir_free_table(struct ir_scancode_table *rc_tab)
+static void ir_free_table(struct rc_map *rc_map)
 {
-   rc_tab->size = 0;
-   kfree(rc_tab->scan);
-   rc_tab->scan = NULL;
+   rc_map->size = 0;
+   kfree(rc_map->scan);
+   rc_map->scan = NULL;
 }
 
 /**
  * ir_resize_table() - resizes a scancode table if necessary
- * @rc_tab:the ir_scancode_table to resize
+ * @rc_map:the rc_map to resize
  * @gfp_flags: gfp flags to use when allocating memory
  * @return:zero on success or a negative error code
  *
- * This routine will shrink the ir_scancode_table if it has lots of
+ * This routine will shrink the rc_map if it has lots of
  * unused entries and grow it if it is full.
  */
-static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)
+static int ir_resize_table(struct rc_map *rc_map, gfp_t gfp_flags)
 {
-   unsigned int oldalloc = rc_tab->alloc;
+   unsigned int oldalloc = rc_map->alloc;
unsigned int newalloc = oldalloc;
-   struct ir_scancode *oldscan = rc_tab->scan;
+   struct ir_scancode *oldscan = rc_map->scan;
struct ir_scancode *newscan;
 
-   if (rc_tab->size == rc_tab->len) {
+   if (rc_map->size == rc_map->len) {
/* All entries in use -> grow keytable */
-   if (rc_tab->alloc >= IR_TAB_MAX_SIZE)
+   if (rc_map->alloc >= IR_TAB_MAX_SIZE)
return -ENOMEM;
 
newalloc *= 2;
IR_dprintk(1, "Growing table to %u bytes\n", newalloc);
}
 
-   if ((rc_tab->len * 3 < rc_tab->size) && (oldalloc > IR_TAB_MIN_SIZE)) {
+   if ((rc_map->len * 3 < rc_map->size) && (oldalloc > IR_TAB_MIN_SIZE)) {
/* Less than 1/3 of entries in use -> shrink keytable */
newalloc /= 2;
IR_dprintk(1, "Shrinking table to %u bytes\n", newalloc);
@@ -188,10 +188,10 @@ static int ir_resize_table(struct ir_scancode_table 
*rc_tab, gfp_t gfp_flags)

[PATCH 05/10] [media] cx231xx: Properly name rc_map name

2010-11-17 Thread Mauro Carvalho Chehab
rc_map is confusing, as it may be understood as another thing. Properly
rename the field to indicate its usage.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c 
b/drivers/media/video/cx231xx/cx231xx-cards.c
index ac4bf2c..bfa3251 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -412,7 +412,7 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_i2c_master = 2,
.demod_i2c_master = 1,
.ir_i2c_master = 2,
-   .rc_map = RC_MAP_PIXELVIEW_NEW,
+   .rc_map_name = RC_MAP_PIXELVIEW_NEW,
.has_dvb = 1,
.demod_addr = 0x10,
.norm = V4L2_STD_PAL_M,
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c 
b/drivers/media/video/cx231xx/cx231xx-input.c
index 65d951e..1d043ed 100644
--- a/drivers/media/video/cx231xx/cx231xx-input.c
+++ b/drivers/media/video/cx231xx/cx231xx-input.c
@@ -57,7 +57,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
dev_dbg(&dev->udev->dev, "%s\n", __func__);
 
/* Only initialize if a rc keycode map is defined */
-   if (!cx231xx_boards[dev->model].rc_map)
+   if (!cx231xx_boards[dev->model].rc_map_name)
return -ENODEV;
 
request_module("ir-kbd-i2c");
@@ -80,7 +80,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
 * an i2c device.
 */
dev->init_data.get_key = get_key_isdbt;
-   dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map;
+   dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map_name;
/* The i2c micro-controller only outputs the cmd part of NEC protocol */
dev->init_data.rc_dev->scanmask = 0xff;
dev->init_data.rc_dev->driver_name = "cx231xx";
diff --git a/drivers/media/video/cx231xx/cx231xx.h 
b/drivers/media/video/cx231xx/cx231xx.h
index 87a20ae..709cb87 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -349,7 +349,7 @@ struct cx231xx_board {
u8 ir_i2c_master;
 
/* for devices with I2C chips for IR */
-   char *rc_map;
+   char *rc_map_name;
 
unsigned int max_range_640_480:1;
unsigned int has_dvb:1;
-- 
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


Re: [cron job] v4l-dvb daily build: WARNINGS

2010-11-17 Thread Anca Emanuel
On Wed, Nov 17, 2010 at 8:27 PM, Hans Verkuil  wrote:
> 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:        Wed Nov 17 19:00:17 CET 2010
> path:        http://www.linuxtv.org/hg/v4l-dvb
> changeset:   15167:abd3aac6644e
> git master:       3e6dce76d99b328716b43929b9195adfee1de00c
> git media-master: a348e9110ddb5d494e060d989b35dd1f35359d58
> gcc version:      i686-linux-gcc (GCC) 4.5.1
> host hardware:    x86_64
> host os:          2.6.32.5
>
> 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: WARNINGS
> linux-git-mips: WARNINGS
> linux-git-powerpc64: WARNINGS
> linux-git-x86_64: WARNINGS
> spec-git: OK
> sparse: ERRORS
>
> Detailed results are available here:
>
> http://www.xs4all.nl/~hverkuil/logs/Wednesday.log
>
> Full logs are available here:
>
> http://www.xs4all.nl/~hverkuil/logs/Wednesday.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
>

Is somebody take care of this ?
--
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: WARNINGS

2010-11-17 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:Wed Nov 17 19:00:17 CET 2010
path:http://www.linuxtv.org/hg/v4l-dvb
changeset:   15167:abd3aac6644e
git master:   3e6dce76d99b328716b43929b9195adfee1de00c
git media-master: a348e9110ddb5d494e060d989b35dd1f35359d58
gcc version:  i686-linux-gcc (GCC) 4.5.1
host hardware:x86_64
host os:  2.6.32.5

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: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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


[Job posting] Linux software developer with experience with the Video4Linux2 API / ALSA

2010-11-17 Thread Curtis Hall
Note, before posting this I asked in the #v4l channel on freenode if a 
(single) announcement for a job posting would be acceptable.  I was told 
that it should be okay, so if it's against the policy let me know (I do 
apologize if it is).


We are looking for a Linux software developer for our Linux based 
surveillance application (www.bluecherrydvr.com).  This reason I'm 
posting this on the linux-media mailing list is because our application 
uses the Video4Linux and ALSA APIs for accessing video / audio.  We 
recently released a open source MPEG-4 / H.264 driver (see links below), 
and since our application uses this driver we are in need of developers 
with extensive knowledge with Video4Linux and ALSA to extend our 
application.  This position would also handle IP camera integration, 
which is not directly related to the V4L.


The complete job posting with more specific requirements is here: 
http://jobview.monster.com/Linux-video-surveillance-software-developer-Video4Linux-ALSA-Job-Fulton-MO-US-91967697.aspx?fwr=true


If you have any questions please email me off-list (email address is 
below) as not to crowd up the mailing list.


Telecommuting is an option for this position.

Thanks!

Links:

http://git.kernel.org/?p=linux/kernel/git/bcollins/solo6x10-staging.git;a=summary
http://linux.slashdot.org/story/10/06/17/1929230/Bluecherry-Releases-GPLd-MPEG-4-Driver
http://support.bluecherrydvr.com/entries/235174-using-the-bluecherry-hardware-compression-open-source-linux-drivers-mpeg-4-h-264

--
--
Curtis Hall (c...@bluecherry.net)
Bluecherry - www.bluecherrydvr.com
(877) 418-3391 x 283 / (573) 642-6161

--
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 01/10] MCDE: Add hardware abstraction layer

2010-11-17 Thread Joe Perches
On Wed, 2010-11-17 at 10:55 +0100, Arnd Bergmann wrote:
> On Tuesday 16 November 2010, Joe Perches wrote:
> > static inline u32 MCDE_channel_path(u32 chnl, u32 fifo, u32 type, u32 ifc, 
> > u32 link)
> > {
> > return ((chnl << 16) |
> > (fifo << 12) |
> > (type << 8) |
> > (ifc << 4) |
> > (link << 0));
> > }
> > 
> > #define SET_ENUM_MCDE_CHNLPATH(chnl, fifo, var, type, ifc, link)\
> > MCDE_CHNLPATH_CHNL##chnl##_FIFO##fifo##_##var = \
> > MCDE_channel_path(MCDE_CHNL_##chnl, \
> >   MCDE_FIFO_##fifo, \
> >   MCDE_PORTTYPE_##type, \
> >   ifc,  \
> >   link)
> > 
> > enum mcde_chnl_path {
> > /* Channel A */
> > SET_ENUM_MCDE_CHNLPATH(A, A, DPI_0, DPI, 0, 0),
> > SET_ENUM_MCDE_CHNLPATH(A, A, DSI_IFC0_0,DSI, 0, 0),
> > SET_ENUM_MCDE_CHNLPATH(A, A, DSI_IFC0_1,DSI, 0, 1),
> 
> While more readable, this has two significant problems:
> 
> * You cannot use the result of an inline function in an enum definition
> * It hides the name of the identifier, making it impossible to use grep
>   or ctags to find the definition when you only know the name

True, though I would avoid that problem by using a get function/macro
and not use an enum at all.

There are just 4 items of interest here.  chan, fifo, #1, #2.
Encoding those in the variable name is a bit of a visual chase and
a bit mind numbing to read I think.
 
> The easiest way is probably to get rid of the macros entirely here
> and just define the values as hex, with a comment exmplaining what the
> digits mean.

That'd be fine too.


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


Re: [RFC PATCH 0/8] V4L BKL removal: first round

2010-11-17 Thread David Ellingsworth
On Tue, Nov 16, 2010 at 4:42 PM, Hans Verkuil  wrote:
> On Tuesday, November 16, 2010 22:32:57 David Ellingsworth wrote:
>> Hans,
>>
>> I've had some patches pending for a while now that affect the dsbr100
>> driver. The patches can be seen here:
>> http://desource.dyndns.org/~atog/gitweb/?p=linux-media.git in the
>> dsbr100 branch. The first patch in the series fixes locking issues
>> throughout the driver and converts it to use the unlocked ioctl. The
>> series is a bit old, so it doesn't make use of the v4l2 core assisted
>> locking; but that is trivial to implement after this patch.
>
> Would it be a problem for you if for 2.6.37 I just replace .ioctl by
> .unlocked_ioctl? And do the full conversion for 2.6.38? That way the
> 2.6.37 patches remain small.
>

If you look at the first patch in that series, you'll see that the
conversion isn't that simple. There are a lot of places in that driver
that should have been protected by a lock that weren't. At the moment,
I think the BKL protects these areas from racing so just replacing the
.ioctl with the .unlocked_ioctl here isn't a good solution for this
driver. Applying the patch I've provided will however remove the BKL
and the resolve all the locking issues as well.

Regards,

David Ellingsworth
--
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] streamzap: merge timeout space with trailing space

2010-11-17 Thread Jarod Wilson
There are cases where we get an ending space, and our trailing timeout
space then gets sent right after it, which breaks repeat, at least for
lirc userspace decoding. Merge the two spaces by way of using
ir_raw_event_store_filter, set a timeout value, and we're back to good.

Successfully tested with streamzap and windows mce remotes.

Signed-off-by: Jarod Wilson 
---
 drivers/media/rc/streamzap.c |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 7781910..19652d4 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -137,7 +137,9 @@ static struct usb_driver streamzap_driver = {
 
 static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)
 {
-   ir_raw_event_store(sz->rdev, &rawir);
+   dev_dbg(sz->dev, "Storing %s with duration %u us\n",
+   (rawir.pulse ? "pulse" : "space"), rawir.duration);
+   ir_raw_event_store_with_filter(sz->rdev, &rawir);
 }
 
 static void sz_push_full_pulse(struct streamzap_ir *sz,
@@ -164,7 +166,6 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
rawir.duration *= 1000;
rawir.duration &= IR_MAX_DURATION;
}
-   dev_dbg(sz->dev, "ls %u\n", rawir.duration);
sz_push(sz, rawir);
 
sz->idle = false;
@@ -177,7 +178,6 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
sz->sum += rawir.duration;
rawir.duration *= 1000;
rawir.duration &= IR_MAX_DURATION;
-   dev_dbg(sz->dev, "p %u\n", rawir.duration);
sz_push(sz, rawir);
 }
 
@@ -197,7 +197,6 @@ static void sz_push_full_space(struct streamzap_ir *sz,
rawir.duration += SZ_RESOLUTION / 2;
sz->sum += rawir.duration;
rawir.duration *= 1000;
-   dev_dbg(sz->dev, "s %u\n", rawir.duration);
sz_push(sz, rawir);
 }
 
@@ -218,8 +217,6 @@ static void streamzap_callback(struct urb *urb)
struct streamzap_ir *sz;
unsigned int i;
int len;
-   static int timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) &
-   IR_MAX_DURATION) | 0x0300);
 
if (!urb)
return;
@@ -243,7 +240,7 @@ static void streamzap_callback(struct urb *urb)
 
dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len);
for (i = 0; i < len; i++) {
-   dev_dbg(sz->dev, "sz idx %d: %x\n",
+   dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n",
i, (unsigned char)sz->buf_in[i]);
switch (sz->decoder_state) {
case PulseSpace:
@@ -270,7 +267,7 @@ static void streamzap_callback(struct urb *urb)
DEFINE_IR_RAW_EVENT(rawir);
 
rawir.pulse = false;
-   rawir.duration = timeout;
+   rawir.duration = sz->rdev->timeout;
sz->idle = true;
if (sz->timeout_enabled)
sz_push(sz, rawir);
@@ -430,6 +427,8 @@ static int __devinit streamzap_probe(struct usb_interface 
*intf,
sz->decoder_state = PulseSpace;
/* FIXME: don't yet have a way to set this */
sz->timeout_enabled = true;
+   sz->rdev->timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) &
+   IR_MAX_DURATION) | 0x0300);
#if 0
/* not yet supported, depends on patches from maxim */
/* see also: LIRC_GET_REC_RESOLUTION and LIRC_SET_REC_TIMEOUT */
-- 
1.7.1

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


[PATCH v16 0/2] *** SUBJECT HERE ***

2010-11-17 Thread Matti J. Aaltonen
Hello all,

This the sixteenth version of the patch set.

On Tue, 2010-11-16 at 12:19 -0200, ext Mauro Carvalho Chehab wrote:
> 
> The proper way is to add the core stuff to drivers/media/radio, adding just
> the mfd glue at drivers/mfd.

Now I've moved basically all of the stuff to the drivers/media/radio...

> I also want mfd's maintainer ack of the mfd patch.

Sending this also to Samuel Ortiz...

Cheers,
Matti

Matti J. Aaltonen (2):
  MFD: WL1273 FM Radio: MFD driver for the FM radio.
  V4L2: WL1273 FM Radio: TI WL1273 FM radio driver

 drivers/media/radio/Kconfig|   16 +
 drivers/media/radio/Makefile   |1 +
 drivers/media/radio/radio-wl1273.c | 2347 
 drivers/mfd/Kconfig|6 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/wl1273-core.c  |  154 +++
 include/linux/mfd/wl1273-core.h|  298 +
 7 files changed, 2823 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/radio-wl1273.c
 create mode 100644 drivers/mfd/wl1273-core.c
 create mode 100644 include/linux/mfd/wl1273-core.h

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


[PATCH v16 1/2] MFD: WL1273 FM Radio: MFD driver for the FM radio.

2010-11-17 Thread Matti J. Aaltonen
This is the core of the WL1273 FM radio driver, it connects
the two child modules.

This is a parent for two child drivers:
drivers/media/radio/radio-wl1273.c and sound/soc/codecs/wl1273.c

Radio-wl1273 implements the V4L2 interface and the communication to the device.
The ALSA codec is for digital audio. Without the codec only analog audio
is available.

Signed-off-by: Matti J. Aaltonen 
---
 drivers/mfd/Kconfig |6 +
 drivers/mfd/Makefile|1 +
 drivers/mfd/wl1273-core.c   |  154 
 include/linux/mfd/wl1273-core.h |  298 +++
 4 files changed, 459 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/wl1273-core.c
 create mode 100644 include/linux/mfd/wl1273-core.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3a1493b..04c76c9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -606,6 +606,12 @@ config MFD_VX855
  VIA VX855/VX875 south bridge. You will need to enable the vx855_spi
  and/or vx855_gpio drivers for this to do anything useful.
 
+config WL1273_CORE
+   tristate
+   depends on I2C
+   select MFD_CORE
+   default n
+
 endif # MFD_SUPPORT
 
 menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f54b365..0d549b4 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,3 +81,4 @@ obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o
 obj-$(CONFIG_MFD_JZ4740_ADC)   += jz4740-adc.o
 obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o
 obj-$(CONFIG_MFD_VX855)+= vx855.o
+obj-$(CONFIG_WL1273_CORE)  += wl1273-core.o
diff --git a/drivers/mfd/wl1273-core.c b/drivers/mfd/wl1273-core.c
new file mode 100644
index 000..c900f35
--- /dev/null
+++ b/drivers/mfd/wl1273-core.c
@@ -0,0 +1,154 @@
+/*
+ * MFD driver for wl1273 FM radio and audio codec submodules.
+ *
+ * Author: Matti Aaltonen 
+ *
+ * Copyright:   (C) 2010 Nokia Corporation
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_DESC "WL1273 FM Radio Core"
+
+static struct i2c_device_id wl1273_driver_id_table[] = {
+   { WL1273_FM_DRIVER_NAME, 0 },
+   { }
+};
+MODULE_DEVICE_TABLE(i2c, wl1273_driver_id_table);
+
+static int wl1273_core_remove(struct i2c_client *client)
+{
+   struct wl1273_core *core = i2c_get_clientdata(client);
+
+   dev_dbg(&client->dev, "%s\n", __func__);
+
+   mfd_remove_devices(&client->dev);
+   i2c_set_clientdata(client, NULL);
+   kfree(core);
+
+   return 0;
+}
+
+static int __devinit wl1273_core_probe(struct i2c_client *client,
+  const struct i2c_device_id *id)
+{
+   struct wl1273_fm_platform_data *pdata = client->dev.platform_data;
+   int r = 0;
+   struct wl1273_core *core;
+   int children = 0;
+
+   dev_dbg(&client->dev, "%s\n", __func__);
+
+   if (!pdata) {
+   dev_err(&client->dev, "No platform data.\n");
+   return -EINVAL;
+   }
+
+   core = kzalloc(sizeof(*core), GFP_KERNEL);
+   if (!core)
+   return -ENOMEM;
+
+   core->pdata = pdata;
+   core->client = client;
+   mutex_init(&core->lock);
+
+   i2c_set_clientdata(client, core);
+
+   /* the radio child must be first */
+   if (pdata->children & WL1273_RADIO_CHILD) {
+   struct mfd_cell *cell = &core->cells[children];
+   dev_dbg(&client->dev, "%s: Have V4L2.\n", __func__);
+   cell->name = "wl1273_fm_radio";
+   cell->platform_data = &core;
+   cell->data_size = sizeof(core);
+   children++;
+   } else {
+   dev_err(&client->dev, "Cannot function without radio child.\n");
+   r = -EINVAL;
+   goto err_radio_child;
+   }
+
+   if (pdata->children & WL1273_CODEC_CHILD) {
+   struct mfd_cell *cell = &core->cells[children];
+   dev_dbg(&client->dev, "%s: Have codec.\n", __func__);
+   cell->name = "wl1273-codec";
+   cell->platform_data = &core;
+   cell->data_size = sizeof(core);
+   children++;
+   }
+
+   if (children) {
+   dev_dbg(&client->dev, "%s: Have children.\n", __func__);
+

Re: [PATCH v4 0/6] FM V4L2 drivers for WL128x

2010-11-17 Thread Ohad Ben-Cohen
Hi Manjunatha,

On Tue, Nov 16, 2010 at 3:18 PM,   wrote:
>  drivers/staging/ti-st/Kconfig        |   10 +
>  drivers/staging/ti-st/Makefile       |    2 +
>  drivers/staging/ti-st/fmdrv.h        |  259 
>  drivers/staging/ti-st/fmdrv_common.c | 2141 
> ++
>  drivers/staging/ti-st/fmdrv_common.h |  458 
>  drivers/staging/ti-st/fmdrv_rx.c     |  979 
>  drivers/staging/ti-st/fmdrv_rx.h     |   59 +
>  drivers/staging/ti-st/fmdrv_tx.c     |  461 
>  drivers/staging/ti-st/fmdrv_tx.h     |   37 +
>  drivers/staging/ti-st/fmdrv_v4l2.c   |  757 
>  drivers/staging/ti-st/fmdrv_v4l2.h   |   32 +
>  11 files changed, 5195 insertions(+), 0 deletions(-)

Usually when a driver is added to staging, it should also have a TODO
file specifying what needs to be done before the driver can be taken
out of staging (at least as far as the author knows of today).

It helps keeping track of the open issues in the driver, which is good
for everyone - the author, the random contributor/observer, and
probably even the staging maintainer.

Can you please add such a TODO file ?

Thanks,
Ohad.

>  create mode 100644 drivers/staging/ti-st/fmdrv.h
>  create mode 100644 drivers/staging/ti-st/fmdrv_common.c
>  create mode 100644 drivers/staging/ti-st/fmdrv_common.h
>  create mode 100644 drivers/staging/ti-st/fmdrv_rx.c
>  create mode 100644 drivers/staging/ti-st/fmdrv_rx.h
>  create mode 100644 drivers/staging/ti-st/fmdrv_tx.c
>  create mode 100644 drivers/staging/ti-st/fmdrv_tx.h
>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.c
>  create mode 100644 drivers/staging/ti-st/fmdrv_v4l2.h
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
--
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 1/1] videobuf: Initialize lists in videobuf_buffer.

2010-11-17 Thread Hans Verkuil

> Hi Hans,
>
> On Wednesday 17 November 2010 08:11:06 Hans Verkuil wrote:
>> On Wednesday, November 17, 2010 02:38:09 Andrew Chew wrote:
>> > > > diff --git a/drivers/media/video/videobuf-dma-contig.c
>> > >
>> > > b/drivers/media/video/videobuf-dma-contig.c
>> > >
>> > > > index c969111..f7e0f86 100644
>> > > > --- a/drivers/media/video/videobuf-dma-contig.c
>> > > > +++ b/drivers/media/video/videobuf-dma-contig.c
>> > > > @@ -193,6 +193,8 @@ static struct videobuf_buffer
>> > >
>> > > *__videobuf_alloc_vb(size_t size)
>> > >
>> > > >if (vb) {
>> > > >
>> > > >mem = vb->priv = ((char *)vb) + size;
>> > > >mem->magic = MAGIC_DC_MEM;
>> > > >
>> > > > +  INIT_LIST_HEAD(&vb->stream);
>> > > > +  INIT_LIST_HEAD(&vb->queue);
>> > >
>> > > i think it no need to be init, it just a list-entry.
>> >
>> > Okay, if that's really the case, then sh_mobile_ceu_camera.c,
>> > pxa_camera.c, mx1_camera.c, mx2_camera.c, and omap1_camera.c needs to
>> be
>> > fixed to remove that WARN_ON(!list_empty(&vb->queue)); in their
>> > videobuf_prepare() methods, because those WARN_ON's are assuming that
>> > vb->queue is properly initialized as a list head.
>> >
>> > Which will it be?
>>
>> These list entries need to be inited. It is bad form to have
>> uninitialized
>> list entries. It is not as if this is a big deal to initialize them
>> properly.
>
> I disagree with that. List heads must be initialized, but there's no point
> in
> initializing list entries.

You are right. I got confused due to some problems I had in the past in
another driver, but it turned out to be a list header that caused the
problems, not a list entry. So removing the bogus WARN_ONs is sufficient.

Regards,

   Hans

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco

--
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 1/1] videobuf: Initialize lists in videobuf_buffer.

2010-11-17 Thread Laurent Pinchart
Hi Hans,

On Wednesday 17 November 2010 08:11:06 Hans Verkuil wrote:
> On Wednesday, November 17, 2010 02:38:09 Andrew Chew wrote:
> > > > diff --git a/drivers/media/video/videobuf-dma-contig.c
> > > 
> > > b/drivers/media/video/videobuf-dma-contig.c
> > > 
> > > > index c969111..f7e0f86 100644
> > > > --- a/drivers/media/video/videobuf-dma-contig.c
> > > > +++ b/drivers/media/video/videobuf-dma-contig.c
> > > > @@ -193,6 +193,8 @@ static struct videobuf_buffer
> > > 
> > > *__videobuf_alloc_vb(size_t size)
> > > 
> > > > if (vb) {
> > > > 
> > > > mem = vb->priv = ((char *)vb) + size;
> > > > mem->magic = MAGIC_DC_MEM;
> > > > 
> > > > +   INIT_LIST_HEAD(&vb->stream);
> > > > +   INIT_LIST_HEAD(&vb->queue);
> > > 
> > > i think it no need to be init, it just a list-entry.
> > 
> > Okay, if that's really the case, then sh_mobile_ceu_camera.c,
> > pxa_camera.c, mx1_camera.c, mx2_camera.c, and omap1_camera.c needs to be
> > fixed to remove that WARN_ON(!list_empty(&vb->queue)); in their
> > videobuf_prepare() methods, because those WARN_ON's are assuming that
> > vb->queue is properly initialized as a list head.
> > 
> > Which will it be?
> 
> These list entries need to be inited. It is bad form to have uninitialized
> list entries. It is not as if this is a big deal to initialize them
> properly.

I disagree with that. List heads must be initialized, but there's no point in 
initializing list entries.

-- 
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: Question about setting V4L2_CID_AUTO_WHITE_BALANCE control to FALSE

2010-11-17 Thread Laurent Pinchart
Hi,

On Tuesday 16 November 2010 23:34:11 Shuzhen Wang wrote:
> Nevermind. I think behavior #1 makes more sense.

I agree with that.

> On Tuesday, November 16, 2010 11:30 AM Shuzhen Wang wrote:
> > 
> > When I set V4L2_CID_AUTO_WHITE_BALANCE control to FALSE, which one of the
> > following is the expected behavior?
> > 
> > 1. Hold the current white balance settting.
> > 2. Set the white balance to whatever V4L2_CID_WHITE_BALANCE_TEMPERATURE
> > control is set to.
> > 
> > The V4L2 API spec doesn't specify this clearly.

The reason why the specification doesn't clearly state what must be done is 
that the behaviour might be hardware dependent. Some hardware won't offer 
option 1, so drivers will be forced to go for option 2.

(I'm not totally sure that's why the specification isn't clear about the 
expected behaviour, but it's at least a good justification for it :-))

-- 
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: hg pull http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/

2010-11-17 Thread Manu Abraham
On Wed, Nov 17, 2010 at 7:48 AM, Mauro Carvalho Chehab
 wrote:
> Em 14-11-2010 18:48, Manu Abraham escreveu:
>> Mauro,
>>
>> Please pull from http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/
>>
>> for the following changes.
>>
>>
>> changeset 15168:baa4e8008db5 Mantis, hopper: use MODULE_DEVICE_TABLE
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/baa4e8008db5
>>
>> changeset 15169:f04605948fdc Mantis: append tasklet maintenance for
>> DVB stream delivery
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/f04605948fdc
>>
>> changeset 15170:ee7a63d70f94 Mantis: use dvb_attach to avoid double
>> dereferencing on module removal
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/ee7a63d70f94
>>
>> changeset 15171:3a2ece3bf184 Mantis: Rename gpio_set_bits to
>> mantis_gpio_set_bits
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/3a2ece3bf184
>>
>> changeset 15172:56c20de4f697 stb6100: Improve tuner performance
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/56c20de4f697
>>
>> changeset 15173:5cc010e3a803 stb0899: fix diseqc messages getting lost
>> http://202.88.242.108:8000/hg/var/www/hg/v4l-dvb/rev/5cc010e3a803
>
> Applied, thanks.
>
> A new warning appeared:
>
> drivers/media/dvb/frontends/stb6100.c:120: warning: ‘stb6100_normalise_regs’ 
> defined but not used


Can you please enclose the function in a #if 0.since it is not being used.

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: [RFC/PATCH v5 01/12] media: Media device node support

2010-11-17 Thread Laurent Pinchart
Hi Jonathan,

On Wednesday 17 November 2010 01:31:15 Jonathan Corbet wrote:
> Here's the first of my more specific comments - probably the only file
> I'll get to today...

Thanks a lot for the review !

> > 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.
> 
> My first impression is that you're creating a simplified wrapper around
> chardevs - essentially a reimplementation of the miscdevice subsystem.  If
> we really need this, it seems like it should be made something more
> generic.

This comes from drivers/media/video/v4l2-dev.c and has been stripped out of 
backward compatibility code and other V4L2-specific parts.

> I wonder, though, why this functionality isn't just folded into struct
> media_device?  Do you plan to use it elsewhere as well?

In previous versions of the patches I was using this code to register 
media_device and video_device nodes. I left out the video_device part 
untouched because it got rejected during review, and I just haven't merged 
media_devnode with media_device in case it would be useful in the future.

> [...]
> 
> > +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);
> > +}
> 
> If it's not registered, I would expect poll() to return an error.
> 
> [...]
> 
> > +/**
> > + * media_devnode_register - register a media device node
> > + * @mdev: media device node structure we want to register
> > + *
> > + * The registration code assigns minor numbers and registers the new
> > device node + * with the kernel. An error is returned if no free minor
> > number can be found, + * or if the registration of the device node
> > fails.
> > + *
> > + * Zero is returned on success.
> > + *
> > + * Note that if the media_devnode_register call fails, the release()
> > callback of + * the media_devnode structure is *not* called, so the
> > caller is responsible for + * freeing any data.
> > + */
> > +int __must_check media_devnode_register(struct media_devnode *mdev)
> > +{
> > +   int minor;
> > +   int ret;
> > +
> > +   /* Part 1: Find a free minor number */
> > +   mutex_lock(&media_devnode_lock);
> > +   minor = find_next_zero_bit(media_devnode_nums, 0, MEDIA_NUM_DEVICES);
> > +   if (minor == MEDIA_NUM_DEVICES) {
> > +   mutex_unlock(&media_devnode_lock);
> > +   printk(KERN_ERR "could not get a free minor\n");
> > +   return -ENFILE;
> > +   }
> > +
> > +   set_bit(mdev->minor, media_devnode_nums);
> > +   mutex_unlock(&media_devnode_lock);
> > +
> > +   mdev->minor = minor;
> > +
> > +   /* Part 2: Initialize and register the character device */
> > +   cdev_init(&mdev->cdev, &media_devnode_fops);
> > +   mdev->cdev.owner = mdev->fops->owner;
> > +
> > +   ret = cdev_add(&mdev->cdev, MKDEV(MAJOR(media_dev_t), mdev->minor), 1);
> > +   if (ret < 0) {
> > +   printk(KERN_ERR "%s: cdev_add failed\n", __func__);
> > +   goto error;
> > +   }
> > +
> > +   /* Part 3: Register the media device */
> > +   mdev->dev.class = &media_class;
> 
> There is a real push to get rid of classes.  Is there a need for this class
> here?

I wrote that before I was aware we were trying to get rid of classes. I'm 
replacing it by a bus.

> It doesn't look like you attach any attributes to it.

I can attach bus attributes anyway :-)

> > +   mdev->dev.devt = MKDEV(MAJOR(media_dev_t), mdev->minor);
> > +   mdev->dev.release = media_devnode_release;
> > +   if (mdev->parent)
> > +   mdev->dev.parent = mdev->parent;
> > +   dev_set_name(&mdev->dev, "media%d", mdev->minor);
> > +   ret = device_register(&mdev->dev);
> > +   if (ret < 0) {
> > +   printk(KERN_ERR "%s: device_register failed\n", __func__);
> > +   goto error;
> > +   }
> > +
> > +   /* Part 4: Activate this minor. The char device can now be used. */
> > +   set_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);
> > +
> > +   return 0;
> > +
> > +error:
> > +   cdev_del(&mdev->cdev);
> > +   mutex_lock(&media_devnode_lock);
> > +   clear_bit(mdev->minor, media_devnode_nums);
> 
> Bitops are atomic, even, it seems, for large bitmaps.

Right, will fix that.

> > +   mutex_unlock(&media_devnode_lock);
> > +   return ret;
> > +}
> > +
> > +/**
> > + * media_devnode_unregister - unregister a media device node
> > + * @mdev: the device node to unregister
> > + *
> > + * This unregisters the passed device. Future open calls will be met
> > with + * errors.
> > + *
> > + * This function can safely be called if the device node has never been
> > + * regis

[PATCH]v4l: list entries no need to check

2010-11-17 Thread Figo.zhang

list entries are not need to be inited, so it no need
for checking. 

Reported-by: Andrew Chew 
Signed-off-by: Figo.zhang 
---
 drivers/media/video/mx1_camera.c   |3 ---
 drivers/media/video/pxa_camera.c   |3 ---
 drivers/media/video/sh_mobile_ceu_camera.c |3 ---
 3 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c
index 5c17f9e..cb2dd24 100644
--- a/drivers/media/video/mx1_camera.c
+++ b/drivers/media/video/mx1_camera.c
@@ -182,9 +182,6 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);
 
-   /* Added list head initialization on alloc */
-   WARN_ON(!list_empty(&vb->queue));
-
BUG_ON(NULL == icd->current_fmt);
 
/*
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index 9de7d59..421de10 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -444,9 +444,6 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);
 
-   /* Added list head initialization on alloc */
-   WARN_ON(!list_empty(&vb->queue));
-
 #ifdef DEBUG
/*
 * This can be useful if you want to see if we actually fill
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c 
b/drivers/media/video/sh_mobile_ceu_camera.c
index 2b24bd0..b2bef3f 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -354,9 +354,6 @@ static int sh_mobile_ceu_videobuf_prepare(struct 
videobuf_queue *vq,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
vb, vb->baddr, vb->bsize);
 
-   /* Added list head initialization on alloc */
-   WARN_ON(!list_empty(&vb->queue));
-
 #ifdef DEBUG
/*
 * This can be useful if you want to see if we actually fill


--
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: rtl2832u support

2010-11-17 Thread Damjan Marion
On Oct 19, 2010, at 10:27 PM, Hans Verkuil wrote:
> On Tuesday, October 19, 2010 21:26:13 Devin Heitmueller wrote:
>> On Tue, Oct 19, 2010 at 1:42 PM, Damjan Marion  
>> wrote:
>>> 
>>> Hi,
>>> 
>>> Is there any special reason why driver for rtl2832u DVB-T receiver chipset 
>>> is not included into v4l-dvb?
>>> 
>>> Realtek published source code under GPL:
>>> 
>>> MODULE_AUTHOR("Realtek");
>>> MODULE_DESCRIPTION("Driver for the RTL2832U DVB-T / RTL2836 DTMB USB2.0 
>>> device");
>>> MODULE_VERSION("1.4.2");
>>> MODULE_LICENSE("GPL");
>> 
>> Unfortunately, in most cases much more is "required" than having a
>> working driver under the GPL in order for it to be accepted upstream.
>> In some cases it can mean a developer spending a few hours cleaning up
>> whitespace and indentation, and in other cases it means significant
>> work to the driver is required.
>> 
>> The position the LinuxTV team has taken is that they would rather have
>> no upstream driver at all than to have a driver which doesn't have the
>> right indentation or other aesthetic problems which has no bearing on
>> how well the driver actually works.
>> 
>> This is one of the big reasons KernelLabs has tens of thousands of
>> lines of code adding support for a variety of devices with many happy
>> users (who are willing to go through the trouble to compile from
>> source), but the code cannot be accepted upstream.  I just cannot find
>> the time to do the "idiot work".
> 
> Bullshit. First of all these rules are those of the kernel community
> as a whole and *not* linuxtv as such, and secondly you can upstream such
> drivers in the staging tree. If you want to move it out of staging, then
> it will take indeed more work since the quality requirements are higher
> there.


Do we have a common agreement that this driver can go to staging as-is?

If yes, I have patch ready, just need to know where to send it (It is around 1 
MB).

Regards,

Damjan



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


Re: [GIT PULL REQUEST v2.] WL1273 FM Radio driver.

2010-11-17 Thread Mauro Carvalho Chehab
Em 16-11-2010 11:35, Matti J. Aaltonen escreveu:
> Hi.
> 
> The radio pull request, now using http protocol.
> 
> The following changes since commit
> f6614b7bb405a9b35dd28baea989a749492c46b2:
>   Linus Torvalds (1):
> Merge git://git.kernel.org/.../sfrench/cifs-2.6
> 
> are available in the git repository at:
> 
>   http://git.gitorious.org/wl1273-fm-driver/wl1273-fm-driver.git master
> 
> Matti J. Aaltonen (2):
>   MFD: WL1273 FM Radio: MFD driver for the FM radio.
>   V4L2: WL1273 FM Radio: Controls for the FM radio.

Hi Matti,

The proper way is to add the core stuff to drivers/media/radio, adding just
the mfd glue at drivers/mfd. I also want mfd's maintainer ack of the mfd
patch.

I just added an mfd driver right now. You may use it as an example:

http://git.linuxtv.org/media_tree.git?a=commit;h=ef6ce9acc5f87e253c97dfd5301f8036f937f595

http://git.linuxtv.org/media_tree.git?a=commit;h=552faf8580766b6fc944cb966f690ed0624a5564

> 
>  drivers/media/radio/Kconfig|   16 +
>  drivers/media/radio/Makefile   |1 +
>  drivers/media/radio/radio-wl1273.c | 1841
> 
>  drivers/mfd/Kconfig|6 +
>  drivers/mfd/Makefile   |1 +
>  drivers/mfd/wl1273-core.c  |  617 
>  include/linux/mfd/wl1273-core.h|  330 +++
>  7 files changed, 2812 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/radio/radio-wl1273.c
>  create mode 100644 drivers/mfd/wl1273-core.c
>  create mode 100644 include/linux/mfd/wl1273-core.h
> 
> 
> B.R.
> Matti A.
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: An article on the media controller

2010-11-17 Thread Laurent Pinchart
Hi Jonathan,

On Tuesday 16 November 2010 23:18:02 Jonathan Corbet wrote:
> I've just spent a fair while looking through the September posting of
> the media controller code (is there a more recent version?).  The
> result is a high-level review which interested people can read here:
> 
>   http://lwn.net/SubscriberLink/415714/1e837f01b8579eb7/

Thanks a lot for the article.

> Most people will not see it for another 24 hours or so; if there's
> something I got radically wrong, I'd appreciate hearing about it.

Here are a few comments:

- Second paragraph: s/lens distortion/lens shading/

- Fifth paragraph: entities can have no bad if no data flows in or out of them 
(think of a flash controller for instance,  it needs to be configured, 
associated with a sensor, but is not involved in any media data flow). The 
pads represent connection points for data flows (usually media data), not for 
software configuration.

- Tenth paragraph: there's no end-user application available at the moment, 
but we already have a command line test application 
(http://git.ideasonboard.org/?p=media-ctl.git;a=summary) and a GStreamer 
element (called subdevsrc, available from http://meego.gitorious.org/maemo-
multimedia/gst-nokia-videosrc).

> The executive summary is that I think this code really needs some
> exposure outside of the V4L2 list; I'd encourage posting it to
> linux-kernel.  That could be hard on plans for a 2.6.38 merge (or, at
> least, plans for any spare time between now and then), but the end
> result might be better for everybody.

I agree that the more developers who will look at the code, the more ideas we 
will get. That might get difficult to manage though :-) I'll cross-post the 
next version of the patches.

Regarding sysfs, I won't repeat Hans' and Andy's arguments, but I don't think 
it would be a very good match. The API would get much more difficult to use 
and would require lany times more system calls. While the media controller 
solves a problem that can appear similar to our current power management and 
clock routing issues, I'm not sure a common API would make sense. That would 
be like arguing that DirectShow should be used for hard disk power management 
in Windows :-)

> I have some low-level comments too which were not suitable for the
> article.  I'll be posting them here, but I have to get some other
> things done first.

Thank you in advance for the review.

-- 
Best regards,

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


[PATCH] drivers/media: nuvoton: fix chip id probe

2010-11-17 Thread Nicolas Kaiser
Make sure we have a matching chip id high and one or the other
of the chip id low values.
Print the values if the probe fails.

Signed-off-by: Nicolas Kaiser 
---
Like this?
Supersedes patch "drivers/media: nuvoton: always true expression".

 drivers/media/IR/nuvoton-cir.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/IR/nuvoton-cir.c b/drivers/media/IR/nuvoton-cir.c
index 301be53..92d32c8 100644
--- a/drivers/media/IR/nuvoton-cir.c
+++ b/drivers/media/IR/nuvoton-cir.c
@@ -249,9 +249,12 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
nvt_dbg("%s: chip id: 0x%02x 0x%02x", chip_id, chip_major, chip_minor);
 
-   if (chip_major != CHIP_ID_HIGH &&
-   (chip_minor != CHIP_ID_LOW || chip_minor != CHIP_ID_LOW2))
+   if (chip_major != CHIP_ID_HIGH ||
+   (chip_minor != CHIP_ID_LOW && chip_minor != CHIP_ID_LOW2)) {
+   nvt_pr(KERN_ERR, "%s: chip id mismatch: 0x%02x 0x%02x",
+  chip_id, chip_major, chip_minor);
ret = -ENODEV;
+   }
 
nvt_efm_disable(nvt);
 
-- 
1.7.2.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 01/10] MCDE: Add hardware abstraction layer

2010-11-17 Thread Arnd Bergmann
On Tuesday 16 November 2010, Joe Perches wrote:
> static inline u32 MCDE_channel_path(u32 chnl, u32 fifo, u32 type, u32 ifc, 
> u32 link)
> {
> return ((chnl << 16) |
> (fifo << 12) |
> (type << 8) |
> (ifc << 4) |
> (link << 0));
> }
> 
> #define SET_ENUM_MCDE_CHNLPATH(chnl, fifo, var, type, ifc, link)\
> MCDE_CHNLPATH_CHNL##chnl##_FIFO##fifo##_##var = \
> MCDE_channel_path(MCDE_CHNL_##chnl, \
>   MCDE_FIFO_##fifo, \
>   MCDE_PORTTYPE_##type, \
>   ifc,  \
>   link)
> 
> enum mcde_chnl_path {
> /* Channel A */
> SET_ENUM_MCDE_CHNLPATH(A, A, DPI_0, DPI, 0, 0),
> SET_ENUM_MCDE_CHNLPATH(A, A, DSI_IFC0_0,DSI, 0, 0),
> SET_ENUM_MCDE_CHNLPATH(A, A, DSI_IFC0_1,DSI, 0, 1),

While more readable, this has two significant problems:

* You cannot use the result of an inline function in an enum definition
* It hides the name of the identifier, making it impossible to use grep
  or ctags to find the definition when you only know the name

The easiest way is probably to get rid of the macros entirely here
and just define the values as hex, with a comment exmplaining what the
digits mean.

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


[PATCH 2/7] v4l: videobuf2: add generic memory handling routines

2010-11-17 Thread Marek Szyprowski
From: Pawel Osciak 

Add generic memory handling routines for userspace pointer handling,
contiguous memory verification and mapping.

Signed-off-by: Pawel Osciak 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Kyungmin Park 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig|3 +
 drivers/media/video/Makefile   |1 +
 drivers/media/video/videobuf2-memops.c |  199 
 include/media/videobuf2-memops.h   |   31 +
 4 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-memops.c
 create mode 100644 include/media/videobuf2-memops.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fef6a14..83ce858 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -52,6 +52,9 @@ config V4L2_MEM2MEM_DEV
 config VIDEOBUF2_CORE
tristate
 
+config VIDEOBUF2_MEMOPS
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 77c4f85..a97a2a0 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_VIDEOBUF_DVB) += videobuf-dvb.o
 obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
+obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-memops.c 
b/drivers/media/video/videobuf2-memops.c
new file mode 100644
index 000..67ebdff
--- /dev/null
+++ b/drivers/media/video/videobuf2-memops.c
@@ -0,0 +1,199 @@
+/*
+ * videobuf2-memops.c - generic memory handling routines for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak 
+ *Marek Szyprowski 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/**
+ * vb2_contig_verify_userptr() - verify contiguity of a userspace-mapped memory
+ * @vma:   virtual memory region which maps the physical memory
+ * to be verified
+ * @vaddr: starting virtual address of the area to be verified
+ * @size:  size of the area to be verified
+ * @paddr: will return physical address for the given vaddr
+ *
+ * This function will go through memory area of size size mapped at vaddr and
+ * verify that the underlying physical pages are contiguous.
+ *
+ * Returns 0 on success and a physical address to the memory pointed
+ * to by vaddr in paddr.
+ */
+int vb2_contig_verify_userptr(struct vm_area_struct *vma,
+   unsigned long vaddr, unsigned long size,
+   unsigned long *paddr)
+{
+   struct mm_struct *mm = current->mm;
+   unsigned long offset;
+   unsigned long vma_size;
+   unsigned long curr_pfn, prev_pfn;
+   unsigned long num_pages;
+   int ret = -EINVAL;
+   unsigned int i;
+
+   offset = vaddr & ~PAGE_MASK;
+
+   down_read(&mm->mmap_sem);
+
+   vma = find_vma(mm, vaddr);
+   if (!vma) {
+   printk(KERN_ERR "Invalid userspace address\n");
+   goto done;
+   }
+
+   vma_size = vma->vm_end - vma->vm_start;
+
+   if (size > vma_size - offset) {
+   printk(KERN_ERR "Region too small\n");
+   goto done;
+   }
+   num_pages = (size + offset) >> PAGE_SHIFT;
+
+   ret = follow_pfn(vma, vaddr, &curr_pfn);
+   if (ret) {
+   printk(KERN_ERR "Invalid userspace address\n");
+   goto done;
+   }
+
+   *paddr = (curr_pfn << PAGE_SHIFT) + offset;
+
+   for (i = 1; i < num_pages; ++i) {
+   prev_pfn = curr_pfn;
+   vaddr += PAGE_SIZE;
+
+   ret = follow_pfn(vma, vaddr, &curr_pfn);
+   if (ret || curr_pfn != prev_pfn + 1) {
+   printk(KERN_ERR "Invalid userspace address\n");
+   ret = -EINVAL;
+   break;
+   }
+   }
+
+done:
+   up_read(&mm->mmap_sem);
+   return ret;
+}
+
+/**
+ * vb2_mmap_pfn_range() - map physical pages to userspace
+ * @vma:   virtual memory region for the mapping
+ * @paddr: starting physical address of the memory to be mapped
+ * @size:  size of the memory to be mapped
+ * @vm_ops:vm operations to be assigned to the created area
+ * @priv:  private data to be associated with the area
+ *
+ * Returns 0 on success.
+ */
+int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
+   unsigned long size,
+   const struct vm_operations_struct *vm_ops,
+   void *priv)
+{
+   int ret;
+
+ 

[PATCH 6/7] v4l: vivi: port to videobuf2

2010-11-17 Thread Marek Szyprowski
Make vivi use videobuf2 in place of videobuf.

Signed-off-by: Pawel Osciak 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Kyungmin Park 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig |2 +-
 drivers/media/video/vivi.c  |  390 ---
 2 files changed, 221 insertions(+), 171 deletions(-)

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index e7752ee1..9315c0a 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -557,7 +557,7 @@ config VIDEO_VIVI
depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64
depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
select FONT_8x16
-   select VIDEOBUF_VMALLOC
+   select VIDEOBUF2_VMALLOC
default n
---help---
  Enables a virtual video driver. This device shows a color bar
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 9797e5a..baaacf3 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -7,6 +7,9 @@
  *  John Sokol 
  *  http://v4l.videotechnology.com/
  *
+ *  Conversion to videobuf2 by Pawel Osciak & Marek Szyprowski
+ *  Copyright (c) 2010 Samsung Electronics
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the BSD Licence, GNU General Public License
  * as published by the Free Software Foundation; either version 2 of the
@@ -23,10 +26,8 @@
 #include 
 #include 
 #include 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
 #include 
-#endif
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -42,7 +43,7 @@
 #define MAX_HEIGHT 1200
 
 #define VIVI_MAJOR_VERSION 0
-#define VIVI_MINOR_VERSION 7
+#define VIVI_MINOR_VERSION 8
 #define VIVI_RELEASE 0
 #define VIVI_VERSION \
KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
@@ -70,6 +71,9 @@ MODULE_PARM_DESC(vid_limit, "capture memory limit in 
megabytes");
 /* Global font descriptor */
 static const u8 *font8x16;
 
+/* Videobuf2 allocator/memory handler context */
+static struct vb2_alloc_ctx *alloc_ctx;
+
 #define dprintk(dev, level, fmt, arg...) \
v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg)
 
@@ -133,16 +137,11 @@ static struct vivi_fmt *get_format(struct v4l2_format *f)
return &formats[k];
 }
 
-struct sg_to_addr {
-   int pos;
-   struct scatterlist *sg;
-};
-
 /* buffer for one video frame */
 struct vivi_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer vb;
-
+   struct vb2_buffer   vb;
+   struct list_headlist;
struct vivi_fmt*fmt;
 };
 
@@ -190,9 +189,11 @@ struct vivi_dev {
/* video capture */
struct vivi_fmt*fmt;
unsigned int   width, height;
-   struct videobuf_queue  vb_vidq;
+   struct vb2_queue   vb_vidq;
+   enum v4l2_fieldfield;
+   unsigned int   field_count;
 
-   unsigned long  generating;
+   unsigned int   open_count;
u8 bars[9][3];
u8 line[MAX_WIDTH * 4];
 };
@@ -443,10 +444,10 @@ static void gen_text(struct vivi_dev *dev, char *basep,
 
 static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 {
-   int hmax = buf->vb.height;
-   int wmax = buf->vb.width;
+   int wmax = dev->width;
+   int hmax = dev->height;
struct timeval ts;
-   void *vbuf = videobuf_to_vmalloc(&buf->vb);
+   void *vbuf = vb2_plane_vaddr(&buf->vb, 0);
unsigned ms;
char str[100];
int h, line = 1;
@@ -483,11 +484,11 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct 
vivi_buffer *buf)
 
dev->mv_count += 2;
 
-   /* Advice that buffer was filled */
-   buf->vb.field_count++;
+   buf->vb.v4l2_buf.field = dev->field;
+   dev->field_count++;
+   buf->vb.v4l2_buf.sequence = dev->field_count >> 1;
do_gettimeofday(&ts);
-   buf->vb.ts = ts;
-   buf->vb.state = VIDEOBUF_DONE;
+   buf->vb.v4l2_buf.timestamp = ts;
 }
 
 static void vivi_thread_tick(struct vivi_dev *dev)
@@ -504,23 +505,21 @@ static void vivi_thread_tick(struct vivi_dev *dev)
goto unlock;
}
 
-   buf = list_entry(dma_q->active.next,
-struct vivi_buffer, vb.queue);
-
-   /* Nobody is waiting on this buffer, return */
-   if (!waitqueue_active(&buf->vb.done))
+   /* If nobody is waiting for a buffer, return */
+   if (!vb2_has_consumers(&dev->vb_vidq))
goto unlock;
 
-   list_del(&buf->vb.queue);
+   buf = list_entry(dma_q->active.next, struct vivi_buffer, list);
+   list_del(&buf->list);
 
-   do_gettimeofday(&buf->vb.ts);
+   do_gettimeofday(&buf->vb.v4l2_buf.timestamp);
 
/* Fill buffer */
vivi_fillbuff(dev, buf);
dprintk(dev

[PATCH 5/7] v4l: videobuf2: add read() and write() emulator

2010-11-17 Thread Marek Szyprowski
Add a generic file io (read and write) emulator for videobuf2. It uses
MMAP memory type buffers and generic vb2 calls: req_bufs, qbuf and
dqbuf. Video date is being copied from mmap buffers to userspace with
standard copy_to_user() function. To add support for file io the driver
needs to provide an additional callback - read_setup or write_setup. It
should provide the default number of buffers used by emulator and flags.

With these flags one can detemine the style of read() or write()
emulation. By default 'streaming' style is used. With
VB2_FILEIO_READ_ONCE flag one can select 'one shot' mode for read()
emulator. With VB2_FILEIO_WRITE_IMMEDIATE flag one can select immediate
conversion of write calls to qbuf for write() emulator, so the vb2 will
not wait until each buffer is filled completely before queueing it to
the driver.

Signed-off-by: Marek Szyprowski 
Signed-off-by: Kyungmin Park 
CC: Pawel Osciak 
---
 drivers/media/video/videobuf2-core.c |  397 +-
 include/media/videobuf2-core.h   |   30 +++
 2 files changed, 426 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/videobuf2-core.c 
b/drivers/media/video/videobuf2-core.c
index 5c9d3d8..35acfe0 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -503,6 +503,11 @@ int vb2_reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
unsigned int num_buffers, num_planes;
int ret = 0;
 
+   if (q->fileio) {
+   dprintk(1, "reqbufs: file io in progress\n");
+   return -EBUSY;
+   }
+
if (req->memory != V4L2_MEMORY_MMAP
&& req->memory != V4L2_MEMORY_USERPTR) {
dprintk(1, "reqbufs: unsupported memory type\n");
@@ -846,6 +851,10 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
struct vb2_buffer *vb;
int ret = 0;
 
+   if (q->fileio) {
+   dprintk(1, "qbuf: file io in progress\n");
+   return -EBUSY;
+   }
 
if (b->type != q->type) {
dprintk(1, "qbuf: invalid buffer type\n");
@@ -1019,6 +1028,10 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer 
*b, bool nonblocking)
struct vb2_buffer *vb = NULL;
int ret;
 
+   if (q->fileio) {
+   dprintk(1, "dqbuf: file io in progress\n");
+   return -EBUSY;
+   }
 
if (b->type != q->type) {
dprintk(1, "dqbuf: invalid buffer type\n");
@@ -1083,6 +1096,10 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type 
type)
struct vb2_buffer *vb;
int ret = 0;
 
+   if (q->fileio) {
+   dprintk(1, "streamon: file io in progress\n");
+   return -EBUSY;
+   }
 
if (type != q->type) {
dprintk(1, "streamon: invalid stream type\n");
@@ -1174,6 +1191,10 @@ int vb2_streamoff(struct vb2_queue *q, enum 
v4l2_buf_type type)
 {
int ret = 0;
 
+   if (q->fileio) {
+   dprintk(1, "streamoff: file io in progress\n");
+   return -EBUSY;
+   }
 
if (type != q->type) {
dprintk(1, "streamoff: invalid stream type\n");
@@ -1312,6 +1333,9 @@ bool vb2_has_consumers(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(vb2_has_consumers);
 
+static int __vb2_init_fileio(struct vb2_queue *q, int read);
+static int __vb2_cleanup_fileio(struct vb2_queue *q);
+
 /**
  * vb2_poll() - implements poll userspace operation
  * @q: videobuf2 queue
@@ -1334,6 +1358,22 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
*file, poll_table *wait)
unsigned int ret = 0;
struct vb2_buffer *vb = NULL;
 
+   /*
+* Start file io emulator if streaming api has not been used yet.
+*/
+   if (q->num_buffers == 0 && q->fileio == NULL) {
+   if (!V4L2_TYPE_IS_OUTPUT(q->type) && q->ops->read_setup) {
+   ret = __vb2_init_fileio(q, 1);
+   if (ret)
+   goto end;
+   }
+   if (V4L2_TYPE_IS_OUTPUT(q->type) && q->ops->write_setup) {
+   ret = __vb2_init_fileio(q, 1);
+   if (ret == 0)
+   ret = POLLOUT | POLLWRNORM;
+   goto end;
+   }
+   }
 
/*
 * There is nothing to wait for if no buffers have already been queued.
@@ -1424,11 +1464,366 @@ EXPORT_SYMBOL_GPL(vb2_queue_init);
  */
 void vb2_queue_release(struct vb2_queue *q)
 {
+   __vb2_cleanup_fileio(q);
__vb2_queue_cancel(q);
__vb2_queue_free(q);
 }
 EXPORT_SYMBOL_GPL(vb2_queue_release);
 
+/**
+ * struct vb2_fileio_buf - buffer context used by file io emulator
+ *
+ * vb2 provides a compatibility layer and emulator of file io (read and
+ * write) calls on top of streaming API. This structure is used for
+ * tracking context related to the buffers.
+ */
+struct vb2

[PATCH 1/7] v4l: add videobuf2 Video for Linux 2 driver framework

2010-11-17 Thread Marek Szyprowski
From: Pawel Osciak 

Videobuf2 is a Video for Linux 2 API-compatible driver framework for
multimedia devices. It acts as an intermediate layer between userspace
applications and device drivers. It also provides low-level, modular
memory management functions for drivers.

Videobuf2 eases driver development, reduces drivers' code size and aids in
proper and consistent implementation of V4L2 API in drivers.

Videobuf2 memory management backend is fully modular. This allows custom
memory management routines for devices and platforms with non-standard
memory management requirements to be plugged in, without changing the
high-level buffer management functions and API.

The framework provides:
- implementations of streaming I/O V4L2 ioctls and file operations
- high-level video buffer, video queue and state management functions
- video buffer memory allocation and management

Signed-off-by: Pawel Osciak 
Signed-off-by: Marek Szyprowski 
Signed-off-by: Kyungmin Park 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig  |3 +
 drivers/media/video/Makefile |2 +
 drivers/media/video/videobuf2-core.c | 1434 ++
 include/media/videobuf2-core.h   |  373 +
 4 files changed, 1812 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-core.c
 create mode 100644 include/media/videobuf2-core.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index ac16e81..fef6a14 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -49,6 +49,9 @@ config V4L2_MEM2MEM_DEV
tristate
depends on VIDEOBUF_GEN
 
+config VIDEOBUF2_CORE
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index af79d47..77c4f85 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -114,6 +114,8 @@ obj-$(CONFIG_VIDEOBUF_VMALLOC) += videobuf-vmalloc.o
 obj-$(CONFIG_VIDEOBUF_DVB) += videobuf-dvb.o
 obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
+obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
+
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
diff --git a/drivers/media/video/videobuf2-core.c 
b/drivers/media/video/videobuf2-core.c
new file mode 100644
index 000..5c9d3d8
--- /dev/null
+++ b/drivers/media/video/videobuf2-core.c
@@ -0,0 +1,1434 @@
+/*
+ * videobuf2-core.c - V4L2 driver helper framework
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak 
+ *Marek Szyprowski 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static int debug;
+module_param(debug, int, 0644);
+
+#define dprintk(level, fmt, arg...)\
+   do {\
+   if (debug >= level) \
+   printk(KERN_DEBUG "vb2: " fmt, ## arg); \
+   } while (0)
+
+#define mem_ops(q, plane) ((q)->alloc_ctx[plane]->mem_ops)
+
+#define call_memop(q, plane, op, args...)  \
+   (((q)->alloc_ctx[plane]->mem_ops->op) ? \
+   ((q)->alloc_ctx[plane]->mem_ops->op(args)) : 0)
+
+#define call_qop(q, op, args...)   \
+   (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
+
+/**
+ * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
+ */
+static int __vb2_buf_mem_alloc(struct vb2_buffer *vb,
+   unsigned long *plane_sizes)
+{
+   struct vb2_queue *q = vb->vb2_queue;
+   void *mem_priv;
+   int plane;
+
+   /* Allocate memory for all planes in this buffer */
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane],
+   plane_sizes[plane]);
+   if (!mem_priv)
+   goto free;
+
+   /* Associate allocator private data with this plane */
+   vb->planes[plane].mem_priv = mem_priv;
+   vb->v4l2_planes[plane].length = plane_sizes[plane];
+   }
+
+   return 0;
+free:
+   /* Free already allocated memory if one of the allocations failed */
+   for (; plane > 0; --plane)
+   call_memop(q, plane, put, vb->planes[plane - 1].mem_priv);
+
+   return -ENOMEM;
+}
+
+/**
+ * __vb2_buf_mem_free() - free memory of the given buffer
+ */
+static void __vb2_buf_mem_free(struct vb2_buffer *vb)
+{
+   struct vb2_queue *q = vb->vb2_queue;
+   unsigned int plane;
+
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   

[PATCH 7/7] v4l: videobuf2: add CMA allocator

2010-11-17 Thread Marek Szyprowski
From: Pawel Osciak 

Add support for the CMA contiguous memory allocator to videobuf2.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kyungmin Park 
Signed-off-by: Marek Szyprowski 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig |5 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/videobuf2-cma.c |  250 +++
 include/media/videobuf2-cma.h   |   31 +
 4 files changed, 287 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-cma.c
 create mode 100644 include/media/videobuf2-cma.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9315c0a..eec6c3f 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -65,6 +65,11 @@ config VIDEOBUF2_VMALLOC
select VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_CMA
+   depends on CMA
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index baa74e7..6f917ee 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -118,6 +118,7 @@ obj-$(CONFIG_VIDEOBUF2_CORE)+= 
videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
 obj-$(CONFIG_VIDEOBUF2_DMA_COHERENT)   += videobuf2-dma_coherent.o
+obj-$(CONFIG_VIDEOBUF2_CMA)+= videobuf2-cma.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-cma.c 
b/drivers/media/video/videobuf2-cma.c
new file mode 100644
index 000..157d7ac
--- /dev/null
+++ b/drivers/media/video/videobuf2-cma.c
@@ -0,0 +1,250 @@
+/*
+ * videobuf2-cma.c - CMA memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct vb2_cma_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+   struct device   *dev;
+   const char  *type;
+   unsigned long   alignment;
+};
+
+struct vb2_cma_buf {
+   struct vb2_cma_conf *conf;
+   dma_addr_t  paddr;
+   unsigned long   size;
+   unsigned intrefcount;
+   struct vm_area_struct   *vma;
+};
+
+static void *vb2_cma_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_cma_conf *conf =
+   container_of(alloc_ctx, struct vb2_cma_conf, alloc_ctx);
+   struct vb2_cma_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return ERR_PTR(-ENOMEM);
+
+   buf->paddr = cma_alloc(conf->dev, conf->type, size, conf->alignment);
+   if (IS_ERR((void *)buf->paddr)) {
+   printk(KERN_ERR "cma_alloc of size %ld failed\n", size);
+   kfree(buf);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   buf->conf = conf;
+   buf->size = size;
+   buf->refcount++;
+
+   printk(KERN_DEBUG "Allocated cma mem of size %ld at paddr=0x%08x\n",
+   buf->size, buf->paddr);
+
+   return buf;
+}
+
+static void vb2_cma_put(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   buf->refcount--;
+
+   if (0 == buf->refcount) {
+   cma_free(buf->paddr);
+   kfree(buf);
+   }
+}
+
+static unsigned long vb2_cma_cookie(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   return buf->paddr;
+}
+
+static unsigned int vb2_cma_num_users(void *buf_priv)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   return buf->refcount;
+}
+
+static void vb2_cma_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_cma_buf *buf = vma->vm_private_data;
+
+   printk(KERN_DEBUG "%s cma_priv: %p, refcount: %d, "
+   "vma: %08lx-%08lx\n", __func__, buf, buf->refcount,
+   vma->vm_start, vma->vm_end);
+
+   buf->refcount++;
+}
+
+static void vb2_cma_vm_close(struct vm_area_struct *vma)
+{
+   struct vb2_cma_buf *buf = vma->vm_private_data;
+
+   printk(KERN_DEBUG "%s cma_priv: %p, refcount: %d, "
+   "vma: %08lx-%08lx\n", __func__, buf, buf->refcount,
+   vma->vm_start, vma->vm_end);
+
+   vb2_cma_put(buf);
+}
+
+static const struct vm_operations_struct vb2_cma_vm_ops = {
+   .open = vb2_cma_vm_open,
+   .close = vb2_cma_vm_close,
+};
+
+static int vb2_cma_mmap(void *buf_priv, struct vm_area_struct *vma)
+{
+   struct vb2_cma_buf *buf = buf_priv;
+
+   if (!buf) {
+   printk(KERN_

[PATCH/RFC v4 0/7] Videobuf2 framework

2010-11-17 Thread Marek Szyprowski
Hello,

I've finally managed to implement all the items that I presented on
Linux Plumbers Conference 2010 in Cambridge, MA, US.

This is a major update since the last public version. The most important
items are a new locking policy that came after a discussion with Hans
Verkuil on Embedded Linux Conference Europe and support for write()
call.

File IO emulator provides 2 modes for both read and write. By default
both read and write are implemented in 'streaming' style (like old
videobuf_read_stream() call). By setting VB2_FILEIO_READ_ONCE one can
request 'one shot' mode (like videobuf_read_one() from the original
videobuf). For write emulator one can set VB2_FILEIO_WRITE_IMMEDIATE
flag, what will make each write() call to transform directly into a
q_buf() with aproperiate bytesused entry set, without waiting until the
buffer is filled completely.

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

Changes since V3:
=
- rebased onto 2.6.37-rc2
- new locking policy: vb2 has no internal/hidden locks, the driver takes
  all the responsibility to ensure proper locking: removed vb2_lock and
  introduced new entries in qops: lock and unlock
- added buf_alloc and buf_free callback, it was very hard to add driver
  dependent custom data to buffers without them (and erlier version of VIVI
  driver silently trashed memory with its vivi_buffer structures - now fixed)
- added a new macro 'call_qop' to the core, simplified code
- fixed bytesused entry handling in core (it is now always stored in planes[0])
- changed the paddr callback into a cookie (required for the new upcoming dma
  sg and iommu memory allocators), see include/media/videobuf2-dma-coherent.h
  for more details
- added generic write() support!

Changes since V2:
=
- added read() emulator (see patch #5/7)
- fixed lack of parentheses in macro definitions (caused side effects
  in some places)
- added a separate check for VM_READ or VM_WRITE in vb2_mmap()
- added vb2_is_streaming(), vb2_lock and vb2_unlock inlines
- updated vivi driver with the new read() emulator 

Changes since V1:
=
- removed drv_lock, added start_streaming and stop_streaming callbacks


Here is the original Videobuf2 introduction prepared by Pawel:
===

These patches add a new driver framework for Video for Linux 2 driver
- Videobuf2.

Videobuf2 is intended as a replacement for videobuf, the current driver
framework, which will be referred to as "videobuf1" for the remainder
of this document.


What is videobuf2?

Videobuf2 is a Video for Linux 2 API-compatible driver framework for
multimedia devices. It acts as an intermediate layer between userspace
applications and device drivers. It also provides low-level, modular
memory management functions for drivers.

Videobuf2 eases driver development, reduces drivers' code size and aids in
proper and consistent implementation of V4L2 API in drivers.

Videobuf2 memory management backend is fully modular. This allows custom
memory management routines for devices and platforms with non-standard
memory management requirements to be plugged in, without changing the
high-level buffer management functions and API.

The framework provides:
- implementations of streaming I/O V4L2 ioctls and file operations
- high-level video buffer, video queue and state management functions
- video buffer memory allocation and management


Why a new framework?

There have been many discussions in the V4L2 community about the feasibility
of writing a new framework, as opposed to fixing the existing one. It has been
agreed though that:
- videobuf1 has major flaws and an attempt to fix it would end up in rewriting
most of the code
- many drivers depend on videobuf1 and since the changes would be major,
an effort to adapt and test them all would not be realistically possible

Due to the problems with videobuf most new drivers cannot use it. This leads
to code replication and overcomplicated drivers.


What is wrong with videobuf1?

There are many problems with the current videobuf implementation. During a V4L2
mini-summit in Helsinki in June 2010, two presentations were delivered
on this topic:
- Laurent Pinchart "videobuf - the good, the bad and the ugly"
http://linuxtv.org/downloads/presentations/summit_jun_2010/20100614-v4l2_summit-videobuf.pdf
- Pawel Osciak "Future of the videobuf framework"
http://linuxtv.org/downloads/presentations/summit_jun_2010/Videobuf_Helsinki_June2010.pdf

These presentations highlighted many problems with videobuf. The most prominent
include:

- V4L2 API violations and wrong memory management design
  - it is impossible to pause streaming (buffers are freed on streamoff)
  - VIDIOC_REQBUFS(0) does not free memory
  - it is imp

[PATCH 4/7] v4l: videobuf2: add DMA coherent allocator

2010-11-17 Thread Marek Szyprowski
From: Pawel Osciak 

Add an implementation of DMA coherent memory allocator and handling
routines for videobuf2, implemented on top of dma_alloc_coherent() call.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kyungmin Park 
Signed-off-by: Marek Szyprowski 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig  |5 +
 drivers/media/video/Makefile |1 +
 drivers/media/video/videobuf2-dma-coherent.c |  208 ++
 include/media/videobuf2-dma-coherent.h   |   27 
 4 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-dma-coherent.c
 create mode 100644 include/media/videobuf2-dma-coherent.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9351423..e7752ee1 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -55,6 +55,11 @@ config VIDEOBUF2_CORE
 config VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_DMA_COHERENT
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
+
 config VIDEOBUF2_VMALLOC
select VIDEOBUF2_CORE
select VIDEOBUF2_MEMOPS
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 538bee9..baa74e7 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -117,6 +117,7 @@ obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
+obj-$(CONFIG_VIDEOBUF2_DMA_COHERENT)   += videobuf2-dma_coherent.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-dma-coherent.c 
b/drivers/media/video/videobuf2-dma-coherent.c
new file mode 100644
index 000..761f366
--- /dev/null
+++ b/drivers/media/video/videobuf2-dma-coherent.c
@@ -0,0 +1,208 @@
+/*
+ * videobuf2-dma-coherent.c - DMA coherent memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+
+struct vb2_dc_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+   struct device   *dev;
+};
+
+struct vb2_dc_buf {
+   struct vb2_dc_conf  *conf;
+   void*vaddr;
+   dma_addr_t  paddr;
+   unsigned long   size;
+   unsigned intrefcount;
+   struct vm_area_struct   *vma;
+};
+
+struct vb2_alloc_ctx *vb2_dma_coherent_init(struct device *dev)
+{
+   struct vb2_dc_conf *conf;
+
+   conf = kzalloc(sizeof *conf, GFP_KERNEL);
+   if (!conf)
+   return ERR_PTR(-ENOMEM);
+
+   conf->dev = dev;
+
+   return &conf->alloc_ctx;
+}
+EXPORT_SYMBOL_GPL(vb2_dma_coherent_init);
+
+void vb2_dma_coherent_cleanup(struct vb2_alloc_ctx *alloc_ctx)
+{
+   struct vb2_dc_conf *conf =
+   container_of(alloc_ctx, struct vb2_dc_conf, alloc_ctx);
+
+   kfree(conf);
+}
+EXPORT_SYMBOL_GPL(vb2_dma_coherent_cleanup);
+
+static void *vb2_dma_coherent_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_dc_conf *conf =
+   container_of(alloc_ctx, struct vb2_dc_conf, alloc_ctx);
+   struct vb2_dc_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return ERR_PTR(-ENOMEM);
+
+   buf->vaddr = dma_alloc_coherent(conf->dev, buf->size,
+   &buf->paddr, GFP_KERNEL);
+   if (!buf->vaddr) {
+   dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
+   buf->size);
+   kfree(buf);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   buf->conf = conf;
+   buf->size = size;
+
+   return buf;
+}
+
+static void vb2_dma_coherent_put(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   buf->refcount--;
+
+   if (0 == buf->refcount) {
+   dma_free_coherent(buf->conf->dev, buf->size, buf->vaddr,
+   buf->paddr);
+   kfree(buf);
+   }
+}
+
+static unsigned long vb2_dma_coherent_paddr(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   return buf->paddr;
+}
+
+static unsigned int vb2_dma_coherent_num_users(void *buf_priv)
+{
+   struct vb2_dc_buf *buf = buf_priv;
+
+   return buf->refcount;
+}
+
+static void vb2_dma_coherent_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_dc_buf *buf = vma->vm_private_data;
+
+   printk(KERN_DEBUG "%s cma_priv: %p, refcount: %d, "
+   "vma: %08lx-%08lx\n", __func__, buf, buf->refcount,
+   v

[PATCH 3/7] v4l: videobuf2: add vmalloc allocator

2010-11-17 Thread Marek Szyprowski
From: Pawel Osciak 

Add an implementation of contiguous virtual memory allocator and handling
routines for videobuf2, implemented on top of vmalloc()/vfree() calls.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kyungmin Park 
Signed-off-by: Marek Szyprowski 
CC: Pawel Osciak 
---
 drivers/media/video/Kconfig |5 +
 drivers/media/video/Makefile|1 +
 drivers/media/video/videobuf2-vmalloc.c |  177 +++
 include/media/videobuf2-vmalloc.h   |   16 +++
 4 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/videobuf2-vmalloc.c
 create mode 100644 include/media/videobuf2-vmalloc.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 83ce858..9351423 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -55,6 +55,11 @@ config VIDEOBUF2_CORE
 config VIDEOBUF2_MEMOPS
tristate
 
+config VIDEOBUF2_VMALLOC
+   select VIDEOBUF2_CORE
+   select VIDEOBUF2_MEMOPS
+   tristate
+
 #
 # Multimedia Video device configuration
 #
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index a97a2a0..538bee9 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -116,6 +116,7 @@ obj-$(CONFIG_VIDEO_BTCX)  += btcx-risc.o
 
 obj-$(CONFIG_VIDEOBUF2_CORE)   += videobuf2-core.o
 obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
+obj-$(CONFIG_VIDEOBUF2_VMALLOC)+= videobuf2-vmalloc.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
diff --git a/drivers/media/video/videobuf2-vmalloc.c 
b/drivers/media/video/videobuf2-vmalloc.c
new file mode 100644
index 000..3310900
--- /dev/null
+++ b/drivers/media/video/videobuf2-vmalloc.c
@@ -0,0 +1,177 @@
+/*
+ * videobuf2-vmalloc.c - vmalloc memory allocator for videobuf2
+ *
+ * Copyright (C) 2010 Samsung Electronics
+ *
+ * Author: Pawel Osciak 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct vb2_vmalloc_conf {
+   struct vb2_alloc_ctxalloc_ctx;
+};
+
+struct vb2_vmalloc_buf {
+   void*vaddr;
+   unsigned long   size;
+   unsigned intrefcount;
+};
+
+static void *vb2_vmalloc_alloc(const struct vb2_alloc_ctx *alloc_ctx,
+   unsigned long size)
+{
+   struct vb2_vmalloc_buf *buf;
+
+   buf = kzalloc(sizeof *buf, GFP_KERNEL);
+   if (!buf)
+   return NULL;
+
+   buf->size = size;
+   buf->vaddr = vmalloc_user(buf->size);
+   if (!buf->vaddr) {
+   printk(KERN_ERR "vmalloc of size %ld failed\n", buf->size);
+   kfree(buf);
+   return NULL;
+   }
+
+   buf->refcount++;
+   printk(KERN_DEBUG "Allocated vmalloc buffer of size %ld at vaddr=%p\n",
+   buf->size, buf->vaddr);
+
+   return buf;
+}
+
+static void vb2_vmalloc_put(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   buf->refcount--;
+
+   if (0 == buf->refcount) {
+   printk(KERN_DEBUG "%s: Freeing vmalloc mem at vaddr=%p\n",
+   __func__, buf->vaddr);
+   vfree(buf->vaddr);
+   kfree(buf);
+   }
+}
+
+static void *vb2_vmalloc_vaddr(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   BUG_ON(!buf);
+
+   if (!buf->vaddr) {
+   printk(KERN_ERR "Address of an unallocated "
+   "plane requested\n");
+   return NULL;
+   }
+
+   return buf->vaddr;
+}
+
+static unsigned int vb2_vmalloc_num_users(void *buf_priv)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+
+   return buf->refcount;
+}
+
+/* TODO generalize and extract to core as much as possible */
+static void vb2_vmalloc_vm_open(struct vm_area_struct *vma)
+{
+   struct vb2_vmalloc_buf *buf = vma->vm_private_data;
+
+   printk(KERN_DEBUG "%s vmalloc_priv: %p, refcount: %d, "
+   "vma: %08lx-%08lx\n", __func__, buf, buf->refcount,
+   vma->vm_start, vma->vm_end);
+
+   buf->refcount++;
+}
+
+static void vb2_vmalloc_vm_close(struct vm_area_struct *vma)
+{
+   struct vb2_vmalloc_buf *buf = vma->vm_private_data;
+
+   printk(KERN_DEBUG "%s vmalloc_priv: %p, refcount: %d, "
+   "vma: %08lx-%08lx\n", __func__, buf, buf->refcount,
+   vma->vm_start, vma->vm_end);
+
+   vb2_vmalloc_put(buf);
+}
+
+static const struct vm_operations_struct vb2_vmalloc_vm_ops = {
+   .open = vb2_vmalloc_vm_open,
+   .close = vb2_vmalloc_vm_close,
+};
+
+static int vb2_vmalloc_mmap(void *buf_priv, struct vm_area_struct *vma)
+{
+   struct vb2_vmalloc_buf *buf = buf_priv;
+

Re: [RFCv2 PATCH 01/15] v4l2-dev: use mutex_lock_interruptible instead of plain mutex_lock

2010-11-17 Thread Arnd Bergmann
On Tuesday 16 November 2010 22:55:32 Hans Verkuil wrote:
> Where reasonable use mutex_lock_interruptible instead of mutex_lock.
> 
> Signed-off-by: Hans Verkuil 

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


Re: [RFCv2 PATCH 14/15] V4L: improve the BKL replacement heuristic

2010-11-17 Thread Arnd Bergmann
On Tuesday 16 November 2010 22:56:45 Hans Verkuil wrote:
> The BKL replacement mutex had some serious performance side-effects on
> V4L drivers. It is replaced by a better heuristic that works around the
> worst of the side-effects.
> 
> Read the v4l2-dev.c comments for the whole sorry story. This is a
> temporary measure only until we can convert all v4l drivers to use
> unlocked_ioctl.
> 
> Signed-off-by: Hans Verkuil 
Acked-by: Arnd Bergmann 

> ---
>  drivers/media/video/v4l2-dev.c|   37 
> ++---
>  drivers/media/video/v4l2-device.c |1 +
>  include/media/v4l2-dev.h  |2 +-
>  include/media/v4l2-device.h   |2 ++
>  4 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index 8eb0756..59ef642 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -258,11 +258,42 @@ static long v4l2_ioctl(struct file *filp, unsigned int 
> cmd, unsigned long arg)
>   if (vdev->lock)
>   mutex_unlock(vdev->lock);
>   } else if (vdev->fops->ioctl) {
> - /* TODO: convert all drivers to unlocked_ioctl */
> - lock_kernel();
> + /* This code path is a replacement for the BKL. It is a major
> +  * hack but it will have to do for those drivers that are not
> +  * yet converted to use unlocked_ioctl.
> +  *
> +  * There are two options: if the driver implements struct
> +  * v4l2_device, then the lock defined there is used to
> +  * serialize the ioctls. Otherwise the v4l2 core lock defined
> +  * below is used. This lock is really bad since it serializes
> +  * completely independent devices.
> +  *
> +  * Both variants suffer from the same problem: if the driver
> +  * sleeps, then it blocks all ioctls since the lock is still
> +  * held. This is very common for VIDIOC_DQBUF since that
> +  * normally waits for a frame to arrive. As a result any other
> +  * ioctl calls will proceed very, very slowly since each call
> +  * will have to wait for the VIDIOC_QBUF to finish. Things that
> +  * should take 0.01s may now take 10-20 seconds.
> +  *
> +  * The workaround is to *not* take the lock for VIDIOC_DQBUF.
> +  * This actually works OK for videobuf-based drivers, since
> +  * videobuf will take its own internal lock.
> +  */
> + static DEFINE_MUTEX(v4l2_ioctl_mutex);
> + struct mutex *m = vdev->v4l2_dev ?
> + &vdev->v4l2_dev->ioctl_lock : &v4l2_ioctl_mutex;
> +
> + if (cmd != VIDIOC_DQBUF) {
> + int res = mutex_lock_interruptible(m);
> +
> + if (res)
> + return res;
> + }
>   if (video_is_registered(vdev))
>   ret = vdev->fops->ioctl(filp, cmd, arg);
> - unlock_kernel();
> + if (cmd != VIDIOC_DQBUF)
> + mutex_unlock(m);
>   } else
>   ret = -ENOTTY;
>  
> diff --git a/drivers/media/video/v4l2-device.c 
> b/drivers/media/video/v4l2-device.c
> index 0b08f96..7fe6f92 100644
> --- a/drivers/media/video/v4l2-device.c
> +++ b/drivers/media/video/v4l2-device.c
> @@ -35,6 +35,7 @@ int v4l2_device_register(struct device *dev, struct 
> v4l2_device *v4l2_dev)
>  
>   INIT_LIST_HEAD(&v4l2_dev->subdevs);
>   spin_lock_init(&v4l2_dev->lock);
> + mutex_init(&v4l2_dev->ioctl_lock);
>   v4l2_dev->dev = dev;
>   if (dev == NULL) {
>   /* If dev == NULL, then name must be filled in by the caller */
> diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
> index 15802a0..59dec5a 100644
> --- a/include/media/v4l2-dev.h
> +++ b/include/media/v4l2-dev.h
> @@ -39,7 +39,7 @@ struct v4l2_file_operations {
>   ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
>   ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
>   unsigned int (*poll) (struct file *, struct poll_table_struct *);
> - long (*ioctl) (struct file *, unsigned int, unsigned long);
> + long (*ioctl __deprecated) (struct file *, unsigned int, unsigned long);
>   long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
>   int (*mmap) (struct file *, struct vm_area_struct *);
>   int (*open) (struct file *);
> diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
> index 6648036..b16f307 100644
> --- a/include/media/v4l2-device.h
> +++ b/include/media/v4l2-device.h
> @@ -51,6 +51,8 @@ struct v4l2_device {
>   unsigned int notification, void *arg);
>   /* The control handler. May be NULL. */
>   struct v4l2_ctrl_hand