Re: [PATCH 1/2] mn88473: fix chip id check on probe

2016-12-01 Thread Benjamin Larsson

On 2016-12-01 01:29, Antti Palosaari wrote:

A register used to identify chip during probe was overwritten during
firmware download and due to that later probe's for warm chip were
failing. Detect chip from the another register, which is located on
different register bank 2.

Fixes: 7908fad99a6c ("[media] mn88473: finalize driver")
Cc: <sta...@vger.kernel.org> # v4.8+
Signed-off-by: Antti Palosaari <cr...@iki.fi>


I can confirm that I saw something with regards to this one time before.

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: [v4.9-rc4] dvb-usb/cinergyT2 NULL pointer dereference

2016-11-12 Thread Benjamin Larsson

On 11/11/2016 02:55 PM, Mauro Carvalho Chehab wrote:

Em Thu, 10 Nov 2016 12:15:39 +0100

Benjamin,

Could you please test it?

Thanks!
Mauro


Hi, I the device is in use now. Can't test it with a new tree. I am 
using an old tree for it.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: [v4.9-rc4] dvb-usb/cinergyT2 NULL pointer dereference

2016-11-08 Thread Benjamin Larsson

On 11/08/2016 09:22 PM, Mauro Carvalho Chehab wrote:

Em Tue, 8 Nov 2016 10:42:03 -0800
Linus Torvalds <torva...@linux-foundation.org> escreveu:


On Sun, Nov 6, 2016 at 7:40 AM, Jörg Otte <jrg.o...@gmail.com> wrote:

Since v4.9-rc4 I get following crash in dvb-usb-cinergyT2 module.


Looks like it's commit 5ef8ed0e5608f ("[media] cinergyT2-core: don't
do DMA on stack"), which movced the DMA data array from the stack to
the "private" pointer. In the process it also added serialization in
the form of "data_mutex", but and now it oopses on that mutex because
the private pointer is NULL.

It looks like the "->private" pointer is allocated in dvb_usb_adapter_init()

cinergyt2_usb_probe ->
  dvb_usb_device_init ->
dvb_usb_init() ->
  dvb_usb_adapter_init()

but the dvb_usb_init() function calls dvb_usb_device_power_ctrl()
(which calls the "power_ctrl" function, which is
cinergyt2_power_ctrl() for that drive) *before* it initializes the
private field.

Mauro, Patrick, could dvb_usb_adapter_init() be called earlier, perhaps?


Calling it earlier won't work, as we need to load the firmware before
sending the power control commands on some devices.

Probably the best here is to pass an extra optional function parameter
that will initialize the mutex before calling any functions.

Btw, if it broke here, the DMA fixes will likely break on other drivers.
So, after Jörg tests this patch, I'll work on a patch series addressing
this issue on the other drivers I touched.

Regards,
Mauro


Just for reference I got the following call trace a week ago. I looks 
like this confirms that other drivers are affected also.


MvH
Benjamin Larsson


