[PATCH] [media] rc: fix hix5hd2 compile-test issue

2014-09-29 Thread Zhangfei Gao
Commit 4c255791ffd6410f (asm-generic: io: implement relaxed accessor
macros as conditional wrappers) adds wrappers to asm-generic of
{read,write}{b,w,l,q}_relaxed.

Change CONFIG_PM to CONFIG_PM_SLEEP to solve
warning: 'hix5hd2_ir_suspend'  'hix5hd2_ir_resume' defined but not used

Reported-by: Fengguang Wu fengguang...@intel.com
Signed-off-by: Zhangfei Gao zhangfei@linaro.org
---
 drivers/media/rc/ir-hix5hd2.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index c555ca2aed0e..58ec5986274e 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -16,11 +16,6 @@
 #include linux/regmap.h
 #include media/rc-core.h
 
-/* Allow the driver to compile on all architectures */
-#ifndef writel_relaxed
-# define writel_relaxed writel
-#endif
-
 #define IR_ENABLE  0x00
 #define IR_CONFIG  0x04
 #define CNT_LEADS  0x08
@@ -294,7 +289,7 @@ static int hix5hd2_ir_remove(struct platform_device *pdev)
return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int hix5hd2_ir_suspend(struct device *dev)
 {
struct hix5hd2_ir_priv *priv = dev_get_drvdata(dev);
-- 
1.7.9.5

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


[PATCH for v3.18] vivid: fix Kconfig FB dependency

2014-09-29 Thread Hans Verkuil
The vivid driver depends on FB, update the Kconfig accordingly.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reported-by: Jim Davis jim.ep...@gmail.com

diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
index d71139a..c309093 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -1,8 +1,11 @@
 config VIDEO_VIVID
tristate Virtual Video Test Driver
-   depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64
+   depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64  FB
select FONT_SUPPORT
select FONT_8x16
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
select VIDEOBUF2_VMALLOC
default n
---help---
--
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] cx23855: add support for DVBSky T980C (no CI support)

2014-09-29 Thread Olli Salonen
This patch adds basic support for DVBSky T980C card. CI interface is not 
supported.

DVBSky T980C is a PCIe card with the following components:
- CX23885 PCIe bridge
- Si2168-A20 demodulator
- Si2158-A20 tuner
- CIMaX SP2 CI chip

The demodulator and tuner need firmware. They're the same as used with TT 
CT2-4650 CI:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg78033.html

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-cards.c | 40 
 drivers/media/pci/cx23885/cx23885-dvb.c   | 61 +++
 drivers/media/pci/cx23885/cx23885.h   |  1 +
 3 files changed, 102 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 88c257d..e8965e6 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -680,6 +680,10 @@ struct cx23885_board cx23885_boards[] = {
.portb  = CX23885_MPEG_DVB,
.portc  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_T980C] = {
+   .name   = DVBSky T980C,
+   .portb  = CX23885_MPEG_DVB,
+   },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -939,6 +943,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x9580,
.card  = CX23885_BOARD_DVBSKY_T9580,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x980c,
+   .card  = CX23885_BOARD_DVBSKY_T980C,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1541,6 +1549,36 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
mdelay(100);
cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
break;
+   case CX23885_BOARD_DVBSKY_T980C:
+   /*
+* GPIO-0 INTA from CiMax, input
+* GPIO-1 reset CiMax, output, high active
+* GPIO-2 reset demod, output, low active
+* GPIO-3 to GPIO-10 data/addr for CAM
+* GPIO-11 ~CS0 to CiMax1
+* GPIO-12 ~CS1 to CiMax2
+* GPIO-13 ADL0 load LSB addr
+* GPIO-14 ADL1 load MSB addr
+* GPIO-15 ~RDY from CiMax
+* GPIO-17 ~RD to CiMax
+* GPIO-18 ~WR to CiMax
+*/
+
+   cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */
+   cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */
+   mdelay(100); /* reset delay */
+   cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */
+   cx_clear(GP0_IO, 0x00010002);
+   cx_write(MC417_CTL, 0x0037); /* enable GPIO3-18 pins */
+
+   /* GPIO-15 IN as ~ACK, rest as OUT */
+   cx_write(MC417_OEN, 0x1000);
+
+   /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
+   cx_write(MC417_RWD, 0xc300);
+
+   /* enable irq */
+   cx_write(GPIO_ISM, 0x); /* INTERRUPTS active low */
}
 }
 
@@ -1817,6 +1855,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_TEVII_S471:
case CX23885_BOARD_DVBWORLD_2005:
case CX23885_BOARD_PROF_8000:
+   case CX23885_BOARD_DVBSKY_T980C:
ts1-gen_ctrl_val  = 0x5; /* Parallel */
ts1-ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -1935,6 +1974,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
dev-sd_cx25840 = v4l2_i2c_new_subdev(dev-v4l2_dev,
dev-i2c_bus[2].i2c_adap,
cx25840, 0x88  1, NULL);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 2f532c9..d327459 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1681,6 +1681,52 @@ static int dvb_register(struct cx23885_tsport *port)
break;
}
break;
+   case CX23885_BOARD_DVBSKY_T980C:
+   i2c_bus = dev-i2c_bus[1];
+
+   /* attach frontend */
+   memset(si2168_config, 0, sizeof(si2168_config));
+   si2168_config.i2c_adapter = adapter;
+   si2168_config.fe = fe0-dvb.frontend;
+   si2168_config.ts_mode = SI2168_TS_PARALLEL;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, si2168, I2C_NAME_SIZE);
+   info.addr = 0x64;
+   info.platform_data = si2168_config;

[PATCH 2/5] sp2: fix incorrect struct

2014-09-29 Thread Olli Salonen
Incorrect struct used in the SP2 driver.

Reported-by: Max Nibble nibble@gmail.com
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/sp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index 9b684d5..1f4f250 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -407,7 +407,7 @@ err:
 
 static int sp2_remove(struct i2c_client *client)
 {
-   struct si2157 *s = i2c_get_clientdata(client);
+   struct sp2 *s = i2c_get_clientdata(client);
 
dev_dbg(client-dev, \n);
 
-- 
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


[PATCH 3/5] sp2: improve debug logging

2014-09-29 Thread Olli Salonen
Improve debugging output.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/sp2.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index 1f4f250..320cbe9 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -92,6 +92,9 @@ static int sp2_write_i2c(struct sp2 *s, u8 reg, u8 *buf, int 
len)
return -EIO;
}
 
+   dev_dbg(s-client-dev, addr=0x%04x, reg = 0x%02x, data = %*ph\n,
+   client-addr, reg, len, buf);
+
return 0;
 }
 
@@ -103,9 +106,6 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, 
int slot, u8 acs,
int mem, ret;
int (*ci_op_cam)(void*, u8, int, u8, int*) = s-ci_control;
 
-   dev_dbg(s-client-dev, slot=%d, acs=0x%02x, addr=0x%04x, data = 
0x%02x,
-   slot, acs, addr, data);
-
if (slot != 0)
return -EINVAL;
 
@@ -140,13 +140,16 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, 
int slot, u8 acs,
if (ret)
return ret;
 
-   if (read) {
-   dev_dbg(s-client-dev, cam read, addr=0x%04x, data = 0x%04x,
-   addr, mem);
+   dev_dbg(s-client-dev, %s: slot=%d, addr=0x%04x, %s, data=%x,
+   (read) ? read : write, slot, addr,
+   (acs == SP2_CI_ATTR_ACS) ? attr : io,
+   (read) ? mem : data);
+
+   if (read)
return mem;
-   } else {
+   else
return 0;
-   }
+
 }
 
 int sp2_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221,
-- 
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


[PATCH 5/5] cx23855: add CI support for DVBSky T980C

2014-09-29 Thread Olli Salonen
Add CI support for DVBSky T980C.

I used the new host device independent CIMaX SP2 I2C driver to implement it.

cx23885_sp2_ci_ctrl function is borrowed entirely from cimax2.c.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 105 +++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..70dbcd6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h
 
@@ -616,6 +617,76 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
return 0;
 }
 
+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+
+   /* MC417 */
+   #define SP2_DATA  0x00ff
+   #define SP2_WR0x8000
+   #define SP2_RD0x4000
+   #define SP2_ACK   0x1000
+   #define SP2_ADHI  0x0800
+   #define SP2_ADLO  0x0400
+   #define SP2_CS1   0x0200
+   #define SP2_CS0   0x0100
+   #define SP2_EN_ALL0x1000
+   #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+   struct cx23885_tsport *port = priv;
+   struct cx23885_dev *dev = port-dev;
+   int ret;
+   int tmp;
+   unsigned long timeout;
+
+   mutex_lock(dev-gpio_lock);
+
+   /* write addr */
+   cx_write(MC417_OEN, SP2_EN_ALL);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADLO | (0xff  addr));
+   cx_clear(MC417_RWD, SP2_ADLO);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADHI | (0xff  (addr  8)));
+   cx_clear(MC417_RWD, SP2_ADHI);
+
+   if (read) { /* data in */
+   cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+   } else /* data out */
+   cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+   /* chip select 0 */
+   cx_clear(MC417_RWD, SP2_CS0);
+
+   /* read/write */
+   cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+   timeout = jiffies + msecs_to_jiffies(1);
+   for (;;) {
+   tmp = cx_read(MC417_RWD);
+   if ((tmp  SP2_ACK) == 0)
+   break;
+   if (time_after(jiffies, timeout))
+   break;
+   udelay(1);
+   }
+
+   cx_set(MC417_RWD, SP2_CTRL_OFF);
+   *mem = tmp  0xff;
+
+   mutex_unlock(dev-gpio_lock);
+
+   if (!read)
+   if (*mem  0) {
+   ret = -EREMOTEIO;
+   goto err;
+   }
+
+   return 0;
+err:
+   return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1015,11 @@ static int dvb_register(struct cx23885_tsport *port)
struct vb2_dvb_frontend *fe0, *fe1 = NULL;
struct si2168_config si2168_config;
struct si2157_config si2157_config;
+   struct sp2_config sp2_config;
struct m88ts2022_config m88ts2022_config;
struct i2c_board_info info;
struct i2c_adapter *adapter;
-   struct i2c_client *client_demod;
-   struct i2c_client *client_tuner;
+   struct i2c_client *client_demod, *client_tuner, *client_ci;
int mfe_shared = 0; /* bus not shared by default */
int ret;
 
@@ -1683,6 +1754,7 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_DVBSKY_T980C:
i2c_bus = dev-i2c_bus[1];
+   i2c_bus2 = dev-i2c_bus[0];
 
/* attach frontend */
memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1892,35 @@ static int dvb_register(struct cx23885_tsport *port)
case CX23885_BOARD_DVBSKY_T980C: {
u8 eeprom[256]; /* 24C02 i2c eeprom */
 
+   /* attach CI */
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = port-frontends.adapter;
+   sp2_config.priv = port;
+   sp2_config.ci_control = cx23885_sp2_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+   request_module(info.type);
+   client_ci = i2c_new_device(i2c_bus2-i2c_adap, info);
+   if (client_ci == NULL ||
+   client_ci-dev.driver == NULL) {
+   module_put(client_tuner-dev.driver-owner);
+   

[PATCH 4/5] cx23885: add I2C client for CI into state and handle unregistering

2014-09-29 Thread Olli Salonen
If the CI chip has an I2C driver, we need to store I2C client into state.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 7 +++
 drivers/media/pci/cx23885/cx23885.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index d327459..cc88997 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1923,6 +1923,13 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
 * implement MFE support.
 */
 
+   /* remove I2C client for CI */
+   client = port-i2c_client_ci;
+   if (client) {
+   module_put(client-dev.driver-owner);
+   i2c_unregister_device(client);
+   }
+
/* remove I2C client for tuner */
client = port-i2c_client_tuner;
if (client) {
diff --git a/drivers/media/pci/cx23885/cx23885.h 
b/drivers/media/pci/cx23885/cx23885.h
index 1792d1a..c35ba2d 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -297,6 +297,7 @@ struct cx23885_tsport {
 
struct i2c_client *i2c_client_demod;
struct i2c_client *i2c_client_tuner;
+   struct i2c_client *i2c_client_ci;
 
int (*set_frontend)(struct dvb_frontend *fe);
int (*fe_set_voltage)(struct dvb_frontend *fe,
-- 
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


[PATCH v4 8/8] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_parse_of

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code bit shorter and
easier to read. Since we can break out of the loop, we keep the
call to of_node_put after the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
Changes since v3:
 - Kept of_node_put after the loop, as in the earlier soc_camera patch.
   This reduces the line count and is safe to do since of_node_put(NULL)
   is a no-op.
---
 drivers/staging/imx-drm/imx-drm-core.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 69e7194..43285dc 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -439,17 +439,13 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np)
 {
struct imx_drm_device *imxdrm = drm-dev_private;
-   struct device_node *ep = NULL;
+   struct device_node *ep;
uint32_t crtc_mask = 0;
-   int i;
+   int i = 0;
 
-   for (i = 0; ; i++) {
+   for_each_endpoint_of_node(np, ep) {
u32 mask;
 
-   ep = of_graph_get_next_endpoint(np, ep);
-   if (!ep)
-   break;
-
mask = imx_drm_find_crtc_mask(imxdrm, ep);
 
/*
@@ -462,6 +458,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
return -EPROBE_DEFER;
 
crtc_mask |= mask;
+   i++;
}
 
of_node_put(ep);
-- 
2.1.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 v4 3/8] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint

2014-09-29 Thread Philipp Zabel
Decrementing the reference count of the previous endpoint node allows to
use the of_graph_get_next_endpoint function in a for_each_... style macro.
Prior to this patch, all current users of this function that actually pass
a non-NULL prev parameter should be changed to not decrement the passed
prev argument's refcount themselves.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/of/base.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d8574ad..a49b5628 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2058,8 +2058,7 @@ EXPORT_SYMBOL(of_graph_parse_endpoint);
  * @prev: previous endpoint node, or NULL to get first
  *
  * Return: An 'endpoint' node pointer with refcount incremented. Refcount
- * of the passed @prev node is not decremented, the caller have to use
- * of_node_put() on it when done.
+ * of the passed @prev node is decremented.
  */
 struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
struct device_node *prev)
@@ -2095,12 +2094,6 @@ struct device_node *of_graph_get_next_endpoint(const 
struct device_node *parent,
if (WARN_ONCE(!port, %s(): endpoint %s has no parent node\n,
  __func__, prev-full_name))
return NULL;
-
-   /*
-* Avoid dropping prev node refcount to 0 when getting the next
-* child below.
-*/
-   of_node_get(prev);
}
 
while (1) {
-- 
2.1.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 v4 5/8] of: Add of_graph_get_port_by_id function

2014-09-29 Thread Philipp Zabel
This patch adds a function to get a port device tree node by port id,
or reg property value.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/of/base.c| 26 ++
 include/linux/of_graph.h |  7 +++
 2 files changed, 33 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a49b5628..76e2651 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2053,6 +2053,32 @@ int of_graph_parse_endpoint(const struct device_node 
*node,
 EXPORT_SYMBOL(of_graph_parse_endpoint);
 
 /**
+ * of_graph_get_port_by_id() - get the port matching a given id
+ * @parent: pointer to the parent device node
+ * @id: id of the port
+ *
+ * Return: A 'port' node pointer with refcount incremented. The caller
+ * has to use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id)
+{
+   struct device_node *port;
+
+   for_each_child_of_node(node, port) {
+   u32 port_id = 0;
+
+   if (of_node_cmp(port-name, port) != 0)
+   continue;
+   of_property_read_u32(port, reg, port_id);
+   if (id == port_id)
+   return port;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(of_graph_get_port_by_id);
+
+/**
  * of_graph_get_next_endpoint() - get next endpoint node
  * @parent: pointer to the parent device node
  * @prev: previous endpoint node, or NULL to get first
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index e43442e..3c1c95a 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -40,6 +40,7 @@ struct of_endpoint {
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
+struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
struct device_node *previous);
 struct device_node *of_graph_get_remote_port_parent(
@@ -53,6 +54,12 @@ static inline int of_graph_parse_endpoint(const struct 
device_node *node,
return -ENOSYS;
 }
 
+static inline struct device_node *of_graph_get_port_by_id(
+   struct device_node *node, u32 id)
+{
+   return NULL;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
const struct device_node *parent,
struct device_node *previous)
-- 
2.1.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 v4 2/8] imx-drm: Do not decrement endpoint node refcount in the loop

2014-09-29 Thread Philipp Zabel
In preparation for the following patch, stop decrementing the endpoint node
refcount in the loop. This temporarily leaks a reference to the endpoint node,
which will be fixed by having of_graph_get_next_endpoint decrement the refcount
of its prev argument instead.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
Changes since v3:
 - Rebased on top of 30e94a564d079f71f53368733720caa0c7c413c8
   (staging: imx-drm: Lines over 80 characters fixed.), which
   added a blank line in imx_drm_of_get_next_endpoint.
---
 drivers/staging/imx-drm/imx-drm-core.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 4289cc8..fab79ad 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -435,15 +435,6 @@ static uint32_t imx_drm_find_crtc_mask(struct 
imx_drm_device *imxdrm,
return 0;
 }
 
-static struct device_node *imx_drm_of_get_next_endpoint(
-   const struct device_node *parent, struct device_node *prev)
-{
-   struct device_node *node = of_graph_get_next_endpoint(parent, prev);
-
-   of_node_put(prev);
-   return node;
-}
-
 int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np)
 {
@@ -455,7 +446,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
for (i = 0; ; i++) {
u32 mask;
 
-   ep = imx_drm_of_get_next_endpoint(np, ep);
+   ep = of_graph_get_next_endpoint(np, ep);
if (!ep)
break;
 
@@ -503,7 +494,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
return -EINVAL;
 
do {
-   ep = imx_drm_of_get_next_endpoint(node, ep);
+   ep = of_graph_get_next_endpoint(node, ep);
if (!ep)
break;
 
-- 
2.1.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 v4 4/8] of: Add for_each_endpoint_of_node helper macro

2014-09-29 Thread Philipp Zabel
Note that while of_graph_get_next_endpoint decrements the reference count
of the child node passed to it, of_node_put(child) still has to be called
manually when breaking out of the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/linux/of_graph.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index befef42..e43442e 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -26,6 +26,17 @@ struct of_endpoint {
const struct device_node *local_node;
 };
 
+/**
+ * for_each_endpoint_of_node - iterate over every endpoint in a device node
+ * @parent: parent device node containing ports and endpoints
+ * @child: loop variable pointing to the current endpoint node
+ *
+ * When breaking out of the loop, of_node_put(child) has to be called manually.
+ */
+#define for_each_endpoint_of_node(parent, child) \
+   for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
+child = of_graph_get_next_endpoint(parent, child))
+
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
-- 
2.1.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 v4 0/8] Add of-graph helpers to loop over endpoints and find ports by id

2014-09-29 Thread Philipp Zabel
Hi,

in theory, I'd like the first five patches to go in together through Grant's
tree, but in practice that might not be necessary; changes in of_node
reference counting are only relevant if CONFIG_OF_DYNAMIC is enabled.
Since patch 2 depends on (or would trivially conflict with) 30e94a564d07
in the staging tree, it might be better to merge this one through staging.
What do you think?

The three 'use for_each_endpoint_of_node macro in ...' patches can be resent
later, separately.

This series converts all existing users of of_graph_get_next_endpoint that pass
a non-NULL prev argument to the function and decrement its refcount themselves
to stop doing that. The of_node_put is moved into of_graph_get_next_endpoint
instead.
This allows to add a for_each_endpoint_of_node helper macro to loop over all
endpoints in a device tree node.
The third of patch adds a of_graph_get_port_by_id function to retrieve a port
by its known port id from the device tree.
Finally, the last three patches convert functions in drm_of.c and imx-drm-core.c
to use the for_each_endpoint_of_node macro instead of 
of_graph_get_next_endpoint.

Changes since v3:
 - Moved of_node_put for the break case after the loop in patch 1 and 8
 - Rebased patch 2 on top of 30e94a564d07 (staging: imx-drm: Lines over 80
   characters fixed.), which added a blank line in the function we remove,
   imx_drm_of_get_next_endpoint.

The previous version can be found here: https://lkml.org/lkml/2014/9/11/696

regards
Philipp

Philipp Zabel (8):
  [media] soc_camera: Do not decrement endpoint node refcount in the
loop
  imx-drm: Do not decrement endpoint node refcount in the loop
  of: Decrement refcount of previous endpoint in
of_graph_get_next_endpoint
  of: Add for_each_endpoint_of_node helper macro
  of: Add of_graph_get_port_by_id function
  drm: use for_each_endpoint_of_node macro in drm_of_find_possible_crtcs
  imx-drm: use for_each_endpoint_of_node macro in
imx_drm_encoder_get_mux_id
  imx-drm: use for_each_endpoint_of_node macro in
imx_drm_encoder_parse_of

 drivers/gpu/drm/drm_of.c   |  8 ++
 drivers/media/platform/soc_camera/soc_camera.c |  3 ++-
 drivers/of/base.c  | 35 --
 drivers/staging/imx-drm/imx-drm-core.c | 29 ++---
 include/linux/of_graph.h   | 18 +
 5 files changed, 56 insertions(+), 37 deletions(-)

-- 
2.1.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 v4 6/8] drm: use for_each_endpoint_of_node macro in drm_of_find_possible_crtcs

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code a bit shorter and
easier to read.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/gpu/drm/drm_of.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 16150a0..024fa77 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -46,11 +46,7 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
struct device_node *remote_port, *ep = NULL;
uint32_t possible_crtcs = 0;
 
-   do {
-   ep = of_graph_get_next_endpoint(port, ep);
-   if (!ep)
-   break;
-
+   for_each_endpoint_of_node(port, ep) {
remote_port = of_graph_get_remote_port(ep);
if (!remote_port) {
of_node_put(ep);
@@ -60,7 +56,7 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
possible_crtcs |= drm_crtc_port_mask(dev, remote_port);
 
of_node_put(remote_port);
-   } while (1);
+   }
 
return possible_crtcs;
 }
-- 
2.1.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 v4 7/8] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_get_mux_id

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code bit shorter and
easier to read. This patch also properly decrements the endpoint node
reference count before returning out of the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/staging/imx-drm/imx-drm-core.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index fab79ad..69e7194 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -493,18 +493,15 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
if (!node || !imx_crtc)
return -EINVAL;
 
-   do {
-   ep = of_graph_get_next_endpoint(node, ep);
-   if (!ep)
-   break;
-
+   for_each_endpoint_of_node(node, ep) {
port = of_graph_get_remote_port(ep);
of_node_put(port);
if (port == imx_crtc-port) {
ret = of_graph_parse_endpoint(ep, endpoint);
+   of_node_put(ep);
return ret ? ret : endpoint.port;
}
-   } while (ep);
+   }
 
return -EINVAL;
 }
-- 
2.1.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 v4 1/8] [media] soc_camera: Do not decrement endpoint node refcount in the loop

2014-09-29 Thread Philipp Zabel
In preparation for a following patch, stop decrementing the endpoint node
refcount in the loop. This temporarily leaks a reference to the endpoint node,
which will be fixed by having of_graph_get_next_endpoint decrement the refcount
of its prev argument instead.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
Changes since v3:
 - Moved of_node_put for the break case after the loop
---
 drivers/media/platform/soc_camera/soc_camera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index f4308fe..619b2d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1696,7 +1696,6 @@ static void scan_of_host(struct soc_camera_host *ici)
if (!i)
soc_of_bind(ici, epn, ren-parent);
 
-   of_node_put(epn);
of_node_put(ren);
 
if (i) {
@@ -1704,6 +1703,8 @@ static void scan_of_host(struct soc_camera_host *ici)
break;
}
}
+
+   of_node_put(epn);
 }
 
 #else
