[PATCH 3/8] rtl2832: Fix deadlock on i2c mux select function.

2014-02-08 Thread Antti Palosaari
From: Luis Alves lja...@gmail.com

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index c0366a8..cfc5438 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -917,7 +917,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
buf[0] = 0x00;
buf[1] = 0x01;
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
@@ -930,7 +930,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
else
buf[1] = 0x10; /* close */
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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/8] rtl28xxu: use muxed RTL2832 I2C adapters for E4000 and RTL2832_SDR

2014-02-08 Thread Antti Palosaari
RTL2832 driver provides muxed I2C adapters for tuner bus I2C gate
control. Pass those adapters to rtl2832_sdr and e4000 modules in order
to get rid of proprietary DVB .i2c_gate_ctrl() callback use.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 12 ++--
 drivers/media/usb/dvb-usb-v2/rtl28xxu.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index afafe92..e04a3e9 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -774,6 +774,9 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
goto err;
}
 
+   /* RTL2832 I2C repeater */
+   priv-demod_i2c_adapter = rtl2832_get_i2c_adapter(adap-fe[0]);
+
/* set fe callback */
adap-fe[0]-callback = rtl2832u_frontend_callback;
 
@@ -920,6 +923,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
rtl28xxu_rtl2832_fc0013_config);
break;
case TUNER_RTL2832_E4000: {
+   struct i2c_adapter *i2c_adap_internal =
+   
rtl2832_get_private_i2c_adapter(adap-fe[0]);
struct e4000_config e4000_config = {
.fe = adap-fe[0],
.clock = 2880,
@@ -930,11 +935,14 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
info.platform_data = e4000_config;
 
request_module(e4000);
-   priv-client = i2c_new_device(d-i2c_adap, info);
+   priv-client = i2c_new_device(priv-demod_i2c_adapter,
+   info);
+
+   i2c_set_adapdata(i2c_adap_internal, d);
 
/* attach SDR */
dvb_attach(rtl2832_sdr_attach, adap-fe[0],
-   d-i2c_adap,
+   i2c_adap_internal,
rtl28xxu_rtl2832_e4000_config);
}
break;
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
index 367aca1..a26cab1 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
@@ -55,6 +55,7 @@ struct rtl28xxu_priv {
u8 tuner;
char *tuner_name;
u8 page; /* integrated demod active register page */
+   struct i2c_adapter *demod_i2c_adapter;
bool rc_active;
struct i2c_client *client;
 };
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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 7/8] rtl2832_sdr: do not init tuner when only freq is changed

2014-02-08 Thread Antti Palosaari
Initializing whole tuner every time when frequency is changed is wrong
and unnecessary. Init tuner only when streaming is started. Change
other parameters runtime.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 25 +++-
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index 0d96aea..cc554f7 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -912,7 +912,7 @@ err:
return;
 };
 
-static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
+static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_state *s)
 {
struct dvb_frontend *fe = s-fe;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
@@ -946,15 +946,24 @@ static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state 
*s)
if (!test_bit(POWER_ON, s-flags))
return 0;
 
-   if (fe-ops.tuner_ops.init)
-   fe-ops.tuner_ops.init(fe);
-
if (fe-ops.tuner_ops.set_params)
fe-ops.tuner_ops.set_params(fe);
 
return 0;
 };
 
+static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
+{
+   struct dvb_frontend *fe = s-fe;
+
+   dev_dbg(s-udev-dev, %s:\n, __func__);
+
+   if (fe-ops.tuner_ops.init)
+   fe-ops.tuner_ops.init(fe);
+
+   return 0;
+};
+
 static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_state *s)
 {
struct dvb_frontend *fe = s-fe;
@@ -988,6 +997,10 @@ static int rtl2832_sdr_start_streaming(struct vb2_queue 
*vq, unsigned int count)
if (ret)
goto err;
 
+   ret = rtl2832_sdr_set_tuner_freq(s);
+   if (ret)
+   goto err;
+
ret = rtl2832_sdr_set_adc(s);
if (ret)
goto err;
@@ -1127,6 +1140,7 @@ static int rtl2832_sdr_s_frequency(struct file *file, 
void *priv,
 {
struct rtl2832_sdr_state *s = video_drvdata(file);
int ret, band;
+
dev_dbg(s-udev-dev, %s: tuner=%d type=%d frequency=%u\n,
__func__, f-tuner, f-type, f-frequency);
 
@@ -1153,7 +1167,8 @@ static int rtl2832_sdr_s_frequency(struct file *file, 
void *priv,
s-f_tuner = f-frequency;
dev_dbg(s-udev-dev, %s: RF frequency=%u Hz\n,
__func__, f-frequency);
-   ret = rtl2832_sdr_set_tuner(s);
+
+   ret = rtl2832_sdr_set_tuner_freq(s);
} else {
ret = -EINVAL;
}
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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 6/8] e4000: get rid of DVB i2c_gate_ctrl()

2014-02-08 Thread Antti Palosaari
Gate control is now implemented by rtl2832 I2C adapter so we do not
need proprietary DVB i2c_gate_ctrl() anymore.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/e4000.c | 106 +--
 1 file changed, 21 insertions(+), 85 deletions(-)

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 662e19a1..e3e3b7e 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -119,9 +119,6 @@ static int e4000_init(struct dvb_frontend *fe)
 
dev_dbg(priv-client-dev, %s:\n, __func__);
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-
/* dummy I2C to ensure I2C wakes up */
ret = e4000_wr_reg(priv, 0x02, 0x40);
 
@@ -178,17 +175,11 @@ static int e4000_init(struct dvb_frontend *fe)
if (ret  0)
goto err;
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-
priv-active = true;
-
-   return 0;
 err:
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   if (ret)
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
 
-   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -201,22 +192,13 @@ static int e4000_sleep(struct dvb_frontend *fe)
 
priv-active = false;
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-
ret = e4000_wr_reg(priv, 0x00, 0x00);
if (ret  0)
goto err;
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-
-   return 0;
 err:
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   if (ret)
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
 
-   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -233,9 +215,6 @@ static int e4000_set_params(struct dvb_frontend *fe)
__func__, c-delivery_system, c-frequency,
c-bandwidth_hz);
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-
/* gain control manual */
ret = e4000_wr_reg(priv, 0x1a, 0x00);
if (ret  0)
@@ -361,16 +340,10 @@ static int e4000_set_params(struct dvb_frontend *fe)
ret = e4000_wr_reg(priv, 0x1a, 0x17);
if (ret  0)
goto err;
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-
-   return 0;
 err:
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   if (ret)
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
 
-   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -390,14 +363,12 @@ static int e4000_set_lna_gain(struct dvb_frontend *fe)
struct e4000_priv *priv = fe-tuner_priv;
int ret;
u8 u8tmp;
+
dev_dbg(priv-client-dev, %s: lna auto=%d-%d val=%d-%d\n,
__func__, priv-lna_gain_auto-cur.val,
priv-lna_gain_auto-val, priv-lna_gain-cur.val,
priv-lna_gain-val);
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-
if (priv-lna_gain_auto-val  priv-if_gain_auto-cur.val)
u8tmp = 0x17;
else if (priv-lna_gain_auto-val)
@@ -416,16 +387,10 @@ static int e4000_set_lna_gain(struct dvb_frontend *fe)
if (ret)
goto err;
}
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-
-   return 0;
 err:
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   if (ret)
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
 
-   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
 
@@ -434,14 +399,12 @@ static int e4000_set_mixer_gain(struct dvb_frontend *fe)
struct e4000_priv *priv = fe-tuner_priv;
int ret;
u8 u8tmp;
+
dev_dbg(priv-client-dev, %s: mixer auto=%d-%d val=%d-%d\n,
__func__, priv-mixer_gain_auto-cur.val,
priv-mixer_gain_auto-val, priv-mixer_gain-cur.val,
priv-mixer_gain-val);
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-
if (priv-mixer_gain_auto-val)
u8tmp = 0x15;
else
@@ -456,16 +419,10 @@ static int e4000_set_mixer_gain(struct dvb_frontend *fe)
if (ret)
goto err;
}
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-
-   return 0;
 err:
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   if (ret)
+   dev_dbg(priv-client-dev, %s: failed=%d\n, __func__, ret);
 
-   

[PATCH 0/8] regmap API kernel I2C driver model

2014-02-08 Thread Antti Palosaari
Converting DVB tuner driver to near kernel practices has been long on
my todo, as I have mentioned multiple times.
Here it is, looks pretty nice! No gate-control, nor home made I2C low
level access routines anymore...

Maybe the only downside is new dependency to regmap (and I2C mux, which
was done already). Fortunately regmap seems to be quite widely used, it
is likely enabled by default most distributions already.

Antti

Antti Palosaari (7):
  rtl2832: provide muxed I2C adapter
  rtl2832: add muxed I2C adapter for demod itself
  rtl2832: implement delayed I2C gate close
  rtl28xxu: use muxed RTL2832 I2C adapters for E4000 and RTL2832_SDR
  e4000: get rid of DVB i2c_gate_ctrl()
  rtl2832_sdr: do not init tuner when only freq is changed
  e4000: convert to Regmap API

Luis Alves (1):
  rtl2832: Fix deadlock on i2c mux select function.

 drivers/media/dvb-frontends/Kconfig  |   2 +-
 drivers/media/dvb-frontends/rtl2832.c| 159 ++-
 drivers/media/dvb-frontends/rtl2832.h|  25 ++
 drivers/media/dvb-frontends/rtl2832_priv.h   |   4 +
 drivers/media/tuners/Kconfig |   1 +
 drivers/media/tuners/e4000.c | 528 ---
 drivers/media/tuners/e4000_priv.h|   4 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c  |  12 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.h  |   1 +
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c |  25 +-
 10 files changed, 413 insertions(+), 348 deletions(-)

-- 
1.8.5.3

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


[PATCH 4/8] rtl2832: implement delayed I2C gate close

2014-02-08 Thread Antti Palosaari
Delay possible I2C gate close a little bit in order to see if there
is next message coming to tuner in a sequence.

Also, export private muxed I2C adapter. That is aimed only for SDR
extension module as SDR belongs to same RTL2832 physical I2C bus (it
is physically property of RTL2832, whilst it is own kernel module).

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832.c  | 92 +-
 drivers/media/dvb-frontends/rtl2832.h  | 12 
 drivers/media/dvb-frontends/rtl2832_priv.h |  1 +
 3 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index cfc5438..fdbed35 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -891,16 +891,65 @@ static void rtl2832_release(struct dvb_frontend *fe)
struct rtl2832_priv *priv = fe-demodulator_priv;
 
dev_dbg(priv-i2c-dev, %s:\n, __func__);
+   cancel_delayed_work_sync(priv-i2c_gate_work);
i2c_del_mux_adapter(priv-i2c_adapter_tuner);
i2c_del_mux_adapter(priv-i2c_adapter);
kfree(priv);
 }
 
+/*
+ * Delay mechanism to avoid unneeded I2C gate open / close. Gate close is
+ * delayed here a little bit in order to see if there is sequence of I2C
+ * messages sent to same I2C bus.
+ * We must use unlocked version of __i2c_transfer() in order to avoid deadlock
+ * as lock is already taken by calling muxed i2c_transfer().
+ */
+static void rtl2832_i2c_gate_work(struct work_struct *work)
+{
+   struct rtl2832_priv *priv = container_of(work,
+   struct rtl2832_priv, i2c_gate_work.work);
+   struct i2c_adapter *adap = priv-i2c;
+   int ret;
+   u8 buf[2];
+   struct i2c_msg msg[1] = {
+   {
+   .addr = priv-cfg.i2c_addr,
+   .flags = 0,
+   .len = sizeof(buf),
+   .buf = buf,
+   }
+   };
+
+   /* select reg bank 1 */
+   buf[0] = 0x00;
+   buf[1] = 0x01;
+   ret = __i2c_transfer(adap, msg, 1);
+   if (ret != 1)
+   goto err;
+
+   priv-page = 1;
+
+   /* close I2C repeater gate */
+   buf[0] = 0x01;
+   buf[1] = 0x10;
+   ret = __i2c_transfer(adap, msg, 1);
+   if (ret != 1)
+   goto err;
+
+   priv-i2c_gate_state = 0;
+
+   return;
+err:
+   dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
+
+   return;
+}
+
 static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 
chan_id)
 {
struct rtl2832_priv *priv = mux_priv;
int ret;
-   u8 buf[2];
+   u8 buf[2], val;
struct i2c_msg msg[1] = {
{
.addr = priv-cfg.i2c_addr,
@@ -909,6 +958,22 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
.buf = buf,
}
};
+   struct i2c_msg msg_rd[2] = {
+   {
+   .addr = priv-cfg.i2c_addr,
+   .flags = 0,
+   .len = 1,
+   .buf = \x01,
+   }, {
+   .addr = priv-cfg.i2c_addr,
+   .flags = I2C_M_RD,
+   .len = 1,
+   .buf = val,
+   }
+   };
+
+   /* terminate possible gate closing */
+   cancel_delayed_work_sync(priv-i2c_gate_work);
 
if (priv-i2c_gate_state == chan_id)
return 0;
@@ -916,13 +981,17 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
/* select reg bank 1 */
buf[0] = 0x00;
buf[1] = 0x01;
-
ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
priv-page = 1;
 
+   /* we must read that register, otherwise there will be errors */
+   ret = __i2c_transfer(adap, msg_rd, 2);
+   if (ret != 2)
+   goto err;
+
/* open or close I2C repeater gate */
buf[0] = 0x01;
if (chan_id == 1)
@@ -939,9 +1008,18 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
return 0;
 err:
dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
+
return -EREMOTEIO;
 }
 