dvb-usb: found a 'Mygica T230 DVB-T/T2/C' in warm state.
BUG: unable to handle kernel NULL pointer dereference at   (null)
IP: [] __mutex_lock_slowpath+0x98/0x130
PGD 0
Oops: 0002 [#1] SMP
Modules linked in: dvb_usb_cxusb(OE+) dib0070(OE) dvb_usb_rtl28xxu(OE+) 
dvb_usb_dw2102(OE+) dvb_usb(OE) dvb_usb_v2(OE) dvb_core(OE) rc_core(OE) 
ipmi_ssif media(OE) lpc_sch joydev input_leds i2c_ismt ipmi_si 
8250_fintek ipmi_msghandler shpchp mac_hid kvm_intel kvm irqbypass 
ib_iser rdma_cm iw_cm ib_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp 
libiscsi_tcp libiscsi scsi_transport_iscsi autofs4 btrfs raid10 
multipath linear raid456 async_raid6_recov async_memcpy async_pq 
async_xor async_tx xor raid6_pq libcrc32c raid0 raid1 hid_generic igb 
dca usbhid ptp pps_core i2c_algo_bit hid ahci libahci fjes
CPU: 3 PID: 571 Comm: systemd-udevd Tainted: G   OE 
4.4.0-45-generic #66-Ubuntu

Hardware name: Supermicro X9SBAA/X9SBAA, BIOS 1.00 04/29/2014
task: 880231678000 ti: 880232048000 task.ti: 880232048000
RIP: 0010:[]  [] 
__mutex_lock_slowpath+0x98/0x130

RSP: 0018:88023204b920  EFLAGS: 00010282
RAX:  RBX: 88023152fea8 RCX: 
RDX: 0001 RSI: 880231678000 RDI: 88023152feac
RBP: 88023204b970 R08: 880232048000 R09: 
R10: 0325 R11:  R12: 88023152feac
R13: 880231678000 R14:  R15: 88023152feb0
FS:  7fc5390d68c0() GS:88023fd8() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2:  CR3: 00023262f000 CR4: 06e0
Stack:
88023152feb0  88023204b978 27226a0c
01ff8802 88023152fea8 88023152fe40 88023152fea8
8800ba9e4000  88023204b988 8182f73f
Call Trace:
[] mutex_lock+0x1f/0x30
[] cxusb_ctrl_msg+0x5a/0xe0 [dvb_usb_cxusb]
[] cxusb_power_ctrl+0x58/0x60 [dvb_usb_cxusb]
[] cxusb_d680_dmb_power_ctrl+0x2b/0x90 [dvb_usb_cxusb]
[] dvb_usb_device_power_ctrl.part.4+0x31/0x50 [dvb_usb]
[] dvb_usb_device_power_ctrl+0x2a/0x40 [dvb_usb]
[] dvb_usb_device_init+0x244/0x750 [dvb_usb]
[] ? kernfs_activate+0x7a/0xe0
[] cxusb_probe+0x260/0x280 [dvb_usb_cxusb]
[] usb_probe_interface+0x118/0x2f0
[] driver_probe_device+0x222/0x4a0
[] __driver_attach+0x84/0x90
[] ? driver_probe_device+0x4a0/0x4a0
[] bus_for_each_dev+0x6c/0xc0
[] driver_attach+0x1e/0x20
[] bus_add_driver+0x1eb/0x280
[] driver_register+0x60/0xe0
[] usb_register_driver+0x84/0x140
[] ? 0xc03d8000
[] cxusb_driver_init+0x1e/0x1000 [dvb_usb_cxusb]
[] do_one_initcall+0xb3/0x200
[] ? __vunmap+0x91/0xe0
[] ? kmem_cache_alloc_trace+0x183/0x1f0
[] ? kfree+0x13a/0x150
[] do_init_module+0x5f/0x1cf
[] load_module+0x166f/0x1c10
[] ? __symbol_put+0x60/0x60
[] ? kernel_read+0x50/0x80
[] SYSC_finit_module+0xb4/0xe0
[] SyS_finit_module+0xe/0x10
[] entry_SYSCALL_64_fastpath+0x16/0x71
Code: e8 ae 1f 00 00 8b 03 83 f8 01 0f 84 94 00 00 00 48 8b 43 10 4c 8d 
7b 08 48 89 63 10 41 be ff ff ff ff 4c 89 3c 24 48 89 44 24 08 <48> 89 
20 4c 89 6c 24 10 eb 1f 49 c7 45 00 02 00 00 00 4c 89 e7

RIP  [] __mutex_lock_slowpath+0x98/0x130
 RSP 
CR2: 
---[ end trace b28b9190ee8e491

Re: [BUG] non working drivers with current linuxtv git on Ubuntu 16.04.1 LTS

2016-10-30 Thread Benjamin Larsson

On 10/30/2016 01:22 PM, Benjamin Larsson wrote:


I got this for my anysee card:

dvb_usb_anysee: disagrees about version of symbol dvb_ca_en50221_init
dvb_usb_anysee: Unknown symbol dvb_ca_en50221_init (err -22)
dvb_usb_anysee: disagrees about version of symbol dvb_ca_en50221_release
dvb_usb_anysee: Unknown symbol dvb_ca_en50221_release (err -22)
dvb_usb_anysee: disagrees about version of symbol rc_keydown
dvb_usb_anysee: Unknown symbol rc_keydown (err -22)
dvb_usb_anysee: disagrees about version of symbol
dvb_usbv2_generic_rw_locked
dvb_usb_anysee: Unknown symbol dvb_usbv2_generic_rw_locked (err -22)



For unknown reasons the anysee module was not enabled.

MvH
Benjamin Larsson

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


[BUG] non working drivers with current linuxtv git on Ubuntu 16.04.1 LTS

2016-10-30 Thread Benjamin Larsson
Just a plain driver install on a newly installed box. The faulting 
drivers did work before using the Ubuntu 16.04 kernel.



WARNING: You are using an experimental version of the media stack.
As the driver is backported to an older kernel, it doesn't offer
enough quality for its usage in production.
Use it with care.
Latest git patches (needed if you report a bug to 
linux-media@vger.kernel.org):
bd676c0c04ec94bd830b9192e2c33f2c4532278d [media] v4l2-flash-led-class: 
remove a now unused var
079933dbcb02132cc48ba052882fe0a9e3b0b762 [media] v4l: flash led class: 
Fix of_node release in probe() error path
c762ff1f7e3b09293c22ce62135ef550c1b3327c [media] coda: fix the error 
path in coda_probe()



I followed the instructions from the user part on the wiki.

I got this for my anysee card:

dvb_usb_anysee: disagrees about version of symbol dvb_ca_en50221_init
dvb_usb_anysee: Unknown symbol dvb_ca_en50221_init (err -22)
dvb_usb_anysee: disagrees about version of symbol dvb_ca_en50221_release
dvb_usb_anysee: Unknown symbol dvb_ca_en50221_release (err -22)
dvb_usb_anysee: disagrees about version of symbol rc_keydown
dvb_usb_anysee: Unknown symbol rc_keydown (err -22)
dvb_usb_anysee: disagrees about version of symbol 
dvb_usbv2_generic_rw_locked

dvb_usb_anysee: Unknown symbol dvb_usbv2_generic_rw_locked (err -22)


And this for my Mygica T230 card:

dvb-usb: found a 'Mygica T230 DVB-T/T2/C' in warm state.
BUG: unable to handle kernel NULL pointer dereference at   (null)
IP: [] __mutex_lock_slowpath+0x98/0x130
PGD 0
Oops: 0002 [#1] SMP
Modules linked in: dvb_usb_cxusb(OE+) dib0070(OE) dvb_usb_rtl28xxu(OE+) 
dvb_usb_dw2102(OE+) dvb_usb(OE) dvb_usb_v2(OE) dvb_core(OE) rc_core(OE) 
ipmi_ssif media(OE) lpc_sch joydev input_leds i2c_ismt ipmi_si 
8250_fintek ipmi_msghandler shpchp mac_hid kvm_intel kvm irqbypass 
ib_iser rdma_cm iw_cm ib_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp 
libiscsi_tcp libiscsi scsi_transport_iscsi autofs4 btrfs raid10 
multipath linear raid456 async_raid6_recov async_memcpy async_pq 
async_xor async_tx xor raid6_pq libcrc32c raid0 raid1 hid_generic igb 
dca usbhid ptp pps_core i2c_algo_bit hid ahci libahci fjes
CPU: 3 PID: 571 Comm: systemd-udevd Tainted: G   OE 
4.4.0-45-generic #66-Ubuntu

Hardware name: Supermicro X9SBAA/X9SBAA, BIOS 1.00 04/29/2014
task: 880231678000 ti: 880232048000 task.ti: 880232048000
RIP: 0010:[]  [] 
__mutex_lock_slowpath+0x98/0x130

RSP: 0018:88023204b920  EFLAGS: 00010282
RAX:  RBX: 88023152fea8 RCX: 
RDX: 0001 RSI: 880231678000 RDI: 88023152feac
RBP: 88023204b970 R08: 880232048000 R09: 
R10: 0325 R11:  R12: 88023152feac
R13: 880231678000 R14:  R15: 88023152feb0
FS:  7fc5390d68c0() GS:88023fd8() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2:  CR3: 00023262f000 CR4: 06e0
Stack:
88023152feb0  88023204b978 27226a0c
01ff8802 88023152fea8 88023152fe40 88023152fea8
8800ba9e4000  88023204b988 8182f73f
Call Trace:
[] mutex_lock+0x1f/0x30
[] cxusb_ctrl_msg+0x5a/0xe0 [dvb_usb_cxusb]
[] cxusb_power_ctrl+0x58/0x60 [dvb_usb_cxusb]
[] cxusb_d680_dmb_power_ctrl+0x2b/0x90 [dvb_usb_cxusb]
[] dvb_usb_device_power_ctrl.part.4+0x31/0x50 [dvb_usb]
[] dvb_usb_device_power_ctrl+0x2a/0x40 [dvb_usb]
[] dvb_usb_device_init+0x244/0x750 [dvb_usb]
[] ? kernfs_activate+0x7a/0xe0
[] cxusb_probe+0x260/0x280 [dvb_usb_cxusb]
[] usb_probe_interface+0x118/0x2f0
[] driver_probe_device+0x222/0x4a0
[] __driver_attach+0x84/0x90
[] ? driver_probe_device+0x4a0/0x4a0
[] bus_for_each_dev+0x6c/0xc0
[] driver_attach+0x1e/0x20
[] bus_add_driver+0x1eb/0x280
[] driver_register+0x60/0xe0
[] usb_register_driver+0x84/0x140
[] ? 0xc03d8000
[] cxusb_driver_init+0x1e/0x1000 [dvb_usb_cxusb]
[] do_one_initcall+0xb3/0x200
[] ? __vunmap+0x91/0xe0
[] ? kmem_cache_alloc_trace+0x183/0x1f0
[] ? kfree+0x13a/0x150
[] do_init_module+0x5f/0x1cf
[] load_module+0x166f/0x1c10
[] ? __symbol_put+0x60/0x60
[] ? kernel_read+0x50/0x80
[] SYSC_finit_module+0xb4/0xe0
[] SyS_finit_module+0xe/0x10
[] entry_SYSCALL_64_fastpath+0x16/0x71
Code: e8 ae 1f 00 00 8b 03 83 f8 01 0f 84 94 00 00 00 48 8b 43 10 4c 8d 
7b 08 48 89 63 10 41 be ff ff ff ff 4c 89 3c 24 48 89 44 24 08 <48> 89 
20 4c 89 6c 24 10 eb 1f 49 c7 45 00 02 00 00 00 4c 89 e7

RIP  [] __mutex_lock_slowpath+0x98/0x130
 RSP 
CR2: 
---[ end trace b28b9190ee8e4917 ]---

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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] dw2102: Add support for Terratec Cinergy S2 USB BOX

2016-07-27 Thread Benjamin Larsson

On 07/18/2016 01:59 PM, Mauro Carvalho Chehab wrote:

It would be
nice if both Philipp and Benjamin test such patch, for us to be sure
that it would work for both.

Regards,
Mauro


I added it to the dvbsky driver so I guess that Philipp has to do the 
testing.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: [PATCHv2] rtl28xxu: increase failed I2C msg repeat count to 3

2016-06-07 Thread Benjamin Larsson

On 2016-06-07 09:52, Antti Palosaari wrote:

1 and 2 wasn't enough for mn88472 chip on Astrometa device,
so increase it to 3.

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


ACK

MvH
Benjamin Larsson

--
To unsubscribe from this list: send the line "unsubscribe 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] rtl2832: add support for slave ts pid filter

2016-05-21 Thread Benjamin Larsson

On 05/21/2016 10:38 PM, Benjamin Larsson wrote:

The rtl2832 demod has 2 sets of PID filters. This patch enables
the filter support when using a slave demod.



Ignore this patch for now.

MvH
Benjamin Larsson

--
To unsubscribe from this list: send the line "unsubscribe 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] rtl2832: add support for slave ts pid filter

2016-05-21 Thread Benjamin Larsson
The rtl2832 demod has 2 sets of PID filters. This patch enables
the filter support when using a slave demod.

Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/media/dvb-frontends/rtl2832.c  | 21 ++---
 drivers/media/dvb-frontends/rtl2832_priv.h |  1 +
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index 7c96f76..fe771b9 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -409,6 +409,7 @@ static int rtl2832_init(struct dvb_frontend *fe)
c->post_bit_count.len = 1;
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
dev->sleeping = false;
+   dev->slave_ts = 0;
 
return 0;
 err:
@@ -1124,10 +1125,16 @@ static int rtl2832_pid_filter_ctrl(struct dvb_frontend 
*fe, int onoff)
else
u8tmp = 0x00;
 
-   ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
+   if (dev->slave_ts) {
+   ret = rtl2832_update_bits(client, 0x021, 0xc0, u8tmp);
+   } else {
+   ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
+   }
if (ret)
goto err;
 
+   dev->slave_ts = 1;
+
return 0;
 err:
dev_dbg(>dev, "failed=%d\n", ret);
@@ -1159,14 +1166,22 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, 
u8 index, u16 pid,
buf[1] = (dev->filters >>  8) & 0xff;
buf[2] = (dev->filters >> 16) & 0xff;
buf[3] = (dev->filters >> 24) & 0xff;
-   ret = rtl2832_bulk_write(client, 0x062, buf, 4);
+
+   if (dev->slave_ts)
+   ret = rtl2832_bulk_write(client, 0x022, buf, 4);
+   else
+   ret = rtl2832_bulk_write(client, 0x062, buf, 4);
if (ret)
goto err;
 
/* add PID */
buf[0] = (pid >> 8) & 0xff;
buf[1] = (pid >> 0) & 0xff;
-   ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
+
+   if (dev->slave_ts)
+   ret = rtl2832_bulk_write(client, 0x026 + 2 * index, buf, 2);
+   else
+   ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
if (ret)
goto err;
 
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h 
b/drivers/media/dvb-frontends/rtl2832_priv.h
index 6b875f4..561f8ab 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -45,6 +45,7 @@ struct rtl2832_dev {
bool sleeping;
struct delayed_work i2c_gate_work;
unsigned long filters; /* PID filter */
+   unsigned long slave_ts;
 };
 
 struct rtl2832_reg_entry {
-- 
2.5.0

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


Re: [PATCH 1/3] rtl28xxu: increase failed I2C msg repeat count to 2

2016-05-14 Thread Benjamin Larsson

On 05/14/2016 07:14 AM, Antti Palosaari wrote:

1 wasn't enough for mn88472 chip on Astrometa device, so increase
it by one.



I did need more then 2 repeats some times (I don't have any logs to back 
it up right now), so can we add some more just in case or can it mess up 
something else ?


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


Re: [PATCH 1/3] rtl2832: add support for slave ts pid filter

2015-12-21 Thread Benjamin Larsson

On 12/21/2015 03:42 AM, Antti Palosaari wrote:

Patch looks acceptable, but it is broken in a mean it does not apply :(



I'll rebase on git://linuxtv.org/anttip/media_tree.git rtl2832u_pull.

MvH
Benjamin Larsson


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


Re: [PATCH 2/3] mn88472: add work around for failing firmware loading

2015-12-21 Thread Benjamin Larsson

On 12/21/2015 03:52 AM, Antti Palosaari wrote:

Hello
I am not sure if problem is I2C adapter/bus or that demodulator I2C
slave. If it is demod, then that workaround is correct place, but if it
is not, then that is wrong and I2C adapter repeating logic should be used.

I did some testing again... Loading mn88472 firmware 1000 times, it failed:
61 times RC polling disabled
68 times RC polling enabled
83 times RC polling enabled, but repeated failed message due to that patch


At least this confirms there is an issue.



I don't want apply that patch until I find some time myself to examine
that problem - or someone else does some study to point out whats wrong.
There is many things to test in order to get better understanding.

regards
Antti


I do have other hardware with with a mn88472 demod on it. A CX23102 
bridge and a dibcom (Xbox one tuner). I think that running the same test 
on those hardware will tell where the issue is.


I know that Olli have worked on the Xbox one tuner, do you have any 
support patches that could help testing this? And did you observe any 
issues with the mn88472 demod when working on the Xbox one tuner ?


I am quite sure that I saw this on the mn88473 version of this hardware 
also. I just haven't had the time to test it. But I will postpone that 
until the tests on the other bridges are done.


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


Re: [PATCH 3/3] rtl28xxu: change Astrometa DVB-T2 to always use hardware pid filters

2015-12-20 Thread Benjamin Larsson

On 12/20/2015 04:36 AM, Antti Palosaari wrote:

Moikka!
I did some testing and I cannot see reason to force hw pid filter for
that device. I assume you somehow think it does not work without
filtering, but I think it does.



[... proof that I was wrong ...]



So point me the reason hw PID filters need to be forced.


The only reason would be that I suspected that high rates would not be 
possible over the bridge and that this was the default mode for the 
binary driver but as you proved that the bridge is able to support the 
rate this patch can be nacked.




regards
Antti


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: AF9035 with no tuner?

2015-12-12 Thread Benjamin Larsson

On 12/12/2015 10:08 PM, Jiri Slaby wrote:

Hello,

I have a USB device which digitizes composite video into a MPEG-2 stream
(I think). It is an AF9035 device according to windows. But it has no
tuner. Is there a way to make it working on linux or am I out of luck?



Open the device and take pictures of the pcb and the chips. After that 
it might be possible to identify what kind of device it is.


MvH
Benjamin Larsson

--
To unsubscribe from this list: send the line "unsubscribe 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: AF9035 with no tuner?

2015-12-12 Thread Benjamin Larsson

On 12/12/2015 10:25 PM, Jiri Slaby wrote:

On 12/12/2015, 10:12 PM, Benjamin Larsson wrote:

On 12/12/2015 10:08 PM, Jiri Slaby wrote:

Hello,

I have a USB device which digitizes composite video into a MPEG-2 stream
(I think). It is an AF9035 device according to windows. But it has no
tuner. Is there a way to make it working on linux or am I out of luck?



Open the device and take pictures of the pcb and the chips. After that
it might be possible to identify what kind of device it is.


Sure:
http://www.fi.muni.cz/~xslaby/sklad/back.JPG
http://www.fi.muni.cz/~xslaby/sklad/front.JPG

thanks,



Hi, seems like this device is a nogo.

http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/24210

No driver support for the composite interface of the af9035. No driver 
support for the AVF 4910BA1 video digitizer chip.



MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: Dear TV card experts - I need you help

2015-12-09 Thread Benjamin Larsson

On 12/04/2015 05:35 PM, Mr Andersson wrote:

Hi Benjamin,

Thanks for your answer. Jag uppskattar din hjälp ;)

So 50 USD per mux. And I could simultaneously record up to  4 channels
per mux ? Is that satellite dependant?

Could you give me an example of high quality/value cards I should look at first?

Also, what linux software would be best to use together with these
cards? I am looking initially at just streaming the content right of,
although we might need to hook into the stream and manipulate it.
Later, we'd also might be interested in recording the stream as well.

Thanks!


Hi, the question you ask needs an answer in the form of basic digital tv 
tutorial. I suggest you search the web for that info.


Regarding software I suggest you look at the tvheadend project. It has a 
software model that is easy to understand.


Regarding hardware I would go for quad pcie in a form factor that would 
fit in rack-mounted servers. You need high density and that is the only 
way to get that. So I would say skip trying to find something cheap, get 
something that is reliable and maintainable.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: Dear TV card experts - I need you help

2015-12-04 Thread Benjamin Larsson

On 12/03/2015 02:45 PM, Mr Andersson wrote:

Hi,


[,,,]


Most cards out there supports maximum 4 channels per cards. Some I've
looked into costs around 200 USD per card and for 2000 channels,
excluding all other hardware, that would cost around 100 000 USD.


[...]

The terminology you are looking for is 4 muxes per card, not channel. 
One mux can hold several channels. One satellite I looked at had ca 24
fta muxes with ca 3-4 channels per mux. So to cover this whole satellite 
you would need 6 quad cards. If a quad card costs $200 that gives you 
$50 / mux cost. The cheapest single mux s2 card I could find cost ca 
$60. So $50/mux is probably what you have to pay for this component if 
you buy from a reseller.


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


[PATCH 1/2] Add Terratec Cinergy S2 usb id's

2015-11-28 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/media/dvb-core/dvb-usb-ids.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 1c1c298..d62ac1f 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -255,6 +255,10 @@
 #define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
 #define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
 #define USB_PID_TERRATEC_CINERGY_T_XXS_2   0x00ab
+#define USB_PID_TERRATEC_CINERGY_S2_R1 0x00a8
+#define USB_PID_TERRATEC_CINERGY_S2_R2 0x00b0
+#define USB_PID_TERRATEC_CINERGY_S2_R3 0x0102
+#define USB_PID_TERRATEC_CINERGY_S2_R4 0x0105
 #define USB_PID_TERRATEC_H70x10b4
 #define USB_PID_TERRATEC_H7_2  0x10a3
 #define USB_PID_TERRATEC_H7_3  0x10a5
-- 
2.1.4

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


[PATCH 1/3] rtl2832: add support for slave ts pid filter

2015-11-28 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/media/dvb-frontends/rtl2832.c  | 21 ++---
 drivers/media/dvb-frontends/rtl2832_priv.h |  1 +
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c 
b/drivers/media/dvb-frontends/rtl2832.c
index 78b87b2..e054079 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -407,6 +407,7 @@ static int rtl2832_init(struct dvb_frontend *fe)
/* start statistics polling */
schedule_delayed_work(>stat_work, msecs_to_jiffies(2000));
dev->sleeping = false;
+   dev->slave_ts = false;
 
return 0;
 err:
@@ -1122,6 +1123,8 @@ static int rtl2832_enable_slave_ts(struct i2c_client 
*client)
if (ret)
goto err;
 
+   dev->slave_ts = true;
+
return 0;
 err:
dev_dbg(>dev, "failed=%d\n", ret);
@@ -1143,7 +1146,11 @@ static int rtl2832_pid_filter_ctrl(struct dvb_frontend 
*fe, int onoff)
else
u8tmp = 0x00;
 
-   ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
+   if (dev->slave_ts)
+   ret = rtl2832_update_bits(client, 0x021, 0xc0, u8tmp);
+   else
+   ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
if (ret)
goto err;
 
@@ -1178,14 +1185,22 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, 
u8 index, u16 pid,
buf[1] = (dev->filters >>  8) & 0xff;
buf[2] = (dev->filters >> 16) & 0xff;
buf[3] = (dev->filters >> 24) & 0xff;
-   ret = rtl2832_bulk_write(client, 0x062, buf, 4);
+
+   if (dev->slave_ts)
+   ret = rtl2832_bulk_write(client, 0x022, buf, 4);
+   else
+   ret = rtl2832_bulk_write(client, 0x062, buf, 4);
if (ret)
goto err;
 
/* add PID */
buf[0] = (pid >> 8) & 0xff;
buf[1] = (pid >> 0) & 0xff;
-   ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
+
+   if (dev->slave_ts)
+   ret = rtl2832_bulk_write(client, 0x026 + 2 * index, buf, 2);
+   else
+   ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
if (ret)
goto err;
 
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h 
b/drivers/media/dvb-frontends/rtl2832_priv.h
index 5dcd3a4..efc230f 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -46,6 +46,7 @@ struct rtl2832_dev {
bool sleeping;
struct delayed_work i2c_gate_work;
unsigned long filters; /* PID filter */
+   bool slave_ts;
 };
 
 struct rtl2832_reg_entry {
-- 
2.1.4

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


[PATCH 3/3] rtl28xxu: change Astrometa DVB-T2 to always use hardware pid filters

2015-11-28 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 35 -
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 5a503a6..74201ec 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1848,6 +1848,39 @@ static const struct dvb_usb_device_properties 
rtl28xxu_props = {
},
 };
 
+static const struct dvb_usb_device_properties rtl28xxp_props = {
+   .driver_name = KBUILD_MODNAME,
+   .owner = THIS_MODULE,
+   .adapter_nr = adapter_nr,
+   .size_of_priv = sizeof(struct rtl28xxu_dev),
+
+   .identify_state = rtl28xxu_identify_state,
+   .power_ctrl = rtl28xxu_power_ctrl,
+   .frontend_ctrl = rtl28xxu_frontend_ctrl,
+   .i2c_algo = _i2c_algo,
+   .read_config = rtl28xxu_read_config,
+   .frontend_attach = rtl28xxu_frontend_attach,
+   .frontend_detach = rtl28xxu_frontend_detach,
+   .tuner_attach = rtl28xxu_tuner_attach,
+   .tuner_detach = rtl28xxu_tuner_detach,
+   .init = rtl28xxu_init,
+
+   .get_rc_config = rtl28xxu_get_rc_config,
+   .num_adapters = 1,
+   .adapter = {
+   {
+   .caps = DVB_USB_ADAP_NEED_PID_FILTERING |
+   DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+
+   .pid_filter_count = 32,
+   .pid_filter_ctrl = rtl28xxu_pid_filter_ctrl,
+   .pid_filter = rtl28xxu_pid_filter,
+
+   .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
+   },
+   },
+};
+
 static const struct usb_device_id rtl28xxu_id_table[] = {
/* RTL2831U devices: */
{ DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U,
@@ -1919,7 +1952,7 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
 
/* RTL2832P devices: */
{ DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131,
-   _props, "Astrometa DVB-T2", NULL) },
+   _props, "Astrometa DVB-T2", NULL) },
{ DVB_USB_DEVICE(0x5654, 0xca42,
_props, "GoTView MasterHD 3", NULL) },
{ }
-- 
2.1.4

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


[PATCH 2/3] mn88472: add work around for failing firmware loading

2015-11-28 Thread Benjamin Larsson
Sometimes the firmware fails to load because of an i2c error.
Work around that by adding retry logic. This kind of logic
also exist in the binary driver and failures have been observed
there also. Thus this seems to be a property of the hardware
and a fix like this is needed.

Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index cf2e96b..80c5807 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -282,7 +282,7 @@ static int mn88472_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
-   unsigned int tmp;
+   unsigned int tmp, retry_cnt;
 
dev_dbg(>dev, "\n");
 
@@ -330,9 +330,22 @@ static int mn88472_init(struct dvb_frontend *fe)
if (len > (dev->i2c_wr_max - 1))
len = dev->i2c_wr_max - 1;
 
+   /* I2C transfers during firmware load might fail sometimes,
+* just retry in that case. 4 consecutive failures have
+* been observed thus a retry limit of 20 is used.
+*/
+   retry_cnt = 20;
+retry:
ret = regmap_bulk_write(dev->regmap[0], 0xf6,
>data[fw->size - remaining], len);
if (ret) {
+   if (retry_cnt) {
+   dev_dbg(>dev,
+   "i2c error, retry %d triggered\n", retry_cnt);
+   retry_cnt--;
+   usleep_range(200, 1);
+   goto retry;
+   }
dev_err(>dev,
"firmware download failed=%d\n", ret);
goto firmware_release;
-- 
2.1.4

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


[PATCH 2/2] Add support for Terratec Cinergy S2 Rev.4

2015-11-28 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson <benja...@southpole.se>
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 1dd9625..2d922b9 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -851,6 +851,9 @@ static const struct usb_device_id dvbsky_id_table[] = {
USB_PID_TERRATEC_H7_3,
_t680c_props, "Terratec H7 Rev.4",
RC_MAP_TT_1500) },
+   { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4,
+   _s960_props, "Terratec Cinergy S2 Rev.4",
+   RC_MAP_DVBSKY) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
-- 
2.1.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: PID filter testing

2015-11-20 Thread Benjamin Larsson

On 11/20/2015 02:27 PM, Honza Petrouš wrote:

2015-11-20 12:00 GMT+01:00 Benjamin Larsson <benja...@southpole.se>:

Hi, what tools can I use to test pid filter support in the drivers ?


Zap utility from dvbapps seems to be some simpler way - you can pass them
the fixed pids and record filtered data by simple command.

See at:
http://www.linuxtv.org/wiki/index.php/Zap

/Honza


Hi, can you elaborate with a command line example ? To start with I want 
only the 0x1fff pid from a random dvb-c mux.


MvH
Benjamin Larsson


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


PID filter testing

2015-11-20 Thread Benjamin Larsson

Hi, what tools can I use to test pid filter support in the drivers ?

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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: PID filter testing

2015-11-20 Thread Benjamin Larsson



hmm, that is null pid for padding ts to correct size IIRC. Take into
account that some pid filters / bridges automatically filter it out.
Usually it is there though.

So it is not very good pid to test. If you want test some pid which is
always there look those mandatory pids which are pids numbered near 0.

regards
Antti



When I hard code the rtl2833 external pid filter I am able to get only 
that pid. The inverse case also works as that is the default. Anyway I 
just want some tool that I can use from command line that can toggle 
pids somewhat dynamically. To bad there seems to be no ready available 
tool for that.


Adding pid selection to dvbv5-zap in monitor mode looks to be the best 
way forward.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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] rtl28xxu: fix control message flaws

2015-11-06 Thread Benjamin Larsson

On 10/10/2015 06:45 PM, Antti Palosaari wrote:

Add lock to prevent concurrent access for control message as control
message function uses shared buffer. Without the lock there may be
remote control polling which messes the buffer causing IO errors.
Increase buffer size and add check for maximum supported message
length.



This patch made at least one of my devices work. Before my log was full 
of errors.


Totally unrelated I do get a fail on loading the firmware. Just retrying 
made it work eventually.


[  143.286498] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  143.551497] mn88473 19-0018: firmware download failed=-32
[  143.826792] rtl2832 19-0010: i2c reg read failed -32
[  143.903215] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  144.345554] mn88473 19-0018: firmware download failed=-32
[  331.060613] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  331.477234] mn88473 19-0018: firmware download failed=-32
[  354.997771] rtl2832 19-0010: i2c reg read failed -32
[  358.591754] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  359.115582] mn88473 19-0018: firmware parity check succeeded=0x20

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe 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] mn88472: Fix possible leak in mn88472_init()

2015-05-02 Thread Benjamin Larsson

On 05/02/2015 11:59 PM, Christian Engelmayer wrote:

Commit 307e95c92257 ([media] mn88472: implement firmware parity check)
introduced the usage of exit paths that do not free the already allocated
firmware data in case the parity handling fails. Go through the correct
exit paths. Detected by Coverity CID 1295989.

Signed-off-by: Christian Engelmayer cenge...@gmx.at


ACK

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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 12/12] rtl2832: add support for GoTView MasterHD 3 USB tuner

2015-04-23 Thread Benjamin Larsson

On 04/23/2015 11:11 PM, Olli Salonen wrote:

GoTView MasterHD 3 is a DVB-T2/C USB 2.0 tuner.

It's based on the following components:
- USB bridge: RTL2832P (contains also DVB-T demodulator)
- Demodulator: Si2168-A30
- Tuner: Si2148-A20


[...]


For some reason, the old I2C write method sporadically failed. Thus the
need for an option to only use the new I2C write method supported by the
RTL2832.


Hi, I also experienced this with the Astrometa stick. I guess the 
new_i2c_write flag should be set on those devices also.


Do you plan on adding pid filter support also? I posted a non working 
rfc patch you could base it on.


MvH
Benjamin Larsson


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


Re: [PATCH 1/1] mn88473: implement lock for all delivery systems

2015-03-22 Thread Benjamin Larsson

Now it works. Next time I really expect you will test your patches
somehow before sending. Now I tested 3 different patch versions, find 2
first to be broken and last one working. It took around 2 hours of my time.

Patch applied.

Antti



Yeah, my bad. Next I want to move the driver out of staging. What do I 
need to fix to make it suitable for the main tree ?


There is locking code for both 88472 and 88473.
There is a workaround for the I2C errors.
The r820t is now able to receive dvb-c at frequencies around 300MHz.

So I think all TODO's are taken care of. Is it inly the missing register 
I/O checks left ?


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


Re: [PATCH 1/1] mn88473: implement lock for all delivery systems

2015-03-20 Thread Benjamin Larsson

On 03/19/2015 03:44 PM, Antti Palosaari wrote:

Bad news. It does lock for DVB-C now, but DVB-T nor DVB-T2 does not lock.

regards
Antti


I'm getting tired :/. Had the time to test now and the checks is 
supposed to be negated.