-- 
2.1.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 1/2] af9033: fix signal strength value not correct issue

2014-09-29 Thread Bimow Chen
Register 0x800048 is not dB measure but relative scale. Fix it and conform to 
NorDig specifications.
From b85ad9df69884b80cce62877039aa9130243ef3a Mon Sep 17 00:00:00 2001
From: Bimow Chen bimow.c...@ite.com.tw
Date: Mon, 29 Sep 2014 13:57:07 +0800
Subject: [PATCH 1/2] af9033: fix signal strength value not correct issue

Register 0x800048 is not dB measure but relative scale. Fix it and conform to NorDig specifications.

Signed-off-by: Bimow Chen bimow.c...@ite.com.tw
---
 drivers/media/dvb-frontends/af9033.c  |   54 ++---
 drivers/media/dvb-frontends/af9033_priv.h |6 +++
 2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 63a89c1..e191bd5 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -862,23 +862,14 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
 static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
 	struct af9033_dev *dev = fe-demodulator_priv;
-	int ret;
-	u8 strength2;
-
-	/* read signal strength of 0-100 scale */
-	ret = af9033_rd_reg(dev, 0x800048, strength2);
-	if (ret  0)
-		goto err;
+	struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;
 
-	/* scale value to 0x-0x */
-	*strength = strength2 * 0x / 100;
+	if (c-strength.stat[0].scale == FE_SCALE_RELATIVE)
+		*strength = c-strength.stat[0].uvalue;
+	else
+		*strength = 0;
 
 	return 0;
-
-err:
-	dev_dbg(dev-client-dev, failed=%d\n, ret);
-
-	return ret;
 }
 
 static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
@@ -974,8 +965,8 @@ static void af9033_stat_work(struct work_struct *work)
 {
 	struct af9033_dev *dev = container_of(work, struct af9033_dev, stat_work.work);
 	struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;
-	int ret, tmp, i, len;
-	u8 u8tmp, buf[7];
+	int ret, tmp, i, len, power_real;
+	u8 u8tmp, gain_offset, buf[7];
 
 	dev_dbg(dev-client-dev, \n);
 
@@ -983,17 +974,40 @@ static void af9033_stat_work(struct work_struct *work)
 	if (dev-fe_status  FE_HAS_SIGNAL) {
 		if (dev-is_af9035) {
 			ret = af9033_rd_reg(dev, 0x80004a, u8tmp);
-			tmp = -u8tmp * 1000;
+			/* scale value to 0x-0x */
+			tmp = u8tmp * 0x / 100;
 		} else {
 			ret = af9033_rd_reg(dev, 0x8000f7, u8tmp);
-			tmp = (u8tmp - 100) * 1000;
+			ret |= af9033_rd_regs(dev, 0x80f900, buf, 7);
+
+			if (c-frequency = 3)
+gain_offset = 7; /* VHF */
+			else
+gain_offset = 4; /* UHF */
+
+			power_real = (u8tmp - 100 - gain_offset) -
+power_reference[((buf[3]  0)  3)][((buf[6]  0)  7)];
+
+			if (power_real  -15)
+tmp = 0;
+			else if ((power_real = -15)  (power_real  0))
+tmp = (2 * (power_real + 15)) / 3;
+			else if ((power_real = 0)  (power_real  20))
+tmp = 4 * power_real + 10;
+			else if ((power_real = 20)  (power_real  35))
+tmp = (2 * (power_real - 20)) / 3 + 90;
+			else
+tmp = 100;
+
+			/* scale value to 0x-0x */
+			tmp = tmp * 0x / 100;
 		}
 		if (ret)
 			goto err;
 
 		c-strength.len = 1;
-		c-strength.stat[0].scale = FE_SCALE_DECIBEL;
-		c-strength.stat[0].svalue = tmp;
+		c-strength.stat[0].scale = FE_SCALE_RELATIVE;
+		c-strength.stat[0].uvalue = tmp;
 	} else {
 		c-strength.len = 1;
 		c-strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
diff --git a/drivers/media/dvb-frontends/af9033_priv.h b/drivers/media/dvb-frontends/af9033_priv.h
index c12c92c..c9c8798 100644
--- a/drivers/media/dvb-frontends/af9033_priv.h
+++ b/drivers/media/dvb-frontends/af9033_priv.h
@@ -2051,4 +2051,10 @@ static const struct reg_val tuner_init_it9135_62[] = {
 	{ 0x80fd8b, 0x00 },
 };
 
+/* NorDig power reference table */
+static const int power_reference[][5] = {
+	{-93, -91, -90, -89, -88}, /* QPSK 1/2 ~ 7/8 */
+	{-87, -85, -84, -83, -82}, /* 16QAM 1/2 ~ 7/8 */
+	{-82, -80, -78, -77, -76}, /* 64QAM 1/2 ~ 7/8 */
+};
 #endif /* AF9033_PRIV_H */
-- 
1.7.0.4



[PATCH 2/2] af9033: fix snr value not correct issue

2014-09-29 Thread Bimow Chen
Snr returns value not correct. Fix it.
From 427a5c6ef49e3235ac35a0464c375f2a2706619e Mon Sep 17 00:00:00 2001
From: Bimow Chen bimow.c...@ite.com.tw
Date: Mon, 29 Sep 2014 16:30:52 +0800
Subject: [PATCH 2/2] af9033: fix snr value not correct issue

Snr returns value not correct. Fix it.

Signed-off-by: Bimow Chen bimow.c...@ite.com.tw
---
 drivers/media/dvb-frontends/af9033.c  |   52 ++---
 drivers/media/dvb-frontends/af9033_priv.h |5 ++-
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index e191bd5..30dc366 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -851,8 +851,8 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
 	struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;
 
 	/* use DVBv5 CNR */
-	if (c-cnr.stat[0].scale == FE_SCALE_DECIBEL)
-		*snr = div_s64(c-cnr.stat[0].svalue, 100); /* 1000x = 10x */
+	if (c-cnr.stat[0].scale == FE_SCALE_RELATIVE)
+		*snr = c-cnr.stat[0].uvalue;
 	else
 		*snr = 0;
 
@@ -1025,6 +1025,33 @@ static void af9033_stat_work(struct work_struct *work)
 
 		snr_val = (buf[2]  16) | (buf[1]  8) | (buf[0]  0);
 
+		/* read superframe number */
+		ret = af9033_rd_reg(dev, 0x80f78b, u8tmp);
+		if (ret)
+			goto err;
+
+		if (u8tmp)
+			snr_val /= u8tmp;
+
+		/* read current transmission mode */
+		ret = af9033_rd_reg(dev, 0x80f900, u8tmp);
+		if (ret)
+			goto err;
+
+		switch ((u8tmp  0)  3) {
+		case 0:
+			snr_val *= 4;
+			break;
+		case 1:
+			snr_val *= 1;
+			break;
+		case 2:
+			snr_val *= 2;
+			break;
+		default:
+			goto err;
+		}
+
 		/* read current modulation */
 		ret = af9033_rd_reg(dev, 0x80f903, u8tmp);
 		if (ret)
@@ -1048,14 +1075,29 @@ static void af9033_stat_work(struct work_struct *work)
 		}
 
 		for (i = 0; i  len; i++) {
-			tmp = snr_lut[i].snr * 1000;
+			tmp = snr_lut[i].snr;
 			if (snr_val  snr_lut[i].val)
 break;
 		}
 
+		/* scale value to 0x-0x */
+		switch ((u8tmp  0)  3) {
+		case 0:
+			tmp = tmp * 0x / 23;
+			break;
+		case 1:
+			tmp = tmp * 0x / 26;
+			break;
+		case 2:
+			tmp = tmp * 0x / 32;
+			break;
+		default:
+			goto err;
+		}
+
 		c-cnr.len = 1;
-		c-cnr.stat[0].scale = FE_SCALE_DECIBEL;
-		c-cnr.stat[0].svalue = tmp;
+		c-cnr.stat[0].scale = FE_SCALE_RELATIVE;
+		c-cnr.stat[0].uvalue = tmp;
 	} else {
 		c-cnr.len = 1;
 		c-cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
diff --git a/drivers/media/dvb-frontends/af9033_priv.h b/drivers/media/dvb-frontends/af9033_priv.h
index c9c8798..8e23275 100644
--- a/drivers/media/dvb-frontends/af9033_priv.h
+++ b/drivers/media/dvb-frontends/af9033_priv.h
@@ -181,7 +181,10 @@ static const struct val_snr qam64_snr_lut[] = {
 	{ 0x05570d, 26 },
 	{ 0x059feb, 27 },
 	{ 0x05bf38, 28 },
-	{ 0xff, 29 },
+	{ 0x05f78f, 29 },
+	{ 0x0612c3, 30 },
+	{ 0x0626be, 31 },
+	{ 0xff, 32 },
 };
 
 static const struct reg_val ofsm_init[] = {
-- 
1.7.0.4



RE: buffer delivery stops with cx23885

2014-09-29 Thread James Harper
 
 041ad449683bb2d54a7f082d78ec15bbc958a175 introduced stats gathering
 into the dib7000p code which seems to generate a lot more i2c traffic which
 would exacerbate the problem, if one existed. The timing (May/June) very
 roughly matches what I remember too. When my recording stops, so do the
 Next all layers stats available in... messages, although that could be for
 other reasons.
 
 Anyway, I'll comment out the call to dib7000p_get_stats and see if it makes a
 difference.
 

That didn't help.

Having chmod 'd /dev/dvb/adapter1 so that mythtv can't open the second 
tuner, things have been absolutely solid for a week. As soon as I let mythtv 
access the second tuner it hangs almost immediately.

Based on a bunch of printk's I added, the tuner loses sync/lock which would 
explain why buffer delivery stops. I had been looking in the wrong place. I 
can't see anything happening when this happens though, it doesn't seem to 
coincide with gathering stats or anything but I can't be completely sure.

Other things I have observed when things stop working are:
 DiB7000P: i2c read error (often)
 DiB0070 I2C read failed (less often)
 DiB0070 I2C write failed (less often)
 NMI: PCI system error (SERR) for reason b1 on CPU 0. (rarely)

Where could the two tuners be treading on each other?

Thanks

James



cron job: media_tree daily build: ERRORS

2014-09-29 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Mon 29 Sep 10:30:33 CEST 2014
git branch: test
git hash:   cf3167cf1e969b17671a4d3d956d22718a8ceb85
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-20-g7abd8a7
host hardware:  x86_64
host os:3.16-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: WARNINGS
linux-3.12.23-i686: WARNINGS
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: OK
linux-3.16-i686: OK
linux-3.17-rc1-i686: OK
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: WARNINGS
linux-3.12.23-x86_64: WARNINGS
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16-x86_64: WARNINGS
linux-3.17-rc1-x86_64: WARNINGS
apps: OK
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH v4 1/8] [media] soc_camera: Do not decrement endpoint node refcount in the loop

2014-09-29 Thread Dan Carpenter
On Mon, Sep 29, 2014 at 10:15:44AM +0200, Philipp Zabel wrote:
 In preparation for a following patch, stop decrementing the endpoint node
 refcount in the loop. This temporarily leaks a reference to the endpoint node,
 which will be fixed by having of_graph_get_next_endpoint decrement the 
 refcount
 of its prev argument instead.

Don't do this...

My understanding (and I haven't invested much time into trying to
understand this beyond glancing at the change) is that patch 1 and 2,
introduce small bugs that are fixed in patch 3?

Just fold all three patches into one patch.  We need an Ack from Mauro
and Greg and then send the patch through Grant's tree.

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: [PATCH v4 1/8] [media] soc_camera: Do not decrement endpoint node refcount in the loop

2014-09-29 Thread Philipp Zabel
Am Montag, den 29.09.2014, 12:13 +0300 schrieb Dan Carpenter:
 On Mon, Sep 29, 2014 at 10:15:44AM +0200, Philipp Zabel wrote:
  In preparation for a following patch, stop decrementing the endpoint node
  refcount in the loop. This temporarily leaks a reference to the endpoint 
  node,
  which will be fixed by having of_graph_get_next_endpoint decrement the 
  refcount
  of its prev argument instead.
 
 Don't do this...
 
 My understanding (and I haven't invested much time into trying to
 understand this beyond glancing at the change) is that patch 1 and 2,
 introduce small bugs that are fixed in patch 3?

 Just fold all three patches into one patch.  We need an Ack from Mauro
 and Greg and then send the patch through Grant's tree.

Yes. Patches 1 and 2 leak a reference on of_nodes touched by the loop.
As far as I am aware, all users of this code don't use the reference
counting (CONFIG_OF_DYNAMIC is disabled), so this bug should be
theoretical.

I'd be happy do as you suggest if Mauro and Greg agree.

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


[PATCH] em28xx: fix uninitialized variable warning

2014-09-29 Thread Hans Verkuil
Fix this daily build warning:

In file included from build/media_build/v4l/em28xx-core.c:35:0:
build/media_build/v4l/em28xx-core.c: In function 'em28xx_audio_setup':
build/media_build/v4l/em28xx.h:798:2: warning: 'vid' may be used uninitialized 
in this function [-Wmaybe-uninitialized]
  printk(KERN_INFO %s: fmt,\
  ^
build/media_build/v4l/em28xx-core.c:507:6: note: 'vid' was declared here
  u32 vid;
  ^

As far as I can tell 'vid' can not really be used uninitialized here, but the 
code
is sufficiently complex that apparently gcc can't figure that out.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com

diff --git a/drivers/media/usb/em28xx/em28xx-core.c 
b/drivers/media/usb/em28xx/em28xx-core.c
index b5e52fe..901cf2b 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -504,7 +504,7 @@ EXPORT_SYMBOL_GPL(em28xx_audio_analog_set);
 int em28xx_audio_setup(struct em28xx *dev)
 {
int vid1, vid2, feat, cfg;
-   u32 vid;
+   u32 vid = 0;
u8 i2s_samplerates;
 
if (dev-chip_id == CHIP_ID_EM2870 ||

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


Re: [PATCH 1/2] af9033: fix signal strength value not correct issue

2014-09-29 Thread Antti Palosaari

On 09/29/2014 11:43 AM, Bimow Chen wrote:

Register 0x800048 is not dB measure but relative scale. Fix it and conform to 
NorDig specifications.


eh, 0x800048 register returned strength normalized to 0-100 %. But that 
was earlier when older firmwares used. I have seen it does not return 
anything anymore, so I am very fine it is replaced with something 
meaningful.


But the issues is that this patches changes current DVBv5 signal 
reporting from dBm to relative. I indeed implemented it is as a dBm and 
I checked it using modulator RF strength it really is dBm. Now you add 
some glue which converts dBm to relative value between 0-0x.


I encourage you to use modulator yourself to generate signals. Then use 
dvbv5-zap to see values DVBv5 API reports.


If you really want return 0-0x values, then do it for old DVBv3 
read_signal_strength(), but do not change new DVBv5 statistics to 
relative. dBm, as a clearly defined unit, is always preferred over 
relative. Relative was added to API for cases we cannot report well 
known units.


Could you tell which is unit NorDig specification defines for signal 
strength?


regards
Antti






0001-af9033-fix-signal-strength-value-not-correct-issue.patch



From b85ad9df69884b80cce62877039aa9130243ef3a Mon Sep 17 00:00:00 2001

From: Bimow Chenbimow.c...@ite.com.tw
Date: Mon, 29 Sep 2014 13:57:07 +0800
Subject: [PATCH 1/2] af9033: fix signal strength value not correct issue

Register 0x800048 is not dB measure but relative scale. Fix it and conform to 
NorDig specifications.

Signed-off-by: Bimow Chenbimow.c...@ite.com.tw
---
  drivers/media/dvb-frontends/af9033.c  |   54 ++---
  drivers/media/dvb-frontends/af9033_priv.h |6 +++
  2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9033.c 
b/drivers/media/dvb-frontends/af9033.c
index 63a89c1..e191bd5 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -862,23 +862,14 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 
*snr)
  static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
  {
struct af9033_dev *dev = fe-demodulator_priv;
-   int ret;
-   u8 strength2;
-
-   /* read signal strength of 0-100 scale */
-   ret = af9033_rd_reg(dev, 0x800048, strength2);
-   if (ret  0)
-   goto err;
+   struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;

-   /* scale value to 0x-0x */
-   *strength = strength2 * 0x / 100;
+   if (c-strength.stat[0].scale == FE_SCALE_RELATIVE)
+   *strength = c-strength.stat[0].uvalue;
+   else
+   *strength = 0;

return 0;
-
-err:
-   dev_dbg(dev-client-dev, failed=%d\n, ret);
-
-   return ret;
  }

  static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
@@ -974,8 +965,8 @@ static void af9033_stat_work(struct work_struct *work)
  {
struct af9033_dev *dev = container_of(work, struct af9033_dev, 
stat_work.work);
struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;
-   int ret, tmp, i, len;
-   u8 u8tmp, buf[7];
+   int ret, tmp, i, len, power_real;
+   u8 u8tmp, gain_offset, buf[7];

dev_dbg(dev-client-dev, \n);

@@ -983,17 +974,40 @@ static void af9033_stat_work(struct work_struct *work)
if (dev-fe_status  FE_HAS_SIGNAL) {
if (dev-is_af9035) {
ret = af9033_rd_reg(dev, 0x80004a, u8tmp);
-   tmp = -u8tmp * 1000;
+   /* scale value to 0x-0x */
+   tmp = u8tmp * 0x / 100;
} else {
ret = af9033_rd_reg(dev, 0x8000f7, u8tmp);
-   tmp = (u8tmp - 100) * 1000;
+   ret |= af9033_rd_regs(dev, 0x80f900, buf, 7);
+
+   if (c-frequency = 3)
+   gain_offset = 7; /* VHF */
+   else
+   gain_offset = 4; /* UHF */
+
+   power_real = (u8tmp - 100 - gain_offset) -
+   power_reference[((buf[3]  0)  3)][((buf[6]  0) 
 7)];
+
+   if (power_real  -15)
+   tmp = 0;
+   else if ((power_real = -15)  (power_real  0))
+   tmp = (2 * (power_real + 15)) / 3;
+   else if ((power_real = 0)  (power_real  20))
+   tmp = 4 * power_real + 10;
+   else if ((power_real = 20)  (power_real  35))
+   tmp = (2 * (power_real - 20)) / 3 + 90;
+   else
+   tmp = 100;
+
+   /* scale value to 0x-0x */
+   tmp = tmp * 0x / 100;
}
if (ret)
   

Re: [PATCH 5/5] cx23855: add CI support for DVBSky T980C

2014-09-29 Thread Nibble Max
Hello,
In hardware design, the CI host controller is wired with GPIO_0 of CX23885.
The GPIO_0 can be configed as the interrupt source.
Interrupt mode in PCIe driver is more faster than poll mode to detect CAM 
insert/remove operations etc.

Add CI support for DVBSky T980C.

I used the new host device independent CIMaX SP2 I2C driver to implement it.

cx23885_sp2_ci_ctrl function is borrowed entirely from cimax2.c.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 105 +++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..70dbcd6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h
 
@@ -616,6 +617,76 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
   return 0;
 }
 
+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+  u8 data, int *mem)
+{
+
+  /* MC417 */
+  #define SP2_DATA  0x00ff
+  #define SP2_WR0x8000
+  #define SP2_RD0x4000
+  #define SP2_ACK   0x1000
+  #define SP2_ADHI  0x0800
+  #define SP2_ADLO  0x0400
+  #define SP2_CS1   0x0200
+  #define SP2_CS0   0x0100
+  #define SP2_EN_ALL0x1000
+  #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+  struct cx23885_tsport *port = priv;
+  struct cx23885_dev *dev = port-dev;
+  int ret;
+  int tmp;
+  unsigned long timeout;
+
+  mutex_lock(dev-gpio_lock);
+
+  /* write addr */
+  cx_write(MC417_OEN, SP2_EN_ALL);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADLO | (0xff  addr));
+  cx_clear(MC417_RWD, SP2_ADLO);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADHI | (0xff  (addr  8)));
+  cx_clear(MC417_RWD, SP2_ADHI);
+
+  if (read) { /* data in */
+  cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+  } else /* data out */
+  cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+  /* chip select 0 */
+  cx_clear(MC417_RWD, SP2_CS0);
+
+  /* read/write */
+  cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+  timeout = jiffies + msecs_to_jiffies(1);
+  for (;;) {
+  tmp = cx_read(MC417_RWD);
+  if ((tmp  SP2_ACK) == 0)
+  break;
+  if (time_after(jiffies, timeout))
+  break;
+  udelay(1);
+  }
+
+  cx_set(MC417_RWD, SP2_CTRL_OFF);
+  *mem = tmp  0xff;
+
+  mutex_unlock(dev-gpio_lock);
+
+  if (!read)
+  if (*mem  0) {
+  ret = -EREMOTEIO;
+  goto err;
+  }
+
+  return 0;
+err:
+  return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
   struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1015,11 @@ static int dvb_register(struct cx23885_tsport *port)
   struct vb2_dvb_frontend *fe0, *fe1 = NULL;
   struct si2168_config si2168_config;
   struct si2157_config si2157_config;
+  struct sp2_config sp2_config;
   struct m88ts2022_config m88ts2022_config;
   struct i2c_board_info info;
   struct i2c_adapter *adapter;
-  struct i2c_client *client_demod;
-  struct i2c_client *client_tuner;
+  struct i2c_client *client_demod, *client_tuner, *client_ci;
   int mfe_shared = 0; /* bus not shared by default */
   int ret;
 
@@ -1683,6 +1754,7 @@ static int dvb_register(struct cx23885_tsport *port)
   break;
   case CX23885_BOARD_DVBSKY_T980C:
   i2c_bus = dev-i2c_bus[1];
+  i2c_bus2 = dev-i2c_bus[0];
 
   /* attach frontend */
   memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1892,35 @@ static int dvb_register(struct cx23885_tsport *port)
   case CX23885_BOARD_DVBSKY_T980C: {
   u8 eeprom[256]; /* 24C02 i2c eeprom */
 
+  /* attach CI */
+  memset(sp2_config, 0, sizeof(sp2_config));
+  sp2_config.dvb_adap = port-frontends.adapter;
+  sp2_config.priv = port;
+  sp2_config.ci_control = cx23885_sp2_ci_ctrl;
+  memset(info, 0, sizeof(struct i2c_board_info));
+  strlcpy(info.type, sp2, I2C_NAME_SIZE);
+  info.addr = 0x40;
+  info.platform_data = sp2_config;
+  request_module(info.type);
+  client_ci = i2c_new_device(i2c_bus2-i2c_adap, info);
+  if (client_ci == NULL ||
+   

Re: [PATCH 2/2] af9033: fix snr value not correct issue

2014-09-29 Thread Antti Palosaari



On 09/29/2014 11:47 AM, Bimow Chen wrote:

Snr returns value not correct. Fix it.


And same here. You change SNR, which is reported by dB to relative 
0-0x. If you like to do it for some reason, then do it for DVBv3 API 
only. Leave new DVBv5 statistic API reports to dB.


I am pretty sure we should report DVBv5 signals using dB if possible, 
not relative.



regards
Antti




0002-af9033-fix-snr-value-not-correct-issue.patch



From 427a5c6ef49e3235ac35a0464c375f2a2706619e Mon Sep 17 00:00:00 2001

From: Bimow Chenbimow.c...@ite.com.tw
Date: Mon, 29 Sep 2014 16:30:52 +0800
Subject: [PATCH 2/2] af9033: fix snr value not correct issue

Snr returns value not correct. Fix it.

Signed-off-by: Bimow Chenbimow.c...@ite.com.tw
---
  drivers/media/dvb-frontends/af9033.c  |   52 ++---
  drivers/media/dvb-frontends/af9033_priv.h |5 ++-
  2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9033.c 
b/drivers/media/dvb-frontends/af9033.c
index e191bd5..30dc366 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -851,8 +851,8 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 
*snr)
struct dtv_frontend_properties *c = dev-fe.dtv_property_cache;

/* use DVBv5 CNR */
-   if (c-cnr.stat[0].scale == FE_SCALE_DECIBEL)
-   *snr = div_s64(c-cnr.stat[0].svalue, 100); /* 1000x = 10x */
+   if (c-cnr.stat[0].scale == FE_SCALE_RELATIVE)
+   *snr = c-cnr.stat[0].uvalue;
else
*snr = 0;

@@ -1025,6 +1025,33 @@ static void af9033_stat_work(struct work_struct *work)

snr_val = (buf[2]  16) | (buf[1]  8) | (buf[0]  0);

+   /* read superframe number */
+   ret = af9033_rd_reg(dev, 0x80f78b, u8tmp);
+   if (ret)
+   goto err;
+
+   if (u8tmp)
+   snr_val /= u8tmp;
+
+   /* read current transmission mode */
+   ret = af9033_rd_reg(dev, 0x80f900, u8tmp);
+   if (ret)
+   goto err;
+
+   switch ((u8tmp  0)  3) {
+   case 0:
+   snr_val *= 4;
+   break;
+   case 1:
+   snr_val *= 1;
+   break;
+   case 2:
+   snr_val *= 2;
+   break;
+   default:
+   goto err;
+   }
+
/* read current modulation */
ret = af9033_rd_reg(dev, 0x80f903, u8tmp);
if (ret)
@@ -1048,14 +1075,29 @@ static void af9033_stat_work(struct work_struct *work)
}

for (i = 0; i  len; i++) {
-   tmp = snr_lut[i].snr * 1000;
+   tmp = snr_lut[i].snr;
if (snr_val  snr_lut[i].val)
break;
}

+   /* scale value to 0x-0x */
+   switch ((u8tmp  0)  3) {
+   case 0:
+   tmp = tmp * 0x / 23;
+   break;
+   case 1:
+   tmp = tmp * 0x / 26;
+   break;
+   case 2:
+   tmp = tmp * 0x / 32;
+   break;
+   default:
+   goto err;
+   }
+
c-cnr.len = 1;
-   c-cnr.stat[0].scale = FE_SCALE_DECIBEL;
-   c-cnr.stat[0].svalue = tmp;
+   c-cnr.stat[0].scale = FE_SCALE_RELATIVE;
+   c-cnr.stat[0].uvalue = tmp;
} else {
c-cnr.len = 1;
c-cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
diff --git a/drivers/media/dvb-frontends/af9033_priv.h 
b/drivers/media/dvb-frontends/af9033_priv.h
index c9c8798..8e23275 100644
--- a/drivers/media/dvb-frontends/af9033_priv.h
+++ b/drivers/media/dvb-frontends/af9033_priv.h
@@ -181,7 +181,10 @@ static const struct val_snr qam64_snr_lut[] = {
{ 0x05570d, 26 },
{ 0x059feb, 27 },
{ 0x05bf38, 28 },
-   { 0xff, 29 },
+   { 0x05f78f, 29 },
+   { 0x0612c3, 30 },
+   { 0x0626be, 31 },
+   { 0xff, 32 },
  };

  static const struct reg_val ofsm_init[] = {
-- 1.7.0.4



--
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 5/5] cx23855: add CI support for DVBSky T980C

2014-09-29 Thread Olli Salonen
Hi Max,

Thanks for the comments. I looked through the existing CIMaX driver
and came to the conclusion that it can be implemented either with the
IRQs or then just to rely on the polling like the USB devices have to
do. I don't think it's that important, as the user probably will not
add/remove the CAM that often. That being said, of course it would be
nice if we had a config option to choose if IRQ is supported or not.
If you have a patch for that, I'm happy to have it in.

Cheers,
-olli


On 29 September 2014 15:05, Nibble Max nibble@gmail.com wrote:
 Hello,
 In hardware design, the CI host controller is wired with GPIO_0 of CX23885.
 The GPIO_0 can be configed as the interrupt source.
 Interrupt mode in PCIe driver is more faster than poll mode to detect CAM 
 insert/remove operations etc.

Add CI support for DVBSky T980C.

I used the new host device independent CIMaX SP2 I2C driver to implement it.

cx23885_sp2_ci_ctrl function is borrowed entirely from cimax2.c.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 105 
 +++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..70dbcd6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h

@@ -616,6 +617,76 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
   return 0;
 }

+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+  u8 data, int *mem)
+{
+
+  /* MC417 */
+  #define SP2_DATA  0x00ff
+  #define SP2_WR0x8000
+  #define SP2_RD0x4000
+  #define SP2_ACK   0x1000
+  #define SP2_ADHI  0x0800
+  #define SP2_ADLO  0x0400
+  #define SP2_CS1   0x0200
+  #define SP2_CS0   0x0100
+  #define SP2_EN_ALL0x1000
+  #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+  struct cx23885_tsport *port = priv;
+  struct cx23885_dev *dev = port-dev;
+  int ret;
+  int tmp;
+  unsigned long timeout;
+
+  mutex_lock(dev-gpio_lock);
+
+  /* write addr */
+  cx_write(MC417_OEN, SP2_EN_ALL);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADLO | (0xff  addr));
+  cx_clear(MC417_RWD, SP2_ADLO);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADHI | (0xff  (addr  8)));
+  cx_clear(MC417_RWD, SP2_ADHI);
+
+  if (read) { /* data in */
+  cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+  } else /* data out */
+  cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+  /* chip select 0 */
+  cx_clear(MC417_RWD, SP2_CS0);
+
+  /* read/write */
+  cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+  timeout = jiffies + msecs_to_jiffies(1);
+  for (;;) {
+  tmp = cx_read(MC417_RWD);
+  if ((tmp  SP2_ACK) == 0)
+  break;
+  if (time_after(jiffies, timeout))
+  break;
+  udelay(1);
+  }
+
+  cx_set(MC417_RWD, SP2_CTRL_OFF);
+  *mem = tmp  0xff;
+
+  mutex_unlock(dev-gpio_lock);
+
+  if (!read)
+  if (*mem  0) {
+  ret = -EREMOTEIO;
+  goto err;
+  }
+
+  return 0;
+err:
+  return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
   struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1015,11 @@ static int dvb_register(struct cx23885_tsport *port)
   struct vb2_dvb_frontend *fe0, *fe1 = NULL;
   struct si2168_config si2168_config;
   struct si2157_config si2157_config;