+static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv,
+   u32 chan_id)
+{
+   struct rtl2832_priv *priv = mux_priv;
+   schedule_delayed_work(priv-i2c_gate_work, usecs_to_jiffies(100));
+   return 0;
+}
+
 struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe)
 {
struct rtl2832_priv *priv = fe-demodulator_priv;
@@ -949,6 +1027,13 @@ struct i2c_adapter *rtl2832_get_i2c_adapter(struct 
dvb_frontend *fe)
 }
 EXPORT_SYMBOL(rtl2832_get_i2c_adapter);
 
+struct i2c_adapter *rtl2832_get_private_i2c_adapter(struct dvb_frontend *fe)

[PATCH 1/8] rtl2832: provide muxed I2C adapter

2014-02-08 Thread Antti Palosaari
RTL2832 provides gated / repeater I2C adapter for tuner.
Implement it as a muxed I2C adapter.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/Kconfig|  2 +-
 drivers/media/dvb-frontends/rtl2832.c  | 26 ++
 drivers/media/dvb-frontends/rtl2832.h  | 13 +
 drivers/media/dvb-frontends/rtl2832_priv.h |  2 ++
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index dd12a1e..d701488 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -441,7 +441,7 @@ config DVB_RTL2830
 
 config DVB_RTL2832
tristate Realtek RTL2832 DVB-T
-   depends on DVB_CORE  I2C
+   depends on DVB_CORE  I2C  I2C_MUX
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Say Y when you want to support this frontend.
diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index 00e63b9..dc46cf0 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -891,9 +891,29 @@ static void rtl2832_release(struct dvb_frontend *fe)
struct rtl2832_priv *priv = fe-demodulator_priv;
 
dev_dbg(priv-i2c-dev, %s:\n, __func__);
+   i2c_del_mux_adapter(priv-i2c_adapter);
kfree(priv);
 }
 
+static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan)
+{
+   struct rtl2832_priv *priv = mux_priv;
+   return rtl2832_i2c_gate_ctrl(priv-fe, 1);
+}
+
+static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv, u32 chan)
+{
+   struct rtl2832_priv *priv = mux_priv;
+   return rtl2832_i2c_gate_ctrl(priv-fe, 0);
+}
+
+struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe)
+{
+   struct rtl2832_priv *priv = fe-demodulator_priv;
+   return priv-i2c_adapter;
+}
+EXPORT_SYMBOL(rtl2832_get_i2c_adapter);
+
 struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg,
struct i2c_adapter *i2c)
 {
@@ -918,6 +938,12 @@ struct dvb_frontend *rtl2832_attach(const struct 
rtl2832_config *cfg,
if (ret)
goto err;
 
+   /* create muxed i2c adapter */
+   priv-i2c_adapter = i2c_add_mux_adapter(i2c, i2c-dev, priv, 0, 0, 0,
+   rtl2832_select, rtl2832_deselect);
+   if (priv-i2c_adapter == NULL)
+   goto err;
+
/* create dvb_frontend */
memcpy(priv-fe.ops, rtl2832_ops, sizeof(struct dvb_frontend_ops));
priv-fe.demodulator_priv = priv;
diff --git a/drivers/media/dvb-frontends/rtl2832.h 
b/drivers/media/dvb-frontends/rtl2832.h
index fa4e5f6..a9202d7 100644
--- a/drivers/media/dvb-frontends/rtl2832.h
+++ b/drivers/media/dvb-frontends/rtl2832.h
@@ -55,7 +55,13 @@ struct dvb_frontend *rtl2832_attach(
const struct rtl2832_config *cfg,
struct i2c_adapter *i2c
 );
+
+extern struct i2c_adapter *rtl2832_get_i2c_adapter(
+   struct dvb_frontend *fe
+);
+
 #else
+
 static inline struct dvb_frontend *rtl2832_attach(
const struct rtl2832_config *config,
struct i2c_adapter *i2c
@@ -64,6 +70,13 @@ static inline struct dvb_frontend *rtl2832_attach(
pr_warn(%s: driver disabled by Kconfig\n, __func__);
return NULL;
 }
+
+static inline struct i2c_adapter *rtl2832_get_i2c_adapter(
+   struct dvb_frontend *fe
+)
+{
+   return NULL;
+}
 #endif
 
 
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h 
b/drivers/media/dvb-frontends/rtl2832_priv.h
index 4c845af..ec26c92 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -23,9 +23,11 @@
 
 #include dvb_frontend.h
 #include rtl2832.h
+#include linux/i2c-mux.h
 
 struct rtl2832_priv {
struct i2c_adapter *i2c;
+   struct i2c_adapter *i2c_adapter;
struct dvb_frontend fe;
struct rtl2832_config cfg;
 
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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 8/8] e4000: convert to Regmap API

2014-02-08 Thread Antti Palosaari
That comes possible after driver was converted to kernel I2C model
(I2C binding  proper I2C client with no gate control hack). All
nasty low level I2C routines are now covered by regmap.

Also some variable renaming and minor functionality changes.

Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/tuners/Kconfig  |   1 +
 drivers/media/tuners/e4000.c  | 442 --
 drivers/media/tuners/e4000_priv.h |   4 +-
 3 files changed, 184 insertions(+), 263 deletions(-)

diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig
index ba2e365..a128488 100644
--- a/drivers/media/tuners/Kconfig
+++ b/drivers/media/tuners/Kconfig
@@ -204,6 +204,7 @@ config MEDIA_TUNER_TDA18212
 config MEDIA_TUNER_E4000
tristate Elonics E4000 silicon tuner
depends on MEDIA_SUPPORT  I2C
+   select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Elonics E4000 silicon tuner driver.
diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index e3e3b7e..0d516ad 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -21,203 +21,112 @@
 #include e4000_priv.h
 #include linux/math64.h
 
-/* Max transfer size done by I2C transfer functions */
-#define MAX_XFER_SIZE  64
-
-/* write multiple registers */
-static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
-{
-   int ret;
-   u8 buf[MAX_XFER_SIZE];
-   struct i2c_msg msg[1] = {
-   {
-   .addr = priv-client-addr,
-   .flags = 0,
-   .len = 1 + len,
-   .buf = buf,
-   }
-   };
-
-   if (1 + len  sizeof(buf)) {
-   dev_warn(priv-client-dev,
-%s: i2c wr reg=%04x: len=%d is too big!\n,
-KBUILD_MODNAME, reg, len);
-   return -EINVAL;
-   }
-
-   buf[0] = reg;
-   memcpy(buf[1], val, len);
-
-   ret = i2c_transfer(priv-client-adapter, msg, 1);
-   if (ret == 1) {
-   ret = 0;
-   } else {
-   dev_warn(priv-client-dev,
-   %s: i2c wr failed=%d reg=%02x len=%d\n,
-   KBUILD_MODNAME, ret, reg, len);
-   ret = -EREMOTEIO;
-   }
-   return ret;
-}
-
-/* read multiple registers */
-static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
-{
-   int ret;
-   u8 buf[MAX_XFER_SIZE];
-   struct i2c_msg msg[2] = {
-   {
-   .addr = priv-client-addr,
-   .flags = 0,
-   .len = 1,
-   .buf = reg,
-   }, {
-   .addr = priv-client-addr,
-   .flags = I2C_M_RD,
-   .len = len,
-   .buf = buf,
-   }
-   };
-
-   if (len  sizeof(buf)) {
-   dev_warn(priv-client-dev,
-%s: i2c rd reg=%04x: len=%d is too big!\n,
-KBUILD_MODNAME, reg, len);
-   return -EINVAL;
-   }
-
-   ret = i2c_transfer(priv-client-adapter, msg, 2);
-   if (ret == 2) {
-   memcpy(val, buf, len);
-   ret = 0;
-   } else {
-   dev_warn(priv-client-dev,
-   %s: i2c rd failed=%d reg=%02x len=%d\n,
-   KBUILD_MODNAME, ret, reg, len);
-   ret = -EREMOTEIO;
-   }
-
-   return ret;
-}
-
-/* write single register */
-static int e4000_wr_reg(struct e4000_priv *priv, u8 reg, u8 val)
-{
-   return e4000_wr_regs(priv, reg, val, 1);
-}
-
-/* read single register */
-static int e4000_rd_reg(struct e4000_priv *priv, u8 reg, u8 *val)
-{
-   return e4000_rd_regs(priv, reg, val, 1);
-}
-
 static int e4000_init(struct dvb_frontend *fe)
 {
-   struct e4000_priv *priv = fe-tuner_priv;
+   struct e4000 *s = fe-tuner_priv;
int ret;
 
-   dev_dbg(priv-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, %s:\n, __func__);
 
/* dummy I2C to ensure I2C wakes up */
-   ret = e4000_wr_reg(priv, 0x02, 0x40);
+   ret = regmap_write(s-regmap, 0x02, 0x40);
 
/* reset */
-   ret = e4000_wr_reg(priv, 0x00, 0x01);
-   if (ret  0)
+   ret = regmap_write(s-regmap, 0x00, 0x01);
+   if (ret)
goto err;
 
/* disable output clock */
-   ret = e4000_wr_reg(priv, 0x06, 0x00);
-   if (ret  0)
+   ret = regmap_write(s-regmap, 0x06, 0x00);
+   if (ret)
goto err;
 
-   ret = e4000_wr_reg(priv, 0x7a, 0x96);
-   if (ret  0)
+   ret = regmap_write(s-regmap, 0x7a, 0x96);
+   if (ret)
goto err;
 
/* configure gains */
-   ret = 

[PATCH 2/8] rtl2832: add muxed I2C adapter for demod itself

2014-02-08 Thread Antti Palosaari
There was a deadlock between master I2C adapter and muxed I2C
adapter. Implement two I2C muxed I2C adapters and leave master
alone, just only for offering I2C adapter for these mux adapters.

Reported-by: Luis Alves lja...@gmail.com
Reported-by: Benjamin Larsson benja...@southpole.se
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832.c  | 71 --
 drivers/media/dvb-frontends/rtl2832_priv.h |  1 +
 2 files changed, 58 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index dc46cf0..c0366a8 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -180,7 +180,7 @@ static int rtl2832_wr(struct rtl2832_priv *priv, u8 reg, u8 
*val, int len)
buf[0] = reg;
memcpy(buf[1], val, len);
 
-   ret = i2c_transfer(priv-i2c, msg, 1);
+   ret = i2c_transfer(priv-i2c_adapter, msg, 1);
if (ret == 1) {
ret = 0;
} else {
@@ -210,7 +210,7 @@ static int rtl2832_rd(struct rtl2832_priv *priv, u8 reg, u8 
*val, int len)
}
};
 
-   ret = i2c_transfer(priv-i2c, msg, 2);
+   ret = i2c_transfer(priv-i2c_adapter, msg, 2);
if (ret == 2) {
ret = 0;
} else {
@@ -891,26 +891,61 @@ static void rtl2832_release(struct dvb_frontend *fe)
struct rtl2832_priv *priv = fe-demodulator_priv;
 
dev_dbg(priv-i2c-dev, %s:\n, __func__);
+   i2c_del_mux_adapter(priv-i2c_adapter_tuner);
i2c_del_mux_adapter(priv-i2c_adapter);
kfree(priv);
 }
 
-static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan)
+static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 
chan_id)
 {
struct rtl2832_priv *priv = mux_priv;
-   return rtl2832_i2c_gate_ctrl(priv-fe, 1);
-}
+   int ret;
+   u8 buf[2];
+   struct i2c_msg msg[1] = {
+   {
+   .addr = priv-cfg.i2c_addr,
+   .flags = 0,
+   .len = sizeof(buf),
+   .buf = buf,
+   }
+   };
 
-static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv, u32 chan)
-{
-   struct rtl2832_priv *priv = mux_priv;
-   return rtl2832_i2c_gate_ctrl(priv-fe, 0);
+   if (priv-i2c_gate_state == chan_id)
+   return 0;
+
+   /* select reg bank 1 */
+   buf[0] = 0x00;
+   buf[1] = 0x01;
+
+   ret = i2c_transfer(adap, msg, 1);
+   if (ret != 1)
+   goto err;
+
+   priv-page = 1;
+
+   /* open or close I2C repeater gate */
+   buf[0] = 0x01;
+   if (chan_id == 1)
+   buf[1] = 0x18; /* open */
+   else
+   buf[1] = 0x10; /* close */
+
+   ret = i2c_transfer(adap, msg, 1);
+   if (ret != 1)
+   goto err;
+
+   priv-i2c_gate_state = chan_id;
+
+   return 0;
+err:
+   dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
+   return -EREMOTEIO;
 }
 
 struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe)
 {
struct rtl2832_priv *priv = fe-demodulator_priv;
-   return priv-i2c_adapter;
+   return priv-i2c_adapter_tuner;
 }
 EXPORT_SYMBOL(rtl2832_get_i2c_adapter);
 