if (utmp  0xA0) { - if (!(utmp  0xA0))

But as stock dvbv5-scan crashes on ubuntu 14.04 and I can't unload the 
mn88473 module I will confirm this when I have an actual working version 
of dvbv5-scan and Ubuntu.


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


Re: [RFC][PATCH] rtl2832: PID filter support for slave demod

2015-03-16 Thread Benjamin Larsson

On 03/16/2015 11:57 PM, Antti Palosaari wrote:

On 03/17/2015 12:12 AM, Benjamin Larsson wrote:

Is this structure ok for the slave pid implementation? Or should there
be only one filters parameter? Will the overlaying pid filter framework
properly flush the set pid filters ?

Note that this code currently is only compile tested.


I am fine with it.

byw. Have you tested if your QAM256 (DVB-C or DVB-T2) stream is valid
even without a PID filtering? IIRC mine stream is correct and PID
filtering is not required (but surely it could be implemented if you wish).

regards
Antti



DVB-C seems fine and one of my DVB-T2 muxes is fine also. But one other 
DVB-T2 mux completely fails. It could be the reception but it might be 
that it needs pid filtering. I do get small disturbances on my DVB-C 
muxes. Will report back if pid filtering makes things better or not.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] rtl2832: PID filter support for slave demod

2015-03-16 Thread Benjamin Larsson
Is this structure ok for the slave pid implementation? Or should there 
be only one filters parameter? Will the overlaying pid filter framework 
properly flush the set pid filters ?


Note that this code currently is only compile tested.

MvH
Benjamin Larsson
From 8efb26c18b4f9416bd516195c6a82853c924 Mon Sep 17 00:00:00 2001
From: Benjamin Larsson benja...@southpole.se
Date: Mon, 16 Mar 2015 22:59:50 +0100
Subject: [PATCH] rtl2832: PID filter support for slave demod
Cc: Linux Media Mailing List linux-media@vger.kernel.org

RTL2832p supports a slave configuration with a demodulator connected
to a ts input on the chip. This makes it possible to receive DVB-T2
muxes that are of larger size then what the rtl2832p usb-bridge is
capable of transfering.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/dvb-frontends/rtl2832.c  | 40 ++
 drivers/media/dvb-frontends/rtl2832_priv.h |  2 ++
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 5d2d8f4..3725211 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -488,6 +488,8 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
+	dev-slave_demod_active = 0;
+
 	/* If the frontend has get_if_frequency(), use it */
 	if (fe-ops.tuner_ops.get_if_frequency) {
 		u32 if_freq;
@@ -1114,6 +1116,8 @@ static int rtl2832_enable_slave_ts(struct i2c_client *client)
 	if (ret)
 		goto err;
 
+	dev-slave_demod_active = 1;
+
 	return 0;
 err:
 	dev_dbg(client-dev, failed=%d\n, ret);
@@ -1135,7 +1139,10 @@ static int rtl2832_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
 	else
 		u8tmp = 0x00;
 
-	ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
+	if (dev-slave_demod_active)
+		ret = rtl2832_update_bits(client, 0x021, 0xc0, u8tmp);
+	else
+		ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
 	if (ret)
 		goto err;
 
@@ -1152,6 +1159,7 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
 	struct i2c_client *client = dev-client;
 	int ret;
 	u8 buf[4];
+	unsigned long* filters;
 
 	dev_dbg(client-dev, index=%d pid=%04x onoff=%d\n,
 		index, pid, onoff);
@@ -1160,24 +1168,36 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
 	if (pid  0x1fff || index  32)
 		return 0;
 
-	if (onoff)
-		set_bit(index, dev-filters);
+	if (dev-slave_demod_active)
+		filters = dev-filters_slave;
 	else
-		clear_bit(index, dev-filters);
+		filters = dev-filters;
+
+	if (onoff) {
+		set_bit(index, filters);
+	} else {
+		clear_bit(index, filters);
+	}
 
 	/* enable / disable PIDs */
-	buf[0] = (dev-filters   0)  0xff;
-	buf[1] = (dev-filters   8)  0xff;
-	buf[2] = (dev-filters  16)  0xff;
-	buf[3] = (dev-filters  24)  0xff;
-	ret = rtl2832_bulk_write(client, 0x062, buf, 4);
+	buf[0] = (*filters   0)  0xff;
+	buf[1] = (*filters   8)  0xff;
+	buf[2] = (*filters  16)  0xff;
+	buf[3] = (*filters  24)  0xff;
+	if (dev-slave_demod_active)
+		ret = rtl2832_bulk_write(client, 0x022, buf, 4);
+	else
+		ret = rtl2832_bulk_write(client, 0x062, buf, 4);
 	if (ret)
 		goto err;
 
 	/* add PID */
 	buf[0] = (pid  8)  0xff;
 	buf[1] = (pid  0)  0xff;
-	ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
+	if (dev-slave_demod_active)
+		ret = rtl2832_bulk_write(client, 0x026 + 2 * index, buf, 2);
+	else
+		ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
 	if (ret)
 		goto err;
 
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index c3a922c..b95a7b7 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -46,6 +46,8 @@ struct rtl2832_dev {
 	bool sleeping;
 	struct delayed_work i2c_gate_work;
 	unsigned long filters; /* PID filter */
+	unsigned long filters_slave; /* PID filter */
+	int slave_demod_active;
 };
 
 struct rtl2832_reg_entry {
-- 
2.1.0



Re: [PATCH 10/10] mn88473: implement lock for all delivery systems

2015-03-16 Thread Benjamin Larsson

On 03/16/2015 11:44 PM, Antti Palosaari wrote:

On 03/16/2015 11:47 PM, Antti Palosaari wrote:

On 03/16/2015 12:57 AM, Benjamin Larsson wrote:

Signed-off-by: Benjamin Larsson benja...@southpole.se


Applied.


I found this does not work at least for DVB-C. After playing with
modulator I find reg 0x85 on bank 1 is likely AGC. Its value is changed
according to RF level even modulation itself is turned off.

I will likely remove that patch... It is a bit hard to find out lock
bits and it comes even harder without a modulator. Using typical tricks
to plug and unplug antenna, while dumping register values out is error
prone as you could not adjust signal strength nor change modulation
parameters causing wrong decision easily.

regards
Antti



Indeed the logic was inverted. Will respin the patch.

MvH
Benjamin Larsson

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


Re: [PATCH 04/10] rtl28xxu: swap frontend order for slave demods

2015-03-16 Thread Benjamin Larsson

On 03/16/2015 10:04 PM, Antti Palosaari wrote:

On 03/16/2015 10:44 PM, Benjamin Larsson wrote:

On 03/15/2015 11:57 PM, Benjamin Larsson wrote:

Some devices have 2 demodulators, when this is the case
make the slave demod be listed first. Enumerating the slave
first will help legacy applications to use the hardware.



Ignore this patch for now. Stuff gets broken if applied.


I will not apply it even you fix it. I don't like idea adding such hack
to kernel in order to workaround buggy applications. There is many older
devices having similar situation, having 2 demods - one for DVB-T and
one for DVB-C. So there has been surely enough time for app developers
to add support for multiple frontends... laziness.

Quite same happened for DVB-T2 support. I added initially hack for
CXD2820R driver in order to support DVB-T2 even applications are not
supporting it. That was implemented using trick driver did DVB-T2 tune
when DVB-T tune fails. After many years I did another DVB-T2 driver
Si2168 and didn't add such hack anymore. And what was result; almost all
applications were still lacking proper DVB-T2 support, after many many
years...

So I will never ever add any hacks to driver to workaround application
support as application developers are so lazy to add support or new
things if there is some workaround available.

regards
Antti



While I agree with your reasoning, the point with this patch is just to 
register one demod before another. If that is a hack or not I don't 
know. I have used it locally for test purposes and it is not needed for 
actual use so consider the patch withdrawn.


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


Re: [PATCH 04/10] rtl28xxu: swap frontend order for slave demods

2015-03-16 Thread Benjamin Larsson

On 03/15/2015 11:57 PM, Benjamin Larsson wrote:

Some devices have 2 demodulators, when this is the case
make the slave demod be listed first. Enumerating the slave
first will help legacy applications to use the hardware.



Ignore this patch for now. Stuff gets broken if applied.

/Benjamin

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


[PATCH 10/10] mn88473: implement lock for all delivery systems

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88473/mn88473.c | 50 +++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index a23e59e..ba39614 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
 {
struct i2c_client *client = fe-demodulator_priv;
struct mn88473_dev *dev = i2c_get_clientdata(client);
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
+   unsigned int utmp;
+   int lock = 0;
 
*status = 0;
 
@@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
goto err;
}
 
-   *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
-   FE_HAS_SYNC | FE_HAS_LOCK;
+   switch (c-delivery_system) {
+   case SYS_DVBT:
+   ret = regmap_read(dev-regmap[0], 0x62, utmp);
+   if (ret)
+   goto err;
+   if (utmp  0xA0) {
+   if ((utmp  0xF) = 0x03)
+   *status |= FE_HAS_SIGNAL;
+   if ((utmp  0xF) = 0x09)
+   lock = 1;
+   }
+   break;
+   case SYS_DVBT2:
+   ret = regmap_read(dev-regmap[2], 0x8B, utmp);
+   if (ret)
+   goto err;
+   if (utmp  0x40) {
+   if ((utmp  0xF) = 0x07)
+   *status |= FE_HAS_SIGNAL;
+   if ((utmp  0xF) = 0x0a)
+   *status |= FE_HAS_CARRIER;
+   if ((utmp  0xF) = 0x0d)
+   *status |= FE_HAS_VITERBI | FE_HAS_SYNC | 
FE_HAS_LOCK;
+   }
+   break;
+   case SYS_DVBC_ANNEX_A:
+   ret = regmap_read(dev-regmap[1], 0x85, utmp);
+   if (ret)
+   goto err;
+   if (utmp  0x40) {
+   ret = regmap_read(dev-regmap[1], 0x89, utmp);
+   if (ret)
+   goto err;
+   if (utmp  0x01)
+   lock = 1;
+   }
+   break;
+   default:
+   ret = -EINVAL;
+   goto err;
+   }
+
+   if (lock)
+   *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
+   FE_HAS_SYNC | FE_HAS_LOCK;
 
return 0;
 err:
-- 
2.1.0

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


[PATCH 06/10] mn88472: implement firmware parity check

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
Reviewed-by: Antti Palosaari cr...@iki.fi
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/staging/media/mn88472/mn88472.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 5070c37..4a00a4d 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -258,6 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
+   unsigned int csum;
 
dev_dbg(client-dev, \n);
 
@@ -303,6 +304,20 @@ static int mn88472_init(struct dvb_frontend *fe)
}
}
 
+   /* parity check of firmware */
+   ret = regmap_read(dev-regmap[0], 0xf8, csum);
+   if (ret) {
+   dev_err(client-dev,
+   parity reg read failed=%d\n, ret);
+   goto err;
+   }
+   if (csum  0x10) {
+   dev_err(client-dev,
+   firmware parity check failed=0x%x\n, csum);
+   goto err;
+   }
+   dev_err(client-dev, firmware parity check succeeded=0x%x\n, csum);
+
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
if (ret)
goto err;
-- 
2.1.0

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


[PATCH 07/10] mn88473: implement firmware parity check

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88473/mn88473.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index 84bd4fa..607ce4d 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -192,6 +192,7 @@ static int mn88473_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88473_FIRMWARE;
+   unsigned int tmp;
 
dev_dbg(client-dev, \n);
 
@@ -227,6 +228,20 @@ static int mn88473_init(struct dvb_frontend *fe)
}
}
 
+   /* parity check of firmware */
+   ret = regmap_read(dev-regmap[0], 0xf8, tmp);
+   if (ret) {
+   dev_err(client-dev,
+   parity reg read failed=%d\n, ret);
+   goto err;
+   }
+   if (tmp  0x10) {
+   dev_err(client-dev,
+   firmware parity check failed=0x%x\n, tmp);
+   goto err;
+   }
+   dev_err(client-dev, firmware parity check succeeded=0x%x\n, tmp);
+
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
if (ret)
goto err;
-- 
2.1.0

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


[PATCH 09/10] mn88472: check if firmware is already running before loading it

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 4a00a4d..c041fbf 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -258,7 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
-   unsigned int csum;
+   unsigned int tmp;
 
dev_dbg(client-dev, \n);
 
@@ -274,6 +274,17 @@ static int mn88472_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   /* check if firmware is already running */
+   ret = regmap_read(dev-regmap[0], 0xf5, tmp);
+   if (ret)
+   goto err;
+
+   if (!(tmp  0x1)) {
+   dev_info(client-dev, firmware already running\n);
+   dev-warm = true;
+   return 0;
+   }
+
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, client-dev);
if (ret) {
@@ -305,18 +316,18 @@ static int mn88472_init(struct dvb_frontend *fe)
}
 
/* parity check of firmware */
-   ret = regmap_read(dev-regmap[0], 0xf8, csum);
+   ret = regmap_read(dev-regmap[0], 0xf8, tmp);
if (ret) {
dev_err(client-dev,
parity reg read failed=%d\n, ret);
goto err;
}
-   if (csum  0x10) {
+   if (tmp  0x10) {
dev_err(client-dev,
-   firmware parity check failed=0x%x\n, csum);
+   firmware parity check failed=0x%x\n, tmp);
goto err;
}
-   dev_err(client-dev, firmware parity check succeeded=0x%x\n, csum);
+   dev_err(client-dev, firmware parity check succeeded=0x%x\n, tmp);
 
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
if (ret)
-- 
2.1.0

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


[PATCH 08/10] mn88473: check if firmware is already running before loading it

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88473/mn88473.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index 607ce4d..a23e59e 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -196,8 +196,19 @@ static int mn88473_init(struct dvb_frontend *fe)
 
dev_dbg(client-dev, \n);
 
-   if (dev-warm)
+   /* set cold state by default */
+   dev-warm = false;
+
+   /* check if firmware is already running */
+   ret = regmap_read(dev-regmap[0], 0xf5, tmp);
+   if (ret)
+   goto err;
+
+   if (!(tmp  0x1)) {
+   dev_info(client-dev, firmware already running\n);
+   dev-warm = true;
return 0;
+   }
 
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, client-dev);
-- 
2.1.0

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


[PATCH 01/10] r820t: add DVBC profile in sysfreq_sel

2015-03-15 Thread Benjamin Larsson
This will make the Astrometa DVB-T/T2/C usb stick be able to pick up
muxes around 290-314 MHz.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 8e040cf..639c220 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -775,6 +775,19 @@ static int r820t_sysfreq_sel(struct r820t_priv *priv, u32 
freq,
div_buf_cur = 0x30; /* 11, 150u */
filter_cur = 0x40;  /* 10, low */
break;
+   case SYS_DVBC_ANNEX_A:
+   mixer_top = 0x24;   /* mixer top:13 , top-1, low-discharge 
*/
+   lna_top = 0xe5;
+   lna_vth_l = 0x62;
+   mixer_vth_l = 0x75;
+   air_cable1_in = 0x60;
+   cable2_in = 0x00;
+   pre_dect = 0x40;
+   lna_discharge = 14;
+   cp_cur = 0x38;  /* 111, auto */
+   div_buf_cur = 0x30; /* 11, 150u */
+   filter_cur = 0x40;  /* 10, low */
+   break;
default: /* DVB-T 8M */
mixer_top = 0x24;   /* mixer top:13 , top-1, low-discharge 
*/
lna_top = 0xe5; /* detect bw 3, lna top:4, predet top:2 
*/
-- 
2.1.0

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


[PATCH 04/10] rtl28xxu: swap frontend order for slave demods

2015-03-15 Thread Benjamin Larsson
Some devices have 2 demodulators, when this is the case
make the slave demod be listed first. Enumerating the slave
first will help legacy applications to use the hardware.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ea75b3a..bb5003d 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -853,6 +853,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
 
if (dev-slave_demod) {
struct i2c_board_info info = {};
+   struct dvb_frontend *tmp_fe;
 
/*
 * We continue on reduced mode, without DVB-T2/C, using master
@@ -907,6 +908,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
 
dev-i2c_client_slave_demod = client;
}
+
+   /* Swap frontend order */
+   tmp_fe = adap-fe[0];
+   adap-fe[0] = adap-fe[1];
+   adap-fe[1] = tmp_fe;
}
 
return 0;
@@ -1134,12 +1140,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
break;
case TUNER_RTL2832_R828D:
-   fe = dvb_attach(r820t_attach, adap-fe[0],
-   dev-demod_i2c_adapter,
-   rtl2832u_r828d_config);
-   adap-fe[0]-ops.read_signal_strength =
-   adap-fe[0]-ops.tuner_ops.get_rf_strength;
-
if (adap-fe[1]) {
fe = dvb_attach(r820t_attach, adap-fe[1],
dev-demod_i2c_adapter,
@@ -1147,6 +1147,12 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[1]-ops.read_signal_strength =

adap-fe[1]-ops.tuner_ops.get_rf_strength;
}
+
+   fe = dvb_attach(r820t_attach, adap-fe[0],
+   dev-demod_i2c_adapter,
+   rtl2832u_r828d_config);
+   adap-fe[0]-ops.read_signal_strength =
+   adap-fe[0]-ops.tuner_ops.get_rf_strength;
break;
default:
dev_err(d-intf-dev, unknown tuner %d\n, dev-tuner);
-- 
2.1.0

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


[PATCH 02/10] r820t: change read_gain() code to match register layout

2015-03-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 639c220..eaaf1dc 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1199,7 +1199,7 @@ static int r820t_read_gain(struct r820t_priv *priv)
if (rc  0)
return rc;
 
-   return ((data[3]  0x0f)  1) + ((data[3]  0xf0)  4);
+   return ((data[3]  0x08)  1) + ((data[3]  0xf0)  4);
 }
 
 #if 0
-- 
2.1.0

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


[PATCH 03/10] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2015-03-15 Thread Benjamin Larsson
The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 77dcfdf..ea75b3a 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1611,7 +1611,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device 
*d,
rc-allowed_protos = RC_BIT_ALL;
rc-driver_type = RC_DRIVER_IR_RAW;
rc-query = rtl2832u_rc_query;
-   rc-interval = 400;
+   rc-interval = 200;
 
return 0;
 }
-- 
2.1.0

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


[PATCH 05/10] mn88472: implement lock for all delivery systems