+  struct sp2_config sp2_config;
   struct m88ts2022_config m88ts2022_config;
   struct i2c_board_info info;
   struct i2c_adapter *adapter;
-  struct i2c_client *client_demod;
-  struct i2c_client *client_tuner;
+  struct i2c_client *client_demod, *client_tuner, *client_ci;
   int mfe_shared = 0; /* bus not shared by default */
   int ret;

@@ -1683,6 +1754,7 @@ static int dvb_register(struct cx23885_tsport *port)
   break;
   case CX23885_BOARD_DVBSKY_T980C:
   i2c_bus = dev-i2c_bus[1];
+  i2c_bus2 = dev-i2c_bus[0];

   /* attach frontend */
   memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1892,35 @@ static int dvb_register(struct cx23885_tsport *port)
   case CX23885_BOARD_DVBSKY_T980C: {
   u8 eeprom[256]; /* 24C02 i2c eeprom */

+  /* attach CI */
+  

[PATCH 6/6] [media] coda: add support for partial interleaved YCbCr 4:2:0 (NV12) format

2014-09-29 Thread Philipp Zabel
This patch adds support for the two-plane NV12 format with one luma plane
and one interleaved chroma plane.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c| 26 +-
 drivers/media/platform/coda/coda-common.c |  8 
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 3839e35..fde7775 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -729,6 +729,9 @@ static int coda_start_encoding(struct coda_ctx *ctx)
break;
}
 
+   ctx-frame_mem_ctrl = ~CODA_FRAME_CHROMA_INTERLEAVE;
+   if (q_data_src-fourcc == V4L2_PIX_FMT_NV12)
+   ctx-frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE;
coda_write(dev, ctx-frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL);
 
if (dev-devtype-product == CODA_DX6) {
@@ -1128,7 +1131,6 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
coda_write(dev, rot_mode, CODA_CMD_ENC_PIC_ROT_MODE);
coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS);
 
-
if (dev-devtype-product == CODA_960) {
coda_write(dev, 4/*FIXME: 0*/, CODA9_CMD_ENC_PIC_SRC_INDEX);
coda_write(dev, q_data_src-width, 
CODA9_CMD_ENC_PIC_SRC_STRIDE);
@@ -1273,7 +1275,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
u32 bitstream_buf, bitstream_size;
struct coda_dev *dev = ctx-dev;
int width, height;
-   u32 src_fourcc;
+   u32 src_fourcc, dst_fourcc;
u32 val;
int ret;
 
@@ -1283,6 +1285,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
bitstream_buf = ctx-bitstream.paddr;
bitstream_size = ctx-bitstream.size;
src_fourcc = q_data_src-fourcc;
+   dst_fourcc = q_data_dst-fourcc;
 
/* Allocate per-instance buffers */
ret = coda_alloc_context_buffers(ctx, q_data_src);
@@ -1294,6 +1297,9 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
/* Update coda bitstream read and write pointers from kfifo */
coda_kfifo_sync_to_device_full(ctx);
 
+   ctx-frame_mem_ctrl = ~CODA_FRAME_CHROMA_INTERLEAVE;
+   if (dst_fourcc == V4L2_PIX_FMT_NV12)
+   ctx-frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE;
coda_write(dev, ctx-frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL);
 
ctx-display_idx = -1;
@@ -1424,13 +1430,23 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
}
 
if (dev-devtype-product == CODA_960) {
-   coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY);
+   int cbb_size, crb_size;
 
+   coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY);
+   /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */
coda_write(dev, 0x20262024, CODA9_CMD_SET_FRAME_CACHE_SIZE);
+
+   if (dst_fourcc == V4L2_PIX_FMT_NV12) {
+   cbb_size = 0;
+   crb_size = 16;
+   } else {
+   cbb_size = 8;
+   crb_size = 8;
+   }
coda_write(dev, 2  CODA9_CACHE_PAGEMERGE_OFFSET |
32  CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
-   8  CODA9_CACHE_CB_BUFFER_SIZE_OFFSET |
-   8  CODA9_CACHE_CR_BUFFER_SIZE_OFFSET,
+   cbb_size  CODA9_CACHE_CB_BUFFER_SIZE_OFFSET |
+   crb_size  CODA9_CACHE_CR_BUFFER_SIZE_OFFSET,
CODA9_CMD_SET_FRAME_CACHE_CONFIG);
}
 
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index feb270f..02d47fa 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -95,6 +95,7 @@ void coda_write_base(struct coda_ctx *ctx, struct coda_q_data 
*q_data,
base_cb = base_cr + q_data-bytesperline * q_data-height / 4;
break;
case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_NV12:
default:
base_cb = base_y + q_data-bytesperline * q_data-height;
base_cr = base_cb + q_data-bytesperline * q_data-height / 4;
@@ -119,6 +120,10 @@ static const struct coda_fmt coda_formats[] = {
.fourcc = V4L2_PIX_FMT_YVU420,
},
{
+   .name = YUV 4:2:0 Partial interleaved Y/CbCr,
+   .fourcc = V4L2_PIX_FMT_NV12,
+   },
+   {
.name = H264 Encoded Stream,
.fourcc = V4L2_PIX_FMT_H264,
},
@@ -162,6 +167,7 @@ static bool coda_format_is_yuv(u32 fourcc)
switch (fourcc) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
+   case V4L2_PIX_FMT_NV12:
return true;
default:
return 

[PATCH 0/6] CODA fixes and NV12 support

2014-09-29 Thread Philipp Zabel
Hi,

this series fixes restarting of streams, cleans up a superfluous error message,
unifies the YUV buffer base pointer setup, disables the encoder rotator unit
when copying input buffers into the internal frame memory if not needed,
simplifies the frame memory control register handling (no need to clear magic
bits if we wrote 0 in the first place), and adds support for the NV12 pixel
format.

regards
Philipp

Philipp Zabel (6):
  [media] coda: clear aborting flag in stop_streaming
  [media] coda: remove superfluous error message on devm_kzalloc failure
  [media] coda: add coda_write_base helper
  [media] coda: disable rotator if not needed
  [media] coda: simplify frame memory control register handling
  [media] coda: add support for partial interleaved YCbCr 4:2:0 (NV12)
format

 drivers/media/platform/coda/coda-bit.c| 108 --
 drivers/media/platform/coda/coda-common.c |  43 ++--
 drivers/media/platform/coda/coda.h|   2 +
 3 files changed, 82 insertions(+), 71 deletions(-)

-- 
2.1.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 1/6] [media] coda: clear aborting flag in stop_streaming

2014-09-29 Thread Philipp Zabel
Clearing the aborting flag in stop_streaming is necessary if we want to start
streaming again without having to closing and reopening the device. Also,
do not explicitly set it in default_params; the context is zeroed by
kzalloc anyway.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index ced4760..3f8a04f 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -880,7 +880,6 @@ static void set_default_params(struct coda_ctx *ctx)
ctx-params.codec_mode = ctx-codec-mode;
ctx-colorspace = V4L2_COLORSPACE_REC709;
ctx-params.framerate = 30;
-   ctx-aborting = 0;
 
/* Default formats for output and input queues */
ctx-q_data[V4L2_M2M_SRC].fourcc = ctx-codec-src_fourcc;
@@ -1144,6 +1143,7 @@ static void coda_stop_streaming(struct vb2_queue *q)
kfifo_init(ctx-bitstream_fifo,
ctx-bitstream.vaddr, ctx-bitstream.size);
ctx-runcounter = 0;
+   ctx-aborting = 0;
}
 }
 
-- 
2.1.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 3/6] [media] coda: add coda_write_base helper

2014-09-29 Thread Philipp Zabel
Add a helper function that writes a vb2_buffer's Y, Cb, and
Cr plane base addresses of into three consecutive registers.
This moves common code out of coda-bit.c.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c| 68 +++
 drivers/media/platform/coda/coda-common.c | 24 +++
 drivers/media/platform/coda/coda.h|  2 +
 3 files changed, 40 insertions(+), 54 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 9b8ea8b..f01393c 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1036,9 +1036,9 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
struct coda_dev *dev = ctx-dev;
int force_ipicture;
int quant_param = 0;
-   u32 picture_y, picture_cb, picture_cr;
u32 pic_stream_buffer_addr, pic_stream_buffer_size;
u32 dst_fourcc;
+   u32 reg;
 
src_buf = v4l2_m2m_next_src_buf(ctx-fh.m2m_ctx);
dst_buf = v4l2_m2m_next_dst_buf(ctx-fh.m2m_ctx);
@@ -1129,37 +1129,17 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS);
 
 
-   picture_y = vb2_dma_contig_plane_dma_addr(src_buf, 0);
-   switch (q_data_src-fourcc) {
-   case V4L2_PIX_FMT_YVU420:
-   /* Switch Cb and Cr for YVU420 format */
-   picture_cr = picture_y + q_data_src-bytesperline *
-   q_data_src-height;
-   picture_cb = picture_cr + q_data_src-bytesperline / 2 *
-   q_data_src-height / 2;
-   break;
-   case V4L2_PIX_FMT_YUV420:
-   default:
-   picture_cb = picture_y + q_data_src-bytesperline *
-   q_data_src-height;
-   picture_cr = picture_cb + q_data_src-bytesperline / 2 *
-   q_data_src-height / 2;
-   break;
-   }
-
if (dev-devtype-product == CODA_960) {
coda_write(dev, 4/*FIXME: 0*/, CODA9_CMD_ENC_PIC_SRC_INDEX);
coda_write(dev, q_data_src-width, 
CODA9_CMD_ENC_PIC_SRC_STRIDE);
coda_write(dev, 0, CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC);
 
-   coda_write(dev, picture_y, CODA9_CMD_ENC_PIC_SRC_ADDR_Y);
-   coda_write(dev, picture_cb, CODA9_CMD_ENC_PIC_SRC_ADDR_CB);
-   coda_write(dev, picture_cr, CODA9_CMD_ENC_PIC_SRC_ADDR_CR);
+   reg = CODA9_CMD_ENC_PIC_SRC_ADDR_Y;
} else {
-   coda_write(dev, picture_y, CODA_CMD_ENC_PIC_SRC_ADDR_Y);
-   coda_write(dev, picture_cb, CODA_CMD_ENC_PIC_SRC_ADDR_CB);
-   coda_write(dev, picture_cr, CODA_CMD_ENC_PIC_SRC_ADDR_CR);
+   reg = CODA_CMD_ENC_PIC_SRC_ADDR_Y;
}
+   coda_write_base(ctx, q_data_src, src_buf, reg);
+
coda_write(dev, force_ipicture  1  0x2,
   CODA_CMD_ENC_PIC_OPTION);
 
@@ -1501,20 +1481,11 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
struct vb2_buffer *dst_buf;
struct coda_dev *dev = ctx-dev;
struct coda_q_data *q_data_dst;
-   u32 stridey, height;
-   u32 picture_y, picture_cb, picture_cr;
+   u32 reg_addr, reg_stride;
 
dst_buf = v4l2_m2m_next_dst_buf(ctx-fh.m2m_ctx);
q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
 
-   if (ctx-params.rot_mode  CODA_ROT_90) {
-   stridey = q_data_dst-height;
-   height = q_data_dst-width;
-   } else {
-   stridey = q_data_dst-width;
-   height = q_data_dst-height;
-   }
-
/* Try to copy source buffer contents into the bitstream ringbuffer */
mutex_lock(ctx-bitstream_mutex);
coda_fill_bitstream(ctx);
@@ -1545,17 +1516,6 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
if (dev-devtype-product == CODA_960)
coda_set_gdi_regs(ctx);
 
-   /* Set rotator output */
-   picture_y = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
-   if (q_data_dst-fourcc == V4L2_PIX_FMT_YVU420) {
-   /* Switch Cr and Cb for YVU420 format */
-   picture_cr = picture_y + stridey * height;
-   picture_cb = picture_cr + stridey / 2 * height / 2;
-   } else {
-   picture_cb = picture_y + stridey * height;
-   picture_cr = picture_cb + stridey / 2 * height / 2;
-   }
-
if (dev-devtype-product == CODA_960) {
/*
 * The CODA960 seems to have an internal list of buffers with
@@ -1565,16 +1525,16 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
 */
coda_write(dev, CODA_MAX_FRAMEBUFFERS + dst_buf-v4l2_buf.index,
CODA9_CMD_DEC_PIC_ROT_INDEX);
-   coda_write(dev, picture_y, 

[PATCH 4/6] [media] coda: disable rotator if not needed

2014-09-29 Thread Philipp Zabel
This will still do a 1:1 copy into the internal buffers, but stop
producing visual artifacts in chroma interleaved (NV12) mode.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index f01393c..747b544 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1037,6 +1037,7 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
int force_ipicture;
int quant_param = 0;
u32 pic_stream_buffer_addr, pic_stream_buffer_size;
+   u32 rot_mode = 0;
u32 dst_fourcc;
u32 reg;
 
@@ -1124,8 +1125,9 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
}
 
/* submit */
-   coda_write(dev, CODA_ROT_MIR_ENABLE | ctx-params.rot_mode,
-  CODA_CMD_ENC_PIC_ROT_MODE);
+   if (ctx-params.rot_mode)
+   rot_mode = CODA_ROT_MIR_ENABLE | ctx-params.rot_mode;
+   coda_write(dev, rot_mode, CODA_CMD_ENC_PIC_ROT_MODE);
coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS);
 
 
-- 
2.1.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 5/6] [media] coda: simplify frame memory control register handling

