[PATCH] rtl28xxu: add [1b80:d3b0] Sveon STV21

2014-06-12 Thread Sebastian Kemper
Added Sveon STV21 device based on Realtek RTL2832U and FC0013 tuner

Signed-off-by: Sebastian Kemper sebastian...@gmx.net
---

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 11d2bea..b518ada 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -363,6 +363,7 @@
 #define USB_PID_TVWAY_PLUS 0x0002
 #define USB_PID_SVEON_STV200xe39d
 #define USB_PID_SVEON_STV20_RTL2832U   0xd39d
+#define USB_PID_SVEON_STV210xd3b0
 #define USB_PID_SVEON_STV220xe401
 #define USB_PID_SVEON_STV22_IT9137 0xe411
 #define USB_PID_AZUREWAVE_AZ6027   0x3275
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index a676e44..5f8ff0f 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1541,6 +1541,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
rtl2832u_props, Peak DVB-T USB, NULL) },
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20_RTL2832U,
rtl2832u_props, Sveon STV20, NULL) },
+   { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV21,
+   rtl2832u_props, Sveon STV21, NULL) },
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV27,
rtl2832u_props, Sveon STV27, NULL) },
 
--
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


color box, display box, corrugated box, color card, blister card, color sleeve, hang tag, label

2014-06-12 Thread Jinghao Printing - CHINA
Hi, this is David Wu from Shanghai, China.
We are a printing company, we can print color box, corrugated box,
label, hang tag etc.
Please let me know if you need these.

I will send you the website then.

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


[patch v2] [media] davinci: vpif: missing unlocks on error

2014-06-12 Thread Dan Carpenter
We recently changed some locking around so we need some new unlocks on
the error paths.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
---
v2: move the unlock so the list_for_each_entry_safe() loop is protected

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index a7ed164..1e4ec69 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -269,6 +269,7 @@ err:
list_del(buf-list);
vb2_buffer_done(buf-vb, VB2_BUF_STATE_QUEUED);
}
+   spin_unlock_irqrestore(common-irqlock, flags);
 
return ret;
 }
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 5bb085b..b431b58 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -233,6 +233,7 @@ err:
list_del(buf-list);
vb2_buffer_done(buf-vb, VB2_BUF_STATE_QUEUED);
}
+   spin_unlock_irqrestore(common-irqlock, flags);
 
return ret;
 }
--
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] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready

2014-06-12 Thread James Harper
Patch originally written by Konrad. Rebased on current linux media tree.

Under Xen, vmalloc_32() isn't guaranteed to return pages which are really
under 4G in machine physical addresses (only in virtual pseudo-physical
addresses).  To work around this, implement a vmalloc variant which
allocates each page with dma_alloc_coherent() to guarantee that each
page is suitable for the device in question.

Signed-off-by: Konrad Rzeszutek Wilk konrad.w...@oracle.com
Signed-off-by: James Harper james.har...@ejbdigital.com.au
---
 drivers/media/v4l2-core/videobuf-dma-sg.c | 62 +--
 include/media/videobuf-dma-sg.h   |  3 ++
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c 
b/drivers/media/v4l2-core/videobuf-dma-sg.c
index 828e7c1..3c8cc02 100644
--- a/drivers/media/v4l2-core/videobuf-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf-dma-sg.c
@@ -211,13 +211,36 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
 int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
 int nr_pages)
 {
+   int i;
+
dprintk(1, init kernel [%d pages]\n, nr_pages);
 
dma-direction = direction;
-   dma-vaddr = vmalloc_32(nr_pages  PAGE_SHIFT);
+   dma-vaddr_pages = kcalloc(nr_pages, sizeof(*dma-vaddr_pages),
+  GFP_KERNEL);
+   if (!dma-vaddr_pages)
+   return -ENOMEM;
+
+   dma-dma_addr = kcalloc(nr_pages, sizeof(*dma-dma_addr), GFP_KERNEL);
+   if (!dma-dma_addr) {
+   kfree(dma-vaddr_pages);
+   return -ENOMEM;
+   }
+   for (i = 0; i  nr_pages; i++) {
+   void *addr;
+
+   addr = dma_alloc_coherent(dma-dev, PAGE_SIZE,
+ (dma-dma_addr[i]), GFP_KERNEL);
+   if (addr == NULL)
+   goto out_free_pages;
+
+   dma-vaddr_pages[i] = virt_to_page(addr);
+   }
+   dma-vaddr = vmap(dma-vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP,
+ PAGE_KERNEL);
if (NULL == dma-vaddr) {
dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
-   return -ENOMEM;
+   goto out_free_pages;
}
 
dprintk(1, vmalloc is at addr 0x%08lx, size=%d\n,
@@ -228,6 +251,19 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, 
int direction,
dma-nr_pages = nr_pages;
 
return 0;
+out_free_pages:
+   while (i  0) {
+   void *addr = page_address(dma-vaddr_pages[i]);
+   dma_free_coherent(dma-dev, PAGE_SIZE, addr, dma-dma_addr[i]);
+   i--;
+   }
+   kfree(dma-dma_addr);
+   dma-dma_addr = NULL;
+   kfree(dma-vaddr_pages);
+   dma-vaddr_pages = NULL;
+
+   return -ENOMEM;
+
 }
 EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
 
@@ -322,8 +358,21 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma)
dma-pages = NULL;
}
 
-   vfree(dma-vaddr);
-   dma-vaddr = NULL;
+   if (dma-dma_addr) {
+   for (i = 0; i  dma-nr_pages; i++) {
+   void *addr;
+
+   addr = page_address(dma-vaddr_pages[i]);
+   dma_free_coherent(dma-dev, PAGE_SIZE, addr,
+ dma-dma_addr[i]);
+   }
+   kfree(dma-dma_addr);
+   dma-dma_addr = NULL;
+   kfree(dma-vaddr_pages);
+   dma-vaddr_pages = NULL;
+   vunmap(dma-vaddr);
+   dma-vaddr = NULL;
+   }
 
if (dma-bus_addr)
dma-bus_addr = 0;
@@ -461,6 +510,11 @@ static int __videobuf_iolock(struct videobuf_queue *q,
 
MAGIC_CHECK(mem-magic, MAGIC_SG_MEM);
 
+   if (!mem-dma.dev)
+   mem-dma.dev = q-dev;
+   else
+   WARN_ON(mem-dma.dev != q-dev);
+
switch (vb-memory) {
case V4L2_MEMORY_MMAP:
case V4L2_MEMORY_USERPTR:
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
index d8fb601..fb6fd4d8 100644
--- a/include/media/videobuf-dma-sg.h
+++ b/include/media/videobuf-dma-sg.h
@@ -53,6 +53,9 @@ struct videobuf_dmabuf {
 
/* for kernel buffers */
void*vaddr;
+   struct page **vaddr_pages;
+   dma_addr_t  *dma_addr;
+   struct device   *dev;
 
/* for overlay buffers (pci-pci dma) */
dma_addr_t  bus_addr;
-- 
2.0.0

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


[PATCH] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready

2014-06-12 Thread James Harper
Patch originally written by Konrad. Rebased on current linux media tree.

Under Xen, vmalloc_32() isn't guaranteed to return pages which are really
under 4G in machine physical addresses (only in virtual pseudo-physical
addresses).  To work around this, implement a vmalloc variant which
allocates each page with dma_alloc_coherent() to guarantee that each
page is suitable for the device in question.

Signed-off-by: Konrad Rzeszutek Wilk konrad.w...@oracle.com
Signed-off-by: James Harper james.har...@ejbdigital.com.au
---
 drivers/media/v4l2-core/videobuf-dma-sg.c | 62 +--
 include/media/videobuf-dma-sg.h   |  3 ++
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c 
b/drivers/media/v4l2-core/videobuf-dma-sg.c
index 828e7c1..3c8cc02 100644
--- a/drivers/media/v4l2-core/videobuf-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf-dma-sg.c
@@ -211,13 +211,36 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
 int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
 int nr_pages)
 {
+   int i;
+
dprintk(1, init kernel [%d pages]\n, nr_pages);
 
dma-direction = direction;
-   dma-vaddr = vmalloc_32(nr_pages  PAGE_SHIFT);
+   dma-vaddr_pages = kcalloc(nr_pages, sizeof(*dma-vaddr_pages),
+  GFP_KERNEL);
+   if (!dma-vaddr_pages)
+   return -ENOMEM;
+
+   dma-dma_addr = kcalloc(nr_pages, sizeof(*dma-dma_addr), GFP_KERNEL);
+   if (!dma-dma_addr) {
+   kfree(dma-vaddr_pages);
+   return -ENOMEM;
+   }
+   for (i = 0; i  nr_pages; i++) {
+   void *addr;
+
+   addr = dma_alloc_coherent(dma-dev, PAGE_SIZE,
+ (dma-dma_addr[i]), GFP_KERNEL);
+   if (addr == NULL)
+   goto out_free_pages;
+
+   dma-vaddr_pages[i] = virt_to_page(addr);
+   }
+   dma-vaddr = vmap(dma-vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP,
+ PAGE_KERNEL);
if (NULL == dma-vaddr) {
dprintk(1, vmalloc_32(%d pages) failed\n, nr_pages);
-   return -ENOMEM;
+   goto out_free_pages;
}
 
dprintk(1, vmalloc is at addr 0x%08lx, size=%d\n,
@@ -228,6 +251,19 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, 
int direction,
dma-nr_pages = nr_pages;
 
return 0;
+out_free_pages:
+   while (i  0) {
+   void *addr = page_address(dma-vaddr_pages[i]);
+   dma_free_coherent(dma-dev, PAGE_SIZE, addr, dma-dma_addr[i]);
+   i--;
+   }
+   kfree(dma-dma_addr);
+   dma-dma_addr = NULL;
+   kfree(dma-vaddr_pages);
+   dma-vaddr_pages = NULL;
+
+   return -ENOMEM;
+
 }
 EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
 
@@ -322,8 +358,21 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma)
dma-pages = NULL;
}
 
-   vfree(dma-vaddr);
-   dma-vaddr = NULL;
+   if (dma-dma_addr) {
+   for (i = 0; i  dma-nr_pages; i++) {
+   void *addr;
+
+   addr = page_address(dma-vaddr_pages[i]);
+   dma_free_coherent(dma-dev, PAGE_SIZE, addr,
+ dma-dma_addr[i]);
+   }
+   kfree(dma-dma_addr);
+   dma-dma_addr = NULL;
+   kfree(dma-vaddr_pages);
+   dma-vaddr_pages = NULL;
+   vunmap(dma-vaddr);
+   dma-vaddr = NULL;
+   }
 
if (dma-bus_addr)
dma-bus_addr = 0;
@@ -461,6 +510,11 @@ static int __videobuf_iolock(struct videobuf_queue *q,
 
MAGIC_CHECK(mem-magic, MAGIC_SG_MEM);
 
+   if (!mem-dma.dev)
+   mem-dma.dev = q-dev;
+   else
+   WARN_ON(mem-dma.dev != q-dev);
+
switch (vb-memory) {
case V4L2_MEMORY_MMAP:
case V4L2_MEMORY_USERPTR:
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
index d8fb601..fb6fd4d8 100644
--- a/include/media/videobuf-dma-sg.h
+++ b/include/media/videobuf-dma-sg.h
@@ -53,6 +53,9 @@ struct videobuf_dmabuf {
 
/* for kernel buffers */
void*vaddr;
+   struct page **vaddr_pages;
+   dma_addr_t  *dma_addr;
+   struct device   *dev;
 
/* for overlay buffers (pci-pci dma) */
dma_addr_t  bus_addr;
-- 
2.0.0

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


[PATCH] Add support for DViCO FusionHDTV DVB-T Dual Express2

2014-06-12 Thread James Harper
DViCO FusionHDTV DVB-T Dual Express2 is cx23885 + dib7070

Signed-off-by: James Harper james.har...@ejbdigital.com.au
---
 drivers/media/pci/cx23885/cx23885-cards.c |  15 +++-
 drivers/media/pci/cx23885/cx23885-dvb.c   | 123 ++
 drivers/media/pci/cx23885/cx23885.h   |   1 +
 3 files changed, 138 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 79f20c8..9ca8855 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -649,7 +649,12 @@ struct cx23885_board cx23885_boards[] = {
  CX25840_NONE1_CH3,
.amux   = CX25840_AUDIO6,
} },
-   }
+   },
+   [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2] = {
+   .name   = DViCO FusionHDTV DVB-T Dual Express2,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -897,6 +902,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x1461,
.subdevice = 0xd939,
.card  = CX23885_BOARD_AVERMEDIA_HC81R,
+   }, {
+   .subvendor = 0x18ac,
+   .subdevice = 0xdb98,
+   .card  = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1137,6 +1146,7 @@ int cx23885_tuner_callback(void *priv, int component, int 
command, int arg)
break;
case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+   case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
/* Two identical tuners on two different i2c buses,
 * we need to reset the correct gpio. */
if (port-nr == 1)
@@ -1280,6 +1290,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x000f000f);
break;
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+   case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
/* GPIO-0 portb xc3028 reset */
/* GPIO-1 portb zl10353 reset */
/* GPIO-2 portc xc3028 reset */
@@ -1585,6 +1596,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
 ir_rxtx_pin_cfg_count, ir_rxtx_pin_cfg);
break;
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+   case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
request_module(ir-kbd-i2c);
break;
}
@@ -1720,6 +1732,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
break;
case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+   case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
ts2-gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
ts2-ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts2-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index d037459..5c627e6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -44,6 +44,7 @@
 #include tuner-xc2028.h
 #include tuner-simple.h
 #include dib7000p.h
+#include dib0070.h
 #include dibx000_common.h
 #include zl10353.h
 #include stv0900.h
@@ -746,6 +747,104 @@ static int netup_altera_fpga_rw(void *device, int flag, 
int data, int read)
return 0;
 };
 
+static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) {
+   struct dib7000p_ops *dib7000p_ops = fe-sec_priv;
+   return dib7000p_ops-set_gpio(fe, 8, 0, !onoff);
+}
+
+static int
+dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) {
+   return 0;
+}
+
+static struct dib0070_config dib7070p_dib0070_config = {
+   .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
+   .reset = dib7070_tuner_reset,
+   .sleep = dib7070_tuner_sleep,
+   .clock_khz = 12000,
+   .freq_offset_khz_vhf = 950,
+   .freq_offset_khz_vhf = 550,
+   //.flip_chip = 1,
+};
+
+/* DIB7070 generic */
+static struct dibx000_agc_config dib7070_agc_config = {
+   .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
+
+   /*
+* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
+* P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
+* P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
+*/
+   .setup = (0  15) | (0  14) | (5  11) | (0  10) | (0  9) |
+(0  8) | (3  5) | (0  4) | (5  1) | (0  0),
+   .inv_gain = 600,
+   .time_stabiliz = 10,
+   .alpha_level = 0,
+   .thlock = 118,

Re: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread David Härdeman

Hi,

the problem with triggering a keypress as soon as 32 bits have been 
received (i.e. before the trailing silence is detected) is that it would 
cause phantom keypresses on some other protocols (I'm thinking of NEC48, 
which does exist in the wild).


Now, the question is why the trailing silence isn't generated within a 
reasonable time. Which hardware decoder do you use?


//David

On 2014-06-11 10:06, Niels Laukens wrote:
I have not received any response on this email... so I hope to bump 
this

thread back to the more active region in most people's in-boxes.


On 2014-05-31 10:37, Niels Laukens wrote:

Hi,

I believe I've found a bug in the NEC decoder for InfraRed remote
controls. The problem manifests itself as an extra keypress that 
happens

when pushing different buttons in rapid succession.

I can reproduce the problem easily (but not always) by pushing DOWN, 
DOWN,
UP in rapid succession. I put rapid in quotes, because I don't 
have to

hurry in any way, it happens when I use it normally. Depending on the
duration of the presses, I get a number of repeats of DOWN. The bug is
that an additional DOWN keypress happens at the time that I press the 
UP

key (or so it seams).

Attached is kernel-debug.log, which contains the redacted and 
annotated
dmesg output, illustrating the problem described above. Especially 
note
lines 31-36 and 54-59, where more than 200ms pass between the end of 
the

IR-code and the actual emit of the keydown event.


I've debugged this issue, and believe I've found the cause: The 
keypress

is only emitted in state 5 (STATE_TRAILER_SPACE). This state is only
executed when the space after the message is received, i.e. when the
next pulse (of the next message) starts. It is only then that the 
length

of the space is known, and that ir_raw_event will fire an event.

The patch below addresses this issue. This is my first kernel patch.
I've tried to follow all guidelines that I could find, but might have
missed a few.

I've tested this patch with the out-of-tree TBS drivers (which seem to
be based on 3.13), and it solves the bug.
I've compared this TBS-version with the current master (1487385). 
There

are 8 (non-comment) lines that differ, none affect this patch. This
patch applies cleanly to the current master.

Regards,
Niels




From 071c316e9315f22a055d6713cc8cdcdc73642193 Mon Sep 17 00:00:00 2001
From: Niels Laukens ni...@dest-unreach.be
Date: Sat, 31 May 2014 10:30:18 +0200
Subject: [PATCH] drivers/media/rc/ir-nec-decode: fix phantom detect

The IR NEC decoder waited until the TRAILER_SPACE state to emit a
keypress. Since the triggering 'space' event will only be sent at the
beginning of the *next* IR-code, this is way to late.

This patch moves the processing to the TRAILER_PULSE state. Since we
arrived here with a 'pulse' event, we know that the pulse has ended 
and

thus that the space is there (as of yet with unknown length).

Signed-off-by: Niels Laukens ni...@dest-unreach.be
---
 drivers/media/rc/ir-nec-decoder.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c

index 35c42e5..955f99d 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -148,16 +148,6 @@ static int ir_nec_decode(struct rc_dev *dev, 
struct ir_raw_event ev)

if (!eq_margin(ev.duration, NEC_TRAILER_PULSE, NEC_UNIT / 2))
break;

-   data-state = STATE_TRAILER_SPACE;
-   return 0;
-
-   case STATE_TRAILER_SPACE:
-   if (ev.pulse)
-   break;
-
-   if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
-   break;
-
address = bitrev8((data-bits  24)  0xff);
not_address = bitrev8((data-bits  16)  0xff);
command = bitrev8((data-bits   8)  0xff);
@@ -190,6 +180,16 @@ static int ir_nec_decode(struct rc_dev *dev, 
struct ir_raw_event ev)

data-necx_repeat = true;

rc_keydown(dev, scancode, 0);
+   data-state = STATE_TRAILER_SPACE;
+   return 0;
+
+   case STATE_TRAILER_SPACE:
+   if (ev.pulse)
+   break;
+
+   if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
+   break;
+
data-state = STATE_INACTIVE;
return 0;
}


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


Re: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread Niels Laukens
On 2014-06-12 12:42, David Härdeman wrote:
 Hi,

Hi, thanks for the response


 the problem with triggering a keypress as soon as 32 bits have been
 received (i.e. before the trailing silence is detected)

Just for clarity: this patch does wait for the trailing silence. It does
NOT wait for the trailing silence to have (at least) a specific length.
(The pulse event is only fired after the pulse has ended, because the
length of the pulse needs to be known)


 is that it would
 cause phantom keypresses on some other protocols (I'm thinking of NEC48,
 which does exist in the wild).

I don't think the current code is able to decode NEC48. Is NEC48
recognizable in some other way than just being longer?

In that case, the alternative would be to start a timer when the
TRAILING_SPACE is entered, and trigger the key-event after, say 2 bit-times.


 Now, the question is why the trailing silence isn't generated within a
 reasonable time. Which hardware decoder do you use?

I use the IR receiver built in to the TBS6281 DVB-T tuner card. I also
have a TBS6982 DVB-S card, but I guess it's the same hardware.

It also depends on what reasonable means. I've found 300+ms, which is
unusable long.


Niels



 On 2014-06-11 10:06, Niels Laukens wrote:
 I have not received any response on this email... so I hope to bump this
 thread back to the more active region in most people's in-boxes.


 On 2014-05-31 10:37, Niels Laukens wrote:
 Hi,

 I believe I've found a bug in the NEC decoder for InfraRed remote
 controls. The problem manifests itself as an extra keypress that happens
 when pushing different buttons in rapid succession.

 I can reproduce the problem easily (but not always) by pushing DOWN,
 DOWN,
 UP in rapid succession. I put rapid in quotes, because I don't
 have to
 hurry in any way, it happens when I use it normally. Depending on the
 duration of the presses, I get a number of repeats of DOWN. The bug is
 that an additional DOWN keypress happens at the time that I press the UP
 key (or so it seams).

 Attached is kernel-debug.log, which contains the redacted and annotated
 dmesg output, illustrating the problem described above. Especially note
 lines 31-36 and 54-59, where more than 200ms pass between the end of the
 IR-code and the actual emit of the keydown event.


 I've debugged this issue, and believe I've found the cause: The keypress
 is only emitted in state 5 (STATE_TRAILER_SPACE). This state is only
 executed when the space after the message is received, i.e. when the
 next pulse (of the next message) starts. It is only then that the length
 of the space is known, and that ir_raw_event will fire an event.

 The patch below addresses this issue. This is my first kernel patch.
 I've tried to follow all guidelines that I could find, but might have
 missed a few.

 I've tested this patch with the out-of-tree TBS drivers (which seem to
 be based on 3.13), and it solves the bug.
 I've compared this TBS-version with the current master (1487385). There
 are 8 (non-comment) lines that differ, none affect this patch. This
 patch applies cleanly to the current master.

 Regards,
 Niels




 From 071c316e9315f22a055d6713cc8cdcdc73642193 Mon Sep 17 00:00:00 2001
 From: Niels Laukens ni...@dest-unreach.be
 Date: Sat, 31 May 2014 10:30:18 +0200
 Subject: [PATCH] drivers/media/rc/ir-nec-decode: fix phantom detect

 The IR NEC decoder waited until the TRAILER_SPACE state to emit a
 keypress. Since the triggering 'space' event will only be sent at the
 beginning of the *next* IR-code, this is way to late.

 This patch moves the processing to the TRAILER_PULSE state. Since we
 arrived here with a 'pulse' event, we know that the pulse has ended and
 thus that the space is there (as of yet with unknown length).

 Signed-off-by: Niels Laukens ni...@dest-unreach.be
 ---
  drivers/media/rc/ir-nec-decoder.c | 20 ++--
  1 file changed, 10 insertions(+), 10 deletions(-)

 diff --git a/drivers/media/rc/ir-nec-decoder.c
 b/drivers/media/rc/ir-nec-decoder.c
 index 35c42e5..955f99d 100644
 --- a/drivers/media/rc/ir-nec-decoder.c
 +++ b/drivers/media/rc/ir-nec-decoder.c
 @@ -148,16 +148,6 @@ static int ir_nec_decode(struct rc_dev *dev,
 struct ir_raw_event ev)
  if (!eq_margin(ev.duration, NEC_TRAILER_PULSE, NEC_UNIT / 2))
  break;

 -data-state = STATE_TRAILER_SPACE;
 -return 0;
 -
 -case STATE_TRAILER_SPACE:
 -if (ev.pulse)
 -break;
 -
 -if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
 -break;
 -
  address = bitrev8((data-bits  24)  0xff);
  not_address = bitrev8((data-bits  16)  0xff);
  command= bitrev8((data-bits   8)  0xff);
 @@ -190,6 +180,16 @@ static int ir_nec_decode(struct rc_dev *dev,
 struct ir_raw_event ev)
  data-necx_repeat = true;

  rc_keydown(dev, scancode, 0);
 +data-state = STATE_TRAILER_SPACE;
 +return 0;
 +
 +case 

Re: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread David Härdeman

On 2014-06-12 13:22, Niels Laukens wrote:

On 2014-06-12 12:42, David Härdeman wrote:

Hi,


Hi, thanks for the response



the problem with triggering a keypress as soon as 32 bits have been
received (i.e. before the trailing silence is detected)


Just for clarity: this patch does wait for the trailing silence. It 
does

NOT wait for the trailing silence to have (at least) a specific length.
(The pulse event is only fired after the pulse has ended, because the
length of the pulse needs to be known)


True.

Interpret trailing silence above as silence long enough to indicate 
end of message :)



is that it would
cause phantom keypresses on some other protocols (I'm thinking of 
NEC48,

which does exist in the wild).


I don't think the current code is able to decode NEC48.


No, but it would still be nice not to interpret a NEC48 signal as NEC32.


Is NEC48 recognizable in some other way than just being longer?


IIRC, no.


In that case, the alternative would be to start a timer when the
TRAILING_SPACE is entered, and trigger the key-event after, say 2 
bit-times.


Another alternative is fix the driver to implement a timeout so that 
unreasonable values are not generated (I saw a 240550us space in your 
log).


That's basically what the filtering version of the raw interface does 
(cf. the use of dev-timeout in ir_raw_event_store_with_filter()).


And it's what most of the popular hardware does. For instance, the 
mceusb hardware will send a USB packet with timings including that 
trailing silence. And the decoder can only do their work once a packet 
has arrived (which will contain a number of samples). That also 
demonstrates a potential problem with your suggested approach (i.e. 
timings can be buffered so calls to the decoders are not necessarily 
real-time).



Now, the question is why the trailing silence isn't generated within a
reasonable time. Which hardware decoder do you use?


I use the IR receiver built in to the TBS6281 DVB-T tuner card. I also
have a TBS6982 DVB-S card, but I guess it's the same hardware.


Which driver?


It also depends on what reasonable means. I've found 300+ms, which is
unusable long.


Agreed...

//David

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


[REVIEWv4 PATCH 06/34] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRL.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add the v4l2 core plumbing for the new VIDIOC_QUERY_EXT_CTRL ioctl.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/v4l2-core/v4l2-dev.c|  2 ++
 drivers/media/v4l2-core/v4l2-ioctl.c  | 33 +
 drivers/media/v4l2-core/v4l2-subdev.c |  3 +++
 include/media/v4l2-ioctl.h|  2 ++
 4 files changed, 40 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 634d863..aba277c 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -577,6 +577,8 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
   be valid if the filehandle passed the control handler. */
if (vdev-ctrl_handler || ops-vidioc_queryctrl)
set_bit(_IOC_NR(VIDIOC_QUERYCTRL), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_query_ext_ctrl)
+   set_bit(_IOC_NR(VIDIOC_QUERY_EXT_CTRL), valid_ioctls);
if (vdev-ctrl_handler || ops-vidioc_g_ctrl || ops-vidioc_g_ext_ctrls)
set_bit(_IOC_NR(VIDIOC_G_CTRL), valid_ioctls);
if (vdev-ctrl_handler || ops-vidioc_s_ctrl || ops-vidioc_s_ext_ctrls)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 16bffd8..b82ea79 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -525,6 +525,21 @@ static void v4l_print_queryctrl(const void *arg, bool 
write_only)
p-step, p-default_value, p-flags);
 }
 
+static void v4l_print_query_ext_ctrl(const void *arg, bool write_only)
+{
+   const struct v4l2_query_ext_ctrl *p = arg;
+
+   pr_cont(id=0x%x, type=%d, name=%.*s, min/max=%lld/%lld, 
+   step=%lld, default=%lld, flags=0x%08x, elem_size=%u, elems=%u, 

+   nr_of_dims=%u, dims=%u,%u,%u,%u,%u,%u,%u,%u\n,
+   p-id, p-type, (int)sizeof(p-name), p-name,
+   p-minimum, p-maximum,
+   p-step, p-default_value, p-flags,
+   p-elem_size, p-elems, p-nr_of_dims,
+   p-dims[0], p-dims[1], p-dims[2], p-dims[3],
+   p-dims[4], p-dims[5], p-dims[6], p-dims[7]);
+}
+
 static void v4l_print_querymenu(const void *arg, bool write_only)
 {
const struct v4l2_querymenu *p = arg;
@@ -1561,6 +1576,23 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops 
*ops,
return -ENOTTY;
 }
 
+static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
+   struct file *file, void *fh, void *arg)
+{
+   struct video_device *vfd = video_devdata(file);
+   struct v4l2_query_ext_ctrl *p = arg;
+   struct v4l2_fh *vfh =
+   test_bit(V4L2_FL_USES_V4L2_FH, vfd-flags) ? fh : NULL;
+
+   if (vfh  vfh-ctrl_handler)
+   return v4l2_query_ext_ctrl(vfh-ctrl_handler, p);
+   if (vfd-ctrl_handler)
+   return v4l2_query_ext_ctrl(vfd-ctrl_handler, p);
+   if (ops-vidioc_query_ext_ctrl)
+   return ops-vidioc_query_ext_ctrl(file, fh, p);
+   return -ENOTTY;
+}
+
 static int v4l_querymenu(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
@@ -2121,6 +2153,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, 
v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)),
IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, 
v4l_print_freq_band, 0),
IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, 
v4l_print_dbg_chip_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)),
+   IOCTL_INFO_FNC(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, 
v4l_print_query_ext_ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, 
id)),
 };
 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
 
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 058c1a6..b984f33 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -139,6 +139,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int 
cmd, void *arg)
case VIDIOC_QUERYCTRL:
return v4l2_queryctrl(vfh-ctrl_handler, arg);
 
+   case VIDIOC_QUERY_EXT_CTRL:
+   return v4l2_query_ext_ctrl(vfh-ctrl_handler, arg);
+
case VIDIOC_QUERYMENU:
return v4l2_querymenu(vfh-ctrl_handler, arg);
 
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 50cf7c1..53605f0 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -158,6 +158,8 @@ struct v4l2_ioctl_ops {
/* Control handling */
int (*vidioc_queryctrl)(struct file *file, void *fh,
   

[REVIEWv4 PATCH 24/34] DocBook media: document new u8 and u16 control types.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

These types are needed for the upcoming Motion Detection matrix
controls, so document them.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   | 14 +
 .../DocBook/media/v4l/vidioc-queryctrl.xml | 23 +-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index 2a157b3..c5bdbfc 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -186,6 +186,20 @@ type constantV4L2_CTRL_TYPE_STRING/constant./entry
  /row
  row
entry/entry
+   entry__u8 */entry
+   entrystructfieldp_u8/structfield/entry
+   entryA pointer to a matrix control of unsigned 8-bit values.
+Valid if this control is of type 
constantV4L2_CTRL_TYPE_U8/constant./entry
+ /row
+ row
+   entry/entry
+   entry__u16 */entry
+   entrystructfieldp_u16/structfield/entry
+   entryA pointer to a matrix control of unsigned 16-bit values.
+Valid if this control is of type 
constantV4L2_CTRL_TYPE_U16/constant./entry
+ /row
+ row
+   entry/entry
entryvoid */entry
entrystructfieldptr/structfield/entry
entryA pointer to a compound type which can be an N-dimensional 
array and/or a
diff --git a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml 
b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
index 30c4e8a..0dcb0af 100644
--- a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
@@ -289,7 +289,8 @@ accepts values 0-511 and the driver reports 0-65535, step 
should be
entryThe default value of a
 constantV4L2_CTRL_TYPE_INTEGER/constant, constant_INTEGER64/constant,
 constant_BOOLEAN/constant, constant_BITMASK/constant,
-constant_MENU/constant or constant_INTEGER_MENU/constant control.
+constant_MENU/constant, constant_INTEGER_MENU/constant,
+constant_U8/constant or constant_U16/constant control.
 Not valid for other types of controls.
 Note that drivers reset controls to their default value only when the
 driver is first loaded, never afterwards.
@@ -510,6 +511,26 @@ ioctl returns the name of the control class and this 
control type.
 Older drivers which do not support this feature return an
 EINVAL;./entry
  /row
+ row
+   entryconstantV4L2_CTRL_TYPE_U8/constant/entry
+   entryany/entry
+   entryany/entry
+   entryany/entry
+   entryAn unsigned 8-bit valued control ranging from minimum to
+maximum inclusive. The step value indicates the increment between
+values which are actually different on the hardware. This type is only used
+in array controls./entry
+ /row
+ row
+   entryconstantV4L2_CTRL_TYPE_U16/constant/entry
+   entryany/entry
+   entryany/entry
+   entryany/entry
+   entryAn unsigned 16-bit valued control ranging from minimum to
+maximum inclusive. The step value indicates the increment between
+values which are actually different on the hardware. This type is only used
+in array controls./entry
+ /row
/tbody
   /tgroup
 /table
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 14/34] v4l2-ctrls: add array support.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Finish the userspace-facing array support.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 109 ---
 1 file changed, 63 insertions(+), 46 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index f6ac927..b3ab8a9 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1202,6 +1202,8 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 
idx,
ptr.p_s32[idx] = ctrl-default_value;
break;
default:
+   idx *= ctrl-elem_size;
+   memset(ptr.p + idx, 0, ctrl-elem_size);
break;
}
 }
@@ -1324,7 +1326,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
u32 len;
 