2015-03-15 Thread Benjamin Larsson
The increase of the lock timeout is needed for dvb-t2.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 6eebe56..5070c37 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -19,7 +19,7 @@
 static int mn88472_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *s)
 {
-   s-min_delay_ms = 400;
+   s-min_delay_ms = 800;
return 0;
 }
 
@@ -201,6 +201,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
unsigned int utmp;
+   int lock = 0;
 
*status = 0;
 
@@ -211,21 +212,36 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
 
switch (c-delivery_system) {
case SYS_DVBT:
+   ret = regmap_read(dev-regmap[0], 0x7F, utmp);
+   if (ret)
+   goto err;
+   if ((utmp  0xF) = 0x09)
+   lock = 1;
+   break;
case SYS_DVBT2:
-   /* FIXME: implement me */
-   utmp = 0x08; /* DVB-C lock value */
+   ret = regmap_read(dev-regmap[2], 0x92, utmp);
+   if (ret)
+   goto err;
+   if ((utmp  0xF) = 0x07)
+   *status |= FE_HAS_SIGNAL;
+   if ((utmp  0xF) = 0x0a)
+   *status |= FE_HAS_CARRIER;
+   if ((utmp  0xF) = 0x0d)
+   *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
break;
case SYS_DVBC_ANNEX_A:
ret = regmap_read(dev-regmap[1], 0x84, utmp);
if (ret)
goto err;
+   if ((utmp  0xF) = 0x08)
+   lock = 1;
break;
default:
ret = -EINVAL;
goto err;
}
 
-   if (utmp == 0x08)
+   if (lock)
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
FE_HAS_SYNC | FE_HAS_LOCK;
 
-- 
2.1.0

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


Re: [PATCH] Basic support for the Elgato EyeTV Hybrid INT 2008 USB Stick

2015-03-01 Thread Benjamin Larsson

On 03/01/2015 04:04 PM, Gilles Risch wrote:

This patch will add basic support for the Elgato EyeTV Hybrid INT
2008 USB Stick.

Signed-off-by: Gilles Risch gilles.ri...@gmail.com



[...]


--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -41,7 +41,7 @@
  #include mt352.h
  #include mt352_priv.h /* FIXME */
  #include tda1002x.h
-#include drx39xyj/drx39xxj.h
+#include drx39xxj.h


This change looks unrelated.

The rest looks ok.

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


Re: Linux TV support Elgato EyeTV hybrid

2015-02-23 Thread Benjamin Larsson

On 02/23/2015 09:24 PM, Gilles Risch wrote:

On 02/22/2015 10:29 PM, Antti Palosaari wrote:

On 02/22/2015 10:04 PM, Benjamin Larsson wrote:

On 02/22/2015 02:47 PM, Gilles Risch wrote:

[...]

[  141.423608] WARNING: You are using an experimental version of the
media stack.
[  141.423609] As the driver is backported to an older kernel, it
doesn't offer
[  141.423610] enough quality for its usage in production.
[  141.423611] Use it with care.
[  141.423612] Latest git patches (needed if you report a bug to
linux-media@vger.kernel.org):
[  141.423613] 135f9be9194cf7778eb73594aa55791b229cf27c [media]
dvb_frontend: start media pipeline while thread is running
[  141.423614] 0f0fa90bd035fa15106799b813d4f0315d99f47e [media]
cx231xx: enable tuner-decoder link at videobuf start
[  141.423615] 9239effd53d47e3cd9c653830c8465c0a3a427dc [media]
dvb-frontend: enable tuner link when the FE thread starts
[  141.424714] em2884 #0: Binding DVB extension
[  142.754917] usb 2-6: firmware: agent loaded
dvb-usb-hauppauge-hvr930c-drxk.fw into memory
[  142.765420] drxk: status = 0x639260d9
[  142.765430] drxk: detected a drx-3926k, spin A3, xtal 20.250 MHz
[  144.006316] drxk: DRXK driver version 0.9.4300
[  144.023065] drxk: frontend initialized.


The demod seems to initialize well.



[  144.042622] xc5000 11-0061: creating new instance
[  144.042938] xc5000: I2C read failed


The tuner does not initialize. What could be wrong is that the tuner 
might need to be powered on (pulling some gpio pin) or it resides on 
another i2c address then what the HVR-930C has it. Or something else.


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


Re: Linux TV support Elgato EyeTV hybrid

2015-02-23 Thread Benjamin Larsson

On 02/23/2015 11:54 PM, Gilles Risch wrote:

On 02/23/2015 09:36 PM, Benjamin Larsson wrote:

On 02/23/2015 09:24 PM, Gilles Risch wrote:

On 02/22/2015 10:29 PM, Antti Palosaari wrote:

On 02/22/2015 10:04 PM, Benjamin Larsson wrote:

On 02/22/2015 02:47 PM, Gilles Risch wrote:

[...]

Not sure if it helps, but I also tried:
 $ modprobe em28xx card=82
 $ modprobe xc5000
 $ echo 0fd9 0018  /sys/bus/usb/drivers/em28xx/new_id
 $ dmesg
[  142.728289] usb 8-6: new high-speed USB device number 3 using ehci_hcd
[  142.862556] usb 8-6: New USB device found, idVendor=0fd9, idProduct=0018
[  142.862565] usb 8-6: New USB device strings: Mfr=3, Product=1,
SerialNumber=2
[  142.862571] usb 8-6: Product: EyeTV Hybrid
[  142.862576] usb 8-6: Manufacturer: Elgato
[  142.862581] usb 8-6: SerialNumber: 100904010917
[  142.863146] em28xx: New device Elgato EyeTV Hybrid @ 480 Mbps
(0fd9:0018, interface 0, class 0)
[  142.863153] em28xx: Audio interface 0 found (Vendor Class)
[  142.863159] em28xx: Video interface 0 found: isoc
[  142.863163] em28xx: DVB interface 0 found: isoc
[  142.863993] em28xx: chip ID is em2884
[  142.927681] em2884 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0x1a01bca5
[  142.927688] em2884 #0: EEPROM info:
[  142.927694] em2884 #0: microcode start address = 0x0004, boot
configuration = 0x01
[  142.935299] em2884 #0: I2S audio, 5 sample rates
[  142.935306] em2884 #0: 500mA max power
[  142.935312] em2884 #0: Table at offset 0x27, strings=0x1a78,
0x1a92, 0x0e6a
[  142.935466] em2884 #0: Identified as Terratec Cinergy HTC Stick
(card=82)
[  142.935474] em2884 #0: analog set to isoc mode.
[  142.935478] em2884 #0: dvb set to isoc mode.
[  142.975149] em2884 #0: Binding audio extension
[  142.975152] em28xx-audio.c: Copyright (C) 2006 Markus Rechberger
[  142.975153] em28xx-audio.c: Copyright (C) 2007-2014 Mauro Carvalho
Chehab
[  142.975180] em2884 #0: Endpoint 0x83 high-speed on intf 0 alt 7
interval = 8, size 196
[  142.975184] em2884 #0: Number of URBs: 1, with 64 packets and 192 size
[  142.975537] em2884 #0: Audio extension successfully initialized
[  142.975540] em28xx: Registered (Em28xx Audio Extension) extension
[  143.003553] WARNING: You are using an experimental version of the
media stack.
[  143.003554] As the driver is backported to an older kernel, it
doesn't offer
[  143.003555] enough quality for its usage in production.
[  143.003556] Use it with care.
[  143.003556] Latest git patches (needed if you report a bug to
linux-media@vger.kernel.org):
[  143.003557] 135f9be9194cf7778eb73594aa55791b229cf27c [media]
dvb_frontend: start media pipeline while thread is running
[  143.003558] 0f0fa90bd035fa15106799b813d4f0315d99f47e [media]
cx231xx: enable tuner-decoder link at videobuf start
[  143.003560] 9239effd53d47e3cd9c653830c8465c0a3a427dc [media]
dvb-frontend: enable tuner link when the FE thread starts
[  143.010977] em2884 #0: Binding DVB extension
[  143.567751] usb 8-6: firmware: agent loaded
dvb-usb-terratec-htc-stick-drxk.fw into memory
[  143.585103] drxk: status = 0x639260d9
[  143.585113] drxk: detected a drx-3926k, spin A3, xtal 20.250 MHz
[  147.656822] drxk: DRXK driver version 0.9.4300
[  147.695203] drxk: frontend initialized.
[  147.764493] tda18271 11-0060: creating new instance
[  147.766552] TDA18271HD/C2 detected @ 11-0060


I am not sure how certain the TDA18271HD detection is but when I look at 
the images from here:


http://www.linuxtv.org/wiki/index.php/Elgato_EyeTV_hybrid

I don't see the tuner chip, so it could be a tda chip.