2014-09-29 Thread Philipp Zabel
Since the firmware newer writes to FRAME_MEM_CTRL, we can initialize it once
per context (incidentally, we already do write it in coda_hw_init) and never
have to read it back.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-bit.c| 8 
 drivers/media/platform/coda/coda-common.c | 4 +++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 747b544..3839e35 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -729,10 +729,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
break;
}
 
-   value = coda_read(dev, CODA_REG_BIT_FRAME_MEM_CTRL);
-   value = ~(1  2 | 0x7  9);
-   ctx-frame_mem_ctrl = value;
-   coda_write(dev, value, CODA_REG_BIT_FRAME_MEM_CTRL);
+   coda_write(dev, ctx-frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL);
 
if (dev-devtype-product == CODA_DX6) {
/* Configure the coda */
@@ -741,6 +738,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
}
 
/* Could set rotation here if needed */
+   value = 0;
switch (dev-devtype-product) {
case CODA_DX6:
value = (q_data_src-width  CODADX6_PICWIDTH_MASK)
@@ -1296,6 +1294,8 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
/* Update coda bitstream read and write pointers from kfifo */
coda_kfifo_sync_to_device_full(ctx);
 
+   coda_write(dev, ctx-frame_mem_ctrl, CODA_REG_BIT_FRAME_MEM_CTRL);
+
ctx-display_idx = -1;
ctx-frm_dis_flg = 0;
coda_write(dev, 0, CODA_REG_BIT_FRM_DIS_FLG(ctx-reg_idx));
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index fac2517..feb270f 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1423,8 +1423,10 @@ static int coda_open(struct file *file, enum 
coda_inst_type inst_type,
ctx-dev = dev;
ctx-idx = idx;
switch (dev-devtype-product) {
-   case CODA_7541:
case CODA_960:
+   ctx-frame_mem_ctrl = 1  12;
+   /* fallthrough */
+   case CODA_7541:
ctx-reg_idx = 0;
break;
default:
-- 
2.1.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 2/6] [media] coda: remove superfluous error message on devm_kzalloc failure

2014-09-29 Thread Philipp Zabel
When devm_kzalloc causes an OOM condition, this is already reported by
the MM subsystem.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/platform/coda/coda-common.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 3f8a04f..538d4ac 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1846,11 +1846,8 @@ static int coda_probe(struct platform_device *pdev)
int ret, irq;
 
dev = devm_kzalloc(pdev-dev, sizeof(*dev), GFP_KERNEL);
-   if (!dev) {
-   dev_err(pdev-dev, Not enough memory for %s\n,
-   CODA_NAME);
+   if (!dev)
return -ENOMEM;
-   }
 
spin_lock_init(dev-irqlock);
INIT_LIST_HEAD(dev-instances);
-- 
2.1.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 v2 2/5] video: add RGB444_1X12 and RGB565_1X16 bus formats

2014-09-29 Thread Boris Brezillon
Add RGB444 format using a 12 bits bus and RGB565 using a 16 bits bus.

These formats will later be used by atmel-hlcdc driver.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
---
 include/uapi/linux/v4l2-mediabus.h| 2 ++
 include/uapi/linux/video-bus-format.h | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 7b0a06c..05336d6 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -33,6 +33,8 @@ enum v4l2_mbus_pixelcode {
VIDEO_BUS_TO_V4L2_MBUS(RGB888_2X12_BE),
VIDEO_BUS_TO_V4L2_MBUS(RGB888_2X12_LE),
VIDEO_BUS_TO_V4L2_MBUS(ARGB_1X32),
+   VIDEO_BUS_TO_V4L2_MBUS(RGB444_1X12),
+   VIDEO_BUS_TO_V4L2_MBUS(RGB565_1X16),
 
VIDEO_BUS_TO_V4L2_MBUS(Y8_1X8),
VIDEO_BUS_TO_V4L2_MBUS(UV8_1X8),
diff --git a/include/uapi/linux/video-bus-format.h 
b/include/uapi/linux/video-bus-format.h
index 4abbd5d..f85f7ee 100644
--- a/include/uapi/linux/video-bus-format.h
+++ b/include/uapi/linux/video-bus-format.h
@@ -34,7 +34,7 @@
 enum video_bus_format {
VIDEO_BUS_FMT_FIXED = 0x0001,
 
-   /* RGB - next is 0x100e */
+   /* RGB - next is 0x1010 */
VIDEO_BUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
VIDEO_BUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
VIDEO_BUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
@@ -48,6 +48,8 @@ enum video_bus_format {
VIDEO_BUS_FMT_RGB888_2X12_BE = 0x100b,
VIDEO_BUS_FMT_RGB888_2X12_LE = 0x100c,
VIDEO_BUS_FMT_ARGB_1X32 = 0x100d,
+   VIDEO_BUS_FMT_RGB444_1X12 = 0x100e,
+   VIDEO_BUS_FMT_RGB565_1X16 = 0x100f,
 
/* YUV (including grey) - next is 0x2024 */
VIDEO_BUS_FMT_Y8_1X8 = 0x2001,
-- 
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


[PATCH v2 4/5] drm: panel: simple-panel: add support for bus_format retrieval

2014-09-29 Thread Boris Brezillon
From: Boris BREZILLON boris.brezil...@free-electrons.com

Provide a way to specify panel requirement in terms of supported media bus
format (particularly useful for panels connected to an RGB or LVDS bus).

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
---
 drivers/gpu/drm/panel/panel-simple.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4ce1db0..eb3a17e 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -61,6 +61,8 @@ struct panel_desc {
unsigned int disable;
unsigned int unprepare;
} delay;
+
+   enum video_bus_format bus_format;
 };
 
 struct panel_simple {
@@ -111,6 +113,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple 
*panel)
connector-display_info.bpc = panel-desc-bpc;
connector-display_info.width_mm = panel-desc-size.width;
connector-display_info.height_mm = panel-desc-size.height;
+   if (panel-desc-bus_format)
+   drm_display_info_set_bus_formats(connector-display_info,
+panel-desc-bus_format, 1);
 
return num;
 }
-- 
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


[PATCH v2 5/5] drm: panel: simple-panel: add bus format information for foxlink panel

2014-09-29 Thread Boris Brezillon
From: Boris BREZILLON boris.brezil...@free-electrons.com

Foxlink's fl500wvr00-a0t supports RGB888 format.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
---
 drivers/gpu/drm/panel/panel-simple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index eb3a17e..11bff3f 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -521,6 +521,7 @@ static const struct panel_desc foxlink_fl500wvr00_a0t = {
.width = 108,
.height = 65,
},
+   .bus_format = VIDEO_BUS_FMT_RGB888_1X24,
 };
 
 static const struct drm_display_mode innolux_n116bge_mode = {
-- 
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


[PATCH v2 3/5] drm: add bus_formats and nbus_formats fields to drm_display_info

2014-09-29 Thread Boris Brezillon
From: Boris BREZILLON boris.brezil...@free-electrons.com

Add bus_formats and nbus_formats fields and
drm_display_info_set_bus_formats helper function to specify the bus
formats supported by a given display.

This information can be used by display controller drivers to configure
the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
RGB or LVDS busses).

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
---
 drivers/gpu/drm/drm_crtc.c | 31 +++
 include/drm/drm_crtc.h |  8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 90e7730..c31420f 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -852,6 +852,37 @@ static void drm_mode_remove(struct drm_connector 
*connector,
drm_mode_destroy(connector-dev, mode);
 }
 
+/*
+ * drm_display_info_set_bus_formats - set the supported bus formats
+ * @info: display info to store bus formats in
+ * @fmts: array containing the supported bus formats
+ * @nfmts: the number of entries in the fmts array
+ *
+ * Store the suppported bus formats in display info structure.
+ */
+int drm_display_info_set_bus_formats(struct drm_display_info *info,
+const enum video_bus_format *fmts,
+unsigned int num_fmts)
+{
+   enum video_bus_format *formats = NULL;
+
+   if (!fmts  num_fmts)
+   return -EINVAL;
+
+   if (fmts  num_fmts) {
+   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
+   if (!formats)
+   return -ENOMEM;
+   }
+
+   kfree(info-bus_formats);
+   info-bus_formats = formats;
+   info-num_bus_formats = num_fmts;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_display_info_set_bus_formats);
+
 /**
  * drm_connector_init - Init a preallocated connector
  * @dev: DRM device
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f1105d0..488f779 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
 #include linux/idr.h
 #include linux/fb.h
 #include linux/hdmi.h
+#include linux/video-bus-format.h
 #include drm/drm_mode.h
 #include drm/drm_fourcc.h
 #include drm/drm_modeset_lock.h
@@ -130,6 +131,9 @@ struct drm_display_info {
enum subpixel_order subpixel_order;
u32 color_formats;
 
+   const enum video_bus_format *bus_formats;
+   int num_bus_formats;
+
/* Mask of supported hdmi deep color modes */
u8 edid_hdmi_dc_modes;
 
@@ -975,6 +979,10 @@ extern int drm_mode_connector_set_path_property(struct 
drm_connector *connector,
 extern int drm_mode_connector_update_edid_property(struct drm_connector 
*connector,
struct edid *edid);
 
+extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
+   const enum video_bus_format *fmts,
+   unsigned int nfmts);
+
 static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
 {
-- 
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


[PATCH v2 0/5] video: describe data bus formats

2014-09-29 Thread Boris Brezillon
Hello,

This patch series is a proposal to describe the different data formats used
by HW components to connect with each other.

This is just a copy of the existing V4L2_MBUS_FMT defintions with a neutral
name so that it can be used by V4L2 and DRM/KMS subsystem.

This series also makes use of this video_bus_format enum in the DRM/KMS
subsystem to define the data fomats supported on the connector - device
link.

Best Regards,

Boris

Changes since v1:
 - define an enum and use a macro for v4l2 bus formats definitions
 - rename nformats into num_formats
 - declare num_formats as an unsigned int

Boris BREZILLON (3):
  drm: add bus_formats and nbus_formats fields to drm_display_info
  drm: panel: simple-panel: add support for bus_format retrieval
  drm: panel: simple-panel: add bus format information for foxlink panel

Boris Brezillon (2):
  video: move mediabus format definition to a more standard place
  video: add RGB444_1X12 and RGB565_1X16 bus formats

 drivers/gpu/drm/drm_crtc.c|  31 ++
 drivers/gpu/drm/panel/panel-simple.c  |   6 ++
 include/drm/drm_crtc.h|   8 ++
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/v4l2-mediabus.h| 185 +++---
 include/uapi/linux/video-bus-format.h | 129 
 6 files changed, 256 insertions(+), 104 deletions(-)
 create mode 100644 include/uapi/linux/video-bus-format.h

-- 
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 v2 1/5] video: move mediabus format definition to a more standard place

2014-09-29 Thread Boris BREZILLON
On Mon, 29 Sep 2014 16:02:39 +0200
Boris Brezillon boris.brezil...@free-electrons.com wrote:

 Rename mediabus formats and move the enum into a separate header file so
 that it can be used by DRM/KMS subsystem without any reference to the V4L2
 subsystem.
 
 Old V4L2_MBUS_FMT_ definitions are now macros that points to VIDEO_BUS_FMT_
 definitions.

I forgot to change the commit message: v4l2_mbus_pixelcode is now an
enum that takes its values from the VIDEO_BUS_FMT_ definitions (as
suggested by Guennadi).


 
 Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
 Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
  include/uapi/linux/Kbuild |   1 +
  include/uapi/linux/v4l2-mediabus.h| 183 
 +++---
  include/uapi/linux/video-bus-format.h | 127 +++
  3 files changed, 207 insertions(+), 104 deletions(-)
  create mode 100644 include/uapi/linux/video-bus-format.h
 
 diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
 index be88166..8712730 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -410,6 +410,7 @@ header-y += veth.h
  header-y += vfio.h
  header-y += vhost.h
  header-y += videodev2.h
 +header-y += video-bus-format.h
  header-y += virtio_9p.h
  header-y += virtio_balloon.h
  header-y += virtio_blk.h
 diff --git a/include/uapi/linux/v4l2-mediabus.h 
 b/include/uapi/linux/v4l2-mediabus.h
 index 1445e85..7b0a06c 100644
 --- a/include/uapi/linux/v4l2-mediabus.h
 +++ b/include/uapi/linux/v4l2-mediabus.h
 @@ -13,118 +13,93 @@
  
  #include linux/types.h
  #include linux/videodev2.h
 +#include linux/video-bus-format.h
  
 -/*
 - * These pixel codes uniquely identify data formats on the media bus. Mostly
 - * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
 - * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where 
 the
 - * data format is fixed. Additionally, 2X8 means that one pixel is 
 transferred
 - * in two 8-bit samples, BE or LE specify in which order those samples 
 are
 - * transferred over the bus: LE means that the least significant bits are
 - * transferred first, BE means that the most significant bits are 
 transferred
 - * first, and PADHI and PADLO define which bits - low or high, in the
 - * incomplete high byte, are filled with padding bits.
 - *
 - * The pixel codes are grouped by type, bus_width, bits per component, 
 samples
 - * per pixel and order of subsamples. Numerical values are sorted using 
 generic
 - * numerical sort order (8 thus comes before 10).
 - *
 - * As their value can't change when a new pixel code is inserted in the
 - * enumeration, the pixel codes are explicitly given a numerical value. The 
 next
 - * free values for each category are listed below, update them when inserting
 - * new pixel codes.
 - */
 -enum v4l2_mbus_pixelcode {
 - V4L2_MBUS_FMT_FIXED = 0x0001,
 +#define VIDEO_BUS_TO_V4L2_MBUS(x)V4L2_MBUS_FMT_ ## x = VIDEO_BUS_FMT_ ## 
 x
  
 - /* RGB - next is 0x100e */
 - V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
 - V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
 - V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
 - V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
 - V4L2_MBUS_FMT_BGR565_2X8_BE = 0x1005,
 - V4L2_MBUS_FMT_BGR565_2X8_LE = 0x1006,
 - V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
 - V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
 - V4L2_MBUS_FMT_RGB666_1X18 = 0x1009,
 - V4L2_MBUS_FMT_RGB888_1X24 = 0x100a,
 - V4L2_MBUS_FMT_RGB888_2X12_BE = 0x100b,
 - V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
 - V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
 +enum v4l2_mbus_pixelcode {
 + VIDEO_BUS_TO_V4L2_MBUS(FIXED),
  
 - /* YUV (including grey) - next is 0x2024 */
 - V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
 - V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
 - V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
 - V4L2_MBUS_FMT_VYUY8_1_5X8 = 0x2003,
 - V4L2_MBUS_FMT_YUYV8_1_5X8 = 0x2004,
 - V4L2_MBUS_FMT_YVYU8_1_5X8 = 0x2005,
 - V4L2_MBUS_FMT_UYVY8_2X8 = 0x2006,
 - V4L2_MBUS_FMT_VYUY8_2X8 = 0x2007,
 - V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
 - V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
 - V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
 - V4L2_MBUS_FMT_UYVY10_2X10 = 0x2018,
 - V4L2_MBUS_FMT_VYUY10_2X10 = 0x2019,
 - V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
 - V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
 - V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
 - V4L2_MBUS_FMT_UYVY8_1X16 = 0x200f,
 - V4L2_MBUS_FMT_VYUY8_1X16 = 0x2010,
 - V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
 - V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
 - V4L2_MBUS_FMT_YDYUYDYV8_1X16 = 0x2014,
 - V4L2_MBUS_FMT_UYVY10_1X20 = 0x201a,
 - V4L2_MBUS_FMT_VYUY10_1X20 = 0x201b,
 - V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
 - V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
 - V4L2_MBUS_FMT_YUV10_1X30 = 0x2016,
 - V4L2_MBUS_FMT_AYUV8_1X32 = 0x2017,
 - V4L2_MBUS_FMT_UYVY12_2X12 = 0x201c,
 - V4L2_MBUS_FMT_VYUY12_2X12 = 0x201d,
 -

[PATCH v2 1/5] video: move mediabus format definition to a more standard place

2014-09-29 Thread Boris Brezillon
Rename mediabus formats and move the enum into a separate header file so
that it can be used by DRM/KMS subsystem without any reference to the V4L2
subsystem.

Old V4L2_MBUS_FMT_ definitions are now macros that points to VIDEO_BUS_FMT_
definitions.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/v4l2-mediabus.h| 183 +++---
 include/uapi/linux/video-bus-format.h | 127 +++
 3 files changed, 207 insertions(+), 104 deletions(-)
 create mode 100644 include/uapi/linux/video-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index be88166..8712730 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -410,6 +410,7 @@ header-y += veth.h
 header-y += vfio.h
 header-y += vhost.h
 header-y += videodev2.h
+header-y += video-bus-format.h
 header-y += virtio_9p.h
 header-y += virtio_balloon.h
 header-y += virtio_blk.h
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 1445e85..7b0a06c 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -13,118 +13,93 @@
 
 #include linux/types.h
 #include linux/videodev2.h
+#include linux/video-bus-format.h
 
-/*
- * These pixel codes uniquely identify data formats on the media bus. Mostly
- * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
- * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
- * data format is fixed. Additionally, 2X8 means that one pixel is 
transferred
- * in two 8-bit samples, BE or LE specify in which order those samples are
- * transferred over the bus: LE means that the least significant bits are
- * transferred first, BE means that the most significant bits are transferred
- * first, and PADHI and PADLO define which bits - low or high, in the
- * incomplete high byte, are filled with padding bits.
- *
- * The pixel codes are grouped by type, bus_width, bits per component, samples
- * per pixel and order of subsamples. Numerical values are sorted using generic
- * numerical sort order (8 thus comes before 10).
- *
- * As their value can't change when a new pixel code is inserted in the
- * enumeration, the pixel codes are explicitly given a numerical value. The 
next
- * free values for each category are listed below, update them when inserting
- * new pixel codes.
- */
-enum v4l2_mbus_pixelcode {
-   V4L2_MBUS_FMT_FIXED = 0x0001,
+#define VIDEO_BUS_TO_V4L2_MBUS(x)  V4L2_MBUS_FMT_ ## x = VIDEO_BUS_FMT_ ## 
x
 
-   /* RGB - next is 0x100e */
-   V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
-   V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
-   V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
-   V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
-   V4L2_MBUS_FMT_BGR565_2X8_BE = 0x1005,
-   V4L2_MBUS_FMT_BGR565_2X8_LE = 0x1006,
-   V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
-   V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
-   V4L2_MBUS_FMT_RGB666_1X18 = 0x1009,
-   V4L2_MBUS_FMT_RGB888_1X24 = 0x100a,
-   V4L2_MBUS_FMT_RGB888_2X12_BE = 0x100b,
-   V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
-   V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
+enum v4l2_mbus_pixelcode {
+   VIDEO_BUS_TO_V4L2_MBUS(FIXED),
 
-   /* YUV (including grey) - next is 0x2024 */
-   V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
-   V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
-   V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
-   V4L2_MBUS_FMT_VYUY8_1_5X8 = 0x2003,
-   V4L2_MBUS_FMT_YUYV8_1_5X8 = 0x2004,
-   V4L2_MBUS_FMT_YVYU8_1_5X8 = 0x2005,
-   V4L2_MBUS_FMT_UYVY8_2X8 = 0x2006,
-   V4L2_MBUS_FMT_VYUY8_2X8 = 0x2007,
-   V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
-   V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
-   V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
-   V4L2_MBUS_FMT_UYVY10_2X10 = 0x2018,
-   V4L2_MBUS_FMT_VYUY10_2X10 = 0x2019,
-   V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
-   V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
-   V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
-   V4L2_MBUS_FMT_UYVY8_1X16 = 0x200f,
-   V4L2_MBUS_FMT_VYUY8_1X16 = 0x2010,
-   V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
-   V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
-   V4L2_MBUS_FMT_YDYUYDYV8_1X16 = 0x2014,
-   V4L2_MBUS_FMT_UYVY10_1X20 = 0x201a,
-   V4L2_MBUS_FMT_VYUY10_1X20 = 0x201b,
-   V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
-   V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
-   V4L2_MBUS_FMT_YUV10_1X30 = 0x2016,
-   V4L2_MBUS_FMT_AYUV8_1X32 = 0x2017,
-   V4L2_MBUS_FMT_UYVY12_2X12 = 0x201c,
-   V4L2_MBUS_FMT_VYUY12_2X12 = 0x201d,
-   V4L2_MBUS_FMT_YUYV12_2X12 = 0x201e,
-   V4L2_MBUS_FMT_YVYU12_2X12 = 0x201f,
-   V4L2_MBUS_FMT_UYVY12_1X24 = 0x2020,
-   V4L2_MBUS_FMT_VYUY12_1X24 = 0x2021,
-   V4L2_MBUS_FMT_YUYV12_1X24 = 0x2022,
-   V4L2_MBUS_FMT_YVYU12_1X24 = 0x2023,
+   

Re: [PATCH 1/2] af9033: fix signal strength value not correct issue

2014-09-29 Thread Antti Palosaari


On 09/29/2014 03:02 PM, Antti Palosaari wrote:

On 09/29/2014 11:43 AM, Bimow Chen wrote:

Register 0x800048 is not dB measure but relative scale. Fix it and
conform to NorDig specifications.


eh, 0x800048 register returned strength normalized to 0-100 %. But that
was earlier when older firmwares used. I have seen it does not return
anything anymore, so I am very fine it is replaced with something
meaningful.

But the issues is that this patches changes current DVBv5 signal
reporting from dBm to relative. I indeed implemented it is as a dBm and
I checked it using modulator RF strength it really is dBm. Now you add
some glue which converts dBm to relative value between 0-0x.

I encourage you to use modulator yourself to generate signals. Then use
dvbv5-zap to see values DVBv5 API reports.

If you really want return 0-0x values, then do it for old DVBv3
read_signal_strength(), but do not change new DVBv5 statistics to
relative. dBm, as a clearly defined unit, is always preferred over
relative. Relative was added to API for cases we cannot report well
known units.

Could you tell which is unit NorDig specification defines for signal
strength?


According to latest NorDig specification, page 39
http://www.nordig.org/pdf/NorDig-Unified_ver_2.5.1.pdf
there is two kind of reports, basic and advanced. Normal report is (%) 
which suits well for relative scale.


The basic status check shall include:
* channel id, according to Annex B.2
* centre frequency
* Signal Strength Indicator, SSI (%), according to section 3.4.4.6
* Signal Quality Indicator, SQI (%), according to section 3.4.4.7


The terrestrial NorDig IRD should provide an advanced status check 
function (accessible through the Navigator) that presents the following 
information:

* channel id, according to Annex B.2
* centre frequency
* signal strength (dBm or dBμV)
* signal strength indicator, SSI (%), according to section 3.4.4.6
* signal quality indicator, SQI (%), according to section 3.4.4.7
* C/N (dB)
* BER before Reed Solomon decoding (DVB-T) or BCH decoding (DVB-T2)
* Uncorrected packets


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


[PATCH] Add IR support for DVBSky T9580 Dual DVB-S2/T2/C PCIe card

2014-09-29 Thread Nibble Max
DVBSky T9580 uses Integrated CX23885 IR controller to decode IR signal.
The IR type of DVBSky remote control is RC5.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/pci/cx23885/cx23885-cards.c | 3 +++
 drivers/media/pci/cx23885/cx23885-input.c | 8 
 2 files changed, 11 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 88c257d..d07f025 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1621,6 +1621,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_MYGICA_X8507:
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
+   case CX23885_BOARD_DVBSKY_T9580:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1667,6 +1668,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_MYGICA_X8507:
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
+   case CX23885_BOARD_DVBSKY_T9580:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1714,6 +1716,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_MYGICA_X8507:
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
+   case CX23885_BOARD_DVBSKY_T9580:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
diff --git a/drivers/media/pci/cx23885/cx23885-input.c 
b/drivers/media/pci/cx23885/cx23885-input.c
index 9d37fe6..f81c2f9 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -87,6 +87,7 @@ void cx23885_input_rx_work_handler(struct cx23885_dev *dev, 
u32 events)
case CX23885_BOARD_MYGICA_X8507:
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
+   case CX23885_BOARD_DVBSKY_T9580:
/*
 * The only boards we handle right now.  However other boards
 * using the CX2388x integrated IR controller should be similar
@@ -139,6 +140,7 @@ static int cx23885_input_ir_start(struct cx23885_dev *dev)
case CX23885_BOARD_HAUPPAUGE_HVR1290:
case CX23885_BOARD_HAUPPAUGE_HVR1250:
case CX23885_BOARD_MYGICA_X8507:
+   case CX23885_BOARD_DVBSKY_T9580:
/*
 * The IR controller on this board only returns pulse widths.
 * Any other mode setting will fail to set up the device.
@@ -305,6 +307,12 @@ int cx23885_input_init(struct cx23885_dev *dev)
/* A guess at the remote */
rc_map = RC_MAP_TBS_NEC;
break;
+   case CX23885_BOARD_DVBSKY_T9580:
+   /* Integrated CX23885 IR controller */
+   driver_type = RC_DRIVER_IR_RAW;
+   allowed_protos = RC_BIT_ALL;
+   rc_map = RC_MAP_DVBSKY;
+   break;
default:
return -ENODEV;
}
-- 
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


[PATCH] [media] pt3: remove bogus module_is_live() check

2014-09-29 Thread Arnd Bergmann
The new pt3 driver checks the module reference for presence
before dropping it, which fails to compile when modules
are disabled:

media/pci/pt3/pt3.c: In function 'pt3_attach_fe':
media/pci/pt3/pt3.c:433:6: error: implicit declaration of function 
'module_is_live' [-Werror=implicit-function-declaration]
  module_is_live(pt3-adaps[i]-i2c_tuner-dev.driver-owner))

As far as I can tell however, this check is not needed at all, because
the module will not go away as long as pt3 is holding a reference on
it. Also the previous check for NULL pointer is not needed at all,
because module_put has the same check.

Signed-off-by: Arnd Bergmann a...@arndb.de

diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
index 90f86ce7a001..39305f07dc2e 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -429,14 +429,10 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i)
 
 err_tuner:
i2c_unregister_device(pt3-adaps[i]-i2c_tuner);
-   if (pt3-adaps[i]-i2c_tuner-dev.driver-owner 
-   module_is_live(pt3-adaps[i]-i2c_tuner-dev.driver-owner))
-   module_put(pt3-adaps[i]-i2c_tuner-dev.driver-owner);
+   module_put(pt3-adaps[i]-i2c_tuner-dev.driver-owner);
 err_demod:
i2c_unregister_device(pt3-adaps[i]-i2c_demod);
-   if (pt3-adaps[i]-i2c_demod-dev.driver-owner 
-   module_is_live(pt3-adaps[i]-i2c_demod-dev.driver-owner))
-   module_put(pt3-adaps[i]-i2c_demod-dev.driver-owner);
+   module_put(pt3-adaps[i]-i2c_demod-dev.driver-owner);
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


Re: [PATCH v2 1/5] video: move mediabus format definition to a more standard place

2014-09-29 Thread Thierry Reding
On Mon, Sep 29, 2014 at 04:02:39PM +0200, Boris Brezillon wrote:
 Rename mediabus formats and move the enum into a separate header file so
 that it can be used by DRM/KMS subsystem without any reference to the V4L2
 subsystem.
 
 Old V4L2_MBUS_FMT_ definitions are now macros that points to VIDEO_BUS_FMT_
 definitions.
 
 Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
 Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
  include/uapi/linux/Kbuild |   1 +
  include/uapi/linux/v4l2-mediabus.h| 183 
 +++---
  include/uapi/linux/video-bus-format.h | 127 +++
  3 files changed, 207 insertions(+), 104 deletions(-)
  create mode 100644 include/uapi/linux/video-bus-format.h

Hi Mauro,

Do you have any objections to me merging patches 1 and 2 through the
drm/panel tree given the dependency of the later patches in the series
on these new constants? If you want I can provide a stable branch once
v3.18-rc1 is out for you to pull into you tree to resolve possible
conflicts.

Thierry


pgp80jlBo2KxU.pgp
Description: PGP signature


Re: [PATCH] [media] pt3: remove bogus module_is_live() check

2014-09-29 Thread Mauro Carvalho Chehab
Hi Arnd,

Em Mon, 29 Sep 2014 16:28:55 +0200
Arnd Bergmann a...@arndb.de escreveu:

 The new pt3 driver checks the module reference for presence
 before dropping it, which fails to compile when modules
 are disabled:
 
 media/pci/pt3/pt3.c: In function 'pt3_attach_fe':
 media/pci/pt3/pt3.c:433:6: error: implicit declaration of function 
 'module_is_live' [-Werror=implicit-function-declaration]
   module_is_live(pt3-adaps[i]-i2c_tuner-dev.driver-owner))
 
 As far as I can tell however, this check is not needed at all, because
 the module will not go away as long as pt3 is holding a reference on
 it. Also the previous check for NULL pointer is not needed at all,
 because module_put has the same check.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de

Thanks for this patch. Antti was quicker than you ;)