@@ -933,15 +968,21 @@ struct dvb_frontend *rtl2832_attach(const struct 
rtl2832_config *cfg,
priv-tuner = cfg-tuner;
memcpy(priv-cfg, cfg, sizeof(struct rtl2832_config));
 
+   /* create muxed i2c adapter for demod itself */
+   priv-i2c_adapter = i2c_add_mux_adapter(i2c, i2c-dev, priv, 0, 0, 0,
+   rtl2832_select, NULL);
+   if (priv-i2c_adapter == NULL)
+   goto err;
+
/* check if the demod is there */
ret = rtl2832_rd_reg(priv, 0x00, 0x0, tmp);
if (ret)
goto err;
 
-   /* create muxed i2c adapter */
-   priv-i2c_adapter = i2c_add_mux_adapter(i2c, i2c-dev, priv, 0, 0, 0,
-   rtl2832_select, rtl2832_deselect);
-   if (priv-i2c_adapter == NULL)
+   /* create muxed i2c adapter for demod tuner bus */
+   priv-i2c_adapter_tuner = i2c_add_mux_adapter(i2c, i2c-dev, priv,
+   0, 1, 0, rtl2832_select, NULL);
+   if (priv-i2c_adapter_tuner == NULL)
goto err;
 
/* create dvb_frontend */
@@ -954,6 +995,8 @@ struct dvb_frontend *rtl2832_attach(const struct 
rtl2832_config *cfg,
return priv-fe;
 err:
dev_dbg(i2c-dev, %s: failed=%d\n, __func__, ret);
+   if (priv  priv-i2c_adapter)
+   i2c_del_mux_adapter(priv-i2c_adapter);
kfree(priv);
return NULL;
 }
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h 
b/drivers/media/dvb-frontends/rtl2832_priv.h
index ec26c92..8b7c1ae 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -28,6 +28,7 @@
 struct 

Re: [PATCH 3/8] rtl2832: Fix deadlock on i2c mux select function.

2014-02-08 Thread Antti Palosaari

Luis,
Could you send your SOB?

Antti

On 08.02.2014 11:37, Antti Palosaari wrote:

From: Luis Alves lja...@gmail.com

Signed-off-by: Antti Palosaari cr...@iki.fi
---
  drivers/media/dvb-frontends/rtl2832.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index c0366a8..cfc5438 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -917,7 +917,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
buf[0] = 0x00;
buf[1] = 0x01;

-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;

@@ -930,7 +930,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void 
*mux_priv, u32 chan_id)
else
buf[1] = 0x10; /* close */

-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;





--
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: [RFC 0/4] rc: ir-raw: Add encode, implement NEC encode

2014-02-08 Thread Antti Seppälä
On 6 February 2014 21:59, James Hogan james.ho...@imgtec.com wrote:
 A recent discussion about proposed interfaces for setting up the
 hardware wakeup filter lead to the conclusion that it could help to have
 the generic capability to encode and modulate scancodes into raw IR
 events so that drivers for hardware with a low level wake filter (on the
 level of pulse/space durations) can still easily implement the higher
 level scancode interface that is proposed.

 This patchset is just a quick experiment to suggest how it might work.
 I'm not familiar with the hardware that could use it so it could well be
 a bit misdesigned in places (e.g. what sort of buffer length would the
 hardware have, do we need to support any kind of partial encoding, can
 the hardware/driver easily take care of allowing for a margin of
 error?).


Hi James.

Thank you for your patchset. I think it is a good start towards an
interface for encoding scancodes back to ir pulses.

First some elaboration to what support is needed regarding nuvoton:

The buffer length is 67 pulses or spaces. At current sampling rate
maximum length of each individual pulse/space is 6350usec. However if
longer consecutive pulses occur they can be split to multiple smaller
values to represent the original long value. Ir-core can just leave
splitting values to the driver.

Due to the 67 pulse/space limitation I'd say that support for partial
encoding would be needed. Now it is difficult for driver to allocate
enough memory for some of the chattier protocols.

The nuvoton hardware has a special register for setting accepted
margin of error (cmp_tolerance). This is the delta within which each
pulse/space length is still considered a match. So for nuvoton the
margin of error does not need to be worried about.


 The first patch adds an encode callback to the existing raw ir handler
 struct and a helper function to encode a scancode for a given protocol.


The mechanism used here to encode works fine as long as there is only
one protocol selected. If there are several which all support encoding
then there's no easy way to tell which one will be used to do the
actual encoding.

 The third patch implements encode for NEC. The modulation is abstracted
 to use functions in patch 2 (pulse-distance is used by multiple
 protocols).

 Finally for debug purposes patch 4 modifies img-ir-raw to loop back the
 encoded data when a filter is altered. Should be pretty easy to apply
 similarly to any raw ir driver to try it out.


I believe we have rc-loopback driver for exactly this purpose. Could
you use it instead? Also adding the scancode filter to it would
demonstrate its usage.

One other thing I noticed while reviewing your patches was that
currently the dev-s_filter callback return value is ignored by
store_filter. It would be useful to return an error to userspace if
scancode storage was not possible for whatever reason.


Nevertheless I decided to use this patchset as a basis and write a
generic rc-5 encoder and use it to support streamzap protocol in
nuvoton. I'll post my patchset shortly for review / discussion.

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


[RFC PATCH 1/3] rc-core: Add Manchester encoder (phase encoder) support to rc-core

2014-02-08 Thread Antti Seppälä
Adding a simple Manchester encoder to rc-core.
Manchester coding is used by at least RC-5 protocol and its variants.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/ir-raw.c   | 44 +
 drivers/media/rc/rc-core-priv.h | 14 +
 2 files changed, 58 insertions(+)

diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 9d734dd..7fea9ac 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -240,6 +240,50 @@ ir_raw_get_allowed_protocols(void)
return protocols;
 }
 
+int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
+ const struct ir_raw_timings_manchester *timings,
+ unsigned int n, unsigned int data)
+{
+   bool need_pulse;
+   int i, count = 0;
+   i = 1  (n - 1);
+
+   if (n  max || max  2)
+   return -EINVAL;
+
+   if (timings-pulse_space_start) {
+   init_ir_raw_event_duration((*ev)++, 1, timings-clock);
+   init_ir_raw_event_duration((*ev), 0, timings-clock);
+   count += 2;
+   } else {
+   init_ir_raw_event_duration((*ev), 1, timings-clock);
+   count++;
+   }
+   i = 1;
+
+   while (i  0) {
+   if (count  max)
+   return -EINVAL;
+
+   need_pulse = !(data  i);
+   if (need_pulse == !!(*ev)-pulse) {
+   (*ev)-duration += timings-clock;
+   } else {
+   init_ir_raw_event_duration(++(*ev), need_pulse,
+  timings-clock);
+   count++;
+   }
+
+   init_ir_raw_event_duration(++(*ev), !need_pulse,
+  timings-clock);
+   count++;
+   i = 1;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(ir_raw_gen_manchester);
+
 int ir_raw_gen_pd(struct ir_raw_event **ev, unsigned int max,
  const struct ir_raw_timings_pd *timings,
  unsigned int n, unsigned int data)
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 3bf8c7b..4a2e2b8 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -173,6 +173,20 @@ static inline void ir_raw_gen_pulse_space(struct 
ir_raw_event **ev,
 }
 
 /**
+ * struct ir_raw_timings_manchester - manchester coding timings
+ * @pulse_space_start: 1 for starting with pulse (0 for starting with space)
+ * @clock: duration of each pulse/space in ns
+ */
+struct ir_raw_timings_manchester {
+   unsigned int pulse_space_start:1;
+   unsigned int clock;
+};
+
+int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
+ const struct ir_raw_timings_manchester *timings,
+ unsigned int n, unsigned int data);
+
+/**
  * struct ir_raw_timings_pd - pulse-distance modulation timings
  * @header_pulse:  duration of header pulse in ns (0 for none)
  * @header_space:  duration of header space in ns
-- 
1.8.3.2

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


[RFC PATCH 3/3] nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback

2014-02-08 Thread Antti Seppälä
Nuvoton-cir utilizes the encoding capabilities of currently active protocols
to convert scancodes from user space to pulse/space format understood by the
underlying hardware.

Samples are then written to the wakeup fifo along with other necessary
configuration to enable wake up functionality.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/nuvoton-cir.c | 121 +
 drivers/media/rc/nuvoton-cir.h |   1 +
 include/media/rc-core.h|   1 +
 3 files changed, 123 insertions(+)

diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index b41e52e..e4a4c5d 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -527,6 +527,126 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 
carrier)
return 0;
 }
 
+static int nvt_write_wakeup_codes(struct rc_dev *dev,
+ const u8 *wakeup_sample_buf, int count)
+{
+   int i = 0;
+   u8 reg, reg_learn_mode;
+   unsigned long flags;
+   struct nvt_dev *nvt = dev-priv;
+
+   nvt_dbg_wake(writing wakeup samples);
+
+   reg = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
+   reg_learn_mode = reg  ~CIR_WAKE_IRCON_MODE0;
+   reg_learn_mode |= CIR_WAKE_IRCON_MODE1;
+
+   /* Lock the learn area to prevent racing with wake-isr */
+   spin_lock_irqsave(nvt-nvt_lock, flags);
+
+   /* Enable fifo writes */
+   nvt_cir_wake_reg_write(nvt, reg_learn_mode, CIR_WAKE_IRCON);
+
+   /* Clear cir wake rx fifo */
+   nvt_clear_cir_wake_fifo(nvt);
+
+   if (count)
+   pr_info(Wake samples (%d) =, count);
+   else
+   pr_info(Wake sample fifo cleared);
+
+   /* Write wake samples to fifo */
+   for (i = 0; i  count; i++) {
+   pr_cont( %02x, wakeup_sample_buf[i]);
+   nvt_cir_wake_reg_write(nvt, wakeup_sample_buf[i],
+  CIR_WAKE_WR_FIFO_DATA);
+   }
+   pr_cont(\n);
+
+   /* Switch cir to wakeup mode and disable fifo writing */
+   nvt_cir_wake_reg_write(nvt, reg, CIR_WAKE_IRCON);
+
+   /* Set number of bytes needed for wake */
+   nvt_cir_wake_reg_write(nvt, count ? count :
+  CIR_WAKE_FIFO_CMP_BYTES,
+  CIR_WAKE_FIFO_CMP_DEEP);
+
+   spin_unlock_irqrestore(nvt-nvt_lock, flags);
+
+   return 0;
+}
+
+static int nvt_ir_raw_set_filter(struct rc_dev *dev, enum rc_filter_type type,
+struct rc_scancode_filter *sc_filter)
+{
+   u8 *reg_buf;
+   int i, ret, count = 0;
+   unsigned int val;
+   struct ir_raw_event *raw;
+
+   /* Other types are not valid for nuvoton */
+   if (type != RC_FILTER_WAKEUP)
+   return -EINVAL;
+
+   /* Require both mask and data to be set before actually committing */
+   if (!sc_filter-mask || !sc_filter-data)
+   return 0;
+
+   raw = kmalloc(WAKE_FIFO_LEN * sizeof(*raw), GFP_KERNEL);
+   if (!raw)
+   return -ENOMEM;
+
+   ret = ir_raw_encode_scancode(dev-enabled_protocols, sc_filter, raw,
+WAKE_FIFO_LEN);
+   if (ret  0)
+   goto out_raw;
+
+   if (ret  WAKE_FIFO_LEN) {
+   pr_info(Scancode size (%d) will not fit in wake fifo (%d),
+   ret, WAKE_FIFO_LEN);
+   ret = -EINVAL;
+   goto out_raw;
+   }
+
+   reg_buf = kmalloc(sizeof(*reg_buf) * WAKE_FIFO_LEN, GFP_KERNEL);
+   if (!reg_buf) {
+   ret = -ENOMEM;
+   goto out_raw;
+   }
+
+   /* Inspect the ir samples */
+   for (i = 0; i  ret; ++i) {
+   val = NS_TO_US((raw[i]).duration) / SAMPLE_PERIOD;
+
+   /* Split too large values into several smaller ones */
+   while (val  BUF_LEN_MASK) {
+   if (count  WAKE_FIFO_LEN) {
+   ret = -EINVAL;
+   goto out_reg;
+   }
+   reg_buf[count] = BUF_LEN_MASK;
+   val -= BUF_LEN_MASK;
+   if ((raw[i]).pulse)
+   reg_buf[count] |= BUF_PULSE_BIT;
+   count++;
+   }
+
+   if ((raw[i]).pulse)
+   val |= BUF_PULSE_BIT;
+   reg_buf[count] = val;
+   count++;
+   }
+
+   ret = nvt_write_wakeup_codes(dev, reg_buf, count);
+
+out_reg:
+   kfree(reg_buf);
+out_raw:
+   kfree(raw);
+
+   return ret;
+}
+
 /*
  * nvt_tx_ir
  *
@@ -1043,6 +1163,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct 
pnp_device_id *dev_id)
rdev-close = nvt_close;
rdev-tx_ir = nvt_tx_ir;
rdev-s_tx_carrier = nvt_set_tx_carrier;
+   rdev-s_filter = nvt_ir_raw_set_filter;
rdev-input_name = 

[RFC PATCH 0/3] rc: add RC5-SZ encoder and utilize encoders in nuvoton-cir

2014-02-08 Thread Antti Seppälä
This patchset is based and built on an earlier series posted by James Hogan
(rc: ir-raw: Add encode, implement NEC encode).

This set extends the series by adding a generic RC-5 encoder and adds support
for it to RC-5-SZ protocol.

In addition nuvoton-cir driver is modified to read wakeup filters from sysfs
and utilize encoding to convert the scancodes to format understood by the
underlying hardware.

Antti Seppälä (3):
  rc-core: Add Manchester encoder (phase encoder) support to rc-core
  ir-rc5-sz: Add ir encoding support
  nuvoton-cir: Add support for writing wakeup samples via sysfs filter
callback

 drivers/media/rc/ir-raw.c|  44 +
 drivers/media/rc/ir-rc5-sz-decoder.c |  35 ++
 drivers/media/rc/nuvoton-cir.c   | 121 +++
 drivers/media/rc/nuvoton-cir.h   |   1 +
 drivers/media/rc/rc-core-priv.h  |  14 
 include/media/rc-core.h  |   1 +
 6 files changed, 216 insertions(+)

-- 
1.8.3.2

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


[RFC PATCH 2/3] ir-rc5-sz: Add ir encoding support

2014-02-08 Thread Antti Seppälä
The encoding in rc5-sz first inserts a pulse and then simply utilizes the
generic Manchester encoder available in rc-core.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
---
 drivers/media/rc/ir-rc5-sz-decoder.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c 
b/drivers/media/rc/ir-rc5-sz-decoder.c
index 984e5b9..0d5e552 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -127,9 +127,44 @@ out:
return -EINVAL;
 }
 
+static struct ir_raw_timings_manchester ir_rc5_sz_timings = {
+   .pulse_space_start  = 0,
+   .clock  = RC5_UNIT,
+};
+
+/*
+ * ir_rc5_sz_encode() - Encode a scancode as a stream of raw events
+ *
+ * @protocols:  allowed protocols
+ * @scancode:   scancode filter describing scancode (helps distinguish between
+ *  protocol subtypes when scancode is ambiguous)
+ * @events: array of raw ir events to write into
+ * @max:maximum size of @events
+ *
+ * This function returns -EINVAL if the scancode filter is invalid or matches
+ * multiple scancodes. Otherwise the number of ir_raw_events generated is
+ * returned.
+ */
+static int ir_rc5_sz_encode(u64 protocols,
+   const struct rc_scancode_filter *scancode,
+   struct ir_raw_event *events, unsigned int max)
+{
+   int ret;
+   struct ir_raw_event *e = events;
+
+   /* RC5-SZ scancode is raw enough for manchester as it is */
+   ret = ir_raw_gen_manchester(e, max, ir_rc5_sz_timings, RC5_SZ_NBITS,
+   scancode-data);
+   if (ret  0)
+   return ret;
+
+   return e - events;
+}
+
 static struct ir_raw_handler rc5_sz_handler = {
.protocols  = RC_BIT_RC5_SZ,
.decode = ir_rc5_sz_decode,
+   .encode = ir_rc5_sz_encode,
 };
 
 static int __init ir_rc5_sz_decode_init(void)