[  147.997562] DVB: registering new adapter (em2884 #0)
[  147.997571] usb 8-6: DVB: registering adapter 0 frontend 0 (DRXK
DVB-C DVB-T)...


This sounds good.


[  147.998567] em2884 #0: DVB extension successfully initialized
[  147.998571] em28xx: Registered (Em28xx dvb Extension) extension
[  148.023086] WARNING: You are using an experimental version of the
media stack.
[  148.023087] As the driver is backported to an older kernel, it
doesn't offer
[  148.023088] enough quality for its usage in production.
[  148.023089] Use it with care.
[  148.023089] Latest git patches (needed if you report a bug to
linux-media@vger.kernel.org):
[  148.023090] 135f9be9194cf7778eb73594aa55791b229cf27c [media]
dvb_frontend: start media pipeline while thread is running
[  148.023091] 0f0fa90bd035fa15106799b813d4f0315d99f47e [media]
cx231xx: enable tuner-decoder link at videobuf start
[  148.023092] 9239effd53d47e3cd9c653830c8465c0a3a427dc [media]
dvb-frontend: enable tuner link when the FE thread starts
[  148.034348] em2884 #0: Registering input extension
[  148.064107] Registered IR keymap rc-nec-terratec-cinergy-xs
[  148.064420] input: em28xx IR (em2884 #0) as
/devices/pci:00/:00:1d.7/usb8/8-6/rc/rc0/input11
[  148.064808] rc0: em28xx IR (em2884 #0) as
/devices/pci:00/:00:1d.7/usb8/8-6/rc/rc0
[  148.065325] em2884 #0: Input extension successfully

Re: Linux TV support Elgato EyeTV hybrid

2015-02-22 Thread Benjamin Larsson

On 02/22/2015 02:47 PM, Gilles Risch wrote:

Hi,

most of the used components are identified:
- USB Controller: Empia EM2884
- Stereo A/V Decoder: Micronas AVF 49x0B
- Hybrid Channel Decoder: Micronas DRX-K DRX3926K:A3 0.9.0
The only ambiguity is the tuner, but I think it could be a Xceive XC5000


This sounds like the Hauppauge WinTV HVR-930C:

http://linuxtv.org/wiki/index.php/Hauppauge_WinTV-HVR-930C


because the windows driver comprises the xc5000 firmware and it is 100%
identical:
 $ mkdir extract-xc5000-fw
 $ cd extract-xc5000-fw
 $ wget http://linuxtv.org/downloads/firmware/dvb-fe-xc5000-1.6.114.fw
 $ wget
http://elgatoweb.s3.amazonaws.com/Documents/Support/EyeTV_Hybrid/EyeTV_Hybrid_2008_509081301_W8.exe

 $ 7z -y e EyeTV_Hybrid_2008_509081301_W8.exe
 $ dd if=emBDA.sys of=dvb-fe-xc5000-test.fw bs=1 skip=518800
count=12401 /dev/null 21
 $ md5sum dvb-fe-xc5000-1.6.114.fw dvb-fe-xc5000-test.fw
 b1ac8f759020523ebaaeff3fdf4789ed  dvb-fe-xc5000-1.6.114.fw
 b1ac8f759020523ebaaeff3fdf4789ed  dvb-fe-xc5000-test.fw

The Elgato_EyeTV_Hybrid.inf file contains a comment with TerraTec H5,
which components are assembled on that USB stick?


The TerraTec H5 has a TDA18271 tuner.




Regards,
Gilles



So most likely the Elgato EyeTV hybrid is one of these combinations. And 
it should quite feasible to add support for someone who knows the Empia 
EM2884.


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


Re: [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2015-02-19 Thread Benjamin Larsson

On 2014-12-06 01:25, Benjamin Larsson wrote:

The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
  drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 705c6c3..9ec4223 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1567,7 +1567,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device 
*d,
rc-allowed_protos = RC_BIT_ALL;
rc-driver_type = RC_DRIVER_IR_RAW;
rc-query = rtl2832u_rc_query;
-   rc-interval = 400;
+   rc-interval = 200;

return 0;
  }



Ping, can I get an ack or nack on this ?

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


Re: [RFC PATCH] mn88472: reduce firmware download chunk size

2015-02-19 Thread Benjamin Larsson

On 2015-02-19 11:21, Antti Seppälä wrote:

On 19 February 2015 at 11:43, Benjamin Larsson benja...@southpole.se wrote:

On 2015-02-19 10:13, Antti Seppälä wrote:


It seems that currently the firmware download on the mn88472 is
somehow wrong for my Astrometa HD-901T2.

Reducing the download chunk size (mn88472_config.i2c_wr_max) to 2
makes the firmware download consistently succeed.




Hi, try adding the workaround patch I sent for this.

[PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

I now see that it hasn't been merged. But I have been running with this
patch for a few months now without any major issues.



The patch really did improve firmware loading. Weird...

Even with it I still get occasional i2c errors from r820t:

[   15.874402] r820t 8-003a: r820t_write: i2c wr failed=-32 reg=0a len=1: da
[   81.455517] r820t 8-003a: r820t_read: i2c rd failed=-32 reg=00
len=4: 69 74 e6 df
[   99.949702] r820t 8-003a: r820t_read: i2c rd failed=-32 reg=00
len=4: 69 74 e6 df

These errors seem to appear more often if I'm reading the signal
strength values using e.g. femon.

Br,
-Antti



This patch implements a retry logic. If a transfer fails it will convert 
it to 1 byte transfers. This will not work when loading the nm88472 
firmware as everything is loaded through the 0xf6 register.


I think we might need something like this to get the Astrometa working 
reliably.


Based on usb logs from the windows driver one can see that they only 
send 1 byte at a time so they can retry all transfers. So this issue 
seems to be related to the rtl2832p bridge chip and how much i2c traffic 
is generated.


MvH
Benjamin Larsson
From 5962cf8fafdfe98138fd69beb4d0b5d2a7af5732 Mon Sep 17 00:00:00 2001
From: Benjamin Larsson benja...@southpole.se
Date: Thu, 20 Nov 2014 00:50:02 +0100
Subject: [PATCH] rtl28xxu: implement i2c transfer retry logic
Cc: Linux Media Mailing List linux-media@vger.kernel.org

This is needed for Astrometa hardware. Retry counts up to 6 has been
observered before the i2c transfer succeded.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 4af8a61..4d321ae 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -185,6 +185,8 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
 	struct rtl28xxu_priv *priv = d-priv;
 	struct rtl28xxu_req req;
+	u8 rb_buf[2];
+	int i, retry_cnt;
 
 	/*
 	 * It is not known which are real I2C bus xfer limits, but testing
@@ -273,6 +275,33 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 			req.size = msg[0].len-1;
 			req.data = msg[0].buf[1];
 			ret = rtl28xxu_ctrl_msg(d, req);
+
+			/* Astrometa hardware needs a retry for some failed transfers.
+			 * Just send one byte at the time.
+			 * Retry max 10 times for each transfer.
+			 */
+			if (ret) {
+req.size = 1;
+req.data = rb_buf;
+
+dev_dbg(d-udev-dev, %s: transfer of %d bytes failed\n, __func__, msg[0].len-1);
+rb_buf[0] = msg[0].buf[0];
+
+for (i=0 ; imsg[0].len-1 ; i++) {
+	retry_cnt = 0;
+	req.value = ((msg[0].buf[0]+i)  8) | (msg[0].addr  1);
+	rb_buf[0] = msg[0].buf[i+1];
+
+	do {
+		dev_dbg(d-udev-dev, %s: byte: %d retry: %d\n, __func__, i, retry_cnt);
+		ret = rtl28xxu_ctrl_msg(d, req);
+		retry_cnt++;
+		if (retry_cnt  10)
+			goto err_mutex_unlock;
+
+	} while (ret);
+}
+			}
 		} else {
 			/* method 3 - new I2C */
 			req.value = (msg[0].addr  1);
-- 
1.9.1



Re: [RFC PATCH] mn88472: reduce firmware download chunk size

2015-02-19 Thread Benjamin Larsson

On 2015-02-19 10:13, Antti Seppälä wrote:

It seems that currently the firmware download on the mn88472 is
somehow wrong for my Astrometa HD-901T2.

Reducing the download chunk size (mn88472_config.i2c_wr_max) to 2
makes the firmware download consistently succeed.




Hi, try adding the workaround patch I sent for this.

[PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

I now see that it hasn't been merged. But I have been running with this 
patch for a few months now without any major issues.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] r820t: add DVBC profile in sysfreq_sel

2015-02-17 Thread Benjamin Larsson
Forgot to say that with this patch the Astrometa DVB-T/T2/C usb stick 
now has working DVB-C reception at all the frequencies I have at home. 
Before it was not working at around 290-314 MHz.


The current status of the Astrometa stick is that DVB-T and DVB-C (8MHz 
tested, 6MHz testers wanted) should be working fine. DVB-T2 needs 
working pid filters before it can work properly.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] r820t: add DVBC profile in sysfreq_sel

2015-02-14 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 8e040cf..639c220 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -775,6 +775,19 @@ static int r820t_sysfreq_sel(struct r820t_priv *priv, u32 
freq,
div_buf_cur = 0x30; /* 11, 150u */
filter_cur = 0x40;  /* 10, low */
break;
+   case SYS_DVBC_ANNEX_A:
+   mixer_top = 0x24;   /* mixer top:13 , top-1, low-discharge 
*/
+   lna_top = 0xe5;
+   lna_vth_l = 0x62;
+   mixer_vth_l = 0x75;
+   air_cable1_in = 0x60;
+   cable2_in = 0x00;
+   pre_dect = 0x40;
+   lna_discharge = 14;
+   cp_cur = 0x38;  /* 111, auto */
+   div_buf_cur = 0x30; /* 11, 150u */
+   filter_cur = 0x40;  /* 10, low */
+   break;
default: /* DVB-T 8M */
mixer_top = 0x24;   /* mixer top:13 , top-1, low-discharge 
*/
lna_top = 0xe5; /* detect bw 3, lna top:4, predet top:2 
*/
-- 
2.1.0

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


Re: Sundtek Media Pro III Europe switching off

2015-02-01 Thread Benjamin Larsson

On 02/01/2015 11:12 AM, steigerungs faktor wrote:

Hi.
New to the list, so maybe topic Sundtek Media Pro III has been treatet
allready.
If so, please just send archives.

If not:
Setup is the the above Stick, newest driver, Linux (Fedora 20), Kodi
with TVHeadend.
All fine when initially starting. Shows TV and records shows.
Then Timer is set, and stick 'stops working'. I.e.: the timed show is
not recorded.
Instead Kodi tells me that connection to tvheadend is lost.
To gain stick back, reboot is necessary.

Any ideas?

Gunter


Try asking for support in the Sundtek forums.

http://support.sundtek.com/

MvH
Benjamin Larsson

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


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2015-01-19 Thread Benjamin Larsson

On 01/19/2015 02:15 PM, Hans Verkuil wrote:

On 12/06/2014 09:26 PM, Benjamin Larsson wrote:


Well I guess I am biased as I have spent lots of time finding a bug that
probably wouldn't exist if the policy was that drivers always should set
their memory to zero before it is free'd.


Just because you zero memory before it is freed doesn't mean it stays zeroed.
As soon as it is freed some other process might take that memory and fill it
up again. So zeroing is pointless and in fact will only *hide* bugs.



Well in this specific case NOT zeroing the memory it actually hid a use 
after free bug. So stating that it is pointless and that it will only 
hide bugs is not correct at least for this case.


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


[PATCH 1/2] r820t: enable flt_ext_wide for SYS_DVBC_ANNEX_A standard

2015-01-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 8e040cf..c94c6a3 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -969,7 +969,7 @@ static int r820t_set_tv_standard(struct r820t_priv *priv,
ext_enable = 0x40;  /* r30[6]=1 ext enable; r30[5]:1 ext at 
lna max-1 */
loop_through = 0x00;/* r5[7], lt on */
lt_att = 0x00;  /* r31[7], lt att enable */
-   flt_ext_widest = 0x00;  /* r15[7]: flt_ext_wide off */
+   flt_ext_widest = 0x80;  /* r15[7]: flt_ext_wide on */
polyfil_cur = 0x60; /* r25[6:5]:min */
} else {
if (bw = 6) {
-- 
2.1.0

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


[PATCH 2/2] r820t: add settings for SYS_DVBC_ANNEX_C standard

2015-01-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index c94c6a3..b4c85ba 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -971,6 +971,18 @@ static int r820t_set_tv_standard(struct r820t_priv *priv,
lt_att = 0x00;  /* r31[7], lt att enable */
flt_ext_widest = 0x80;  /* r15[7]: flt_ext_wide on */
polyfil_cur = 0x60; /* r25[6:5]:min */
+   } else if (delsys == SYS_DVBC_ANNEX_C) {
+   if_khz = 4063;
+   filt_cal_lo = 55000;
+   filt_gain = 0x10;   /* +3db, 6mhz on */
+   img_r = 0x00;   /* image negative */
+   filt_q = 0x10;  /* r10[4]:low q(1'b1) */
+   hp_cor = 0x6a;  /* 1.7m disable, +0cap, 1.0mhz */
+   ext_enable = 0x40;  /* r30[6]=1 ext enable; r30[5]:1 ext at 
lna max-1 */
+   loop_through = 0x00;/* r5[7], lt on */
+   lt_att = 0x00;  /* r31[7], lt att enable */
+   flt_ext_widest = 0x80;  /* r15[7]: flt_ext_wide on */
+   polyfil_cur = 0x60; /* r25[6:5]:min */
} else {
if (bw = 6) {
if_khz = 3570;
-- 
2.1.0

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


[PATCH 2/2] mn88473: simplify bandwidth registers setting code

2015-01-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88473/mn88473.c | 27 ++-
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index b65e519..994294c 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -59,28 +59,13 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   switch (c-delivery_system) {
-   case SYS_DVBT:
-   case SYS_DVBT2:
-   if (c-bandwidth_hz = 600) {
-   /* IF 357 Hz, BW 600 Hz */
-   memcpy(bw_val, \xe9\x55\x55\x1c\x29\x1c\x29, 7);
-   } else if (c-bandwidth_hz = 700) {
-   /* IF 457 Hz, BW 700 Hz */
-   memcpy(bw_val, \xc8\x00\x00\x17\x0a\x17\x0a, 7);
-   } else if (c-bandwidth_hz = 800) {
-   /* IF 457 Hz, BW 800 Hz */
-   memcpy(bw_val, \xaf\x00\x00\x11\xec\x11\xec, 7);
-   } else {
-   ret = -EINVAL;
-   goto err;
-   }
-   break;
-   case SYS_DVBC_ANNEX_A:
-   /* IF 507 Hz, BW 800 Hz */
+   if (c-bandwidth_hz = 600) {
+   memcpy(bw_val, \xe9\x55\x55\x1c\x29\x1c\x29, 7);
+   } else if (c-bandwidth_hz = 700) {
+   memcpy(bw_val, \xc8\x00\x00\x17\x0a\x17\x0a, 7);
+   } else if (c-bandwidth_hz = 800) {
memcpy(bw_val, \xaf\x00\x00\x11\xec\x11\xec, 7);
-   break;
-   default:
+   } else {
ret = -EINVAL;
goto err;
}
-- 
2.1.0

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


[PATCH 1/2] mn88473: calculate the IF register values

2015-01-12 Thread Benjamin Larsson
Add xtal as a configuration parameter so it can be used
in the IF register value calculation. If not set in the
configuration then use a default value.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/dvb-frontends/mn88473.h|  6 ++
 drivers/staging/media/mn88473/mn88473.c  | 26 +++---
 drivers/staging/media/mn88473/mn88473_priv.h |  1 +
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/media/dvb-frontends/mn88473.h 
b/drivers/media/dvb-frontends/mn88473.h
index a373ec9..c717ebed 100644
--- a/drivers/media/dvb-frontends/mn88473.h
+++ b/drivers/media/dvb-frontends/mn88473.h
@@ -33,6 +33,12 @@ struct mn88473_config {
 * DVB frontend.
 */
struct dvb_frontend **fe;
+
+   /*
+* Xtal frequency.
+* Hz
+*/
+   u32 xtal;
 };
 
 #endif
diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index 1659335..b65e519 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -30,6 +30,7 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret, i;
u32 if_frequency;
+   u64 tmp;
u8 delivery_system_val, if_val[3], bw_val[7];
 
dev_dbg(client-dev,
@@ -63,15 +64,12 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
case SYS_DVBT2:
if (c-bandwidth_hz = 600) {
/* IF 357 Hz, BW 600 Hz */
-   memcpy(if_val, \x24\x8e\x8a, 3);
memcpy(bw_val, \xe9\x55\x55\x1c\x29\x1c\x29, 7);
} else if (c-bandwidth_hz = 700) {
/* IF 457 Hz, BW 700 Hz */
-   memcpy(if_val, \x2e\xcb\xfb, 3);
memcpy(bw_val, \xc8\x00\x00\x17\x0a\x17\x0a, 7);
} else if (c-bandwidth_hz = 800) {
/* IF 457 Hz, BW 800 Hz */
-   memcpy(if_val, \x2e\xcb\xfb, 3);
memcpy(bw_val, \xaf\x00\x00\x11\xec\x11\xec, 7);
} else {
ret = -EINVAL;
@@ -80,7 +78,6 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
break;
case SYS_DVBC_ANNEX_A:
/* IF 507 Hz, BW 800 Hz */
-   memcpy(if_val, \x33\xea\xb3, 3);
memcpy(bw_val, \xaf\x00\x00\x11\xec\x11\xec, 7);
break;
default:
@@ -105,17 +102,12 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
if_frequency = 0;
}
 
-   switch (if_frequency) {
-   case 357:
-   case 457:
-   case 507:
-   break;
-   default:
-   dev_err(client-dev, IF frequency %d not supported\n,
-   if_frequency);
-   ret = -EINVAL;
-   goto err;
-   }
+   /* Calculate IF registers ( (124)*IF / Xtal ) */
+   tmp =  div_u64(if_frequency * (u64)(124) + (dev-xtal / 2),
+  dev-xtal);
+   if_val[0] = ((tmp  16)  0xff);
+   if_val[1] = ((tmp   8)  0xff);
+   if_val[2] = ((tmp   0)  0xff);
 
ret = regmap_write(dev-regmap[2], 0x05, 0x00);
ret = regmap_write(dev-regmap[2], 0xfb, 0x13);
@@ -352,6 +344,10 @@ static int mn88473_probe(struct i2c_client *client,
}
 
dev-i2c_wr_max = config-i2c_wr_max;
+   if (!config-xtal)
+   dev-xtal = 2500;
+   else
+   dev-xtal = config-xtal;
dev-client[0] = client;
dev-regmap[0] = regmap_init_i2c(dev-client[0], regmap_config);
if (IS_ERR(dev-regmap[0])) {
diff --git a/drivers/staging/media/mn88473/mn88473_priv.h 
b/drivers/staging/media/mn88473/mn88473_priv.h
index 78af112..ef6f013 100644
--- a/drivers/staging/media/mn88473/mn88473_priv.h
+++ b/drivers/staging/media/mn88473/mn88473_priv.h
@@ -31,6 +31,7 @@ struct mn88473_dev {
u16 i2c_wr_max;
fe_delivery_system_t delivery_system;
bool warm; /* FW running */
+   u32 xtal;
 };
 
 #endif
-- 
2.1.0

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


[PATCH 1/1] rtl28xxu: swap frontend order for devices with slave demodulators

2015-01-02 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ab48b5f..37f8825 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -863,6 +863,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
 
/* attach slave demodulator */
if (priv-slave_demod == SLAVE_DEMOD_MN88472) {
+   struct dvb_frontend *tmp_fe;
struct mn88472_config mn88472_config = {};
 
mn88472_config.fe = adap-fe[1];
@@ -887,7 +888,13 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
}
 
priv-i2c_client_slave_demod = client;
+
+   /* Swap frontend order */
+   tmp_fe = adap-fe[0];
+   adap-fe[0] = adap-fe[1];
+   adap-fe[1] = tmp_fe;
} else {
+   struct dvb_frontend *tmp_fe;
struct mn88473_config mn88473_config = {};
 
mn88473_config.fe = adap-fe[1];
@@ -909,6 +916,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
}
 
priv-i2c_client_slave_demod = client;
+
+   /* Swap frontend order */
+   tmp_fe = adap-fe[0];
+   adap-fe[0] = adap-fe[1];
+   adap-fe[1] = tmp_fe;
}
}
 
@@ -1144,12 +1156,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
rtl28xxu_rtl2832_r820t_config, NULL);
break;
case TUNER_RTL2832_R828D:
-   fe = dvb_attach(r820t_attach, adap-fe[0],
-   priv-demod_i2c_adapter,
-   rtl2832u_r828d_config);
-   adap-fe[0]-ops.read_signal_strength =
-   adap-fe[0]-ops.tuner_ops.get_rf_strength;
-
if (adap-fe[1]) {
fe = dvb_attach(r820t_attach, adap-fe[1],
priv-demod_i2c_adapter,
@@ -1158,6 +1164,12 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)

adap-fe[1]-ops.tuner_ops.get_rf_strength;
}
 
+   fe = dvb_attach(r820t_attach, adap-fe[0],
+   priv-demod_i2c_adapter,
+   rtl2832u_r828d_config);
+   adap-fe[0]-ops.read_signal_strength =
+   adap-fe[0]-ops.tuner_ops.get_rf_strength;
+
/* attach SDR */
dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_r820t_config, NULL);
@@ -1373,7 +1385,7 @@ static int rtl2832u_frontend_ctrl(struct dvb_frontend 
*fe, int onoff)
 
/* bypass slave demod TS through master demod */
if (fe-id == 1  onoff) {
-   ret = rtl2832_enable_external_ts_if(adap-fe[0]);
+   ret = rtl2832_enable_external_ts_if(adap-fe[1]);
if (ret)
goto err;
}
-- 
1.9.1

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


[PATCH] mn88472: simplify bandwidth registers setting code

2015-01-02 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 41 +++--
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 33604dc..ee933c3 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -58,35 +58,22 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   switch (c-delivery_system) {
-   case SYS_DVBT:
-   case SYS_DVBT2:
-   if (c-bandwidth_hz = 500) {
-   memcpy(bw_val, \xe5\x99\x9a\x1b\xa9\x1b\xa9, 7);
-   bw_val2 = 0x03;
-   } else if (c-bandwidth_hz = 600) {
-   /* IF 357 Hz, BW 600 Hz */
-   memcpy(bw_val, \xbf\x55\x55\x15\x6b\x15\x6b, 7);
-   bw_val2 = 0x02;
-   } else if (c-bandwidth_hz = 700) {
-   /* IF 457 Hz, BW 700 Hz */
-   memcpy(bw_val, \xa4\x00\x00\x0f\x2c\x0f\x2c, 7);
-   bw_val2 = 0x01;
-   } else if (c-bandwidth_hz = 800) {
-   /* IF 457 Hz, BW 800 Hz */
-   memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
-   bw_val2 = 0x00;
-   } else {
-   ret = -EINVAL;
-   goto err;
-   }
-   break;
-   case SYS_DVBC_ANNEX_A:
-   /* IF 507 Hz, BW 800 Hz */
+   if (c-bandwidth_hz = 500) {
+   memcpy(bw_val, \xe5\x99\x9a\x1b\xa9\x1b\xa9, 7);
+   bw_val2 = 0x03;
+   } else if (c-bandwidth_hz = 600) {
+   /* IF 357 Hz, BW 600 Hz */
+   memcpy(bw_val, \xbf\x55\x55\x15\x6b\x15\x6b, 7);
+   bw_val2 = 0x02;
+   } else if (c-bandwidth_hz = 700) {
+   /* IF 457 Hz, BW 700 Hz */
+   memcpy(bw_val, \xa4\x00\x00\x0f\x2c\x0f\x2c, 7);
+   bw_val2 = 0x01;
+   } else if (c-bandwidth_hz = 800) {
+   /* IF 457 Hz, BW 800 Hz */
memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
bw_val2 = 0x00;
-   break;
-   default:
+   } else {
ret = -EINVAL;
goto err;
}
-- 
1.9.1

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


Re: [RFC][PATCH] mn88472: add support for the mn88473 demod

2014-12-30 Thread Benjamin Larsson

On 12/21/2014 10:21 AM, Antti Palosaari wrote:

Moikka!


[...]



You patch looks rather good and these drivers should be merged to one if
possible, lets say registers are 80% same or something like that. Looks
like those are.


I've dropped this effort, the chips registers are not similar enough. 
The code that could be shared is not enough to give any advantage over 2 
drivers.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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 48/66] rtl28xxu: use master I2C adapter for slave demods

2014-12-23 Thread Benjamin Larsson

On 12/23/2014 09:49 PM, Antti Palosaari wrote:

Both mn88472 and mn88473 slave demods are connected to master I2C
bus, not the bus behind master demod I2C gate like tuners. Use
correct bus.



Hello Antti, in my work tree I am still getting i2c errors even with the 
ir poll workaround (it takes really long time to get them). If I reload 
the rtl28xxu driver 2 times it starts working again. Could this change 
be related to such errors ?


MvH
Benjamin Larsson

--
To unsubscribe from this list: send the line unsubscribe 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] mn88472: add support for the mn88473 demod

2014-12-20 Thread Benjamin Larsson
Factor out the bw_val data to a table and load data from it
depending on the configured demod.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/dvb-frontends/mn88472.h| 30 +
 drivers/staging/media/mn88472/mn88472.c  | 66 ++--
 drivers/staging/media/mn88472/mn88472_priv.h |  1 +
 3 files changed, 64 insertions(+), 33 deletions(-)

diff --git a/drivers/media/dvb-frontends/mn88472.h 
b/drivers/media/dvb-frontends/mn88472.h
index f0fdc7e..0016f7b 100644
--- a/drivers/media/dvb-frontends/mn88472.h
+++ b/drivers/media/dvb-frontends/mn88472.h
@@ -29,6 +29,35 @@ enum ts_mode {
PARALLEL_TS_MODE,
 };
 
+enum model {
+   MODEL_MN88472,
+   MODEL_MN88473,
+   MODEL_MAX,
+};
+
+enum bw_modes {
+   BW_5MHZ,
+   BW_6MHZ,
+   BW_7MHZ,
+   BW_8MHZ,
+   BW_MODE_MAX,
+};
+
+/* close to y=freq*4.5714285 */
+static u32 ad_frequency_factor[BW_MODE_MAX] = {
+   0x15CC5B6,  /* 5MHz */
+   0x1A286DC,  /* 6MHz */
+   0x1E84800,  /* 7MHz */
+   0x22E0925,  /* 8MHz */
+};
+
+static u8 bw_param[MODEL_MAX][BW_MODE_MAX][2] = {
+   { { 0x1b, 0xa9 }, { 0x00, 0x00 } }, /* 5MHz */
+   { { 0x15, 0x6b }, { 0x1c, 0x29 } }, /* 6MHz */
+   { { 0x0f, 0x2c }, { 0x17, 0x0a } }, /* 7MHz */
+   { { 0x08, 0xee }, { 0x11, 0xec } }, /* 8MHz */
+};
+
 struct mn88472_config {
/*
 * Max num of bytes given I2C adapter could write at once.
@@ -53,6 +82,7 @@ struct mn88472_config {
u32 xtal;
int ts_mode;
int ts_clock;
+   int model;
 };
 
 #endif
diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 8b35639..77ed941 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -28,10 +28,10 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
struct i2c_client *client = fe-demodulator_priv;
struct mn88472_dev *dev = i2c_get_clientdata(client);
struct dtv_frontend_properties *c = fe-dtv_property_cache;
-   int ret, i;
+   int ret, i, bw;
u64 tmp;
-   u8 delivery_system_val, if_val[3], bw_val[7], bw_val2;
+   u8 delivery_system_val, if_val[3], ad_val[3], bw_val2;
 
dev_dbg(client-dev, %s:\n, __func__);
dev_dbg(client-dev,
@@ -59,35 +59,20 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   switch (c-delivery_system) {
-   case SYS_DVBT:
-   case SYS_DVBT2:
-   if (c-bandwidth_hz = 500) {
-   memcpy(bw_val, \xe5\x99\x9a\x1b\xa9\x1b\xa9, 7);
-   bw_val2 = 0x03;
-   } else if (c-bandwidth_hz = 600) {
-   /* IF 357 Hz, BW 600 Hz */
-   memcpy(bw_val, \xbf\x55\x55\x15\x6b\x15\x6b, 7);
-   bw_val2 = 0x02;
-   } else if (c-bandwidth_hz = 700) {
-   /* IF 457 Hz, BW 700 Hz */
-   memcpy(bw_val, \xa4\x00\x00\x0f\x2c\x0f\x2c, 7);
-   bw_val2 = 0x01;
-   } else if (c-bandwidth_hz = 800) {
-   /* IF 457 Hz, BW 800 Hz */
-   memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
-   bw_val2 = 0x00;
-   } else {
-   ret = -EINVAL;
-   goto err;
-   }
-   break;
-   case SYS_DVBC_ANNEX_A:
-   /* IF 507 Hz, BW 800 Hz */
-   memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
+   /* bw related parameters */
+   if (c-bandwidth_hz = 500) {
+   bw = BW_5MHZ;
+   bw_val2 = 0x03;
+   } else if (c-bandwidth_hz = 600) {
+   bw = BW_6MHZ;
+   bw_val2 = 0x02;
+   } else if (c-bandwidth_hz = 700) {
+   bw = BW_7MHZ;
+   bw_val2 = 0x01;
+   } else if (c-bandwidth_hz = 800) {
+   bw = BW_8MHZ;
bw_val2 = 0x00;
-   break;
-   default:
+   } else {
ret = -EINVAL;
goto err;
}
@@ -114,6 +99,14 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
if_val[1] = ((tmp   8)  0xff);
if_val[2] = ((tmp   0)  0xff);
 
+   /* Calculate A/D frequency registers (Xtal * ad_freq_fac) */
+   tmp =  div_u64(dev-xtal * (u64)(124) +
+((dev-xtal * (u64)(124))/ 2),
+  ad_frequency_factor[bw] );
+   ad_val[0] = ((tmp  16)  0xff);
+   ad_val[1] = ((tmp   8)  0xff);
+   ad_val[2] = ((tmp   0)  0xff);
+
ret = regmap_write(dev-regmap[2], 0xfb, 0x13);
ret = regmap_write(dev-regmap[2], 0xef, 0x13);
ret = regmap_write(dev-regmap[2], 0xf9, 0x13);
@@ -142,12 +135,19 @@ static int

Re: [RFC][PATCH] mn88472: add support for the mn88473 demod

2014-12-20 Thread Benjamin Larsson
This is what mn88473 support in the mn88472 demod driver could look 
like. The code is untested but will look similar in the final version. 
It is also possible to let the driver figure out the demod version from 
the 0xff register. Then the users would not need to set that parameter. 
Same goes to the xtal parameter.


So does the mn88473 support look ok and should the driver figure out 
what demod is connected ?


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


[PATCH v2] mn88472: implement lock for all delivery systems

2014-12-16 Thread Benjamin Larsson
The increase of the lock timeout is needed for dvb-t2.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 68f5036..4ddeb09 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -19,7 +19,7 @@
 static int mn88472_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *s)
 {
-   s-min_delay_ms = 400;
+   s-min_delay_ms = 800;
return 0;
 }
 
@@ -238,6 +238,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
unsigned int utmp;
+   int lock = 0;
 
*status = 0;
 
@@ -248,21 +249,36 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
 
switch (c-delivery_system) {
case SYS_DVBT:
+   ret = regmap_read(dev-regmap[0], 0x7F, utmp);
+   if (ret)
+   goto err;
+   if ((utmp  0xF) = 0x09)
+   lock = 1;
+   break;
case SYS_DVBT2:
-   /* FIXME: implement me */
-   utmp = 0x08; /* DVB-C lock value */
+   ret = regmap_read(dev-regmap[2], 0x92, utmp);
+   if (ret)
+   goto err;
+   if ((utmp  0xF) = 0x07)
+   *status |= FE_HAS_SIGNAL;
+   if ((utmp  0xF) = 0x0a)
+   *status |= FE_HAS_CARRIER;
+   if ((utmp  0xF) = 0x0d)
+   *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
break;
case SYS_DVBC_ANNEX_A:
ret = regmap_read(dev-regmap[1], 0x84, utmp);
if (ret)
goto err;
+   if ((utmp  0xF) = 0x08)
+   lock = 1;
break;
default:
ret = -EINVAL;
goto err;
}
 
-   if (utmp == 0x08)
+   if (lock)
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
FE_HAS_SYNC | FE_HAS_LOCK;
 
-- 
1.9.1

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


Re: [PATCH] mn88472: implement lock for all delivery systems

2014-12-16 Thread Benjamin Larsson

Hello.

On 12/16/2014 04:34 AM, Antti Palosaari wrote:

Moikka!

On 12/16/2014 01:40 AM, Benjamin Larsson wrote:

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
  drivers/staging/media/mn88472/mn88472.c | 23 ---
  1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c

index 68f5036..426f0ed 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -238,6 +238,7 @@ static int mn88472_read_status(struct 
dvb_frontend *fe, fe_status_t *status)

  struct dtv_frontend_properties *c = fe-dtv_property_cache;
  int ret;
  unsigned int utmp;
+int lock = 0;

  *status = 0;

@@ -248,21 +249,37 @@ static int mn88472_read_status(struct 
dvb_frontend *fe, fe_status_t *status)


  switch (c-delivery_system) {
  case SYS_DVBT:
+ret = regmap_read(dev-regmap[0], 0x7F, utmp);
+if (ret)
+goto err;
+if ((utmp0xF)  8)


You didn't read Kernel coding style doc?

around line 206 Documentation/CodingStyle
---
Use one space around (on each side of) most binary and ternary operators,
such as any of these:

=  +  -  *  /  %  |^  =  =  == !=  ?  :
---


Fixed.




+lock = 1;
+break;
  case SYS_DVBT2:
-/* FIXME: implement me */
-utmp = 0x08; /* DVB-C lock value */
+msleep(150);


This sleep does not look correct. Why it is here? In order to provide 
more time for lock waiting? In that case you must increase 
.get_tune_settings() timeout. On some other case you will need to add 
comment why such strange thing is needed.


Increased.




+ret = regmap_read(dev-regmap[2], 0x92, utmp);
+if (ret)
+goto err;
+if ((utmp0xF) = 0x07)
+*status |= FE_HAS_SIGNAL;
+if ((utmp0xF) = 0x0a)
+*status |= FE_HAS_CARRIER;
+if ((utmp0xF) = 0x0d)
+*status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
  break;
  case SYS_DVBC_ANNEX_A:
  ret = regmap_read(dev-regmap[1], 0x84, utmp);
  if (ret)
  goto err;
+if ((utmp0xF)  7)
+lock = 1;
  break;
  default:
  ret = -EINVAL;
  goto err;
  }

-if (utmp == 0x08)
+if (lock)
  *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
  FE_HAS_SYNC | FE_HAS_LOCK;


Antti



Sent v2 patch.

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] mn88472: implement lock for all delivery systems

2014-12-15 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 68f5036..426f0ed 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -238,6 +238,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
unsigned int utmp;
+   int lock = 0;
 
*status = 0;
 
@@ -248,21 +249,37 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
 
switch (c-delivery_system) {
case SYS_DVBT:
+   ret = regmap_read(dev-regmap[0], 0x7F, utmp);
+   if (ret)
+   goto err;
+   if ((utmp0xF)  8)
+   lock = 1;
+   break;
case SYS_DVBT2:
-   /* FIXME: implement me */
-   utmp = 0x08; /* DVB-C lock value */
+   msleep(150);
+   ret = regmap_read(dev-regmap[2], 0x92, utmp);
+   if (ret)
+   goto err;
+   if ((utmp0xF) = 0x07)
+   *status |= FE_HAS_SIGNAL;
+   if ((utmp0xF) = 0x0a)
+   *status |= FE_HAS_CARRIER;
+   if ((utmp0xF) = 0x0d)
+   *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
break;
case SYS_DVBC_ANNEX_A:
ret = regmap_read(dev-regmap[1], 0x84, utmp);
if (ret)
goto err;
+   if ((utmp0xF)  7)
+   lock = 1;
break;
default:
ret = -EINVAL;
goto err;
}
 
-   if (utmp == 0x08)
+   if (lock)
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
FE_HAS_SYNC | FE_HAS_LOCK;
 
-- 
1.9.1

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


Re: [PATCH 2/4] rtl28xxu: swap frontend order for devices with slave demodulators

2014-12-13 Thread Benjamin Larsson

On 12/13/2014 05:02 AM, Antti Palosaari wrote:
I am not sure even idea of that. You didn't add even commit 
description, like all the other patches too :( You should really start 
adding commit messages explaining why and how commit is.


So the question is why that patch should be applied?


Lots of legacy applications doesn't set the frontend number and use 0 by 
default. For me to use w_scan I need this change. If that is reason good 
enough I can amend that to the commit message and resend?




On the other-hand, how there is
if (fe-id == 1  onoff) {
... as I don't remember any patch changing it to 0. I look my tree FE 
ID is 0. Do you have some unpublished hacks?


No hacks, it works for me that way.



Antti

MvH
Benjamin Larsson


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


Re: [PATCH 4/4] mn88472: implemented ber reporting

2014-12-13 Thread Benjamin Larsson

On 12/13/2014 05:15 AM, Antti Palosaari wrote:

On 12/13/2014 02:18 AM, Benjamin Larsson wrote:

Signed-off-by: Benjamin Larsson benja...@southpole.se


Reviewed-by: Antti Palosaari cr...@iki.fi


Even I could accept that, as a staging driver, I see there some issues:

* missing commit message (ok, it is trivial and patch subject says)

* it is legacy DVBv3 API BER reporting, whilst driver is DVBv5 mostly 
due to DVB-T2... So DVBv5 statistics are preferred.


* dynamic debugs has unneded __func__,  see 
Documentation/dynamic-debug-howto.txt


* there should be spaces used around binary and ternary calculation 
operators, see Documentation/CodingStyle for more info how it should be.



Could you read overall these two docs before make new patches:
Documentation/CodingStyle
Documentation/dynamic-debug-howto.txt

also use scripts/checkpatch.pl to verify patch, like that
git diff | ./scripts/checkpatch.pl -

regards
Antti


I will read those. Can you recommend a driver as template for DVBv5 
statistics ?


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


Re: [PATCH 1/4] mn88472: implement dvb-t signal lock

2014-12-13 Thread Benjamin Larsson

On 12/13/2014 04:52 AM, Antti Palosaari wrote:
That breaks DVB-C lock check as old utmp = 0x08 was set according to 
DVB-C lock check, right?


Antti


I have a dvb-c setup now. I will respin this patch with dvb-c support 
tested properly.


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


Re: [PATCH 2/4] rtl28xxu: swap frontend order for devices with slave demodulators

2014-12-13 Thread Benjamin Larsson

On 12/13/2014 02:35 PM, Antti Palosaari wrote:



Do you understand that code at all?


No I can't really say I understand all the workings of the media api.



Now it is:
FE0 == (fe-id == 0) == RTL2832
FE1 == (fe-id == 1) == MN88472

you changed it to:
FE0 == (fe-id == 0) == MN88472
FE1 == (fe-id == 1) == RTL2832


I thought the rtl2832u_frontend_attach() actually attached the devices. 
Then the id's would have followed the frontend.





Then there is:

/* bypass slave demod TS through master demod */
if (fe-id == 1  onoff) {
ret = rtl2832_enable_external_ts_if(adap-fe[1]);
if (ret)
goto err;
}

After your change that code branch is taken when RTL2832 demod is 
activated / used. Shouldn't TS bypass enabled just opposite, when 
MN88472 is used



Antti



This intent of the patch was for better backwards compatibility with old 
software. This isn't strictly needed so consider the patch dropped.


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


[PATCH 3/4] mn88472: elaborate debug printout

2014-12-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 4d80046..746cc94 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -33,6 +33,7 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
u64 tmp;
u8 delivery_system_val, if_val[3], bw_val[7], bw_val2;
 
+   dev_dbg(client-dev, %s:\n, __func__);
dev_dbg(client-dev,
delivery_system=%d modulation=%d frequency=%d 
symbol_rate=%d inversion=%d\n,
c-delivery_system, c-modulation,
@@ -288,7 +289,7 @@ static int mn88472_init(struct dvb_frontend *fe)
u8 *fw_file = MN88472_FIRMWARE;
unsigned int csum;
 
-   dev_dbg(client-dev, \n);
+   dev_dbg(client-dev, %s:\n, __func__);
 
/* set cold state by default */
dev-warm = false;
@@ -371,7 +372,7 @@ static int mn88472_sleep(struct dvb_frontend *fe)
struct mn88472_dev *dev = i2c_get_clientdata(client);
int ret;
 
-   dev_dbg(client-dev, \n);
+   dev_dbg(client-dev, %s:\n, __func__);
 
/* power off */
ret = regmap_write(dev-regmap[2], 0x0b, 0x30);
-- 
1.9.1

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


[PATCH 1/4] mn88472: implement dvb-t signal lock

2014-12-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 107552a..4d80046 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -238,6 +238,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
unsigned int utmp;
+   int lock = 0;
 
*status = 0;
 
@@ -248,6 +249,12 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
 
switch (c-delivery_system) {
case SYS_DVBT:
+   ret = regmap_read(dev-regmap[0], 0x7F, utmp);
+   if (ret)
+   goto err;
+   if ((utmp0xF)  8)
+   lock = 1;
+   break;
case SYS_DVBT2:
/* FIXME: implement me */
utmp = 0x08; /* DVB-C lock value */
@@ -262,7 +269,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
goto err;
}
 
-   if (utmp == 0x08)
+   if (lock)
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI |
FE_HAS_SYNC | FE_HAS_LOCK;
 
-- 
1.9.1

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


[PATCH 2/4] rtl28xxu: swap frontend order for devices with slave demodulators

2014-12-12 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index ab48b5f..cdc342a 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -863,6 +863,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
 
/* attach slave demodulator */
if (priv-slave_demod == SLAVE_DEMOD_MN88472) {
+   struct dvb_frontend *tmp_fe;
struct mn88472_config mn88472_config = {};
 
mn88472_config.fe = adap-fe[1];
@@ -887,6 +888,12 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
}
 
priv-i2c_client_slave_demod = client;
+
+   /* Swap frontend order */
+   tmp_fe = adap-fe[0];
+   adap-fe[0] = adap-fe[1];
+   adap-fe[1] = tmp_fe;
+
} else {
struct mn88473_config mn88473_config = {};
 
@@ -1373,7 +1380,7 @@ static int rtl2832u_frontend_ctrl(struct dvb_frontend 
*fe, int onoff)
 
/* bypass slave demod TS through master demod */
if (fe-id == 1  onoff) {
-   ret = rtl2832_enable_external_ts_if(adap-fe[0]);
+   ret = rtl2832_enable_external_ts_if(adap-fe[1]);
if (ret)
goto err;
}
-- 
1.9.1

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


Re: [PATCH 2/2] mn88472: fix firmware loading

2014-12-08 Thread Benjamin Larsson

On 12/07/2014 11:36 PM, Antti Palosaari wrote:

On 12/08/2014 12:10 AM, Benjamin Larsson wrote:

The firmware must be loaded one byte at a time via the 0xf6 register.


I don't think so. Currently it downloads firmware in 22 byte chunks 
and it seems to work, at least for me, both mn88472 and mn88473.


With both these changes I get much better sensitivity. So something is 
better then before. I will track down the needed changes and respin the 
patches.


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


Re: [PATCH 2/2] mn88472: fix firmware loading

2014-12-08 Thread Benjamin Larsson

On 12/07/2014 11:36 PM, Antti Palosaari wrote:

On 12/08/2014 12:10 AM, Benjamin Larsson wrote:

The firmware must be loaded one byte at a time via the 0xf6 register.


I don't think so. Currently it downloads firmware in 22 byte chunks 
and it seems to work, at least for me, both mn88472 and mn88473.


Ok, I have now tried the driver with my defaults patch in and with your 
method of loading the firmware and my patch. I have my antenna placed in 
a bad location with bad reception. With my patch I am getting data from 
the device, without my patch I am not. So whatever my code does it makes 
the device more sensitive.


And then there is this comment in the regmap code:

regmap_bulk_write(): Write multiple registers to the device

In this case we want to write multiple bytes to the same register. So I 
think that my patch is correct in principle.


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


Re: [PATCH 2/2] mn88472: fix firmware loading

2014-12-08 Thread Benjamin Larsson

On 12/08/2014 06:46 PM, Antti Palosaari wrote:

Hello!
[...]

regmap_bulk_write(): Write multiple registers to the device

In this case we want to write multiple bytes to the same register. So I
think that my patch is correct in principle.


You haven't make any test whether it is possible to write that 
firmware in a large chunks *or* writing one byte (smallest possible 
~chuck) at the time? I think it does not matter. I suspect you could 
even download whole firmware as one go - but rtl2832p I2C adapter does 
support only 22 bytes on one xfer.


Even those are written to one register, chip knows how many bytes one 
message has and could increase its internal address counter. That is 
usually called register address auto-increment.


A) writing:
f6 00
f6 01
f6 02
f6 03
f6 04
f6 05
f6 06
f6 07
f6 08
f6 09

B) writing:
f6 00 01 02 03 04
f6 05 06 07 08 09

will likely end up same. B is better as only 2 xfers are done - much 
less IO.


regards
Antti


Hello Antti.

I have now tried the following patch on top of my load defaults patch.

index a7d35bb..fd9796d
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -467,7 +467,7 @@ static int mn88472_probe(struct i2c_client *client,
goto err;
}

-   dev-i2c_wr_max = config-i2c_wr_max;
+   dev-i2c_wr_max = 2;
dev-xtal = config-xtal;
dev-ts_mode = config-ts_mode;
dev-ts_clock = config-ts_clock;

With this patch I get data, without it I don't. Based on that info I 
started testing different i2c wr max values.


When I got to 18 it stopped working. So it seams like both you and me 
where right. We can write several

values at once but only a maximum of 16.

I have a patch that adds parity check of the firmware and all the times 
the check succeeded but the demodulator
didn't deliver data. So I guess that the parity checker is before the 16 
byte buffer and if you write more the data is

just ignored.

I will send an updated patch based on this.

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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/2] mn88472: implement firmware parity check

2014-12-08 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index df7dbe9..1df85a7 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -294,6 +294,7 @@ static int mn88472_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
+   unsigned int csum;
 
dev_dbg(client-dev, \n);
 
@@ -346,6 +347,20 @@ static int mn88472_init(struct dvb_frontend *fe)
}
}
 
+   /* parity check of firmware */
+   ret = regmap_read(dev-regmap[0], 0xf8, csum);
+   if (ret) {
+   dev_err(client-dev,
+   parity reg read failed=%d\n, ret);
+   goto err;
+   }
+   if (csum  0x10) {
+   dev_err(client-dev,
+   firmware parity check failed=0x%x\n, csum);
+   goto err;
+   }
+   dev_err(client-dev, firmware parity check succeeded=0x%x\n, csum);
+
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
if (ret)
goto err;
-- 
1.9.1

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


[PATCH 1/2] mn88472: fix firmware downloading

2014-12-08 Thread Benjamin Larsson
The max amount of payload bytes in each i2c transfer when
loading the demodulator firmware is 16 bytes.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index ffee187..df7dbe9 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -15,6 +15,7 @@
  */
 
 #include mn88472_priv.h
+#define FW_BUF_SIZE 16
 
 static int mn88472_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *s)