I merged the patch on my tree yesterday. It should be popping up
on the tomorrow's -next (I think that sfr didn't release one today).

 
 diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
 index 90f86ce7a001..39305f07dc2e 100644
 --- a/drivers/media/pci/pt3/pt3.c
 +++ b/drivers/media/pci/pt3/pt3.c
 @@ -429,14 +429,10 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i)
  
  err_tuner:
   i2c_unregister_device(pt3-adaps[i]-i2c_tuner);
 - if (pt3-adaps[i]-i2c_tuner-dev.driver-owner 
 - module_is_live(pt3-adaps[i]-i2c_tuner-dev.driver-owner))
 - module_put(pt3-adaps[i]-i2c_tuner-dev.driver-owner);
 + module_put(pt3-adaps[i]-i2c_tuner-dev.driver-owner);
  err_demod:
   i2c_unregister_device(pt3-adaps[i]-i2c_demod);
 - if (pt3-adaps[i]-i2c_demod-dev.driver-owner 
 - module_is_live(pt3-adaps[i]-i2c_demod-dev.driver-owner))
 - module_put(pt3-adaps[i]-i2c_demod-dev.driver-owner);
 + module_put(pt3-adaps[i]-i2c_demod-dev.driver-owner);
   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] [media] vivid: add CONFIG_FB dependency

2014-09-29 Thread Arnd Bergmann
From 6699184d4b791e8a10380d3b75be837607d3 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann a...@arndb.de
Date: Mon, 29 Sep 2014 17:33:25 +0200
Subject: [PATCH] [media] vivid: add CONFIG_FB dependency

The vivid test driver creates a framebuffer, which fails if the the framebuffer
layer is not enabled:

drivers/built-in.o: In function `vivid_fb_release_buffers':
:(.text+0x2acfe8): undefined reference to `fb_dealloc_cmap'
drivers/built-in.o: In function `vivid_fb_init':
:(.text+0x2ad344): undefined reference to `fb_alloc_cmap'
:(.text+0x2ad34c): undefined reference to `register_framebuffer'
drivers/built-in.o: In function `vivid_exit':
:(.exit.text+0x4354): undefined reference to `unregister_framebuffer'
drivers/built-in.o:(.data+0x55f88): undefined reference to `cfb_fillrect'
drivers/built-in.o:(.data+0x55f8c): undefined reference to `cfb_copyarea'
drivers/built-in.o:(.data+0x55f90): undefined reference to `cfb_imageblit'

This adds the dependency in Kconfig.

Signed-off-by: Arnd Bergmann a...@arndb.de
Cc: Hans Verkuil hans.verk...@cisco.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com

diff --git a/drivers/media/platform/vivid/Kconfig 
b/drivers/media/platform/vivid/Kconfig
index d71139a2ae00..4c31421fd90d 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -1,6 +1,6 @@
 config VIDEO_VIVID
tristate Virtual Video Test Driver
-   depends on VIDEO_DEV  VIDEO_V4L2  !SPARC32  !SPARC64
+   depends on VIDEO_DEV  VIDEO_V4L2  FB  !SPARC32  !SPARC64
select FONT_SUPPORT
select FONT_8x16
select VIDEOBUF2_VMALLOC

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


Re: [PATCH v4 1/8] [media] soc_camera: Do not decrement endpoint node refcount in the loop

2014-09-29 Thread Greg Kroah-Hartman
On Mon, Sep 29, 2014 at 11:45:23AM +0200, Philipp Zabel wrote:
 Am Montag, den 29.09.2014, 12:13 +0300 schrieb Dan Carpenter:
  On Mon, Sep 29, 2014 at 10:15:44AM +0200, Philipp Zabel wrote:
   In preparation for a following patch, stop decrementing the endpoint node
   refcount in the loop. This temporarily leaks a reference to the endpoint 
   node,
   which will be fixed by having of_graph_get_next_endpoint decrement the 
   refcount
   of its prev argument instead.
  
  Don't do this...
  
  My understanding (and I haven't invested much time into trying to
  understand this beyond glancing at the change) is that patch 1 and 2,
  introduce small bugs that are fixed in patch 3?
 
  Just fold all three patches into one patch.  We need an Ack from Mauro
  and Greg and then send the patch through Grant's tree.
 
 Yes. Patches 1 and 2 leak a reference on of_nodes touched by the loop.
 As far as I am aware, all users of this code don't use the reference
 counting (CONFIG_OF_DYNAMIC is disabled), so this bug should be
 theoretical.
 
 I'd be happy do as you suggest if Mauro and Greg agree.

Let's see the correct patch, don't break things and then later on fix
them...

thanks,

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 0/6] some fixes and cleanups for the em28xx-based HVR-930C

2014-09-29 Thread Johannes Stezenbach
Hi Mauro,

On Sun, Sep 28, 2014 at 11:23:17PM -0300, Mauro Carvalho Chehab wrote:
 This patch series addresses some issues with suspend2ram of devices
 based on DRX-K.
 
 With this patch series, it is now possible to suspend to ram while
 streaming. At resume, the stream will continue to play.
 
 While doing that, I added a few other changes:
 
 - I moved the init code to .init. That is an initial step to fix
   suspend to disk;
 
 - There's a fix to an issue that happens at xc5000 removal (sent
   already as a RFC patch);
 
 - A dprintk change at his logic to not require both a boot parameter and
   a dynamic_printk enablement. It also re-adds __func__ to the printks,
   that got previously removed;
 
 - It removes the unused mfe_sharing var from the dvb attach logic.
 
 Mauro Carvalho Chehab (6):
   [media] em28xx: remove firmware before releasing xc5000 priv state
   [media] drxk: Fix debug printks
   [media] em28xx-dvb: remove unused mfe_sharing
   [media] em28xx-dvb: handle to stop/start streaming at PM
   [media] em28xx: move board-specific init code
   [media] drxk: move device init code to .init callback
 
  drivers/media/dvb-frontends/drxk_hard.c | 117 
 
  drivers/media/tuners/xc5000.c   |   2 +-
  drivers/media/usb/em28xx/em28xx-dvb.c   |  45 
  3 files changed, 92 insertions(+), 72 deletions(-)


Disregarding your mails from the em28xx breaks after hibernate
that hibernate doesn't work for you, I decided to give these
changes a try on top of today's media_tree.git
(cf3167c - 3.17.0-rc5-00741-g9a3fbd8), still inside qemu
(can't upgrade/reboot my main machine right now).

Works!  For hibernate, using echo reboot /sys/power/disk, so
the host driver cannot interfere with the qemu driver during hibernate.
Qemu causes several USB resets to the device during
hibernate - resume, but the USB power is not cut.
It works even while running dvbv5-zap and streaming to mplayer.

I tried both suspend-to-ram and hibernate a couple of times,
at least in Qemu it all works.

There are a lot of drxk debug prints now enabled by default,
not sure if that was intentional.


Thanks,
Johannes
--
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 v5 0/6] Add of-graph helpers to loop over endpoints and find ports by id

2014-09-29 Thread Philipp Zabel
Hi,

now the first three patches of the previous series are combined into one. This
patch touches of, media, and staging. Since it is rebased onto Grant's tree, it
now trivially conflicts with 30e94a564d07 (staging: imx-drm: Lines over 80
characters fixed.)

This series converts all existing users of of_graph_get_next_endpoint that pass
a non-NULL prev argument to the function and decrement its refcount themselves
to stop doing that. The of_node_put is moved into of_graph_get_next_endpoint
instead.
This allows to add a for_each_endpoint_of_node helper macro to loop over all
endpoints in a device tree node.
The third of patch adds a of_graph_get_port_by_id function to retrieve a port
by its known port id from the device tree.

Finally, the last three patches convert functions in drm_of.c and imx-drm-core.c
to use the for_each_endpoint_of_node macro instead of 
of_graph_get_next_endpoint.

Changes since v4:
 - Combined patches 1-3 into one

The previous version can be found here: https://lkml.org/lkml/2014/9/29/78

regards
Philipp

Philipp Zabel (6):
  of: Decrement refcount of previous endpoint in
of_graph_get_next_endpoint
  of: Add for_each_endpoint_of_node helper macro
  of: Add of_graph_get_port_by_id function
  drm: use for_each_endpoint_of_node macro in drm_of_find_possible_crtcs
  imx-drm: use for_each_endpoint_of_node macro in
imx_drm_encoder_get_mux_id
  imx-drm: use for_each_endpoint_of_node macro in
imx_drm_encoder_parse_of

 drivers/gpu/drm/drm_of.c   |  8 ++
 drivers/media/platform/soc_camera/soc_camera.c |  3 ++-
 drivers/of/base.c  | 35 --
 drivers/staging/imx-drm/imx-drm-core.c | 28 ++---
 include/linux/of_graph.h   | 18 +
 5 files changed, 56 insertions(+), 36 deletions(-)

-- 
2.1.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 v5 1/6] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint

2014-09-29 Thread Philipp Zabel
Decrementing the reference count of the previous endpoint node allows to
use the of_graph_get_next_endpoint function in a for_each_... style macro.
All current users of this function that pass a non-NULL prev parameter
(that is, soc_camera and imx-drm) are changed to not decrement the passed
prev argument's refcount themselves.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
Changes since v4:
 - Folded patches 1-3 into this one
---
 drivers/media/platform/soc_camera/soc_camera.c |  3 ++-
 drivers/of/base.c  |  9 +
 drivers/staging/imx-drm/imx-drm-core.c | 12 ++--
 3 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index f4308fe..619b2d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1696,7 +1696,6 @@ static void scan_of_host(struct soc_camera_host *ici)
if (!i)
soc_of_bind(ici, epn, ren-parent);
 
-   of_node_put(epn);
of_node_put(ren);
 
if (i) {
@@ -1704,6 +1703,8 @@ static void scan_of_host(struct soc_camera_host *ici)
break;
}
}
+
+   of_node_put(epn);
 }
 
 #else
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 293ed4b..f7a9aa8 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2070,8 +2070,7 @@ EXPORT_SYMBOL(of_graph_parse_endpoint);
  * @prev: previous endpoint node, or NULL to get first
  *
  * Return: An 'endpoint' node pointer with refcount incremented. Refcount
- * of the passed @prev node is not decremented, the caller have to use
- * of_node_put() on it when done.
+ * of the passed @prev node is decremented.
  */
 struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
struct device_node *prev)
@@ -2107,12 +2106,6 @@ struct device_node *of_graph_get_next_endpoint(const 
struct device_node *parent,
if (WARN_ONCE(!port, %s(): endpoint %s has no parent node\n,
  __func__, prev-full_name))
return NULL;
-
-   /*
-* Avoid dropping prev node refcount to 0 when getting the next
-* child below.
-*/
-   of_node_get(prev);
}
 
while (1) {
diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 6b22106..12303b3 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -434,14 +434,6 @@ static uint32_t imx_drm_find_crtc_mask(struct 
imx_drm_device *imxdrm,
return 0;
 }
 
-static struct device_node *imx_drm_of_get_next_endpoint(
-   const struct device_node *parent, struct device_node *prev)
-{
-   struct device_node *node = of_graph_get_next_endpoint(parent, prev);
-   of_node_put(prev);
-   return node;
-}
-
 int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np)
 {
@@ -453,7 +445,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
for (i = 0; ; i++) {
u32 mask;
 
-   ep = imx_drm_of_get_next_endpoint(np, ep);
+   ep = of_graph_get_next_endpoint(np, ep);
if (!ep)
break;
 
@@ -502,7 +494,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
return -EINVAL;
 
do {
-   ep = imx_drm_of_get_next_endpoint(node, ep);
+   ep = of_graph_get_next_endpoint(node, ep);
if (!ep)
break;
 
-- 
2.1.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 v5 4/6] drm: use for_each_endpoint_of_node macro in drm_of_find_possible_crtcs

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code a bit shorter and
easier to read.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/gpu/drm/drm_of.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 16150a0..024fa77 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -46,11 +46,7 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
struct device_node *remote_port, *ep = NULL;
uint32_t possible_crtcs = 0;
 
-   do {
-   ep = of_graph_get_next_endpoint(port, ep);
-   if (!ep)
-   break;
-
+   for_each_endpoint_of_node(port, ep) {
remote_port = of_graph_get_remote_port(ep);
if (!remote_port) {
of_node_put(ep);
@@ -60,7 +56,7 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
possible_crtcs |= drm_crtc_port_mask(dev, remote_port);
 
of_node_put(remote_port);
-   } while (1);
+   }
 
return possible_crtcs;
 }
-- 
2.1.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 v5 6/6] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_parse_of

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code bit shorter and
easier to read. Since we can break out of the loop, we keep the
call to of_node_put after the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/staging/imx-drm/imx-drm-core.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 9b5222c..8f2a802 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -438,17 +438,13 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np)
 {
struct imx_drm_device *imxdrm = drm-dev_private;
-   struct device_node *ep = NULL;
+   struct device_node *ep;
uint32_t crtc_mask = 0;
-   int i;
+   int i = 0;
 
-   for (i = 0; ; i++) {
+   for_each_endpoint_of_node(np, ep) {
u32 mask;
 
-   ep = of_graph_get_next_endpoint(np, ep);
-   if (!ep)
-   break;
-
mask = imx_drm_find_crtc_mask(imxdrm, ep);
 
/*
@@ -461,6 +457,7 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
return -EPROBE_DEFER;
 
crtc_mask |= mask;
+   i++;
}
 
if (ep)
-- 
2.1.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 v5 2/6] of: Add for_each_endpoint_of_node helper macro

2014-09-29 Thread Philipp Zabel
Note that while of_graph_get_next_endpoint decrements the reference count
of the child node passed to it, of_node_put(child) still has to be called
manually when breaking out of the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/linux/of_graph.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index befef42..e43442e 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -26,6 +26,17 @@ struct of_endpoint {
const struct device_node *local_node;
 };
 
+/**
+ * for_each_endpoint_of_node - iterate over every endpoint in a device node
+ * @parent: parent device node containing ports and endpoints
+ * @child: loop variable pointing to the current endpoint node
+ *
+ * When breaking out of the loop, of_node_put(child) has to be called manually.
+ */
+#define for_each_endpoint_of_node(parent, child) \
+   for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
+child = of_graph_get_next_endpoint(parent, child))
+
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
-- 
2.1.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 v5 5/6] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_get_mux_id

2014-09-29 Thread Philipp Zabel
Using the for_each_... macro should make the code bit shorter and
easier to read. This patch also properly decrements the endpoint node
reference count before returning out of the loop.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/staging/imx-drm/imx-drm-core.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c 
b/drivers/staging/imx-drm/imx-drm-core.c
index 12303b3..9b5222c 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -493,18 +493,15 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
if (!node || !imx_crtc)
return -EINVAL;
 
-   do {
-   ep = of_graph_get_next_endpoint(node, ep);
-   if (!ep)
-   break;
-
+   for_each_endpoint_of_node(node, ep) {
port = of_graph_get_remote_port(ep);
of_node_put(port);
if (port == imx_crtc-port) {
ret = of_graph_parse_endpoint(ep, endpoint);
+   of_node_put(ep);
return ret ? ret : endpoint.port;
}
-   } while (ep);
+   }
 
return -EINVAL;
 }
-- 
2.1.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 v5 3/6] of: Add of_graph_get_port_by_id function