-- 
1.8.3.2

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


Re: [PATCH v4.2 4/4] v4l: Document timestamp buffer flag behaviour

2014-02-08 Thread Hans Verkuil
On 02/07/2014 11:52 PM, Sakari Ailus wrote:
 Timestamp buffer flags are constant at the moment. Document them so that 1)
 they're always valid and 2) not changed by the drivers. This leaves room to
 extend the functionality later on if needed.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  Documentation/DocBook/media/v4l/io.xml |8 
  1 file changed, 8 insertions(+)
 
 diff --git a/Documentation/DocBook/media/v4l/io.xml 
 b/Documentation/DocBook/media/v4l/io.xml
 index 451626f..f523725 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -654,6 +654,14 @@ plane, are stored in struct 
 structnamev4l2_plane/structname instead.
  In that case, struct structnamev4l2_buffer/structname contains an array 
 of
  plane structures./para
  
 +paraBuffers that have been dequeued come with timestamps. These
 +timestamps can be taken from different clocks and at different part of
 +the frame, depending on the driver. Please see flags in the masks
 +constantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant and
 +constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant in xref
 +linkend=buffer-flags. These flags are guaranteed to be always valid
 +and will not be changed by the driver./para

That's a bit too strong. Different inputs or outputs may have different 
timestamp
sources. Also add a note that the SOE does not apply to outputs (there is no
exposure there after all). For EOF the formulation for outputs should be:
..last pixel of the frame has been transmitted.

For the COPY mode I think the SRC_MASK bits should be copied as well. That 
should
be stated in the documentation.

Regards,

Hans

 +
  table frame=none pgwide=1 id=v4l2-buffer
titlestruct structnamev4l2_buffer/structname/title
tgroup cols=4
 

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


Re: Where to find the em28xx log parser

2014-02-08 Thread Geert Stappers
On Sat, Feb 08, 2014 at 07:34:09AM +0100, mjs wrote:
 Hello,
 
 I'm trying to make a patch for a :zolid usb dvb-t receiver.
 Like to try the em28xx log parser to decode the usbsnoop output.
 According to:
 http://www.linuxtv.org/wiki/index.php/Bus_snooping/sniffing
 it has been out there at least once but so far no luck to find it.
 
 So, the program or a link where to find would help.


It is the v4l-utils git repository


git clone git://linuxtv.org/v4l-utils.git
cd v4l-utils


Then a

head -n 25 contrib/em28xx/parse_em28xx.pl


will reveal among other lines

#
# To use it, you may modprobe em28xx with reg_debug=1, and do:
# dmesg | ./parse_em28xx.pl
#


But that will only work
after you have set execute permissons the perl script.


Cheers
Geert Stappers

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


SOB

2014-02-08 Thread Geert Stappers
On Sat, Feb 08, 2014 at 11:48:08AM +0200, Antti Palosaari wrote:
 On 08.02.2014 11:37, Antti Palosaari wrote:
 From: Luis Alves lja...@gmail.com
 
 Signed-off-by: Antti Palosaari cr...@iki.fi

 Luis,
 Could you send your SOB?
 

What is a SOB on this mailinglist?


My visit to http://en.wikipedia.org/wiki/SOB was not conclusive.


Cheers
Geert Stappers
--
To unsubscribe from this list: send the line unsubscribe 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: SOB

2014-02-08 Thread Antti Palosaari

Moikka!

On 08.02.2014 15:58, Geert Stappers wrote:

On Sat, Feb 08, 2014 at 11:48:08AM +0200, Antti Palosaari wrote:

On 08.02.2014 11:37, Antti Palosaari wrote:

From: Luis Alves lja...@gmail.com

Signed-off-by: Antti Palosaari cr...@iki.fi



Luis,
Could you send your SOB?



What is a SOB on this mailinglist?


It is shorthand for signed-off-by tag
https://www.kernel.org/doc/Documentation/SubmittingPatches




My visit to http://en.wikipedia.org/wiki/SOB was not conclusive.


Cheers
Geert Stappers



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


Re: [PATCH] [media] stb0899: Fix DVB-S2 support for TechniSat SkyStar 2 HD CI USB ID 14f7:0002

2014-02-08 Thread Antti Palosaari

Moikka!

On 08.02.2014 15:28, David Jedelsky wrote:

Manu, Antti,

Thank you for explanation. Now I see that I patched wrong place. More
appropriate would be to concentrate on az6027 I2C code.
Maybe my device could be working with corrected I2C code.
And yes, I have to confirm that the current I2C interface code is very
strange. Especially that address checking, which really suggests that
there is something wrong.

I looked at the PCB and there isn't too much information written there
...just SkyStar USB 2 HD CI REV 2.0. Here are images (taken little bit
from the side to be IC labels visible)
http://djed.cz/skystar-usb-2-hd-ci-bottom.jpg
http://djed.cz/skystar-usb-2-hd-ci-top.jpg
and closeup of stb0899
http://djed.cz/skystar-usb-2-hd-ci-stb0899.jpg

Regarding the firmware (btw. just for curiosity you can see from the
images that the actual controller is CY7C68013A).
At some point I have extracted the firmware sent by windows driver from
the USB communication and it was the same as the Linux one. I can try to
look for some updates.


You likely already know, but lets say, CY7C68013A is general USB bridge 
having firmware which defines how it behaves. There is open DVB firmware 
for that chip somewhere on LinuxTV.org cvs. I hacked it once 
successfully for one device, relatively small changes were needed.


STB0899 is demodulator. And that small chip near antenna connector is 
tuner. Altera is fpga, running custom logic. It implements common 
interface. LC245A near Altera is likely TS (transport stream, picture is 
here) switch. Parallel TS used. It routes TS via CI or directly to 
CY7C68013A. Cypress datasheets are rather open, you could easily check 
which are I2C pins. If you has hardware sniffer, Bus Pirate, 
oscilloscope, etc. you could easily sniff I2C bus and look if it uses 
repeated START condition for register reads.


regards
Antti





Regards,
David



On Fri, Feb 7, 2014 at 10:46 PM, Manu Abraham abraham.m...@gmail.com
mailto:abraham.m...@gmail.com wrote:

On Sat, Feb 8, 2014 at 2:41 AM, Antti Palosaari cr...@iki.fi
mailto:cr...@iki.fi wrote:
  On 07.02.2014 22:54, Manu Abraham wrote:
 
  On Sat, Feb 8, 2014 at 1:19 AM, David Jedelsky
david.jedel...@gmail.com mailto:david.jedel...@gmail.com
  wrote:
 
  That changes I2C functionality from STOP + START to repeated
START.
  Current functionality looks also very weird, as there is 5
messages
  sent,
  all with STOP condition. I am not surprised if actually bug is
still in
  adapter... Somehow it should be first resolved how those
messages are
  send,
  with repeated START or STOP. And fix I2C client or adapter or
both.
 
  regards
  Antti
 
 
 
 
  Manu, Antti,
 
  Thank you for your response. I agree that the code is somewhat
peculiar
  and
  it could be worthy to review it using documentation before I
leave it as
  bug
  in my hw. Unfortunately I don't own appropriate documentation.
If you can
  supply it I can look at it.
 
 
  I can assure you that the STB0899 driver works well for S2 with most
  USB bridges and PCI bridges, which brings me to the fact that
the issue
  does not exist with the STB0899 driver.
 
  Regarding the documentation, I don't have any wrt to the USB
bridge, but
  only for the demodulator, tuner. But my hands are tied on that
front, due
  to
  NDA's and agreements.
 
  Looking further in my hardware museum, I did find a
  Technisat Skystar USB2 HD CI REV 2.0
 
  The information on a white sticker on the PCB states:
  Model AD-SB301, Project ID: 6027
  DVB-S2, CI, USB Box (on-line update)
  H/W Ver: A1, PID/VID: 14F7 / 0002
 
  manufactured and sent to me by Azurewave.
 
  It has a broken ferrite cored inductor on it, which appears to
be on the
  power line to the demodulator/tuner.
 
  The PID/VID looks exactly the same as yours. If you have a
firmware bug,
  maybe it helps to update the firmware online ? (I guess the
windows driver
  uses some stock Cypress driver, from what I can imagine ?)
 
  I had similar problems as you state, when I worked with a prototype
  version
  of the Mantis PCI chipset where it had some issues regarding
repeated
  starts. I can't really remember the exact issue back then, but I do
  remember
  the issue being tuner related as well, since the write to the
tuner would
  reach
  the very first tuner register alone. The communications to the
tuner are
  through a repeater on the demodulator.
 
  This issue was addressed with an ECO Metal fix for the PCI
bridge, but
  that
  did eventually result in a newer chip though.
 
  The problem could likely be similar with your USB bridge. Maybe
it is a
  driver bug too .. I haven't 

[PATCH] omap_vout: Add DVI display type support

2014-02-08 Thread Laurent Pinchart
Since the introduction of the new OMAP DSS DVI connector driver in
commit 348077b154357eec595068a3336ef6beb870e6f3 (OMAPDSS: Add new DVI
Connector driver), DVI outputs report a new display type of
OMAP_DISPLAY_TYPE_DVI instead of OMAP_DISPLAY_TYPE_DPI. Handle the new
type in the IRQ handler.

Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/platform/omap/omap_vout.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index dfd0a21..9a726ea 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -601,6 +601,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
switch (cur_display-type) {
case OMAP_DISPLAY_TYPE_DSI:
case OMAP_DISPLAY_TYPE_DPI:
+   case OMAP_DISPLAY_TYPE_DVI:
if (mgr_id == OMAP_DSS_CHANNEL_LCD)
irq = DISPC_IRQ_VSYNC;
else if (mgr_id == OMAP_DSS_CHANNEL_LCD2)
-- 
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: video from USB DVB-T get damaged after some time

2014-02-08 Thread kapetr

Hello,

unfortunately I do not understand development, patching, compiling things.
I have try it but I need more help.

I have done:

git clone --depth=1 git://linuxtv.org/media_build.git
cd media_build
./build

it downloads and builds all. At begin of compiling I had stop it.
Then I did manual change of
./media_build/linux/drivers/media/usb/dvb-usb-v2/af9035.c

--- old part:
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
af9035_props, TerraTec Cinergy T Stick (rev. 2), 
NULL) },

/* IT9135 devices */
#if 0
{ DVB_USB_DEVICE(0x048d, 0x9135,
af9035_props, IT9135 reference design, NULL) },
{ DVB_USB_DEVICE(0x048d, 0x9006,
af9035_props, IT9135 reference design, NULL) },
#endif
/* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 
2), NULL) },

- new:
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
af9035_props, TerraTec Cinergy T Stick (rev. 2), NULL) },
/* IT9135 devices */

{ DVB_USB_DEVICE(0x048d, 0x9135,
af9035_props, IT9135 reference design, NULL) },

/* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 2), 
NULL) },



But now I do not know how to restart build process.

I have try:

cd /tmp/media_build/linux
make

It had compiled *. and *.ko files.

Then I have copy the new
dvb-usb-af9035.ko to kernel modules dir

And the result is:

# modprobe -r dvb_usb_it913x
# modprobe -v dvb-usb-af9035
insmod 
/lib/modules/3.2.0-58-generic/kernel/drivers/media/dvb-core/dvb-core.ko
insmod 
/lib/modules/3.2.0-58-generic/kernel/drivers/media/usb/dvb-usb-v2/dvb_usb_v2.ko 

insmod 
/lib/modules/3.2.0-58-generic/kernel/drivers/media/usb/dvb-usb-v2/dvb-usb-af9035.ko 

FATAL: Error inserting dvb_usb_af9035 
(/lib/modules/3.2.0-58-generic/kernel/drivers/media/usb/dvb-usb-v2/dvb-usb-af9035.ko): 
Invalid argument



--- syslog:
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833525] WARNING: You are using 
an experimental version of the media stack.
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833526] 	As the driver is 
backported to an older kernel, it doesn't offer
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833527] 	enough quality for its 
usage in production.

Feb  8 15:31:13 zly-hugo kernel: [ 5910.833528] Use it with care.
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833528] Latest git patches 
(needed if you report a bug to linux-media@vger.kernel.org):
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833529] 
587d1b06e07b4a079453c74ba9edf17d21931049 [media] rc-core: reuse device 
numbers
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833530] 
c3aed262186841bf01feb9603885671ea567ebd9 [media] em28xx-cards: properly 
initialize the device bitmap
Feb  8 15:31:13 zly-hugo kernel: [ 5910.833531] 
f52e9828d5f3001f11981d852dc9cbd3c8c5debe [media] Staging: media: Fix 
line length exceeding 80 characters in as102_drv.c
Feb  8 15:31:13 zly-hugo kernel: [ 5910.843728] dvb_usb_af9035: 
disagrees about version of symbol rc_keydown
Feb  8 15:31:13 zly-hugo kernel: [ 5910.843732] dvb_usb_af9035: Unknown 
symbol rc_keydown (err -22)
Feb  8 15:31:13 zly-hugo kernel: [ 5910.843738] dvb_usb_af9035: 
disagrees about version of symbol dvb_usbv2_generic_rw_locked
Feb  8 15:31:13 zly-hugo kernel: [ 5910.843740] dvb_usb_af9035: Unknown 
symbol dvb_usbv2_generic_rw_locked (err -22)



What do I wrong ?
How to do it correct ?

- probably I should add patch file to
./media_build/backports

But I need the correct patch file with correct name of it ?
And what about modification of ./media_build/backports/backports.txt ?

Sorry that all is over my knowledge.

And it is not possible somehow to add new_id without patching ?
echo 048d 9135  /sys/bus/usb/drivers/dvb_usb_af9035/new_id
bash: /sys/bus/usb/drivers/dvb_usb_af9035/new_id: Adresář nebo soubor 
neexistuje


the file do not exist.

Why ? At my wifi dongle it has work.

Thanks for helping.

--kapetr






Dne 8.2.2014 00:17, Antti Palosaari napsal(a):

Moikka

On 07.02.2014 18:47, kap...@mizera.cz wrote:

Hello,

I have this:
http://linuxtv.org/wiki/index.php/ITE_IT9135

with dvb-usb-it9135-02.fw (chip version 2) on U12.04 64b with compiled
newest drivers from:
http://linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers.




The problem is - after some time I receive a program (e.g. in Kaffeine,
me-tv, vlc, ...) the program get more and more damaged and finely get
lost at all.

I happens quicker (+- after 10-20 minutes) on channels with lower
signal. On stronger signals it happens after +- 30-100 minutes.

The USB stick stays cool.

I can switch to another frequency and back and it 

Re: video from USB DVB-T get damaged after some time

2014-02-08 Thread Malcolm Priestley
On Sat, 2014-02-08 at 15:43 +0100, kap...@mizera.cz wrote:
 Hello,
 
 unfortunately I do not understand development, patching, compiling things.
 I have try it but I need more help.
 
 I have done:
 
 git clone --depth=1 git://linuxtv.org/media_build.git
 cd media_build
 ./build
 
 it downloads and builds all. At begin of compiling I had stop it.
 Then I did manual change of
 ./media_build/linux/drivers/media/usb/dvb-usb-v2/af9035.c
 
 --- old part:
  { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
  af9035_props, TerraTec Cinergy T Stick (rev. 2), 
 NULL) },
  /* IT9135 devices */
 #if 0
  { DVB_USB_DEVICE(0x048d, 0x9135,
  af9035_props, IT9135 reference design, NULL) },
  { DVB_USB_DEVICE(0x048d, 0x9006,
  af9035_props, IT9135 reference design, NULL) },
 #endif
  /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
  { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
  af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 
 2), NULL) },
 - new:
   { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
   af9035_props, TerraTec Cinergy T Stick (rev. 2), NULL) },
   /* IT9135 devices */
 
   { DVB_USB_DEVICE(0x048d, 0x9135,
   af9035_props, IT9135 reference design, NULL) },
 
   /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
   { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
   af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 2), 
 NULL) },
 
 
 
 But now I do not know how to restart build process.

Just 

make

from media_build directory.

 
 I have try:
 
 cd /tmp/media_build/linux
 make
 
 It had compiled *. and *.ko files.
 
you need to run
/sbin/depmod -a

and reboot

it best to just run with su/sudo 

make install

I have just tested all the single ids.

I am about to send a patch to add all the single tuner ids
to af9035 from it913x.

I haven't found any problems.


Regards


Malcolm

--
To unsubscribe from this list: send the line unsubscribe 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] af9035: Move it913x single devices to af9035

2014-02-08 Thread Malcolm Priestley
The generic v1 and v2 devices have been all tested.

IDs tested
USB_PID_ITETECH_IT9135 v1  v2
USB_PID_ITETECH_IT9135_9005 v1
USB_PID_ITETECH_IT9135_9006 v2

Current Issues
There is no signal  on
USB_PID_ITETECH_IT9135 v2 

No SNR reported all devices.

All single devices tune and scan fine.

All remotes tested okay.

Dual device failed to register second adapter
USB_PID_KWORLD_UB499_2T_T09
It is not clear what the problem is at the moment.

So only single IDs are transferred in this patch.

Signed-off-by: Malcolm Priestley tvbox...@gmail.com
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 22 --
 drivers/media/usb/dvb-usb-v2/it913x.c | 24 
 2 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 8ede8ea..3825c2f 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1528,12 +1528,22 @@ static const struct usb_device_id af9035_id_table[] = {
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
af9035_props, TerraTec Cinergy T Stick (rev. 2), NULL) },
/* IT9135 devices */
-#if 0
-   { DVB_USB_DEVICE(0x048d, 0x9135,
-   af9035_props, IT9135 reference design, NULL) },
-   { DVB_USB_DEVICE(0x048d, 0x9006,
-   af9035_props, IT9135 reference design, NULL) },
-#endif
+   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135,
+   af9035_props, ITE 9135 Generic, RC_MAP_IT913X_V1) },
+   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9005,
+   af9035_props, ITE 9135(9005) Generic, RC_MAP_IT913X_V2) },
+   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006,
+   af9035_props, ITE 9135(9006) Generic, RC_MAP_IT913X_V1) },
+   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_1835,
+   af9035_props, Avermedia A835B(1835), RC_MAP_IT913X_V2) },
+   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_2835,
+   af9035_props, Avermedia A835B(2835), RC_MAP_IT913X_V2) },
+   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_3835,
+   af9035_props, Avermedia A835B(3835), RC_MAP_IT913X_V2) },
+   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835,
+   af9035_props, Avermedia A835B(4835), RC_MAP_IT913X_V2) },
+   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335,
+   af9035_props, Avermedia H335, RC_MAP_IT913X_V2) },
/* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 2), 
NULL) },
diff --git a/drivers/media/usb/dvb-usb-v2/it913x.c 
b/drivers/media/usb/dvb-usb-v2/it913x.c
index fe95a58..78bf8fd 100644
--- a/drivers/media/usb/dvb-usb-v2/it913x.c
+++ b/drivers/media/usb/dvb-usb-v2/it913x.c
@@ -772,36 +772,12 @@ static const struct usb_device_id it913x_id_table[] = {
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09,
it913x_properties, Kworld UB499-2T T09(IT9137),
RC_MAP_IT913X_V1) },
-   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135,
-   it913x_properties, ITE 9135 Generic,
-   RC_MAP_IT913X_V1) },
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22_IT9137,
it913x_properties, Sveon STV22 Dual DVB-T HDTV(IT9137),
RC_MAP_IT913X_V1) },
-   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9005,
-   it913x_properties, ITE 9135(9005) Generic,
-   RC_MAP_IT913X_V2) },
-   { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006,
-   it913x_properties, ITE 9135(9006) Generic,
-   RC_MAP_IT913X_V1) },
-   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_1835,
-   it913x_properties, Avermedia A835B(1835),
-   RC_MAP_IT913X_V2) },
-   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_2835,
-   it913x_properties, Avermedia A835B(2835),
-   RC_MAP_IT913X_V2) },
-   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_3835,
-   it913x_properties, Avermedia A835B(3835),
-   RC_MAP_IT913X_V2) },
-   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835,
-   it913x_properties, Avermedia A835B(4835),
-   RC_MAP_IT913X_V2) },
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2,
it913x_properties, Digital Dual TV Receiver CTVDIGDUAL_V2,
RC_MAP_IT913X_V1) },
-   { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335,
-   it913x_properties, Avermedia H335,
-   RC_MAP_IT913X_V2) 

GSPCA ov534 payload error

2014-02-08 Thread Mark Pupilli
Hi,

I have successfully been using the PS3 eye camera on a beagleboard-xm
with kernel 2.6.32. I have upgraded to kernel 3.13.1 and can no longer
stream from the camera. I am using unicap to access the camera which
never returns any frames.

I enabled debugging for the gspca_main module and saw that it is
repeatedly getting payload errors:

root@(none): $ dmesg | grep -A 50 -B10 stream on
[  801.179748] ov534 2-2.3:1.0: SET 01  00f2 0cov534 2-2.3:1.0:
SET 01  00f3 d0
[  801.180847] ov534 2-2.3:1.0: SET 01  00f5 37ov534 2-2.3:1.0:
GET 01  00f6 00
[  801.199005] ov534 2-2.3:1.0: SET 01  00f2 0cov534 2-2.3:1.0:
SET 01  00f5 33
[  801.218994] ov534 2-2.3:1.0: GET 01  00f6 00ov534 2-2.3:1.0:
SET 01  00f5 f9
[  801.238861] ov534 2-2.3:1.0: GET 01  00f6 00ov534 2-2.3:1.0:
GET 01  00f4 d0
[  801.239349] ov534 2-2.3:1.0: sccb write: 0c d0ov534 2-2.3:1.0: SET
01  00f2 0c
[  801.240081] ov534 2-2.3:1.0: SET 01  00f3 d0ov534 2-2.3:1.0:
SET 01  00f5 37
[  801.258850] ov534 2-2.3:1.0: GET 01  00f6 00ov534 2-2.3:1.0:
sccb write: 2b 00
[  801.258972] ov534 2-2.3:1.0: SET 01  00f2 2bov534 2-2.3:1.0:
SET 01  00f3 00
[  801.260040] ov534 2-2.3:1.0: SET 01  00f5 37ov534 2-2.3:1.0:
GET 01  00f6 00
[  801.278930] ov534 2-2.3:1.0: stream on OK YUYV 640x480ov534
2-2.3:1.0: bulk irq
[  801.284210] ov534 2-2.3:1.0: packet l:12ov534 2-2.3:1.0: payload error
[  801.285919] ov534 2-2.3:1.0: bulk irqov534 2-2.3:1.0: packet l:8768
[  801.286041] ov534 2-2.3:1.0: add t:1 l:2036ov534 2-2.3:1.0: add t:2 l:2036
[  801.286468] ov534 2-2.3:1.0: add t:2 l:2036ov534 2-2.3:1.0: add t:2 l:2036
[  801.286834] ov534 2-2.3:1.0: add t:2 l:564ov534 2-2.3:1.0: bulk irq
[  801.287139] ov534 2-2.3:1.0: packet l:12ov534 2-2.3:1.0: payload error
...

Is this likely to be a problem with the gspca ov534 driver or with the
USB subsystem?

thanks,
Mark
--
To unsubscribe from this list: send the line unsubscribe 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.2 4/4] v4l: Document timestamp buffer flag behaviour

2014-02-08 Thread Sakari Ailus
Hi Hans,

Thanks for the comments.

Hans Verkuil wrote:
 On 02/07/2014 11:52 PM, Sakari Ailus wrote:
 Timestamp buffer flags are constant at the moment. Document them so that 1)
 they're always valid and 2) not changed by the drivers. This leaves room to
 extend the functionality later on if needed.

 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  Documentation/DocBook/media/v4l/io.xml |8 
  1 file changed, 8 insertions(+)

 diff --git a/Documentation/DocBook/media/v4l/io.xml 
 b/Documentation/DocBook/media/v4l/io.xml
 index 451626f..f523725 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -654,6 +654,14 @@ plane, are stored in struct 
 structnamev4l2_plane/structname instead.
  In that case, struct structnamev4l2_buffer/structname contains an array 
 of
  plane structures./para
  
 +paraBuffers that have been dequeued come with timestamps. These
 +timestamps can be taken from different clocks and at different part of
 +the frame, depending on the driver. Please see flags in the masks
 +constantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant and
 +constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant in xref
 +linkend=buffer-flags. These flags are guaranteed to be always valid
 +and will not be changed by the driver./para
 
 That's a bit too strong. Different inputs or outputs may have different 
 timestamp

Fixed.

 sources. Also add a note that the SOE does not apply to outputs (there is no

The flags are already documented separately, but I can add that to make
it explicit.

 exposure there after all). For EOF the formulation for outputs should be:
 ..last pixel of the frame has been transmitted.

Added.

 For the COPY mode I think the SRC_MASK bits should be copied as well. That 
 should
 be stated in the documentation.

Good point. I'll make that a separate patch as it changes a number of
drivers. Perhaps this could be a good occasion to clean up some timecode
field usage from those drivers, too.

-- 
Kind regards,

Sakari Ailus
sakari.ai...@iki.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: video from USB DVB-T get damaged after some time

2014-02-08 Thread kapetr

Hello,

I have compile it (I hope) the more right way now :-)

The patch saved as aaa.patch in media_build/backports
and added lines to  media_build/backports/backports.txt:

[3.2.0]
add aaa.patch


Now dmesg looks like:
-
[   17.643287] usb 1-1.3: dvb_usb_af9035: prechip_version=83 
chip_version=02 chip_type=9135
[   17.643661] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in cold 
state
[   17.652169] usb 1-1.3: dvb_usb_v2: downloading firmware from file 
'dvb-usb-it9135-02.fw'

[   17.746382] usb 1-1.3: dvb_usb_af9035: firmware version=3.39.1.0
[   17.746389] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in warm 
state
[   17.747413] usb 1-1.3: dvb_usb_v2: will pass the complete MPEG2 
transport stream to the software demuxer

[   17.747429] DVB: registering new adapter (ITE 9135 Generic)
[   17.805233] i2c i2c-16: af9033: firmware version: LINK=0.0.0.0 
OFDM=3.9.1.0
[   17.805238] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Afatech 
AF9033 (DVB-T))...
[   17.821832] i2c i2c-16: tuner_it913x: ITE Tech IT913X successfully 
attached

[   17.858231] Registered IR keymap rc-it913x-v1
[   17.858291] input: ITE 9135 Generic as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0/input5
[   17.858395] rc0: ITE 9135 Generic as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0
[   17.858398] usb 1-1.3: dvb_usb_v2: schedule remote query interval to 
500 msecs
[   17.858401] usb 1-1.3: dvb_usb_v2: 'ITE 9135 Generic' successfully 
initialized and connected

[   17.858415] usbcore: registered new interface driver dvb_usb_af9035
--

First I have thing the problem is gone: It has run OK over 20 minutes 
(before it goes down mostly in 10 min on CH59).


But - unfortunately after cca 25 min it has go down again :-(

status 1f | signal  | snr 0122 | ber  | unc 014f | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 830e | unc 014f | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 0001061c | unc 014f | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber  | unc 014f | 
FE_HAS_LOCK


...

status 1f | signal  | snr 0122 | ber 003dedb0 | unc 0002fd94 | 
FE_HAS_LOCK

status 07 | signal  | snr 0122 | ber 004c8030 | unc 0002fffd |
status 1f | signal  | snr 0118 | ber 006d50fd | unc 0003026d | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 006cfc4e | unc 00030569 | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 009d1eda | unc 00030832 | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 008924b1 | unc 00030a5e | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 00712074 | unc 00030d27 | 
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 008d4d85 | unc 00030f55 | 
FE_HAS_LOCK

-


So - maybe is it little better, but the problem persist.
Any chance to solve it in dvb driver ?


I have tested (with the old driver) - that it helps to CTRL+C the:
tzap -r -c /etc/channels.conf Prima ZOOM

And then run it again. (It was not necessary to switch to another freq. 
and back, as I wrote before).

Unfortunately it damages for  a while the recording (file.ts).
Is there another way how to re-tune (re-zap) without break 
recording/viewing ?

I could then re-tune e.g. every 5 minutes and it could solve the problem.
Could not that be done in driver itself ?

Thanks.

--kapetr




Dne 8.2.2014 16:08, Malcolm Priestley napsal(a):

On Sat, 2014-02-08 at 15:43 +0100, kap...@mizera.cz wrote:

Hello,

unfortunately I do not understand development, patching, compiling things.
I have try it but I need more help.

I have done:

git clone --depth=1 git://linuxtv.org/media_build.git
cd media_build
./build

it downloads and builds all. At begin of compiling I had stop it.
Then I did manual change of
./media_build/linux/drivers/media/usb/dvb-usb-v2/af9035.c

--- old part:
  { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
  af9035_props, TerraTec Cinergy T Stick (rev. 2),
NULL) },
  /* IT9135 devices */