@@ -331,10 +332,10 @@ static int mn88472_init(struct dvb_frontend *fe)
goto err;
 
for (remaining = fw-size; remaining  0;
-   remaining -= (dev-i2c_wr_max - 1)) {
+   remaining -= FW_BUF_SIZE) {
len = remaining;
-   if (len  (dev-i2c_wr_max - 1))
-   len = (dev-i2c_wr_max - 1);
+   if (len  FW_BUF_SIZE)
+   len = FW_BUF_SIZE;
 
ret = regmap_bulk_write(dev-regmap[0], 0xf6,
fw-data[fw-size - remaining], len);
-- 
1.9.1

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


Re: [PATCH 1/2] mn88472: fix firmware downloading

2014-12-08 Thread Benjamin Larsson

On 12/08/2014 09:55 PM, Antti Palosaari wrote:

Moikka!

But that patch is rather useless :] Only thing needed is to change 
existing value in file drivers/media/usb/dvb-usb-v2/rtl28xxu.c :

mn88472_config.i2c_wr_max = 22,
... and that leaves room for use even smaller values if there is an 
I2C adapter which cannot write even 17 bytes.


2nd thing is to add comment mn88472.h to specify that max limit and 
that's all.


regards
Antti


Ok, I'll do that.

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


[PATCH 1/2] mn88472: load demodulator register defaults