2014-09-29 Thread Philipp Zabel
This patch adds a function to get a port device tree node by port id,
or reg property value.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/of/base.c| 26 ++
 include/linux/of_graph.h |  7 +++
 2 files changed, 33 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index f7a9aa8..e17e534 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2065,6 +2065,32 @@ int of_graph_parse_endpoint(const struct device_node 
*node,
 EXPORT_SYMBOL(of_graph_parse_endpoint);
 
 /**
+ * of_graph_get_port_by_id() - get the port matching a given id
+ * @parent: pointer to the parent device node
+ * @id: id of the port
+ *
+ * Return: A 'port' node pointer with refcount incremented. The caller
+ * has to use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id)
+{
+   struct device_node *port;
+
+   for_each_child_of_node(node, port) {
+   u32 port_id = 0;
+
+   if (of_node_cmp(port-name, port) != 0)
+   continue;
+   of_property_read_u32(port, reg, port_id);
+   if (id == port_id)
+   return port;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(of_graph_get_port_by_id);
+
+/**
  * of_graph_get_next_endpoint() - get next endpoint node
  * @parent: pointer to the parent device node
  * @prev: previous endpoint node, or NULL to get first
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index e43442e..3c1c95a 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -40,6 +40,7 @@ struct of_endpoint {
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
+struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
struct device_node *previous);
 struct device_node *of_graph_get_remote_port_parent(
@@ -53,6 +54,12 @@ static inline int of_graph_parse_endpoint(const struct 
device_node *node,
return -ENOSYS;
 }
 
+static inline struct device_node *of_graph_get_port_by_id(
+   struct device_node *node, u32 id)
+{
+   return NULL;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
const struct device_node *parent,
struct device_node *previous)
-- 
2.1.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] dvb_usb_af9005: fix kernel panic on init if the driver is compiled in without IR symbols

2014-09-29 Thread Frank Schäfer
This patches fixes an ancient bug in the dvb_usb_af9005 driver, which
has been reported at least in the following threads:
https://lkml.org/lkml/2009/2/4/350
https://lkml.org/lkml/2014/9/18/558

If the driver is compiled in without any IR support (neither
DVB_USB_AF9005_REMOTE nor custom symbols), the symbol_request calls in
af9005_usb_module_init() return pointers != NULL although the IR
symbols are not available.

This leads to the following oops:
...
[8.529751] usbcore: registered new interface driver dvb_usb_af9005
[8.531584] BUG: unable to handle kernel paging request at 02e0
[8.533385] IP: [7d9d67c6] af9005_usb_module_init+0x6b/0x9d
[8.535613] *pde = 
[8.536416] Oops:  [#1] PREEMPT PREEMPT DEBUG_PAGEALLOCDEBUG_PAGEALLOC
[8.537863] CPU: 0 PID: 1 Comm: swapper Not tainted 
3.15.0-rc6-00151-ga5c075c #1
[8.539827] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.7.5-20140531_083030-gandalf 04/01/2014
[8.541519] task: 89c9a670 ti: 89c9c000 task.ti: 89c9c000
[8.541519] EIP: 0060:[7d9d67c6] EFLAGS: 00010206 CPU: 0
[8.541519] EIP is at af9005_usb_module_init+0x6b/0x9d
[8.541519] EAX: 02e0 EBX:  ECX: 0006 EDX: 
[8.541519] ESI:  EDI: 7da33ec8 EBP: 89c9df30 ESP: 89c9df2c
[8.541519]  DS: 007b ES: 007b FS:  GS: 00e0 SS: 0068
[8.541519] CR0: 8005003b CR2: 02e0 CR3: 05a54000 CR4: 0690
[8.541519] Stack:
[8.541519]  7d9d675b 89c9df90 7d992a49 7d7d5914 89c9df4c 7be3a800 7d08c58c 
8a4c3968
[8.541519]  89c9df80 7be3a966 0192 0006 0006 7d7d3ff4 8a4c397a 
0200
[8.541519]  7d6b1280 8a4c3979 0006 09a6 7da32db8 b13eec81 0006 
09a6
[8.541519] Call Trace:
[8.541519]  [7d9d675b] ? ttusb2_driver_init+0x16/0x16
[8.541519]  [7d992a49] do_one_initcall+0x77/0x106
[8.541519]  [7be3a800] ? parameqn+0x2/0x35
[8.541519]  [7be3a966] ? parse_args+0x113/0x25c
[8.541519]  [7d992bc2] kernel_init_freeable+0xea/0x167
[8.541519]  [7cf01070] kernel_init+0x8/0xb8
[8.541519]  [7cf27ec0] ret_from_kernel_thread+0x20/0x30
[8.541519]  [7cf01068] ? rest_init+0x10c/0x10c
[8.541519] Code: 08 c2 c7 05 44 ed f9 7d 00 00 e0 02 c7 05 40 ed f9 7d 00 
00 e0 02 c7 05 3c ed f9 7d 00 00 e0 02 75 1f b8 00 00 e0 02 85 c0 74 16 a1 00 
00 e0 02 c7 05 54 84 8e 7d 00 00 e0 02 a3 58 84 8e 7d eb
[8.541519] EIP: [7d9d67c6] af9005_usb_module_init+0x6b/0x9d SS:ESP 
0068:89c9df2c
[8.541519] CR2: 02e0
[8.541519] ---[ end trace 768b6faf51370fc7 ]---

The prefered fix would be to convert the whole IR code to use the kernel IR
infrastructure (which wasn't available at the time this driver had been 
created).

Until anyone who still has this old hardware steps up an does the conversion,
fix it by not calling the symbol_request calls if the driver is compiled in
without the default IR symbols (CONFIG_DVB_USB_AF9005_REMOTE).
Due to the IR related pointers beeing NULL by default, IR support will then be 
disabled.

The downside of this solution is, that it will no longer be possible to
compile custom IR symbols (not using CONFIG_DVB_USB_AF9005_REMOTE) in.

Please note that this patch has NOT been tested with all possible cases.
I don't have the hardware and could only verify that it fixes the reported
bug.

Reported-by: Fengguag Wu fengguang...@intel.com
Signed-off-by: Frank Schäfer fschaefer@googlemail.com
Cc: sta...@vger.kernel.org
---
 drivers/media/usb/dvb-usb/af9005.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/dvb-usb/af9005.c 
b/drivers/media/usb/dvb-usb/af9005.c
index af176b6..e6d3561 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -1081,9 +1081,12 @@ static int __init af9005_usb_module_init(void)
err(usb_register failed. (%d), result);
return result;
}
+#if IS_MODULE(CONFIG_DVB_USB_AF9005) || defined(CONFIG_DVB_USB_AF9005_REMOTE)
+   /* FIXME: convert to todays kernel IR infrastructure */
rc_decode = symbol_request(af9005_rc_decode);
rc_keys = symbol_request(rc_map_af9005_table);
rc_keys_size = symbol_request(rc_map_af9005_table_size);
+#endif
if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) {
err(af9005_rc_decode function not found, disabling remote);
af9005_properties.rc.legacy.rc_query = NULL;
-- 
1.8.4.5

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


Re: [PATCH 0/6] some fixes and cleanups for the em28xx-based HVR-930C

2014-09-29 Thread Mauro Carvalho Chehab
Em Mon, 29 Sep 2014 19:44:30 +0200
Johannes Stezenbach j...@linuxtv.org escreveu:

 Hi Mauro,
 
 On Sun, Sep 28, 2014 at 11:23:17PM -0300, Mauro Carvalho Chehab wrote:
  This patch series addresses some issues with suspend2ram of devices
  based on DRX-K.
  
  With this patch series, it is now possible to suspend to ram while
  streaming. At resume, the stream will continue to play.
  
  While doing that, I added a few other changes:
  
  - I moved the init code to .init. That is an initial step to fix
suspend to disk;
  
  - There's a fix to an issue that happens at xc5000 removal (sent
already as a RFC patch);
  
  - A dprintk change at his logic to not require both a boot parameter and
a dynamic_printk enablement. It also re-adds __func__ to the printks,
that got previously removed;
  
  - It removes the unused mfe_sharing var from the dvb attach logic.
  
  Mauro Carvalho Chehab (6):
[media] em28xx: remove firmware before releasing xc5000 priv state
[media] drxk: Fix debug printks
[media] em28xx-dvb: remove unused mfe_sharing
[media] em28xx-dvb: handle to stop/start streaming at PM
[media] em28xx: move board-specific init code
[media] drxk: move device init code to .init callback
  
   drivers/media/dvb-frontends/drxk_hard.c | 117 
  
   drivers/media/tuners/xc5000.c   |   2 +-
   drivers/media/usb/em28xx/em28xx-dvb.c   |  45 
   3 files changed, 92 insertions(+), 72 deletions(-)
 
 
 Disregarding your mails from the em28xx breaks after hibernate
 that hibernate doesn't work for you, I decided to give these
 changes a try on top of today's media_tree.git
 (cf3167c - 3.17.0-rc5-00741-g9a3fbd8), still inside qemu
 (can't upgrade/reboot my main machine right now).

Well, I think I was not clear: It doesn't work for me when 
I power down the USB or the machine after suspended. If I keep
the device energized, it works ;)

 Works!  For hibernate, using echo reboot /sys/power/disk, so
 the host driver cannot interfere with the qemu driver during hibernate.
 Qemu causes several USB resets to the device during
 hibernate - resume, but the USB power is not cut.
 It works even while running dvbv5-zap and streaming to mplayer.

Thanks for testing it! it is great to have a separate test for
the patches.

Could I add a tested-by tag on those patches?

 I tried both suspend-to-ram and hibernate a couple of times,
 at least in Qemu it all works.
 
 There are a lot of drxk debug prints now enabled by default,
 not sure if that was intentional.

You're probably probing the device with debug=1, right?

Before the patches, debug=1 were not working well, because:

- it would require to also manually enable the debug lines via
  dynamic_printk sysfs nodes;

- the called function where not displayed. Weveral printks there
  are just dprintk(1, \n), used as a way to trace the drxk
  driver. With the old way, this were just printing:
  drxk: empty line

We should likely do some cleanup in some future, removing those
empty printks, as function trace can easily be done via perf, 
and to remove the debug level, using just dynamic_printk.

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


[PATCH] [media] cx231xx: cx231xx_uninit_bulk attempts to reference and free isoc_ctl instead of bulk_ctl

2014-09-29 Thread Luke Suchocki

cx231xx_uninit_bulk() checks that
dev-video_mode.bulk_ctl.transfer_buffer[i] is not NULL, but then calls
usb_free_cohert() with dev-video_mode.isoc_ctl.transfer_buffer[i]
resulting in BUG: unable to handle NULL pointer dereference when
closing stream; most likely a cut-and-paste slip from previous
uninit_isoc function.

This will present itself when cx231xx.ko is loaded with
transfer_mode=0 (USB bulk transfers).

Signed-off-by: Luke Suchocki ker...@suchocki.net