#if 0
  { DVB_USB_DEVICE(0x048d, 0x9135,
  af9035_props, IT9135 reference design, NULL) },
  { DVB_USB_DEVICE(0x048d, 0x9006,
  af9035_props, IT9135 reference design, NULL) },
#endif
  /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
  { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
  af9035_props, TerraTec Cinergy T Stick Dual RC (rev.
2), NULL) },
- new:
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
af9035_props, TerraTec Cinergy T Stick (rev. 2), NULL) },
/* IT9135 devices */

{ DVB_USB_DEVICE(0x048d, 0x9135,
af9035_props, IT9135 reference design, NULL) },

/* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
af9035_props, TerraTec Cinergy T Stick Dual RC (rev. 2), 
NULL) },

[PATCH] saa7134: Add support for Snazio TvPVR PRO

2014-02-08 Thread GEORGE

From 6eb8ed397f724499b4439426bec98ab7e1cd588e Mon Sep 17 00:00:00 2001
From: POJAR GEORGE geoubu...@gmail.com
Date: Sat, 8 Feb 2014 20:46:35 +0200
Subject: [PATCH] saa7134: Add support for Snazio TvPVR PRO

Signed-off-by: POJAR GEORGE geoubu...@gmail.com
---
 Documentation/video4linux/CARDLIST.saa7134 |   1 +
 drivers/media/pci/saa7134/saa7134-cards.c  |  50 +++
 drivers/media/pci/saa7134/saa7134-input.c  |  64 ++
 drivers/media/pci/saa7134/saa7134.h|   1 +
 drivers/media/rc/keymaps/Makefile  |   1 +
 drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c | 111 
+

 include/media/rc-map.h |   1 +
 7 files changed, 229 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-snazio-tvpvr-pro.c

diff --git a/Documentation/video4linux/CARDLIST.saa7134 
b/Documentation/video4linux/CARDLIST.saa7134

index 8df17d0..32e4353 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -191,3 +191,4 @@
 190 - Asus My Cinema PS3-100   [1043:48cd]
 191 - Hawell HW-9004V1
 192 - AverMedia AverTV Satellite Hybrid+FM A706 [1461:2055]
+193 - SnaZio TvPVR PRO [0x1779:0x13cf,0x1779:0x13d0,0x1779:0x13d1]
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c 
b/drivers/media/pci/saa7134/saa7134-cards.c

index d45e7f6..795f0a9 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -5827,6 +5827,37 @@ struct saa7134_board saa7134_boards[] = {
 .gpio = 0x800,
 },
 },
+[SAA7134_BOARD_SNAZIO_TVPVR_PRO] = {
+.name   = SnaZio TvPVR PRO,
+.audio_clock= 0x00187de7,
+.tuner_type = TUNER_PHILIPS_TDA8290,
+.radio_type = UNSET,
+.tuner_addr = ADDR_UNSET,
+.radio_addr = ADDR_UNSET,
+.gpiomask   = 1  21,
+.inputs = {{
+.name = name_tv,
+.vmux = 1,
+.amux = TV,
+.gpio = 0x000,
+.tv   = 1,
+}, {
+.name = name_comp1, /* Composite input */
+.vmux = 3,
+.amux = LINE2,
+.gpio = 0x000,
+}, {
+.name = name_svideo,/* S-Video input */
+.vmux = 8,
+.amux = LINE2,
+.gpio = 0x000,
+} },
+.radio = {
+.name = name_radio,
+.amux = TV,
+.gpio = 0x020,
+},
+},

 };

@@ -7080,6 +7111,24 @@ struct pci_device_id saa7134_pci_tbl[] = {
 .subdevice= 0x2055, /* AverTV Satellite Hybrid+FM A706 */
 .driver_data  = SAA7134_BOARD_AVERMEDIA_A706,
 }, {
+.vendor   = PCI_VENDOR_ID_PHILIPS,
+.device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+.subvendor= 0x1779,
+.subdevice= 0x13cf,
+.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,
+}, {
+.vendor   = PCI_VENDOR_ID_PHILIPS,
+.device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+.subvendor= 0x1779,
+.subdevice= 0x13d0,
+.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,
+}, {
+.vendor   = PCI_VENDOR_ID_PHILIPS,
+.device   = PCI_DEVICE_ID_PHILIPS_SAA7133,
+.subvendor= 0x1779,
+.subdevice= 0x13d1,
+.driver_data  = SAA7134_BOARD_SNAZIO_TVPVR_PRO,
+}, {
 /* --- boards without eeprom + subsystem ID --- */
 .vendor   = PCI_VENDOR_ID_PHILIPS,
 .device   = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -7608,6 +7657,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
 case SAA7134_BOARD_BEHOLD_H7:
 case SAA7134_BOARD_BEHOLD_A7:
 case SAA7134_BOARD_KWORLD_PC150U:
+case SAA7134_BOARD_SNAZIO_TVPVR_PRO:
 dev-has_remote = SAA7134_REMOTE_I2C;
 break;
 case SAA7134_BOARD_AVERMEDIA_A169_B:
diff --git a/drivers/media/pci/saa7134/saa7134-input.c 
b/drivers/media/pci/saa7134/saa7134-input.c

index 6f43126..ade29f6 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -416,6 +416,54 @@ static int get_key_pinnacle_color(struct IR_i2c 
*ir, u32 *ir_key, u32 *ir_raw)

 return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
 }

+/* copied and modified from get_key_msi_tvanywhere_plus() */
+static int get_key_snazio_tvpvr_pro(struct IR_i2c *ir, u32 *ir_key,
+   u32 *ir_raw)
+{
+unsigned char b;
+int gpio;
+
+/* dev is needed to access GPIO. Used by the saa_readl macro. */
+struct saa7134_dev *dev = ir-c-adapter-algo_data;
+if (dev == NULL) {
+i2cdprintk(get_key_snazio_tvpvr_pro: 
+   ir-c-adapter-algo_data is NULL!\n);
+return -EIO;
+}
+
+/* rising SAA7134_GPIO_GPRESCAN reads the status */
+
+saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
+

Re: video from USB DVB-T get damaged after some time

2014-02-08 Thread Malcolm Priestley
On Sat, 2014-02-08 at 19:35 +0100, kap...@mizera.cz wrote:
 Hello,
 
 I have compile it (I hope) the more right way now :-)
 
 The patch saved as aaa.patch in media_build/backports
 and added lines to  media_build/backports/backports.txt:
 
 [3.2.0]
 add aaa.patch
 
 
 Now dmesg looks like:
 -
 [   17.643287] usb 1-1.3: dvb_usb_af9035: prechip_version=83 
 chip_version=02 chip_type=9135
 [   17.643661] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in cold 
 state
 [   17.652169] usb 1-1.3: dvb_usb_v2: downloading firmware from file 
 'dvb-usb-it9135-02.fw'
 [   17.746382] usb 1-1.3: dvb_usb_af9035: firmware version=3.39.1.0
 [   17.746389] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in warm 
 state
 [   17.747413] usb 1-1.3: dvb_usb_v2: will pass the complete MPEG2 
 transport stream to the software demuxer
 [   17.747429] DVB: registering new adapter (ITE 9135 Generic)
 [   17.805233] i2c i2c-16: af9033: firmware version: LINK=0.0.0.0 
 OFDM=3.9.1.0
 [   17.805238] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Afatech 
 AF9033 (DVB-T))...
 [   17.821832] i2c i2c-16: tuner_it913x: ITE Tech IT913X successfully 
 attached
 [   17.858231] Registered IR keymap rc-it913x-v1
 [   17.858291] input: ITE 9135 Generic as 
 /devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0/input5
 [   17.858395] rc0: ITE 9135 Generic as 
 /devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0
 [   17.858398] usb 1-1.3: dvb_usb_v2: schedule remote query interval to 
 500 msecs
 [   17.858401] usb 1-1.3: dvb_usb_v2: 'ITE 9135 Generic' successfully 
 initialized and connected
 [   17.858415] usbcore: registered new interface driver dvb_usb_af9035
 --
 
 First I have thing the problem is gone: It has run OK over 20 minutes 
 (before it goes down mostly in 10 min on CH59).
 
 But - unfortunately after cca 25 min it has go down again :-(
 
 status 1f | signal  | snr 0122 | ber  | unc 014f | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 830e | unc 014f | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 0001061c | unc 014f | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber  | unc 014f | 
 FE_HAS_LOCK
 
 ...
 
 status 1f | signal  | snr 0122 | ber 003dedb0 | unc 0002fd94 | 
 FE_HAS_LOCK
 status 07 | signal  | snr 0122 | ber 004c8030 | unc 0002fffd |
 status 1f | signal  | snr 0118 | ber 006d50fd | unc 0003026d | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 006cfc4e | unc 00030569 | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 009d1eda | unc 00030832 | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 008924b1 | unc 00030a5e | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 00712074 | unc 00030d27 | 
 FE_HAS_LOCK
 status 1f | signal  | snr 0122 | ber 008d4d85 | unc 00030f55 | 
 FE_HAS_LOCK
That BER looks awful.

If the antenna is good, it looks like local interference.

Check the wifi adapter is not causing it.

If possible put the TV adapter on a short 0.5m/1m USB extension cable
away from the PC. Trouble is these devices do not have any shielding.

I have heard problems of memory leak in Ubuntu 64 running low on memory
check free memory after 30 mins. 

Regards


Malcolm

 -
 
 
 So - maybe is it little better, but the problem persist.
 Any chance to solve it in dvb driver ?
 
 
 I have tested (with the old driver) - that it helps to CTRL+C the:
 tzap -r -c /etc/channels.conf Prima ZOOM
 
 And then run it again. (It was not necessary to switch to another freq. 
 and back, as I wrote before).
 Unfortunately it damages for  a while the recording (file.ts).
 Is there another way how to re-tune (re-zap) without break 
 recording/viewing ?
 I could then re-tune e.g. every 5 minutes and it could solve the problem.
 Could not that be done in driver itself ?
 
 Thanks.
 
 --kapetr
 
 
 
 
 Dne 8.2.2014 16:08, Malcolm Priestley napsal(a):
  On Sat, 2014-02-08 at 15:43 +0100, kap...@mizera.cz wrote:
  Hello,
 
  unfortunately I do not understand development, patching, compiling things.
  I have try it but I need more help.
 
  I have done:
 
  git clone --depth=1 git://linuxtv.org/media_build.git
  cd media_build
  ./build
 
  it downloads and builds all. At begin of compiling I had stop it.
  Then I did manual change of
  ./media_build/linux/drivers/media/usb/dvb-usb-v2/af9035.c
 
  --- old part:
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
af9035_props, TerraTec Cinergy T Stick (rev. 2),
  NULL) },
/* IT9135 devices */
  #if 0
{ DVB_USB_DEVICE(0x048d, 0x9135,
af9035_props, IT9135 reference design, NULL) },
{ DVB_USB_DEVICE(0x048d, 0x9006,
af9035_props, IT9135 reference design, NULL) },
  #endif
/* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
{ DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
  

RE: [PATCH 3/8] rtl2832: Fix deadlock on i2c mux select function.

2014-02-08 Thread Luis Alves
From: Luis Alves lja...@gmail.com

Signed-off-by: Luis Alves lja...@gmail.com
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/dvb-frontends/rtl2832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c
b/drivers/media/dvb-frontends/rtl2832.c
index c0366a8..cfc5438 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -917,7 +917,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void
*mux_priv, u32 chan_id)
buf[0] = 0x00;
buf[1] = 0x01;
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
@@ -930,7 +930,7 @@ static int rtl2832_select(struct i2c_adapter *adap, void
*mux_priv, u32 chan_id)
else
buf[1] = 0x10; /* close */
 
-   ret = i2c_transfer(adap, msg, 1);
+   ret = __i2c_transfer(adap, msg, 1);
if (ret != 1)
goto err;
 
-- 
1.8.5.3


--
To unsubscribe from this list: send the line unsubscribe 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: video from USB DVB-T get damaged after some time

2014-02-08 Thread kapetr

Hello,

thanks - but in my Antenna is noway the problem - the signal is strong 
and HQ. All other tuners (STB, TVs, ...) are more then happy.


If it would not - the BERs would by HIGH all time.

No WiFi. 4GB RAM - most of them always free.


I thing the problem is - that the card loses tuned status (becomes 
detuned). That is why helps re-tune. That is why I ask about how to 
re-tune without breaking the stream.

Ideal would be if this could be done by driver.


--kapetr



Dne 8.2.2014 21:36, Malcolm Priestley napsal(a):

On Sat, 2014-02-08 at 19:35 +0100, kap...@mizera.cz wrote:

Hello,

I have compile it (I hope) the more right way now :-)

The patch saved as aaa.patch in media_build/backports
and added lines to  media_build/backports/backports.txt:

[3.2.0]
add aaa.patch


Now dmesg looks like:
-
[   17.643287] usb 1-1.3: dvb_usb_af9035: prechip_version=83
chip_version=02 chip_type=9135
[   17.643661] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in cold
state
[   17.652169] usb 1-1.3: dvb_usb_v2: downloading firmware from file
'dvb-usb-it9135-02.fw'
[   17.746382] usb 1-1.3: dvb_usb_af9035: firmware version=3.39.1.0
[   17.746389] usb 1-1.3: dvb_usb_v2: found a 'ITE 9135 Generic' in warm
state
[   17.747413] usb 1-1.3: dvb_usb_v2: will pass the complete MPEG2
transport stream to the software demuxer
[   17.747429] DVB: registering new adapter (ITE 9135 Generic)
[   17.805233] i2c i2c-16: af9033: firmware version: LINK=0.0.0.0
OFDM=3.9.1.0
[   17.805238] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Afatech
AF9033 (DVB-T))...
[   17.821832] i2c i2c-16: tuner_it913x: ITE Tech IT913X successfully
attached
[   17.858231] Registered IR keymap rc-it913x-v1
[   17.858291] input: ITE 9135 Generic as
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0/input5
[   17.858395] rc0: ITE 9135 Generic as
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0
[   17.858398] usb 1-1.3: dvb_usb_v2: schedule remote query interval to
500 msecs
[   17.858401] usb 1-1.3: dvb_usb_v2: 'ITE 9135 Generic' successfully
initialized and connected
[   17.858415] usbcore: registered new interface driver dvb_usb_af9035
--

First I have thing the problem is gone: It has run OK over 20 minutes
(before it goes down mostly in 10 min on CH59).

But - unfortunately after cca 25 min it has go down again :-(

status 1f | signal  | snr 0122 | ber  | unc 014f |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 830e | unc 014f |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 0001061c | unc 014f |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber  | unc 014f |
FE_HAS_LOCK

...

status 1f | signal  | snr 0122 | ber 003dedb0 | unc 0002fd94 |
FE_HAS_LOCK
status 07 | signal  | snr 0122 | ber 004c8030 | unc 0002fffd |
status 1f | signal  | snr 0118 | ber 006d50fd | unc 0003026d |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 006cfc4e | unc 00030569 |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 009d1eda | unc 00030832 |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 008924b1 | unc 00030a5e |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 00712074 | unc 00030d27 |
FE_HAS_LOCK
status 1f | signal  | snr 0122 | ber 008d4d85 | unc 00030f55 |
FE_HAS_LOCK

That BER looks awful.

If the antenna is good, it looks like local interference.

Check the wifi adapter is not causing it.

If possible put the TV adapter on a short 0.5m/1m USB extension cable
away from the PC. Trouble is these devices do not have any shielding.

I have heard problems of memory leak in Ubuntu 64 running low on memory
check free memory after 30 mins.

Regards


Malcolm


-


So - maybe is it little better, but the problem persist.
Any chance to solve it in dvb driver ?


I have tested (with the old driver) - that it helps to CTRL+C the:
tzap -r -c /etc/channels.conf Prima ZOOM

And then run it again. (It was not necessary to switch to another freq.
and back, as I wrote before).
Unfortunately it damages for  a while the recording (file.ts).
Is there another way how to re-tune (re-zap) without break
recording/viewing ?
I could then re-tune e.g. every 5 minutes and it could solve the problem.
Could not that be done in driver itself ?

Thanks.

--kapetr




Dne 8.2.2014 16:08, Malcolm Priestley napsal(a):

On Sat, 2014-02-08 at 15:43 +0100, kap...@mizera.cz wrote:

Hello,

unfortunately I do not understand development, patching, compiling things.
I have try it but I need more help.

I have done:

git clone --depth=1 git://linuxtv.org/media_build.git
cd media_build
./build

it downloads and builds all. At begin of compiling I had stop it.
Then I did manual change of
./media_build/linux/drivers/media/usb/dvb-usb-v2/af9035.c

--- old part:
   { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
   af9035_props, TerraTec Cinergy T Stick (rev. 2),
NULL) },
   /* IT9135 devices */
#if 0
   

Re: video from USB DVB-T get damaged after some time

2014-02-08 Thread Antti Palosaari

Moikka!
I am going to extract new firmware. I dumped init tables out from 
Windows driver version 12.07.06.1. Is there any newer?


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


cron job: media_tree daily build: WARNINGS

2014-02-08 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:   Sun Feb  9 04:00:23 CET 2014
git branch: test
git hash:   37e59f876bc710d67a30b660826a5e83e07101ce
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-6.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: WARNINGS
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-i686: OK
linux-3.14-rc1-i686: OK
linux-2.6.31.14-x86_64: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-x86_64: OK
linux-3.14-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.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: video from USB DVB-T get damaged after some time

2014-02-08 Thread Antti Palosaari

On 09.02.2014 02:42, Antti Palosaari wrote:

Moikka!
I am going to extract new firmware. I dumped init tables out from
Windows driver version 12.07.06.1. Is there any newer?

regards
Antti



I extracted firmwares from Windows driver 12.10.04.1. Didn't find newer 
driver...


http://blog.palosaari.fi/2014/02/linux-it9135-driver-firmwares.html

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 0/5] v4l2-ctl: add SDR device support

2014-02-08 Thread Antti Palosaari
That is here too:
http://git.linuxtv.org/anttip/v4l-utils.git/shortlog/refs/heads/sdr

I will pull request it soon.

regards
Antti

Antti Palosaari (4):
  synch videodev2.h headers with kernel SDR API
  v4l2-ctl: add tuner support for SDR tuners
  v4l2-ctl: add support for SDR FMT
  v4l2-ctl: implement list SDR buffers command

Mauro Carvalho Chehab (1):
  libdvbv5: better handle ATSC/Annex B

 contrib/freebsd/include/linux/videodev2.h |  16 +
 include/linux/videodev2.h |  16 +
 lib/libdvbv5/dvb-file.c   |  33 +-
 utils/v4l2-ctl/Makefile.am|   2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp|   1 +
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp   | 104 ++
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp |   6 ++
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp |  53 ---
 utils/v4l2-ctl/v4l2-ctl.cpp   |  23 +++
 utils/v4l2-ctl/v4l2-ctl.h |  13 
 10 files changed, 255 insertions(+), 12 deletions(-)
 create mode 100644 utils/v4l2-ctl/v4l2-ctl-sdr.cpp

-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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] v4l2-ctl: implement list SDR buffers command

2014-02-08 Thread Antti Palosaari
Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 6 ++
 utils/v4l2-ctl/v4l2-ctl.cpp   | 1 +
 utils/v4l2-ctl/v4l2-ctl.h | 1 +
 3 files changed, 8 insertions(+)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp 
b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 13ee8ec..925d73d 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -78,6 +78,8 @@ void streaming_usage(void)
list all sliced VBI buffers 
[VIDIOC_QUERYBUF]\n
 --list-buffers-sliced-vbi-out\n
list all sliced VBI output buffers 
[VIDIOC_QUERYBUF]\n
+--list-buffers-sdr\n
+   list all SDR RX buffers 
[VIDIOC_QUERYBUF]\n
   );
 }
 
@@ -986,4 +988,8 @@ void streaming_list(int fd)
if (options[OptListBuffersSlicedVbiOut]) {
list_buffers(fd, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
}
+
+   if (options[OptListBuffersSdr]) {
+   list_buffers(fd, V4L2_BUF_TYPE_SDR_CAPTURE);
+   }
 }
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 855613c..a602366 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -198,6 +198,7 @@ static struct option long_options[] = {
{list-buffers-sliced-vbi, no_argument, 0, OptListBuffersSlicedVbi},
{list-buffers-vbi-out, no_argument, 0, OptListBuffersVbiOut},
{list-buffers-sliced-vbi-out, no_argument, 0, 
OptListBuffersSlicedVbiOut},
+   {list-buffers-sdr, no_argument, 0, OptListBuffersSdr},
{stream-count, required_argument, 0, OptStreamCount},
{stream-skip, required_argument, 0, OptStreamSkip},
{stream-loop, no_argument, 0, OptStreamLoop},
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 108198d..1caac34 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -139,6 +139,7 @@ enum Option {
OptListBuffersSlicedVbi,
OptListBuffersVbiOut,
OptListBuffersSlicedVbiOut,
+   OptListBuffersSdr,
OptStreamCount,
OptStreamSkip,
OptStreamLoop,
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe 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] libdvbv5: better handle ATSC/Annex B

2014-02-08 Thread Antti Palosaari
From: Mauro Carvalho Chehab m.che...@samsung.com

As DVBv3 is confusing with regards to ATSC and ClearQAM (DVB-C
annex B), userpace apps also only differenciate between ATSC and
ClearQAM via modulation.

However, when using DVBv5, may be using the delivery system
in order to enforce one or the other.

In any case, the DVB API should clearly identify between ATSC
and ClearQAM.

So, make the API to better handle it, fixing the delivery
system if needed, when reading or write a file.

Signed-off-by: Mauro Carvalho Chehab m.che...@samsung.com
---
 lib/libdvbv5/dvb-file.c | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index 1c33a90..e0cef34 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -88,6 +88,32 @@ int retrieve_entry_prop(struct dvb_entry *entry,
return -1;
 }
 
+static void adjust_delsys(struct dvb_entry *entry)
+{
+   uint32_t delsys = SYS_UNDEFINED;
+
+   retrieve_entry_prop(entry, DTV_DELIVERY_SYSTEM, delsys);
+   switch (delsys) {
+   case SYS_ATSC:
+   case SYS_DVBC_ANNEX_B: {
+   uint32_t modulation = VSB_8;
+
+   retrieve_entry_prop(entry, DTV_MODULATION, modulation);
+   switch (modulation) {
+   case VSB_8:
+   case VSB_16:
+   delsys = SYS_ATSC;
+   break;
+   default:
+   delsys = SYS_DVBC_ANNEX_B;
+   break;
+   }
+   store_entry_prop(entry, DTV_DELIVERY_SYSTEM, delsys);
+   break;
+   }
+   } /* switch */
+}
+
 /*
  * Generic parse function for all formats each channel is contained into
  * just one line.
@@ -242,7 +268,7 @@ struct dvb_file *parse_format_oneline(const char *fname,
entry-props[entry-n_props].cmd = DTV_INVERSION;
entry-props[entry-n_props++].u.data = INVERSION_AUTO;
}
-
+   adjust_delsys(entry);
} while (1);
fclose(fd);
free(buf);
@@ -330,6 +356,7 @@ int write_format_oneline(const char *fname,
 delsys);
goto error;
}
+   adjust_delsys(entry);
if (parse_file-has_delsys_id) {
fprintf(fp, %s, formats[i].id);
first = 0;
@@ -596,6 +623,7 @@ struct dvb_file *read_dvb_file(const char *fname)
dvb_file-first_entry = calloc(sizeof(*entry), 
1);
entry = dvb_file-first_entry;
} else {
+   adjust_delsys(entry);
entry-next = calloc(sizeof(*entry), 1);
entry = entry-next;
}
@@ -644,6 +672,8 @@ struct dvb_file *read_dvb_file(const char *fname)
}
}
} while (1);
+   if (entry)
+   adjust_delsys(entry);
fclose(fd);
return dvb_file;
 
@@ -668,6 +698,7 @@ int write_dvb_file(const char *fname, struct dvb_file 
*dvb_file)
}
 
for (entry = dvb_file-first_entry; entry != NULL; entry = entry-next) 
{
+   adjust_delsys(entry);
if (entry-channel) {
fprintf(fp, [%s]\n, entry-channel);
if (entry-vchannel)
-- 
1.8.5.3

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


[PATCH 2/5] synch videodev2.h headers with kernel SDR API

2014-02-08 Thread Antti Palosaari
Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 contrib/freebsd/include/linux/videodev2.h | 16 
 include/linux/videodev2.h | 16 
 2 files changed, 32 insertions(+)

diff --git a/contrib/freebsd/include/linux/videodev2.h 
b/contrib/freebsd/include/linux/videodev2.h
index 5c75762..6d49f97 100644
--- a/contrib/freebsd/include/linux/videodev2.h
+++ b/contrib/freebsd/include/linux/videodev2.h
@@ -173,6 +173,7 @@ enum v4l2_buf_type {
 #endif
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
+   V4L2_BUF_TYPE_SDR_CAPTURE  = 11,
/* Deprecated, do not use */
V4L2_BUF_TYPE_PRIVATE  = 0x80,
 };