2014-12-07 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c  |  21 +
 drivers/staging/media/mn88472/mn88472_priv.h | 558 +++
 2 files changed, 579 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index be8a6d5..ffee187 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -272,6 +272,20 @@ err:
return ret;
 }
 
+static int mn88472_load_defaults(struct mn88472_dev *dev)
+{
+   int i, ret = 0;
+
+   for (i = 0 ; i  sizeof(mn88472_init_tab)/sizeof(struct idx_num_val)
+   ; i++) {
+   ret |= regmap_write(dev-regmap[mn88472_init_tab[i].reg_idx],
+   mn88472_init_tab[i].reg_num,
+   mn88472_init_tab[i].reg_val);
+   }
+
+   return ret;
+}
+
 static int mn88472_init(struct dvb_frontend *fe)
 {
struct i2c_client *client = fe-demodulator_priv;
@@ -294,6 +308,13 @@ static int mn88472_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   /* load register defaults */
+   ret = mn88472_load_defaults(dev);
+   if (ret) {
+   dev_err(client-dev, register defaults failed\n);
+   goto err;
+   }
+
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, client-dev);
if (ret) {
diff --git a/drivers/staging/media/mn88472/mn88472_priv.h 
b/drivers/staging/media/mn88472/mn88472_priv.h
index 9ba8c8b..b77ff1e 100644
--- a/drivers/staging/media/mn88472/mn88472_priv.h
+++ b/drivers/staging/media/mn88472/mn88472_priv.h
@@ -36,4 +36,562 @@ struct mn88472_dev {
int ts_clock;
 };
 
+struct idx_num_val {
+   unsigned char reg_idx;
+   unsigned char reg_num;
+   unsigned char reg_val;
+};
+
+struct idx_num_val mn88472_init_tab[] = {
+{ 2, 0x00, 0x66 },
+{ 2, 0x01, 0x00 },
+{ 2, 0x02, 0x01 },
+{ 2, 0x03, 0x03 },
+{ 2, 0x04, 0x00 },
+{ 2, 0x05, 0x00 },
+{ 2, 0x06, 0x00 },
+{ 2, 0x07, 0x00 },
+{ 2, 0x08, 0x00 },
+{ 2, 0x09, 0x00 },
+{ 2, 0x0a, 0x00 },
+{ 2, 0x0b, 0x00 },
+{ 2, 0x0c, 0x00 },
+{ 2, 0x0d, 0x00 },
+{ 2, 0x0e, 0x00 },
+{ 2, 0x0f, 0x00 },
+{ 2, 0x10, 0x3e },
+{ 2, 0x11, 0x70 },
+{ 2, 0x12, 0x64 },
+{ 2, 0x13, 0x8f },
+{ 2, 0x14, 0x80 },
+{ 2, 0x15, 0x00 },
+{ 2, 0x16, 0x08 },
+{ 2, 0x17, 0xee },
+{ 2, 0x18, 0x08 },
+{ 2, 0x19, 0xee },
+{ 2, 0x1a, 0x43 },
+{ 2, 0x1b, 0x00 },
+{ 2, 0x1c, 0x74 },
+{ 2, 0x1d, 0xe4 },
+{ 2, 0x1e, 0x26 },
+{ 2, 0x1f, 0x4f },
+{ 2, 0x20, 0x72 },
+{ 2, 0x21, 0x22 },
+{ 2, 0x22, 0x22 },
+{ 2, 0x23, 0x01 },
+{ 2, 0x24, 0x00 },
+{ 2, 0x25, 0x12 },
+{ 2, 0x26, 0x00 },
+{ 2, 0x27, 0x00 },
+{ 2, 0x28, 0x80 },
+{ 2, 0x29, 0x0c },
+{ 2, 0x2a, 0xf4 },
+{ 2, 0x2b, 0x13 },
+{ 2, 0x2c, 0x00 },
+{ 2, 0x2d, 0x20 },
+{ 2, 0x2e, 0x88 },
+{ 2, 0x2f, 0x00 },
+{ 2, 0x30, 0x80 },
+{ 2, 0x31, 0x80 },
+{ 2, 0x32, 0x00 },
+{ 2, 0x33, 0x00 },
+{ 2, 0x34, 0x00 },
+{ 2, 0x35, 0x00 },
+{ 2, 0x36, 0x00 },
+{ 2, 0x37, 0x00 },
+{ 2, 0x38, 0xca },
+{ 2, 0x39, 0x03 },
+{ 2, 0x3a, 0x02 },
+{ 2, 0x3b, 0x55 },
+{ 2, 0x3c, 0xd7 },
+{ 2, 0x3d, 0x00 },
+{ 2, 0x3e, 0x00 },
+{ 2, 0x3f, 0x22 },
+{ 2, 0x40, 0x00 },
+{ 2, 0x41, 0x38 },
+{ 2, 0x42, 0x22 },
+{ 2, 0x43, 0x00 },
+{ 2, 0x44, 0x38 },
+{ 2, 0x45, 0xd3 },
+{ 2, 0x46, 0x10 },
+{ 2, 0x47, 0xb5 },
+{ 2, 0x48, 0xa1 },
+{ 2, 0x49, 0x00 },
+{ 2, 0x4a, 0xd3 },
+{ 2, 0x4b, 0x07 },
+{ 2, 0x4c, 0x64 },
+{ 2, 0x4d, 0x0d },
+{ 2, 0x4e, 0x00 },
+{ 2, 0x4f, 0x05 },
+{ 2, 0x50, 0x00 },
+{ 2, 0x51, 0x55 },
+{ 2, 0x52, 0x20 },
+{ 2, 0x53, 0x00 },
+{ 2, 0x54, 0x24 },
+{ 2, 0x55, 0x64 },
+{ 2, 0x56, 0x44 },
+{ 2, 0x57, 0x33 },
+{ 2, 0x58, 0x1f },
+{ 2, 0x59, 0x00 },
+{ 2, 0x5a, 0x5a },
+{ 2, 0x5b, 0x03 },
+{ 2, 0x5c, 0xc0 },
+{ 2, 0x5d, 0x00 },
+{ 2, 0x5e, 0x00 },
+{ 2, 0x5f, 0x03 },
+{ 2, 0x60, 0x00 },
+{ 2, 0x61, 0x00 },
+{ 2, 0x62, 0x11 },
+{ 2, 0x63, 0x40 },
+{ 2, 0x64, 0x84 },
+{ 2, 0x65, 0x04 },
+{ 2, 0x66, 0x0c },
+{ 2, 0x67, 0x00 },
+{ 2, 0x68, 0x08 },
+{ 2, 0x69, 0x00 },
+{ 2, 0x6a, 0x00 },
+{ 2, 0x6b, 0x12 },
+{ 2, 0x6c, 0x21 },
+{ 2, 0x6d, 0x10 },
+{ 2, 0x6e, 0x01 },
+{ 2, 0x6f, 0x00 },
+{ 2, 0x70, 0x00 },
+{ 2, 0x71, 0x00 },
+{ 2, 0x72, 0xe8 },
+{ 2, 0x73, 0x48 },
+{ 2, 0x74, 0x40 },
+{ 2, 0x75, 0x00 },
+{ 2, 0x76, 0x1d },
+{ 2, 0x77, 0x19 },
+{ 2, 0x78, 0x1d },
+{ 2, 0x79, 0x19 },
+{ 2, 0x7a, 0x66 },
+{ 2, 0x7b, 0x8c },
+{ 2, 0x7c, 0x9f },
+{ 2, 0x7d, 0x08 },
+{ 2, 0x7e, 0x00 },
+{ 2, 0x7f, 0x00 },
+{ 2, 0x80, 0x00 },
+{ 2, 0x81, 0x00 },
+{ 2, 0x83, 0x00 },
+{ 2, 0x84, 0x00 },
+{ 2, 0x85, 0x00 },
+{ 2, 0x86, 0x00 },
+{ 2, 0x87, 0x00 },
+{ 2, 0x88, 0x00 },
+{ 2, 0x89, 0x00 },
+{ 2, 0x8a, 0x20 },
+{ 2, 0x8b, 0x49 },
+{ 2, 0x8c, 0x00 },
+{ 2, 0xc4, 0x00 },
+{ 2, 0xc5, 0x00 },
+{ 2, 0xc6, 0x00 },
+{ 2, 0xc7, 0x87 },
+{ 2, 0xc8, 0x40 },
+{ 2, 0xc9, 0x30 },
+{ 2, 0xca, 0x06 },
+{ 2, 0xcb, 0x02 },
+{ 2, 0xcc, 0x00 },
+{ 2, 0xcd, 0x3b },
+{ 2

[PATCH 2/2] mn88472: fix firmware loading

2014-12-07 Thread Benjamin Larsson
The firmware must be loaded one byte at a time via the 0xf6 register.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index ffee187..ba1bc8d 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -290,7 +290,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 {
struct i2c_client *client = fe-demodulator_priv;
struct mn88472_dev *dev = i2c_get_clientdata(client);
-   int ret, len, remaining;
+   int ret, i;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
 
@@ -330,19 +330,12 @@ static int mn88472_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   for (remaining = fw-size; remaining  0;
-   remaining -= (dev-i2c_wr_max - 1)) {
-   len = remaining;
-   if (len  (dev-i2c_wr_max - 1))
-   len = (dev-i2c_wr_max - 1);
-
-   ret = regmap_bulk_write(dev-regmap[0], 0xf6,
-   fw-data[fw-size - remaining], len);
-   if (ret) {
-   dev_err(client-dev,
-   firmware download failed=%d\n, ret);
-   goto err;
-   }
+   for (i = 0 ; i  fw-size ; i++)
+   ret |= regmap_write(dev-regmap[0], 0xf6, fw-data[i]);
+   if (ret) {
+   dev_err(client-dev,
+   firmware download failed=%d\n, ret);
+   goto err;
}
 
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
-- 
1.9.1

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


Re: [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 01:46 PM, Antti Palosaari wrote:

Moikka!
I am very surprised about that patch, especially because it 
*increases* polling interval from 400ms to 200ms. For me it has been 
always worked rather well, but now I suspect it could be due to I 
disable always remote controller... I have to test that.


regards
Antti


I noticed that I got more retry errors when I removed the poll. So when 
I tried lowering the interval time the errors totally disappeared for 
me. Exactly how it works is unclear to me but I guess that the rc poll 
triggers something in the chip to mitigate some overflow in the i2c 
transmit buffer. This workaround also suggest that the i2c bus actually 
is ok and not the cause for the errors. Anyway please test and if this 
is an acceptable solution then there might also be some check that this 
poll is active and set to 200 at all times for this card. At least when 
the card is set in dvb mode, for sdr mode this might not be an issue.


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


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 05:29 PM, Antti Palosaari wrote:

But that is not needed anymore ?

regards
Antti


Chances are that more devices with the mn8847x chips appear. Someone 
somewhere might try to use this demod with the old dvb attach model 
during development. Adding this memset will make the unload issue appear 
all the time instead of randomly. But this patch doesn't really matter 
so feel free to NACK it. I just wanted to post it for completeness.


I do think it is good practice to set pointers to null generally as that 
would have saved me several days of work of whentracking down this bug. 
The current dvb framework contain several other cases where pointers are 
feed'd but not nulled.


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


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 07:37 PM, Antti Palosaari wrote:


I do think it is good practice to set pointers to null generally as that
would have saved me several days of work of whentracking down this bug.
The current dvb framework contain several other cases where pointers are
feed'd but not nulled.


There is kzfree() for that, but still I am very unsure should we start 
zeroing memory upon release driver has allocated, or just relase it 
using kfree.


regards
Antti 


Well I guess I am biased as I have spent lots of time finding a bug that 
probably wouldn't exist if the policy was that drivers always should set 
their memory to zero before it is free'd. Maybe we should have a compile 
time override so that all free calls zeroes the memory before the actual 
free? Maybe there already is this kind of feature?


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] mn88472: add 5MHz dvb-t2 bandwitdh support

2014-12-06 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index c6895ee..be8a6d5 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -61,7 +61,10 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
switch (c-delivery_system) {
case SYS_DVBT:
case SYS_DVBT2:
-   if (c-bandwidth_hz = 600) {
+   if (c-bandwidth_hz = 500) {
+   memcpy(bw_val, \xe5\x99\x9a\x1b\xa9\x1b\xa9, 7);
+   bw_val2 = 0x03;
+   } else if (c-bandwidth_hz = 600) {
/* IF 357 Hz, BW 600 Hz */
memcpy(bw_val, \xbf\x55\x55\x15\x6b\x15\x6b, 7);
bw_val2 = 0x02;
-- 
1.9.1

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


[PATCH 3/3] mn88472: add ts mode and ts clock to driver

2014-12-05 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/dvb-frontends/mn88472.h| 12 +++
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c  |  2 ++
 drivers/staging/media/mn88472/mn88472.c  | 30 ++--
 drivers/staging/media/mn88472/mn88472_priv.h |  2 ++
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/mn88472.h 
b/drivers/media/dvb-frontends/mn88472.h
index e4e0b80..095294d 100644
--- a/drivers/media/dvb-frontends/mn88472.h
+++ b/drivers/media/dvb-frontends/mn88472.h
@@ -19,6 +19,16 @@
 
 #include linux/dvb/frontend.h
 
+enum ts_clock {
+   VARIABLE_TS_CLOCK,
+   FIXED_TS_CLOCK,
+};
+
+enum ts_mode {
+   SERIAL_TS_MODE,
+   PARALLEL_TS_MODE,
+};
+
 struct mn88472_config {
/*
 * Max num of bytes given I2C adapter could write at once.
@@ -39,6 +49,8 @@ struct mn88472_config {
 * Hz
 */
u32 xtal;
+   int ts_mode;
+   int ts_clock;
 };
 
 #endif
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 9ec4223..663583b 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -869,6 +869,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
mn88472_config.i2c_wr_max = 22,
strlcpy(info.type, mn88472, I2C_NAME_SIZE);
mn88472_config.xtal = 2050;
+   mn88472_config.ts_mode = SERIAL_TS_MODE;
+   mn88472_config.ts_clock = VARIABLE_TS_CLOCK;
info.addr = 0x18;
info.platform_data = mn88472_config;
request_module(info.type);
diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index a9d5f0a..c6895ee 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -188,8 +188,32 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
 
ret = regmap_write(dev-regmap[0], 0x46, 0x00);
ret = regmap_write(dev-regmap[0], 0xae, 0x00);
-   ret = regmap_write(dev-regmap[2], 0x08, 0x1d);
-   ret = regmap_write(dev-regmap[0], 0xd9, 0xe3);
+
+   switch (dev-ts_mode) {
+   case SERIAL_TS_MODE:
+   ret = regmap_write(dev-regmap[2], 0x08, 0x1d);
+   break;
+   case PARALLEL_TS_MODE:
+   ret = regmap_write(dev-regmap[2], 0x08, 0x00);
+   break;
+   default:
+   dev_dbg(client-dev, ts_mode error: %d\n, dev-ts_mode);
+   ret = -EINVAL;
+   goto err;
+   }
+
+   switch (dev-ts_clock) {
+   case VARIABLE_TS_CLOCK:
+   ret = regmap_write(dev-regmap[0], 0xd9, 0xe3);
+   break;
+   case FIXED_TS_CLOCK:
+   ret = regmap_write(dev-regmap[0], 0xd9, 0xe1);
+   break;
+   default:
+   dev_dbg(client-dev, ts_clock error: %d\n, dev-ts_clock);
+   ret = -EINVAL;
+   goto err;
+   }
 
/* Reset demod */
ret = regmap_write(dev-regmap[2], 0xf8, 0x9f);
@@ -406,6 +430,8 @@ static int mn88472_probe(struct i2c_client *client,
 
dev-i2c_wr_max = config-i2c_wr_max;
dev-xtal = config-xtal;
+   dev-ts_mode = config-ts_mode;
+   dev-ts_clock = config-ts_clock;
dev-client[0] = client;
dev-regmap[0] = regmap_init_i2c(dev-client[0], regmap_config);
if (IS_ERR(dev-regmap[0])) {
diff --git a/drivers/staging/media/mn88472/mn88472_priv.h 
b/drivers/staging/media/mn88472/mn88472_priv.h
index b12b731..9ba8c8b 100644
--- a/drivers/staging/media/mn88472/mn88472_priv.h
+++ b/drivers/staging/media/mn88472/mn88472_priv.h
@@ -32,6 +32,8 @@ struct mn88472_dev {
fe_delivery_system_t delivery_system;
bool warm; /* FW running */
u32 xtal;
+   int ts_mode;
+   int ts_clock;
 };
 
 #endif
-- 
1.9.1

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


[PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-05 Thread Benjamin Larsson
Using this driver with the attach dvb model might trigger a use
after free when unloading the driver. With this change the driver
will always fail on unload instead of randomly crash depending
on if the memory has been reused or not.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 36ef39b..a9d5f0a 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -489,6 +489,7 @@ static int mn88472_remove(struct i2c_client *client)
 
regmap_exit(dev-regmap[0]);
 
+   memset(dev, 0, sizeof(*dev));
kfree(dev);
 
return 0;
-- 
1.9.1

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


[PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2014-12-05 Thread Benjamin Larsson
The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 705c6c3..9ec4223 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1567,7 +1567,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device 
*d,
rc-allowed_protos = RC_BIT_ALL;
rc-driver_type = RC_DRIVER_IR_RAW;
rc-query = rtl2832u_rc_query;
-   rc-interval = 400;
+   rc-interval = 200;
 
return 0;
 }
-- 
1.9.1

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


Re: Random memory corruption of fe[1]-dvb pointer

2014-12-02 Thread Benjamin Larsson

On 2014-12-02 11:02, Antti Palosaari wrote:



On 12/02/2014 11:47 AM, Akihiro TSUKADA wrote:

So at first it would be nice if someone could confirm my findings.
Applying the same kind of code like my patch and unplug something that
uses the affected frontend should be enough.


I tried that for tc90522, and I could remove earth-pt3
(which uses tc90522), tc90522 and tuner modules without any problem,
although earth-pt3 is a pci driver and does not use dvb-usb-v2.


From your log(?) output,

I guess that rtl28xxu_exit() removed the attached demod module
(mn88472) and thus free'ed fe BEFORE calling dvb_usbv2_exit(),
from where dvb_unregister_frontend(fe) is called.
I think that the demod i2c device is removed automatically by
dvb_usbv2_i2c_exit() in dvb_usbv2_exit(), if you registered
the demod i2c device, and your adapter/bridge driver
should not try to remove it.


Yes. You must unregister frontend before you remove driver. I have 
already added new callbacks detach tuner and frontend to avoid that, 
but there was yet again new issue as it removes rtl2832 demod driver 
first and mn88472 slave demod was put to i2c bus / adapter which is 
owned by rtl2832. So it will crash too. Solution is to convert rtl2832 
to I2C binding (or convert mn88472 legacy DVB binding (which I don't 
allow :)). When rtl2832 driver is converted to I2C model it is not 
unloaded automatically and you could remove those in a correct order.


But hey, mn88472 is still on staging :D

regards
Antti



So the solution is to change rtl2832.c to the I2C model? And does this 
issue only affect the mn8847x drivers ?


If this is the case would a patch that does not free the buffer but 
leaks the memory be ok ? I can add a todo item and log it in syslog. 
That would for sure be better then crashing the subsystem and the driver 
is still in staging for a reason.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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: Random memory corruption of fe[1]-dvb pointer

2014-12-02 Thread Benjamin Larsson

On 2014-12-02 11:59, Antti Palosaari wrote:

[...]

So the solution is to change rtl2832.c to the I2C model? And does this
issue only affect the mn8847x drivers ?


It likely affects some other dvb-usb-v2 drivers too. But not af9035 as 
I fixed it initially there I think.



If this is the case would a patch that does not free the buffer but
leaks the memory be ok ? I can add a todo item and log it in syslog.
That would for sure be better then crashing the subsystem and the driver
is still in staging for a reason.


Maybe yes, but it does not sound absolute any good. I think you will 
need to set FE pointer NULL after driver is removed.


It is NULL now, that is why it is crashing, or the current code leads to 
random corruptions.


Then unregister frontend will not call members of that struct anymore, 
but leak memory?


Well any solution that does not randomly crash the kernel when unloading 
the module is fine by me. My suggestion is to leak the memory and put a 
note about it in syslog. But I guess there are only a handful of users 
of this driver so maybe leave it as it is right now? It must be fixed 
anyway before the driver is moved out of staging.




regards
Antti



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


Re: [PATCH 1/3] rtl2832: convert driver to I2C binding

2014-12-02 Thread Benjamin Larsson

On 12/02/2014 03:31 PM, Antti Palosaari wrote:

Convert that driver to I2C driver model.
Legacy DVB binding is left also for later removal...

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


Works fine. Thanks for the quick fix.

Tested-by: Benjamin Larsson benja...@southpole.se

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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: Random memory corruption of fe[1]-dvb pointer

2014-12-01 Thread Benjamin Larsson
I think I have found the issue for this error and it looks like a use 
after free that affects multiple drivers. The effect is that the driver 
crashes on unload.


I added the following code to the mn88472 driver, it should behave as a nop:

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c

index 52de8f8..58af319 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -494,6 +494,7 @@ static int mn88472_remove(struct i2c_client *client)

regmap_exit(dev-regmap[0]);

+   memset(dev, 0, sizeof(*dev));
kfree(dev);


When I now unload the driver I get the following code flow:

usb 1-1: rtl28xxu_exit:
mn88472 2-0018: mn88472_remove:  -- this call will actually free the 
fe[1] pointer, I added the memset to make sure they where null

usb 1-1: dvb_usbv2_exit:
usb 1-1: dvb_usbv2_remote_exit:
usb 1-1: dvb_usbv2_adapter_exit:
usb 1-1: dvb_usbv2_adapter_exit: fe0[0]=0x88007a8b0018
usb 1-1: dvb_usbv2_adapter_exit: fe0[0]-dvb=0x88007a142580
usb 1-1: dvb_usbv2_adapter_exit: fe0[0]-demodulator_priv=0x88007a8b
usb 1-1: dvb_usbv2_adapter_exit: fe1[0]=0x88007a8d0030
usb 1-1: dvb_usbv2_adapter_exit: fe1[0]-dvb=0x  (null)
usb 1-1: dvb_usbv2_adapter_exit: fe1[0]-demodulator_priv=0x  (null)
BUG: unable to handle kernel NULL pointer dereference at 0040
IP: [a021f3de] dvb_unregister_frontend+0x2a/0xf1 [dvb_core]

dvb_unregister_frontend() is sent the fe[1] pointer which now is null 
and thus crashes with a null pointer dereference. A use after free issue.


I looked for similar code and found it in:
si2168.c
af9033.c
tc90522.c

sp2.c has the same structure but I think it is fine.

So at first it would be nice if someone could confirm my findings. 
Applying the same kind of code like my patch and unplug something that 
uses the affected frontend should be enough.


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


Random memory corruption of fe[1]-dvb pointer

2014-11-30 Thread Benjamin Larsson
While working on a driver I noticed that I had trouble unloading the 
module after testing, it crashed while running
dvb_usbv2_adapter_frontend_exit. So I added a print out of some pointers 
and got this:


Init:
usb 1-1: dvb_usbv2_adapter_frontend_init: adap=fe[0] 88006afa6818
usb 1-1: dvb_usbv2_adapter_frontend_init: adap=fe[0]-dvb 880078cba580
usb 1-1: dvb_usbv2_adapter_frontend_init: adap=fe[1] 88003698e830
usb 1-1: dvb_usbv2_adapter_frontend_init: adap=fe[1]-dvb 880078cba580

ok looking 64bit pointers

Deinit:
usb 1-1: dvb_usbv2_exit:
usb 1-1: dvb_usbv2_remote_exit:
usb 1-1: dvb_usbv2_adapter_exit:
usb 1-1: dvb_usbv2_adapter_exit: fe0[0]= 88006afa6818
usb 1-1: dvb_usbv2_adapter_exit: fe0[0]-dvb= 880078cba580
usb 1-1: dvb_usbv2_adapter_exit: fe1[0]= 88003698e830
usb 1-1: dvb_usbv2_adapter_exit: fe1[0]-dvb= 003a746165733a3d
usb 1-1: dvb_usbv2_adapter_frontend_exit: adap=0
usb 1-1: dvb_usbv2_adapter_frontend_exit: fe[1]= 88003698e830
usb 1-1: dvb_usbv2_adapter_frontend_exit: fe[1]-dvb= 003a746165733a3d

Later on in dvb_usbv2_adapter_frontend_exit() fe[1]-dvb is dereferenced 
and thus causes a kernel crash.


So for some reason fe[1]-dvb gets corrupted. It doesn't happen all the 
time but after max 3 times I get this crash. I have reproduced this on 
my main machine running Ubuntu 14.04, 14.10 and a VM running Ubuntu 
14.04 all running stock kernel (3.13 and 3.16) and the media_build back 
port code.


After some investigation I saw that fe[1]-demodulator_priv also gets 
corrupted. Something is overwriting the pointers.


So with that knowledge I wrote the following patch and now I can freely 
reload the driver without a crash. This of course doesn't fix the issue 
but just corrupts unused dummy memory.


So does anyone have any hunch on what might be causing this issue or how 
to track it down ?
Keep in mind that this could be caused by me running the media_build 
code or some bug in the driver. Or it could also affect the regular tree 
when unplugging devices with more then 1 frontend.


MvH
Benjamin Larsson


diff --git a/drivers/media/dvb-core/dvb_frontend.h 
b/drivers/media/dvb-core/dvb_frontend.h

index 816269e..e0ba434 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -413,19 +413,30 @@ struct dtv_frontend_properties {
 #define DVB_FE_DEVICE_RESUME3

 struct dvb_frontend {
-   struct dvb_frontend_ops ops;
-   struct dvb_adapter *dvb;
void *demodulator_priv;
+   int dummy1[16000];
void *tuner_priv;
+   int dummy2[16000];
void *frontend_priv;
+   int dummy3[16000];
void *sec_priv;
+   int dummy4[16000];
void *analog_demod_priv;
+   int dummy5[16000];
struct dtv_frontend_properties dtv_property_cache;
+   int dummy6[16000];
 #define DVB_FRONTEND_COMPONENT_TUNER 0
 #define DVB_FRONTEND_COMPONENT_DEMOD 1
int (*callback)(void *adapter_priv, int component, int cmd, int 
arg);

+   int dummy7[16000];
int id;
+   int dummy8[16000];
unsigned int exit;
+   int dummy9[16000];
+   struct dvb_frontend_ops ops;
+   int dummy10[16000];
+   struct dvb_adapter *dvb;
+   int dummy11[16000];
 };

--
To unsubscribe from this list: send the line unsubscribe 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/2] mn88472: document demod reset

2014-11-26 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/staging/media/mn88472/mn88472.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index f648b58..36ef39b 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -190,6 +190,8 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
ret = regmap_write(dev-regmap[0], 0xae, 0x00);
ret = regmap_write(dev-regmap[2], 0x08, 0x1d);
ret = regmap_write(dev-regmap[0], 0xd9, 0xe3);
+
+   /* Reset demod */
ret = regmap_write(dev-regmap[2], 0xf8, 0x9f);
if (ret)
goto err;
-- 
2.1.0

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


[PATCH 1/2] mn88472: calculate the IF register values

2014-11-26 Thread Benjamin Larsson
Add xtal as a configuration parameter so it can be used
in the IF register value calculation.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/dvb-frontends/mn88472.h|  6 ++
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c  |  1 +
 drivers/staging/media/mn88472/mn88472.c  | 23 ---
 drivers/staging/media/mn88472/mn88472_priv.h |  1 +
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/media/dvb-frontends/mn88472.h 
b/drivers/media/dvb-frontends/mn88472.h
index da4558b..e4e0b80 100644
--- a/drivers/media/dvb-frontends/mn88472.h
+++ b/drivers/media/dvb-frontends/mn88472.h
@@ -33,6 +33,12 @@ struct mn88472_config {
 * DVB frontend.
 */
struct dvb_frontend **fe;
+
+   /*
+* Xtal frequency.
+* Hz
+*/
+   u32 xtal;
 };
 
 #endif
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 896a225..73580f8 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -852,6 +852,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter 
*adap)
mn88472_config.fe = adap-fe[1];
mn88472_config.i2c_wr_max = 22,
strlcpy(info.type, mn88472, I2C_NAME_SIZE);
+   mn88472_config.xtal = 2050;
info.addr = 0x18;
info.platform_data = mn88472_config;
request_module(info.type);
diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 52de8f8..f648b58 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -30,6 +30,7 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret, i;
u32 if_frequency = 0;
+   u64 tmp;
u8 delivery_system_val, if_val[3], bw_val[7], bw_val2;
 
dev_dbg(client-dev,
@@ -62,17 +63,14 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
case SYS_DVBT2:
if (c-bandwidth_hz = 600) {
/* IF 357 Hz, BW 600 Hz */
-   memcpy(if_val, \x2c\x94\xdb, 3);
memcpy(bw_val, \xbf\x55\x55\x15\x6b\x15\x6b, 7);
bw_val2 = 0x02;
} else if (c-bandwidth_hz = 700) {
/* IF 457 Hz, BW 700 Hz */
-   memcpy(if_val, \x39\x11\xbc, 3);
memcpy(bw_val, \xa4\x00\x00\x0f\x2c\x0f\x2c, 7);
bw_val2 = 0x01;
} else if (c-bandwidth_hz = 800) {
/* IF 457 Hz, BW 800 Hz */
-   memcpy(if_val, \x39\x11\xbc, 3);
memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
bw_val2 = 0x00;
} else {
@@ -82,7 +80,6 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
break;
case SYS_DVBC_ANNEX_A:
/* IF 507 Hz, BW 800 Hz */
-   memcpy(if_val, \x3f\x50\x2c, 3);
memcpy(bw_val, \x8f\x80\x00\x08\xee\x08\xee, 7);
bw_val2 = 0x00;
break;
@@ -106,17 +103,12 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
dev_dbg(client-dev, get_if_frequency=%d\n, if_frequency);
}
 
-   switch (if_frequency) {
-   case 357:
-   case 457:
-   case 507:
-   break;
-   default:
-   dev_err(client-dev, IF frequency %d not supported\n,
-   if_frequency);
-   ret = -EINVAL;
-   goto err;
-   }
+   /* Calculate IF registers ( (124)*IF / Xtal ) */
+   tmp =  div_u64(if_frequency * (u64)(124) + (dev-xtal / 2),
+  dev-xtal);
+   if_val[0] = ((tmp  16)  0xff);
+   if_val[1] = ((tmp   8)  0xff);
+   if_val[2] = ((tmp   0)  0xff);
 
ret = regmap_write(dev-regmap[2], 0xfb, 0x13);
ret = regmap_write(dev-regmap[2], 0xef, 0x13);
@@ -411,6 +403,7 @@ static int mn88472_probe(struct i2c_client *client,
}
 
dev-i2c_wr_max = config-i2c_wr_max;
+   dev-xtal = config-xtal;
dev-client[0] = client;
dev-regmap[0] = regmap_init_i2c(dev-client[0], regmap_config);
if (IS_ERR(dev-regmap[0])) {
diff --git a/drivers/staging/media/mn88472/mn88472_priv.h 
b/drivers/staging/media/mn88472/mn88472_priv.h
index 1095949..b12b731 100644
--- a/drivers/staging/media/mn88472/mn88472_priv.h
+++ b/drivers/staging/media/mn88472/mn88472_priv.h
@@ -31,6 +31,7 @@ struct mn88472_dev {
u16 i2c_wr_max;
fe_delivery_system_t delivery_system;
bool warm; /* FW running */
+   u32 xtal

Re: [PATCH 2/8] rtl2832: implement PIP mode

2014-11-16 Thread Benjamin Larsson

On 11/16/2014 11:25 AM, Mauro Carvalho Chehab wrote:


[...]
What demod(s) are exposed to userspace? both or just demod#1?

If both are exposed, how userspace knows that demod#0 should not be
used?

Regards,
Mauro



Currently both demods are exposed to userspace. While it is nice to have 
both I suggest that if a NM8847x demod is activated only expose that 
demod. That would remove the hack in master and would make it possible 
to faster move the NM8847x demods out of staging. The main reason for 
this hardware is the DVB-C and DVB-T2 support. Lets focus on getting 
that in an easy obtainable way.


MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line unsubscribe 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] r820t: fix size and init values

2014-03-16 Thread Benjamin Larsson
Correct the initialization values at the start of the function
and use proper variable sizes to prevent overflow.

Signed-off-by: Benjamin Larsson benja...@southpole.se
---
 drivers/media/tuners/r820t.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index d9ee43f..ce10c18 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1468,7 +1468,8 @@ static int r820t_imr_prepare(struct r820t_priv *priv)
 static int r820t_multi_read(struct r820t_priv *priv)
 {
int rc, i;
-   u8 data[2], min = 0, max = 255, sum = 0;
+   u16 sum = 0;
+   u8 data[2], min = 255, max = 0;
 
usleep_range(5000, 6000);
 
-- 
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


  1   2   >