--- a/drivers/media/usb/cx231xx/cx231xx-core.c  2014-09-29
13:06:52.006326612 -0500
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c  2014-09-29
13:10:46.796695980 -0500
@@ -943,7 +943,7 @@ void cx231xx_uninit_bulk(struct cx231xx
if (dev-video_mode.bulk_ctl.transfer_buffer[i])
{
usb_free_coherent(dev-udev,

urb-transfer_buffer_length,
-
dev-video_mode.isoc_ctl.
+
dev-video_mode.bulk_ctl.
transfer_buffer[i],
urb-transfer_dma);



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


Re: [PATCH 0/6] some fixes and cleanups for the em28xx-based HVR-930C

2014-09-29 Thread Johannes Stezenbach
On Mon, Sep 29, 2014 at 03:30:18PM -0300, Mauro Carvalho Chehab wrote:
 Em Mon, 29 Sep 2014 19:44:30 +0200
 Johannes Stezenbach j...@linuxtv.org escreveu:
 
  Disregarding your mails from the em28xx breaks after hibernate
  that hibernate doesn't work for you, I decided to give these
  changes a try on top of today's media_tree.git
  (cf3167c - 3.17.0-rc5-00741-g9a3fbd8), still inside qemu
  (can't upgrade/reboot my main machine right now).
 
 Well, I think I was not clear: It doesn't work for me when 
 I power down the USB or the machine after suspended. If I keep
 the device energized, it works ;)

Ah, OK.  I'll try to test with power removed tomorrow.

  Works!  For hibernate, using echo reboot /sys/power/disk, so
  the host driver cannot interfere with the qemu driver during hibernate.
  Qemu causes several USB resets to the device during
  hibernate - resume, but the USB power is not cut.
  It works even while running dvbv5-zap and streaming to mplayer.
 
 Thanks for testing it! it is great to have a separate test for
 the patches.
 
 Could I add a tested-by tag on those patches?

sure

  I tried both suspend-to-ram and hibernate a couple of times,
  at least in Qemu it all works.
  
  There are a lot of drxk debug prints now enabled by default,
  not sure if that was intentional.
 
 You're probably probing the device with debug=1, right?

right, forgot I had added this to the kernel command line
in my qemu start script


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


Re: [PATCH v2] [media] uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale

2014-09-29 Thread Philipp Zabel
Hi Laurent,

On Wed, Aug 6, 2014 at 10:50 PM, Philipp Zabel philipp.za...@gmail.com wrote:
 This patch adds a quirk to force Y8 pixel format even if the camera reports
 half-width YUYV.

 Signed-off-by: Philipp Zabel philipp.za...@gmail.com

do you have any further comments on this patch?

regards
Philipp

 ---
  drivers/media/usb/uvc/uvc_driver.c | 29 -
  drivers/media/usb/uvc/uvcvideo.h   |  1 +
  2 files changed, 29 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/usb/uvc/uvc_driver.c 
 b/drivers/media/usb/uvc/uvc_driver.c
 index c3bb250..90a8f10 100644
 --- a/drivers/media/usb/uvc/uvc_driver.c
 +++ b/drivers/media/usb/uvc/uvc_driver.c
 @@ -311,6 +311,7 @@ static int uvc_parse_format(struct uvc_device *dev,
 struct uvc_format_desc *fmtdesc;
 struct uvc_frame *frame;
 const unsigned char *start = buffer;
 +   bool force_yuy2_to_y8 = false;
 unsigned int interval;
 unsigned int i, n;
 __u8 ftype;
 @@ -333,6 +334,22 @@ static int uvc_parse_format(struct uvc_device *dev,
 /* Find the format descriptor from its GUID. */
 fmtdesc = uvc_format_by_guid(buffer[5]);

 +   format-bpp = buffer[21];
 +
 +   if (dev-quirks  UVC_QUIRK_FORCE_Y8) {
 +   if (fmtdesc  fmtdesc-fcc == V4L2_PIX_FMT_YUYV 
 +   format-bpp == 16) {
 +   force_yuy2_to_y8 = true;
 +   fmtdesc = uvc_fmts[9];
 +   format-bpp = 8;
 +   } else {
 +   uvc_printk(KERN_WARNING,
 +   Forcing %d-bit %s to %s not 
 supported,
 +   format-bpp, fmtdesc-name,
 +   uvc_fmts[9].name);
 +   }
 +   }
 +
 if (fmtdesc != NULL) {
 strlcpy(format-name, fmtdesc-name,
 sizeof format-name);
 @@ -345,7 +362,6 @@ static int uvc_parse_format(struct uvc_device *dev,
 format-fcc = 0;
 }

 -   format-bpp = buffer[21];
 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
 ftype = UVC_VS_FRAME_UNCOMPRESSED;
 } else {
 @@ -455,6 +471,8 @@ static int uvc_parse_format(struct uvc_device *dev,
 frame-bFrameIndex = buffer[3];
 frame-bmCapabilities = buffer[4];
 frame-wWidth = get_unaligned_le16(buffer[5]);
 +   if (force_yuy2_to_y8)
 +   frame-wWidth *= 2;
 frame-wHeight = get_unaligned_le16(buffer[7]);
 frame-dwMinBitRate = get_unaligned_le32(buffer[9]);
 frame-dwMaxBitRate = get_unaligned_le32(buffer[13]);
 @@ -2467,6 +2485,15 @@ static struct usb_device_id uvc_ids[] = {
   .bInterfaceProtocol   = 0,
   .driver_info  = UVC_QUIRK_PROBE_MINMAX
 | UVC_QUIRK_IGNORE_SELECTOR_UNIT },
 +   /* Oculus VR Positional Tracker DK2 */
 +   { .match_flags  = USB_DEVICE_ID_MATCH_DEVICE
 +   | USB_DEVICE_ID_MATCH_INT_INFO,
 + .idVendor = 0x2833,
 + .idProduct= 0x0201,
 + .bInterfaceClass  = USB_CLASS_VIDEO,
 + .bInterfaceSubClass   = 1,
 + .bInterfaceProtocol   = 0,
 + .driver_info  = UVC_QUIRK_FORCE_Y8 },
 /* Generic USB Video Class */
 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) },
 {}
 diff --git a/drivers/media/usb/uvc/uvcvideo.h 
 b/drivers/media/usb/uvc/uvcvideo.h
 index 9e35982..1dd78c0 100644
 --- a/drivers/media/usb/uvc/uvcvideo.h
 +++ b/drivers/media/usb/uvc/uvcvideo.h
 @@ -137,6 +137,7 @@
  #define UVC_QUIRK_FIX_BANDWIDTH0x0080
  #define UVC_QUIRK_PROBE_DEF0x0100
  #define UVC_QUIRK_RESTRICT_FRAME_RATE  0x0200
 +#define UVC_QUIRK_FORCE_Y8 0x0400

  /* Format flags */
  #define UVC_FMT_FLAG_COMPRESSED0x0001
 --
 2.0.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


[PATCH 01/11] media: entity: Document the media_entity_ops structure

2014-09-29 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 include/media/media-entity.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index e004591..786906b 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -44,6 +44,15 @@ struct media_pad {
unsigned long flags;/* Pad flags (MEDIA_PAD_FL_*) */
 };
 
+/**
+ * struct media_entity_operations - Media entity operations
+ * @link_setup:Notify the entity of link changes. The 
operation can
+ * return an error, in which case link setup will be
+ * cancelled. Optional.
+ * @link_validate: Return whether a link is valid from the entity point of
+ * view. The media_entity_pipeline_start() function
+ * validates all links by calling this operation. Optional.
+ */
 struct media_entity_operations {
int (*link_setup)(struct media_entity *entity,
  const struct media_pad *local,
-- 
1.8.5.5

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


[PATCH 02/11] v4l: Add RBG and RGB 8:8:8 media bus formats on 24 and 32 bit busses

2014-09-29 Thread Laurent Pinchart
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 67 ++
 include/uapi/linux/v4l2-mediabus.h |  4 +-
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..d0fb3c7 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -424,6 +424,36 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
+   row id=V4L2-MBUS-FMT-RBG888-1X24
+ entryV4L2_MBUS_FMT_RBG888_1X24/entry
+ entry0x100e/entry
+ entry/entry
+ dash-ent-8;
+ entryrsubscript7/subscript/entry
+ entryrsubscript6/subscript/entry
+ entryrsubscript5/subscript/entry
+ entryrsubscript4/subscript/entry
+ entryrsubscript3/subscript/entry
+ entryrsubscript2/subscript/entry
+ entryrsubscript1/subscript/entry
+ entryrsubscript0/subscript/entry
+ entrybsubscript7/subscript/entry
+ entrybsubscript6/subscript/entry
+ entrybsubscript5/subscript/entry
+ entrybsubscript4/subscript/entry
+ entrybsubscript3/subscript/entry
+ entrybsubscript2/subscript/entry
+ entrybsubscript1/subscript/entry
+ entrybsubscript0/subscript/entry
+ entrygsubscript7/subscript/entry
+ entrygsubscript6/subscript/entry
+ entrygsubscript5/subscript/entry
+ entrygsubscript4/subscript/entry
+ entrygsubscript3/subscript/entry
+ entrygsubscript2/subscript/entry
+ entrygsubscript1/subscript/entry
+ entrygsubscript0/subscript/entry
+   /row
row id=V4L2-MBUS-FMT-RGB888-1X24
  entryV4L2_MBUS_FMT_RGB888_1X24/entry
  entry0x100a/entry
@@ -563,6 +593,43 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
+   row id=V4L2-MBUS-FMT-RGB888-1X32-PADHI
+ entryV4L2_MBUS_FMT_RGB888_1X32_PADHI/entry
+ entry0x100f/entry
+ entry/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entry0/entry
+ entryrsubscript7/subscript/entry
+ entryrsubscript6/subscript/entry
+ entryrsubscript5/subscript/entry
+ entryrsubscript4/subscript/entry
+ entryrsubscript3/subscript/entry
+ entryrsubscript2/subscript/entry
+ entryrsubscript1/subscript/entry
+ entryrsubscript0/subscript/entry
+ entrygsubscript7/subscript/entry
+ entrygsubscript6/subscript/entry
+ entrygsubscript5/subscript/entry
+ entrygsubscript4/subscript/entry
+ entrygsubscript3/subscript/entry
+ entrygsubscript2/subscript/entry
+ entrygsubscript1/subscript/entry
+ entrygsubscript0/subscript/entry
+ entrybsubscript7/subscript/entry
+ entrybsubscript6/subscript/entry
+ entrybsubscript5/subscript/entry
+ entrybsubscript4/subscript/entry
+ entrybsubscript3/subscript/entry
+ entrybsubscript2/subscript/entry
+ entrybsubscript1/subscript/entry
+ entrybsubscript0/subscript/entry
+   /row
  /tbody
/tgroup
   /table
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 1445e85..8ea4f26 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -37,7 +37,7 @@
 enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_FIXED = 0x0001,
 
-   /* RGB - next is 0x100e */
+   /* RGB - next is 0x1010 */
V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
@@ -47,10 +47,12 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
V4L2_MBUS_FMT_RGB666_1X18 = 0x1009,
+   V4L2_MBUS_FMT_RBG888_1X24 = 0x100e,
V4L2_MBUS_FMT_RGB888_1X24 = 0x100a,
V4L2_MBUS_FMT_RGB888_2X12_BE = 0x100b,
V4L2_MBUS_FMT_RGB888_2X12_LE = 0x100c,
V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
+   V4L2_MBUS_FMT_RGB888_1X32_PADHI = 0x100f,
 
/* YUV (including grey) - next is 0x2024 */
V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
-- 
1.8.5.5

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

[PATCH 07/11] dma: xilinx: vdma: Allow only one chunk in a line

2014-09-29 Thread Laurent Pinchart
From: Srikanth Thokala srikanth.thok...@xilinx.com

This patch adds a sanity check to see if frame_size is 1.

Signed-off-by: Srikanth Thokala stho...@xilinx.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 drivers/dma/xilinx/xilinx_vdma.c | 3 +++
 1 file changed, 3 insertions(+)

Cc: dmaeng...@vger.kernel.org

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 8e9f2a6..b3b8761 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -942,6 +942,9 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan,
if (!xt-numf || !xt-sgl[0].size)
return NULL;
 
+   if (xt-frame_size != 1)
+   return NULL;
+
/* Allocate a transaction descriptor. */
desc = xilinx_vdma_alloc_tx_descriptor(chan);
if (!desc)
-- 
1.8.5.5

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


[PATCH 05/11] v4l: of: Add v4l2_of_parse_link() function

2014-09-29 Thread Laurent Pinchart
The function fills a link data structure with the device node and port
number at both the local and remote ends of a link defined by one of its
endpoint nodes.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/v4l2-core/v4l2-of.c | 61 +++
 include/media/v4l2-of.h   | 27 +
 2 files changed, 88 insertions(+)

Cc: Sylwester Nawrocki s.nawro...@samsung.com

diff --git a/drivers/media/v4l2-core/v4l2-of.c 
b/drivers/media/v4l2-core/v4l2-of.c
index b4ed9a9..c473479 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -142,3 +142,64 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
return 0;
 }
 EXPORT_SYMBOL(v4l2_of_parse_endpoint);
+
+/**
+ * v4l2_of_parse_link() - parse a link between two endpoints
+ * @node: pointer to the endpoint at the local end of the link
+ * @link: pointer to the V4L2 OF link data structure
+ *
+ * Fill the link structure with the local and remote nodes and port numbers.
+ * The local_node and remote_node fields are set to point to the local and
+ * remote port parent nodes respectively (the port parent node being the parent
+ * node of the port node if that node isn't a 'ports' node, or the grand-parent
+ * node of the port node otherwise).
+ *
+ * A reference is taken to both the local and remote nodes, the caller must use
+ * v4l2_of_put_link() to drop the references when done with the link.
+ *
+ * Return: 0 on success, or -ENOLINK if the remote endpoint can't be found.
+ */
+int v4l2_of_parse_link(const struct device_node *node,
+  struct v4l2_of_link *link)
+{
+   struct device_node *np;
+
+   memset(link, 0, sizeof(*link));
+
+   np = of_get_parent(node);
+   of_property_read_u32(np, reg, link-local_port);
+   np = of_get_next_parent(np);
+   if (of_node_cmp(np-name, ports) == 0)
+   np = of_get_next_parent(np);
+   link-local_node = np;
+
+   np = of_parse_phandle(node, remote-endpoint, 0);
+   if (!np) {
+   of_node_put(link-local_node);
+   return -ENOLINK;
+   }
+
+   np = of_get_parent(np);
+   of_property_read_u32(np, reg, link-remote_port);
+   np = of_get_next_parent(np);
+   if (of_node_cmp(np-name, ports) == 0)
+   np = of_get_next_parent(np);
+   link-remote_node = np;
+
+   return 0;
+}
+EXPORT_SYMBOL(v4l2_of_parse_link);
+
+/**
+ * v4l2_of_put_link() - drop references to nodes in a link
+ * @link: pointer to the V4L2 OF link data structure
+ *
+ * Drop references to the local and remote nodes in the link. This function 
must
+ * be called on every link parsed with v4l2_of_parse_link().
+ */
+void v4l2_of_put_link(struct v4l2_of_link *link)
+{
+   of_node_put(link-local_node);
+   of_node_put(link-remote_node);
+}
+EXPORT_SYMBOL(v4l2_of_put_link);
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 70fa7b7..078846d 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -66,9 +66,26 @@ struct v4l2_of_endpoint {
struct list_head head;
 };
 
+/**
+ * struct v4l2_of_link - a link between two endpoints
+ * @local_node: pointer to device_node of this endpoint
+ * @local_port: identifier of the port this endpoint belongs to
+ * @remote_node: pointer to device_node of the remote endpoint
+ * @remote_port: identifier of the port the remote endpoint belongs to
+ */
+struct v4l2_of_link {
+   struct device_node *local_node;
+   unsigned int local_port;
+   struct device_node *remote_node;
+   unsigned int remote_port;
+};
+
 #ifdef CONFIG_OF
 int v4l2_of_parse_endpoint(const struct device_node *node,
   struct v4l2_of_endpoint *endpoint);
+int v4l2_of_parse_link(const struct device_node *node,
+  struct v4l2_of_link *link);
+void v4l2_of_put_link(struct v4l2_of_link *link);
 #else /* CONFIG_OF */
 
 static inline int v4l2_of_parse_endpoint(const struct device_node *node,
@@ -77,6 +94,16 @@ static inline int v4l2_of_parse_endpoint(const struct 
device_node *node,
return -ENOSYS;
 }
 
+static inline int v4l2_of_parse_link(const struct device_node *node,
+struct v4l2_of_link *link)
+{
+   return -ENOSYS;
+}
+
+static inline void v4l2_of_put_link(struct v4l2_of_link *link)
+{
+}
+
 #endif /* CONFIG_OF */
 
 #endif /* _V4L2_OF_H */
-- 
1.8.5.5

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


[PATCH 10/11] v4l: xilinx: Add Video Timing Controller driver

2014-09-29 Thread Laurent Pinchart
The Video Timing Controller (VTC) includes a timing detector and/or a
timing generator. Only the generator is currently supported.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 .../devicetree/bindings/media/xilinx/xlnx,v-tc.txt |  33 ++
 drivers/media/platform/xilinx/Kconfig  |   6 +
 drivers/media/platform/xilinx/Makefile |   1 +
 drivers/media/platform/xilinx/xilinx-vtc.c | 386 +
 drivers/media/platform/xilinx/xilinx-vtc.h |  42 +++
 5 files changed, 468 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/xilinx/xlnx,v-tc.txt
 create mode 100644 drivers/media/platform/xilinx/xilinx-vtc.c
 create mode 100644 drivers/media/platform/xilinx/xilinx-vtc.h

Cc: devicet...@vger.kernel.org

diff --git a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tc.txt 
b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tc.txt
new file mode 100644
index 000..2aed3b4
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tc.txt
@@ -0,0 +1,33 @@
+Xilinx Video Timing Controller (VTC)
+
+
+The Video Timing Controller is a general purpose video timing generator and
+detector.
+
+Required properties:
+
+  - compatible: Must be xlnx,v-tc-6.1.
+
+  - reg: Physical base address and length of the registers set for the device.
+
+  - clocks: Must contain a clock specifier for the VTC core and timing
+interfaces clock.
+
+Optional properties:
+
+  - xlnx,detector: The VTC has a timing detector
+  - xlnx,generator: The VTC has a timing generator
+
+  At least one of the xlnx,detector and xlnx,generator properties must be
+  specified.
+
+
+Example:
+
+   vtc: vtc@43c4 {
+   compatible = xlnx,v-tc-6.1;
+   reg = 0x43c4 0x1;
+
+   clocks = clkc 15;
+   xlnx,generator;
+   };
diff --git a/drivers/media/platform/xilinx/Kconfig 
b/drivers/media/platform/xilinx/Kconfig
index f4347e9..19db823 100644
--- a/drivers/media/platform/xilinx/Kconfig
+++ b/drivers/media/platform/xilinx/Kconfig
@@ -7,4 +7,10 @@ config VIDEO_XILINX
 
 if VIDEO_XILINX
 
+config VIDEO_XILINX_VTC
+   tristate Xilinx Video Timing Controller
+   depends on VIDEO_XILINX
+   ---help---
+  Driver for the Xilinx Video Timing Controller
+
 endif #VIDEO_XILINX
diff --git a/drivers/media/platform/xilinx/Makefile 
b/drivers/media/platform/xilinx/Makefile
index 3ef9c8e..6611e32 100644
--- a/drivers/media/platform/xilinx/Makefile
+++ b/drivers/media/platform/xilinx/Makefile
@@ -1,3 +1,4 @@
 xilinx-video-objs += xilinx-dma.o xilinx-vip.o xilinx-vipp.o
 
 obj-$(CONFIG_VIDEO_XILINX) += xilinx-video.o
+obj-$(CONFIG_VIDEO_XILINX_VTC) += xilinx-vtc.o
diff --git a/drivers/media/platform/xilinx/xilinx-vtc.c 
b/drivers/media/platform/xilinx/xilinx-vtc.c
new file mode 100644
index 000..949063a
--- /dev/null
+++ b/drivers/media/platform/xilinx/xilinx-vtc.c
@@ -0,0 +1,386 @@
+/*
+ * Xilinx Video Timing Controller
+ *
+ * Copyright (C) 2013-2014 Ideas on Board
+ * Copyright (C) 2013-2014 Xilinx, Inc.
+ *
+ * Contacts: Hyun Kwon hyun.k...@xilinx.com
+ *   Laurent Pinchart laurent.pinch...@ideasonboard.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/module.h
+#include linux/of.h
+#include linux/platform_device.h
+#include linux/slab.h
+
+#include xilinx-vip.h
+#include xilinx-vtc.h
+
+#define XVTC_CONTROL_FIELD_ID_POL_SRC  (1  26)
+#define XVTC_CONTROL_ACTIVE_CHROMA_POL_SRC (1  25)
+#define XVTC_CONTROL_ACTIVE_VIDEO_POL_SRC  (1  24)
+#define XVTC_CONTROL_HSYNC_POL_SRC (1  23)
+#define XVTC_CONTROL_VSYNC_POL_SRC (1  22)
+#define XVTC_CONTROL_HBLANK_POL_SRC(1  21)
+#define XVTC_CONTROL_VBLANK_POL_SRC(1  20)
+#define XVTC_CONTROL_CHROMA_SRC(1  18)
+#define XVTC_CONTROL_VBLANK_HOFF_SRC   (1  17)
+#define XVTC_CONTROL_VSYNC_END_SRC (1  16)
+#define XVTC_CONTROL_VSYNC_START_SRC   (1  15)
+#define XVTC_CONTROL_ACTIVE_VSIZE_SRC  (1  14)
+#define XVTC_CONTROL_FRAME_VSIZE_SRC   (1  13)
+#define XVTC_CONTROL_HSYNC_END_SRC (1  11)
+#define XVTC_CONTROL_HSYNC_START_SRC   (1  10)
+#define XVTC_CONTROL_ACTIVE_HSIZE_SRC  (1  9)
+#define XVTC_CONTROL_FRAME_HSIZE_SRC   (1  8)
+#define XVTC_CONTROL_SYNC_ENABLE   (1  5)
+#define XVTC_CONTROL_DET_ENABLE(1  3)
+#define XVTC_CONTROL_GEN_ENABLE(1  2)
+
+#define XVTC_STATUS_FSYNC(n)   ((n)  16)
+#define XVTC_STATUS_GEN_ACTIVE_VIDEO   (1  13)
+#define XVTC_STATUS_GEN_VBLANK (1  12)
+#define 

[PATCH 04/11] v4l: Add VUY8 24 bits bus format

2014-09-29 Thread Laurent Pinchart
From: Hyun Kwon hyun.k...@xilinx.com

Add VUY8 24 bits bus format, V4L2_MBUS_FMT_VUY8_1X24.

Signed-off-by: Hyun Kwon hyun.k...@xilinx.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 30 ++
 include/uapi/linux/v4l2-mediabus.h |  3 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index 588aed4..aef3c8b 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -2999,6 +2999,36 @@
  entryusubscript1/subscript/entry
  entryusubscript0/subscript/entry
/row
+   row id=V4L2-MBUS-FMT-VUY8-1X24
+ entryV4L2_MBUS_FMT_VUY8_1X24/entry
+ entry0x201a/entry
+ entry/entry
+ dash-ent-8;
+ entryvsubscript7/subscript/entry
+ entryvsubscript6/subscript/entry
+ entryvsubscript5/subscript/entry
+ entryvsubscript4/subscript/entry
+ entryvsubscript3/subscript/entry
+ entryvsubscript2/subscript/entry
+ entryvsubscript1/subscript/entry
+ entryvsubscript0/subscript/entry
+ entryusubscript7/subscript/entry
+ entryusubscript6/subscript/entry
+ entryusubscript5/subscript/entry
+ entryusubscript4/subscript/entry
+ entryusubscript3/subscript/entry
+ entryusubscript2/subscript/entry
+ entryusubscript1/subscript/entry
+ entryusubscript0/subscript/entry
+ entryysubscript7/subscript/entry
+ entryysubscript6/subscript/entry
+ entryysubscript5/subscript/entry
+ entryysubscript4/subscript/entry
+ entryysubscript3/subscript/entry
+ entryysubscript2/subscript/entry
+ entryysubscript1/subscript/entry
+ entryysubscript0/subscript/entry
+   /row
row id=V4L2-MBUS-FMT-UYVY12-1X24
  entryV4L2_MBUS_FMT_UYVY12_1X24/entry
  entry0x2020/entry
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index 9be976f..31b4ce1 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -54,7 +54,7 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_ARGB_1X32 = 0x100d,
V4L2_MBUS_FMT_RGB888_1X32_PADHI = 0x100f,
 
-   /* YUV (including grey) - next is 0x2024 */
+   /* YUV (including grey) - next is 0x2025 */
V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
V4L2_MBUS_FMT_UV8_1X8 = 0x2015,
V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
@@ -84,6 +84,7 @@ enum v4l2_mbus_pixelcode {
V4L2_MBUS_FMT_VYUY10_1X20 = 0x201b,
V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
+   V4L2_MBUS_FMT_VUY8_1X24 = 0x2024,
V4L2_MBUS_FMT_UYVY12_1X24 = 0x2020,
V4L2_MBUS_FMT_VYUY12_1X24 = 0x2021,
V4L2_MBUS_FMT_YUYV12_1X24 = 0x2022,
-- 
1.8.5.5

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


[PATCH 03/11] v4l: Sort YUV formats of v4l2_mbus_pixelcode

2014-09-29 Thread Laurent Pinchart
From: Hyun Kwon hyun.k...@xilinx.com

Keep the formats sorted by type, bus_width, bits per component, samples
per pixel and order of subsamples, in that order.

Signed-off-by: Hyun Kwon hyun.k...@xilinx.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/subdev-formats.xml | 600 ++---
 include/uapi/linux/v4l2-mediabus.h |  12 +-
 2 files changed, 306 insertions(+), 306 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index d0fb3c7..588aed4 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -2239,11 +2239,15 @@
  entryysubscript1/subscript/entry
  entryysubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-UYVY8-1X16
- entryV4L2_MBUS_FMT_UYVY8_1X16/entry
- entry0x200f/entry
+   row id=V4L2-MBUS-FMT-UYVY12-2X12
+ entryV4L2_MBUS_FMT_UYVY12_2X12/entry
+ entry0x201c/entry
  entry/entry
- dash-ent-16;
+ dash-ent-20;
+ entryusubscript11/subscript/entry
+ entryusubscript10/subscript/entry
+ entryusubscript9/subscript/entry
+ entryusubscript8/subscript/entry
  entryusubscript7/subscript/entry
  entryusubscript6/subscript/entry
  entryusubscript5/subscript/entry
@@ -2252,6 +2256,16 @@
  entryusubscript2/subscript/entry
  entryusubscript1/subscript/entry
  entryusubscript0/subscript/entry
+   /row
+   row
+ entry/entry
+ entry/entry
+ entry/entry
+ dash-ent-20;
+ entryysubscript11/subscript/entry
+ entryysubscript10/subscript/entry
+ entryysubscript9/subscript/entry
+ entryysubscript8/subscript/entry
  entryysubscript7/subscript/entry
  entryysubscript6/subscript/entry
  entryysubscript5/subscript/entry
@@ -2265,7 +2279,11 @@
  entry/entry
  entry/entry
  entry/entry
- dash-ent-16;
+ dash-ent-20;
+ entryvsubscript11/subscript/entry
+ entryvsubscript10/subscript/entry
+ entryvsubscript9/subscript/entry
+ entryvsubscript8/subscript/entry
  entryvsubscript7/subscript/entry
  entryvsubscript6/subscript/entry
  entryvsubscript5/subscript/entry
@@ -2274,6 +2292,16 @@
  entryvsubscript2/subscript/entry
  entryvsubscript1/subscript/entry
  entryvsubscript0/subscript/entry
+   /row
+   row
+ entry/entry
+ entry/entry
+ entry/entry
+ dash-ent-20;
+ entryysubscript11/subscript/entry
+ entryysubscript10/subscript/entry
+ entryysubscript9/subscript/entry
+ entryysubscript8/subscript/entry
  entryysubscript7/subscript/entry
  entryysubscript6/subscript/entry
  entryysubscript5/subscript/entry
@@ -2283,11 +2311,15 @@
  entryysubscript1/subscript/entry
  entryysubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-VYUY8-1X16
- entryV4L2_MBUS_FMT_VYUY8_1X16/entry
- entry0x2010/entry
+   row id=V4L2-MBUS-FMT-VYUY12-2X12
+ entryV4L2_MBUS_FMT_VYUY12_2X12/entry
+ entry0x201d/entry
  entry/entry
- dash-ent-16;
+ dash-ent-20;
+ entryvsubscript11/subscript/entry
+ entryvsubscript10/subscript/entry
+ entryvsubscript9/subscript/entry
+ entryvsubscript8/subscript/entry
  entryvsubscript7/subscript/entry
  entryvsubscript6/subscript/entry
  entryvsubscript5/subscript/entry
@@ -2296,6 +2328,16 @@
  entryvsubscript2/subscript/entry
  entryvsubscript1/subscript/entry
  entryvsubscript0/subscript/entry
+   /row
+   row
+ entry/entry
+ entry/entry
+ entry/entry
+ dash-ent-20;
+ entryysubscript11/subscript/entry
+ entryysubscript10/subscript/entry
+ entryysubscript9/subscript/entry
+ entryysubscript8/subscript/entry
  entryysubscript7/subscript/entry
  entryysubscript6/subscript/entry
  entryysubscript5/subscript/entry
@@ -2309,7 +2351,11 @@
  entry/entry
  entry/entry
  entry/entry
- dash-ent-16;
+ dash-ent-20;
+ entryusubscript11/subscript/entry
+ entryusubscript10/subscript/entry
+ 

[PATCH 08/11] dma: xilinx: vdma: icg should be difference of stride and hsize

2014-09-29 Thread Laurent Pinchart
From: Srikanth Thokala srikanth.thok...@xilinx.com

This patch modifies the icg field to match the description
as mentioned in the DMA Linux framework.

Signed-off-by: Srikanth Thokala stho...@xilinx.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 drivers/dma/xilinx/xilinx_vdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Cc: dmaeng...@vger.kernel.org

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index b3b8761..a67ced1 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -963,7 +963,7 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan,
hw = segment-hw;
hw-vsize = xt-numf;
hw-hsize = xt-sgl[0].size;
-   hw-stride = xt-sgl[0].icg 
+   hw-stride = (xt-sgl[0].icg + xt-sgl[0].size) 
XILINX_VDMA_FRMDLY_STRIDE_STRIDE_SHIFT;
hw-stride |= chan-config.frm_dly 
XILINX_VDMA_FRMDLY_STRIDE_FRMDLY_SHIFT;
-- 
1.8.5.5

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


[PATCH 06/11] dma: xilinx: vdma: Check if the segment list is empty in a descriptor

2014-09-29 Thread Laurent Pinchart
From: Srikanth Thokala srikanth.thok...@xilinx.com

The segment list in a descriptor should be checked for empty, else
it will try to access invalid address for the first call.  This
patch fixes this issue.

Signed-off-by: Srikanth Thokala stho...@xilinx.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 drivers/dma/xilinx/xilinx_vdma.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

Cc: dmaeng...@vger.kernel.org

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 42a13e8..8e9f2a6 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -971,9 +971,11 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan,
hw-buf_addr = xt-src_start;
 
/* Link the previous next descriptor to current */
-   prev = list_last_entry(desc-segments,
-   struct xilinx_vdma_tx_segment, node);
-   prev-hw.next_desc = segment-phys;
+   if (!list_empty(desc-segments)) {
+   prev = list_last_entry(desc-segments,
+  struct xilinx_vdma_tx_segment, node);
+   prev-hw.next_desc = segment-phys;
+   }
 
/* Insert the segment into the descriptor segments list. */
list_add_tail(segment-node, desc-segments);
-- 
1.8.5.5

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


[PATCH 00/11] Xilinx Video IP Core support

2014-09-29 Thread Laurent Pinchart
Hello,

Here's (finally) a set of kernel drivers to support the Xilinx FPGA Video IP
Cores architecture.

I won't detail in great lengths the Xilinx Video IP architecture here, as that
would result in dozens of pages of documentation. The interested reader can
refer to the Zynq ZC702 Base TRD (Targeted Reference Design) User Guide
(http://www.xilinx.com/support/documentation/boards_and_kits/zc702_zvik/2014_2/ug925-zynq-zc702-base-trd.pdf).

In a nutshell, the Xilinx Video IP Cores architecture specifies how
video-related IP cores need to be designed to interoperate and how to assemble
them in pipelines of various complexities. The concepts map neatly to the
media controller architecture, which this patch set uses extensively.

The series starts with various new V4L2 core features, bug fixes or cleanups,
with a small documentation enhancement (01/11), the addition of new media bus
formats needed by the new drivers (02/11 to 04/11), a new V4L2 OF link parsing
function (05/11).

The next three patches (06/11 to 08/11) fix bugs in the Xilinx Video DMA
driver. They are required as a runtime dependency but will not break
compilation. They could thus be applied separately through the DMA engine tree
if needed. If that's required, and if time still permits, getting those
patches merged in v3.18 could help.

The last three patches are the code or this series.

Patch 09/11 adds support for the Xilinx Video IP architecture core in the form
of a base object to model video IP cores (xilinx-vip.c - Video IP), a
framework that parses a DT representation of a video pipeline and connects the
corresponding V4L2 subdevices together (xilinx-vipp.c - Video IP Pipeline) and
a glue between the Video DMA engine driver and the V4L2 API (xilinx-dma.c).

Patch 10/11 adds a driver for the Video Timing Controller (VTC) IP core. While
not strictly a video processing IP core, the VTC is required by other video IP
core drivers.

Finally, patch 11/11 adds a first video IP core driver for the Test Pattern
Generator (TPG). Drivers for other IP cores will be added in the future.

Cc: dmaeng...@vger.kernel.org
Cc: devicet...@vger.kernel.org

Hyun Kwon (2):
  v4l: Sort YUV formats of v4l2_mbus_pixelcode
  v4l: Add VUY8 24 bits bus format

Laurent Pinchart (6):
  media: entity: Document the media_entity_ops structure
  v4l: Add RBG and RGB 8:8:8 media bus formats on 24 and 32 bit busses
  v4l: of: Add v4l2_of_parse_link() function
  v4l: xilinx: Add Xilinx Video IP core
  v4l: xilinx: Add Video Timing Controller driver
  v4l: xilinx: Add Test Pattern Generator driver

Srikanth Thokala (3):
  dma: xilinx: vdma: Check if the segment list is empty in a descriptor
  dma: xilinx: vdma: Allow only one chunk in a line
  dma: xilinx: vdma: icg should be difference of stride and hsize

 Documentation/DocBook/media/v4l/subdev-formats.xml | 719 ---
 .../devicetree/bindings/media/xilinx/video.txt |  52 ++
 .../devicetree/bindings/media/xilinx/xlnx,v-tc.txt |  33 +
 .../bindings/media/xilinx/xlnx,v-tpg.txt   |  68 ++
 .../bindings/media/xilinx/xlnx,video.txt   |  55 ++
 MAINTAINERS|  10 +
 drivers/dma/xilinx/xilinx_vdma.c   |  13 +-
 drivers/media/platform/Kconfig |   1 +
 drivers/media/platform/Makefile|   2 +
 drivers/media/platform/xilinx/Kconfig  |  23 +
 drivers/media/platform/xilinx/Makefile |   5 +
 drivers/media/platform/xilinx/xilinx-dma.c | 995 +
 drivers/media/platform/xilinx/xilinx-dma.h | 109 +++
 drivers/media/platform/xilinx/xilinx-tpg.c | 921 +++
 drivers/media/platform/xilinx/xilinx-vip.c | 269 ++
 drivers/media/platform/xilinx/xilinx-vip.h | 227 +
 drivers/media/platform/xilinx/xilinx-vipp.c| 666 ++
 drivers/media/platform/xilinx/xilinx-vipp.h|  47 +
 drivers/media/platform/xilinx/xilinx-vtc.c | 386 
 drivers/media/platform/xilinx/xilinx-vtc.h |  42 +
 drivers/media/v4l2-core/v4l2-of.c  |  61 ++
 include/media/media-entity.h   |   9 +
 include/media/v4l2-of.h|  27 +
 include/uapi/linux/Kbuild  |   1 +
 include/uapi/linux/v4l2-mediabus.h |  19 +-
 include/uapi/linux/xilinx-v4l2-controls.h  |  73 ++
 26 files changed, 4510 insertions(+), 323 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/xilinx/video.txt
 create mode 100644 Documentation/devicetree/bindings/media/xilinx/xlnx,v-tc.txt
 create mode 100644 
Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
 create mode 100644 
Documentation/devicetree/bindings/media/xilinx/xlnx,video.txt
 create mode 100644 drivers/media/platform/xilinx/Kconfig
 create mode 100644 drivers/media/platform/xilinx/Makefile
 create mode 100644 drivers/media/platform/xilinx/xilinx-dma.c

[PATCH 11/11] v4l: xilinx: Add Test Pattern Generator driver

2014-09-29 Thread Laurent Pinchart
The TPG generates multiple static or dynamic test patterns. The driver
currently hardcodes the pattern to the moving box pattern.

Signed-off-by: Christian Kohn christian.k...@xilinx.com
Signed-off-by: Hyun Kwon hyun.k...@xilinx.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 .../bindings/media/xilinx/xlnx,v-tpg.txt   |  68 ++
 MAINTAINERS|   1 +
 drivers/media/platform/xilinx/Kconfig  |   7 +
 drivers/media/platform/xilinx/Makefile |   1 +
 drivers/media/platform/xilinx/xilinx-tpg.c | 921 +
 include/uapi/linux/Kbuild  |   1 +
 include/uapi/linux/xilinx-v4l2-controls.h  |  73 ++
 7 files changed, 1072 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
 create mode 100644 drivers/media/platform/xilinx/xilinx-tpg.c
 create mode 100644 include/uapi/linux/xilinx-v4l2-controls.h

Cc: devicet...@vger.kernel.org

diff --git a/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt 
b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
new file mode 100644
index 000..c6de1e3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/xilinx/xlnx,v-tpg.txt
@@ -0,0 +1,68 @@
+Xilinx Video Test Pattern Generator (TPG)
+-
+
+Required properties:
+
+- compatible: Must contain at least one of
+
+xlnx,v-tpg-5.0 (TPG version 5.0)
+xlnx,v-tpg-6.0 (TPG version 6.0)
+
+  TPG versions backward-compatible with previous versions should list all
+  compatible versions in the newer to older order.
+
+- reg: Physical base address and length of the registers set for the device.
+
+- xlnx,video-format, xlnx,video-width: Video format and width, as defined in
+  video.txt.
+
+- port: Video port, using the DT bindings defined in ../video-interfaces.txt.
+  The TPG has a single output port numbered 0.
+
+Optional properties:
+
+- xlnx,vtc: A phandle referencing the Video Timing Controller that generates
+  video timings for the TPG test patterns.
+
+- timing-gpios: Specifier for a GPIO that controls the timing mux at the TPG
+  input. The GPIO active level corresponds to the selection of VTC-generated
+  video timings.
+
+The xlnx,vtc and timing-gpios properties are mandatory when the TPG is
+synthesized with two ports and forbidden when synthesized with one port.
+
+Example:
+
+   tpg_0: tpg@4005 {
+   compatible = xlnx,v-tpg-6.0, xlnx,v-tpg-5.0;
+   reg = 0x4005 0x1;
+
+   xlnx,vtc = vtc_3;
+   timing-gpios = ps7_gpio_0 55 GPIO_ACTIVE_LOW;
+
+   ports {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   port@0 {
+   reg = 0;
+
+   xlnx,video-format = yuv422;
+   xlnx,video-width = 8;
+
+   tpg_in: endpoint {
+   remote-endpoint = adv7611_out;
+   };
+   };
+   port@1 {
+   reg = 1;
+
+   xlnx,video-format = yuv422;
+   xlnx,video-width = 8;
+
+   tpg1_out: endpoint {
+   remote-endpoint = switch_in0;
+   };
+   }:
+   };
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 8d09f6e..384bdd4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10224,6 +10224,7 @@ T:  git git://linuxtv.org/media_tree.git
 S: Supported
 F: Documentation/devicetree/bindings/media/xilinx/
 F: drivers/media/platform/xilinx/
+F: include/uapi/linux/xilinx-v4l2-controls.h
 
 XTENSA XTFPGA PLATFORM SUPPORT
 M: Max Filippov jcmvb...@gmail.com
diff --git a/drivers/media/platform/xilinx/Kconfig 
b/drivers/media/platform/xilinx/Kconfig
index 19db823..d7324c7 100644
--- a/drivers/media/platform/xilinx/Kconfig
+++ b/drivers/media/platform/xilinx/Kconfig
@@ -7,6 +7,13 @@ config VIDEO_XILINX
 
 if VIDEO_XILINX
 
+config VIDEO_XILINX_TPG
+   tristate Xilinx Video Test Pattern Generator
+   depends on VIDEO_XILINX
+   select VIDEO_XILINX_VTC
+   ---help---
+  Driver for the Xilinx Video Test Pattern Generator
+
 config VIDEO_XILINX_VTC
tristate Xilinx Video Timing Controller
depends on VIDEO_XILINX
diff --git a/drivers/media/platform/xilinx/Makefile 
b/drivers/media/platform/xilinx/Makefile
index 6611e32..e8a0f2a 100644
--- a/drivers/media/platform/xilinx/Makefile
+++ b/drivers/media/platform/xilinx/Makefile
@@ -1,4 +1,5 @@
 xilinx-video-objs += xilinx-dma.o xilinx-vip.o xilinx-vipp.o
 
 obj-$(CONFIG_VIDEO_XILINX) += xilinx-video.o

[PATCH 09/11] v4l: xilinx: Add Xilinx Video IP core

2014-09-29 Thread Laurent Pinchart
Xilinx platforms have no hardwired video capture or video processing
interface. Users create capture and memory to memory processing
pipelines in the FPGA fabric to suit their particular needs, by
instantiating video IP cores from a large library.

The Xilinx Video IP core is a framework that models a video pipeline
described in the device tree and expose the pipeline to userspace
through the media controller and V4L2 APIs.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Hyun Kwon hyun.k...@xilinx.com
Signed-off-by: Radhey Shyam Pandey radh...@xilinx.com
Signed-off-by: Michal Simek michal.si...@xilinx.com
---
 .../devicetree/bindings/media/xilinx/video.txt |  52 ++
 .../bindings/media/xilinx/xlnx,video.txt   |  55 ++
 MAINTAINERS|   9 +
 drivers/media/platform/Kconfig |   1 +
 drivers/media/platform/Makefile|   2 +
 drivers/media/platform/xilinx/Kconfig  |  10 +
 drivers/media/platform/xilinx/Makefile |   3 +
 drivers/media/platform/xilinx/xilinx-dma.c | 995 +
 drivers/media/platform/xilinx/xilinx-dma.h | 109 +++
 drivers/media/platform/xilinx/xilinx-vip.c | 269 ++
 drivers/media/platform/xilinx/xilinx-vip.h | 227 +
 drivers/media/platform/xilinx/xilinx-vipp.c| 666 ++
 drivers/media/platform/xilinx/xilinx-vipp.h|  47 +
 13 files changed, 2445 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/xilinx/video.txt
 create mode 100644 
Documentation/devicetree/bindings/media/xilinx/xlnx,video.txt
 create mode 100644 drivers/media/platform/xilinx/Kconfig
 create mode 100644 drivers/media/platform/xilinx/Makefile
 create mode 100644 drivers/media/platform/xilinx/xilinx-dma.c
 create mode 100644 drivers/media/platform/xilinx/xilinx-dma.h
 create mode 100644 drivers/media/platform/xilinx/xilinx-vip.c
 create mode 100644 drivers/media/platform/xilinx/xilinx-vip.h
 create mode 100644 drivers/media/platform/xilinx/xilinx-vipp.c
 create mode 100644 drivers/media/platform/xilinx/xilinx-vipp.h

Cc: devicet...@vger.kernel.org

diff --git a/Documentation/devicetree/bindings/media/xilinx/video.txt 
b/Documentation/devicetree/bindings/media/xilinx/video.txt
new file mode 100644
index 000..15720e4
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/xilinx/video.txt
@@ -0,0 +1,52 @@
+DT bindings for Xilinx video IP cores
+-
+
+Xilinx video IP cores process video streams by acting as video sinks and/or
+sources. They are connected by links through their input and output ports,
+creating a video pipeline.
+
+Each video IP core is represented by an AMBA bus child node in the device
+tree using bindings documented in this directory. Connections between the IP
+cores are represented as defined in ../video-interfaces.txt.
+
+The whole  pipeline is represented by an AMBA bus child node in the device
+tree using bindings documented in ./xlnx,video.txt.
+
+Common properties
+-
+
+The following properties are common to all Xilinx video IP cores.
+
+- xlnx,video-format: This property represents a video format transmitted on an
+  AXI bus between video IP cores. How the format relates to the IP core is
+  decribed in the IP core bindings documentation. The following formats are
+  supported.
+
+   rbg
+   xrgb
+   yuv422
+   yuv444
+   rggb
+   grbg
+   gbrg
+   bggr
+
+- xlnx,video-width: This property qualifies the video format with the sample
+  width expressed as a number of bits per pixel component. All components must
+  use the same width.
+
+The following table lists the supported formats and widths combinations, along
+with the corresponding media bus pixel code.
+
++---+---
+Format | Width | Media bus code
++---+---
+rbg| 8 | V4L2_MBUS_FMT_RBG888_1X24
+xrgb   | 8 | V4L2_MBUS_FMT_RGB888_1X32_PADHI
+yuv422 | 8 | V4L2_MBUS_FMT_UYVY8_1X16
+yuv444 | 8 | V4L2_MBUS_FMT_VUY888_1X24
+rggb   | 8 | V4L2_MBUS_FMT_SRGGB8_1X8
+grbg   | 8 | V4L2_MBUS_FMT_SGRBG8_1X8
+gbrg   | 8 | V4L2_MBUS_FMT_SGBRG8_1X8
+bggr   | 8 | V4L2_MBUS_FMT_SBGGR8_1X8
++---+---
diff --git a/Documentation/devicetree/bindings/media/xilinx/xlnx,video.txt 
b/Documentation/devicetree/bindings/media/xilinx/xlnx,video.txt
new file mode 100644
index 000..5a02270
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/xilinx/xlnx,video.txt
@@ -0,0 +1,55 @@
+Xilinx Video IP Pipeline (VIPP)
+---
+
+General concept
+---
+
+Xilinx video IP pipeline processes video 

Re: [PATCH v2 1/5] video: move mediabus format definition to a more standard place

2014-09-29 Thread Laurent Pinchart
Hi Boris,

Thank you for the patch.

On Monday 29 September 2014 16:02:39 Boris Brezillon wrote:
 Rename mediabus formats and move the enum into a separate header file so
 that it can be used by DRM/KMS subsystem without any reference to the V4L2
 subsystem.
 
 Old V4L2_MBUS_FMT_ definitions are now macros that points to VIDEO_BUS_FMT_
 definitions.
 
 Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
 Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
  include/uapi/linux/Kbuild |   1 +
  include/uapi/linux/v4l2-mediabus.h| 183 +--
  include/uapi/linux/video-bus-format.h | 127 +++
  3 files changed, 207 insertions(+), 104 deletions(-)
  create mode 100644 include/uapi/linux/video-bus-format.h

One of the self-inflicted rules in V4L2 is to properly document every new 
media bus format when adding it to the kernel. The documentation is located in 
Documentation/DocBook/media/v4l/subdev-formats.xml. If we move the formats to 
a centralized header (which I believe is a good idea), we should also update 
the documentation, and possibly its location. I really want to avoid getting 
undocumented formats merged, and this will happen if we don't make the rule 
clear and/or don't make the documentation easily accessible.

Incidentally, patch 2/5 in this series is missing a documentation update ;-)

-- 
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] dvb_usb_af9005: fix kernel panic on init if the driver is compiled in without IR symbols

2014-09-29 Thread Luca Olivetti
El 29/09/14 20:17, Frank Schäfer ha escrit:
 This patches fixes an ancient bug in the dvb_usb_af9005 driver, which
 has been reported at least in the following threads:
 https://lkml.org/lkml/2009/2/4/350
 https://lkml.org/lkml/2014/9/18/558
 
 If the driver is compiled in without any IR support (neither
 DVB_USB_AF9005_REMOTE nor custom symbols), the symbol_request calls in
 af9005_usb_module_init() return pointers != NULL although the IR
 symbols are not available.
 
 This leads to the following oops:
 ...
 [8.529751] usbcore: registered new interface driver dvb_usb_af9005
 [8.531584] BUG: unable to handle kernel paging request at 02e0
 [8.533385] IP: [7d9d67c6] af9005_usb_module_init+0x6b/0x9d
 [8.535613] *pde = 
 [8.536416] Oops:  [#1] PREEMPT PREEMPT DEBUG_PAGEALLOCDEBUG_PAGEALLOC
 [8.537863] CPU: 0 PID: 1 Comm: swapper Not tainted 
 3.15.0-rc6-00151-ga5c075c #1
 [8.539827] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
 1.7.5-20140531_083030-gandalf 04/01/2014
 [8.541519] task: 89c9a670 ti: 89c9c000 task.ti: 89c9c000
 [8.541519] EIP: 0060:[7d9d67c6] EFLAGS: 00010206 CPU: 0
 [8.541519] EIP is at af9005_usb_module_init+0x6b/0x9d
 [8.541519] EAX: 02e0 EBX:  ECX: 0006 EDX: 
 [8.541519] ESI:  EDI: 7da33ec8 EBP: 89c9df30 ESP: 89c9df2c
 [8.541519]  DS: 007b ES: 007b FS:  GS: 00e0 SS: 0068
 [8.541519] CR0: 8005003b CR2: 02e0 CR3: 05a54000 CR4: 0690
 [8.541519] Stack:
 [8.541519]  7d9d675b 89c9df90 7d992a49 7d7d5914 89c9df4c 7be3a800 
 7d08c58c 8a4c3968
 [8.541519]  89c9df80 7be3a966 0192 0006 0006 7d7d3ff4 
 8a4c397a 0200
 [8.541519]  7d6b1280 8a4c3979 0006 09a6 7da32db8 b13eec81 
 0006 09a6
 [8.541519] Call Trace:
 [8.541519]  [7d9d675b] ? ttusb2_driver_init+0x16/0x16
 [8.541519]  [7d992a49] do_one_initcall+0x77/0x106
 [8.541519]  [7be3a800] ? parameqn+0x2/0x35
 [8.541519]  [7be3a966] ? parse_args+0x113/0x25c
 [8.541519]  [7d992bc2] kernel_init_freeable+0xea/0x167
 [8.541519]  [7cf01070] kernel_init+0x8/0xb8
 [8.541519]  [7cf27ec0] ret_from_kernel_thread+0x20/0x30
 [8.541519]  [7cf01068] ? rest_init+0x10c/0x10c
 [8.541519] Code: 08 c2 c7 05 44 ed f9 7d 00 00 e0 02 c7 05 40 ed f9 7d 00 
 00 e0 02 c7 05 3c ed f9 7d 00 00 e0 02 75 1f b8 00 00 e0 02 85 c0 74 16 a1 
 00 00 e0 02 c7 05 54 84 8e 7d 00 00 e0 02 a3 58 84 8e 7d eb
 [8.541519] EIP: [7d9d67c6] af9005_usb_module_init+0x6b/0x9d SS:ESP 
 0068:89c9df2c
 [8.541519] CR2: 02e0
 [8.541519] ---[ end trace 768b6faf51370fc7 ]---
 
 The prefered fix would be to convert the whole IR code to use the kernel IR
 infrastructure (which wasn't available at the time this driver had been 
 created).
 
 Until anyone who still has this old hardware steps up an does the conversion,
 fix it by not calling the symbol_request calls if the driver is compiled in
 without the default IR symbols (CONFIG_DVB_USB_AF9005_REMOTE).
 Due to the IR related pointers beeing NULL by default, IR support will then 
 be disabled.
 
 The downside of this solution is, that it will no longer be possible to
 compile custom IR symbols (not using CONFIG_DVB_USB_AF9005_REMOTE) in.
 
 Please note that this patch has NOT been tested with all possible cases.
 I don't have the hardware and could only verify that it fixes the reported
 bug.
 
 Reported-by: Fengguag Wu fengguang...@intel.com
 Signed-off-by: Frank Schäfer fschaefer@googlemail.com
 Cc: sta...@vger.kernel.org

Acked-by: Luca Olivetti l...@ventoso.org


 ---
  drivers/media/usb/dvb-usb/af9005.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/drivers/media/usb/dvb-usb/af9005.c 
 b/drivers/media/usb/dvb-usb/af9005.c
 index af176b6..e6d3561 100644
 --- a/drivers/media/usb/dvb-usb/af9005.c
 +++ b/drivers/media/usb/dvb-usb/af9005.c
 @@ -1081,9 +1081,12 @@ static int __init af9005_usb_module_init(void)
   err(usb_register failed. (%d), result);
   return result;
   }
 +#if IS_MODULE(CONFIG_DVB_USB_AF9005) || defined(CONFIG_DVB_USB_AF9005_REMOTE)
 + /* FIXME: convert to todays kernel IR infrastructure */
   rc_decode = symbol_request(af9005_rc_decode);
   rc_keys = symbol_request(rc_map_af9005_table);
   rc_keys_size = symbol_request(rc_map_af9005_table_size);
 +#endif
   if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) {
   err(af9005_rc_decode function not found, disabling remote);
   af9005_properties.rc.legacy.rc_query = 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


Regression: in v4l2 converter does not set the buffer.length anymore

2014-09-29 Thread Nicolas Dufresne

This was initially reported to GStreamer project:
https://bugzilla.gnome.org/show_bug.cgi?id=737521

We track this down to be a regression introduced in v4l2-utils from 
version 1.4.0. In recent GStreamer we make sure the buffer.length field 
(retreived with QUERYBUF) is bigger or equal to the expected sizeimage 
(as obtained in S_FMT). This is to fail cleanly and avoid buffer 
overflow if a driver (or libv4l2) endup doing a short allocation. Since 
1.4.0, this field is always 0 if an emulated format is selected.


Reverting patch 10213c brings back normal behaviour:
http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=10213c975afdfcc90aa7de39e66c40cd7e8a57f7

This currently makes use of any emulated format impossible in GStreamer. 
v4l2-utils 1.4.0 is being shipped at least in debian/unstable at the moment.


cheers,
Nicolas
--
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 v5 1/6] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint

2014-09-29 Thread Greg Kroah-Hartman
On Mon, Sep 29, 2014 at 08:03:34PM +0200, Philipp Zabel wrote:
 Decrementing the reference count of the previous endpoint node allows to
 use the of_graph_get_next_endpoint function in a for_each_... style macro.
 All current users of this function that pass a non-NULL prev parameter
 (that is, soc_camera and imx-drm) are changed to not decrement the passed
 prev argument's refcount themselves.
 
 Signed-off-by: Philipp Zabel p.za...@pengutronix.de
 ---
 Changes since v4:
  - Folded patches 1-3 into this one
 ---
  drivers/media/platform/soc_camera/soc_camera.c |  3 ++-
  drivers/of/base.c  |  9 +
  drivers/staging/imx-drm/imx-drm-core.c | 12 ++--
  3 files changed, 5 insertions(+), 19 deletions(-)

No objection from me for this, but Grant is in charge of
drivers/of/base.c, so I'll leave it for him to apply.

Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org

thanks,

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


cron job: media_tree daily build: WARNINGS

2014-09-29 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Tue Sep 30 04:00:14 CEST 2014
git branch: test
git hash:   cf3167cf1e969b17671a4d3d956d22718a8ceb85
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-20-g7abd8a7
host hardware:  x86_64
host os:3.16-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: WARNINGS
linux-3.12.23-i686: WARNINGS
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: OK
linux-3.16-i686: OK
linux-3.17-rc1-i686: OK
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: WARNINGS
linux-3.12.23-x86_64: WARNINGS
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16-x86_64: WARNINGS
linux-3.17-rc1-x86_64: WARNINGS
apps: OK
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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