if (ctrl-is_ptr  !ctrl-is_string)
-   return copy_to_user(c-ptr, ptr.p, ctrl-elem_size);
+   return copy_to_user(c-ptr, ptr.p, c-size);
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
@@ -1368,8 +1370,16 @@ static int user_to_ptr(struct v4l2_ext_control *c,
u32 size;
 
ctrl-is_new = 1;
-   if (ctrl-is_ptr  !ctrl-is_string)
-   return copy_from_user(ptr.p, c-ptr, ctrl-elem_size);
+   if (ctrl-is_ptr  !ctrl-is_string) {
+   unsigned idx;
+
+   ret = copy_from_user(ptr.p, c-ptr, c-size);
+   if (ret || !ctrl-is_array)
+   return ret;
+   for (idx = c-size / ctrl-elem_size; idx  ctrl-elems; idx++)
+   ctrl-type_ops-init(ctrl, idx, ptr);
+   return 0;
+   }
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER64:
@@ -1412,21 +1422,7 @@ static void ptr_to_ptr(struct v4l2_ctrl *ctrl,
 {
if (ctrl == NULL)
return;
-   switch (ctrl-type) {
-   case V4L2_CTRL_TYPE_STRING:
-   /* strings are always 0-terminated */
-   strcpy(to.p_char, from.p_char);
-   break;
-   case V4L2_CTRL_TYPE_INTEGER64:
-   *to.p_s64 = *from.p_s64;
-   break;
-   default:
-   if (ctrl-is_ptr)
-   memcpy(to.p, from.p, ctrl-elem_size);
-   else
-   *to.p_s32 = *from.p_s32;
-   break;
-   }
+   memcpy(to.p, from.p, ctrl-elems * ctrl-elem_size);
 }
 
 /* Copy the new value to the current value. */
@@ -1478,15 +1474,19 @@ static void cur_to_new(struct v4l2_ctrl *ctrl)
 static int cluster_changed(struct v4l2_ctrl *master)
 {
bool changed = false;
+   unsigned idx;
int i;
 
for (i = 0; i  master-ncontrols; i++) {
struct v4l2_ctrl *ctrl = master-cluster[i];
+   bool ctrl_changed = false;
 
if (ctrl == NULL)
continue;
-   ctrl-has_changed = !ctrl-type_ops-equal(ctrl, 0,
+   for (idx = 0; !ctrl_changed  idx  ctrl-elems; idx++)
+   ctrl_changed = !ctrl-type_ops-equal(ctrl, idx,
ctrl-p_cur, ctrl-p_new);
+   ctrl-has_changed = ctrl_changed;
changed |= ctrl-has_changed;
}
return changed;
@@ -1533,26 +1533,32 @@ static int validate_new(const struct v4l2_ctrl *ctrl,
struct v4l2_ext_control *c)
 {
union v4l2_ctrl_ptr ptr;
-
-   switch (ctrl-type) {
-   case V4L2_CTRL_TYPE_INTEGER:
-   case V4L2_CTRL_TYPE_INTEGER_MENU:
-   case V4L2_CTRL_TYPE_MENU:
-   case V4L2_CTRL_TYPE_BITMASK:
-   case V4L2_CTRL_TYPE_BOOLEAN:
-   case V4L2_CTRL_TYPE_BUTTON:
-   case V4L2_CTRL_TYPE_CTRL_CLASS:
-   ptr.p_s32 = c-value;
-   return ctrl-type_ops-validate(ctrl, 0, ptr);
-
-   case V4L2_CTRL_TYPE_INTEGER64:
-   ptr.p_s64 = c-value64;
-   return ctrl-type_ops-validate(ctrl, 0, ptr);
-
-   default:
-   ptr.p = c-ptr;
-   return ctrl-type_ops-validate(ctrl, 0, ptr);
+   unsigned idx;
+   int err = 0;
+
+   if (!ctrl-is_ptr) {
+   switch (ctrl-type) {
+   case V4L2_CTRL_TYPE_INTEGER:
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
+   case V4L2_CTRL_TYPE_MENU:
+   case V4L2_CTRL_TYPE_BITMASK:
+   case V4L2_CTRL_TYPE_BOOLEAN:
+   case V4L2_CTRL_TYPE_BUTTON:
+   case V4L2_CTRL_TYPE_CTRL_CLASS:
+   ptr.p_s32 = c-value;
+   return ctrl-type_ops-validate(ctrl, 0, ptr);
+
+   case V4L2_CTRL_TYPE_INTEGER64:
+   ptr.p_s64 = c-value64;
+   return ctrl-type_ops-validate(ctrl, 0, ptr);
+   default:
+   break;
+   }
}
+   ptr.p = c-ptr;
+   for (idx = 0; 

[REVIEWv4 PATCH 10/34] v4l2-ctrls: use ptrs for all but the s32 type.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Rather than having two unions for all types just keep 'val' and
'cur.val' and use the p_cur and p_new unions to access all others.

The only reason for keeping 'val' and 'cur.val' is that it is used
all over, so converting this as well would be a huge job.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-controls.txt|  2 +-
 drivers/media/i2c/mt9v032.c|  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  4 ++--
 drivers/media/pci/ivtv/ivtv-controls.c |  4 ++--
 drivers/media/platform/vivi.c  |  4 ++--
 drivers/media/radio/si4713/si4713.c|  4 ++--
 drivers/media/v4l2-core/v4l2-ctrls.c   | 16 +---
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c |  2 +-
 include/media/v4l2-ctrls.h | 12 ++--
 9 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index 06cf3ac..c9ee9a7 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -362,7 +362,7 @@ will result in a deadlock since these helpers lock the 
handler as well.
 You can also take the handler lock yourself:
 
mutex_lock(state-ctrl_handler.lock);
-   printk(KERN_INFO String value is '%s'\n, ctrl1-cur.string);
+   pr_info(String value is '%s'\n, ctrl1-p_cur.p_char);
printk(KERN_INFO Integer value is '%s'\n, ctrl2-cur.val);
mutex_unlock(state-ctrl_handler.lock);
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 65e6e1a..435e9e6 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -667,7 +667,7 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
break;
 
freq = mt9v032-pdata-link_freqs[mt9v032-link_freq-val];
-   mt9v032-pixel_rate-val64 = freq;
+   *mt9v032-pixel_rate-p_new.p_s64 = freq;
mt9v032-sysclk = freq;
break;
 
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 0e82756..83d506e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -297,8 +297,8 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
if (rval  0)
return rval;
 
-   sensor-pixel_rate_parray-cur.val64 = pll-vt_pix_clk_freq_hz;
-   sensor-pixel_rate_csi-cur.val64 = pll-pixel_rate_csi;
+   *sensor-pixel_rate_parray-p_cur.p_s64 = pll-vt_pix_clk_freq_hz;
+   *sensor-pixel_rate_csi-p_cur.p_s64 = pll-pixel_rate_csi;
 
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index c604246..2b0ab26 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -135,8 +135,8 @@ static int ivtv_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
/* V4L2_CID_MPEG_VIDEO_DEC_PTS and V4L2_CID_MPEG_VIDEO_DEC_FRAME
   control cluster */
case V4L2_CID_MPEG_VIDEO_DEC_PTS:
-   return ivtv_g_pts_frame(itv, itv-ctrl_pts-val64,
-itv-ctrl_frame-val64);
+   return ivtv_g_pts_frame(itv, itv-ctrl_pts-p_new.p_s64,
+itv-ctrl_frame-p_new.p_s64);
}
return 0;
 }
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 2fa05e1..69e65e6 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -648,13 +648,13 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct 
vivi_buffer *buf)
gen_text(dev, vbuf, line++ * 16, 16, str);
snprintf(str, sizeof(str),  int32 %d, int64 %lld, bitmask %08x ,
dev-int32-cur.val,
-   dev-int64-cur.val64,
+   *dev-int64-p_cur.p_s64,
dev-bitmask-cur.val);
gen_text(dev, vbuf, line++ * 16, 16, str);
snprintf(str, sizeof(str),  boolean %d, menu %s, string \%s\ ,
dev-boolean-cur.val,
dev-menu-qmenu[dev-menu-cur.val],
-   dev-string-cur.string);
+   dev-string-p_cur.p_char);
gen_text(dev, vbuf, line++ * 16, 16, str);
snprintf(str, sizeof(str),  integer_menu %lld, value %d ,
dev-int_menu-qmenu_int[dev-int_menu-cur.val],
diff --git a/drivers/media/radio/si4713/si4713.c 
b/drivers/media/radio/si4713/si4713.c
index 07d5153..dbe4726 100644
--- a/drivers/media/radio/si4713/si4713.c
+++ b/drivers/media/radio/si4713/si4713.c
@@ -1098,11 +1098,11 @@ static int si4713_s_ctrl(struct v4l2_ctrl *ctrl)
 
switch (ctrl-id) {
case V4L2_CID_RDS_TX_PS_NAME:
- 

[REVIEWv4 PATCH 11/34] v4l2-ctrls: prepare for array support

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add dims, nr_of_dims and elems fields to the core control structures in 
preparation
for N-dimensional array support.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 33 -
 include/media/v4l2-ctrls.h   |  8 
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 4b10571..e6c98a7 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1759,18 +1759,27 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_type_ops *type_ops,
u32 id, const char *name, enum v4l2_ctrl_type type,
s64 min, s64 max, u64 step, s64 def,
-   u32 elem_size,
+   const u32 dims[V4L2_CTRL_MAX_DIMS], u32 elem_size,
u32 flags, const char * const *qmenu,
const s64 *qmenu_int, void *priv)
 {
struct v4l2_ctrl *ctrl;
unsigned sz_extra;
+   unsigned nr_of_dims = 0;
+   unsigned elems = 1;
void *data;
int err;
 
if (hdl-error)
return NULL;
 
+   while (dims  dims[nr_of_dims]) {
+   elems *= dims[nr_of_dims];
+   nr_of_dims++;
+   if (nr_of_dims == V4L2_CTRL_MAX_DIMS)
+   break;
+   }
+
if (type == V4L2_CTRL_TYPE_INTEGER64)
elem_size = sizeof(s64);
else if (type == V4L2_CTRL_TYPE_STRING)
@@ -1828,6 +1837,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
ctrl-is_string = type == V4L2_CTRL_TYPE_STRING;
ctrl-is_ptr = type = V4L2_CTRL_COMPOUND_TYPES || ctrl-is_string;
ctrl-is_int = !ctrl-is_ptr  type != V4L2_CTRL_TYPE_INTEGER64;
+   ctrl-elems = elems;
+   ctrl-nr_of_dims = nr_of_dims;
+   if (nr_of_dims)
+   memcpy(ctrl-dims, dims, nr_of_dims * sizeof(dims[0]));
ctrl-elem_size = elem_size;
if (type == V4L2_CTRL_TYPE_MENU)
ctrl-qmenu = qmenu;
@@ -1892,8 +1905,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct 
v4l2_ctrl_handler *hdl,
 
ctrl = v4l2_ctrl_new(hdl, cfg-ops, cfg-type_ops, cfg-id, name,
type, min, max,
-   is_menu ? cfg-menu_skip_mask : step,
-   def, cfg-elem_size,
+   is_menu ? cfg-menu_skip_mask : step, def,
+   cfg-dims, cfg-elem_size,
flags, qmenu, qmenu_int, priv);
if (ctrl)
ctrl-is_private = cfg-is_private;
@@ -1918,7 +1931,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct 
v4l2_ctrl_handler *hdl,
return NULL;
}
return v4l2_ctrl_new(hdl, ops, NULL, id, name, type,
-min, max, step, def, 0,
+min, max, step, def, NULL, 0,
 flags, NULL, NULL, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std);
@@ -1951,7 +1964,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct 
v4l2_ctrl_handler *hdl,
return NULL;
}
return v4l2_ctrl_new(hdl, ops, NULL, id, name, type,
-0, max, mask, def, 0,
+0, max, mask, def, NULL, 0,
 flags, qmenu, qmenu_int, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
@@ -1983,8 +1996,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct 
v4l2_ctrl_handler *hdl,
return NULL;
}
return v4l2_ctrl_new(hdl, ops, NULL, id, name, type,
-0, max, mask, def,
-0, flags, qmenu, NULL, NULL);
+0, max, mask, def, NULL, 0,
+flags, qmenu, NULL, NULL);
 
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items);
@@ -2008,7 +2021,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct 
v4l2_ctrl_handler *hdl,
return NULL;
}
return v4l2_ctrl_new(hdl, ops, NULL, id, name, type,
-0, max, 0, def, 0,
+0, max, 0, def, NULL, 0,
 flags, NULL, qmenu_int, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_int_menu);
@@ -2354,7 +2367,9 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, 
struct v4l2_query_ext_ctr
if (ctrl-is_ptr)
qc-flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
qc-elem_size = ctrl-elem_size;
-   qc-elems = 1;
+   qc-elems = ctrl-elems;
+   qc-nr_of_dims = ctrl-nr_of_dims;
+   memcpy(qc-dims, ctrl-dims, qc-nr_of_dims * sizeof(qc-dims[0]));
qc-minimum = ctrl-minimum;
qc-maximum = ctrl-maximum;
qc-default_value = ctrl-default_value;

[REVIEWv4 PATCH 02/34] v4l2-ctrls: use pr_info/cont instead of printk.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Codingstyle fix.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index e132fa2..365884b 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2068,45 +2068,45 @@ static void log_ctrl(const struct v4l2_ctrl *ctrl,
if (ctrl-type == V4L2_CTRL_TYPE_CTRL_CLASS)
return;
 
-   printk(KERN_INFO %s%s%s: , prefix, colon, ctrl-name);
+   pr_info(%s%s%s: , prefix, colon, ctrl-name);
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER:
-   printk(KERN_CONT %d, ctrl-cur.val);
+   pr_cont(%d, ctrl-cur.val);
break;
case V4L2_CTRL_TYPE_BOOLEAN:
-   printk(KERN_CONT %s, ctrl-cur.val ? true : false);
+   pr_cont(%s, ctrl-cur.val ? true : false);
break;
case V4L2_CTRL_TYPE_MENU:
-   printk(KERN_CONT %s, ctrl-qmenu[ctrl-cur.val]);
+   pr_cont(%s, ctrl-qmenu[ctrl-cur.val]);
break;
case V4L2_CTRL_TYPE_INTEGER_MENU:
-   printk(KERN_CONT %lld, ctrl-qmenu_int[ctrl-cur.val]);
+   pr_cont(%lld, ctrl-qmenu_int[ctrl-cur.val]);
break;
case V4L2_CTRL_TYPE_BITMASK:
-   printk(KERN_CONT 0x%08x, ctrl-cur.val);
+   pr_cont(0x%08x, ctrl-cur.val);
break;
case V4L2_CTRL_TYPE_INTEGER64:
-   printk(KERN_CONT %lld, ctrl-cur.val64);
+   pr_cont(%lld, ctrl-cur.val64);
break;
case V4L2_CTRL_TYPE_STRING:
-   printk(KERN_CONT %s, ctrl-cur.string);
+   pr_cont(%s, ctrl-cur.string);
break;
default:
-   printk(KERN_CONT unknown type %d, ctrl-type);
+   pr_cont(unknown type %d, ctrl-type);
break;
}
if (ctrl-flags  (V4L2_CTRL_FLAG_INACTIVE |
   V4L2_CTRL_FLAG_GRABBED |
   V4L2_CTRL_FLAG_VOLATILE)) {
if (ctrl-flags  V4L2_CTRL_FLAG_INACTIVE)
-   printk(KERN_CONT  inactive);
+   pr_cont( inactive);
if (ctrl-flags  V4L2_CTRL_FLAG_GRABBED)
-   printk(KERN_CONT  grabbed);
+   pr_cont( grabbed);
if (ctrl-flags  V4L2_CTRL_FLAG_VOLATILE)
-   printk(KERN_CONT  volatile);
+   pr_cont( volatile);
}
-   printk(KERN_CONT \n);
+   pr_cont(\n);
 }
 
 /* Log all controls owned by the handler */
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 00/34] Add support for compound controls, use in solo/go7007

2014-06-12 Thread Hans Verkuil
This patch series adds support for compound controls and up to 8-dimensional
arrays to the control framework and uses it in the solo6x10 and go7007
drivers for the motion detection implementation.

This patch series supersedes 
http://www.spinics.net/lists/linux-media/msg73118.html.

It incorporates all of Mauro's comments of the v3 patch series with two
exceptions:

- The v4l2_ctrl_new() prototype still has too many arguments. I do want
  to clean this up, but when I tried it I quickly discovered that that
  would cause quite a bit of code churn so I much rather do that after
  this patch series is merged.

- The number of maximum dimensions for multi-dimensional arrays is set at
  8. I'm not allowing for more than 8 dimensions as was suggested. Based on
  the feedback Sakari gave me and my own feelings on this topic I did not
  want to replace the dims[V4L2_CTRL_MAX_DIMS] array with a dims pointer.
  If changing to a u32 *dims is the only way to get this in, then I will
  do so but I am not ready to give up on this. We're dealing with video
  hardware, not with 11-dimensional string theory.

I have added support for getting/setting multidimensional arrays to
v4l2-ctl here:

http://git.linuxtv.org/cgit.cgi/hverkuil/v4l-utils.git/log/?h=compound

I've also tested this with the solo and go7007 driver.

This patch series is available in the propapi-part4 branch of my git
repo: git://linuxtv.org/hverkuil/media_tree.git.

Regards,

Hans

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


[REVIEWv4 PATCH 04/34] videodev2.h: add struct v4l2_query_ext_ctrl and VIDIOC_QUERY_EXT_CTRL.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add a new struct and ioctl to extend the amount of information you can
get for a control.

The range is now a s64 type, and array dimensions and element size can be
reported through nr_of_dims/dims/elems/elem_size.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 include/uapi/linux/videodev2.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 438c4a6..7d94adc 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1269,6 +1269,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_ID_MASK(0x0fff)
 #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
 #define V4L2_CTRL_DRIVER_PRIV(id) (((id)  0x) = 0x1000)
+#define V4L2_CTRL_MAX_DIMS   (8)
 
 enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_INTEGER   = 1,
@@ -1298,6 +1299,23 @@ struct v4l2_queryctrl {
__u32reserved[2];
 };
 
+/*  Used in the VIDIOC_QUERY_EXT_CTRL ioctl for querying extended controls */
+struct v4l2_query_ext_ctrl {
+   __u32id;
+   __u32type;
+   char name[32];
+   __s64minimum;
+   __s64maximum;
+   __u64step;
+   __s64default_value;
+   __u32flags;
+   __u32elem_size;
+   __u32elems;
+   __u32nr_of_dims;
+   __u32dims[V4L2_CTRL_MAX_DIMS];
+   __u32reserved[16];
+};
+
 /*  Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
 struct v4l2_querymenu {
__u32   id;
@@ -2011,6 +2029,8 @@ struct v4l2_create_buffers {
Never use these in applications! */
 #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
 
+#define VIDIOC_QUERY_EXT_CTRL  _IOWR('V', 103, struct v4l2_query_ext_ctrl)
+
 /* Reminder: when adding new ioctls please add support for them to
drivers/media/video/v4l2-compat-ioctl32.c as well! */
 
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 22/34] v4l2-controls.txt: update to the new way of accessing controls.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The way current and new values are accessed has changed. Update the
document to bring it up to date with the code.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/video4linux/v4l2-controls.txt | 61 ++---
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index c9ee9a7..0f84ce8 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -77,9 +77,9 @@ Basic usage for V4L2 and sub-device drivers
 
   Where foo-v4l2_dev is of type struct v4l2_device.
 
-  Finally, remove all control functions from your v4l2_ioctl_ops:
-  vidioc_queryctrl, vidioc_querymenu, vidioc_g_ctrl, vidioc_s_ctrl,
-  vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
+  Finally, remove all control functions from your v4l2_ioctl_ops (if any):
+  vidioc_queryctrl, vidioc_query_ext_ctrl, vidioc_querymenu, vidioc_g_ctrl,
+  vidioc_s_ctrl, vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and 
vidioc_s_ext_ctrls.
   Those are now no longer needed.
 
 1.3.2) For sub-device drivers do this:
@@ -258,8 +258,8 @@ The new control value has already been validated, so all 
you need to do is
 to actually update the hardware registers.
 
 You're done! And this is sufficient for most of the drivers we have. No need
-to do any validation of control values, or implement QUERYCTRL/QUERYMENU. And
-G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically supported.
+to do any validation of control values, or implement QUERYCTRL, QUERY_EXT_CTRL
+and QUERYMENU. And G/S_CTRL as well as G/TRY/S_EXT_CTRLS are automatically 
supported.
 
 
 ==
@@ -288,30 +288,45 @@ of v4l2_device.
 Accessing Control Values
 
 
-The v4l2_ctrl struct contains these two unions:
+The following union is used inside the control framework to access control
+values:
 
-   /* The current control value. */
-   union {
+union v4l2_ctrl_ptr {
+   s32 *p_s32;
+   s64 *p_s64;
+   char *p_char;
+   void *p;
+};
+
+The v4l2_ctrl struct contains these fields that can be used to access both
+current and new values:
+
+   s32 val;
+   struct {
s32 val;
-   s64 val64;
-   char *string;
} cur;
 
-   /* The new control value. */
-   union {
-   s32 val;
-   s64 val64;
-   char *string;
-   };
 
-Within the control ops you can freely use these. The val and val64 speak for
-themselves. The string pointers point to character buffers of length
+   union v4l2_ctrl_ptr p_new;
+   union v4l2_ctrl_ptr p_cur;
+
+If the control has a simple s32 type type, then:
+
+   ctrl-val == ctrl-p_new.p_s32
+   ctrl-cur.val == ctrl-p_cur.p_s32
+
+For all other types use ctrl-p_cur.psomething. Basically the val
+and cur.val fields can be considered an alias since these are used so often.
+
+Within the control ops you can freely use these. The val and cur.val speak for
+themselves. The p_char pointers point to character buffers of length
 ctrl-maximum + 1, and are always 0-terminated.
 
-In most cases 'cur' contains the current cached control value. When you create
-a new control this value is made identical to the default value. After calling
-v4l2_ctrl_handler_setup() this value is passed to the hardware. It is generally
-a good idea to call this function.
+Unless the control is marked volatile the p_cur field points to the the
+current cached control value. When you create a new control this value is made
+identical to the default value. After calling v4l2_ctrl_handler_setup() this
+value is passed to the hardware. It is generally a good idea to call this
+function.
 
 Whenever a new value is set that new value is automatically cached. This means
 that most drivers do not need to implement the g_volatile_ctrl() op. The
@@ -363,7 +378,7 @@ You can also take the handler lock yourself:
 
mutex_lock(state-ctrl_handler.lock);
pr_info(String value is '%s'\n, ctrl1-p_cur.p_char);
-   printk(KERN_INFO Integer value is '%s'\n, ctrl2-cur.val);
+   pr_info(Integer value is '%s'\n, ctrl2-cur.val);
mutex_unlock(state-ctrl_handler.lock);
 
 
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 19/34] DocBook media: fix coding style in the control example code

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Use the proper kernel coding style in these examples.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/controls.xml | 81 ++--
 1 file changed, 40 insertions(+), 41 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 47198ee..00cf0a7 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -441,61 +441,60 @@ more menu type controls./para
 v4l2-queryctrl; queryctrl;
 v4l2-querymenu; querymenu;
 