@@ -193,6 +194,8 @@ enum v4l2_tuner_type {
V4L2_TUNER_RADIO = 1,
V4L2_TUNER_ANALOG_TV = 2,
V4L2_TUNER_DIGITAL_TV= 3,
+   V4L2_TUNER_ADC   = 4,
+   V4L2_TUNER_RF= 5,
 };
 
 enum v4l2_memory {
@@ -298,6 +301,8 @@ struct v4l2_capability {
 #define V4L2_CAP_RADIO 0x0004  /* is a radio device */
 #define V4L2_CAP_MODULATOR 0x0008  /* has a modulator */
 
+#define V4L2_CAP_SDR_CAPTURE   0x0010  /* Is a SDR capture device 
*/
+
 #define V4L2_CAP_READWRITE  0x0100  /* read/write systemcalls 
*/
 #define V4L2_CAP_ASYNCIO0x0200  /* async I/O */
 #define V4L2_CAP_STREAMING  0x0400  /* streaming I/O ioctls */
@@ -1373,6 +1378,7 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS_CONTROLS0x0200
 #define V4L2_TUNER_CAP_FREQ_BANDS  0x0400
 #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800
+#define V4L2_TUNER_CAP_1HZ 0x1000
 
 /*  Flags for the 'rxsubchans' field */
 #define V4L2_TUNER_SUB_MONO0x0001
@@ -1726,6 +1732,15 @@ struct v4l2_pix_format_mplane {
 } __attribute__ ((packed));
 
 /**
+ * struct v4l2_format_sdr - SDR format definition
+ * @pixelformat:   little endian four character code (fourcc)
+ */
+struct v4l2_format_sdr {
+   uint32_tpixelformat;
+   uint8_t reserved[28];
+} __attribute__ ((packed));
+
+/**
  * struct v4l2_format - stream data format
  * @type:  enum v4l2_buf_type; type of the data stream
  * @pix:   definition of an image format
@@ -1743,6 +1758,7 @@ struct v4l2_format {
struct v4l2_window  win; /* 
V4L2_BUF_TYPE_VIDEO_OVERLAY */
struct v4l2_vbi_format  vbi; /* 
V4L2_BUF_TYPE_VBI_CAPTURE */
struct v4l2_sliced_vbi_format   sliced;  /* 
V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
+   struct v4l2_format_sdr  sdr; /* 
V4L2_BUF_TYPE_SDR_CAPTURE */
uint8_t raw_data[200];   /* user-defined */
} fmt;
 };
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 6ae7bbe..27fedfe 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -139,6 +139,7 @@ enum v4l2_buf_type {
 #endif
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
+   V4L2_BUF_TYPE_SDR_CAPTURE  = 11,
/* Deprecated, do not use */
V4L2_BUF_TYPE_PRIVATE  = 0x80,
 };
@@ -159,6 +160,8 @@ enum v4l2_tuner_type {
V4L2_TUNER_RADIO = 1,
V4L2_TUNER_ANALOG_TV = 2,
V4L2_TUNER_DIGITAL_TV= 3,
+   V4L2_TUNER_ADC   = 4,
+   V4L2_TUNER_RF= 5,
 };
 
 enum v4l2_memory {
@@ -264,6 +267,8 @@ struct v4l2_capability {
 #define V4L2_CAP_RADIO 0x0004  /* is a radio device */
 #define V4L2_CAP_MODULATOR 0x0008  /* has a modulator */
 
+#define V4L2_CAP_SDR_CAPTURE   0x0010  /* Is a SDR capture device 
*/
+
 #define V4L2_CAP_READWRITE  0x0100  /* read/write systemcalls 
*/
 #define V4L2_CAP_ASYNCIO0x0200  /* async I/O */
 #define V4L2_CAP_STREAMING  0x0400  /* streaming I/O ioctls */
@@ -1339,6 +1344,7 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS_CONTROLS0x0200
 #define V4L2_TUNER_CAP_FREQ_BANDS  0x0400
 #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800
+#define V4L2_TUNER_CAP_1HZ 0x1000
 
 /*  Flags for the 'rxsubchans' field */
 #define V4L2_TUNER_SUB_MONO0x0001
@@ -1692,6 +1698,15 @@ struct v4l2_pix_format_mplane {
 } __attribute__ ((packed));
 
 /**
+ * struct v4l2_format_sdr - SDR format definition
+ * @pixelformat:   little endian four character code (fourcc)
+ */
+struct v4l2_format_sdr {
+   __u32   pixelformat;
+   __u8reserved[28];
+} __attribute__ ((packed));
+
+/**
  * struct v4l2_format - stream data format
  * @type:  enum v4l2_buf_type; type of the data stream
  * @pix:   

[PATCH 4/5] v4l2-ctl: add support for SDR FMT

2014-02-08 Thread Antti Palosaari
Add support for FMT IOCTL operations used for SDR receivers.

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 utils/v4l2-ctl/Makefile.am |   2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp |   1 +
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp| 104 +
 utils/v4l2-ctl/v4l2-ctl.cpp|  22 
 utils/v4l2-ctl/v4l2-ctl.h  |  12 +
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 utils/v4l2-ctl/v4l2-ctl-sdr.cpp

diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am
index b5744e7..becaa15 100644
--- a/utils/v4l2-ctl/Makefile.am
+++ b/utils/v4l2-ctl/Makefile.am
@@ -8,5 +8,5 @@ ivtv_ctl_LDFLAGS = -lm
 v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp 
v4l2-ctl-tuner.cpp \
v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp 
v4l2-ctl-vidout.cpp \
v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp 
v4l2-ctl-misc.cpp \
-   v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp
+   v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp v4l2-ctl-sdr.cpp
 v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la 
../../lib/libv4lconvert/libv4lconvert.la
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp 
b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index fe570b0..37099cd 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -64,6 +64,7 @@ void common_usage(void)
 --help-io  input/output options\n
 --help-miscmiscellaneous options\n
 --help-overlay overlay format options\n
+--help-sdr SDR format options\n
 --help-selection   crop/selection options\n
 --help-stdsstandards and other video timings 
options\n
 --help-streaming   streaming options\n
diff --git a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp
new file mode 100644
index 000..9c9a6c4
--- /dev/null
+++ b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp
@@ -0,0 +1,104 @@
+#include unistd.h
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include inttypes.h
+#include getopt.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include ctype.h
+#include errno.h
+#include sys/ioctl.h
+#include sys/time.h
+#include dirent.h
+#include math.h
+#include config.h
+
+#include linux/videodev2.h
+#include libv4l2.h
+#include string
+
+#include v4l2-ctl.h
+
+static struct v4l2_format vfmt;/* set_format/get_format */
+
+void sdr_usage(void)
+{
+   printf(\nSDR Formats options:\n
+--list-formats-sdr display supported SDR formats 
[VIDIOC_ENUM_FMT]\n
+--get-fmt-sdr  query the SDR capture format 
[VIDIOC_G_FMT]\n
+--set-fmt-sdr=f  set the SDR capture format 
[VIDIOC_S_FMT]\n
+   parameter is either the format index as 
reported by\n
+   --list-formats-sdr, or the fourcc value as 
a string\n
+--try-fmt-sdr=f  try the SDR capture format 
[VIDIOC_TRY_FMT]\n
+   parameter is either the format index as 
reported by\n
+   --list-formats-sdr, or the fourcc value as 
a string\n
+  );
+}
+
+void sdr_cmd(int ch, char *optarg)
+{
+   switch (ch) {
+   case OptSetSdrFormat:
+   case OptTrySdrFormat:
+   if (strlen(optarg) == 0) {
+   sdr_usage();
+   exit(1);
+   } else if (strlen(optarg) == 4) {
+   vfmt.fmt.sdr.pixelformat = v4l2_fourcc(optarg[0],
+   optarg[1], optarg[2], optarg[3]);
+   } else {
+   vfmt.fmt.sdr.pixelformat = strtol(optarg, 0L, 0);
+   }
+   break;
+   }
+}
+
+void sdr_set(int fd)
+{
+   int ret;
+
+   if (options[OptSetSdrFormat] || options[OptTrySdrFormat]) {
+   struct v4l2_format in_vfmt;
+
+   in_vfmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
+   in_vfmt.fmt.sdr.pixelformat = vfmt.fmt.sdr.pixelformat;
+
+   if (in_vfmt.fmt.sdr.pixelformat  256) {
+   struct v4l2_fmtdesc fmt;
+
+   fmt.index = in_vfmt.fmt.sdr.pixelformat;
+   fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
+
+   if (doioctl(fd, VIDIOC_ENUM_FMT, fmt))
+   fmt.pixelformat = 0;
+
+   in_vfmt.fmt.sdr.pixelformat = fmt.pixelformat;
+   }
+
+   if (options[OptSetSdrFormat])
+   ret = doioctl(fd, VIDIOC_S_FMT, in_vfmt);
+   else
+   ret = doioctl(fd, VIDIOC_TRY_FMT, in_vfmt);
+   if (ret == 0  (verbose || options[OptTrySdrFormat]))
+   printfmt(in_vfmt);
+   }
+}
+
+void sdr_get(int fd)

[PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners

2014-02-08 Thread Antti Palosaari
Add initial SDR support for tuner related operations.

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 53 +++
 1 file changed, 43 insertions(+), 10 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp 
b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
index 16e1652..0fc2371 100644
--- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp
@@ -116,6 +116,8 @@ static std::string tcap2s(unsigned cap)
 
if (cap  V4L2_TUNER_CAP_LOW)
s += 62.5 Hz ;
+   else if (cap  V4L2_TUNER_CAP_1HZ)
+   s += 1 Hz ;
else
s += 62.5 kHz ;
if (cap  V4L2_TUNER_CAP_NORM)
@@ -264,12 +266,24 @@ void tuner_set(int fd)
if (capabilities  V4L2_CAP_MODULATOR) {
type = V4L2_TUNER_RADIO;
modulator.index = tuner_index;
-   if (doioctl(fd, VIDIOC_G_MODULATOR, modulator) == 0)
-   fac = (modulator.capability  V4L2_TUNER_CAP_LOW) ? 
16000 : 16;
+   if (doioctl(fd, VIDIOC_G_MODULATOR, modulator) == 0) {
+   if (modulator.capability  V4L2_TUNER_CAP_LOW)
+   fac = 16000;
+   else if (modulator.capability  V4L2_TUNER_CAP_1HZ)
+   fac = 100;
+   else
+   fac = 16;
+   }
} else if (capabilities  V4L2_CAP_TUNER) {
tuner.index = tuner_index;
if (doioctl(fd, VIDIOC_G_TUNER, tuner) == 0) {
-   fac = (tuner.capability  V4L2_TUNER_CAP_LOW) ? 16000 : 
16;
+   if (tuner.capability  V4L2_TUNER_CAP_LOW)
+   fac = 16000;
+   else if (tuner.capability  V4L2_TUNER_CAP_1HZ)
+   fac = 100;
+   else
+   fac = 16;
+
type = tuner.type;
}
}
@@ -310,6 +324,9 @@ void tuner_set(int fd)
if (band.capability  V4L2_TUNER_CAP_LOW)
printf(\tFrequency Range: %.3f MHz - %.3f 
MHz\n,
 band.rangelow / 16000.0, band.rangehigh / 
16000.0);
+   else if (band.capability  V4L2_TUNER_CAP_1HZ)
+   printf(\tFrequency Range: %.6f MHz - %.6f 
MHz\n,
+band.rangelow / 100.0, band.rangehigh 
/ 100.0);
else
printf(\tFrequency Range: %.3f MHz - %.3f 
MHz\n,
 band.rangelow / 16.0, band.rangehigh / 
16.0);
@@ -345,13 +362,24 @@ void tuner_get(int fd)
if (capabilities  V4L2_CAP_MODULATOR) {
vf.type = V4L2_TUNER_RADIO;
modulator.index = tuner_index;
-   if (doioctl(fd, VIDIOC_G_MODULATOR, modulator) == 0)
-   fac = (modulator.capability  
V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+   if (doioctl(fd, VIDIOC_G_MODULATOR, modulator) == 0) {
+   if (modulator.capability  V4L2_TUNER_CAP_LOW)
+   fac = 16000;
+   else if (modulator.capability  
V4L2_TUNER_CAP_1HZ)
+   fac = 100;
+   else
+   fac = 16;
+   }
} else {
vf.type = V4L2_TUNER_ANALOG_TV;
tuner.index = tuner_index;
if (doioctl(fd, VIDIOC_G_TUNER, tuner) == 0) {
-   fac = (tuner.capability  V4L2_TUNER_CAP_LOW) ? 
16000 : 16;
+   if (tuner.capability  V4L2_TUNER_CAP_LOW)
+   fac = 16000;
+   else if (tuner.capability  V4L2_TUNER_CAP_1HZ)
+   fac = 100;
+   else
+   fac = 16;
vf.type = tuner.type;
}
}
@@ -373,13 +401,18 @@ void tuner_get(int fd)
if (vt.capability  V4L2_TUNER_CAP_LOW)
printf(\tFrequency range  : %.3f MHz - 
%.3f MHz\n,
 vt.rangelow / 16000.0, vt.rangehigh / 
16000.0);
+   else if (vt.capability  V4L2_TUNER_CAP_1HZ)
+   printf(\tFrequency range  : %.6f MHz - 
%.6f MHz\n,
+vt.rangelow / 100.0, vt.rangehigh / 
100.0);
else