-static void
-enumerate_menu (void)
+static void enumerate_menu(void)
 {
-   printf (  Menu items:\n);
+   printf(  Menu items:\n);
 
-   memset (amp;querymenu, 0, sizeof (querymenu));
+   memset(amp;querymenu, 0, sizeof(querymenu));
querymenu.id = queryctrl.id;
 
for (querymenu.index = queryctrl.minimum;
 querymenu.index lt;= queryctrl.maximum;
- querymenu.index++) {
-   if (0 == ioctl (fd, VIDIOC-QUERYMENU;, amp;querymenu)) {
-   printf (  %s\n, querymenu.name);
+querymenu.index++) {
+   if (0 == ioctl(fd, VIDIOC-QUERYMENU;, amp;querymenu)) {
+   printf(  %s\n, querymenu.name);
}
}
 }
 
-memset (amp;queryctrl, 0, sizeof (queryctrl));
+memset(amp;queryctrl, 0, sizeof(queryctrl));
 
 for (queryctrl.id = V4L2_CID_BASE;
  queryctrl.id lt; V4L2_CID_LASTP1;
  queryctrl.id++) {
-   if (0 == ioctl (fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
+   if (0 == ioctl(fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
if (queryctrl.flags amp; V4L2_CTRL_FLAG_DISABLED)
continue;
 
-   printf (Control %s\n, queryctrl.name);
+   printf(Control %s\n, queryctrl.name);
 
if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
-   enumerate_menu ();
+   enumerate_menu();
} else {
if (errno == EINVAL)
continue;
 
-   perror (VIDIOC_QUERYCTRL);
-   exit (EXIT_FAILURE);
+   perror(VIDIOC_QUERYCTRL);
+   exit(EXIT_FAILURE);
}
 }
 
 for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;
  queryctrl.id++) {
-   if (0 == ioctl (fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
+   if (0 == ioctl(fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
if (queryctrl.flags amp; V4L2_CTRL_FLAG_DISABLED)
continue;
 
-   printf (Control %s\n, queryctrl.name);
+   printf(Control %s\n, queryctrl.name);
 
if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
-   enumerate_menu ();
+   enumerate_menu();
} else {
if (errno == EINVAL)
break;
 
-   perror (VIDIOC_QUERYCTRL);
-   exit (EXIT_FAILURE);
+   perror(VIDIOC_QUERYCTRL);
+   exit(EXIT_FAILURE);
}
 }
 /programlisting
@@ -508,53 +507,53 @@ for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;
 v4l2-queryctrl; queryctrl;
 v4l2-control; control;
 
-memset (amp;queryctrl, 0, sizeof (queryctrl));
+memset(amp;queryctrl, 0, sizeof(queryctrl));
 queryctrl.id = V4L2_CID_BRIGHTNESS;
 
-if (-1 == ioctl (fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
+if (-1 == ioctl(fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
if (errno != EINVAL) {
-   perror (VIDIOC_QUERYCTRL);
-   exit (EXIT_FAILURE);
+   perror(VIDIOC_QUERYCTRL);
+   exit(EXIT_FAILURE);
} else {
-   printf (V4L2_CID_BRIGHTNESS is not supported\n);
+   printf(V4L2_CID_BRIGHTNESS is not supported\n);
}
 } else if (queryctrl.flags amp; V4L2_CTRL_FLAG_DISABLED) {
-   printf (V4L2_CID_BRIGHTNESS is not supported\n);
+   printf(V4L2_CID_BRIGHTNESS is not supported\n);
 } else {
-   memset (amp;control, 0, sizeof (control));
+   memset(amp;control, 0, sizeof (control));
control.id = V4L2_CID_BRIGHTNESS;
control.value = queryctrl.default_value;
 
-   if (-1 == ioctl (fd, VIDIOC-S-CTRL;, amp;control)) {
-   perror (VIDIOC_S_CTRL);
-   exit (EXIT_FAILURE);
+   if (-1 == ioctl(fd, VIDIOC-S-CTRL;, amp;control)) {
+   perror(VIDIOC_S_CTRL);
+   exit(EXIT_FAILURE);
}
 }
 
-memset (amp;control, 0, sizeof (control));
+memset(amp;control, 0, sizeof(control));
 control.id = V4L2_CID_CONTRAST;
 
-if (0 == ioctl (fd, VIDIOC-G-CTRL;, amp;control)) {
+if (0 == ioctl(fd, VIDIOC-G-CTRL;, amp;control)) {
control.value += 1;
 
/* The driver may clamp the value or return ERANGE, ignored here */
 
-   if (-1 == ioctl (fd, VIDIOC-S-CTRL;, amp;control)
+   if (-1 == ioctl(fd, VIDIOC-S-CTRL;, amp;control)
  

[REVIEWv4 PATCH 18/34] DocBook media: update VIDIOC_G/S/TRY_EXT_CTRLS.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Document the support for the new compound type controls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   | 37 +-
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index e9f6735..2a157b3 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -72,23 +72,30 @@ initialize the structfieldid/structfield,
 structfieldsize/structfield and structfieldreserved2/structfield fields
 of each v4l2-ext-control; and call the
 constantVIDIOC_G_EXT_CTRLS/constant ioctl. String controls controls
-must also set the structfieldstring/structfield field./para
+must also set the structfieldstring/structfield field. Controls
+of compound types (constantV4L2_CTRL_FLAG_HAS_PAYLOAD/constant is set)
+must set the structfieldptr/structfield field./para
 
 paraIf the structfieldsize/structfield is too small to
 receive the control result (only relevant for pointer-type controls
 like strings), then the driver will set structfieldsize/structfield
 to a valid value and return an ENOSPC;. You should re-allocate the
-string memory to this new size and try again. It is possible that the
-same issue occurs again if the string has grown in the meantime. It is
+memory to this new size and try again. For the string type it is possible that
+the same issue occurs again if the string has grown in the meantime. It is
 recommended to call VIDIOC-QUERYCTRL; first and use
 structfieldmaximum/structfield+1 as the new structfieldsize/structfield
 value. It is guaranteed that that is sufficient memory.
 /para
 
+paraN-dimensional arrays are set and retrieved row-by-row. You cannot 
set a partial
+array, all elements have to be set or retrieved. The total size is calculated
+as structfieldelems/structfield * structfieldelem_size/structfield.
+These values can be obtained by calling VIDIOC-QUERY-EXT-CTRL;./para
+
 paraTo change the value of a set of controls applications
 initialize the structfieldid/structfield, structfieldsize/structfield,
 structfieldreserved2/structfield and
-structfieldvalue/string/structfield fields of each v4l2-ext-control; and
+structfieldvalue/value64/string/ptr/structfield fields of each 
v4l2-ext-control; and
 call the constantVIDIOC_S_EXT_CTRLS/constant ioctl. The controls
 will only be set if emphasisall/emphasis control values are
 valid./para
@@ -96,7 +103,7 @@ valid./para
 paraTo check if a set of controls have correct values applications
 initialize the structfieldid/structfield, structfieldsize/structfield,
 structfieldreserved2/structfield and
-structfieldvalue/string/structfield fields of each v4l2-ext-control; and
+structfieldvalue/value64/string/ptr/structfield fields of each 
v4l2-ext-control; and
 call the constantVIDIOC_TRY_EXT_CTRLS/constant ioctl. It is up to
 the driver whether wrong values are automatically adjusted to a valid
 value or if an error is returned./para
@@ -158,19 +165,33 @@ applications must set the array to zero./entry
entry/entry
entry__s32/entry
entrystructfieldvalue/structfield/entry
-   entryNew value or current value./entry
+   entryNew value or current value. Valid if this control is not of
+type constantV4L2_CTRL_TYPE_INTEGER64/constant and
+constantV4L2_CTRL_FLAG_HAS_PAYLOAD/constant is not set./entry
  /row
  row
entry/entry
entry__s64/entry
entrystructfieldvalue64/structfield/entry
-   entryNew value or current value./entry
+   entryNew value or current value. Valid if this control is of
+type constantV4L2_CTRL_TYPE_INTEGER64/constant and
+constantV4L2_CTRL_FLAG_HAS_PAYLOAD/constant is not set./entry
  /row
  row
entry/entry
entrychar */entry
entrystructfieldstring/structfield/entry
-   entryA pointer to a string./entry
+   entryA pointer to a string. Valid if this control is of
+type constantV4L2_CTRL_TYPE_STRING/constant./entry
+ /row
+ row
+   entry/entry
+   entryvoid */entry
+   entrystructfieldptr/structfield/entry
+   entryA pointer to a compound type which can be an N-dimensional 
array and/or a
+compound type (the control's type is = 
constantV4L2_CTRL_COMPOUND_TYPES/constant).
+Valid if constantV4L2_CTRL_FLAG_HAS_PAYLOAD/constant is set for this 
control.
+/entry
  /row
/tbody
   /tgroup
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 15/34] v4l2-ctrls: return elem_size instead of strlen

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

When getting a string and the size given by the application is too
short return the max length the string can have (elem_size) instead
of the string length + 1. That makes more sense.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index b3ab8a9..e6e33b3 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1332,7 +1332,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
case V4L2_CTRL_TYPE_STRING:
len = strlen(ptr.p_char);
if (c-size  len + 1) {
-   c-size = len + 1;
+   c-size = ctrl-elem_size;
return -ENOSPC;
}
return copy_to_user(c-string, ptr.p_char, len + 1) ?
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 30/34] solo6x10: implement the new motion detection controls.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Replace the custom ioctls to set motion detection thresholds by standard
matrix controls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10-disp.c |   4 +-
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c | 103 +++--
 drivers/staging/media/solo6x10/solo6x10.h  |  19 +---
 3 files changed, 39 insertions(+), 87 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10-disp.c 
b/drivers/staging/media/solo6x10/solo6x10-disp.c
index 145295a..44d98b8 100644
--- a/drivers/staging/media/solo6x10/solo6x10-disp.c
+++ b/drivers/staging/media/solo6x10/solo6x10-disp.c
@@ -211,7 +211,7 @@ int solo_set_motion_threshold(struct solo_dev *solo_dev, u8 
ch, u16 val)
 }
 
 int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
-   const struct solo_motion_thresholds *thresholds)
+   const u16 *thresholds)
 {
u32 off = SOLO_MOT_FLAG_AREA + ch * SOLO_MOT_THRESH_SIZE * 2;
u16 buf[64];
@@ -221,7 +221,7 @@ int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
memset(buf, 0, sizeof(buf));
for (y = 0; y  SOLO_MOTION_SZ; y++) {
for (x = 0; x  SOLO_MOTION_SZ; x++)
-   buf[x] = cpu_to_le16(thresholds-thresholds[y][x]);
+   buf[x] = cpu_to_le16(thresholds[y * SOLO_MOTION_SZ + 
x]);
ret |= solo_p2m_dma(solo_dev, 1, buf,
SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * sizeof(buf),
sizeof(buf), 0, 0);
diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c 
b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index 09ce30b..67b40a4 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -1068,31 +1068,6 @@ static int solo_s_parm(struct file *file, void *priv,
return solo_g_parm(file, priv, sp);
 }
 
-static long solo_enc_default(struct file *file, void *fh,
-   bool valid_prio, unsigned int cmd, void *arg)
-{
-   struct solo_enc_dev *solo_enc = video_drvdata(file);
-   struct solo_dev *solo_dev = solo_enc-solo_dev;
-   struct solo_motion_thresholds *thresholds = arg;
-
-   switch (cmd) {
-   case SOLO_IOC_G_MOTION_THRESHOLDS:
-   *thresholds = solo_enc-motion_thresholds;
-   return 0;
-
-   case SOLO_IOC_S_MOTION_THRESHOLDS:
-   if (!valid_prio)
-   return -EBUSY;
-   solo_enc-motion_thresholds = *thresholds;
-   if (solo_enc-motion_enabled  !solo_enc-motion_global)
-   return solo_set_motion_block(solo_dev, solo_enc-ch,
-   solo_enc-motion_thresholds);
-   return 0;
-   default:
-   return -ENOTTY;
-   }
-}
-
 static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
 {
struct solo_enc_dev *solo_enc =
@@ -,25 +1086,30 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
solo_enc-gop = ctrl-val;
return 0;
-   case V4L2_CID_MOTION_THRESHOLD:
-   solo_enc-motion_thresh = ctrl-val;
+   case V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD:
+   solo_enc-motion_thresh = ctrl-val  8;
if (!solo_enc-motion_global || !solo_enc-motion_enabled)
return 0;
return solo_set_motion_threshold(solo_dev, solo_enc-ch,
-   ctrl-val);
-   case V4L2_CID_MOTION_MODE:
-   solo_enc-motion_global = ctrl-val == 1;
-   solo_enc-motion_enabled = ctrl-val  0;
+   solo_enc-motion_thresh);
+   case V4L2_CID_DETECT_MD_MODE:
+   solo_enc-motion_global = ctrl-val == 
V4L2_DETECT_MD_MODE_GLOBAL;
+   solo_enc-motion_enabled = ctrl-val  
V4L2_DETECT_MD_MODE_DISABLED;
if (ctrl-val) {
if (solo_enc-motion_global)
-   solo_set_motion_threshold(solo_dev,
-   solo_enc-ch, solo_enc-motion_thresh);
+   solo_set_motion_threshold(solo_dev, 
solo_enc-ch,
+   solo_enc-motion_thresh);
else
solo_set_motion_block(solo_dev, solo_enc-ch,
-   solo_enc-motion_thresholds);
+   solo_enc-md_thresholds-p_cur.p_u16);
}
solo_motion_toggle(solo_enc, ctrl-val);
return 0;
+   case V4L2_CID_DETECT_MD_THRESHOLD_GRID:
+   if (solo_enc-motion_enabled  !solo_enc-motion_global)
+   return solo_set_motion_block(solo_dev, solo_enc-ch,
+   

[REVIEWv4 PATCH 09/34] v4l2-ctrls: compare values only once.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

When setting a control the control's new value is compared to the current
value twice: once by new_to_cur(), once by cluster_changed(). Not a big
deal when dealing with simple values, but it can be a problem when dealing
with compound types or arrays. So fix this: cluster_changed() sets the
has_changed flag, which is used by new_to_cur() instead of having to do
another compare.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 17 +++--
 include/media/v4l2-ctrls.h   |  3 +++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index e7e0bea..1b4d37c 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1424,8 +1424,11 @@ static void new_to_cur(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl, u32 ch_flags)
 
if (ctrl == NULL)
return;
-   changed = !ctrl-type_ops-equal(ctrl, ctrl-p_cur, ctrl-p_new);
-   ptr_to_ptr(ctrl, ctrl-p_new, ctrl-p_cur);
+
+   /* has_changed is set by cluster_changed */
+   changed = ctrl-has_changed;
+   if (changed)
+   ptr_to_ptr(ctrl, ctrl-p_new, ctrl-p_cur);
 
if (ch_flags  V4L2_EVENT_CTRL_CH_FLAGS) {
/* Note: CH_FLAGS is only set for auto clusters. */
@@ -1462,17 +1465,19 @@ static void cur_to_new(struct v4l2_ctrl *ctrl)
value that differs from the current value. */
 static int cluster_changed(struct v4l2_ctrl *master)
 {
-   int diff = 0;
+   bool changed = false;
int i;
 
-   for (i = 0; !diff  i  master-ncontrols; i++) {
+   for (i = 0; i  master-ncontrols; i++) {
struct v4l2_ctrl *ctrl = master-cluster[i];
 
if (ctrl == NULL)
continue;
-   diff = !ctrl-type_ops-equal(ctrl, ctrl-p_cur, ctrl-p_new);
+   ctrl-has_changed = !ctrl-type_ops-equal(ctrl,
+   ctrl-p_cur, ctrl-p_new);
+   changed |= ctrl-has_changed;
}
-   return diff;
+   return changed;
 }
 
 /* Control range checking */
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index ddd9fdf..a38bd55 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -96,6 +96,8 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, 
void *priv);
   * @is_new:   Set when the user specified a new value for this control. It
   *is also set when called from v4l2_ctrl_handler_setup. Drivers
   *should never set this flag.
+  * @has_changed: Set when the current value differs from the new value. 
Drivers
+  *should never use this flag.
   * @is_private: If set, then this control is private to its handler and it
   *will not be added to any other handlers. Drivers can set
   *this flag.
@@ -158,6 +160,7 @@ struct v4l2_ctrl {
unsigned int done:1;
 
unsigned int is_new:1;
+   unsigned int has_changed:1;
unsigned int is_private:1;
unsigned int is_auto:1;
unsigned int is_int:1;
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 21/34] DocBook media: update control section.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Document the support for compound types in controls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 73bae13..e7b8b72 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -660,16 +660,29 @@ supported./para
 v4l2-control;, except for the fact that it also allows for 64-bit
 values and pointers to be passed./para
 
+  paraSince the v4l2-ext-control; supports pointers it is now
+also possible to have controls with compound types such as N-dimensional arrays
+and/or structures. You need to specify the 
constantV4L2_CTRL_FLAG_NEXT_COMPOUND/constant
+when enumerating controls to actually be able to see such compound controls.
+In other words, these controls with compound types should only be used
+programmatically./para
+
+  paraSince such compound controls need to expose more information
+about themselves than is possible with VIDIOC-QUERYCTRL; the
+VIDIOC-QUERY-EXT-CTRL; ioctl was added. In particular, this ioctl gives
+the dimensions of the N-dimensional array if this control consists of more than
+one element./para
+
   paraIt is important to realize that due to the flexibility of
 controls it is necessary to check whether the control you want to set
 actually is supported in the driver and what the valid range of values
-is. So use the VIDIOC-QUERYCTRL; and VIDIOC-QUERYMENU; ioctls to
-check this. Also note that it is possible that some of the menu
-indices in a control of type constantV4L2_CTRL_TYPE_MENU/constant
-may not be supported (constantVIDIOC_QUERYMENU/constant will
-return an error). A good example is the list of supported MPEG audio
-bitrates. Some drivers only support one or two bitrates, others
-support a wider range./para
+is. So use the VIDIOC-QUERYCTRL; (or VIDIOC-QUERY-EXT-CTRL;) and
+VIDIOC-QUERYMENU; ioctls to check this. Also note that it is possible
+that some of the menu indices in a control of type
+constantV4L2_CTRL_TYPE_MENU/constant may not be supported
+(constantVIDIOC_QUERYMENU/constant will return an error). A good
+example is the list of supported MPEG audio bitrates. Some drivers only
+support one or two bitrates, others support a wider range./para
 
   para
All controls use machine endianness.
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 13/34] v4l2-ctrls: type_ops can handle array elements.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Extend the control type operations to handle N-dimensional array elements.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 40 
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 6ed2d56..f6ac927 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1169,14 +1169,16 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 
idx,
case V4L2_CTRL_TYPE_BUTTON:
return false;
case V4L2_CTRL_TYPE_STRING:
+   idx *= ctrl-elem_size;
/* strings are always 0-terminated */
-   return !strcmp(ptr1.p_char, ptr2.p_char);
+   return !strcmp(ptr1.p_char + idx, ptr2.p_char + idx);
case V4L2_CTRL_TYPE_INTEGER64:
-   return *ptr1.p_s64 == *ptr2.p_s64;
+   return ptr1.p_s64[idx] == ptr2.p_s64[idx];
default:
-   if (ctrl-is_ptr)
-   return !memcmp(ptr1.p, ptr2.p, ctrl-elem_size);
-   return *ptr1.p_s32 == *ptr2.p_s32;
+   if (ctrl-is_int)
+   return ptr1.p_s32[idx] == ptr2.p_s32[idx];
+   idx *= ctrl-elem_size;
+   return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl-elem_size);
}
 }
 
@@ -1185,18 +1187,19 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 
idx,
 {
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
-   memset(ptr.p_char, ' ', ctrl-minimum);
-   ptr.p_char[ctrl-minimum] = '\0';
+   idx *= ctrl-elem_size;
+   memset(ptr.p_char + idx, ' ', ctrl-minimum);
+   ptr.p_char[idx + ctrl-minimum] = '\0';
break;
case V4L2_CTRL_TYPE_INTEGER64:
-   *ptr.p_s64 = ctrl-default_value;
+   ptr.p_s64[idx] = ctrl-default_value;
break;
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_INTEGER_MENU:
case V4L2_CTRL_TYPE_MENU:
case V4L2_CTRL_TYPE_BITMASK:
case V4L2_CTRL_TYPE_BOOLEAN:
-   *ptr.p_s32 = ctrl-default_value;
+   ptr.p_s32[idx] = ctrl-default_value;
break;
default:
break;
@@ -1264,36 +1267,37 @@ static int std_validate(const struct v4l2_ctrl *ctrl, 
u32 idx,
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER:
-   return ROUND_TO_RANGE(*ptr.p_s32, u32, ctrl);
+   return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl);
case V4L2_CTRL_TYPE_INTEGER64:
-   return ROUND_TO_RANGE(*ptr.p_s64, u64, ctrl);
+   return ROUND_TO_RANGE(ptr.p_s64[idx], u64, ctrl);
 
case V4L2_CTRL_TYPE_BOOLEAN:
-   *ptr.p_s32 = !!*ptr.p_s32;
+   ptr.p_s32[idx] = !!ptr.p_s32[idx];
return 0;
 
case V4L2_CTRL_TYPE_MENU:
case V4L2_CTRL_TYPE_INTEGER_MENU:
-   if (*ptr.p_s32  ctrl-minimum || *ptr.p_s32  ctrl-maximum)
+   if (ptr.p_s32[idx]  ctrl-minimum || ptr.p_s32[idx]  
ctrl-maximum)
return -ERANGE;
-   if (ctrl-menu_skip_mask  (1  *ptr.p_s32))
+   if (ctrl-menu_skip_mask  (1  ptr.p_s32[idx]))
return -EINVAL;
if (ctrl-type == V4L2_CTRL_TYPE_MENU 
-   ctrl-qmenu[*ptr.p_s32][0] == '\0')
+   ctrl-qmenu[ptr.p_s32[idx]][0] == '\0')
return -EINVAL;
return 0;
 
case V4L2_CTRL_TYPE_BITMASK:
-   *ptr.p_s32 = ctrl-maximum;
+   ptr.p_s32[idx] = ctrl-maximum;
return 0;
 
case V4L2_CTRL_TYPE_BUTTON:
case V4L2_CTRL_TYPE_CTRL_CLASS:
-   *ptr.p_s32 = 0;
+   ptr.p_s32[idx] = 0;
return 0;
 
case V4L2_CTRL_TYPE_STRING:
-   len = strlen(ptr.p_char);
+   idx *= ctrl-elem_size;
+   len = strlen(ptr.p_char + idx);
if (len  ctrl-minimum)
return -ERANGE;
if ((len - ctrl-minimum) % ctrl-step)
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 27/34] DocBook media: document new motion detection controls.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Document the 'Detect' control class and the new Motion Detection controls.
Those controls will be used by the solo6x10 and go7007 drivers.

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

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index e7b8b72..cc0087e 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -5055,6 +5055,102 @@ defines possible values for de-emphasis. Here they 
are:/entry
 /tbody
   /tgroup
   /table
+/section
+
+section id=detect-controls
+  titleDetect Control Reference/title
+
+  paraThe Detect class includes controls for common features of
+  various motion or object detection capable devices./para
+
+  table pgwide=1 frame=none id=detect-control-id
+  titleDetect Control IDs/title
+
+  tgroup cols=4
+colspec colname=c1 colwidth=1* /
+colspec colname=c2 colwidth=6* /
+colspec colname=c3 colwidth=2* /
+colspec colname=c4 colwidth=6* /
+spanspec namest=c1 nameend=c2 spanname=id /
+spanspec namest=c2 nameend=c4 spanname=descr /
+thead
+  row
+entry spanname=id align=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_DETECT_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe Detect class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_DETECT_MD_MODE/constantnbsp;/entry
+entrymenu/entry
+  /rowrowentry spanname=descrSets the motion detection 
mode./entry
+  /row
+ row
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ entryconstantV4L2_DETECT_MD_MODE_DISABLED/constant
+ /entryentryDisable motion detection./entry
+   /row
+   row
+ entryconstantV4L2_DETECT_MD_MODE_GLOBAL/constant
+ /entryentryUse a single motion detection 
threshold./entry
+   /row
+   row
+ entryconstantV4L2_DETECT_MD_MODE_THRESHOLD_GRID/constant
+ /entryentryThe image is divided into a grid, each cell 
with its own
+ motion detection threshold. These thresholds are set through 
the
+ constantV4L2_CID_DETECT_MD_THRESHOLD_GRID/constant matrix 
control./entry
+   /row
+   row
+ entryconstantV4L2_DETECT_MD_MODE_REGION_GRID/constant
+ /entryentryThe image is divided into a grid, each cell 
with its own
+ region value that specifies which per-region motion detection 
thresholds
+ should be used. Each region has its own thresholds. How these 
per-region
+ thresholds are set up is driver-specific. The region values 
for the grid are set
+ through the 
constantV4L2_CID_DETECT_MD_REGION_GRID/constant matrix
+ control./entry
+   /row
+ /tbody
+   /entrytbl
+ /row
+  row
+   entry 
spanname=idconstantV4L2_CID_DETECT_MD_GLOBAL_THRESHOLD/constantnbsp;/entry
+   entryinteger/entry
+ /row
+ rowentry spanname=descrSets the global motion detection 
threshold to be
+ used with the constantV4L2_DETECT_MD_MODE_GLOBAL/constant motion 
detection mode./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_DETECT_MD_THRESHOLD_GRID/constantnbsp;/entry
+   entry__u16 matrix/entry
+ /row
+ rowentry spanname=descrSets the motion detection thresholds for 
each cell in the grid.
+ To be used with the 
constantV4L2_DETECT_MD_MODE_THRESHOLD_GRID/constant
+ motion detection mode. Matrix element (0, 0) represents the cell at 
the top-left of the
+ grid./entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_DETECT_MD_REGION_GRID/constantnbsp;/entry
+   entry__u8 matrix/entry
+ /row
+ rowentry spanname=descrSets the motion detection region value 
for each cell in the grid.
+ To be used with the 
constantV4L2_DETECT_MD_MODE_REGION_GRID/constant
+ motion detection mode. Matrix element (0, 0) represents the cell at 
the top-left of the
+ grid./entry
+  /row
+/tbody
+  /tgroup
+  /table
 
   

[REVIEWv4 PATCH 01/34] v4l2-ctrls: increase internal min/max/step/def to 64 bit

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

While VIDIOC_QUERYCTRL is limited to 32 bit min/max/step/def values
for controls, the upcoming VIDIOC_QUERY_EXT_CTRL isn't. So increase
the internal representation to 64 bits in preparation.

Because of these changes the msi3101 driver has been modified slightly
to fix a formatting issue (%d becomes %lld), vivi had to be modified
as well to cope with the new 64-bit min/max values and the PIXEL_RATE
control in a few sensor drivers required proper min/max/def values.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/i2c/mt9v032.c  |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c   |  4 +-
 drivers/media/platform/vivi.c|  5 +-
 drivers/media/v4l2-core/v4l2-common.c|  6 +-
 drivers/media/v4l2-core/v4l2-ctrls.c | 93 +++-
 drivers/staging/media/msi3101/msi001.c   |  2 +-
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c |  4 +-
 include/media/v4l2-ctrls.h   | 42 +--
 8 files changed, 93 insertions(+), 65 deletions(-)

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 40172b8..65e6e1a 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -931,7 +931,7 @@ static int mt9v032_probe(struct i2c_client *client,
 
mt9v032-pixel_rate =
v4l2_ctrl_new_std(mt9v032-ctrls, mt9v032_ctrl_ops,
- V4L2_CID_PIXEL_RATE, 0, 0, 1, 0);
+ V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1);
 
if (pdata  pdata-link_freqs) {
unsigned int def = 0;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 06fb032..0e82756 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -533,7 +533,7 @@ static int smiapp_init_controls(struct smiapp_sensor 
*sensor)
 
sensor-pixel_rate_parray = v4l2_ctrl_new_std(
sensor-pixel_array-ctrl_handler, smiapp_ctrl_ops,
-   V4L2_CID_PIXEL_RATE, 0, 0, 1, 0);
+   V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1);
 
if (sensor-pixel_array-ctrl_handler.error) {
dev_err(client-dev,
@@ -562,7 +562,7 @@ static int smiapp_init_controls(struct smiapp_sensor 
*sensor)
 
sensor-pixel_rate_csi = v4l2_ctrl_new_std(
sensor-src-ctrl_handler, smiapp_ctrl_ops,
-   V4L2_CID_PIXEL_RATE, 0, 0, 1, 0);
+   V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1);
 
if (sensor-src-ctrl_handler.error) {
dev_err(client-dev,
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index d00bf3d..2fa05e1 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -1236,7 +1236,7 @@ static const struct v4l2_ctrl_config vivi_ctrl_int32 = {
.id = VIVI_CID_CUSTOM_BASE + 2,
.name = Integer 32 Bits,
.type = V4L2_CTRL_TYPE_INTEGER,
-   .min = 0x8000,
+   .min = -0x8000LL,
.max = 0x7fff,
.step = 1,
 };
@@ -1246,6 +1246,9 @@ static const struct v4l2_ctrl_config vivi_ctrl_int64 = {
.id = VIVI_CID_CUSTOM_BASE + 3,
.name = Integer 64 Bits,
.type = V4L2_CTRL_TYPE_INTEGER64,
+   .min = LLONG_MIN,
+   .max = LLONG_MAX,
+   .step = 1,
 };
 
 static const char * const vivi_ctrl_menu_strings[] = {
diff --git a/drivers/media/v4l2-core/v4l2-common.c 
b/drivers/media/v4l2-core/v4l2-common.c
index 433d6d7..ccaa38f 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -111,9 +111,13 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct 
v4l2_queryctrl *qctrl,
 EXPORT_SYMBOL(v4l2_ctrl_check);
 
 /* Fill in a struct v4l2_queryctrl */
-int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 
step, s32 def)
+int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 
_step, s32 _def)
 {
const char *name;
+   s64 min = _min;
+   s64 max = _max;
+   u64 step = _step;
+   s64 def = _def;
 
v4l2_ctrl_fill(qctrl-id, name, qctrl-type,
   min, max, step, def, qctrl-flags);
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 55c6832..e132fa2 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -877,7 +877,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 EXPORT_SYMBOL(v4l2_ctrl_get_name);
 
 void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
-   s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags)
+   s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags)
 {
*name = v4l2_ctrl_get_name(id);
*flags = 0;
@@ -1041,14 +1041,23 @@ void v4l2_ctrl_fill(u32 id, const 

[REVIEWv4 PATCH 17/34] DocBook media: document VIDIOC_QUERY_EXT_CTRL.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Document the new VIDIOC_QUERY_EXT_CTRL ioctl.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 .../DocBook/media/v4l/vidioc-queryctrl.xml | 211 +
 1 file changed, 175 insertions(+), 36 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml 
b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
index e6645b9..30c4e8a 100644
--- a/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-queryctrl.xml
@@ -1,11 +1,12 @@
 refentry id=vidioc-queryctrl
   refmeta
-refentrytitleioctl VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU/refentrytitle
+refentrytitleioctl VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL, 
VIDIOC_QUERYMENU/refentrytitle
 manvol;
   /refmeta
 
   refnamediv
 refnameVIDIOC_QUERYCTRL/refname
+refnameVIDIOC_QUERY_EXT_CTRL/refname
 refnameVIDIOC_QUERYMENU/refname
 refpurposeEnumerate controls and menu control items/refpurpose
   /refnamediv
@@ -24,6 +25,14 @@
funcdefint functionioctl/function/funcdef
paramdefint parameterfd/parameter/paramdef
paramdefint parameterrequest/parameter/paramdef
+   paramdefstruct v4l2_query_ext_ctrl 
*parameterargp/parameter/paramdef
+  /funcprototype
+/funcsynopsis
+funcsynopsis
+  funcprototype
+   funcdefint functionioctl/function/funcdef
+   paramdefint parameterfd/parameter/paramdef
+   paramdefint parameterrequest/parameter/paramdef
paramdefstruct v4l2_querymenu *parameterargp/parameter/paramdef
   /funcprototype
 /funcsynopsis
@@ -42,7 +51,7 @@
   varlistentry
termparameterrequest/parameter/term
listitem
- paraVIDIOC_QUERYCTRL, VIDIOC_QUERYMENU/para
+ paraVIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL, VIDIOC_QUERYMENU/para
/listitem
   /varlistentry
   varlistentry
@@ -89,9 +98,23 @@ prematurely end the enumeration)./para/footnote/para
 
 paraWhen the application ORs structfieldid/structfield with
 constantV4L2_CTRL_FLAG_NEXT_CTRL/constant the driver returns the
-next supported control, or errorcodeEINVAL/errorcode if there is
-none. Drivers which do not support this flag yet always return
-errorcodeEINVAL/errorcode./para
+next supported non-compound control, or errorcodeEINVAL/errorcode
+if there is none. In addition, the 
constantV4L2_CTRL_FLAG_NEXT_COMPOUND/constant
+flag can be specified to enumerate all compound controls (i.e. controls
+with type ge; constantV4L2_CTRL_COMPOUND_TYPES/constant). Specify both
+constantV4L2_CTRL_FLAG_NEXT_CTRL/constant and
+constantV4L2_CTRL_FLAG_NEXT_COMPOUND/constant in order to enumerate
+all controls, compound or not. Drivers which do not support these flags yet
+always return errorcodeEINVAL/errorcode./para
+
+paraThe constantVIDIOC_QUERY_EXT_CTRL/constant ioctl was
+introduced in order to better support controls that can use compound
+types, and to expose additional control information that cannot be
+returned in v4l2-queryctrl; since that structure is full./para
+
+paraconstantVIDIOC_QUERY_EXT_CTRL/constant is used in the
+same way as constantVIDIOC_QUERYCTRL/constant, except that the
+structfieldreserved/structfield array must be zeroed as well./para
 
 paraAdditional information is required for menu controls: the
 names of the menu items. To query them applications set the
@@ -142,38 +165,23 @@ string. This information is intended for the user./entry
entry__s32/entry
entrystructfieldminimum/structfield/entry
entryMinimum value, inclusive. This field gives a lower
-bound for constantV4L2_CTRL_TYPE_INTEGER/constant controls and the
-lowest valid index for constantV4L2_CTRL_TYPE_MENU/constant controls.
-For constantV4L2_CTRL_TYPE_STRING/constant controls the minimum value
-gives the minimum length of the string. This length emphasisdoes not include 
the terminating
-zero/emphasis. It may not be valid for any other type of control, including
-constantV4L2_CTRL_TYPE_INTEGER64/constant controls. Note that this is a
-signed value./entry
+bound for the control. See v4l2-ctrl-type; how the minimum value is to
+be used for each possible control type. Note that this a signed 32-bit 
value./entry
  /row
  row
entry__s32/entry
entrystructfieldmaximum/structfield/entry
entryMaximum value, inclusive. This field gives an upper
-bound for constantV4L2_CTRL_TYPE_INTEGER/constant controls and the
-highest valid index for constantV4L2_CTRL_TYPE_MENU/constant
-controls. For constantV4L2_CTRL_TYPE_BITMASK/constant controls it is the
-set of usable bits.
-For constantV4L2_CTRL_TYPE_STRING/constant controls the maximum value
-gives the maximum length of the string. This length emphasisdoes not include 
the terminating
-zero/emphasis. It may not be valid for any other type of control, including
-constantV4L2_CTRL_TYPE_INTEGER64/constant controls. Note that this is a

[REVIEWv4 PATCH 07/34] v4l2-ctrls: create type_ops.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Since compound controls can have non-standard types we need to be able to do
type-specific checks etc. In order to make that easy type operations are added.
There are four operations:

- equal: check if two values are equal
- init: initialize a value
- log: log the value
- validate: validate a new value

The v4l2_ctrl struct adds p_new and p_cur unions at the end of the struct.
This union provides a standard way of accessing control types through a pointer,
which greatly simplifies internal control processing.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 273 ++-
 include/media/v4l2-ctrls.h   |  37 +
 2 files changed, 210 insertions(+), 100 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index d5cd1aa..09e2c3a 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1161,6 +1161,149 @@ static void send_event(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl, u32 changes)
v4l2_event_queue_fh(sev-fh, ev);
 }
 
+static bool std_equal(const struct v4l2_ctrl *ctrl,
+ union v4l2_ctrl_ptr ptr1,
+ union v4l2_ctrl_ptr ptr2)
+{
+   switch (ctrl-type) {
+   case V4L2_CTRL_TYPE_BUTTON:
+   return false;
+   case V4L2_CTRL_TYPE_STRING:
+   /* strings are always 0-terminated */
+   return !strcmp(ptr1.p_char, ptr2.p_char);
+   case V4L2_CTRL_TYPE_INTEGER64:
+   return *ptr1.p_s64 == *ptr2.p_s64;
+   default:
+   if (ctrl-is_ptr)
+   return !memcmp(ptr1.p, ptr2.p, ctrl-elem_size);
+   return *ptr1.p_s32 == *ptr2.p_s32;
+   }
+}
+
+static void std_init(const struct v4l2_ctrl *ctrl,
+union v4l2_ctrl_ptr ptr)
+{
+   switch (ctrl-type) {
+   case V4L2_CTRL_TYPE_STRING:
+   memset(ptr.p_char, ' ', ctrl-minimum);
+   ptr.p_char[ctrl-minimum] = '\0';
+   break;
+   case V4L2_CTRL_TYPE_INTEGER64:
+   *ptr.p_s64 = ctrl-default_value;
+   break;
+   case V4L2_CTRL_TYPE_INTEGER:
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
+   case V4L2_CTRL_TYPE_MENU:
+   case V4L2_CTRL_TYPE_BITMASK:
+   case V4L2_CTRL_TYPE_BOOLEAN:
+   *ptr.p_s32 = ctrl-default_value;
+   break;
+   default:
+   break;
+   }
+}
+
+static void std_log(const struct v4l2_ctrl *ctrl)
+{
+   union v4l2_ctrl_ptr ptr = ctrl-p_cur;
+
+   switch (ctrl-type) {
+   case V4L2_CTRL_TYPE_INTEGER:
+   pr_cont(%d, *ptr.p_s32);
+   break;
+   case V4L2_CTRL_TYPE_BOOLEAN:
+   pr_cont(%s, *ptr.p_s32 ? true : false);
+   break;
+   case V4L2_CTRL_TYPE_MENU:
+   pr_cont(%s, ctrl-qmenu[*ptr.p_s32]);
+   break;
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
+   pr_cont(%lld, ctrl-qmenu_int[*ptr.p_s32]);
+   break;
+   case V4L2_CTRL_TYPE_BITMASK:
+   pr_cont(0x%08x, *ptr.p_s32);
+   break;
+   case V4L2_CTRL_TYPE_INTEGER64:
+   pr_cont(%lld, *ptr.p_s64);
+   break;
+   case V4L2_CTRL_TYPE_STRING:
+   pr_cont(%s, ptr.p_char);
+   break;
+   default:
+   pr_cont(unknown type %d, ctrl-type);
+   break;
+   }
+}
+
+/* Round towards the closest legal value */
+#define ROUND_TO_RANGE(val, offset_type, ctrl) \
+({ \
+   offset_type offset; \
+   val += (ctrl)-step / 2;\
+   val = clamp_t(typeof(val), val, \
+ (ctrl)-minimum, (ctrl)-maximum);\
+   offset = (val) - (ctrl)-minimum;   \
+   offset = (ctrl)-step * (offset / (ctrl)-step);\
+   val = (ctrl)-minimum + offset; \
+   0;  \
+})
+
+/* Validate a new control */
+static int std_validate(const struct v4l2_ctrl *ctrl,
+   union v4l2_ctrl_ptr ptr)
+{
+   size_t len;
+
+   switch (ctrl-type) {
+   case V4L2_CTRL_TYPE_INTEGER:
+   return ROUND_TO_RANGE(*ptr.p_s32, u32, ctrl);
+   case V4L2_CTRL_TYPE_INTEGER64:
+   return ROUND_TO_RANGE(*ptr.p_s64, u64, ctrl);
+
+   case V4L2_CTRL_TYPE_BOOLEAN:
+   *ptr.p_s32 = !!*ptr.p_s32;
+   return 0;
+
+   case V4L2_CTRL_TYPE_MENU:
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
+   if (*ptr.p_s32  ctrl-minimum || *ptr.p_s32  ctrl-maximum)
+   return -ERANGE;
+   if (ctrl-menu_skip_mask  

[REVIEWv4 PATCH 26/34] v4l2-ctrls/v4l2-controls.h: add MD controls

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add the 'Detect' control class and the new motion detection controls.
Those controls will be used by the solo6x10 and go7007 drivers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 27 +++
 include/uapi/linux/v4l2-controls.h   | 17 +
 2 files changed, 44 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 5aaf15e..5c3b8de 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -462,6 +462,13 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
RGB full range (0-255),
NULL,
};
+   static const char * const detect_md_mode[] = {
+   Disabled,
+   Global,
+   Threshold Grid,
+   Region Grid,
+   NULL,
+   };
 
 
switch (id) {
@@ -553,6 +560,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_DV_TX_RGB_RANGE:
case V4L2_CID_DV_RX_RGB_RANGE:
return dv_rgb_range;
+   case V4L2_CID_DETECT_MD_MODE:
+   return detect_md_mode;
 
default:
return NULL;
@@ -874,6 +883,15 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:  return Bandwidth, Auto;
case V4L2_CID_RF_TUNER_BANDWIDTH:   return Bandwidth;
case V4L2_CID_RF_TUNER_PLL_LOCK:return PLL Lock;
+
+   /* Detection controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
+   case V4L2_CID_DETECT_CLASS: return Detection Controls;
+   case V4L2_CID_DETECT_MD_MODE:   return Motion Detection Mode;
+   case V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD: return MD Global Threshold;
+   case V4L2_CID_DETECT_MD_THRESHOLD_GRID: return MD Threshold Grid;
+   case V4L2_CID_DETECT_MD_REGION_GRID:return MD Region Grid;
+
default:
return NULL;
}
@@ -992,6 +1010,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_TEST_PATTERN:
case V4L2_CID_TUNE_DEEMPHASIS:
case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
+   case V4L2_CID_DETECT_MD_MODE:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_LINK_FREQ:
@@ -1018,6 +1037,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_DV_CLASS:
case V4L2_CID_FM_RX_CLASS:
case V4L2_CID_RF_TUNER_CLASS:
+   case V4L2_CID_DETECT_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -1063,6 +1083,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
*type = V4L2_CTRL_TYPE_INTEGER64;
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
break;
+   case V4L2_CID_DETECT_MD_REGION_GRID:
+   *type = V4L2_CTRL_TYPE_U8;
+   break;
+   case V4L2_CID_DETECT_MD_THRESHOLD_GRID:
+   *type = V4L2_CTRL_TYPE_U16;
+   break;
default:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
@@ -1103,6 +1129,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_RF_TUNER_MIXER_GAIN:
case V4L2_CID_RF_TUNER_IF_GAIN:
case V4L2_CID_RF_TUNER_BANDWIDTH:
+   case V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD:
*flags |= V4L2_CTRL_FLAG_SLIDER;
break;
case V4L2_CID_PAN_RELATIVE:
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 2ac5597..db526d1 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -61,6 +61,7 @@
 #define V4L2_CTRL_CLASS_DV 0x00a0  /* Digital Video 
controls */
 #define V4L2_CTRL_CLASS_FM_RX  0x00a1  /* FM Receiver controls 
*/
 #define V4L2_CTRL_CLASS_RF_TUNER   0x00a2  /* RF tuner controls */
+#define V4L2_CTRL_CLASS_DETECT 0x00a3  /* Detection controls */
 
 /* User-class control IDs */
 
@@ -914,4 +915,20 @@ enum v4l2_deemphasis {
 #define V4L2_CID_RF_TUNER_IF_GAIN  (V4L2_CID_RF_TUNER_CLASS_BASE + 
62)
 #define V4L2_CID_RF_TUNER_PLL_LOCK 
(V4L2_CID_RF_TUNER_CLASS_BASE + 91)
 
+
+/*  Detection-class control IDs defined by V4L2 */
+#define V4L2_CID_DETECT_CLASS_BASE (V4L2_CTRL_CLASS_DETECT | 0x900)
+#define V4L2_CID_DETECT_CLASS  (V4L2_CTRL_CLASS_DETECT | 1)
+
+#define V4L2_CID_DETECT_MD_MODE
(V4L2_CID_DETECT_CLASS_BASE + 1)
+enum v4l2_detect_md_mode {
+   V4L2_DETECT_MD_MODE_DISABLED= 0,
+   

[REVIEWv4 PATCH 16/34] v4l2-ctrl: fix error return of copy_to/from_user.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

copy_to/from_user returns the number of bytes not copied, it does not
return a 'normal' linux error code.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index e6e33b3..1086ae3 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1326,7 +1326,8 @@ static int ptr_to_user(struct v4l2_ext_control *c,
u32 len;
 
if (ctrl-is_ptr  !ctrl-is_string)
-   return copy_to_user(c-ptr, ptr.p, c-size);
+   return copy_to_user(c-ptr, ptr.p, c-size) ?
+  -EFAULT : 0;
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
@@ -1336,7 +1337,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
return -ENOSPC;
}
return copy_to_user(c-string, ptr.p_char, len + 1) ?
-   -EFAULT : 0;
+  -EFAULT : 0;
case V4L2_CTRL_TYPE_INTEGER64:
c-value64 = *ptr.p_s64;
break;
@@ -1373,7 +1374,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
if (ctrl-is_ptr  !ctrl-is_string) {
unsigned idx;
 
-   ret = copy_from_user(ptr.p, c-ptr, c-size);
+   ret = copy_from_user(ptr.p, c-ptr, c-size) ? -EFAULT : 0;
if (ret || !ctrl-is_array)
return ret;
for (idx = c-size / ctrl-elem_size; idx  ctrl-elems; idx++)
@@ -1391,7 +1392,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
return -ERANGE;
if (size  ctrl-maximum + 1)
size = ctrl-maximum + 1;
-   ret = copy_from_user(ptr.p_char, c-string, size);
+   ret = copy_from_user(ptr.p_char, c-string, size) ? -EFAULT : 0;
if (!ret) {
char last = ptr.p_char[size - 1];
 
@@ -1401,7 +1402,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
if (strlen(ptr.p_char) == ctrl-maximum  last)
return -ERANGE;
}
-   return ret ? -EFAULT : 0;
+   return ret;
default:
*ptr.p_s32 = c-value;
break;
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 05/34] v4l2-ctrls: add support for compound types.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This patch implements initial support for compound types.

The changes are fairly obvious: basic support for is_ptr types, the
type_is_int function is replaced by a is_int bitfield, and
v4l2_query_ext_ctrl is added.

Note that this patch does not yet add support for N-dimensional
arrays, that comes later. So v4l2_query_ext_ctrl just sets elems to
1 and nr_of_dims and dims[] are all zero.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 224 ++-
 include/media/v4l2-ctrls.h   |  23 +++-
 2 files changed, 187 insertions(+), 60 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 365884b..d5cd1aa 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1124,20 +1124,6 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
 }
 EXPORT_SYMBOL(v4l2_ctrl_fill);
 
-/* Helper function to determine whether the control type is compatible with
-   VIDIOC_G/S_CTRL. */
-static bool type_is_int(const struct v4l2_ctrl *ctrl)
-{
-   switch (ctrl-type) {
-   case V4L2_CTRL_TYPE_INTEGER64:
-   case V4L2_CTRL_TYPE_STRING:
-   /* Nope, these need v4l2_ext_control */
-   return false;
-   default:
-   return true;
-   }
-}
-
 static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 
changes)
 {
memset(ev-reserved, 0, sizeof(ev-reserved));
@@ -1146,7 +1132,7 @@ static void fill_event(struct v4l2_event *ev, struct 
v4l2_ctrl *ctrl, u32 change
ev-u.ctrl.changes = changes;
ev-u.ctrl.type = ctrl-type;
ev-u.ctrl.flags = ctrl-flags;
-   if (ctrl-type == V4L2_CTRL_TYPE_STRING)
+   if (ctrl-is_ptr)
ev-u.ctrl.value64 = 0;
else
ev-u.ctrl.value64 = ctrl-cur.val64;
@@ -1181,6 +1167,9 @@ static int cur_to_user(struct v4l2_ext_control *c,
 {
u32 len;
 
+   if (ctrl-is_ptr  !ctrl-is_string)
+   return copy_to_user(c-ptr, ctrl-cur.p, ctrl-elem_size);
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
len = strlen(ctrl-cur.string);
@@ -1208,6 +1197,9 @@ static int user_to_new(struct v4l2_ext_control *c,
u32 size;
 
ctrl-is_new = 1;
+   if (ctrl-is_ptr  !ctrl-is_string)
+   return copy_from_user(ctrl-p, c-ptr, ctrl-elem_size);
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER64:
ctrl-val64 = c-value64;
@@ -1242,6 +1234,9 @@ static int new_to_user(struct v4l2_ext_control *c,
 {
u32 len;
 
+   if (ctrl-is_ptr  !ctrl-is_string)
+   return copy_to_user(c-ptr, ctrl-p, ctrl-elem_size);
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
len = strlen(ctrl-string);
@@ -1268,6 +1263,7 @@ static void new_to_cur(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl, u32 ch_flags)
 
if (ctrl == NULL)
return;
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_BUTTON:
changed = true;
@@ -1282,8 +1278,13 @@ static void new_to_cur(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl, u32 ch_flags)
ctrl-cur.val64 = ctrl-val64;
break;
default:
-   changed = ctrl-val != ctrl-cur.val;
-   ctrl-cur.val = ctrl-val;
+   if (ctrl-is_ptr) {
+   changed = memcmp(ctrl-p, ctrl-cur.p, ctrl-elem_size);
+   memcpy(ctrl-cur.p, ctrl-p, ctrl-elem_size);
+   } else {
+   changed = ctrl-val != ctrl-cur.val;
+   ctrl-cur.val = ctrl-val;
+   }
break;
}
if (ch_flags  V4L2_EVENT_CTRL_CH_FLAGS) {
@@ -1323,7 +1324,10 @@ static void cur_to_new(struct v4l2_ctrl *ctrl)
ctrl-val64 = ctrl-cur.val64;
break;
default:
-   ctrl-val = ctrl-cur.val;
+   if (ctrl-is_ptr)
+   memcpy(ctrl-p, ctrl-cur.p, ctrl-elem_size);
+   else
+   ctrl-val = ctrl-cur.val;
break;
}
 }
@@ -1536,7 +1540,7 @@ static struct v4l2_ctrl_ref *find_private_ref(
   VIDIOC_G/S_CTRL. */
if (V4L2_CTRL_ID2CLASS(ref-ctrl-id) == V4L2_CTRL_CLASS_USER 
V4L2_CTRL_DRIVER_PRIV(ref-ctrl-id)) {
-   if (!type_is_int(ref-ctrl))
+   if (!ref-ctrl-is_int)
continue;
if (id == 0)
return ref;
@@ -1606,8 +1610,12 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl,
u32 class_ctrl = V4L2_CTRL_ID2CLASS(id) | 1;
int bucket = id % hdl-nr_of_buckets;   /* which bucket to use */
 
-   /* Automatically add the 

[REVIEWv4 PATCH 31/34] solo6x10: implement the motion detection event.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Use the new motion detection event.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c | 68 ++
 drivers/staging/media/solo6x10/solo6x10.h  |  7 +--
 2 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c 
b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index 67b40a4..ab0b1a6 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -243,6 +243,8 @@ static int solo_enc_on(struct solo_enc_dev *solo_enc)
if (solo_enc-bw_weight  solo_dev-enc_bw_remain)
return -EBUSY;
solo_enc-sequence = 0;
+   solo_enc-motion_last_state = false;
+   solo_enc-frames_since_last_motion = 0;
solo_dev-enc_bw_remain -= solo_enc-bw_weight;
 
if (solo_enc-type == SOLO_ENC_TYPE_EXT)
@@ -544,15 +546,6 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
const vop_header *vh = enc_buf-vh;
int ret;
 
-   /* Check for motion flags */
-   vb-v4l2_buf.flags = ~(V4L2_BUF_FLAG_MOTION_ON |
-   V4L2_BUF_FLAG_MOTION_DETECTED);
-   if (solo_is_motion_on(solo_enc)) {
-   vb-v4l2_buf.flags |= V4L2_BUF_FLAG_MOTION_ON;
-   if (enc_buf-motion)
-   vb-v4l2_buf.flags |= V4L2_BUF_FLAG_MOTION_DETECTED;
-   }
-
switch (solo_enc-fmt) {
case V4L2_PIX_FMT_MPEG4:
case V4L2_PIX_FMT_H264:
@@ -564,9 +557,49 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
}
 
if (!ret) {
+   bool send_event = false;
+
vb-v4l2_buf.sequence = solo_enc-sequence++;
vb-v4l2_buf.timestamp.tv_sec = vop_sec(vh);
vb-v4l2_buf.timestamp.tv_usec = vop_usec(vh);
+
+   /* Check for motion flags */
+   if (solo_is_motion_on(solo_enc)) {
+   /* It takes a few frames for the hardware to detect
+* motion. Once it does it clears the motion detection
+* register and it takes again a few frames before
+* motion is seen. This means in practice that when the
+* motion field is 1, it will go back to 0 for the next
+* frame. This leads to motion detection event being
+* sent all the time, which is not what we want.
+* Instead wait a few frames before deciding that the
+* motion has halted. After some experimentation it
+* turns out that waiting for 5 frames works well.
+*/
+   if (enc_buf-motion == 0 
+   solo_enc-motion_last_state 
+   solo_enc-frames_since_last_motion++  5)
+   send_event = true;
+   else if (enc_buf-motion) {
+   solo_enc-frames_since_last_motion = 0;
+   send_event = !solo_enc-motion_last_state;
+   }
+   }
+
+   if (send_event) {
+   struct v4l2_event ev = {
+   .type = V4L2_EVENT_MOTION_DET,
+   .u.motion_det = {
+   .flags = 
V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ,
+   .frame_sequence = vb-v4l2_buf.sequence,
+   .region_mask = enc_buf-motion ? 1 : 0,
+   },
+   };
+
+   solo_enc-motion_last_state = enc_buf-motion;
+   solo_enc-frames_since_last_motion = 0;
+   v4l2_event_queue(solo_enc-vfd, ev);
+   }
}
 
vb2_buffer_done(vb, ret ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
@@ -1121,6 +1154,21 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
return 0;
 }
 
+static int solo_subscribe_event(struct v4l2_fh *fh,
+   const struct v4l2_event_subscription *sub)
+{
+
+   switch (sub-type) {
+   case V4L2_EVENT_CTRL:
+   return v4l2_ctrl_subscribe_event(fh, sub);
+   case V4L2_EVENT_MOTION_DET:
+   /* Allow for up to 30 events (1 second for NTSC) to be
+* stored. */
+   return v4l2_event_subscribe(fh, sub, 30, NULL);
+   }
+   return -EINVAL;
+}
+
 static const struct v4l2_file_operations solo_enc_fops = {
.owner  = THIS_MODULE,
.open   = v4l2_fh_open,
@@ -1159,7 +1207,7 @@ static const struct v4l2_ioctl_ops solo_enc_ioctl_ops = {
.vidioc_g_parm  = solo_g_parm,
/* Logging and 

[REVIEWv4 PATCH 12/34] v4l2-ctrls: prepare for array support.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add core support for N-dimensional arrays.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 58 
 include/media/v4l2-ctrls.h   |  8 +++--
 2 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index e6c98a7..6ed2d56 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1161,7 +1161,7 @@ static void send_event(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl, u32 changes)
v4l2_event_queue_fh(sev-fh, ev);
 }
 
-static bool std_equal(const struct v4l2_ctrl *ctrl,
+static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx,
  union v4l2_ctrl_ptr ptr1,
  union v4l2_ctrl_ptr ptr2)
 {
@@ -1180,7 +1180,7 @@ static bool std_equal(const struct v4l2_ctrl *ctrl,
}
 }
 
-static void std_init(const struct v4l2_ctrl *ctrl,
+static void std_init(const struct v4l2_ctrl *ctrl, u32 idx,
 union v4l2_ctrl_ptr ptr)
 {
switch (ctrl-type) {
@@ -1207,6 +1207,14 @@ static void std_log(const struct v4l2_ctrl *ctrl)
 {
union v4l2_ctrl_ptr ptr = ctrl-p_cur;
 
+   if (ctrl-is_array) {
+   unsigned i;
+
+   for (i = 0; i  ctrl-nr_of_dims; i++)
+   pr_cont([%u], ctrl-dims[i]);
+   pr_cont( );
+   }
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER:
pr_cont(%d, *ptr.p_s32);
@@ -1249,7 +1257,7 @@ static void std_log(const struct v4l2_ctrl *ctrl)
 })
 
 /* Validate a new control */
-static int std_validate(const struct v4l2_ctrl *ctrl,
+static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
union v4l2_ctrl_ptr ptr)
 {
size_t len;
@@ -1473,8 +1481,8 @@ static int cluster_changed(struct v4l2_ctrl *master)
 
if (ctrl == NULL)
continue;
-   ctrl-has_changed = !ctrl-type_ops-equal(ctrl,
-   ctrl-p_cur, ctrl-p_new);
+   ctrl-has_changed = !ctrl-type_ops-equal(ctrl, 0,
+   ctrl-p_cur, ctrl-p_new);
changed |= ctrl-has_changed;
}
return changed;
@@ -1531,15 +1539,15 @@ static int validate_new(const struct v4l2_ctrl *ctrl,
case V4L2_CTRL_TYPE_BUTTON:
case V4L2_CTRL_TYPE_CTRL_CLASS:
ptr.p_s32 = c-value;
-   return ctrl-type_ops-validate(ctrl, ptr);
+   return ctrl-type_ops-validate(ctrl, 0, ptr);
 
case V4L2_CTRL_TYPE_INTEGER64:
ptr.p_s64 = c-value64;
-   return ctrl-type_ops-validate(ctrl, ptr);
+   return ctrl-type_ops-validate(ctrl, 0, ptr);
 
default:
ptr.p = c-ptr;
-   return ctrl-type_ops-validate(ctrl, ptr);
+   return ctrl-type_ops-validate(ctrl, 0, ptr);
}
 }
 
@@ -1767,6 +1775,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
unsigned sz_extra;
unsigned nr_of_dims = 0;
unsigned elems = 1;
+   bool is_array;
+   unsigned tot_ctrl_size;
void *data;
int err;
 
@@ -1779,6 +1789,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
if (nr_of_dims == V4L2_CTRL_MAX_DIMS)
break;
}
+   is_array = nr_of_dims  0;
 
if (type == V4L2_CTRL_TYPE_INTEGER64)
elem_size = sizeof(s64);
@@ -1786,10 +1797,11 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
elem_size = max + 1;
else if (type  V4L2_CTRL_COMPOUND_TYPES)
elem_size = sizeof(s32);
+   tot_ctrl_size = elem_size * elems;
 
/* Sanity checks */
-   if (id == 0 || name == NULL || id = V4L2_CID_PRIVATE_BASE ||
-   elem_size == 0 ||
+   if (id == 0 || name == NULL || !elem_size ||
+   id = V4L2_CID_PRIVATE_BASE ||
(type == V4L2_CTRL_TYPE_MENU  qmenu == NULL) ||
(type == V4L2_CTRL_TYPE_INTEGER_MENU  qmenu_int == NULL)) {
handler_set_err(hdl, -ERANGE);
@@ -1804,6 +1816,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
handler_set_err(hdl, -ERANGE);
return NULL;
}
+   if (is_array 
+   (type == V4L2_CTRL_TYPE_BUTTON ||
+type == V4L2_CTRL_TYPE_CTRL_CLASS)) {
+   handler_set_err(hdl, -EINVAL);
+   return NULL;
+   }
 
sz_extra = 0;
if (type == V4L2_CTRL_TYPE_BUTTON)
@@ -1812,8 +1830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
flags |= V4L2_CTRL_FLAG_READ_ONLY;
else if (type == V4L2_CTRL_TYPE_INTEGER64 

[REVIEWv4 PATCH 32/34] solo6x10: fix 'dma from stack' warning.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10-disp.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10-disp.c 
b/drivers/staging/media/solo6x10/solo6x10-disp.c
index 44d98b8..b529a96 100644
--- a/drivers/staging/media/solo6x10/solo6x10-disp.c
+++ b/drivers/staging/media/solo6x10/solo6x10-disp.c
@@ -213,19 +213,21 @@ int solo_set_motion_threshold(struct solo_dev *solo_dev, 
u8 ch, u16 val)
 int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
const u16 *thresholds)
 {
+   const unsigned size = sizeof(u16) * 64;
u32 off = SOLO_MOT_FLAG_AREA + ch * SOLO_MOT_THRESH_SIZE * 2;
-   u16 buf[64];
+   u16 *buf;
int x, y;
int ret = 0;
 
-   memset(buf, 0, sizeof(buf));
+   buf = kzalloc(size, GFP_KERNEL);
for (y = 0; y  SOLO_MOTION_SZ; y++) {
for (x = 0; x  SOLO_MOTION_SZ; x++)
buf[x] = cpu_to_le16(thresholds[y * SOLO_MOTION_SZ + 
x]);
ret |= solo_p2m_dma(solo_dev, 1, buf,
-   SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * sizeof(buf),
-   sizeof(buf), 0, 0);
+   SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * size,
+   size, 0, 0);
}
+   kfree(buf);
return ret;
 }
 
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 03/34] videodev2.h: add initial support for compound controls.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Compound controls are controls that can be used for compound and array
types. This allows for more compound data structures to be used with the
control framework.

The existing V4L2_CTRL_FLAG_NEXT_CTRL flag will only enumerate non-compound
controls, so a new V4L2_CTRL_FLAG_NEXT_COMPOUND flag is added to enumerate
compound controls. Set both flags to enumerate any control (compound or not).

Compound control types will start at V4L2_CTRL_COMPOUND_TYPES. In addition, any
control that uses the new 'ptr' field or the existing 'string' field will have
flag V4L2_CTRL_FLAG_HAS_PAYLOAD set.

While not strictly necessary, adding that flag makes life for applications
a lot simpler. If the flag is not set, then the control value is set
through the value or value64 fields of struct v4l2_ext_control, otherwise
a pointer points to the value.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 include/uapi/linux/videodev2.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 168ff50..438c4a6 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1254,6 +1254,7 @@ struct v4l2_ext_control {
__s32 value;
__s64 value64;
char *string;
+   void *ptr;
};
 } __attribute__ ((packed));
 
@@ -1278,7 +1279,10 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_CTRL_CLASS= 6,
V4L2_CTRL_TYPE_STRING= 7,
V4L2_CTRL_TYPE_BITMASK   = 8,
-   V4L2_CTRL_TYPE_INTEGER_MENU = 9,
+   V4L2_CTRL_TYPE_INTEGER_MENU  = 9,
+
+   /* Compound types are = 0x0100 */
+   V4L2_CTRL_COMPOUND_TYPES = 0x0100,
 };
 
 /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@@ -1314,9 +1318,11 @@ struct v4l2_querymenu {
 #define V4L2_CTRL_FLAG_SLIDER  0x0020
 #define V4L2_CTRL_FLAG_WRITE_ONLY  0x0040
 #define V4L2_CTRL_FLAG_VOLATILE0x0080
+#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100
 
-/*  Query flag, to be ORed with the control ID */
+/*  Query flags, to be ORed with the control ID */
 #define V4L2_CTRL_FLAG_NEXT_CTRL   0x8000
+#define V4L2_CTRL_FLAG_NEXT_COMPOUND   0x4000
 
 /*  User-class control IDs defined by V4L2 */
 #define V4L2_CID_MAX_CTRLS 1024
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 29/34] DocBook: document new v4l motion detection event.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Document the new motion detection event.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml | 44 ++
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |  8 
 2 files changed, 52 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index 820f86e..f3767fb 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -94,6 +94,12 @@
  /row
  row
entry/entry
+   entryv4l2-event-motion-det;/entry
+entrystructfieldmotion_det/structfield/entry
+   entryEvent data for event V4L2_EVENT_MOTION_DET./entry
+ /row
+ row
+   entry/entry
entry__u8/entry
 entrystructfielddata/structfield[64]/entry
entryEvent data. Defined by the event type. The union
@@ -258,6 +264,44 @@
   /tgroup
 /table
 
+table frame=none pgwide=1 id=v4l2-event-motion-det
+  titlestruct structnamev4l2_event_motion_det/structname/title
+  tgroup cols=3
+   cs-str;
+   tbody valign=top
+ row
+   entry__u32/entry
+   entrystructfieldflags/structfield/entry
+   entry
+ Currently only one flag is available: if 
constantV4L2_EVENT_MD_FL_HAVE_FRAME_SEQ/constant
+ is set, then the structfieldframe_sequence/structfield field 
is valid,
+ otherwise that field should be ignored.
+   /entry
+ /row
+ row
+   entry__u32/entry
+   entrystructfieldframe_sequence/structfield/entry
+   entry
+ The sequence number of the frame being received. Only valid if the
+ constantV4L2_EVENT_MD_FL_HAVE_FRAME_SEQ/constant flag was set.
+   /entry
+ /row
+ row
+   entry__u32/entry
+   entrystructfieldregion_mask/structfield/entry
+   entry
+ The bitmask of the regions that reported motion. There is at 
least one
+ region. If this field is 0, then no motion was detected at all.
+ If there is no 
constantV4L2_CID_DETECT_MD_REGION_GRID/constant control
+ (see xref linkend=detect-controls /) to assign a different 
region
+ to each cell in the motion detection grid, then that all cells
+ are automatically assigned to the default region 0.
+   /entry
+ /row
+   /tbody
+  /tgroup
+/table
+
 table pgwide=1 frame=none id=changes-flags
   titleChanges/title
   tgroup cols=3
diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml 
b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
index 17efa87..9f60956 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
@@ -175,6 +175,14 @@
/entry
  /row
  row
+   entryconstantV4L2_EVENT_MOTION_DET/constant/entry
+   entry5/entry
+   entry
+ paraTriggered whenever the motion detection state for one or 
more of the regions
+ changes. This event has a v4l2-event-motion-det; associated with 
it./para
+   /entry
+ /row
+ row
entryconstantV4L2_EVENT_PRIVATE_START/constant/entry
entry0x0800/entry
entryBase event number for driver-private events./entry
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 33/34] solo6x10: check dma_map_sg() return value

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The dma_map_sg() function can fail, so check for the return value.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c 
b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index ab0b1a6..d9d0941 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -478,8 +478,9 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc,
vb2_set_plane_payload(vb, 0, vop_jpeg_size(vh) + solo_enc-jpeg_len);
 
/* may discard all previous data in vbuf-sgl */
-   dma_map_sg(solo_dev-pdev-dev, vbuf-sgl, vbuf-nents,
-   DMA_FROM_DEVICE);
+   if (!dma_map_sg(solo_dev-pdev-dev, vbuf-sgl, vbuf-nents,
+   DMA_FROM_DEVICE))
+   return -ENOMEM;
ret = solo_send_desc(solo_enc, solo_enc-jpeg_len, vbuf,
 vop_jpeg_offset(vh) - SOLO_JPEG_EXT_ADDR(solo_dev),
 frame_size, SOLO_JPEG_EXT_ADDR(solo_dev),
@@ -525,8 +526,9 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc,
frame_size = ALIGN(vop_mpeg_size(vh) + skip, DMA_ALIGN);
 
/* may discard all previous data in vbuf-sgl */
-   dma_map_sg(solo_dev-pdev-dev, vbuf-sgl, vbuf-nents,
-   DMA_FROM_DEVICE);
+   if (!dma_map_sg(solo_dev-pdev-dev, vbuf-sgl, vbuf-nents,
+   DMA_FROM_DEVICE))
+   return -ENOMEM;
ret = solo_send_desc(solo_enc, skip, vbuf, frame_off, frame_size,
SOLO_MP4E_EXT_ADDR(solo_dev),
SOLO_MP4E_EXT_SIZE(solo_dev));
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 20/34] DocBook media: improve control section.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Improve the control section:

- Clarify the handling of private controls
- Explain the V4L2_CTRL_FLAG_INACTIVE flag
- Remove obsolete text regarding missing control event (we have them
  today) and the incorrect V4L2_CTRL_FLAG_DISABLED reference.
- Add a code example on how to enumerate over user controls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml | 74 +---
 1 file changed, 55 insertions(+), 19 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 00cf0a7..73bae13 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -13,6 +13,19 @@ correctly with any device./para
 paraAll controls are accessed using an ID value. V4L2 defines
 several IDs for specific purposes. Drivers can also implement their
 own custom controls using constantV4L2_CID_PRIVATE_BASE/constant
+footnoteparaThe use of constantV4L2_CID_PRIVATE_BASE/constant
+is problematic because different drivers may use the same
+constantV4L2_CID_PRIVATE_BASE/constant ID for different controls.
+This makes it hard to programatically set such controls since the meaning
+of the control with that ID is driver dependent. In order to resolve this
+drivers use unique IDs and the constantV4L2_CID_PRIVATE_BASE/constant
+IDs are mapped to those unique IDs by the kernel. Consider these
+constantV4L2_CID_PRIVATE_BASE/constant IDs as aliases to the real
+IDs./para
+paraMany applications today still use the 
constantV4L2_CID_PRIVATE_BASE/constant
+IDs instead of using VIDIOC-QUERYCTRL; with the 
constantV4L2_CTRL_FLAG_NEXT_CTRL/constant
+flag to enumerate all IDs, so support for 
constantV4L2_CID_PRIVATE_BASE/constant
+is still around./para/footnote
 and higher values. The pre-defined control IDs have the prefix
 constantV4L2_CID_/constant, and are listed in xref
 linkend=control-id /. The ID is used when querying the attributes of
@@ -31,25 +44,22 @@ the current video input or output, tuner or modulator, or 
audio input
 or output. Different in the sense of other bounds, another default and
 current value, step size or other menu items. A control with a certain
 emphasiscustom/emphasis ID can also change name and
-type.footnote
-   paraIt will be more convenient for applications if drivers
-make use of the constantV4L2_CTRL_FLAG_DISABLED/constant flag, but
-that was never required./para
-  /footnote Control values are stored globally, they do not
+type./para
+
+paraIf a control is not applicable to the current configuration
+of the device (for example, it doesn't apply to the current video input)
+drivers set the constantV4L2_CTRL_FLAG_INACTIVE/constant flag./para
+
+paraControl values are stored globally, they do not
 change when switching except to stay within the reported bounds. They
 also do not change eg; when the device is opened or closed, when the
 tuner radio frequency is changed or generally never without
-application request. Since V4L2 specifies no event mechanism, panel
-applications intended to cooperate with other panel applications (be
-they built into a larger application, as a TV viewer) may need to
-regularly poll control values to update their user
-interface.footnote
-   paraApplications could call an ioctl to request events.
-After another process called VIDIOC-S-CTRL; or another ioctl changing
-shared properties the func-select; function would indicate
-readability until any ioctl (querying the properties) is
-called./para
-  /footnote/para
+application request./para
+
+paraV4L2 specifies an event mechanism to notify applications
+when controls change value (see VIDIOC-SUBSCRIBE-EVENT;, event
+constantV4L2_EVENT_CTRL/constant), panel applications might want to make
+use of that in order to always reflect the correct control value./para
 
 para
   All controls use machine endianness.
@@ -434,8 +444,8 @@ Drivers must implement 
constantVIDIOC_QUERYCTRL/constant,
 controls, constantVIDIOC_QUERYMENU/constant when it has one or
 more menu type controls./para
 
-example
-  titleEnumerating all controls/title
+example id=enum_all_controls
+  titleEnumerating all user controls/title
 
   programlisting
 v4l2-queryctrl; queryctrl;
@@ -501,6 +511,32 @@ for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;
 /example
 
 example
+  titleEnumerating all user controls (alternative)/title
+   programlisting
+memset(amp;queryctrl, 0, sizeof(queryctrl));
+
+queryctrl.id = V4L2_CTRL_CLASS_USER | V4L2_CTRL_FLAG_NEXT_CTRL;
+while (0 == ioctl(fd, VIDIOC-QUERYCTRL;, amp;queryctrl)) {
+   if (V4L2_CTRL_ID2CLASS(queryctrl.id) != V4L2_CTRL_CLASS_USER)
+   break;
+   if (queryctrl.flags amp; V4L2_CTRL_FLAG_DISABLED)
+   continue;
+
+   printf(Control %s\n, 

[REVIEWv4 PATCH 28/34] v4l2: add a motion detection event.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add a new MOTION_DET event to signal when motion is detected.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 include/uapi/linux/videodev2.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 93ae827..f7defeb 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1799,6 +1799,7 @@ struct v4l2_streamparm {
 #define V4L2_EVENT_CTRL3
 #define V4L2_EVENT_FRAME_SYNC  4
 #define V4L2_EVENT_SOURCE_CHANGE   5
+#define V4L2_EVENT_MOTION_DET  6
 #define V4L2_EVENT_PRIVATE_START   0x0800
 
 /* Payload for V4L2_EVENT_VSYNC */
@@ -1836,6 +1837,21 @@ struct v4l2_event_src_change {
__u32 changes;
 };
 
+#define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ(1  0)
+
+/**
+ * struct v4l2_event_motion_det - motion detection event
+ * @flags: if V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ is set, then the
+ * frame_sequence field is valid.
+ * @frame_sequence:the frame sequence number associated with this event.
+ * @region_mask:   which regions detected motion.
+ */
+struct v4l2_event_motion_det {
+   __u32 flags;
+   __u32 frame_sequence;
+   __u32 region_mask;
+};
+
 struct v4l2_event {
__u32   type;
union {
@@ -1843,6 +1859,7 @@ struct v4l2_event {
struct v4l2_event_ctrl  ctrl;
struct v4l2_event_frame_syncframe_sync;
struct v4l2_event_src_changesrc_change;
+   struct v4l2_event_motion_detmotion_det;
__u8data[64];
} u;
__u32   pending;
-- 
2.0.0.rc0

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


[REVIEWv4 PATCH 23/34] v4l2-ctrls/videodev2.h: add u8 and u16 types.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

These are needed by the upcoming patches for the motion detection
matrices.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 45 
 include/media/v4l2-ctrls.h   |  4 
 include/uapi/linux/videodev2.h   |  4 
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 1086ae3..adf5485 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1174,6 +1174,10 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 
idx,
return !strcmp(ptr1.p_char + idx, ptr2.p_char + idx);
case V4L2_CTRL_TYPE_INTEGER64:
return ptr1.p_s64[idx] == ptr2.p_s64[idx];
+   case V4L2_CTRL_TYPE_U8:
+   return ptr1.p_u8[idx] == ptr2.p_u8[idx];
+   case V4L2_CTRL_TYPE_U16:
+   return ptr1.p_u16[idx] == ptr2.p_u16[idx];
default:
if (ctrl-is_int)
return ptr1.p_s32[idx] == ptr2.p_s32[idx];
@@ -1201,6 +1205,12 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 
idx,
case V4L2_CTRL_TYPE_BOOLEAN:
ptr.p_s32[idx] = ctrl-default_value;
break;
+   case V4L2_CTRL_TYPE_U8:
+   ptr.p_u8[idx] = ctrl-default_value;
+   break;
+   case V4L2_CTRL_TYPE_U16:
+   ptr.p_u16[idx] = ctrl-default_value;
+   break;
default:
idx *= ctrl-elem_size;
memset(ptr.p + idx, 0, ctrl-elem_size);
@@ -1242,6 +1252,12 @@ static void std_log(const struct v4l2_ctrl *ctrl)
case V4L2_CTRL_TYPE_STRING:
pr_cont(%s, ptr.p_char);
break;
+   case V4L2_CTRL_TYPE_U8:
+   pr_cont(%u, (unsigned)*ptr.p_u8);
+   break;
+   case V4L2_CTRL_TYPE_U16:
+   pr_cont(%u, (unsigned)*ptr.p_u16);
+   break;
default:
pr_cont(unknown type %d, ctrl-type);
break;
@@ -1272,6 +1288,10 @@ static int std_validate(const struct v4l2_ctrl *ctrl, 
u32 idx,
return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl);
case V4L2_CTRL_TYPE_INTEGER64:
return ROUND_TO_RANGE(ptr.p_s64[idx], u64, ctrl);
+   case V4L2_CTRL_TYPE_U8:
+   return ROUND_TO_RANGE(ptr.p_u8[idx], u8, ctrl);
+   case V4L2_CTRL_TYPE_U16:
+   return ROUND_TO_RANGE(ptr.p_u16[idx], u16, ctrl);
 
case V4L2_CTRL_TYPE_BOOLEAN:
ptr.p_s32[idx] = !!ptr.p_s32[idx];
@@ -1502,6 +1522,8 @@ static int check_range(enum v4l2_ctrl_type type,
if (step != 1 || max  1 || min  0)
return -ERANGE;
/* fall through */
+   case V4L2_CTRL_TYPE_U8:
+   case V4L2_CTRL_TYPE_U16:
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_INTEGER64:
if (step == 0 || min  max || def  min || def  max)
@@ -1803,12 +1825,25 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
}
is_array = nr_of_dims  0;
 
-   if (type == V4L2_CTRL_TYPE_INTEGER64)
+   /* Prefill elem_size for all types handled by std_type_ops */
+   switch (type) {
+   case V4L2_CTRL_TYPE_INTEGER64:
elem_size = sizeof(s64);
-   else if (type == V4L2_CTRL_TYPE_STRING)
+   break;
+   case V4L2_CTRL_TYPE_STRING:
elem_size = max + 1;
-   else if (type  V4L2_CTRL_COMPOUND_TYPES)
-   elem_size = sizeof(s32);
+   break;
+   case V4L2_CTRL_TYPE_U8:
+   elem_size = sizeof(u8);
+   break;
+   case V4L2_CTRL_TYPE_U16:
+   elem_size = sizeof(u16);
+   break;
+   default:
+   if (type  V4L2_CTRL_COMPOUND_TYPES)
+   elem_size = sizeof(s32);
+   break;
+   }
tot_ctrl_size = elem_size * elems;
 
/* Sanity checks */
@@ -3148,6 +3183,8 @@ int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
case V4L2_CTRL_TYPE_MENU:
case V4L2_CTRL_TYPE_INTEGER_MENU:
case V4L2_CTRL_TYPE_BITMASK:
+   case V4L2_CTRL_TYPE_U8:
+   case V4L2_CTRL_TYPE_U16:
if (ctrl-is_array)
return -EINVAL;
ret = check_range(ctrl-type, min, max, step, def);
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 7915b1125..c630345 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -39,12 +39,16 @@ struct poll_table_struct;
 /** union v4l2_ctrl_ptr - A pointer to a control value.
  * @p_s32: Pointer to a 32-bit signed value.
  * @p_s64: Pointer to a 64-bit signed value.
+ * @p_u8:  Pointer to a 8-bit unsigned value.
+ * @p_u16: Pointer to a 16-bit 

[REVIEWv4 PATCH 34/34] go7007: add motion detection support.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This patch adds motion detection support to the go7007 driver using the new
motion detection controls, events.

The global motion detection works fine, but the regional motion detection
support probably needs more work. There seems to be some interaction between
regions that makes setting correct thresholds difficult. The exact meaning of
the thresholds isn't entirely clear either.

I do not have any documentation, the only information I have is the custom code
in the driver and a modet.c application.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/go7007/go7007-driver.c  | 127 ---
 drivers/staging/media/go7007/go7007-fw.c  |  28 ++-
 drivers/staging/media/go7007/go7007-priv.h|  16 ++
 drivers/staging/media/go7007/go7007-v4l2.c| 317 ++
 drivers/staging/media/go7007/go7007.h |  40 
 drivers/staging/media/go7007/saa7134-go7007.c |   1 -
 6 files changed, 345 insertions(+), 184 deletions(-)
 delete mode 100644 drivers/staging/media/go7007/go7007.h

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index 6f1beca..c200601 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -32,6 +32,7 @@
 #include linux/videodev2.h
 #include media/tuner.h
 #include media/v4l2-common.h
+#include media/v4l2-event.h
 
 #include go7007-priv.h
 
@@ -332,20 +333,33 @@ EXPORT_SYMBOL(go7007_register_encoder);
 int go7007_start_encoder(struct go7007 *go)
 {
u8 *fw;
-   int fw_len, rv = 0, i;
+   int fw_len, rv = 0, i, x, y;
u16 intr_val, intr_data;
 
go-modet_enable = 0;
-   if (!go-dvd_mode)
-   for (i = 0; i  4; ++i) {
-   if (go-modet[i].enable) {
-   go-modet_enable = 1;
-   continue;
+   for (i = 0; i  4; i++)
+   go-modet[i].enable = 0;
+
+   switch (v4l2_ctrl_g_ctrl(go-modet_mode)) {
+   case V4L2_DETECT_MD_MODE_GLOBAL:
+   memset(go-modet_map, 0, sizeof(go-modet_map));
+   go-modet[0].enable = 1;
+   go-modet_enable = 1;
+   break;
+   case V4L2_DETECT_MD_MODE_REGION_GRID:
+   for (y = 0; y  go-height / 16; y++) {
+   for (x = 0; x  go-width / 16; x++) {
+   int idx = y * go-width / 16 + x;
+
+   go-modet[go-modet_map[idx]].enable = 1;
}
-   go-modet[i].pixel_threshold = 32767;
-   go-modet[i].motion_threshold = 32767;
-   go-modet[i].mb_threshold = 32767;
}
+   go-modet_enable = 1;
+   break;
+   }
+
+   if (go-dvd_mode)
+   go-modet_enable = 0;
 
if (go7007_construct_fw_image(go, fw, fw_len)  0)
return -1;
@@ -383,44 +397,89 @@ static inline void store_byte(struct go7007_buffer *vb, 
u8 byte)
}
 }
 
+static void go7007_set_motion_regions(struct go7007 *go, struct go7007_buffer 
*vb,
+   u32 motion_regions)
+{
+   if (motion_regions != go-modet_event_status) {
+   struct v4l2_event ev = {
+   .type = V4L2_EVENT_MOTION_DET,
+   .u.motion_det = {
+   .flags = V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ,
+   .frame_sequence = vb-vb.v4l2_buf.sequence,
+   .region_mask = motion_regions,
+   },
+   };
+
+   v4l2_event_queue(go-vdev, ev);
+   go-modet_event_status = motion_regions;
+   }
+}
+
 /*
- * Deliver the last video buffer and get a new one to start writing to.
+ * Determine regions with motion and send a motion detection event
+ * in case of changes.
  */
-static struct go7007_buffer *frame_boundary(struct go7007 *go, struct 
go7007_buffer *vb)
+static void go7007_motion_regions(struct go7007 *go, struct go7007_buffer *vb)
 {
-   struct go7007_buffer *vb_tmp = NULL;
u32 *bytesused = vb-vb.v4l2_planes[0].bytesused;
+   unsigned motion[4] = { 0, 0, 0, 0 };
+   u32 motion_regions = 0;
+   unsigned stride = (go-width + 7)  3;
+   unsigned x, y;
int i;
 
-   if (vb) {
-   if (vb-modet_active) {
-   if (*bytesused + 216  GO7007_BUF_SIZE) {
-   for (i = 0; i  216; ++i)
-   store_byte(vb, go-active_map[i]);
-   *bytesused -= 216;
-   } else
-   vb-modet_active = 0;
+   for (i = 0; i  216; ++i)
+   store_byte(vb, go-active_map[i]);
+   for (y = 0; y  go-height / 16; y++) {
+   for (x = 0; x  go-width / 

[REVIEWv4 PATCH 08/34] v4l2-ctrls: rewrite copy routines to operate on union v4l2_ctrl_ptr.

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

In order to implement array support and (for the future) configuration stores
we need to have more generic copy routines that all operate on the v4l2_ctrl_ptr
union. So instead of e.g. using ctrl-cur.string it uses ptr.p_char. This makes
e.g. cur_to_user generic so it can be used to copy any v4l2_ctrl_ptr value to
userspace, not just the (hardcoded) current value.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 129 +++
 1 file changed, 56 insertions(+), 73 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 09e2c3a..e7e0bea 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1304,48 +1304,64 @@ static const struct v4l2_ctrl_type_ops std_type_ops = {
.validate = std_validate,
 };
 
-/* Helper function: copy the current control value back to the caller */
-static int cur_to_user(struct v4l2_ext_control *c,
-  struct v4l2_ctrl *ctrl)
+/* Helper function: copy the given control value back to the caller */
+static int ptr_to_user(struct v4l2_ext_control *c,
+  struct v4l2_ctrl *ctrl,
+  union v4l2_ctrl_ptr ptr)
 {
u32 len;
 
if (ctrl-is_ptr  !ctrl-is_string)
-   return copy_to_user(c-ptr, ctrl-cur.p, ctrl-elem_size);
+   return copy_to_user(c-ptr, ptr.p, ctrl-elem_size);
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_STRING:
-   len = strlen(ctrl-cur.string);
+   len = strlen(ptr.p_char);
if (c-size  len + 1) {
c-size = len + 1;
return -ENOSPC;
}
-   return copy_to_user(c-string, ctrl-cur.string,
-   len + 1) ? -EFAULT : 0;
+   return copy_to_user(c-string, ptr.p_char, len + 1) ?
+   -EFAULT : 0;
case V4L2_CTRL_TYPE_INTEGER64:
-   c-value64 = ctrl-cur.val64;
+   c-value64 = *ptr.p_s64;
break;
default:
-   c-value = ctrl-cur.val;
+   c-value = *ptr.p_s32;
break;
}
return 0;
 }
 
-/* Helper function: copy the caller-provider value as the new control value */
-static int user_to_new(struct v4l2_ext_control *c,
+/* Helper function: copy the current control value back to the caller */
+static int cur_to_user(struct v4l2_ext_control *c,
   struct v4l2_ctrl *ctrl)
 {
+   return ptr_to_user(c, ctrl, ctrl-p_cur);
+}
+
+/* Helper function: copy the new control value back to the caller */
+static int new_to_user(struct v4l2_ext_control *c,
+  struct v4l2_ctrl *ctrl)
+{
+   return ptr_to_user(c, ctrl, ctrl-p_new);
+}
+
+/* Helper function: copy the caller-provider value to the given control value 
*/
+static int user_to_ptr(struct v4l2_ext_control *c,
+  struct v4l2_ctrl *ctrl,
+  union v4l2_ctrl_ptr ptr)
+{
int ret;
u32 size;
 
ctrl-is_new = 1;
if (ctrl-is_ptr  !ctrl-is_string)
-   return copy_from_user(ctrl-p, c-ptr, ctrl-elem_size);
+   return copy_from_user(ptr.p, c-ptr, ctrl-elem_size);
 
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER64:
-   ctrl-val64 = c-value64;
+   *ptr.p_s64 = c-value64;
break;
case V4L2_CTRL_TYPE_STRING:
size = c-size;
@@ -1353,83 +1369,64 @@ static int user_to_new(struct v4l2_ext_control *c,
return -ERANGE;
if (size  ctrl-maximum + 1)
size = ctrl-maximum + 1;
-   ret = copy_from_user(ctrl-string, c-string, size);
+   ret = copy_from_user(ptr.p_char, c-string, size);
if (!ret) {
-   char last = ctrl-string[size - 1];
+   char last = ptr.p_char[size - 1];
 
-   ctrl-string[size - 1] = 0;
+   ptr.p_char[size - 1] = 0;
/* If the string was longer than ctrl-maximum,
   then return an error. */
-   if (strlen(ctrl-string) == ctrl-maximum  last)
+   if (strlen(ptr.p_char) == ctrl-maximum  last)
return -ERANGE;
}
return ret ? -EFAULT : 0;
default:
-   ctrl-val = c-value;
+   *ptr.p_s32 = c-value;
break;
}
return 0;
 }
 
-/* Helper function: copy the new control value back to the caller */
-static int new_to_user(struct v4l2_ext_control *c,
+/* Helper function: copy the caller-provider value as the new control 

[REVIEWv4 PATCH 25/34] v4l2-ctrls: fix comments

2014-06-12 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Various comments referred to videodev2.h, but the control definitions have
been moved to v4l2-controls.h.

Also add the same reminder message to each class of controls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index adf5485..5aaf15e 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -592,7 +592,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 {
switch (id) {
/* USER controls */
-   /* Keep the order of the 'case's the same as in videodev2.h! */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_USER_CLASS:   return User Controls;
case V4L2_CID_BRIGHTNESS:   return Brightness;
case V4L2_CID_CONTRAST: return Contrast;
@@ -754,7 +754,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_VPX_PROFILE:   return VPX 
Profile;
 
/* CAMERA controls */
-   /* Keep the order of the 'case's the same as in videodev2.h! */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_CAMERA_CLASS: return Camera Controls;
case V4L2_CID_EXPOSURE_AUTO:return Auto Exposure;
case V4L2_CID_EXPOSURE_ABSOLUTE:return Exposure Time, 
Absolute;
@@ -788,8 +788,8 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_AUTO_FOCUS_STATUS:return Auto Focus, Status;
case V4L2_CID_AUTO_FOCUS_RANGE: return Auto Focus, Range;
 
-   /* FM Radio Modulator control */
-   /* Keep the order of the 'case's the same as in videodev2.h! */
+   /* FM Radio Modulator controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_FM_TX_CLASS:  return FM Radio Modulator 
Controls;
case V4L2_CID_RDS_TX_DEVIATION: return RDS Signal Deviation;
case V4L2_CID_RDS_TX_PI:return RDS Program ID;
@@ -812,6 +812,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_TUNE_ANTENNA_CAPACITOR:   return Tune Antenna Capacitor;
 
/* Flash controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_FLASH_CLASS:  return Flash Controls;
case V4L2_CID_FLASH_LED_MODE:   return LED Mode;
case V4L2_CID_FLASH_STROBE_SOURCE:  return Strobe Source;
@@ -827,7 +828,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_FLASH_READY:  return Ready to Strobe;
 
/* JPEG encoder controls */
-   /* Keep the order of the 'case's the same as in videodev2.h! */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_JPEG_CLASS:   return JPEG Compression 
Controls;
case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:  return Chroma Subsampling;
case V4L2_CID_JPEG_RESTART_INTERVAL:return Restart Interval;
@@ -835,18 +836,21 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_JPEG_ACTIVE_MARKER:   return Active Markers;
 
/* Image source controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_IMAGE_SOURCE_CLASS:   return Image Source Controls;
case V4L2_CID_VBLANK:   return Vertical Blanking;
case V4L2_CID_HBLANK:   return Horizontal Blanking;
case V4L2_CID_ANALOGUE_GAIN:return Analogue Gain;
 
/* Image processing controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_IMAGE_PROC_CLASS: return Image Processing 
Controls;
case V4L2_CID_LINK_FREQ:return Link Frequency;
case V4L2_CID_PIXEL_RATE:   return Pixel Rate;
case V4L2_CID_TEST_PATTERN: return Test Pattern;
 
/* DV controls */
+   /* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_DV_CLASS: return Digital Video Controls;
case V4L2_CID_DV_TX_HOTPLUG:return Hotplug Present;
case V4L2_CID_DV_TX_RXSENSE:return RxSense Present;
-- 
2.0.0.rc0

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


[ATTN] Please review/check the REVIEWv4 compound control patch series

2014-06-12 Thread Hans Verkuil
Mauro  anyone else with an interest,

I'd appreciate it if this patch series was reviewed, in particular
with respect to the handling of multi-dimensional arrays:

http://www.mail-archive.com/linux-media@vger.kernel.org/msg75929.html

This patch series incorporates all comments from the REVIEWv3 series
except for two (see the cover letter of the patch series for details),

If support for arrays with more than 8 dimensions is really needed,
then I would like to know asap so I can implement that in time for
3.17.

Regards,

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


Re: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread Niels Laukens
On 2014-06-12 13:51, David Härdeman wrote:
 On 2014-06-12 13:22, Niels Laukens wrote:
 In that case, the alternative would be to start a timer when the
 TRAILING_SPACE is entered, and trigger the key-event after, say 2
 bit-times.
 
 Another alternative is fix the driver to implement a timeout so that
 unreasonable values are not generated (I saw a 240550us space in your
 log).

OK, that sounds like a good way to solve this as well.
I'm very new to this subsystem, so I don't know what layer should
perform what function.


 Now, the question is why the trailing silence isn't generated
 within a reasonable time. Which hardware decoder do you use?

 I use the IR receiver built in to the TBS6281 DVB-T tuner card. I
 also have a TBS6982 DVB-S card, but I guess it's the same hardware.

 Which driver?

I think it's the out-of-tree saa716x_tbs_dvb driver:

[7.670565] input: saa716x IR (TurboSight TBS 6281) as
/devices/pci:00/:00:1c.0/:02:00.0/rc/rc0/input6
[7.671156] rc0: saa716x IR (TurboSight TBS 6281) as
/devices/pci:00/:00:1c.0/:02:00.0/rc/rc0



 And it's what most of the popular hardware does.

So I'll have to rework this patch to function at this lower level, and
try to upstream it to TBS. Thank you for your time!


 For instance, the
 mceusb hardware will send a USB packet with timings including that
 trailing silence. And the decoder can only do their work once a packet
 has arrived (which will contain a number of samples). That also
 demonstrates a potential problem with your suggested approach (i.e.
 timings can be buffered so calls to the decoders are not necessarily
 real-time).

I see what you mean, but I don't see how the proposed patch fails in
this sense. Or were you referring to the proposal of adding a timer at
the ir-nec-decoder level?


Niels
--
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: [REVIEWv4 PATCH 04/34] videodev2.h: add struct v4l2_query_ext_ctrl and VIDIOC_QUERY_EXT_CTRL.

2014-06-12 Thread Sakari Ailus
Hi Hans,

On Thu, Jun 12, 2014 at 01:52:36PM +0200, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 Add a new struct and ioctl to extend the amount of information you can
 get for a control.
 
 The range is now a s64 type, and array dimensions and element size can be
 reported through nr_of_dims/dims/elems/elem_size.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  include/uapi/linux/videodev2.h | 20 
  1 file changed, 20 insertions(+)
 
 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
 index 438c4a6..7d94adc 100644
 --- a/include/uapi/linux/videodev2.h
 +++ b/include/uapi/linux/videodev2.h
 @@ -1269,6 +1269,7 @@ struct v4l2_ext_controls {
  #define V4L2_CTRL_ID_MASK  (0x0fff)
  #define V4L2_CTRL_ID2CLASS(id)((id)  0x0fffUL)
  #define V4L2_CTRL_DRIVER_PRIV(id) (((id)  0x) = 0x1000)
 +#define V4L2_CTRL_MAX_DIMS (8)
  
  enum v4l2_ctrl_type {
   V4L2_CTRL_TYPE_INTEGER   = 1,
 @@ -1298,6 +1299,23 @@ struct v4l2_queryctrl {
   __u32reserved[2];
  };
  
 +/*  Used in the VIDIOC_QUERY_EXT_CTRL ioctl for querying extended controls */
 +struct v4l2_query_ext_ctrl {
 + __u32id;
 + __u32type;
 + char name[32];
 + __s64minimum;
 + __s64maximum;
 + __u64step;
 + __s64default_value;
 + __u32flags;
 + __u32elem_size;
 + __u32elems;
 + __u32nr_of_dims;
 + __u32dims[V4L2_CTRL_MAX_DIMS];
 + __u32reserved[16];

Considering that units are going to be added (probably 16 or even 32 bytes),
I might add even more. Something to be discussed is fractional parts which
is a related topic.

As you have already 34 patches in your set, perhaps it'd be good to postpone
these.

 +};
 +
  /*  Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
  struct v4l2_querymenu {
   __u32   id;
 @@ -2011,6 +2029,8 @@ struct v4l2_create_buffers {
 Never use these in applications! */
  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)
  
 +#define VIDIOC_QUERY_EXT_CTRL_IOWR('V', 103, struct 
 v4l2_query_ext_ctrl)
 +
  /* Reminder: when adding new ioctls please add support for them to
 drivers/media/video/v4l2-compat-ioctl32.c as well! */
  

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread David Härdeman

On 2014-06-12 14:12, Niels Laukens wrote:

On 2014-06-12 13:51, David Härdeman wrote:

On 2014-06-12 13:22, Niels Laukens wrote:

In that case, the alternative would be to start a timer when the
TRAILING_SPACE is entered, and trigger the key-event after, say 2
bit-times.


Another alternative is fix the driver to implement a timeout so that
unreasonable values are not generated (I saw a 240550us space in 
your

log).


OK, that sounds like a good way to solve this as well.
I'm very new to this subsystem, so I don't know what layer should
perform what function.


I'm not 100% sure that would be the right fix, but I think so. Haven't 
looked at the driver.



Now, the question is why the trailing silence isn't generated
within a reasonable time. Which hardware decoder do you use?


I use the IR receiver built in to the TBS6281 DVB-T tuner card. I
also have a TBS6982 DVB-S card, but I guess it's the same hardware.


Which driver?


I think it's the out-of-tree saa716x_tbs_dvb driver:

[7.670565] input: saa716x IR (TurboSight TBS 6281) as
/devices/pci:00/:00:1c.0/:02:00.0/rc/rc0/input6
[7.671156] rc0: saa716x IR (TurboSight TBS 6281) as
/devices/pci:00/:00:1c.0/:02:00.0/rc/rc0


Could you paste the output from lsmod?

Where did you get the driver? Is it this one?
http://www.tbsdtv.com/download/document/common/tbs-linux-drivers_v140425.zip



And it's what most of the popular hardware does.


So I'll have to rework this patch to function at this lower level, and
try to upstream it to TBS. Thank you for your time!



For instance, the
mceusb hardware will send a USB packet with timings including that
trailing silence. And the decoder can only do their work once a packet
has arrived (which will contain a number of samples). That also
demonstrates a potential problem with your suggested approach (i.e.
timings can be buffered so calls to the decoders are not necessarily
real-time).


I see what you mean, but I don't see how the proposed patch fails in
this sense. Or were you referring to the proposal of adding a timer at
the ir-nec-decoder level?


Yes. The ir-nec-decoder timer doesn't know what the hardware is up to so 
it could timeout because it didn't get more data in time while at the 
same time the driver is buffering data...



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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Arnd Bergmann
On Thursday 12 June 2014 16:12:17 Laurent Pinchart wrote:
  From 3a965f4fd5a6b3ef4a66aa4e7c916cfd34fd5706 Mon Sep 17 00:00:00 2001
  From: Arnd Bergmann a...@arndb.de
  Date: Tue, 21 Jan 2014 09:32:43 +0100
  Subject: [PATCH] [media] staging: tighten omap4iss dependencies
  
  The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
  of which can be loadable modules. This causes build failures
  if we want the camera driver to be built-in.
  
  This can be solved by turning the option into tristate,
  which unfortunately causes another problem, because the
  driver incorrectly calls a platform-internal interface
  for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.
  
  Instead, this patch just forbids the invalid configurations
  and ensures that the driver can only be built if all its
  dependencies are built-in.
  
  Signed-off-by: Arnd Bergmann a...@arndb.de
 
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 
 Should I take this in my tree for v3.17 or would you like to fast-track it ?
 

I'd actually like to see it in 3.15 as a stable backport if possible,
but definitely in 3.16. What is the normal path for staging/media
but fix patches?

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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Greg KH
On Thu, Jun 12, 2014 at 04:15:32PM +0200, Arnd Bergmann wrote:
 On Thursday 12 June 2014 16:12:17 Laurent Pinchart wrote:
   From 3a965f4fd5a6b3ef4a66aa4e7c916cfd34fd5706 Mon Sep 17 00:00:00 2001
   From: Arnd Bergmann a...@arndb.de
   Date: Tue, 21 Jan 2014 09:32:43 +0100
   Subject: [PATCH] [media] staging: tighten omap4iss dependencies
   
   The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
   of which can be loadable modules. This causes build failures
   if we want the camera driver to be built-in.
   
   This can be solved by turning the option into tristate,
   which unfortunately causes another problem, because the
   driver incorrectly calls a platform-internal interface
   for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.
   
   Instead, this patch just forbids the invalid configurations
   and ensures that the driver can only be built if all its
   dependencies are built-in.
   
   Signed-off-by: Arnd Bergmann a...@arndb.de
  
  Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
  
  Should I take this in my tree for v3.17 or would you like to fast-track it ?
  
 
 I'd actually like to see it in 3.15 as a stable backport if possible,

It's not stable material, sorry.

 but definitely in 3.16. What is the normal path for staging/media
 but fix patches?

Through Mauro's tree.

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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Arnd Bergmann
On Thursday 12 June 2014 07:25:15 Greg KH wrote:
 On Thu, Jun 12, 2014 at 04:15:32PM +0200, Arnd Bergmann wrote:
  On Thursday 12 June 2014 16:12:17 Laurent Pinchart wrote:
From 3a965f4fd5a6b3ef4a66aa4e7c916cfd34fd5706 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann a...@arndb.de
Date: Tue, 21 Jan 2014 09:32:43 +0100
Subject: [PATCH] [media] staging: tighten omap4iss dependencies

The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
of which can be loadable modules. This causes build failures
if we want the camera driver to be built-in.

This can be solved by turning the option into tristate,
which unfortunately causes another problem, because the
driver incorrectly calls a platform-internal interface
for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.

Instead, this patch just forbids the invalid configurations
and ensures that the driver can only be built if all its
dependencies are built-in.

Signed-off-by: Arnd Bergmann a...@arndb.de
   
   Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
   
   Should I take this in my tree for v3.17 or would you like to fast-track 
   it ?
   
  
  I'd actually like to see it in 3.15 as a stable backport if possible,
 
 It's not stable material, sorry.

To clarify, I was talking about second version of the patch,
not the original one. It just does this:

  config VIDEO_OMAP4
   bool OMAP 4 Camera support
 - depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  I2C  ARCH_OMAP4
 + depends on VIDEO_V4L2=y  VIDEO_V4L2_SUBDEV_API  I2C=y  ARCH_OMAP4
   select VIDEOBUF2_DMA_CONTIG
   ---help---
 Driver for an OMAP 4 ISS controller.

which enforces that configurations that cannot be compiled
will not be selectable in Kconfig, so we can have allmodconfig
working. I thought that was ok for -stable.

  but definitely in 3.16. What is the normal path for staging/media
  but fix patches?
 
 Through Mauro's tree.

Ok.

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


re: [media] dvb_usb_v2: use dev_* logging macros

2014-06-12 Thread Dan Carpenter
Hello Antti Palosaari,

This is a semi-automatic email about new static checker warnings.

The patch d10d1b9ac97b: [media] dvb_usb_v2: use dev_* logging
macros from Jun 26, 2012, leads to the following Smatch complaint:

drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c:31 dvb_usb_v2_generic_io()
 error: we previously assumed 'd' could be null (see line 29)

drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
28  
29  if (!d || !wbuf || !wlen || 
!d-props-generic_bulk_ctrl_endpoint ||
^^
Old check.

30  !d-props-generic_bulk_ctrl_endpoint_response) 
{
31  dev_dbg(d-udev-dev, %s: failed=%d\n, __func__, 
-EINVAL);
^
New dereference.

32  return -EINVAL;
33  }

regards,
dan carpenter
--
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: [media] dvb_usb_v2: use dev_* logging macros

2014-06-12 Thread Antti Palosaari

Moikka Dan,
Thank for the report. I will check that later... I am now back from 
traveling and there is a lot of stuff on my queue waiting for action.


regards
Antti



On 06/12/2014 05:30 PM, Dan Carpenter wrote:

Hello Antti Palosaari,

This is a semi-automatic email about new static checker warnings.

The patch d10d1b9ac97b: [media] dvb_usb_v2: use dev_* logging
macros from Jun 26, 2012, leads to the following Smatch complaint:

drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c:31 dvb_usb_v2_generic_io()
 error: we previously assumed 'd' could be null (see line 29)

drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
 28 
 29 if (!d || !wbuf || !wlen || 
!d-props-generic_bulk_ctrl_endpoint ||
 ^^
Old check.

 30 !d-props-generic_bulk_ctrl_endpoint_response) 
{
 31 dev_dbg(d-udev-dev, %s: failed=%d\n, __func__, 
-EINVAL);
 ^
New dereference.

 32 return -EINVAL;
 33 }

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




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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Laurent Pinchart
Hi Tony,

On Wednesday 11 June 2014 07:47:54 Tony Lindgren wrote:
 * Arnd Bergmann a...@arndb.de [140611 07:37]:
  The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
  of which can be loadable modules. This causes build failures
  if we want the camera driver to be built-in.
 
 That's good news, but let's not fix it this way.
 
  This can be solved by turning the option into tristate,
  which unfortunately causes another problem, because the
  driver incorrectly calls a platform-internal interface
  for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.
  To work around that, we can export those symbols, but
  that isn't really the correct solution, as we should not
  have dependencies on platform code this way.
  
  Signed-off-by: Arnd Bergmann a...@arndb.de
  ---
  This is one of just two patches we currently need to get
  'make allmodconfig' to build again on ARM.
  
  diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
  index 751f354..05d2d98 100644
  --- a/arch/arm/mach-omap2/control.c
  +++ b/arch/arm/mach-omap2/control.c
  @@ -190,11 +190,13 @@ u32 omap4_ctrl_pad_readl(u16 offset)
   {
  return readl_relaxed(OMAP4_CTRL_PAD_REGADDR(offset));
   }
  +EXPORT_SYMBOL_GPL(omap4_ctrl_pad_readl);
  
   void omap4_ctrl_pad_writel(u32 val, u16 offset)
   {
  writel_relaxed(val, OMAP4_CTRL_PAD_REGADDR(offset));
   }
  +EXPORT_SYMBOL_GPL(omap4_ctrl_pad_writel);
  
   #ifdef CONFIG_ARCH_OMAP3
 
 Exporting these will likely cause immediate misuse in other
 drivers all over the place.
 
 These should just use either pinctrl-single.c instead for muxing.
 Or if they are not mux registers, we do have the syscon mapping
 available in omap4.dtsi that pbias-regulator.c is already using.
 
 Laurent, got any better ideas?

The ISS driver needs to write a single register, which contains several 
independent fields. They thus need to be controlled by a single driver. Some 
of them might be considered to be related to pinmuxing (although I disagree on 
that), others are certainly not about muxing (there are clock gate bits for 
instance).

Using the syscon mapping seems like the best option. I'll give it a try.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Laurent Pinchart
Hi Arnd,

On Thursday 12 June 2014 16:28:39 Arnd Bergmann wrote:
 On Thursday 12 June 2014 07:25:15 Greg KH wrote:
  On Thu, Jun 12, 2014 at 04:15:32PM +0200, Arnd Bergmann wrote:
   On Thursday 12 June 2014 16:12:17 Laurent Pinchart wrote:
 From 3a965f4fd5a6b3ef4a66aa4e7c916cfd34fd5706 Mon Sep 17 00:00:00
 2001
 From: Arnd Bergmann a...@arndb.de
 Date: Tue, 21 Jan 2014 09:32:43 +0100
 Subject: [PATCH] [media] staging: tighten omap4iss dependencies
 
 The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
 of which can be loadable modules. This causes build failures
 if we want the camera driver to be built-in.
 
 This can be solved by turning the option into tristate,
 which unfortunately causes another problem, because the
 driver incorrectly calls a platform-internal interface
 for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.
 
 Instead, this patch just forbids the invalid configurations
 and ensures that the driver can only be built if all its
 dependencies are built-in.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de

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

Should I take this in my tree for v3.17 or would you like to
fast-track it ?  
   I'd actually like to see it in 3.15 as a stable backport if possible,
  
  It's not stable material, sorry.
 
 To clarify, I was talking about second version of the patch,
 not the original one. It just does this:

   config VIDEO_OMAP4
bool OMAP 4 Camera support
  - depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  I2C  ARCH_OMAP4
  + depends on VIDEO_V4L2=y  VIDEO_V4L2_SUBDEV_API  I2C=y 
  ARCH_OMAP4
select VIDEOBUF2_DMA_CONTIG
---help---
  Driver for an OMAP 4 ISS controller.
 
 which enforces that configurations that cannot be compiled
 will not be selectable in Kconfig, so we can have allmodconfig
 working. I thought that was ok for -stable.
 
   but definitely in 3.16. What is the normal path for staging/media
   but fix patches?
  
  Through Mauro's tree.
 
 Ok.

I've applied the patch to my tree and will send a pull request to Mauro for 
v3.16 as soon as you reach an agreement with Greg on whether I should add CC: 
stable or not.

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Tony Lindgren
* Laurent Pinchart laurent.pinch...@ideasonboard.com [140612 07:52]:
 On Wednesday 11 June 2014 07:47:54 Tony Lindgren wrote:
  
  These should just use either pinctrl-single.c instead for muxing.
  Or if they are not mux registers, we do have the syscon mapping
  available in omap4.dtsi that pbias-regulator.c is already using.
  
  Laurent, got any better ideas?
 
 The ISS driver needs to write a single register, which contains several 
 independent fields. They thus need to be controlled by a single driver. Some 
 of them might be considered to be related to pinmuxing (although I disagree 
 on 
 that), others are certainly not about muxing (there are clock gate bits for 
 instance).
 
 Using the syscon mapping seems like the best option. I'll give it a try.

OK if it's not strictly pinctrl related then let's not use
pinctrl-single,bits for it. You may be able to implement one or more
framework drivers for it for pinctrl/regulator/clock/transceiver
whatever that register is doing.

In any case it's best to have that handling in a separate helper driver
somewhere as it's a separate piece of hardware from the camera module.
If it does not fit into any existing frameworks then it's best to have
it in a separate driver with the camera driver.

Regards,

Tony
--
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: [BUG PATCH] media/rc/ir-nec-decode : phantom keypress

2014-06-12 Thread Niels Laukens
On 2014-06-12 14:42, David Härdeman wrote:
 Could you paste the output from lsmod?

At the end of this mail.


 Where did you get the driver? Is it this one?
 http://www.tbsdtv.com/download/document/common/tbs-linux-drivers_v140425.zip

Yes, inside the zip is `linux-tbs-drivers.tar.bz2`, where the actual
drivers live. I believe we should be looking at
linux-tbs-drivers/linux/drivers/media/common/saa716x/saa716x_input.c

I think the interesting parts are at the end of the file, where the two
IRQ-handling functions are.

I don't understand why there is a 15ms timer before
ir_raw_event_handle() is called (the comment just says what the code
does, not why it does it). I assume this throttles the decoders a bit.
Does that make sense?


From what I understand from the code, the hardware fires an interrupt
every time there is an edge, so I need to start a timer myself to call
ir_raw_event_set_idle() some time in the future. (And possible
re-schedule the ir_raw_event_handle() call as well). Does that sound right?

I've been reading ir-raw.c, but I don't see any timers there. I see the
timeout-check in ir_raw_event_store_with_filter(), but that will only
fire when called, and won't trigger by itself.

Thanks again for your time,
Niels




# lsmod
Module  Size  Used by
rpcsec_gss_krb535573  1
nfsv4 465643  2
tbsfe  13023  2
nfsd  280297  2
auth_rpcgss59338  3 nfsd,rpcsec_gss_krb5
nfs_acl12837  1 nfsd
nfs   236636  2 nfsv4
lockd  93977  2 nfs,nfsd
sunrpc284404  10
nfs,nfsd,rpcsec_gss_krb5,auth_rpcgss,lockd,nfsv4,nfs_acl
fscache63988  2 nfs,nfsv4
hid_generic12548  0
usbhid 52616  0
hid   106148  2 hid_generic,usbhid
tbs62x1fe  55345  2
snd_hda_codec_hdmi 46207  2
snd_hda_codec_realtek61438  1
ir_lirc_codec  12898  0
lirc_dev   19166  1 ir_lirc_codec
snd_seq_midi   13324  0
snd_seq_midi_event 14899  1 snd_seq_midi
snd_rawmidi30144  1 snd_seq_midi
ir_mce_kbd_decoder 12845  0
ir_sony_decoder12549  0
ir_jvc_decoder 12546  0
intel_rapl 18773  0
x86_pkg_temp_thermal14205  0
ir_rc6_decoder 12546  0
intel_powerclamp   14705  0
kvm_intel 143060  0
kvm   451511  1 kvm_intel
ir_rc5_decoder 12546  0
crct10dif_pclmul   14289  0
ir_nec_decoder 12546  0
crc32_pclmul   13113  0
ghash_clmulni_intel13259  0
rc_tbs_nec 12502  0
aesni_intel55624  0
snd_seq61560  2 snd_seq_midi_event,snd_seq_midi
aes_x86_64 17131  1 aesni_intel
lrw13286  1 aesni_intel
gf128mul   14951  1 lrw
glue_helper13990  1 aesni_intel
snd_hda_intel  52355  5
ablk_helper13597  1 aesni_intel
cryptd 20359  3 ghash_clmulni_intel,aesni_intel,ablk_helper
snd_hda_codec 192906  3
snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intel
snd_hwdep  13602  1 snd_hda_codec
i915  783485  1
serio_raw  13462  0
snd_pcm   102099  3
snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel
saa716x_tbs_dvb76784  0
tbs6982fe  22408  1 saa716x_tbs_dvb
tbs6680fe  17791  1 saa716x_tbs_dvb
tbs6923fe  22408  1 saa716x_tbs_dvb
tbs6985se  17882  1 saa716x_tbs_dvb
tbs6928se  17884  1 saa716x_tbs_dvb
tbs6982se  22408  1 saa716x_tbs_dvb
tbs6991fe  17785  1 saa716x_tbs_dvb
tbs6618fe  17791  1 saa716x_tbs_dvb
saa716x_core   50899  1 saa716x_tbs_dvb
tbs6922fe  22478  1 saa716x_tbs_dvb
tbs6928fe  17785  1 saa716x_tbs_dvb
tbs6991se  17882  1 saa716x_tbs_dvb
tbs6290fe  50747  1 saa716x_tbs_dvb
stv090x70414  1 saa716x_tbs_dvb
dvb_core  109932  2 saa716x_core,saa716x_tbs_dvb
rc_core26933  11
ir_lirc_codec,ir_rc5_decoder,ir_nec_decoder,ir_sony_decoder,rc_tbs_nec,saa716x_tbs_dvb,ir_mce_kbd_decoder,ir_jvc_decoder,ir_rc6_decoder
snd_seq_device 14497  3 snd_seq,snd_rawmidi,snd_seq_midi
snd_page_alloc 18710  2 snd_pcm,snd_hda_intel
lpc_ich21080  0
snd_timer  29482  2 snd_pcm,snd_seq
snd69238  21
snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_seq,snd_rawmidi,snd_hda_codec,snd_hda_intel,snd_seq_device,snd_seq_midi
nvidia  10675249  29
mei_me 18627  0
mei82274  1 mei_me
soundcore  12680  1 snd
video  19476  1 i915
drm_kms_helper 52758  1 i915
mac_hid13205  0
drm   302817  4 i915,drm_kms_helper,nvidia
i2c_algo_bit   13413  2 i915,saa716x_tbs_dvb
nct6775  

Re: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Laurent Pinchart
Hi Tony,

On Thursday 12 June 2014 08:15:35 Tony Lindgren wrote:
 * Laurent Pinchart laurent.pinch...@ideasonboard.com [140612 07:52]:
  On Wednesday 11 June 2014 07:47:54 Tony Lindgren wrote:
   These should just use either pinctrl-single.c instead for muxing.
   Or if they are not mux registers, we do have the syscon mapping
   available in omap4.dtsi that pbias-regulator.c is already using.
   
   Laurent, got any better ideas?
  
  The ISS driver needs to write a single register, which contains several
  independent fields. They thus need to be controlled by a single driver.
  Some of them might be considered to be related to pinmuxing (although I
  disagree on that), others are certainly not about muxing (there are clock
  gate bits for instance).
  
  Using the syscon mapping seems like the best option. I'll give it a try.
 
 OK if it's not strictly pinctrl related then let's not use
 pinctrl-single,bits for it. You may be able to implement one or more
 framework drivers for it for pinctrl/regulator/clock/transceiver
 whatever that register is doing.
 
 In any case it's best to have that handling in a separate helper driver
 somewhere as it's a separate piece of hardware from the camera module.
 If it does not fit into any existing frameworks then it's best to have
 it in a separate driver with the camera driver.

The register contains the following fields that control the two CSI2 PHYs 
(PHY1 and PHY2).

31CAMERARX_CSI22_LANEENABLE2   PHY2 Lane 2 (CSI22_DX2, CSI22_DY2) Enable
30CAMERARX_CSI22_LANEENABLE1   PHY2 Lane 1 (CSI22_DX1, CSI22_DY1) Enable
29CAMERARX_CSI22_LANEENABLE0   PHY2 Lane 0 (CSI22_DX0, CSI22_DY0) Enable
28CAMERARX_CSI21_LANEENABLE4   PHY1 Lane 4 (CSI21_DX4, CSI21_DY4) Enable
27CAMERARX_CSI21_LANEENABLE3   PHY1 Lane 3 (CSI21_DX3, CSI21_DY3) Enable
26CAMERARX_CSI21_LANEENABLE2   PHY1 Lane 2 (CSI21_DX2, CSI21_DY2) Enable
25CAMERARX_CSI21_LANEENABLE1   PHY1 Lane 1 (CSI21_DX1, CSI21_DY1) Enable
24CAMERARX_CSI21_LANEENABLE0   PHY1 Lane 0 (CSI21_DX0, CSI21_DY0) Enable
21CAMERARX_CSI22_CTRLCLKEN PHY2 Clock Enable
20:19 CAMERARX_CSI22_CAMMODE   PHY2 Mode (CCP2, CSI1, CSI2)
18CAMERARX_CSI21_CTRLCLKEN PHY1 Clock Enable
17:16 CAMERARX_CSI21_CAMMODE   PHY1 Mode (CCP2, CSI1, CSI2)

Bits 18 and 21 could be exposed through CCF. Bits 24 to 31 enable/disable the 
CSI2 lanes, so it could be argued that they could be exposed through the 
pinctrl framework. However, they need to be configured independently, possibly 
at runtime. I'm thus not sure pinctrl would be a good idea. Bits 17:16 and 
20:19 don't fit in existing frameworks.

Given that this register is specific to the ISS, I think handling it as a 
separate device through a separate driver would only complicate the 
implementation without any real benefit.

-- 
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] Add patch to allow compilation on versions 3.5 with CONFIG_OF

2014-06-12 Thread Devin Heitmueller
Support for Open Firmware was introduced in the V4L2 tree, but
it depends on features only found in 3.5+.  Add a patch to disable
the support for earlier kernels.

Tested on Ubuntu 10.04 with kernel 3.2.0-030200-generic (which has
CONFIG_OF enabled by default).

Signed-off-by: Devin Heitmueller dheitmuel...@kernellabs.com
---
 backports/backports.txt   |  1 +
 backports/v3.4_openfirmware.patch | 13 +
 2 files changed, 14 insertions(+)
 create mode 100644 backports/v3.4_openfirmware.patch

diff --git a/backports/backports.txt b/backports/backports.txt
index 281c263..08908e6 100644
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -43,6 +43,7 @@ add v3.6_i2c_add_mux_adapter.patch
 
 [3.4.255]
 add v3.4_i2c_add_mux_adapter.patch
+add v3.4_openfirmware.patch
 
 [3.2.255]
 add v3.2_devnode_uses_mode_t.patch
diff --git a/backports/v3.4_openfirmware.patch 
b/backports/v3.4_openfirmware.patch
new file mode 100644
index 000..f0a8d36
--- /dev/null
+++ b/backports/v3.4_openfirmware.patch
@@ -0,0 +1,13 @@
+--- a/drivers/media/v4l2-core/v4l2-of.c2014-06-11 17:05:02.0 
-0700
 b/drivers/media/v4l2-core/v4l2-of.c2014-06-11 17:05:34.0 
-0700
+@@ -1,3 +1,5 @@
++/* Depends on symbols not present until kernel 3.5 */
++#if 0
+ /*
+  * V4L2 OF binding parsing library
+  *
+@@ -142,3 +144,4 @@
+   return 0;
+ }
+ EXPORT_SYMBOL(v4l2_of_parse_endpoint);
++#endif
-- 
1.9.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: [PATCH] [media] staging: allow omap4iss to be modular

2014-06-12 Thread Greg KH
On Thu, Jun 12, 2014 at 04:28:39PM +0200, Arnd Bergmann wrote:
 On Thursday 12 June 2014 07:25:15 Greg KH wrote:
  On Thu, Jun 12, 2014 at 04:15:32PM +0200, Arnd Bergmann wrote:
   On Thursday 12 June 2014 16:12:17 Laurent Pinchart wrote:
 From 3a965f4fd5a6b3ef4a66aa4e7c916cfd34fd5706 Mon Sep 17 00:00:00 2001
 From: Arnd Bergmann a...@arndb.de
 Date: Tue, 21 Jan 2014 09:32:43 +0100
 Subject: [PATCH] [media] staging: tighten omap4iss dependencies
 
 The OMAP4 camera support depends on I2C and VIDEO_V4L2, both
 of which can be loadable modules. This causes build failures
 if we want the camera driver to be built-in.
 
 This can be solved by turning the option into tristate,
 which unfortunately causes another problem, because the
 driver incorrectly calls a platform-internal interface
 for omap4_ctrl_pad_readl/omap4_ctrl_pad_writel.
 
 Instead, this patch just forbids the invalid configurations
 and ensures that the driver can only be built if all its
 dependencies are built-in.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de

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

Should I take this in my tree for v3.17 or would you like to fast-track 
it ?

   
   I'd actually like to see it in 3.15 as a stable backport if possible,
  
  It's not stable material, sorry.
 
 To clarify, I was talking about second version of the patch,
 not the original one. It just does this:
 
   config VIDEO_OMAP4
bool OMAP 4 Camera support
  - depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  I2C  ARCH_OMAP4
  + depends on VIDEO_V4L2=y  VIDEO_V4L2_SUBDEV_API  I2C=y  
  ARCH_OMAP4
select VIDEOBUF2_DMA_CONTIG
---help---
  Driver for an OMAP 4 ISS controller.
 
 which enforces that configurations that cannot be compiled
 will not be selectable in Kconfig, so we can have allmodconfig
 working. I thought that was ok for -stable.

Ah, yes, that one works, sorry, I was thinking of the first one.

greg k-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 4/5] v4l: ctrls: Unlocked variants of v4l2_ctrl_s_ctrl{,_int64}()

2014-06-12 Thread Sakari Ailus
From: Sakari Ailus sakari.ai...@linux.intel.com

Implement unlocked variants of v4l2_ctrl_s_ctrl() and
v4l2_ctrl_s_ctrl_int64(). As drivers need to set controls as they access
driver internal state elsewhere than in the control framework unlocked
variants of these functions become handy.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c |   26 --
 include/media/v4l2-ctrls.h   |   27 +--
 2 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 7324ef0..36228b4 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2848,27 +2848,41 @@ int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct 
v4l2_control *control)
 }
 EXPORT_SYMBOL(v4l2_subdev_s_ctrl);
 
-int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
+int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
 {
struct v4l2_ext_control c;
+   int rval;
+
+   lockdep_assert_held(ctrl-handler-lock);
 
/* It's a driver bug if this happens. */
WARN_ON(!type_is_int(ctrl));
c.value = val;
-   return set_ctrl_lock(NULL, ctrl, c);
+   rval = set_ctrl(NULL, ctrl, c, 0);
+   if (!rval)
+   cur_to_user(c, ctrl);
+
+   return rval;
 }
-EXPORT_SYMBOL(v4l2_ctrl_s_ctrl);
+EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl);
 
-int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
+int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
 {
struct v4l2_ext_control c;
+   int rval;
+
+   lockdep_assert_held(ctrl-handler-lock);
 
/* It's a driver bug if this happens. */
WARN_ON(ctrl-type != V4L2_CTRL_TYPE_INTEGER64);
c.value64 = val;
-   return set_ctrl_lock(NULL, ctrl, c);
+   rval = set_ctrl(NULL, ctrl, c, 0);
+   if (!rval)
+   cur_to_user(c, ctrl);
+
+   return rval;
 }
-EXPORT_SYMBOL(v4l2_ctrl_s_ctrl_int64);
+EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_int64);
 
 void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, 
void *priv)
 {
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 371c4f1..00c1778 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -619,6 +619,8 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, 
v4l2_ctrl_notify_fnc notify, void
   */
 s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
 
+/** __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). */
+int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
 /** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from 
within a driver.
   * @ctrl: The control.
   * @val:  The new value.
@@ -629,7 +631,16 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
   *
   * This function is for integer type controls only.
   */
-int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
+static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
+{
+   int rval;
+
+   v4l2_ctrl_lock(ctrl);
+   rval = __v4l2_ctrl_s_ctrl(ctrl, val);
+   v4l2_ctrl_unlock(ctrl);
+
+   return rval;
+}
 
 /** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value 
from within a driver.
   * @ctrl: The control.
@@ -642,6 +653,9 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
   */
 s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
 
+/** __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64(). 
*/
+int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
+
 /** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value 
from within a driver.
   * @ctrl: The control.
   * @val:  The new value.
@@ -652,7 +666,16 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
   *
   * This function is for 64-bit integer type controls only.
   */
-int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
+static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
+{
+   int rval;
+
+   v4l2_ctrl_lock(ctrl);
+   rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
+   v4l2_ctrl_unlock(ctrl);
+
+   return rval;
+}
 
 /* Internal helper functions that deal with control events. */
 extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
-- 
1.7.10.4

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


[PATCH 0/5] v4l: ctrls: Unlocked variants of (some) functions for driver's internal use

2014-06-12 Thread Sakari Ailus
Hi,

This patchset adds unlocked variants of control framework functions to
set controls and modify their range. As in many cases the driver internal
data structures are protected using the same lock the control handler uses,
thus either forcing to poke the control framework data structures directly
or releasing the lock which leads to serialisation issues.

Also use the new unlocked variants in the smiapp driver.

-- 
Kind regards,
Sakari

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


[PATCH 3/5] smiapp: Use unlocked __v4l2_ctrl_modify_range()

2014-06-12 Thread Sakari Ailus
From: Sakari Ailus sakari.ai...@linux.intel.com

Instead of modifying the control ranges directly by manipulating struct
v4l2_ctrl, use __v4l2_ctrl_modify_range() for the purpose.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c |   47 ++--
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 446c82c..c669525 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -319,13 +319,7 @@ static void __smiapp_update_exposure_limits(struct 
smiapp_sensor *sensor)
+ sensor-vblank-val
- 
sensor-limits[SMIAPP_LIMIT_COARSE_INTEGRATION_TIME_MAX_MARGIN];
 
-   ctrl-maximum = max;
-   if (ctrl-default_value  max)
-   ctrl-default_value = max;
-   if (ctrl-val  max)
-   ctrl-val = max;
-   if (ctrl-cur.val  max)
-   ctrl-cur.val = max;
+   __v4l2_ctrl_modify_range(ctrl, ctrl-minimum, max, ctrl-step, max);
 }
 
 /*
@@ -782,36 +776,25 @@ static void smiapp_update_blanking(struct smiapp_sensor 
*sensor)
 {
struct v4l2_ctrl *vblank = sensor-vblank;
struct v4l2_ctrl *hblank = sensor-hblank;
+   int min, max;
 
-   vblank-minimum =
-   max_t(int,
- sensor-limits[SMIAPP_LIMIT_MIN_FRAME_BLANKING_LINES],
- sensor-limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES_BIN] -
- sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].height);
-   vblank-maximum =
-   sensor-limits[SMIAPP_LIMIT_MAX_FRAME_LENGTH_LINES_BIN] -
+   min = max_t(int,
+   sensor-limits[SMIAPP_LIMIT_MIN_FRAME_BLANKING_LINES],
+   sensor-limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES_BIN] -
+   sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].height);
+   max = sensor-limits[SMIAPP_LIMIT_MAX_FRAME_LENGTH_LINES_BIN] -
sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].height;
 
-   vblank-val = clamp_t(int, vblank-val,
- vblank-minimum, vblank-maximum);
-   vblank-default_value = vblank-minimum;
-   vblank-val = vblank-val;
-   vblank-cur.val = vblank-val;
-
-   hblank-minimum =
-   max_t(int,
- sensor-limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN] -
- sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].width,
- sensor-limits[SMIAPP_LIMIT_MIN_LINE_BLANKING_PCK_BIN]);
-   hblank-maximum =
-   sensor-limits[SMIAPP_LIMIT_MAX_LINE_LENGTH_PCK_BIN] -
+   __v4l2_ctrl_modify_range(vblank, min, max, vblank-step, min);
+
+   min = max_t(int,
+   sensor-limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN] -
+   sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].width,
+   sensor-limits[SMIAPP_LIMIT_MIN_LINE_BLANKING_PCK_BIN]);
+   max = sensor-limits[SMIAPP_LIMIT_MAX_LINE_LENGTH_PCK_BIN] -
sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].width;
 
-   hblank-val = clamp_t(int, hblank-val,
- hblank-minimum, hblank-maximum);
-   hblank-default_value = hblank-minimum;
-   hblank-val = hblank-val;
-   hblank-cur.val = hblank-val;
+   __v4l2_ctrl_modify_range(hblank, min, max, hblank-step, min);
 
__smiapp_update_exposure_limits(sensor);
 }
-- 
1.7.10.4

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


[PATCH 2/5] v4l: ctrls: Provide an unlocked variant of v4l2_ctrl_modify_range()

2014-06-12 Thread Sakari Ailus
From: Sakari Ailus sakari.ai...@linux.intel.com

Drivers may use the v4l2_ctrl_modify_range() internally as part of other
operations that need to be both serialised using a driver's lock which can
also be used to serialise access to the control handler. Provide an unlocked
version of the function, __v4l2_ctrl_modify_range() which then may be used
by drivers for the purpose.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c |   10 +-
 include/media/v4l2-ctrls.h   |   18 --
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 55c6832..7324ef0 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2886,12 +2886,14 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, 
v4l2_ctrl_notify_fnc notify, void
 }
 EXPORT_SYMBOL(v4l2_ctrl_notify);
 
-int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
-   s32 min, s32 max, u32 step, s32 def)
+int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+s32 min, s32 max, u32 step, s32 def)
 {
int ret = check_range(ctrl-type, min, max, step, def);
struct v4l2_ext_control c;
 
+   lockdep_assert_held(ctrl-handler-lock);
+
switch (ctrl-type) {
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_BOOLEAN:
@@ -2904,7 +2906,6 @@ int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
default:
return -EINVAL;
}
-   v4l2_ctrl_lock(ctrl);
ctrl-minimum = min;
ctrl-maximum = max;
ctrl-step = step;
@@ -2916,10 +2917,9 @@ int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
ret = set_ctrl(NULL, ctrl, c, V4L2_EVENT_CTRL_CH_RANGE);
else
send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE);
-   v4l2_ctrl_unlock(ctrl);
return ret;
 }
-EXPORT_SYMBOL(v4l2_ctrl_modify_range);
+EXPORT_SYMBOL(__v4l2_ctrl_modify_range);
 
 static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned 
elems)
 {
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 2d17819..371c4f1 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -560,6 +560,11 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool 
active);
   */
 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
 
+
+/** __v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() 
*/
+int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+s32 min, s32 max, u32 step, s32 def);
+
 /** v4l2_ctrl_modify_range() - Update the range of a control.
   * @ctrl: The control to update.
   * @min:  The control's minimum value.
@@ -577,8 +582,17 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
-int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
-   s32 min, s32 max, u32 step, s32 def);
+static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+s32 min, s32 max, u32 step, s32 def)
+{
+   int rval;
+
+   v4l2_ctrl_lock(ctrl);
+   rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
+   v4l2_ctrl_unlock(ctrl);
+
+   return rval;
+}
 
 /** v4l2_ctrl_notify() - Function to set a notify callback for a control.
   * @ctrl: The control.
-- 
1.7.10.4

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


[PATCH 1/5] v4l: ctrls: Move control lock/unlock above the control access functions

2014-06-12 Thread Sakari Ailus
From: Sakari Ailus sakari.ai...@linux.intel.com

The v4l2_ctrl_{,un}lock will be needed elsewhere. Define them before the
functions that perform operations on controls.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/media/v4l2-ctrls.h |   36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 16f7f26..2d17819 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -307,6 +307,24 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler 
*hdl,
   */
 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
 
+/** v4l2_ctrl_lock() - Helper function to lock the handler
+  * associated with the control.
+  * @ctrl: The control to lock.
+  */
+static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
+{
+   mutex_lock(ctrl-handler-lock);
+}
+
+/** v4l2_ctrl_unlock() - Helper function to unlock the handler
+  * associated with the control.
+  * @ctrl: The control to unlock.
+  */
+static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
+{
+   mutex_unlock(ctrl-handler-lock);
+}
+
 /** v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
   * to the handler to initialize the hardware to the current control values.
   * @hdl:  The control handler.
@@ -562,24 +580,6 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
 int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
s32 min, s32 max, u32 step, s32 def);
 
-/** v4l2_ctrl_lock() - Helper function to lock the handler
-  * associated with the control.
-  * @ctrl: The control to lock.
-  */
-static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
-{
-   mutex_lock(ctrl-handler-lock);
-}
-
-/** v4l2_ctrl_unlock() - Helper function to unlock the handler
-  * associated with the control.
-  * @ctrl: The control to unlock.
-  */
-static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
-{
-   mutex_unlock(ctrl-handler-lock);
-}
-
 /** v4l2_ctrl_notify() - Function to set a notify callback for a control.
   * @ctrl: The control.
   * @notify:   The callback function.
-- 
1.7.10.4

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


[PATCH 5/5] smiapp: Set 64-bit integer control using v4l2_ctrl_s_ctrl_int64()

2014-06-12 Thread Sakari Ailus
From: Sakari Ailus sakari.ai...@linux.intel.com

Don't manipulate struct v4l2_ctrl directly. Instead, use
v4l2_ctrl_s_ctrl_int64() to change the values.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index c669525..95d3d0e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -297,8 +297,9 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
if (rval  0)
return rval;
 
-   sensor-pixel_rate_parray-cur.val64 = pll-vt_pix_clk_freq_hz;
-   sensor-pixel_rate_csi-cur.val64 = pll-pixel_rate_csi;
+   __v4l2_ctrl_s_ctrl_int64(sensor-pixel_rate_parray,
+pll-vt_pix_clk_freq_hz);
+   __v4l2_ctrl_s_ctrl_int64(sensor-pixel_rate_csi, pll-pixel_rate_csi);
 
return 0;
 }
@@ -471,6 +472,10 @@ static int smiapp_set_ctrl(struct v4l2_ctrl *ctrl)
 
return smiapp_pll_update(sensor);
 
+   case V4L2_CID_PIXEL_RATE:
+   /* For v4l2_ctrl_s_ctrl_int64() used internally. */
+   return 0;
+
default:
return -EINVAL;
}
-- 
1.7.10.4

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


Re: [PATCH 00/43] i.MX6 Video capture

2014-06-12 Thread Philipp Zabel
Hi Steve,

[Added Russell to Cc: because of the question how to send IPU core 
 patches to drm-next]

Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:
 Hi Philipp and Sascha,
 
 First of all, thanks for the detailed review.

You are welcome. I am tasked to prepare our own capture drivers for
mainline submission, but they are not quite there yet. I'd be very
interested in getting this worked out together, especially since we
seem to be interested in orthogonal features (we had no use for the
preview and and encoder IC tasks or MIPI CSI-2 so far, but we need
media controller support and mem2mem scaling via the post-processor IC
task).
I'm going to post our current series as is, if only to illustrate my
point of view.

 I think it's obvious that this patch set should be split into two: first,
 the changes to IPU core driver submitted to drm-next, and the capture driver
 to media-tree.

I agree.

 Or, do you prefer I submit the IPU core patches to your own pengutronix git
 tree, and we can correspond on one of your internal mailing lists?

Why would we move discussion to an internal mailing list? Since we are
sitting right inbetween dri-devel and linux-media with the IPU core
code, I think either mailing list is an appropriate place for discussing
these patches, depending on the context.

 I can then leave it to you to push those changes to drm-next.

I think a central place to collect IPU core patches before sending them
off to drm-next is a good idea. I offer to do the collecting in my tree.
I also know Russell volunteered to collect and send off imx-drm patches
towards staging. Russell, I'm not sure if this offer extends to non-DRM
IPU core patches to be submitted to drm-next? (And if yes, whether you'd
rather keep at it or have this taken off your hands.)

 I agree with most of your feedback, and most is specific to the IPU core
 changes.

Excellent. For the core changes, rebasing them onto next and then
integrating some remaining changes from our patchset shouldn't be a
problem.
The big issue I have with the media parts is the missing media
controller support and the code organization around the IC tasks
instead of around hardware submodules.

  We can discuss those in detail elsewhere, but just in summary here,
 some of your comments seem to conflict:
 
 1. Regarding the input muxes to the CSI and IC, Philipp you acked those
 functions but would like to see these muxes as v4l2 subdevs and configured
 in the DT, but Sascha, you had a comment that this should be a job for
 mediactrl.

No conflict here, there are different multiplexers to talk about.

First, there are two external multiplexers controlled by IOMUXC (on
i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and
IPU_CSI0/1_MUX. They are not part of the IPU.
They each sit between a set of parallel input pads and the CSI2IPU
gasket on one side and one CSI on the other side.
In my opinion, these should be handled by separate v4l2_subdev drivers
and their connections described in the device tree. The links between
subdevices can then be controlled via the media controller framework.
This is what my comments on patches 05/43 and 08/43 are about.

Second, there are the CSI0/1_DATA_SOURCE muxes and the CSI_SEL/IC_INPUT
muxes controlled by the IPU_CONF register. These should not be described
in the device tree. Just as CSI and IC, they are an IPU internal detail.

The CSI0/1_DATA_SOURCE, if I understand correctly, muxes not the data
bus, but the 8-bit mct_di bus which carries the MIPI channel id and data
type. This should be controlled by the CSI subdevice driver directly
when choosing its input format.

The CSI_SEL/IC_INPUT multiplexer selects the input to the IC to come
from either CSI0, CSI1, or the VDI. Each of those subunits would fit
the media entity abstraction well. This multiplexer should be controlled
by the media controller framework.

I acked the CSI/IC source mux functions in patch 06/43 because I think
those functions are in the right place and useful in the above scenario.

 2. Philipp, you would like to see CSI, IC, and SMFC units moved out of IPU
 core and become v4l2 subdevs. I agree with that, but drm-next has ipu-smfc
 as part of IPU core, and SMFC is most definitely v4l2 capture specific.

About the CSI I'm just a tiny bit conflicted myself, that seems to show.

From an organizational standpoint, with all the other register access
code in gpu/ipu-v3, having the ipu-csi code in there too looks nice and
as expected. On the other hand, this should really be only used by one
v4l2_subdev driver. When I look at it this way, I see a driver that is
split in two parts, wasting exported symbol space for no very good
reason.

The IC I'd like to describe as a v4l2_subdev. But I'd also like to use
the IC from the DRM driver. So the IC core code has to stay in
gpu/ipu-v3. I'd just like to pool all V4L2 code that uses this into a IC
v4l2_subdev driver if possible. The only use we have for the IC
currently is 

The SMFC 

[RFC PATCH 25/26] ARM: dts: Add IPU aliases on i.MX6

2014-06-12 Thread Philipp Zabel
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 arch/arm/boot/dts/imx6q.dtsi   | 1 +
 arch/arm/boot/dts/imx6qdl.dtsi | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fb6185f..919a18a 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -14,6 +14,7 @@
 
 / {
aliases {
+   ipu1 = ipu2;
spi4 = ecspi5;
};
 
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 84ddc94..27303d6 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -28,6 +28,7 @@
i2c0 = i2c1;
i2c1 = i2c2;
i2c2 = i2c3;
+   ipu0 = ipu1;
mmc0 = usdhc1;
mmc1 = usdhc2;
mmc2 = usdhc3;
-- 
2.0.0.rc2

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


[RFC PATCH 03/26] gpu: ipu-v3: Add function to setup CP channel as interlaced

2014-06-12 Thread Philipp Zabel
This patch adds a function to enable line interlaced buffer scanout
and writing.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/gpu/ipu-v3/ipu-common.c | 19 +++
 include/video/imx-ipu-v3.h  |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index a4910d8..94b9e8e 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -525,6 +525,25 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_image);
 
+int ipu_ch_cpmem_set_interlaced_scan(struct ipuv3_channel *channel)
+{
+   u32 stride;
+   struct ipu_soc *ipu = channel-ipu;
+   struct ipu_ch_param __iomem *p = ipu_get_cpmem(channel);
+
+   stride = ipu_ch_param_read_field(p, IPU_FIELD_SL) + 1;
+   if (stride % 8)
+   dev_warn(ipu-dev,
+IDMAC%d's ILO is not 8-byte aligned\n, channel-num);
+
+   ipu_ch_param_write_field(p, IPU_FIELD_SO, 1);
+   ipu_ch_param_write_field(p, IPU_FIELD_ILO, stride / 8);
+   ipu_ch_param_write_field(p, IPU_FIELD_SL, 2 * stride - 1);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_ch_cpmem_set_interlaced_scan);
+
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 {
switch (pixelformat) {
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 2d14425..77a82f5 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -320,6 +320,7 @@ void ipu_cpmem_set_yuv_planar_full(struct ipu_ch_param 
__iomem *p,
 int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, u32 pixelformat);
 int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
struct ipu_image *image);
+int ipu_ch_cpmem_set_interlaced_scan(struct ipuv3_channel *channel);
 
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
-- 
2.0.0.rc2

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


[RFC PATCH 16/26] [media] ipuv3-csi: Skip 3 lines for NTSC BT.656

2014-06-12 Thread Philipp Zabel
TVP5150 creates 480 visible lines, but synchronisation
signals for 486 visible lines.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/imx-ipuv3-csi.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/imx/imx-ipuv3-csi.c 
b/drivers/media/platform/imx/imx-ipuv3-csi.c
index d9326a8..dfa2daa 100644
--- a/drivers/media/platform/imx/imx-ipuv3-csi.c
+++ b/drivers/media/platform/imx/imx-ipuv3-csi.c
@@ -698,8 +698,14 @@ static int ipucsi_videobuf_start_streaming(struct 
vb2_queue *vq, unsigned int co
 
ipu_csi_write(ipucsi, CSI_ACT_FRM_HEIGHT(yres) | 
CSI_ACT_FRM_WIDTH(xres),
CSI_ACT_FRM_SIZE);
-   ipu_csi_write(ipucsi, CSI_OUT_FRM_CTRL_HSC(0) | CSI_OUT_FRM_CTRL_VSC(0),
-   CSI_OUT_FRM_CTRL);
+   /* FIXME */
+   if (xres == 720  yres == 480) {
+   ipu_csi_write(ipucsi, CSI_OUT_FRM_CTRL_HSC(0) |
+   CSI_OUT_FRM_CTRL_VSC(3), CSI_OUT_FRM_CTRL);
+   } else {
+   ipu_csi_write(ipucsi, CSI_OUT_FRM_CTRL_HSC(0) |
+   CSI_OUT_FRM_CTRL_VSC(0), CSI_OUT_FRM_CTRL);
+   }
 
ret = media_entity_pipeline_start(ipucsi-subdev.entity, 
ipucsi-pipe);
if (ret)
-- 
2.0.0.rc2

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


[RFC PATCH 20/26] [media] imx-ipuv3-csi: Export sync lock event to userspace

2014-06-12 Thread Philipp Zabel
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/imx-ipuv3-csi.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/media/platform/imx/imx-ipuv3-csi.c 
b/drivers/media/platform/imx/imx-ipuv3-csi.c
index ab22cad..86fadd0 100644
--- a/drivers/media/platform/imx/imx-ipuv3-csi.c
+++ b/drivers/media/platform/imx/imx-ipuv3-csi.c
@@ -43,12 +43,19 @@
 #include media/v4l2-common.h
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
+#include media/v4l2-event.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
 #include media/v4l2-of.h
 
 #define DRIVER_NAME imx-ipuv3-camera
 
+#define V4L2_EVENT_SYNC_LOCK   (V4L2_EVENT_PRIVATE_START | 0x200)
+
+struct v4l2_event_sync_lock {
+   __u8 lock;
+} __attribute__ ((packed));
+
 /* CMOS Sensor Interface Registers */
 #define CSI_SENS_CONF  0x
 #define CSI_SENS_FRM_SIZE  0x0004
@@ -579,6 +586,7 @@ static void ipucsi_v4l2_dev_notify(struct v4l2_subdev *sd,
if (notification == V4L2_SUBDEV_SYNC_LOCK_NOTIFY) {
struct media_entity_graph graph;
struct media_entity *entity;
+   struct v4l2_event event;
struct ipucsi *ipucsi;
bool lock = *(bool *)arg;
 
@@ -595,6 +603,11 @@ static void ipucsi_v4l2_dev_notify(struct v4l2_subdev *sd,
ipucsi_resume_stream(ipucsi);
else
ipucsi_pause_stream(ipucsi);
+
+   memset(event, 0, sizeof(event));
+   event.type = V4L2_EVENT_SYNC_LOCK;
+   ((struct v4l2_event_sync_lock *)event.u.data)-lock = lock;
+   v4l2_event_queue(ipucsi-vdev, event);
}
 }
 
@@ -1378,6 +1391,14 @@ static int ipucsi_enum_framesizes(struct file *file, 
void *fh,
return 0;
 }
 
+static int ipucsi_subscribe_event(struct v4l2_fh *fh,
+ const struct v4l2_event_subscription *sub)
+{
+   if (sub-type == V4L2_EVENT_SYNC_LOCK)
+   return v4l2_event_subscribe(fh, sub, 0, NULL);
+   return -EINVAL;
+}
+
 static const struct v4l2_ioctl_ops ipucsi_capture_ioctl_ops = {
.vidioc_querycap= ipucsi_querycap,
 
@@ -1397,6 +1418,9 @@ static const struct v4l2_ioctl_ops 
ipucsi_capture_ioctl_ops = {
.vidioc_streamoff   = vb2_ioctl_streamoff,
 
.vidioc_enum_framesizes = ipucsi_enum_framesizes,
+
+   .vidioc_subscribe_event = ipucsi_subscribe_event,
+   .vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
 
 static int ipucsi_subdev_s_ctrl(struct v4l2_ctrl *ctrl)
-- 
2.0.0.rc2

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


[RFC PATCH 18/26] [media] ipuv3-csi: make subdev controls available on video device

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/platform/imx/imx-ipuv3-csi.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/platform/imx/imx-ipuv3-csi.c 
b/drivers/media/platform/imx/imx-ipuv3-csi.c
index e75d7f5..0dd40a4 100644
--- a/drivers/media/platform/imx/imx-ipuv3-csi.c
+++ b/drivers/media/platform/imx/imx-ipuv3-csi.c
@@ -250,6 +250,7 @@ struct ipucsi {
struct v4l2_format  format;
struct ipucsi_formatipucsifmt;
struct v4l2_ctrl_handlerctrls;
+   struct v4l2_ctrl_handlerctrls_vdev;
struct v4l2_ctrl*ctrl_test_pattern;
struct media_padmedia_pad;
struct media_pipeline   pipe;
@@ -1096,12 +1097,19 @@ int v4l2_media_subdev_s_power(struct ipucsi *ipucsi, 
int enable)
goto disable;
}
 
+   v4l2_ctrl_handler_init(ipucsi-ctrls_vdev, 1);
+
while (!ret  (entity = media_entity_graph_walk_next(graph))) {
if (media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV) {
sd = media_entity_to_v4l2_subdev(entity);
ret = v4l2_subdev_call(sd, core, s_power, 1);
if (ret == -ENOIOCTLCMD)
ret = 0;
+
+   ret = v4l2_ctrl_add_handler(ipucsi-ctrls_vdev,
+   sd-ctrl_handler, NULL);
+   if (ret)
+   return ret;
}
}
 
@@ -1147,6 +1155,8 @@ static int ipucsi_release(struct file *file)
if (v4l2_fh_is_singular_file(file)) {
v4l2_media_subdev_s_power(ipucsi, 0);
 
+   v4l2_ctrl_handler_free(ipucsi-ctrls_vdev);
+
vb2_fop_release(file);
} else {
v4l2_fh_release(file);
@@ -1320,6 +1330,7 @@ static int ipucsi_video_device_init(struct 
platform_device *pdev,
vdev-minor = -1;
vdev-release   = video_device_release_empty;
vdev-lock  = ipucsi-mutex;
+   vdev-ctrl_handler = ipucsi-ctrls_vdev;
vdev-queue = ipucsi-vb2_vidq;
 
video_set_drvdata(vdev, ipucsi);
-- 
2.0.0.rc2

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


[RFC PATCH 17/26] [media] ipuv3-csi: Pass ipucsi to v4l2_media_subdev_s_power

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

Makes it easier to access ipucsi from v4l2_media_subdev_s_power which
is needed in subsequent patches.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/platform/imx/imx-ipuv3-csi.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/imx/imx-ipuv3-csi.c 
b/drivers/media/platform/imx/imx-ipuv3-csi.c
index dfa2daa..e75d7f5 100644
--- a/drivers/media/platform/imx/imx-ipuv3-csi.c
+++ b/drivers/media/platform/imx/imx-ipuv3-csi.c
@@ -1080,8 +1080,9 @@ disable:
return ret;
 }
 
-int v4l2_media_subdev_s_power(struct media_entity *entity, int enable)
+int v4l2_media_subdev_s_power(struct ipucsi *ipucsi, int enable)
 {
+   struct media_entity *entity = ipucsi-subdev.entity;
struct media_entity_graph graph;
struct media_entity *first;
struct v4l2_subdev *sd;
@@ -1131,7 +1132,7 @@ static int ipucsi_open(struct file *file)
goto out;
 
if (v4l2_fh_is_singular_file(file))
-   ret = v4l2_media_subdev_s_power(ipucsi-subdev.entity, 1);
+   ret = v4l2_media_subdev_s_power(ipucsi, 1);
 
 out:
mutex_unlock(ipucsi-mutex);
@@ -1144,7 +1145,7 @@ static int ipucsi_release(struct file *file)
 
mutex_lock(ipucsi-mutex);
if (v4l2_fh_is_singular_file(file)) {
-   v4l2_media_subdev_s_power(ipucsi-subdev.entity, 0);
+   v4l2_media_subdev_s_power(ipucsi, 0);
 
vb2_fop_release(file);
} else {
-- 
2.0.0.rc2

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


[RFC PATCH 04/26] gpu: ipu-v3: Add ipu_cpmem_get_buffer function

2014-06-12 Thread Philipp Zabel
This is needed for imx-ipu-vout to extract the buffer address from a
saved CPMEM block.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 include/video/imx-ipu-v3.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 77a82f5..e8764dc 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -268,6 +268,15 @@ static inline void ipu_cpmem_set_buffer(struct 
ipu_ch_param __iomem *p,
ipu_ch_param_write_field(p, IPU_FIELD_EBA0, buf  3);
 }
 
+static inline dma_addr_t ipu_cpmem_get_buffer(struct ipu_ch_param __iomem *p,
+   int bufnum)
+{
+   if (bufnum)
+   return ipu_ch_param_read_field(p, IPU_FIELD_EBA1)  3;
+   else
+   return ipu_ch_param_read_field(p, IPU_FIELD_EBA0)  3;
+}
+
 static inline void ipu_cpmem_set_resolution(struct ipu_ch_param __iomem *p,
int xres, int yres)
 {
-- 
2.0.0.rc2

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


[RFC PATCH 15/26] [media] imx-ipu: Add i.MX IPUv3 capture driver

2014-06-12 Thread Philipp Zabel
This driver uses the IDMA controller's double buffering feature to do the
processing of finished frames in the new frame acknowledge (NFACK) interrupt
handler while the next frame is already being captured. This avoids a race
condition between the end of frame interrupt and NFACK for very short blanking
intervals. On the other hand, the driver needs at least two buffers. It will
never hand out any frames if there is only one.
It supports interlaced input and allows to translate between sequential and
interlaced field formats using the IDMAC scan order and interlace offset
parameters.
If the source entity connected to the CSI subdevice sink pad is a multiplexer,
the mbus_format can change dynamically when the media graph is reconfigured.
Use the current source mbus_format and only then fall back to the static
format read from the device tree.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/Kconfig |9 +
 drivers/media/platform/imx/Makefile|1 +
 drivers/media/platform/imx/imx-ipuv3-csi.c | 1527 
 3 files changed, 1537 insertions(+)
 create mode 100644 drivers/media/platform/imx/imx-ipuv3-csi.c

diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index d2f1693..8431441 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -14,6 +14,15 @@ config MEDIA_IMX_IPU
 config VIDEO_IMX_IPU_COMMON
tristate
 
+config VIDEO_IMX_IPU_CSI
+   tristate i.MX5/6 CMOS Sensor Interface driver
+   depends on VIDEO_DEV  IMX_IPUV3_CORE  MEDIA_CONTROLLER
+   select VIDEOBUF2_DMA_CONTIG
+   select VIDEO_IMX_IPU_COMMON
+   select VIDEO_IMX_IPUV3
+   ---help---
+ This is a v4l2 video capture driver for the IPUv3 on i.MX5/6.
+
 config VIDEO_IMX_IPU_SCALER
tristate i.MX5/6 IPUv3 based image scaler driver
depends on VIDEO_DEV  IMX_IPUV3_CORE
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index 60f451a..49d8fab 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MEDIA_IMX)+= imx-media.o
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
+obj-$(CONFIG_VIDEO_IMX_IPU_CSI)+= imx-ipuv3-csi.o
 obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
 obj-$(CONFIG_VIDEO_IMX_IPU_VDIC)   += imx-ipu-vdic.o
diff --git a/drivers/media/platform/imx/imx-ipuv3-csi.c 
b/drivers/media/platform/imx/imx-ipuv3-csi.c
new file mode 100644
index 000..d9326a8
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipuv3-csi.c
@@ -0,0 +1,1527 @@
+/*
+ * V4L2 Driver for i.MXL/i.MXL camera (CSI) host
+ *
+ * Copyright (C) 2008, Paulius Zaleckas paulius.zalec...@teltonika.lt
+ * Copyright (C) 2009, Darius Augulis augulis.dar...@gmail.com
+ *
+ * Based on PXA SoC camera driver
+ * Copyright (C) 2006, Sascha Hauer, Pengutronix
+ * Copyright (C) 2008, Guennadi Liakhovetski ker...@pengutronix.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/platform_device.h
+#include linux/dma-mapping.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/videodev2.h
+#include linux/version.h
+#include linux/device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/mutex.h
+#include linux/sched.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/time.h
+#include linux/clk.h
+#include linux/fs.h
+#include linux/io.h
+#include linux/mm.h
+
+#include video/imx-ipu-v3.h
+#include imx-ipu.h
+
+#include media/imx.h
+#include linux/of_graph.h
+#include media/videobuf2-dma-contig.h
+#include media/v4l2-common.h
+#include media/v4l2-device.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-dev.h
+#include media/v4l2-of.h
+
+#define DRIVER_NAME imx-ipuv3-camera
+
+/* CMOS Sensor Interface Registers */
+#define CSI_SENS_CONF  0x
+#define CSI_SENS_FRM_SIZE  0x0004
+#define CSI_ACT_FRM_SIZE   0x0008
+#define CSI_OUT_FRM_CTRL   0x000c
+#define CSI_TST_CTRL   0x0010
+#define CSI_CCIR_CODE_10x0014
+#define CSI_CCIR_CODE_20x0018
+#define CSI_CCIR_CODE_30x001c
+#define CSI_MIPI_DI0x0020
+#define CSI_SKIP   0x0024
+#define CSI_CPD_CTRL   0x0028
+#define CSI_CPD_RC(n)  (0x002c + 4 * (n))
+#define CSI_CPD_RS(n)  (0x004c + 4 * (n))
+#define CSI_CPD_GRC(n) (0x005c + 4 * (n))
+#define CSI_CPD_GRS(n) (0x007c + 4 * (n))
+#define CSI_CPD_GBC(n) (0x008c + 4 * (n))
+#define CSI_CPD_GBS(n) (0x00ac + 

[RFC PATCH 26/26] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections

2014-06-12 Thread Philipp Zabel
This patch adds the device tree graph connecting the input multiplexers
to the IPU CSIs and the MIPI-CSI2 gasket on i.MX6. The MIPI_IPU multiplexers
are added as children of the iomuxc-gpr syscon device node.
On i.MX6Q/D two two-input multiplexers in front of IPU1 CSI0 and IPU2 CSI1
allow to select between CSI0/1 parallel input pads and the MIPI CSI-2 virtual
channels 0/3.
On i.MX6DL/S two five-input multiplexers in front of IPU1 CSI0 and IPU1 CSI1
allow to select between CSI0/1 parallel input pads and any of the four MIPI
CSI-2 virtual channels.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 arch/arm/boot/dts/imx6dl.dtsi  | 182 +
 arch/arm/boot/dts/imx6q.dtsi   | 118 ++
 arch/arm/boot/dts/imx6qdl.dtsi |   8 ++
 3 files changed, 308 insertions(+)

diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi
index 5c5f574..619c7ce 100644
--- a/arch/arm/boot/dts/imx6dl.dtsi
+++ b/arch/arm/boot/dts/imx6dl.dtsi
@@ -110,3 +110,185 @@
  di0_sel, di1_sel,
  di0, di1;
 };
+
+gpr {
+   ipu_csi0_mux {
+   compatible = video-multiplexer;
+   reg = 0x34;
+   bit-mask = 0x7;
+   bit-shift = 0;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   port@0 {
+   reg = 0;
+
+   ipu_csi0_mux_from_mipi_csi0: endpoint {
+   remote-endpoint = mipi_csi0_to_ipu_csi0_mux;
+   };
+   };
+
+   port@1 {
+   reg = 1;
+
+   ipu_csi0_mux_from_mipi_csi1: endpoint {
+   remote-endpoint = mipi_csi1_to_ipu_csi0_mux;
+   };
+   };
+
+   port@2 {
+   reg = 2;
+
+   ipu_csi0_mux_from_mipi_csi2: endpoint {
+   remote-endpoint = mipi_csi2_to_ipu_csi0_mux;
+   };
+   };
+
+   port@3 {
+   reg = 3;
+
+   ipu_csi0_mux_from_mipi_csi3: endpoint {
+   remote-endpoint = mipi_csi3_to_ipu_csi0_mux;
+   };
+   };
+
+   csi0: port@4 {
+   reg = 4;
+   };
+
+   port@5 {
+   reg = 5;
+
+   ipu_csi0_mux_to_ipu1_csi0: endpoint {
+   remote-endpoint = 
ipu1_csi0_from_ipu_csi0_mux;
+   };
+   };
+   };
+
+   ipu_csi1_mux {
+   compatible = video-multiplexer;
+   reg = 0x34;
+   bit-mask = 0x7;
+   bit-shift = 0;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   port@0 {
+   reg = 0;
+
+   ipu_csi1_mux_from_mipi_csi0: endpoint {
+   remote-endpoint = mipi_csi0_to_ipu_csi1_mux;
+   };
+   };
+
+   port@1 {
+   reg = 1;
+
+   ipu_csi1_mux_from_mipi_csi1: endpoint {
+   remote-endpoint = mipi_csi1_to_ipu_csi1_mux;
+   };
+   };
+
+   port@2 {
+   reg = 2;
+
+   ipu_csi1_mux_from_mipi_csi2: endpoint {
+   remote-endpoint = mipi_csi2_to_ipu_csi1_mux;
+   };
+   };
+
+   port@3 {
+   reg = 3;
+
+   ipu_csi1_mux_from_mipi_csi3: endpoint {
+   remote-endpoint = mipi_csi3_to_ipu_csi1_mux;
+   };
+   };
+
+   csi1: port@4 {
+   reg = 4;
+   };
+
+   port@5 {
+   reg = 5;
+
+   ipu_csi1_mux_to_ipu1_csi1: endpoint {
+   remote-endpoint = 
ipu1_csi1_from_ipu_csi1_mux;
+   };
+   };
+   };
+};
+
+ipu1_csi0 {
+   ipu1_csi0_from_ipu_csi0_mux: endpoint {
+   remote-endpoint = ipu_csi0_mux_to_ipu1_csi0;
+   };
+};
+
+ipu1_csi1 {
+   ipu1_csi1_from_ipu_csi1_mux: endpoint {
+   remote-endpoint = ipu_csi1_mux_to_ipu1_csi1;
+   };
+};
+
+mipi_csi {
+   port@0 {
+   reg = 0;
+   };
+
+   port@1 {
+   reg = 1;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   mipi_csi0_to_ipu_csi0_mux: endpoint@0 {
+   remote-endpoint = ipu_csi0_mux_from_mipi_csi0;
+   };
+
+   mipi_csi0_to_ipu_csi1_mux: endpoint@1 {
+   remote-endpoint = 

[RFC PATCH 14/26] [media] Add i.MX SoC wide media device driver

2014-06-12 Thread Philipp Zabel
This driver registers a single, SoC wide media device, which all entities
in the media graph can be registered with via OF graph bindings.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/Kconfig |   2 +
 drivers/media/platform/imx/Kconfig |  13 +++
 drivers/media/platform/imx/Makefile|   1 +
 drivers/media/platform/imx/imx-media.c | 174 +
 include/media/imx.h|  25 +
 5 files changed, 215 insertions(+)
 create mode 100644 drivers/media/platform/imx/imx-media.c
 create mode 100644 include/media/imx.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 8e9c26c..3fe7e28 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -35,6 +35,8 @@ source drivers/media/platform/omap/Kconfig
 
 source drivers/media/platform/blackfin/Kconfig
 
+source drivers/media/platform/imx/Kconfig
+
 config VIDEO_SH_VOU
tristate SuperH VOU video output driver
depends on MEDIA_CAMERA_SUPPORT
diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index 506326a..d2f1693 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -1,3 +1,16 @@
+config MEDIA_IMX
+   tristate Multimedia Support for Freescale i.MX
+   depends on MEDIA_CONTROLLER
+   ---help---
+ This driver provides a SoC wide media controller device that all
+ multimedia components in i.MX5 and i.MX6 SoCs can register with.
+
+config MEDIA_IMX_IPU
+   tristate i.MX Image Processing Unit (v3) core driver
+   ---help---
+ This driver provides core support for the i.MX IPUv3 contained in
+ i.MX5 and i.MX6 SoCs.
+
 config VIDEO_IMX_IPU_COMMON
tristate
 
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index 5c9da82..60f451a 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_MEDIA_IMX)+= imx-media.o
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
 obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
 obj-$(CONFIG_VIDEO_IMX_IPU_VDIC)   += imx-ipu-vdic.o
diff --git a/drivers/media/platform/imx/imx-media.c 
b/drivers/media/platform/imx/imx-media.c
new file mode 100644
index 000..ae63c49
--- /dev/null
+++ b/drivers/media/platform/imx/imx-media.c
@@ -0,0 +1,174 @@
+#include linux/module.h
+#include linux/export.h
+#include linux/types.h
+#include linux/init.h
+#include linux/err.h
+#include linux/spinlock.h
+#include linux/delay.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/of_device.h
+#include linux/of_graph.h
+#include media/media-device.h
+#include media/v4l2-device.h
+#include video/imx-ipu-v3.h
+
+struct ipu_media_controller {
+   struct v4l2_device v4l2_dev;
+   struct media_device mdev;
+};
+
+static struct ipu_media_controller *ipu_media;
+
+struct media_device *ipu_find_media_device(void)
+{
+   return ipu_media-mdev;
+}
+EXPORT_SYMBOL_GPL(ipu_find_media_device);
+
+struct ipu_media_link {
+   struct v4l2_async_notifier  asn;
+   struct v4l2_async_subdevasd;
+   struct v4l2_async_subdev*asdp;
+   struct v4l2_subdev  *sd;
+   int padno;
+   struct device_node  *endpoint;
+   u32 media_link_flags;
+};
+
+static int ipu_media_bound(struct v4l2_async_notifier *notifier,
+  struct v4l2_subdev *sd,
+  struct v4l2_async_subdev *asd)
+{
+   struct ipu_media_controller *im = ipu_media;
+   struct ipu_media_link *link = container_of(notifier,
+  struct ipu_media_link, asn);
+   struct device_node *np, *rp;
+   uint32_t portno = 0;
+   int ret;
+
+   if ((sd-flags  V4L2_SUBDEV_FL_HAS_DEVNODE)) {
+   ret = v4l2_device_register_subdev_node(im-v4l2_dev, sd);
+   if (ret)
+   return ret;
+   }
+
+   np = link-endpoint;
+   rp = of_graph_get_remote_port(np);
+   of_property_read_u32(rp, reg, portno);
+
+   ret = media_entity_create_link(sd-entity, portno, link-sd-entity,
+   link-padno, link-media_link_flags);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void ipu_media_unbind(struct v4l2_async_notifier *notifier,
+struct v4l2_subdev *sd,
+struct v4l2_async_subdev *asd)
+{
+   if ((sd-flags  V4L2_SUBDEV_FL_HAS_DEVNODE)) {
+   video_unregister_device(sd-devnode);
+   kfree(sd-devnode);
+   }
+}
+
+struct ipu_media_link *ipu_media_entity_create_link(struct v4l2_subdev *sd,
+   int padno, struct device_node *endpoint,
+   u32 media_link_flags)
+{
+  

[RFC PATCH 21/26] [media] v4l2-subdev.h: Add lock status notification

2014-06-12 Thread Philipp Zabel
This notification type can be used by ADC converters with their
own interrupt handler to notify the bridge or capture interface
driver about the signal lock status.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 include/media/v4l2-subdev.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 28f4d8c..0af5e08 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -40,6 +40,9 @@
 #define V4L2_SUBDEV_IR_TX_NOTIFY   _IOW('v', 1, u32)
 #define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x0001
 
+#define V4L2_SUBDEV_SYNC_LOCK_NOTIFY   _IOW('v', 2, u32)
+#define V4L2_SUBDEV_SYNC_LOCK  0x0001
+
 struct v4l2_device;
 struct v4l2_ctrl_handler;
 struct v4l2_event_subscription;
-- 
2.0.0.rc2

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


[RFC PATCH 02/26] gpu: ipu-v3: Register IC with IPUv3

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/gpu/ipu-v3/ipu-common.c | 35 +++
 drivers/gpu/ipu-v3/ipu-prv.h|  6 ++
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 719788c..a4910d8 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -914,8 +914,18 @@ static int ipu_submodules_init(struct ipu_soc *ipu,
goto err_smfc;
}
 
+   ret = ipu_ic_init(ipu, dev, ipu_base + devtype-cm_ofs +
+   IPU_CM_IC_REG_OFS, ipu_base + devtype-tpm_ofs,
+   ipu_base + devtype-vdi_ofs);
+   if (ret) {
+   unit = ic;
+   goto err_ic;
+   }
+
return 0;
 
+err_ic:
+   ipu_smfc_exit(ipu);
 err_smfc:
ipu_dp_exit(ipu);
 err_dp:
@@ -995,6 +1005,7 @@ static void ipu_submodules_exit(struct ipu_soc *ipu)
ipu_dc_exit(ipu);
ipu_di_exit(ipu, 1);
ipu_di_exit(ipu, 0);
+   ipu_ic_exit(ipu);
 }
 
 static int platform_remove_devices_fn(struct device *dev, void *unused)
@@ -1052,6 +1063,18 @@ static const struct ipu_platform_reg client_reg[] = {
},
.reg_offset = IPU_CM_CSI1_REG_OFS,
.name = imx-ipuv3-camera,
+   }, {
+   .pdata = {
+   .dma[0] = IPUV3_CHANNEL_MEM_FG_SYNC,
+   },
+   .name = imx-ipuv3-scaler,
+   }, {
+   .pdata = {
+   .dma[0] = IPUV3_CHANNEL_MEM_FG_SYNC,
+   },
+   .name = imx-ipuv3-ovl,
+   }, {
+   .name = imx-ipuv3-vdic,
},
 };
 
@@ -1179,6 +1202,7 @@ static int ipu_probe(struct platform_device *pdev)
unsigned long ipu_base;
int i, ret, irq_sync, irq_err;
const struct ipu_devtype *devtype;
+   u32 reg;
 
devtype = of_id-data;
 
@@ -1272,6 +1296,9 @@ static int ipu_probe(struct platform_device *pdev)
if (ret)
goto out_failed_reset;
 
+   /* Set sync refresh channels as high priority */
+   ipu_idmac_write(ipu, 0x1880, IDMAC_CHA_PRI(0));
+
/* Set MCU_T to divide MCU access window into 2 */
ipu_cm_write(ipu, 0x0040L | (IPU_MCU_T_DEFAULT  18),
IPU_DISP_GEN);
@@ -1280,6 +1307,14 @@ static int ipu_probe(struct platform_device *pdev)
if (ret)
goto failed_submodules_init;
 
+   reg = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+   reg |= (5  24);
+   ipu_cm_write(ipu, reg, IPU_FS_PROC_FLOW1);
+
+   reg = ipu_cm_read(ipu, IPU_CONF);
+   reg |= IPU_CONF_IC_INPUT;
+   ipu_cm_write(ipu, reg, IPU_CONF);
+
ret = ipu_add_client_devices(ipu, ipu_base);
if (ret) {
dev_err(pdev-dev, adding client devices failed with %d\n,
diff --git a/drivers/gpu/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h
index acf1811..e869ac1 100644
--- a/drivers/gpu/ipu-v3/ipu-prv.h
+++ b/drivers/gpu/ipu-v3/ipu-prv.h
@@ -152,6 +152,7 @@ struct ipu_dc_priv;
 struct ipu_dmfc_priv;
 struct ipu_di;
 struct ipu_smfc_priv;
+struct ipu_ic_priv;
 
 struct ipu_devtype;
 
@@ -181,6 +182,7 @@ struct ipu_soc {
struct ipu_dmfc_priv*dmfc_priv;
struct ipu_di   *di_priv[2];
struct ipu_smfc_priv*smfc_priv;
+   struct ipu_ic_priv  *ic_priv;
 };
 
 void ipu_srm_dp_sync_update(struct ipu_soc *ipu);
@@ -209,4 +211,8 @@ void ipu_cpmem_exit(struct ipu_soc *ipu);
 int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev, unsigned long base);
 void ipu_smfc_exit(struct ipu_soc *ipu);
 
+int ipu_ic_init(struct ipu_soc *ipu, struct device *dev, unsigned long ic_base,
+   unsigned long tpm_base, unsigned long vdi_base);
+void ipu_ic_exit(struct ipu_soc *ipu);
+
 #endif /* __IPU_PRV_H__ */
-- 
2.0.0.rc2

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


[RFC PATCH 22/26] [media] v4l2-subdev: Export v4l2_subdev_fops

2014-06-12 Thread Philipp Zabel
This is needed by the imx-ipuv3-csi driver when compiled as a module.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/v4l2-core/v4l2-subdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index aea84ac..c4dc495 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -406,6 +406,7 @@ const struct v4l2_file_operations v4l2_subdev_fops = {
.release = subdev_close,
.poll = subdev_poll,
 };
+EXPORT_SYMBOL_GPL(v4l2_subdev_fops);
 
 #ifdef CONFIG_MEDIA_CONTROLLER
 int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
-- 
2.0.0.rc2

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


[RFC PATCH 08/26] [media] imx-ipu: add ipu media common code

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

Add video4linux API routines common to IPU scaler, overlay, and deinterlacer
drivers.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Lucas Stach l.st...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/Kconfig   |   2 +
 drivers/media/platform/Makefile  |   1 +
 drivers/media/platform/imx/Kconfig   |   2 +
 drivers/media/platform/imx/Makefile  |   1 +
 drivers/media/platform/imx/imx-ipu.c | 313 +++
 drivers/media/platform/imx/imx-ipu.h |  35 
 6 files changed, 354 insertions(+)
 create mode 100644 drivers/media/platform/imx/Kconfig
 create mode 100644 drivers/media/platform/imx/Makefile
 create mode 100644 drivers/media/platform/imx/imx-ipu.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 20f1655..8e9c26c 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -29,6 +29,8 @@ config VIDEO_VIA_CAMERA
 
 source drivers/media/platform/davinci/Kconfig
 
+source drivers/media/platform/imx/Kconfig
+
 source drivers/media/platform/omap/Kconfig
 
 source drivers/media/platform/blackfin/Kconfig
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index e5269da..ba114c0 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_SOC_CAMERA)  += soc_camera/
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
 obj-y  += davinci/
+obj-y  += imx/
 
 obj-$(CONFIG_ARCH_OMAP)+= omap/
 
diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
new file mode 100644
index 000..a90c973
--- /dev/null
+++ b/drivers/media/platform/imx/Kconfig
@@ -0,0 +1,2 @@
+config VIDEO_IMX_IPU_COMMON
+   tristate
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
new file mode 100644
index 000..5de119c
--- /dev/null
+++ b/drivers/media/platform/imx/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
diff --git a/drivers/media/platform/imx/imx-ipu.c 
b/drivers/media/platform/imx/imx-ipu.c
new file mode 100644
index 000..c1b8637
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipu.c
@@ -0,0 +1,313 @@
+/*
+ * i.MX IPUv3 common v4l2 support
+ *
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix
+ *
+ * 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.
+ */
+#include linux/module.h
+#include media/v4l2-common.h
+#include media/v4l2-dev.h
+#include media/v4l2-ioctl.h
+
+#include imx-ipu.h
+
+static struct ipu_fmt ipu_fmt_yuv[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_YUV420,
+   .name = YUV 4:2:0 planar, YCbCr,
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YVU420,
+   .name = YUV 4:2:0 planar, YCrCb,
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YUV422P,
+   .name = YUV 4:2:2 planar, YCbCr,
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_NV12,
+   .name = YUV 4:2:0 partial interleaved, YCbCr,
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_UYVY,
+   .name = 4:2:2, packed, UYVY,
+   .bytes_per_pixel = 2,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YUYV,
+   .name = 4:2:2, packed, YUYV,
+   .bytes_per_pixel = 2,
+   },
+};
+
+static struct ipu_fmt ipu_fmt_rgb[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_RGB32,
+   .name = RGB888,
+   .bytes_per_pixel = 4,
+   }, {
+   .fourcc = V4L2_PIX_FMT_RGB24,
+   .name = RGB24,
+   .bytes_per_pixel = 3,
+   }, {
+   .fourcc = V4L2_PIX_FMT_BGR24,
+   .name = BGR24,
+   .bytes_per_pixel = 3,
+   }, {
+   .fourcc = V4L2_PIX_FMT_RGB565,
+   .name = RGB565,
+   .bytes_per_pixel = 2,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_BGR32,
+   .name = BGR888,
+   .bytes_per_pixel = 4,
+   },
+};
+
+struct ipu_fmt *ipu_find_fmt_yuv(unsigned int pixelformat)
+{
+   struct ipu_fmt *fmt;
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(ipu_fmt_yuv); i++) {
+   fmt = ipu_fmt_yuv[i];
+   if (fmt-fourcc == 

[RFC PATCH 07/26] imx-drm: currently only IPUv3 is supported, make it mandatory

2014-06-12 Thread Philipp Zabel
As long as only IPUv3 is supported in imx-drm, hide the separate
DRM_IMX_IPUV3 option and make DRM_IMX depend on IMX_IPUV3_CORE.

Reported-by: Michael Olbrich m.olbr...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/staging/imx-drm/Kconfig | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig
index 82fb758..ab31848 100644
--- a/drivers/staging/imx-drm/Kconfig
+++ b/drivers/staging/imx-drm/Kconfig
@@ -6,6 +6,7 @@ config DRM_IMX
select DRM_GEM_CMA_HELPER
select DRM_KMS_CMA_HELPER
depends on DRM  (ARCH_MXC || ARCH_MULTIPLATFORM)
+   depends on IMX_IPUV3_CORE
help
  enable i.MX graphics support
 
@@ -40,11 +41,11 @@ config DRM_IMX_LDB
  found on i.MX53 and i.MX6 processors.
 
 config DRM_IMX_IPUV3
-   tristate DRM Support for i.MX IPUv3
+   tristate
depends on DRM_IMX
depends on IMX_IPUV3_CORE
-   help
- Choose this if you have a i.MX5 or i.MX6 processor.
+   default y if DRM_IMX=y
+   default m if DRM_IMX=m
 
 config DRM_IMX_HDMI
tristate Freescale i.MX DRM HDMI
-- 
2.0.0.rc2

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


[RFC PATCH 11/26] [media] v4l2: subdev: Add v4l2_device_register_subdev_node function

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

We currently only have a function that registers all subdev
device nodes for a v4l2 device at once. This assumes that
there is a point when all subdevices are known and that all
subdevices are needed to make a functional device. With the
advent of asynchronous subdevices this may no longer be the
case, so add a function which registers a single subdevice for
a given v4l2 device only and let v4l2_device_register_subdev_nodes
use this function.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/v4l2-core/v4l2-device.c | 63 ---
 include/media/v4l2-device.h   |  5 +++
 2 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-device.c 
b/drivers/media/v4l2-core/v4l2-device.c
index 02d1b63..4211163 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -205,9 +205,43 @@ static void v4l2_device_release_subdev_node(struct 
video_device *vdev)
kfree(vdev);
 }
 
-int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
+int v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev,
+   struct v4l2_subdev *sd)
 {
struct video_device *vdev;
+   int err;
+
+   if (!(sd-flags  V4L2_SUBDEV_FL_HAS_DEVNODE))
+   return 0;
+
+   vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
+   if (!vdev)
+   return -ENOMEM;
+
+   video_set_drvdata(vdev, sd);
+   strlcpy(vdev-name, sd-name, sizeof(vdev-name));
+   vdev-v4l2_dev = v4l2_dev;
+   vdev-fops = v4l2_subdev_fops;
+   vdev-release = v4l2_device_release_subdev_node;
+   vdev-ctrl_handler = sd-ctrl_handler;
+   err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1,
+ sd-owner);
+   if (err  0) {
+   kfree(vdev);
+   return err;
+   }
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   sd-entity.info.v4l.major = VIDEO_MAJOR;
+   sd-entity.info.v4l.minor = vdev-minor;
+#endif
+   sd-devnode = vdev;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_device_register_subdev_node);
+
+int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
+{
struct v4l2_subdev *sd;
int err;
 
@@ -215,32 +249,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device 
*v4l2_dev)
 * V4L2_SUBDEV_FL_HAS_DEVNODE flag.
 */
list_for_each_entry(sd, v4l2_dev-subdevs, list) {
-   if (!(sd-flags  V4L2_SUBDEV_FL_HAS_DEVNODE))
-   continue;
-
-   vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
-   if (!vdev) {
-   err = -ENOMEM;
-   goto clean_up;
-   }
-
-   video_set_drvdata(vdev, sd);
-   strlcpy(vdev-name, sd-name, sizeof(vdev-name));
-   vdev-v4l2_dev = v4l2_dev;
-   vdev-fops = v4l2_subdev_fops;
-   vdev-release = v4l2_device_release_subdev_node;
-   vdev-ctrl_handler = sd-ctrl_handler;
-   err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1,
- sd-owner);
-   if (err  0) {
-   kfree(vdev);
+   err = v4l2_device_register_subdev_node(v4l2_dev, sd);
+   if (err)
goto clean_up;
-   }
-#if defined(CONFIG_MEDIA_CONTROLLER)
-   sd-entity.info.v4l.major = VIDEO_MAJOR;
-   sd-entity.info.v4l.minor = vdev-minor;
-#endif
-   sd-devnode = vdev;
}
return 0;
 
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index c9b1593..512cc4b 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -120,6 +120,11 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
 int __must_check
 v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
 
+/* Register a single device node for a subdev of a v4l2 device. */
+int __must_check
+v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev,
+   struct v4l2_subdev *sd);
+
 /* Iterate over all subdevs. */
 #define v4l2_device_for_each_subdev(sd, v4l2_dev)  \
list_for_each_entry(sd, (v4l2_dev)-subdevs, list)
-- 
2.0.0.rc2

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


[RFC PATCH 13/26] [media] v4l2 async: remove from notifier list

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

In v4l2_async_notifier_register remove the notifier from the notifier
list in case of an error.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/v4l2-core/v4l2-async.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 85a6a34..1e1e58c 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -173,6 +173,7 @@ int v4l2_async_notifier_register(struct v4l2_device 
*v4l2_dev,
 
ret = v4l2_async_test_notify(notifier, sd, asd);
if (ret  0) {
+   list_del(notifier-list);
mutex_unlock(list_lock);
return ret;
}
-- 
2.0.0.rc2

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


[RFC PATCH 00/26] i.MX5/6 IPUv3 CSI/IC

2014-06-12 Thread Philipp Zabel
Hi,

attached is a series of our work in progress i.MX6 capture drivers.
I'm posting this now in reaction to Steve's i.MX6 Video capture series,
as a reference for further discussion.
Of the Image Converter (IC) we only use the postprocessor task, with
tiling for larger frames, to implement v4l2 mem2mem scaler/colorspace
converter and deinterlacer devices.
The capture code capture code already uses the media controller framework
and creates a subdevice representing the CSI, but the path to memory is
fixed to IDMAC via SMFC, which is the only possible path for grayscale
and  and anything with multiple output ports connected
to the CSIs (such as the CSI2IPU gasket on i.MX6) doesn't work yet. Also,
I think the CSI subdevice driver should be completely separate from the
capture driver.

regards
Philipp

Philipp Zabel (16):
  gpu: ipu-v3: Add function to setup CP channel as interlaced
  gpu: ipu-v3: Add ipu_cpmem_get_buffer function
  gpu: ipu-v3: Add support for partial interleaved YCbCr 4:2:0 (NV12)
format
  gpu: ipu-v3: Add support for planar YUV 4:2:2 (YUV422P) format
  imx-drm: currently only IPUv3 is supported, make it mandatory
  [media] Add i.MX SoC wide media device driver
  [media] imx-ipu: Add i.MX IPUv3 capture driver
  [media] ipuv3-csi: Skip 3 lines for NTSC BT.656
  [media] imx-ipuv3-csi: Add support for temporarily stopping the stream
on sync loss
  [media] imx-ipuv3-csi: Export sync lock event to userspace
  [media] v4l2-subdev.h: Add lock status notification
  [media] v4l2-subdev: Export v4l2_subdev_fops
  mfd: syscon: add child device support
  [media] imx: Add video switch
  ARM: dts: Add IPU aliases on i.MX6
  ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their
connections

Sascha Hauer (10):
  gpu: ipu-v3: Add IC support
  gpu: ipu-v3: Register IC with IPUv3
  [media] imx-ipu: add ipu media common code
  [media] imx-ipu: Add i.MX IPUv3 scaler driver
  [media] imx-ipu: Add i.MX IPUv3 deinterlacer driver
  [media] v4l2: subdev: Add v4l2_device_register_subdev_node function
  [media] v4l2: Fix V4L2_CID_PIXEL_RATE
  [media] v4l2 async: remove from notifier list
  [media] ipuv3-csi: Pass ipucsi to v4l2_media_subdev_s_power
  [media] ipuv3-csi: make subdev controls available on video device

 Documentation/devicetree/bindings/mfd/syscon.txt |   11 +
 arch/arm/boot/dts/imx6dl.dtsi|  182 +++
 arch/arm/boot/dts/imx6q.dtsi |  119 ++
 arch/arm/boot/dts/imx6qdl.dtsi   |9 +
 drivers/gpu/ipu-v3/Makefile  |2 +-
 drivers/gpu/ipu-v3/ipu-common.c  |  119 ++
 drivers/gpu/ipu-v3/ipu-ic.c  | 1227 +++
 drivers/gpu/ipu-v3/ipu-prv.h |6 +
 drivers/media/platform/Kconfig   |4 +
 drivers/media/platform/Makefile  |1 +
 drivers/media/platform/imx/Kconfig   |   50 +
 drivers/media/platform/imx/Makefile  |6 +
 drivers/media/platform/imx/imx-ipu-scaler.c  |  825 +++
 drivers/media/platform/imx/imx-ipu-vdic.c|  716 +
 drivers/media/platform/imx/imx-ipu.c |  313 
 drivers/media/platform/imx/imx-ipu.h |   36 +
 drivers/media/platform/imx/imx-ipuv3-csi.c   | 1729 ++
 drivers/media/platform/imx/imx-media.c   |  174 +++
 drivers/media/platform/imx/imx-video-switch.c|  347 +
 drivers/media/v4l2-core/v4l2-async.c |1 +
 drivers/media/v4l2-core/v4l2-ctrls.c |8 +-
 drivers/media/v4l2-core/v4l2-device.c|   63 +-
 drivers/media/v4l2-core/v4l2-subdev.c|1 +
 drivers/mfd/syscon.c |3 +
 drivers/staging/imx-drm/Kconfig  |7 +-
 include/media/imx.h  |   25 +
 include/media/v4l2-device.h  |5 +
 include/media/v4l2-subdev.h  |3 +
 include/video/imx-ipu-v3.h   |   16 +
 29 files changed, 5976 insertions(+), 32 deletions(-)
 create mode 100644 drivers/gpu/ipu-v3/ipu-ic.c
 create mode 100644 drivers/media/platform/imx/Kconfig
 create mode 100644 drivers/media/platform/imx/Makefile
 create mode 100644 drivers/media/platform/imx/imx-ipu-scaler.c
 create mode 100644 drivers/media/platform/imx/imx-ipu-vdic.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.h
 create mode 100644 drivers/media/platform/imx/imx-ipuv3-csi.c
 create mode 100644 drivers/media/platform/imx/imx-media.c
 create mode 100644 drivers/media/platform/imx/imx-video-switch.c
 create mode 100644 include/media/imx.h

-- 
2.0.0.rc2

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


[RFC PATCH 23/26] mfd: syscon: add child device support

2014-06-12 Thread Philipp Zabel
For devices which have a complete register for themselves, it is possible to
place them next to the syscon device with overlapping reg ranges. The same is
not possible for devices which only occupy bitfields in registers shared with
other users.
For devices that are completely controlled by bitfields in the syscon address
range, such as multiplexers or voltage regulators, allow to put child devices
into the syscon device node.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 Documentation/devicetree/bindings/mfd/syscon.txt | 11 +++
 drivers/mfd/syscon.c |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt 
b/Documentation/devicetree/bindings/mfd/syscon.txt
index fe8150b..a7e11d5 100644
--- a/Documentation/devicetree/bindings/mfd/syscon.txt
+++ b/Documentation/devicetree/bindings/mfd/syscon.txt
@@ -9,10 +9,21 @@ using a specific compatible value), interrogate the node (or 
associated
 OS driver) to determine the location of the registers, and access the
 registers directly.
 
+Optionally, devices that are only controlled through single syscon
+registers or bitfields can also be added as child nodes to the syscon
+device node. These devices can implicitly assume their parent node
+as syscon provider without referencing it explicitly via phandle.
+In this case, the syscon node should have #address-cells = 1 and
+#size-cells = 0 and no ranges property.
+
 Required properties:
 - compatible: Should contain syscon.
 - reg: the register region can be accessed from syscon
 
+Optional properties:
+- #address-cells: Should be 1.
+- #size-cells: Should be 0.
+
 Examples:
 gpr: iomuxc-gpr@020e {
compatible = fsl,imx6q-iomuxc-gpr, syscon;
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index dbea55d..4b5d237 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -147,6 +147,9 @@ static int syscon_probe(struct platform_device *pdev)
 
dev_dbg(dev, regmap %pR registered\n, res);
 
+   if (!of_device_is_compatible(pdev-dev.of_node, simple-bus))
+   of_platform_populate(pdev-dev.of_node, NULL, NULL, pdev-dev);
+
return 0;
 }
 
-- 
2.0.0.rc2

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


[RFC PATCH 06/26] gpu: ipu-v3: Add support for planar YUV 4:2:2 (YUV422P) format

2014-06-12 Thread Philipp Zabel
From: Philipp Zabel philipp.za...@gmail.com

Signed-off-by: Philipp Zabel philipp.za...@gmail.com
---
 drivers/gpu/ipu-v3/ipu-common.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 7a0b377..cd4f584 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -251,6 +251,7 @@ void ipu_cpmem_set_yuv_planar_full(struct ipu_ch_param 
__iomem *p,
 {
switch (pixel_format) {
case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YUV422P:
ipu_ch_param_write_field(p, IPU_FIELD_SLUV, (stride / 2) - 1);
ipu_ch_param_write_field(p, IPU_FIELD_UBO, u_offset / 8);
ipu_ch_param_write_field(p, IPU_FIELD_VBO, v_offset / 8);
@@ -284,6 +285,13 @@ void ipu_cpmem_set_yuv_planar(struct ipu_ch_param __iomem 
*p, u32 pixel_format,
ipu_cpmem_set_yuv_planar_full(p, pixel_format, stride,
u_offset, v_offset);
break;
+   case V4L2_PIX_FMT_YUV422P:
+   uv_stride = stride / 2;
+   u_offset = stride * height;
+   v_offset = u_offset + (uv_stride * height);
+   ipu_cpmem_set_yuv_planar_full(p, pixel_format, stride,
+   u_offset, v_offset);
+   break;
case V4L2_PIX_FMT_NV12:
u_offset = v_offset = stride * height;
ipu_cpmem_set_yuv_planar_full(p, pixel_format, stride,
@@ -347,6 +355,11 @@ static const struct ipu_rgb def_bgr_16 = {
 #define V_OFFSET(pix, x, y)((pix-width * pix-height) + \
(pix-width * pix-height / 4) + \
(pix-width * (y) / 4) + (x) / 2)
+#define U_OFFSET2(pix, x, y)   ((pix-width * pix-height) + \
+   (pix-width * (y) / 2) + (x) / 2)
+#define V_OFFSET2(pix, x, y)   ((pix-width * pix-height) + \
+   (pix-width * pix-height / 2) + \
+   (pix-width * (y) / 2) + (x) / 2)
 
 int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, u32 drm_fourcc)
 {
@@ -358,6 +371,11 @@ int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, 
u32 drm_fourcc)
/* burst size */
ipu_ch_param_write_field(cpmem, IPU_FIELD_NPB, 63);
break;
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   ipu_ch_param_write_field(cpmem, IPU_FIELD_PFS, 1);
+   ipu_ch_param_write_field(cpmem, IPU_FIELD_NPB, 63);
+   break;
case DRM_FORMAT_NV12:
ipu_ch_param_write_field(cpmem, IPU_FIELD_PFS, 4);
ipu_ch_param_write_field(cpmem, IPU_FIELD_NPB, 63);
@@ -447,6 +465,8 @@ static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat)
return DRM_FORMAT_YUV420;
case V4L2_PIX_FMT_YVU420:
return DRM_FORMAT_YVU420;
+   case V4L2_PIX_FMT_YUV422P:
+   return DRM_FORMAT_YUV422;
case V4L2_PIX_FMT_NV12:
return DRM_FORMAT_NV12;
}
@@ -474,6 +494,8 @@ enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 
drm_fourcc)
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YUV420:
case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
case DRM_FORMAT_NV12:
return IPUV3_COLORSPACE_YUV;
default:
@@ -511,6 +533,17 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
pix-bytesperline, u_offset, v_offset);
ipu_cpmem_set_buffer(cpmem, 0, image-phys + y_offset);
break;
+   case V4L2_PIX_FMT_YUV422P:
+   y_offset = Y_OFFSET(pix, image-rect.left, image-rect.top);
+   u_offset = U_OFFSET2(pix, image-rect.left,
+   image-rect.top) - y_offset;
+   v_offset = V_OFFSET2(pix, image-rect.left,
+   image-rect.top) - y_offset;
+
+   ipu_cpmem_set_yuv_planar_full(cpmem, pix-pixelformat,
+   pix-bytesperline, u_offset, v_offset);
+   ipu_cpmem_set_buffer(cpmem, 0, image-phys + y_offset);
+   break;
case V4L2_PIX_FMT_NV12:
y_offset = Y_OFFSET(pix, image-rect.left, image-rect.top);
u_offset = U_OFFSET(pix, image-rect.left,
@@ -579,6 +612,7 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 
pixelformat)
switch (pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
+   case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_NV12:
-- 
2.0.0.rc2

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

[RFC PATCH 24/26] [media] imx: Add video switch

2014-06-12 Thread Philipp Zabel
This driver can handle SoC internal and extern video bus multiplexers,
controlled either by register bit fields or by GPIO.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/Kconfig|   8 +
 drivers/media/platform/imx/Makefile   |   1 +
 drivers/media/platform/imx/imx-video-switch.c | 347 ++
 3 files changed, 356 insertions(+)
 create mode 100644 drivers/media/platform/imx/imx-video-switch.c

diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index 8431441..ffced1c 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -11,6 +11,14 @@ config MEDIA_IMX_IPU
  This driver provides core support for the i.MX IPUv3 contained in
  i.MX5 and i.MX6 SoCs.
 
+config MEDIA_IMX_VIDEO_SWITCH
+   tristate i.MX Video Bus Multiplexer
+   depends on VIDEO_V4L2_SUBDEV_API
+   help
+ This driver provides support for SoC internal video bus multiplexers
+ controlled by register bitfields as well as external multiplexers
+ controller by a GPIO.
+
 config VIDEO_IMX_IPU_COMMON
tristate
 
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index 49d8fab..d972674 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MEDIA_IMX)+= imx-media.o
+obj-$(CONFIG_MEDIA_IMX_VIDEO_SWITCH)   += imx-video-switch.o
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
 obj-$(CONFIG_VIDEO_IMX_IPU_CSI)+= imx-ipuv3-csi.o
 obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
diff --git a/drivers/media/platform/imx/imx-video-switch.c 
b/drivers/media/platform/imx/imx-video-switch.c
new file mode 100644
index 000..7a5f64f
--- /dev/null
+++ b/drivers/media/platform/imx/imx-video-switch.c
@@ -0,0 +1,347 @@
+/*
+ * devicetree probed mediacontrol multiplexer.
+ *
+ * Copyright (C) 2013 Sascha Hauer, Pengutronix
+ *
+ * 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.
+ */
+
+#include linux/err.h
+#include linux/gpio.h
+#include linux/mfd/syscon.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_gpio.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/of_graph.h
+#include media/v4l2-subdev.h
+#include media/v4l2-of.h
+
+#include media/imx.h /* for ipu_media_entity_create_link */
+
+enum {
+   PAD_INPUT0,
+   PAD_INPUT1,
+   PAD_OUTPUT,
+   PAD_NUM,
+};
+
+struct vidsw {
+   struct device *dev;
+   struct v4l2_subdev subdev;
+   struct media_pad pads[PAD_NUM];
+   struct v4l2_mbus_framefmt format_mbus[PAD_NUM];
+   struct v4l2_of_endpoint endpoint[PAD_NUM - 1];
+   struct regmap_field *field;
+   unsigned int gpio;
+   int streaming;
+   int active;
+};
+
+#define to_vidsw(sd) container_of(sd, struct vidsw, subdev)
+
+static int vidsw_link_setup(struct media_entity *entity,
+   const struct media_pad *local,
+   const struct media_pad *remote, u32 flags)
+{
+   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+   struct vidsw *vidsw = to_vidsw(sd);
+
+   dev_dbg(vidsw-dev, link setup %s - %s, remote-entity-name,
+   local-entity-name);
+
+   if (vidsw-streaming)
+   return -EBUSY;
+
+   if (!(flags  MEDIA_LNK_FL_ENABLED)) {
+   if (local-index == vidsw-active) {
+   dev_dbg(vidsw-dev, going inactive\n);
+   vidsw-active = -1;
+   }
+   return 0;
+   }
+
+   if (vidsw-active = 0) {
+   if (vidsw-active == local-index)
+   return 0;
+   else
+   return -EBUSY;
+   }
+
+   vidsw-active = local-index;
+
+   dev_dbg(vidsw-dev, setting %d active\n, vidsw-active);
+
+   if (vidsw-field)
+   regmap_field_write(vidsw-field, vidsw-active);
+   else if (gpio_is_valid(vidsw-gpio))
+   gpio_set_value(vidsw-gpio, vidsw-active);
+
+   return 0;
+}
+
+static struct media_entity_operations vidsw_ops = {
+   .link_setup = vidsw_link_setup,
+};
+
+static int vidsw_async_init(struct vidsw *vidsw, struct device_node *node)
+{
+   struct v4l2_of_endpoint endpoint;
+   struct device_node *rp, *port;
+   u32 portno;
+   int numports;
+   int 

Re: [PATCH 32/43] ARM: dts: imx: sabrelite: add video capture ports and endpoints

2014-06-12 Thread Philipp Zabel
Am Mittwoch, den 11.06.2014, 13:38 +0200 schrieb Philipp Zabel:
 Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:
 [...]
  +ipu1 {
  +   status = okay;
  +
  +   v4l2-capture {
  +   compatible = fsl,imx6-v4l2-capture;
 
 I'm not happy with adding the simple-bus compatible to the ipu
 device tree node just to instantiate a virtual subdevice. See
 my comment in the following mail. I think it would be better to
 create this platform device from code, not from the device tree
 if something is connected to ipu port@0 or port@1, see below.
 
  +   #address-cells = 1;
  +   #size-cells = 0;
  +   status = okay;
  +   pinctrl-names = default;
  +   pinctrl-0 = 
  +   pinctrl_ipu1_csi0_1
  +   pinctrl_ipu1_csi0_data_en
  +   ;
  +
  +   /* CSI0 */
  +   port@0 {
 
 That port really is a property of the IPU itself. I have left
 space for ports 0 and 1 when specifying the IPU output interfaces
 as port 2 (DI0) and 3 (DI1).

Shawn Guo's for-next tree contains the CSI ports in
1fbf4ad8e1983732aa6a1de10da0bfcc7384f626

regards
Philipp

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


[RFC PATCH 09/26] [media] imx-ipu: Add i.MX IPUv3 scaler driver

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

This patch adds support for hardware accelerated scaling and color
space conversion between memory buffers using the IPUv3 IC.
Since the maximum output size of the IC unit is 1024x1024 pixels, multiple
IC tasks with overlapping tiles are used to scale and convert larger frames.

The IC operates with a burst size of at least 8 pixels. Depending on the
scaling factor, up to 7 junk pixels may be written after the end of the
frame. The sizeimage is increased accordingly.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Michael Olbrich m.olbr...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/Kconfig  |   9 +
 drivers/media/platform/imx/Makefile |   1 +
 drivers/media/platform/imx/imx-ipu-scaler.c | 825 
 drivers/media/platform/imx/imx-ipu.c|   2 +-
 drivers/media/platform/imx/imx-ipu.h|   1 +
 5 files changed, 837 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/imx/imx-ipu-scaler.c

diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index a90c973..4694367 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -1,2 +1,11 @@
 config VIDEO_IMX_IPU_COMMON
tristate
+
+config VIDEO_IMX_IPU_SCALER
+   tristate i.MX5/6 IPUv3 based image scaler driver
+   depends on VIDEO_DEV  IMX_IPUV3_CORE
+   select VIDEOBUF2_DMA_CONTIG
+   select VIDEO_IMX_IPU_COMMON
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a v4l2 scaler video driver for the IPUv3 on i.MX5/6.
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index 5de119c..f20aa0b 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
+obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
diff --git a/drivers/media/platform/imx/imx-ipu-scaler.c 
b/drivers/media/platform/imx/imx-ipu-scaler.c
new file mode 100644
index 000..ced209a
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipu-scaler.c
@@ -0,0 +1,825 @@
+/*
+ * i.MX IPUv3 scaler driver
+ *
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix
+ *
+ * based on the mem2mem test driver
+ *
+ * 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.
+ */
+#include linux/module.h
+#include linux/delay.h
+#include linux/fs.h
+#include linux/version.h
+#include linux/sched.h
+#include linux/slab.h
+#include video/imx-ipu-v3.h
+
+#include linux/platform_device.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include imx-ipu.h
+
+#define MIN_W 32
+#define MIN_H 32
+#define MAX_W 4096
+#define MAX_H 4096
+#define DIM_ALIGN_MASK 0x08 /* 8-alignment for dimensions */
+
+/* Flags that indicate a format can be used for capture/output */
+#define MEM2MEM_CAPTURE(1  0)
+#define MEM2MEM_OUTPUT (1  1)
+
+#define MEM2MEM_NAME   imx-ipuv3-scale
+
+/* Per queue */
+#define MEM2MEM_DEF_NUM_BUFS   VIDEO_MAX_FRAME
+/* In bytes, per queue */
+#define MEM2MEM_VID_MEM_LIMIT  (64 * 1024 * 1024)
+
+#define fh_to_ctx(__fh)container_of(__fh, struct ipu_scale_ctx, fh)
+
+enum {
+   V4L2_M2M_SRC = 0,
+   V4L2_M2M_DST = 1,
+};
+
+struct ipu_scale_dev {
+   struct v4l2_device  v4l2_dev;
+   struct video_device *vfd;
+   struct device   *dev;
+   struct ipu_soc  *ipu;
+
+   atomic_tnum_inst;
+   spinlock_t  irqlock;
+
+   struct v4l2_m2m_dev *m2m_dev;
+   struct mutexdev_mutex;
+};
+
+/* Per-queue, driver-specific private data */
+struct ipu_scale_q_data {
+   struct v4l2_pix_format  cur_fmt;
+   struct v4l2_rectrect;
+};
+
+struct ipu_scale_ctx {
+   struct ipu_scale_dev*ipu_scaler;
+
+   struct v4l2_fh  fh;
+   struct vb2_alloc_ctx*alloc_ctx;
+   struct ipu_scale_q_data q_data[2];
+   struct work_struct  work;
+   struct completion   completion;
+   struct work_struct  skip_run;
+   int error;
+   int aborting;
+};
+
+static struct ipu_scale_q_data *get_q_data(struct ipu_scale_ctx *ctx,
+  enum v4l2_buf_type type)
+{
+   switch (type) {
+   case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+

[RFC PATCH 12/26] [media] v4l2: Fix V4L2_CID_PIXEL_RATE

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 55c6832..6a6ccc5 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1048,7 +1048,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_PIXEL_RATE:
*type = V4L2_CTRL_TYPE_INTEGER64;
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
-   *min = *max = *step = *def = 0;
+   *min = *max = *step = 0;
break;
default:
*type = V4L2_CTRL_TYPE_INTEGER;
@@ -1710,7 +1710,11 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
ctrl-qmenu_int = qmenu_int;
ctrl-priv = priv;
-   ctrl-cur.val = ctrl-val = ctrl-default_value = def;
+
+   if (type == V4L2_CTRL_TYPE_INTEGER64)
+   ctrl-val64 = ctrl-cur.val64 = def;
+   else
+   ctrl-cur.val = ctrl-val = ctrl-default_value = def;
 
if (ctrl-type == V4L2_CTRL_TYPE_STRING) {
ctrl-cur.string = (char *)ctrl[1] + sz_extra - (max + 1);
-- 
2.0.0.rc2

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


[RFC PATCH 10/26] [media] imx-ipu: Add i.MX IPUv3 deinterlacer driver

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

This adds a video4linux mem2mem driver that deinterlaces input
frames using the IPUv3 VDIC module.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/imx/Kconfig|   9 +
 drivers/media/platform/imx/Makefile   |   1 +
 drivers/media/platform/imx/imx-ipu-vdic.c | 716 ++
 3 files changed, 726 insertions(+)
 create mode 100644 drivers/media/platform/imx/imx-ipu-vdic.c

diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index 4694367..506326a 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -9,3 +9,12 @@ config VIDEO_IMX_IPU_SCALER
select V4L2_MEM2MEM_DEV
---help---
  This is a v4l2 scaler video driver for the IPUv3 on i.MX5/6.
+
+config VIDEO_IMX_IPU_VDIC
+   tristate i.MX5/6 IPUv3 based deinterlacer driver
+   depends on VIDEO_DEV  IMX_IPUV3_CORE
+   select VIDEOBUF2_DMA_CONTIG
+   select VIDEO_IMX_IPU_COMMON
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a v4l2 deinterlacer video driver for the IPUv3 on i.MX5/6.
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index f20aa0b..5c9da82 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
 obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
+obj-$(CONFIG_VIDEO_IMX_IPU_VDIC)   += imx-ipu-vdic.o
diff --git a/drivers/media/platform/imx/imx-ipu-vdic.c 
b/drivers/media/platform/imx/imx-ipu-vdic.c
new file mode 100644
index 000..f4c7a31
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipu-vdic.c
@@ -0,0 +1,716 @@
+/*
+ * i.MX IPUv3 vdic driver
+ *
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix
+ *
+ * based on the mem2mem test driver
+ *
+ * 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.
+ */
+#include linux/module.h
+#include linux/delay.h
+#include linux/fs.h
+#include linux/version.h
+#include linux/sched.h
+#include linux/slab.h
+#include video/imx-ipu-v3.h
+
+#include linux/platform_device.h
+#include media/v4l2-mem2mem.h
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include imx-ipu.h
+
+#define MIN_W 32
+#define MIN_H 32
+#define MAX_W 4096
+#define MAX_H 4096
+#define DIM_ALIGN_MASK 0x08 /* 8-alignment for dimensions */
+
+/* Flags that indicate a format can be used for capture/output */
+#define MEM2MEM_CAPTURE(1  0)
+#define MEM2MEM_OUTPUT (1  1)
+
+#define MEM2MEM_NAME   imx-ipuv3-vdic
+
+/* Per queue */
+#define MEM2MEM_DEF_NUM_BUFS   VIDEO_MAX_FRAME
+/* In bytes, per queue */
+#define MEM2MEM_VID_MEM_LIMIT  (64 * 1024 * 1024)
+
+#define fh_to_ctx(__fh)container_of(__fh, struct ipu_vdic_ctx, fh)
+
+enum {
+   V4L2_M2M_SRC = 0,
+   V4L2_M2M_DST = 1,
+};
+
+struct ipu_vdic_dev {
+   struct v4l2_device  v4l2_dev;
+   struct video_device *vfd;
+   struct device   *dev;
+   struct ipu_soc  *ipu;
+
+   atomic_tnum_inst;
+   spinlock_t  irqlock;
+
+   struct v4l2_m2m_dev *m2m_dev;
+   struct mutexdev_mutex;
+   struct ipuv3_channel*ipu_ch[4];
+};
+
+/* Per-queue, driver-specific private data */
+struct ipu_vdic_q_data {
+   struct v4l2_pix_format  cur_fmt;
+};
+
+struct ipu_vdic_ctx {
+   struct ipu_vdic_dev *ipu_vdic;
+
+   struct v4l2_fh  fh;
+   struct vb2_alloc_ctx*alloc_ctx;
+   struct ipu_vdic_q_data  q_data[2];
+
+   struct vb2_buffer *in_p, *in;
+};
+
+static struct ipu_vdic_q_data *get_q_data(struct ipu_vdic_ctx *ctx,
+ enum v4l2_buf_type type)
+{
+   switch (type) {
+   case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+   return ctx-q_data[V4L2_M2M_SRC];
+   case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+   return ctx-q_data[V4L2_M2M_DST];
+   default:
+   BUG();
+   }
+   return NULL;
+}
+
+/*
+ * mem2mem callbacks
+ */
+
+static void job_abort(void *priv)
+{
+}
+
+static void ipu_complete(void *priv, int err)
+{
+   struct ipu_vdic_dev *ipu_vdic = priv;
+   struct ipu_vdic_ctx *ctx;
+   struct vb2_buffer *dst_vb;
+   unsigned long flags;
+
+   ctx = v4l2_m2m_get_curr_priv(ipu_vdic-m2m_dev);
+
+   if (!ctx) {
+

[RFC PATCH 01/26] gpu: ipu-v3: Add IC support

2014-06-12 Thread Philipp Zabel
From: Sascha Hauer s.ha...@pengutronix.de

This patch adds support for the IC module used for scaling, rotation,
and colorspace conversions.
Scaling images larger than 1024x1024 is supported by tiling over multiple
IC scaling tasks. Instead of scaling tiles separately, which causes an ugly
seam at the edge, use a single scaling coefficient and write them with
overlap due to the 8-pixel burst size. Due to overlap, tiles have to be
rendered right to left and bottom to top. Up to 7 pixels (depending on
the scaling factor) have to be available to be written after the end of
the frame.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/gpu/ipu-v3/Makefile |2 +-
 drivers/gpu/ipu-v3/ipu-ic.c | 1227 +++
 include/video/imx-ipu-v3.h  |6 +
 3 files changed, 1234 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/ipu-v3/ipu-ic.c

diff --git a/drivers/gpu/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile
index 1887972b..2c4d1ef 100644
--- a/drivers/gpu/ipu-v3/Makefile
+++ b/drivers/gpu/ipu-v3/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o 
ipu-smfc.o
+imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o 
ipu-smfc.o ipu-ic.o
diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
new file mode 100644
index 000..778751f
--- /dev/null
+++ b/drivers/gpu/ipu-v3/ipu-ic.c
@@ -0,0 +1,1227 @@
+/*
+ * Copyright (c) 2012 Sascha Hauer s.ha...@pengutronix.de
+ *
+ * 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.
+ */
+#include linux/types.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/errno.h
+#include linux/export.h
+#include linux/spinlock.h
+#include linux/io.h
+#include linux/bitrev.h
+#include linux/delay.h
+#include linux/dma-mapping.h
+#include video/imx-ipu-v3.h
+
+#include ipu-prv.h
+
+enum {
+   IC_TASK_VIEWFINDER,
+   IC_TASK_ENCODER,
+   IC_TASK_POST_PROCESSOR,
+   IC_TASK_MAX,
+};
+
+struct image_convert_ctx {
+   void (*complete)(void *ctx, int err);
+   void *complete_context;
+
+   struct list_head list;
+   struct ipu_image in;
+   struct ipu_image in_n;
+   struct ipu_image in_p;
+   struct ipu_image out;
+
+   void *freep;
+
+   unsigned int rotate:1;
+   unsigned int deinterlace:1;
+
+   u32 rsc;
+};
+
+struct ipu_ic_task {
+   int id;
+   struct ipu_ic_priv *priv;
+   void __iomem *reg_rsc;
+   u32 csc1_mask;
+   u32 csc2_mask;
+   u32 cmb_mask;
+   void __iomem *tpm_base_csc1;
+   void __iomem *tpm_base_csc2;
+   u32 ic_conf_rot_en;
+   u32 ic_conf_en;
+   int first_deinterlace_frame;
+   struct ipuv3_channel *input_channel_p;
+   struct ipuv3_channel *input_channel;
+   struct ipuv3_channel *input_channel_n;
+   struct ipuv3_channel *output_channel;
+   struct ipuv3_channel *rotation_input_channel;
+   struct ipuv3_channel *rotation_output_channel;
+
+   struct list_head image_list;
+
+   struct workqueue_struct *workqueue;
+   struct work_struct work;
+   struct completion complete;
+};
+
+struct ipu_ic_priv {
+   void __iomem *ic_base;
+   void __iomem *tpm_base;
+   void __iomem *vdi_base;
+   struct device *dev;
+   struct ipu_soc *ipu;
+   struct mutex mutex;
+   struct ipu_ic_task task[IC_TASK_MAX];
+   spinlock_t lock;
+   int ic_usecount;
+};
+
+#define IC_CONF0x0
+#define IC_PRP_ENC_RSC 0x4
+#define IC_PRP_VF_RSC  0x8
+#define IC_PP_RSC  0xC
+#define IC_CMBP_1  0x10
+#define IC_CMBP_2  0x14
+#define IC_IDMAC_1 0x18
+#define IC_IDMAC_2 0x1C
+#define IC_IDMAC_3 0x20
+#define IC_IDMAC_4 0x24
+
+/* Image Converter Register bits */
+#defineIC_CONF_PRPENC_EN   0x0001
+#defineIC_CONF_PRPENC_CSC1 0x0002
+#defineIC_CONF_PRPENC_ROT_EN   0x0004
+#defineIC_CONF_PRPVF_EN0x0100
+#defineIC_CONF_PRPVF_CSC1  0x0200
+#defineIC_CONF_PRPVF_CSC2  0x0400
+#defineIC_CONF_PRPVF_CMB   0x0800
+#defineIC_CONF_PRPVF_ROT_EN0x1000
+#defineIC_CONF_PP_EN   0x0001
+#defineIC_CONF_PP_CSC1 0x0002
+#defineIC_CONF_PP_CSC2 0x0004

[RFC PATCH 05/26] gpu: ipu-v3: Add support for partial interleaved YCbCr 4:2:0 (NV12) format

2014-06-12 Thread Philipp Zabel
From: Philipp Zabel philipp.za...@gmail.com

The partial interleaved format consists of two planes, one with 8-bit
luma (Y) values, and one with alternating 8-bit chroma (CbCr) values.
This format can be produced by CODA960 VPU and VDOA.

Signed-off-by: Philipp Zabel philipp.za...@gmail.com
---
 drivers/gpu/ipu-v3/ipu-common.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 94b9e8e..7a0b377 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -260,6 +260,11 @@ void ipu_cpmem_set_yuv_planar_full(struct ipu_ch_param 
__iomem *p,
ipu_ch_param_write_field(p, IPU_FIELD_UBO, v_offset / 8);
ipu_ch_param_write_field(p, IPU_FIELD_VBO, u_offset / 8);
break;
+   case V4L2_PIX_FMT_NV12:
+   ipu_ch_param_write_field(p, IPU_FIELD_SLUV, stride - 1);
+   ipu_ch_param_write_field(p, IPU_FIELD_UBO, u_offset / 8);
+   ipu_ch_param_write_field(p, IPU_FIELD_VBO, u_offset / 8);
+   break;
}
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_yuv_planar_full);
@@ -279,6 +284,11 @@ void ipu_cpmem_set_yuv_planar(struct ipu_ch_param __iomem 
*p, u32 pixel_format,
ipu_cpmem_set_yuv_planar_full(p, pixel_format, stride,
u_offset, v_offset);
break;
+   case V4L2_PIX_FMT_NV12:
+   u_offset = v_offset = stride * height;
+   ipu_cpmem_set_yuv_planar_full(p, pixel_format, stride,
+   u_offset, v_offset);
+   break;
}
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_yuv_planar);
@@ -348,6 +358,10 @@ int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, 
u32 drm_fourcc)
/* burst size */
ipu_ch_param_write_field(cpmem, IPU_FIELD_NPB, 63);
break;
+   case DRM_FORMAT_NV12:
+   ipu_ch_param_write_field(cpmem, IPU_FIELD_PFS, 4);
+   ipu_ch_param_write_field(cpmem, IPU_FIELD_NPB, 63);
+   break;
case DRM_FORMAT_UYVY:
/* bits/pixel */
ipu_ch_param_write_field(cpmem, IPU_FIELD_BPP, 3);
@@ -433,6 +447,8 @@ static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat)
return DRM_FORMAT_YUV420;
case V4L2_PIX_FMT_YVU420:
return DRM_FORMAT_YVU420;
+   case V4L2_PIX_FMT_NV12:
+   return DRM_FORMAT_NV12;
}
 
return -EINVAL;
@@ -458,6 +474,7 @@ enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 
drm_fourcc)
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YUV420:
case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_NV12:
return IPUV3_COLORSPACE_YUV;
default:
return IPUV3_COLORSPACE_UNKNOWN;
@@ -494,6 +511,19 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
pix-bytesperline, u_offset, v_offset);
ipu_cpmem_set_buffer(cpmem, 0, image-phys + y_offset);
break;
+   case V4L2_PIX_FMT_NV12:
+   y_offset = Y_OFFSET(pix, image-rect.left, image-rect.top);
+   u_offset = U_OFFSET(pix, image-rect.left,
+   image-rect.top) - y_offset;
+
+   ipu_cpmem_set_yuv_planar_full(cpmem, pix-pixelformat,
+   pix-bytesperline, u_offset, u_offset);
+   ipu_cpmem_set_buffer(cpmem, 0, image-phys + y_offset);
+   break;
+   ipu_cpmem_set_yuv_planar_full(cpmem, pix-pixelformat,
+   pix-bytesperline, u_offset, v_offset);
+   ipu_cpmem_set_buffer(cpmem, 0, image-phys + y_offset);
+   break;
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YUYV:
ipu_cpmem_set_buffer(cpmem, 0, image-phys +
@@ -551,6 +581,7 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 
pixelformat)
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YUYV:
+   case V4L2_PIX_FMT_NV12:
return IPUV3_COLORSPACE_YUV;
case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_BGR32:
-- 
2.0.0.rc2

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


046d:0896 [Acer Aspire 5630] Orbicam not working

2014-06-12 Thread Thierry Coton

Hi,

I have been asked to post on this mailing list about an annoying 
integrated webcam issue, please find details below:


I have installed latest version available 3.15-0-031500-generic for 
testing purpose as current distribution kernel did not work and result 
is not convincing.


The main issue is that integrated webcam does not work.

First time I launched guvcview, nothing happened as usual, no video 
window and no camera working. Program closed


I then launched Skype which did exactly the same apart of the camera led 
which was on this time but no video working. When I quit Skype, the 
led shut down then shortly blinked after ca. 15 sec.


Back to guvcview, the camera worked straight away. So, I closed it and 
started Skype and video did not work.


When I quit and open Skype again, it does not work anymore neither with 
guvcview.


Back to Skype, the LED is on but no video... (on /dev/video0). I quit 
Skype, restart it and this time no video and no LED...


Reboot- Skype = no video nor LED -- Quit

Guvcview = no video nor LED -- Quit

Skype = LED but no video -- Quit (LED blink when closing video options)

Guvcview = video fully working --Quit

Skype = no video nor LED -- Quit

Guvcview = the same -- Quit

Skype = LED but no video -- Quit (LED blink when closing video options)

Guvcview = video working -- Quit

Skype = no video nor LED -- Quit

Guvcview = video working -- Quit

Skype = LED but no video -- Quit (LED blink when closing video options)

Skype = no video nor LED -- Quit

So it looks too random for a normal human to use the webcam!



Technical data:

cat /proc/version = Linux version 3.15.0-031500-generic (apw@gomeisa) 
(gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #201406081435 SMP 
Sun Jun 8 18:56:41 UTC 2014



lsb_release -rd = Description:Ubuntu 14.04 LTS  Release: 14.04

/usr/src/linux-headers-3.15.0-031500-generic/scripts/ver_linux = sh: 0: 
can't open ver_linux


cat /proc/cpuinfo =

processor: 0
vendor_id: GenuineIntel
cpu family: 6
model: 15
model name: Intel(R) Core(TM)2 CPU T5500  @ 1.66GHz
stepping: 6
microcode: 0x48
cpu MHz: 1333.000
cache size: 2048 KB
physical id: 0
siblings: 2
core id: 0
cpu cores: 2
apicid: 0
initial apicid: 0
fdiv_bug: no
f00f_bug: no
coma_bug: no
fpu: yes
fpu_exception: yes
cpuid level: 10
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm 
constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl 
est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm

bogomips: 3324.91
clflush size: 64
cache_alignment: 64
address sizes: 36 bits physical, 48 bits virtual
power management:

processor: 1
vendor_id: GenuineIntel
cpu family: 6
model: 15
model name: Intel(R) Core(TM)2 CPU T5500  @ 1.66GHz
stepping: 6
microcode: 0x48
cpu MHz: 1000.000
cache size: 2048 KB
physical id: 0
siblings: 2
core id: 1
cpu cores: 2
apicid: 1
initial apicid: 1
fdiv_bug: no
f00f_bug: no
coma_bug: no
fpu: yes
fpu_exception: yes
cpuid level: 10
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm 
constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl 
est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm

bogomips: 3324.91
clflush size: 64
cache_alignment: 64
address sizes: 36 bits physical, 48 bits virtual
power management:

cat /proc/modules =

ctr 13025 2 - Live 0x
ccm 17562 2 - Live 0x
bnep 19107 2 - Live 0x
rfcomm 59300 0 - Live 0x
bluetooth 401303 10 bnep,rfcomm, Live 0x
6lowpan_iphc 18480 1 bluetooth, Live 0x
snd_hda_codec_realtek 65688 1 - Live 0x
snd_hda_codec_generic 63743 2 snd_hda_codec_realtek, Live 0x
snd_hda_intel 29400 1 - Live 0x
gspca_vc032x 31460 0 - Live 0x
coretemp 13358 0 - Live 0x
snd_hda_controller 30246 1 snd_hda_intel, Live 0x
gspca_main 28077 1 gspca_vc032x, Live 0x
arc4 12509 2 - Live 0x
snd_hda_codec 121022 4 
snd_hda_codec_realtek,snd_hda_codec_generic,snd_hda_intel,snd_hda_controller, 
Live 0x

videodev 122550 2 gspca_vc032x,gspca_main, Live 0x
snd_hwdep 13276 1 snd_hda_codec, Live 0x
snd_pcm 96792 3 snd_hda_intel,snd_hda_controller,snd_hda_codec, Live 
0x

iwl3945 64660 0 - Live 0x
snd_seq_midi 13324 0 - Live 0x
iwlegacy 88297 1 iwl3945, Live 0x
mac80211 573480 2 iwl3945,iwlegacy, Live 0x
snd_seq_midi_event 14475 1 snd_seq_midi, Live 0x
snd_rawmidi 25518 1 snd_seq_midi, Live 0x
acer_wmi 32140 0 - Live 0x
microcode 19509 0 - Live 0x
sparse_keymap 13658 1 

Re: [Mjpeg-users] [patch] [media] zoran: remove duplicate ZR050_MO_COMP define

2014-06-12 Thread Bernhard Praschinger

Hallo

More than 15 years have passed since the first working module for a 
zoran chipset based PCI card existed. Well not included into the Linux 
kernel at that time.
According to my experience, the driver started to make problems when 64 
Bit and more than 2GB Ram became popular. In May 2011 there was a patch 
available that made the cards working in machines with more than 2GB 
Ram, and AMDIntel x64 architectures. According to my information that 
patch did not make it into the linux kernel (the Patch was for the Linux 
2.6.38 Kernel)


So people spend time looking at code that does not work (well it 
compiles and does not cause troubles), and send patches the world will 
never honor.


I haven't had a question related to a zoran based card's in years. So 
I'm quite sure there are not much users out there that use a zoran based 
video cards in a up to date environment.


Because of that I would really suggest that somebody removes the whole 
zoran driver from the linux kernel.


Dan Carpenter wrote:

The ZR050_MO_COMP define is cut and pasted twice so we can delete the
second instance.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/media/pci/zoran/zr36050.h 
b/drivers/media/pci/zoran/zr36050.h
index 9f52f0c..ea083ad 100644
--- a/drivers/media/pci/zoran/zr36050.h
+++ b/drivers/media/pci/zoran/zr36050.h
@@ -126,7 +126,6 @@ struct zr36050 {
  /* zr36050 mode register bits */

  #define ZR050_MO_COMP0x80
-#define ZR050_MO_COMP0x80
  #define ZR050_MO_ATP 0x40
  #define ZR050_MO_PASS2   0x20
  #define ZR050_MO_TLM 0x10

--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing  Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
___
Mjpeg-users mailing list
mjpeg-us...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


Kind Regards
Bernhard Praschinger
Docwriter, probably the last mjpegtools maintainer
--
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 00/43] i.MX6 Video capture

2014-06-12 Thread Steve Longerbeam
On 06/12/2014 09:50 AM, Philipp Zabel wrote:
 Hi Steve,
 
 [Added Russell to Cc: because of the question how to send IPU core 
  patches to drm-next]
 
 Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:
 Hi Philipp and Sascha,

 First of all, thanks for the detailed review.
 
 You are welcome. I am tasked to prepare our own capture drivers for
 mainline submission, but they are not quite there yet. I'd be very
 interested in getting this worked out together, especially since we
 seem to be interested in orthogonal features (we had no use for the
 preview and and encoder IC tasks or MIPI CSI-2 so far, but we need
 media controller support

Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the
capture path is nice too, since it allows userland to select arbitrary user
resolutions, pixel format color space, and also rotation controls. The
capture driver decides whether to include the IC in the capture pipeline
based on user format and rotation control. I.e. if user colorspace is
different from what the sensor can output, IC CSC is required. If user
resolution is different from the selected capture cropping rectangle,
IC resizer is required, and finally if user requests rotation, the IC
rotation unit is required. If none of those are true, the capture driver
decides to exclude the IC from the pipeline and send raw sensor frames
(well, after cropping anyway) directly to memory via the SMFC.

So in our driver, the decision to link the IC in a pipeline is made
internally by the driver and is not a decision exported to userland.

My plan was to add media device framework support, but only after basic
video capture is in place. Our driver is full featured in terms of basic
capture support, and it works on all three reference platforms. But I
agree it needs to convert subdev's to media entities and allow some of
them to be linked via the media controller API.

But only some linkages make sense to me. As I explain above, if the IC were
to be made a media entity, I think it's linkage should be made internally
by the capture driver, and this should not be controllable by userspace.

and mem2mem scaling via the post-processor IC task).


Heh, we have a mem2mem driver as well, and it also uses IC post-processor
task. It uses banding and striping to support resized output frames larger
than 1024x1024. It also makes use of IC rotation and CSC.

But again this is not converted to a media entity. And again, if IC were to
be made a standalone media entity, then the mem2mem device would _always_
require the IC post-processor be linked to it, since the essential feature
of mem2mem is to make use of IC post-processor task for CSC, resize, and
rotation operations.

So as you can see I'm confused about where allowing control of media entity
linking would make sense.


 I'm going to post our current series as is, if only to illustrate my
 point of view.

I see them thanks. I'll study them.

 
 I think it's obvious that this patch set should be split into two: first,
 the changes to IPU core driver submitted to drm-next, and the capture driver
 to media-tree.
 
 I agree.
 
 Or, do you prefer I submit the IPU core patches to your own pengutronix git
 tree, and we can correspond on one of your internal mailing lists?
 
 Why would we move discussion to an internal mailing list? Since we are
 sitting right inbetween dri-devel and linux-media with the IPU core
 code, I think either mailing list is an appropriate place for discussing
 these patches, depending on the context.
 
 I can then leave it to you to push those changes to drm-next.
 
 I think a central place to collect IPU core patches before sending them
 off to drm-next is a good idea. I offer to do the collecting in my tree.
 I also know Russell volunteered to collect and send off imx-drm patches
 towards staging. Russell, I'm not sure if this offer extends to non-DRM
 IPU core patches to be submitted to drm-next? (And if yes, whether you'd
 rather keep at it or have this taken off your hands.)
 
 I agree with most of your feedback, and most is specific to the IPU core
 changes.
 
 Excellent. For the core changes, rebasing them onto next and then
 integrating some remaining changes from our patchset shouldn't be a
 problem.
 The big issue I have with the media parts is the missing media
 controller support and the code organization around the IC tasks
 instead of around hardware submodules.
 
  We can discuss those in detail elsewhere, but just in summary here,
 some of your comments seem to conflict:

 1. Regarding the input muxes to the CSI and IC, Philipp you acked those
 functions but would like to see these muxes as v4l2 subdevs and configured
 in the DT, but Sascha, you had a comment that this should be a job for
 mediactrl.
 
 No conflict here, there are different multiplexers to talk about.
 
 First, there are two external multiplexers controlled by IOMUXC (on
 i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and
 

Re: AF9033 / IT913X: Avermedia A835B(1835) only works sporadically

2014-06-12 Thread Antti Palosaari

Moikka,

The reason is that Avermedia has programmed wrong tuner ID to device 
eeprom. For one IT9135BX device I have it is set 0x38 (whilst Windows 
driver programs 0x60), no idea how others. That same issues was for 
AF9015 too, where I added USB ID based overrides for certain Avermedia 
models. I think I will do same for AF9035 driver.


regards
Antti


On 06/11/2014 11:11 AM, jason.d...@ite.com.tw wrote:

Dear David,

The RF performance of ITE9137 BX + IE9133 dongle is a little worse than single 
tuner.
As our test resolut, the RF performances should be -80db and -82db for dual 
tuners and single tuner.
There is an issue in hardware design if the reception capability is too worse.

We don’t need to change the firmware for dual tuners. I think there are some 
problems in af9033 driver of kernel v3.15.

BRs,
Jason

-Original Message-
From: David Shirley [mailto:tep...@gmail.com]
Sent: Wednesday, June 11, 2014 3:00 PM
To: Jason Dong (董志堅)
Cc: sebastian...@gmx.net; linux-media@vger.kernel.org
Subject: Re: AF9033 / IT913X: Avermedia A835B(1835) only works sporadically

Hey Jason,

Do we know if that RF problem exists in 3.14.5? Using the IT913X driver?

I have a Leadtek Winfast Dual Dongle (0413:6a05 - dual usb - ITE9137 BX + 
IE9133) which is being extremely painful (random signal locks, tzap reports ok 
signal strength for one tuner but poor for the other, random signal dropouts 
(ie working fine, then progressively getting more and more blips in 
visual/audio from stream)).

I dont think its signal strength related because 3x Leadtek Winfast Gold 
dongles (AF9013) all work (until they stop tuning and cold reboot is required)

I suspect something about the firmware is at fault, I have tried to talk to 
Antti - but he must be busy. I have tried three different dvb-usb-it9135-02.fw 
firmwares, and they don't seem to make a huge difference (newest doesn't create 
/dev/dvb bits)...

Does a BX (v2) 9137 require yet another firmware image?

If I use the AF9035 kernel driver it doesn't tune at all. But does detect the 
tuners...

Sorry to threadjack - but seeing your @ite.com.tw I thought I would ask while I 
can :)

Regards
David

On 11 June 2014 15:31,  jason.d...@ite.com.tw wrote:

Dear Sebastian,

There is a RF performance issue in the af9033 driver of kernel 3.15. It is no 
problem in the it913x driver of kernel 3.14.
There were some initial sequences not correct after the it913x driver was 
integrated into af9033 driver.

BRs,
Jason

-Original Message-
From: linux-media-ow...@vger.kernel.org
[mailto:linux-media-ow...@vger.kernel.org] On Behalf Of Sebastian
Kemper
Sent: Tuesday, June 10, 2014 8:51 PM
To: linux-media@vger.kernel.org
Subject: AF9033 / IT913X: Avermedia A835B(1835) only works
sporadically

Hello list,

I have an Avermedia A835B(1835) USB DVB-T stick (07ca:1835) which works only 
(very) sporadically. It's pure luck as far as I can see.
I can't reproduce how to get it working. There are no special steps that I can 
take to guarantee that it'll work once I plug it in.

I'd rate my chances of having the device actually working between 5
and
10 percent.

In the log everything looks fine, apart from the messages at the bottom about 
the device not being able to get a lock on a channel.

Reception here is really good, so there's no problem with signal strength. When 
loading the device in Windows 7 64 bit it always finds a lock.

Has anybody any idea? Thanks for any suggestions!

Jun 10 14:18:07 meiner kernel: usb 1-2: new high-speed USB device number 2 
using xhci_hcd Jun 10 14:18:07 meiner kernel: WARNING: You are using an 
experimental version of the media stack.
Jun 10 14:18:07 meiner kernel:  As the driver is backported to an
older kernel, it doesn't offer Jun 10 14:18:07 meiner kernel:  enough quality 
for its usage in production.
Jun 10 14:18:07 meiner kernel:  Use it with care.
Jun 10 14:18:07 meiner kernel: Latest git patches (needed if you report a bug 
to linux-media@vger.kernel.org):
Jun 10 14:18:07 meiner kernel:
bfd0306462fdbc5e0a8c6999aef9dde0f9745399 [media] v4l: Document
timestamp buffer flag behaviour Jun 10 14:18:07 meiner kernel:
309f4d62eda0e864c2d4eef536cc82e41931c3c5 [media] v4l: Copy timestamp
source flags to destination on m2m devices Jun 10 14:18:07 meiner kernel:  
599b08929efe9b90e44b504454218a120bb062a0 [media] exynos-gsc, m2m-deinterlace, 
mx2_emmaprp: Copy v4l2_buffer data from src to dst Jun 10 14:18:07 meiner 
kernel:  experimental: a60b303c3e347297a25f0a203f0ff11a8efc818c 
experimental/ngene: Support DuoFlex C/C2/T/T2 (V3) Jun 10 14:18:07 meiner 
kernel:  v4l-dvb-saa716x: 052c468e33be00a3d4d9b93da3581ffa861bb288 saa716x: IO 
memory of upper PHI1 regions is mapped in saa716x_ff driver.
Jun 10 14:18:07 meiner kernel: usb 1-2: dvb_usb_af9035: prechip_version=83 
chip_version=02 chip_type=9135 Jun 10 14:18:07 meiner kernel: usb 1-2: 
dvb_usb_v2: found a 'Avermedia A835B(1835)' in cold state Jun 10 14:18:07 
meiner kernel: usb 1-2: dvb_usb_v2: 

[GIT PULL for 3.16-rc1] OMAP3 updates

2014-06-12 Thread Mauro Carvalho Chehab
Hi Linus,

Please pull from:
  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
topic/omap3isp

For some driver improvements on OMAP3. This series depend on some iommu
patches already merged.

Thanks,
Mauro

The following changes since commit 85ac1a1772bb41da895bad83a81f6a62c8f293f6:

  [media] media: stk1160: Avoid stack-allocated buffer for control URBs 
(2014-05-24 17:12:11 -0300)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
topic/omap3isp

for you to fetch changes up to 21d8582d480443574d6a8811e25ccb65dff974d5:

  [media] omap3isp: Rename isp_buffer isp_addr field to dma (2014-05-25 
11:40:09 -0300)


Laurent Pinchart (26):
  [media] omap3isp: stat: Rename IS_COHERENT_BUF to ISP_STAT_USES_DMAENGINE
  [media] omap3isp: stat: Remove impossible WARN_ON
  [media] omap3isp: stat: Share common code for buffer allocation
  [media] omap3isp: stat: Merge dma_addr and iommu_addr fields
  [media] omap3isp: stat: Store sg table in ispstat_buffer
  [media] omap3isp: stat: Use the DMA API
  [media] omap3isp: ccdc: Use the DMA API for LSC
  [media] omap3isp: ccdc: Use the DMA API for FPC
  [media] omap3isp: video: Set the buffer bytesused field at completion time
  [media] omap3isp: queue: Move IOMMU handling code to the queue
  [media] omap3isp: queue: Use sg_table structure
  [media] omap3isp: queue: Merge the prepare and sglist functions
  [media] omap3isp: queue: Inline the ispmmu_v(un)map functions
  [media] omap3isp: queue: Allocate kernel buffers with dma_alloc_coherent
  [media] omap3isp: queue: Fix the dma_map_sg() return value check
  [media] omap3isp: queue: Map PFNMAP buffers to device
  [media] omap3isp: queue: Use sg_alloc_table_from_pages()
  [media] omap3isp: Use the ARM DMA IOMMU-aware operations
  [media] omap3isp: queue: Don't build scatterlist for kernel buffer
  [media] omap3isp: Move queue mutex to isp_video structure
  [media] omap3isp: Move queue irqlock to isp_video structure
  [media] omap3isp: Move buffer irqlist to isp_buffer structure
  [media] omap3isp: Cancel all queued buffers when stopping the video stream
  [media] v4l: vb2: Add a function to discard all DONE buffers
  [media] omap3isp: Move to videobuf2
  [media] omap3isp: Rename isp_buffer isp_addr field to dma

Mauro Carvalho Chehab (1):
  Merge branch 'arm/omap' of git://git.kernel.org/.../joro/iommu into 
topic/omap3isp

 drivers/iommu/omap-iommu.c|   31 +-
 drivers/iommu/omap-iopgtable.h|3 -
 drivers/media/platform/Kconfig|4 +-
 drivers/media/platform/omap3isp/Makefile  |2 +-
 drivers/media/platform/omap3isp/isp.c |  108 ++-
 drivers/media/platform/omap3isp/isp.h |8 +-
 drivers/media/platform/omap3isp/ispccdc.c |  107 ++-
 drivers/media/platform/omap3isp/ispccdc.h |   16 +-
 drivers/media/platform/omap3isp/ispccp2.c |4 +-
 drivers/media/platform/omap3isp/ispcsi2.c |4 +-
 drivers/media/platform/omap3isp/isph3a_aewb.c |2 +-
 drivers/media/platform/omap3isp/isph3a_af.c   |2 +-
 drivers/media/platform/omap3isp/isppreview.c  |8 +-
 drivers/media/platform/omap3isp/ispqueue.c| 1161 -
 drivers/media/platform/omap3isp/ispqueue.h|  188 
 drivers/media/platform/omap3isp/ispresizer.c  |8 +-
 drivers/media/platform/omap3isp/ispstat.c |  197 ++---
 drivers/media/platform/omap3isp/ispstat.h |3 +-
 drivers/media/platform/omap3isp/ispvideo.c|  325 +++
 drivers/media/platform/omap3isp/ispvideo.h|   29 +-
 drivers/media/v4l2-core/videobuf2-core.c  |   24 +
 drivers/staging/media/omap4iss/iss_video.c|2 +-
 include/media/videobuf2-core.h|1 +
 23 files changed, 470 insertions(+), 1767 deletions(-)
 delete mode 100644 drivers/media/platform/omap3isp/ispqueue.c
 delete mode 100644 drivers/media/platform/omap3isp/ispqueue.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


Re: [PATCH 00/43] i.MX6 Video capture

2014-06-12 Thread Troy Kisky
On 6/12/2014 2:05 PM, Steve Longerbeam wrote:
 On 06/12/2014 09:50 AM, Philipp Zabel wrote:
 Hi Steve,

 [Added Russell to Cc: because of the question how to send IPU core 
  patches to drm-next]

 Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:
 Hi Philipp and Sascha,

 First of all, thanks for the detailed review.

 You are welcome. I am tasked to prepare our own capture drivers for
 mainline submission, but they are not quite there yet. I'd be very
 interested in getting this worked out together, especially since we
 seem to be interested in orthogonal features (we had no use for the
 preview and and encoder IC tasks or MIPI CSI-2 so far, but we need
 media controller support
 
 Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the
 capture path is nice too, since it allows userland to select arbitrary user
 resolutions, pixel format color space, and also rotation controls. The
 capture driver decides whether to include the IC in the capture pipeline
 based on user format and rotation control. I.e. if user colorspace is
 different from what the sensor can output, IC CSC is required. If user
 resolution is different from the selected capture cropping rectangle,
 IC resizer is required, and finally if user requests rotation, the IC
 rotation unit is required. If none of those are true, the capture driver
 decides to exclude the IC from the pipeline and send raw sensor frames
 (well, after cropping anyway) directly to memory via the SMFC.
 
 So in our driver, the decision to link the IC in a pipeline is made
 internally by the driver and is not a decision exported to userland.
 
 My plan was to add media device framework support, but only after basic
 video capture is in place. Our driver is full featured in terms of basic
 capture support, and it works on all three reference platforms. But I
 agree it needs to convert subdev's to media entities and allow some of
 them to be linked via the media controller API.
 
 But only some linkages make sense to me. As I explain above, if the IC were
 to be made a media entity, I think it's linkage should be made internally
 by the capture driver, and this should not be controllable by userspace.
 

What if 2 cameras on different CSIs on the same IPU want to use the IC.
Is it 1st come 1st server? Or, both routed to memory, and a separate
memory convert? Is the 1st pipeline shut down and restarted in this mode?




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


  1   2   >