Re: [PATCH] dvb: Save port number and provide sysfs attributes to pass values to udev

2018-03-08 Thread David Howells
Mauro Carvalho Chehab  wrote:

> > +   dvb_class->dev_groups = dvb_class_groups,
> > dvb_class->dev_uevent = dvb_uevent;
> > dvb_class->devnode = dvb_devnode;
> > return 0;
> 
> The patch itself looks good, but I'm not seeing any documentation.

I should probably add something to Documentation/media/dvb-drivers/udev.rst

> You should likely add something to Documentation/ABI

Any suggestions as to where to add stuff in there?  The README there leaves
a lot to be desired as to how to name elements - for instance, DVB devices can
be seen through /sys/class/ and /sys/devices/.

I could put it in sys-class-dvb or sys-devices-dvb - or, arguably, both.

> and to the DVB uAPI (Documentation/media/uapi/dvb).

Likewise, any suggestion as to where in here?  As far as I can tell, the docs
here don't currently mention sysfs at all.  I'm guessing I'll need to create a
file specifically to talk about how to use this stuff with udev.

> > +   port->frontends.adapter.port_num = port->nr;
> > +
> 
> Doing it for each multi-adapter device is something that bothers
> me. The better would be if we could move this to the DVB Kernel,
> in order to not need to check/fix every driver.

I'm not sure how achievable that is: *port in this case is a private
cx23885-specific structure object.

> If, otherwise, this is not possible, then we need a patch fixing port_num
> for all drivers that support multiple adapters.
> 
> Also, the risk of forgetting it seems high. So, perhaps we should
> add a new parameter to some function (like at dvb_register_device
> or at dvb_register_frontend), in order to make the port number
> a mandatory attribute.

Hmmm...  The cx23885 driver doesn't call either of these functions as far as I
can tell - at least, not directly.  Maybe by vb2_dvb_register_bus()?

Note that these attribute files appear for the demux, dvr and net directories
as well as for the frontend.

Hmmm... further, the port number is no longer getting through and all adapters
are showing port 0.  The MAC address works, though.  Maybe I should drop the
port number.

David


[PATCH] dvb: Save port number and provide sysfs attributes to pass values to udev

2018-01-10 Thread David Howells
Some devices, such as the DVBSky S952 and T982 cards, are dual port cards
that provide two cx23885 devices on the same PCI device, which means the
attributes available for writing udev rules are exactly the same, apart
from the adapter number.  Unfortunately, the adapter numbers are dependent
on the order in which things are initialised, so this can change over
different releases of the kernel.

The struct cx23885_tsport has a port number available, which is printed
during boot:

[   10.951517] DVBSky T982 port 1 MAC address: 00:17:42:54:09:87
...
[   10.984875] DVBSky T982 port 2 MAC address: 00:17:42:54:09:88

To make it possible to distinguish these in udev, do the following steps:

 (1) Save the port number into struct dvb_adapter.

 (2) Provide sysfs attributes to export port number and also MAC address,
 adapter number and type.  There are other fields that could perhaps be
 exported also.

The new sysfs attributes can be seen from userspace as:

[root@deneb ~]# ls /sys/class/dvb/dvb0.frontend0/
dev  device  dvb_adapter  dvb_mac  dvb_port  dvb_type
power  subsystem  uevent
[root@deneb ~]# cat /sys/class/dvb/dvb0.frontend0/dvb_*
0
00:17:42:54:09:87
0
frontend

They can be used in udev rules:

SUBSYSTEM=="dvb", ATTRS{vendor}=="0x14f1", ATTRS{device}=="0x8852", 
ATTRS{subsystem_device}=="0x0982", ATTR{dvb_mac}=="00:17:42:54:09:87", 
PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter9820/%%s $${K#*.}'", 
SYMLINK+="%c"
SUBSYSTEM=="dvb", ATTRS{vendor}=="0x14f1", ATTRS{device}=="0x8852", 
ATTRS{subsystem_device}=="0x0982", ATTR{dvb_mac}=="00:17:42:54:09:88", 
PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter9821/%%s $${K#*.}'", 
SYMLINK+="%c"

where the match is made with ATTR{dvb_mac} or similar.  The rules above
make symlinks from /dev/dvb/adapter982/* to /dev/dvb/adapterXX/*.

Note that binding the dvb-net device to a network interface and changing it
there does not reflect back into the the dvb_adapter struct and doesn't
change the MAC address here.  This means that a system with two identical
cards in it may need to distinguish them by some other means than MAC
address.

Signed-off-by: David Howells <dhowe...@redhat.com>
---

 drivers/media/dvb-core/dvbdev.c |   46 +++
 drivers/media/dvb-core/dvbdev.h |2 +
 drivers/media/pci/cx23885/cx23885-dvb.c |2 +
 3 files changed, 50 insertions(+)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 060c60ddfcc3..b3aa5ae3d57f 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -941,6 +941,51 @@ int dvb_usercopy(struct file *file,
return err;
 }
 
+static ssize_t dvb_adapter_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", dvbdev->adapter->num);
+}
+static DEVICE_ATTR_RO(dvb_adapter);
+
+static ssize_t dvb_mac_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%pM\n", dvbdev->adapter->proposed_mac);
+}
+static DEVICE_ATTR_RO(dvb_mac);
+
+static ssize_t dvb_port_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", dvbdev->adapter->port_num);
+}
+static DEVICE_ATTR_RO(dvb_port);
+
+static ssize_t dvb_type_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%s\n", dnames[dvbdev->type]);
+}
+static DEVICE_ATTR_RO(dvb_type);
+
+static struct attribute *dvb_class_attrs[] = {
+   _attr_dvb_adapter.attr,
+   _attr_dvb_mac.attr,
+   _attr_dvb_port.attr,
+   _attr_dvb_type.attr,
+   NULL
+};
+ATTRIBUTE_GROUPS(dvb_class);
+
 static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
struct dvb_device *dvbdev = dev_get_drvdata(dev);
@@ -981,6 +1026,7 @@ static int __init init_dvbdev(void)
retval = PTR_ERR(dvb_class);
goto error;
}
+   dvb_class->dev_groups = dvb_class_groups,
dvb_class->dev_uevent = dvb_uevent;
dvb_class->devnode = dvb_devnode;
return 0;
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index bbc1c20c0529..1d5a170e279a 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -83

[PATCH 28/38] Annotate hardware config module parameters in drivers/staging/media/

2017-04-05 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/media/.

Suggested-by: Alan Cox <gno...@lxorguk.ukuu.org.uk>
Signed-off-by: David Howells <dhowe...@redhat.com>
cc: Mauro Carvalho Chehab <mche...@kernel.org>
cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
cc: linux-media@vger.kernel.org
cc: de...@driverdev.osuosl.org
---

 drivers/staging/media/lirc/lirc_sir.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_sir.c 
b/drivers/staging/media/lirc/lirc_sir.c
index c6c3de94adaa..dde46dd8cabb 100644
--- a/drivers/staging/media/lirc/lirc_sir.c
+++ b/drivers/staging/media/lirc/lirc_sir.c
@@ -826,10 +826,10 @@ MODULE_AUTHOR("Milan Pikula");
 #endif
 MODULE_LICENSE("GPL");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
 module_param(threshold, int, S_IRUGO);



[PATCH 13/38] Annotate hardware config module parameters in drivers/media/

2017-04-05 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/media/.

Suggested-by: Alan Cox <gno...@lxorguk.ukuu.org.uk>
Signed-off-by: David Howells <dhowe...@redhat.com>
cc: Mauro Carvalho Chehab <mche...@kernel.org>
cc: mjpeg-us...@lists.sourceforge.net
cc: linux-media@vger.kernel.org
---

 drivers/media/pci/zoran/zoran_card.c |2 +-
 drivers/media/rc/serial_ir.c |   10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/zoran/zoran_card.c 
b/drivers/media/pci/zoran/zoran_card.c
index 5266755add63..4680f001653a 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -69,7 +69,7 @@ MODULE_PARM_DESC(card, "Card type");
  */
 
 static unsigned long vidmem;   /* default = 0 - Video memory base address */
-module_param(vidmem, ulong, 0444);
+module_param_hw(vidmem, ulong, iomem, 0444);
 MODULE_PARM_DESC(vidmem, "Default video memory base address");
 
 /*
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index 41b54e40176c..40d305842a9b 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -833,11 +833,11 @@ MODULE_LICENSE("GPL");
 module_param(type, int, 0444);
 MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 = IRdeo, 2 = IRdeo 
Remote, 3 = AnimaX, 4 = IgorPlug");
 
-module_param(io, int, 0444);
+module_param_hw(io, int, ioport, 0444);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
 /* some architectures (e.g. intel xscale) have memory mapped registers */
-module_param(iommap, bool, 0444);
+module_param_hw(iommap, bool, other, 0444);
 MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O (0 = no memory 
mapped io)");
 
 /*
@@ -845,13 +845,13 @@ MODULE_PARM_DESC(iommap, "physical base for memory mapped 
I/O (0 = no memory map
  * on 32bit word boundaries.
  * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
  */
-module_param(ioshift, int, 0444);
+module_param_hw(ioshift, int, other, 0444);
 MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
 
-module_param(irq, int, 0444);
+module_param_hw(irq, int, irq, 0444);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
-module_param(share_irq, bool, 0444);
+module_param_hw(share_irq, bool, other, 0444);
 MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
 
 module_param(sense, int, 0444);



[no subject]

2017-01-13 Thread David Howells
> -header-y += msr-index.h

I see it on my desktop as /usr/include/asm/msr-index.h and it's been there at
least four years - and as such it's part of the UAPI.  I don't think you can
remove it unless you can guarantee there are no userspace users.

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


[no subject]

2017-01-13 Thread David Howells
Nicolas Dichtel  wrote:

> This header file is exported, thus move it to uapi.

Exported how?

> +#ifdef __INT32_TYPE__
> +#undef __INT32_TYPE__
> +#define __INT32_TYPE__   int
> +#endif
> +
> +#ifdef __UINT32_TYPE__
> +#undef __UINT32_TYPE__
> +#define __UINT32_TYPE__  unsigned int
> +#endif
> +
> +#ifdef __UINTPTR_TYPE__
> +#undef __UINTPTR_TYPE__
> +#define __UINTPTR_TYPE__ unsigned long
> +#endif

These weren't defined by the kernel before, so why do we need to define them
now?

Will defining __UINTPTR_TYPE__ cause problems in compiling libboost by
changing the signature on C++ functions that use uintptr_t?

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


Re: [PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread David Howells
Mauro Carvalho Chehab  wrote:

> drivers/staging/media/lirc/lirc_parallel.c:728:19: error: Expected ) in 
> function declarator

Did you apply patch 1 first?  That defines module_param_hw*.

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


[PATCH 29/39] Annotate hardware config module parameters in drivers/staging/media/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/staging/media/.

Suggested-by: One Thousand Gnomes <gno...@lxorguk.ukuu.org.uk>
Signed-off-by: David Howells <dhowe...@redhat.com>
cc: Mauro Carvalho Chehab <mche...@kernel.org>
cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
cc: linux-media@vger.kernel.org
cc: de...@driverdev.osuosl.org
---

 drivers/staging/media/lirc/lirc_parallel.c |4 ++--
 drivers/staging/media/lirc/lirc_serial.c   |   10 +-
 drivers/staging/media/lirc/lirc_sir.c  |4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_parallel.c 
b/drivers/staging/media/lirc/lirc_parallel.c
index bfb76a45bfbf..65530e0a6d99 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -725,10 +725,10 @@ MODULE_DESCRIPTION("Infrared receiver driver for parallel 
ports.");
 MODULE_AUTHOR("Christoph Bartelmus");
 MODULE_LICENSE("GPL");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3bc, 0x378 or 0x278)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (7 or 5)");
 
 module_param(tx_mask, int, S_IRUGO);
diff --git a/drivers/staging/media/lirc/lirc_serial.c 
b/drivers/staging/media/lirc/lirc_serial.c
index b798b311d32c..ea3f735a196d 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -1094,11 +1094,11 @@ MODULE_PARM_DESC(type, "Hardware type (0 = home-brew, 1 
= IRdeo,"
 " 2 = IRdeo Remote, 3 = AnimaX, 4 = IgorPlug,"
 " 5 = NSLU2 RX:CTS2/TX:GreenLED)");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
 /* some architectures (e.g. intel xscale) have memory mapped registers */
-module_param(iommap, bool, S_IRUGO);
+module_param_hw(iommap, bool, other, S_IRUGO);
 MODULE_PARM_DESC(iommap, "physical base for memory mapped I/O"
" (0 = no memory mapped io)");
 
@@ -1107,13 +1107,13 @@ MODULE_PARM_DESC(iommap, "physical base for memory 
mapped I/O"
  * on 32bit word boundaries.
  * See linux-kernel/drivers/tty/serial/8250/8250.c serial_in()/out()
  */
-module_param(ioshift, int, S_IRUGO);
+module_param_hw(ioshift, int, other, S_IRUGO);
 MODULE_PARM_DESC(ioshift, "shift I/O register offset (0 = no shift)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
-module_param(share_irq, bool, S_IRUGO);
+module_param_hw (share_irq, bool, other, S_IRUGO);
 MODULE_PARM_DESC(share_irq, "Share interrupts (0 = off, 1 = on)");
 
 module_param(sense, int, S_IRUGO);
diff --git a/drivers/staging/media/lirc/lirc_sir.c 
b/drivers/staging/media/lirc/lirc_sir.c
index 4f326e97ad75..e27842e01fba 100644
--- a/drivers/staging/media/lirc/lirc_sir.c
+++ b/drivers/staging/media/lirc/lirc_sir.c
@@ -986,10 +986,10 @@ MODULE_AUTHOR("Milan Pikula");
 #endif
 MODULE_LICENSE("GPL");
 
-module_param(io, int, S_IRUGO);
+module_param_hw(io, int, ioport, S_IRUGO);
 MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
 
-module_param(irq, int, S_IRUGO);
+module_param_hw(irq, int, irq, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
 
 module_param(threshold, int, S_IRUGO);

--
To unsubscribe from this list: send the line "unsubscribe 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 13/39] Annotate hardware config module parameters in drivers/media/

2016-12-01 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to
prevent userspace from modifying the running kernel image.  Whilst this
includes prohibiting access to things like /dev/mem, it must also prevent
access by means of configuring driver modules in such a way as to cause a
device to access or modify the kernel image.

To this end, annotate module_param* statements that refer to hardware
configuration and indicate for future reference what type of parameter they
specify.  The parameter parser in the core sees this information and can
skip such parameters with an error message if the kernel is locked down.
The module initialisation then runs as normal, but just sees whatever the
default values for those parameters is.

Note that we do still need to do the module initialisation because some
drivers have viable defaults set in case parameters aren't specified and
some drivers support automatic configuration (e.g. PNP or PCI) in addition
to manually coded parameters.

This patch annotates drivers in drivers/media/.

Suggested-by: One Thousand Gnomes <gno...@lxorguk.ukuu.org.uk>
Signed-off-by: David Howells <dhowe...@redhat.com>
cc: Mauro Carvalho Chehab <mche...@kernel.org>
cc: mjpeg-us...@lists.sourceforge.net
cc: linux-media@vger.kernel.org
---

 drivers/media/pci/zoran/zoran_card.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/zoran/zoran_card.c 
b/drivers/media/pci/zoran/zoran_card.c
index 9d2697f5b455..3a03a0df7999 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -73,7 +73,7 @@ MODULE_PARM_DESC(card, "Card type");
  */
 
 static unsigned long vidmem;   /* default = 0 - Video memory base address */
-module_param(vidmem, ulong, 0444);
+module_param_hw(vidmem, ulong, iomem, 0444);
 MODULE_PARM_DESC(vidmem, "Default video memory base address");
 
 /*

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


Trying to pass the port number to udev for a multiport DVB card

2016-07-15 Thread David Howells
Hi,

Can someone give me a hand with unpicking the tangle of spaghetti that's the
DVB core?

Attached is a patch that can pass various attributes, including,
theoretically, the port number of the separate ports of a multiport card, such
as the DVBSky S952 and T982 cards, so that udev can create persistent names.

However, the port number I've added to the dvb_adapter struct is always seen
as zero in the attribute function I've written.  Putting in some printks shows
that the dvb_adapter struct seen in the attribute struct has a *different*
address to the one seen in dvb_register() in cx23885-dvb.c.  Does anyone know
what's going on?  I should also add that the MAC address *does* go through,
though I can't see where it's copied.

David
---
commit c100b0ddc9436152e770a80eedfdd90644c1ee3d
Author: David Howells <dhowe...@redhat.com>
Date:   Wed Jul 13 23:05:34 2016 +0100

dvb: Save port number and provide sysfs attributes to pass values to udev

Some devices, such as the DVBSky S952 and T982 cards, are dual port cards
that provide two cx23885 devices on the same PCI device, which means the
attributes available for writing udev rules are exactly the same, apart
from the adapter number.  Unfortunately, the adapter numbers are dependent
on the order in which things are initialised, so this can change over
different releases of the kernel.

The struct cx23885_tsport has a port number available, which is printed
during boot:

[   10.951517] DVBSky T982 port 1 MAC address: 00:17:42:54:09:87
...
[   10.984875] DVBSky T982 port 2 MAC address: 00:17:42:54:09:88

To make it possible to distinguish these in udev, do the following steps:

 (1) Save the port number into struct dvb_adapter.

 (2) Provide sysfs attributes to export port number and also MAC address,
 adapter number and type.  There are other fields that could perhaps be
 exported also.

The new sysfs attributes can be seen from userspace as:

[root@deneb ~]# ls /sys/class/dvb/dvb0.frontend0/
dev  device  dvb_adapter  dvb_mac  dvb_port  dvb_type
power  subsystem  uevent
[root@deneb ~]# cat /sys/class/dvb/dvb0.frontend0/dvb_*
0
00:17:42:54:09:87
0
frontend

They can be used in udev rules:

SUBSYSTEM=="dvb", ATTRS{vendor}=="0x14f1", ATTRS{device}=="0x8852", 
ATTRS{subsystem_device}=="0x0982", ATTR{dvb_mac}=="00:17:42:54:09:87", 
PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter9820/%%s $${K#*.}'", 
SYMLINK+="%c"
SUBSYSTEM=="dvb", ATTRS{vendor}=="0x14f1", ATTRS{device}=="0x8852", 
ATTRS{subsystem_device}=="0x0982", ATTR{dvb_mac}=="00:17:42:54:09:88", 
PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter9821/%%s $${K#*.}'", 
SYMLINK+="%c"

where the match is made with ATTR{dvb_mac} or similar.  The rules above
make symlinks from /dev/dvb/adapter982/* to /dev/dvb/adapterXX/*.

Note that binding the dvb-net device to a network interface and changing it
there does not reflect back into the the dvb_adapter struct and doesn't
change the MAC address here.  This means that a system with two identical
cards in it may need to distinguish them by some other means than MAC
address.

Signed-off-by: David Howells <dhowe...@redhat.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 75a3f4b57fd4..638719483167 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -901,6 +901,51 @@ out:
return err;
 }
 
+static ssize_t dvb_adapter_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", dvbdev->adapter->num);
+}
+static DEVICE_ATTR_RO(dvb_adapter);
+
+static ssize_t dvb_mac_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%pM\n", dvbdev->adapter->proposed_mac);
+}
+static DEVICE_ATTR_RO(dvb_mac);
+
+static ssize_t dvb_port_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", dvbdev->adapter->port_num);
+}
+static DEVICE_ATTR_RO(dvb_port);
+
+static ssize_t dvb_type_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct dvb_device *dvbdev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%s\n", dnames[dvbdev->type]);
+}
+static DEVICE_ATTR_RO(

Re: [PATCH] [media] cx23885-dvb: move initialization of a8293_pdata

2015-12-18 Thread David Howells
Mauro Carvalho Chehab <mche...@osg.samsung.com> wrote:

> Smatch complains about where the au8293_data is placed:
> 
> drivers/media/pci/cx23885/cx23885-dvb.c:2174 dvb_register() info: 
> 'a8293_pdata' is not actually initialized (unreached code).
> 
> It is not actually expected to have such initialization at
> 
> switch {
>   foo = bar;
> 
>   case:
> ...
> }
> 
> Not really sure how gcc does that, but this is something that I would
> expect that different compilers would do different things.
> 
> So, move the initialization outside the switch(), making smatch to
> shut up one warning.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@osg.samsung.com>

Yeah - checked with the compiler people: it's not really expected to
initialise as expected.

Acked-by: David Howells <dhowe...@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types

2015-09-21 Thread David Howells
Andrzej Hajda  wrote:

> Semantic patch finds comparisons of types:
> unsigned < 0
> unsigned >= 0
> The former is always false, the latter is always true.
> Such comparisons are useless, so theoretically they could be
> safely removed, but their presence quite often indicates bugs.

Or someone has left them in because they don't matter and there's the
possibility that the type being tested might be or become signed under some
circumstances.  If the comparison is useless, I'd expect the compiler to just
discard it - for such cases your patch is pointless.

If I have, for example:

unsigned x;

if (x == 0 || x > 27)
give_a_range_error();

I will write this as:

unsigned x;

if (x <= 0 || x > 27)
give_a_range_error();

because it that gives a way to handle x being changed to signed at some point
in the future for no cost.  In which case, your changing the <= to an ==
"because the < part of the case is useless" is arguably wrong.

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


[PATCH] ts2020: Copy loop_through from the config to the internal data

2015-06-03 Thread David Howells
Copy the loop_through setting from the ts2020_config struct to the internal
ts2020_priv struct so that it can actually be used.

Whilst we're at it, group the bitfields together in the same order in both
structs so that the compiler has a good chance to copy them in one go.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/dvb-frontends/ts2020.c |3 ++-
 drivers/media/dvb-frontends/ts2020.h |2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 80ae039..8c997d0 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -37,6 +37,7 @@ struct ts2020_priv {
/* i2c details */
struct i2c_adapter *i2c;
int i2c_address;
+   bool loop_through:1;
u8 clk_out:2;
u8 clk_out_div:5;
u32 frequency_div; /* LO output divider switch frequency */
@@ -44,7 +45,6 @@ struct ts2020_priv {
 #define TS2020_M88TS2020 0
 #define TS2020_M88TS2022 1
u8 tuner;
-   u8 loop_through:1;
 };
 
 struct ts2020_reg_val {
@@ -582,6 +582,7 @@ static int ts2020_probe(struct i2c_client *client,
 
dev-i2c = client-adapter;
dev-i2c_address = client-addr;
+   dev-loop_through = pdata-loop_through;
dev-clk_out = pdata-clk_out;
dev-clk_out_div = pdata-clk_out_div;
dev-frequency_div = pdata-frequency_div;
diff --git a/drivers/media/dvb-frontends/ts2020.h 
b/drivers/media/dvb-frontends/ts2020.h
index 3779724..002bc0a 100644
--- a/drivers/media/dvb-frontends/ts2020.h
+++ b/drivers/media/dvb-frontends/ts2020.h
@@ -32,7 +32,7 @@ struct ts2020_config {
/*
 * RF loop-through
 */
-   u8 loop_through:1;
+   bool loop_through:1;
 
/*
 * clock output

--
To unsubscribe from this list: send the line unsubscribe 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] ts2020: Provide DVBv5 API signal strength

2015-06-03 Thread David Howells
Malcolm Priestley tvbox...@gmail.com wrote:

 Yes, also, the workqueue appears not to be initialized when using the dvb
 attached method.

I'm not sure what you're referring to.  It's initialised in ts2020_probe()
just after the ts2020_priv struct is allocated - the only place it is
allocated.

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


[PATCH] ts2020: Allow stats polling to be suppressed

2015-06-03 Thread David Howells
Statistics polling can not be done by lmedm04 driver's implementation of
M88RS2000/TS2020 because I2C messages stop the device's demuxer, so allow
polling for statistics to be suppressed in the ts2020 driver by setting
dont_poll in the ts2020_config struct.

Reported-by: Malcolm Priestley tvbox...@gmail.com
Signed-off-by: David Howells dhowe...@redhat.com
cc: Malcolm Priestley tvbox...@gmail.com
---

 drivers/media/dvb-frontends/ts2020.c |   18 ++
 drivers/media/dvb-frontends/ts2020.h |3 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 8c997d0..946d8e950 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -40,6 +40,7 @@ struct ts2020_priv {
bool loop_through:1;
u8 clk_out:2;
u8 clk_out_div:5;
+   bool dont_poll:1;
u32 frequency_div; /* LO output divider switch frequency */
u32 frequency_khz; /* actual used LO frequency */
 #define TS2020_M88TS2020 0
@@ -52,6 +53,8 @@ struct ts2020_reg_val {
u8 val;
 };
 
+static void ts2020_stat_work(struct work_struct *work);
+
 static int ts2020_release(struct dvb_frontend *fe)
 {
struct ts2020_priv *priv = fe-tuner_priv;
@@ -79,7 +82,8 @@ static int ts2020_sleep(struct dvb_frontend *fe)
return ret;
 
/* stop statistics polling */
-   cancel_delayed_work_sync(priv-stat_work);
+   if (!priv-dont_poll)
+   cancel_delayed_work_sync(priv-stat_work);
return 0;
 }
 
@@ -152,8 +156,8 @@ static int ts2020_init(struct dvb_frontend *fe)
c-strength.stat[0].scale = FE_SCALE_DECIBEL;
c-strength.stat[0].uvalue = 0;
 
-   /* Start statistics polling */
-   schedule_delayed_work(priv-stat_work, 0);
+   /* Start statistics polling by invoking the work function */
+   ts2020_stat_work(priv-stat_work.work);
return 0;
 }
 
@@ -445,7 +449,8 @@ static void ts2020_stat_work(struct work_struct *work)
 
c-strength.stat[0].scale = FE_SCALE_DECIBEL;
 
-   schedule_delayed_work(priv-stat_work, msecs_to_jiffies(2000));
+   if (!priv-dont_poll)
+   schedule_delayed_work(priv-stat_work, msecs_to_jiffies(2000));
return;
 err:
dev_dbg(client-dev, failed=%d\n, ret);
@@ -458,9 +463,13 @@ static int ts2020_read_signal_strength(struct dvb_frontend 
*fe,
   u16 *_signal_strength)
 {
struct dtv_frontend_properties *c = fe-dtv_property_cache;
+   struct ts2020_priv *priv = fe-tuner_priv;
unsigned strength;
__s64 gain;
 
+   if (priv-dont_poll)
+   ts2020_stat_work(priv-stat_work.work);
+
if (c-strength.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
*_signal_strength = 0;
return 0;
@@ -585,6 +594,7 @@ static int ts2020_probe(struct i2c_client *client,
dev-loop_through = pdata-loop_through;
dev-clk_out = pdata-clk_out;
dev-clk_out_div = pdata-clk_out_div;
+   dev-dont_poll = pdata-dont_poll;
dev-frequency_div = pdata-frequency_div;
dev-fe = fe;
dev-get_agc_pwm = pdata-get_agc_pwm;
diff --git a/drivers/media/dvb-frontends/ts2020.h 
b/drivers/media/dvb-frontends/ts2020.h
index 002bc0a..9220e5c 100644
--- a/drivers/media/dvb-frontends/ts2020.h
+++ b/drivers/media/dvb-frontends/ts2020.h
@@ -48,6 +48,9 @@ struct ts2020_config {
 */
u8 clk_out_div:5;
 
+   /* Set to true to suppress stat polling */
+   bool dont_poll:1;
+
/*
 * pointer to DVB frontend
 */

--
To unsubscribe from this list: send the line unsubscribe 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] ts2020: Provide DVBv5 API signal strength

2015-06-03 Thread David Howells
Antti Palosaari cr...@iki.fi wrote:

 Malcolm misses some pending patches where attach() is wrapped to I2C model
 probe().
 http://git.linuxtv.org/cgit.cgi/anttip/media_tree.git/log/?h=ts2020

Aha!  That explains it.

ts2020: register I2C driver from legacy media attach

removes the allocation from attach() in the branch I'm working on top of.

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


Re: [PATCH 2/2] ts2020: Provide DVBv5 API signal strength

2015-06-03 Thread David Howells
Malcolm Priestley tvbox...@gmail.com wrote:

  Yes, also, the workqueue appears not to be initialized when using the dvb
  attached method.
 
  I'm not sure what you're referring to.  It's initialised in ts2020_probe()
  just after the ts2020_priv struct is allocated - the only place it is
  allocated.
 
 ts2020_probe() isn't touched by devices not converted to I2C binding.

Hmmm...  Doesn't that expose a larger problem?  The only place the ts2020_priv
struct is allocated is in ts2020_probe() within ts2020.c and the struct
definition is private to that file and so it can't be allocated from outside.
So if you don't pass through ts2020_probe(), fe-tuner_priv will remain NULL
and the driver will crash.

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


Re: [PATCH 2/2] ts2020: Provide DVBv5 API signal strength

2015-05-28 Thread David Howells
Malcolm Priestley tvbox...@gmail.com wrote:

 Statistics polling can not be done by lmedm04 driver's implementation of
 M88RS2000/TS2020 because I2C messages stop the devices demuxer.
 
 So any polling must be a config option for this driver.

Ummm...  I presume a runtime config option is okay.

Also, does that mean that the lmedm04 driver can't be made compatible with the
DVBv5 API?

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


[PATCH 1/2] TS2020: Calculate tuner gain correctly

2015-05-26 Thread David Howells
The TS2020 and TS2022 tuners take an input from the demodulator indicating the
AGC setting on that component that is then used to influence the tuner's own
gain.  This should be taken into account when calculating the gain and signal
strength.

Further, the existing TS2020 driver miscalculates the signal strength as the
result of its calculations can exceed the storage capacity of the 16-bit word
used to return it to userspace.

To this end:

 (1) Add a callback function (-get_agc_pwm()) in the ts2020_config struct that
 the tuner can call to get the AGC PWM value from the demodulator.

 (2) Modify the TS2020 driver to calculate the gain according to Montage's
 specification with the adjustment that we produce a negative value and
 scale it to 0.001dB units (which is what the DVBv5 API will require):

 (a) Callback to the demodulator to retrieve the AGC PWM value and then
 turn that into Vagc for incorporation in the calculations.  If the
 callback is unset, assume a Vagc of 0.

 (b) Calculate the tuner gain from a combination of Vagc and the tuner's RF
 gain and baseband gain settings.

 (3) Turn this into a percentage signal strength as per Montage's
 specification for return to userspace with the DVBv3 API.

 (4) Provide a function in the M88DS3103 demodulator driver that can be used to
 get the AGC PWM value on behalf of the tuner.

 (5) The ts2020_config.get_agc_pwm function should be set by the code that
 stitches together the drivers for each card.

 For the DVBSky cards that use the M88DS3103 with the TS2020 or the TS2022,
 set the get_agc_pwm function to point to m88ds3103_get_agc_pwm.

I have tested this with a DVBSky S952 card which has an M88DS3103 and a TS2022.

Thanks to Montage for providing access to information about the workings of
these parts.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/dvb-frontends/m88ds3103.c |   16 
 drivers/media/dvb-frontends/m88ds3103.h |2 
 drivers/media/dvb-frontends/ts2020.c|  138 +++
 drivers/media/dvb-frontends/ts2020.h|5 +
 drivers/media/pci/cx23885/cx23885-dvb.c |3 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c   |2 
 6 files changed, 148 insertions(+), 18 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index 50ede6a..0703316 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -52,6 +52,22 @@ err:
return ret;
 }
 
+/*
+ * Get the demodulator AGC PWM voltage setting supplied to the tuner.
+ */
+int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm)
+{
+   struct m88ds3103_dev *dev = fe-demodulator_priv;
+   unsigned tmp;
+   int ret;
+
+   ret = regmap_read(dev-regmap, 0x3f, tmp);
+   if (ret == 0)
+   *_agc_pwm = tmp;
+   return ret;
+}
+EXPORT_SYMBOL(m88ds3103_get_agc_pwm);
+
 static int m88ds3103_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
struct m88ds3103_dev *dev = fe-demodulator_priv;
diff --git a/drivers/media/dvb-frontends/m88ds3103.h 
b/drivers/media/dvb-frontends/m88ds3103.h
index ff03905..04b355a 100644
--- a/drivers/media/dvb-frontends/m88ds3103.h
+++ b/drivers/media/dvb-frontends/m88ds3103.h
@@ -176,6 +176,7 @@ extern struct dvb_frontend *m88ds3103_attach(
const struct m88ds3103_config *config,
struct i2c_adapter *i2c,
struct i2c_adapter **tuner_i2c);
+extern int m88ds3103_get_agc_pwm(struct dvb_frontend *fe, u8 *_agc_pwm);
 #else
 static inline struct dvb_frontend *m88ds3103_attach(
const struct m88ds3103_config *config,
@@ -185,6 +186,7 @@ static inline struct dvb_frontend *m88ds3103_attach(
pr_warn(%s: driver disabled by Kconfig\n, __func__);
return NULL;
 }
+#define m88ds3103_get_agc_pwm NULL
 #endif
 
 #endif
diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index f674717..277e1cf 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -32,6 +32,7 @@ struct ts2020_priv {
struct regmap_config regmap_config;
struct regmap *regmap;
struct dvb_frontend *fe;
+   int (*get_agc_pwm)(struct dvb_frontend *fe, u8 *_agc_pwm);
/* i2c details */
int i2c_address;
struct i2c_adapter *i2c;
@@ -313,32 +314,132 @@ static int ts2020_get_if_frequency(struct dvb_frontend 
*fe, u32 *frequency)
return 0;
 }
 
-/* read TS2020 signal strength */
-static int ts2020_read_signal_strength(struct dvb_frontend *fe,
-   u16 *signal_strength)
+/*
+ * Get the tuner gain.
+ * @fe: The front end for which we're determining the gain
+ * @v_agc: The voltage of the AGC from the demodulator (0-2600mV)
+ * @_gain: Where to store the gain (in 0.001dB units)
+ *
+ * Returns 0 or a negative error

[PATCH 2/2] ts2020: Provide DVBv5 API signal strength

2015-05-26 Thread David Howells
Provide a DVBv5 API signal strength.  This is in units of 0.001 dBm rather
than a percentage.

From Antti Palosaari's testing with a signal generator, it appears that the
gain calculated according to Montage's specification if negated is a
reasonable representation of the signal strength of the generator.

To this end:

 (1) Polled statistic gathering needed to be implemented in the TS2020 driver.
 This is done in the ts2020_stat_work() function.

 (2) The calculated gain is placed as the signal strength in the
 dtv_property_cache associated with the front end with the scale set to
 FE_SCALE_DECIBEL.

 (3) The DVBv3 format signal strength then needed to be calculated from the
 signal strength stored in the dtv_property_cache rather than accessing
 the value when ts2020_read_signal_strength() is called.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/dvb-frontends/ts2020.c |   62 +-
 1 file changed, 53 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 277e1cf..80ae039 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -32,10 +32,11 @@ struct ts2020_priv {
struct regmap_config regmap_config;
struct regmap *regmap;
struct dvb_frontend *fe;
+   struct delayed_work stat_work;
int (*get_agc_pwm)(struct dvb_frontend *fe, u8 *_agc_pwm);
/* i2c details */
-   int i2c_address;
struct i2c_adapter *i2c;
+   int i2c_address;
u8 clk_out:2;
u8 clk_out_div:5;
u32 frequency_div; /* LO output divider switch frequency */
@@ -65,6 +66,7 @@ static int ts2020_release(struct dvb_frontend *fe)
 static int ts2020_sleep(struct dvb_frontend *fe)
 {
struct ts2020_priv *priv = fe-tuner_priv;
+   int ret;
u8 u8tmp;
 
if (priv-tuner == TS2020_M88TS2020)
@@ -72,11 +74,18 @@ static int ts2020_sleep(struct dvb_frontend *fe)
else
u8tmp = 0x00;
 
-   return regmap_write(priv-regmap, u8tmp, 0x00);
+   ret = regmap_write(priv-regmap, u8tmp, 0x00);
+   if (ret  0)
+   return ret;
+
+   /* stop statistics polling */
+   cancel_delayed_work_sync(priv-stat_work);
+   return 0;
 }
 
 static int ts2020_init(struct dvb_frontend *fe)
 {
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
struct ts2020_priv *priv = fe-tuner_priv;
int i;
u8 u8tmp;
@@ -138,6 +147,13 @@ static int ts2020_init(struct dvb_frontend *fe)
 reg_vals[i].val);
}
 
+   /* Initialise v5 stats here */
+   c-strength.len = 1;
+   c-strength.stat[0].scale = FE_SCALE_DECIBEL;
+   c-strength.stat[0].uvalue = 0;
+
+   /* Start statistics polling */
+   schedule_delayed_work(priv-stat_work, 0);
return 0;
 }
 
@@ -411,19 +427,46 @@ static int ts2020_get_tuner_gain(struct dvb_frontend *fe, 
__s64 *_gain)
 }
 
 /*
+ * Gather statistics on a regular basis
+ */
+static void ts2020_stat_work(struct work_struct *work)
+{
+   struct ts2020_priv *priv = container_of(work, struct ts2020_priv,
+  stat_work.work);
+   struct i2c_client *client = priv-client;
+   struct dtv_frontend_properties *c = priv-fe-dtv_property_cache;
+   int ret;
+
+   dev_dbg(client-dev, \n);
+
+   ret = ts2020_get_tuner_gain(priv-fe, c-strength.stat[0].svalue);
+   if (ret  0)
+   goto err;
+
+   c-strength.stat[0].scale = FE_SCALE_DECIBEL;
+
+   schedule_delayed_work(priv-stat_work, msecs_to_jiffies(2000));
+   return;
+err:
+   dev_dbg(client-dev, failed=%d\n, ret);
+}
+
+/*
  * Read TS2020 signal strength in v3 format.
  */
 static int ts2020_read_signal_strength(struct dvb_frontend *fe,
-   u16 *signal_strength)
+  u16 *_signal_strength)
 {
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
unsigned strength;
__s64 gain;
-   int ret;
 
-   /* Determine the total gain of the tuner */
-   ret = ts2020_get_tuner_gain(fe, gain);
-   if (ret  0)
-   return ret;
+   if (c-strength.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
+   *_signal_strength = 0;
+   return 0;
+   }
+
+   gain = c-strength.stat[0].svalue;
 
/* Calculate the signal strength based on the total gain of the tuner */
if (gain  -85000)
@@ -439,7 +482,7 @@ static int ts2020_read_signal_strength(struct dvb_frontend 
*fe,
/* 90% - 99%: strong signal */
strength = 90 + (45000 + gain) / 5000;
 
-   *signal_strength = strength * 65535 / 100;
+   *_signal_strength = strength * 65535 / 100;
return 0;
 }
 
@@ -546,6 +589,7 @@ static int ts2020_probe(struct

[PATCH] libdvbv5: Retry FE_GET_PROPERTY ioctl if it returns EAGAIN

2015-04-14 Thread David Howells
Retry the FE_GET_PROPERTY ioctl used to determine if we have a DVBv5 device
if it returns EAGAIN indicating the driver is currently locked by the kernel.

Also skip over subsequent information gathering calls to FE_GET_PROPERTY
that return EAGAIN.

Original-author: Mauro Carvalho Chehab mche...@osg.samsung.com
Signed-off-by: David Howells dhowe...@redhat.com
---
 dvb-fe.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index 04ad907..3657334 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -171,9 +171,12 @@ struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int 
frontend,
dtv_prop.props = parms-dvb_prop;
 
/* Detect a DVBv3 device */
-   if (ioctl(fd, FE_GET_PROPERTY, dtv_prop) == -1) {
+   while (ioctl(fd, FE_GET_PROPERTY, dtv_prop) == -1) {
+   if (errno == EAGAIN)
+   continue;
parms-dvb_prop[0].u.data = 0x300;
parms-dvb_prop[1].u.data = SYS_UNDEFINED;
+   break;
}
parms-p.version = parms-dvb_prop[0].u.data;
parms-p.current_sys = parms-dvb_prop[1].u.data;
@@ -1336,8 +1339,11 @@ int dvb_fe_get_stats(struct dvb_v5_fe_parms *p)
props.props = parms-stats.prop;
 
/* Do a DVBv5.10 stats call */
-   if (ioctl(parms-fd, FE_GET_PROPERTY, props) == -1)
+   if (ioctl(parms-fd, FE_GET_PROPERTY, props) == -1) {
+   if (errno == EAGAIN)
+   return 0;
goto dvbv3_fallback;
+   }
 
/*
 * All props with len=0 mean that this device doesn't have any
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] dvb: Document FE_SCALE_DECIBEL units consistently

2015-04-09 Thread David Howells
In comments and in the documentation, the units of properties marked with the
FE_SCALE_DECIBEL scale are specified in terms of 1/1000 dB or 0.0001 dB.  This
is inconsistent, however, as 1/1000 is 0.001, not 0.0001.

Note that the v4l-utils divide the value by 1000 for the signal strength
suggesting that the 1/1000 is correct.

Settle on millidecibels, ie. 1/1000dB or 0.001dB.

Signed-off-by: David Howells dhowe...@redhat.com
---

 Documentation/DocBook/media/dvb/dvbproperty.xml |4 ++--
 include/uapi/linux/dvb/frontend.h   |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/dvb/dvbproperty.xml 
b/Documentation/DocBook/media/dvb/dvbproperty.xml
index 3018564..7ddab2b 100644
--- a/Documentation/DocBook/media/dvb/dvbproperty.xml
+++ b/Documentation/DocBook/media/dvb/dvbproperty.xml
@@ -953,7 +953,7 @@ enum fe_interleaving {
paraPossible scales for this metric are:/para
itemizedlist mark='bullet'

listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - it failed to 
measure it, or the measurement was not complete yet./para/listitem
-   listitemparaconstantFE_SCALE_DECIBEL/constant - 
signal strength is in 0.0001 dBm units, power measured in miliwatts. This value 
is generally negative./para/listitem
+   listitemparaconstantFE_SCALE_DECIBEL/constant - 
signal strength is in 0.001 dBm units, power measured in miliwatts. This value 
is generally negative./para/listitem
listitemparaconstantFE_SCALE_RELATIVE/constant 
- The frontend provides a 0% to 100% measurement for power (actually, 0 to 
65535)./para/listitem
/itemizedlist
/section
@@ -963,7 +963,7 @@ enum fe_interleaving {
paraPossible scales for this metric are:/para
itemizedlist mark='bullet'

listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - it failed to 
measure it, or the measurement was not complete yet./para/listitem
-   listitemparaconstantFE_SCALE_DECIBEL/constant - 
Signal/Noise ratio is in 0.0001 dB units./para/listitem
+   listitemparaconstantFE_SCALE_DECIBEL/constant - 
Signal/Noise ratio is in 0.001 dB units./para/listitem
listitemparaconstantFE_SCALE_RELATIVE/constant 
- The frontend provides a 0% to 100% measurement for Signal/Noise (actually, 0 
to 65535)./para/listitem
/itemizedlist
/section
diff --git a/include/uapi/linux/dvb/frontend.h 
b/include/uapi/linux/dvb/frontend.h
index c56d77c..466f569 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -467,7 +467,7 @@ struct dtv_cmds_h {
  * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
  * could indicate a temporary or a permanent
  * condition.
- * @FE_SCALE_DECIBEL: The scale is measured in 0.0001 dB steps, typically
+ * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically
  *   used on signal measures.
  * @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
  * ranging from 0 (0%) to 0x (100%).
@@ -516,7 +516,7 @@ struct dtv_stats {
__u8 scale; /* enum fecap_scale_params type */
union {
__u64 uvalue;   /* for counters and relative scales */
-   __s64 svalue;   /* for 0.0001 dB measures */
+   __s64 svalue;   /* for 0.001 dB measures */
};
 } __attribute__ ((packed));
 

--
To unsubscribe from this list: send the line unsubscribe 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] cx23885: Always initialise dev-slock spinlock

2015-03-26 Thread David Howells
The slock spinlock in the cx23885_dev struct is only initialised if analogue
video is being used, but is used in other places too, leading to the attached
lockdep complaint.

Move the lock initialisation so that it is done unconditionally.

INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 1 PID: 4413 Comm: scandvb Tainted: GW   4.0.0-rc1-fsdevel+ #25
Hardware name: System manufacturer System Product Name/P5Q PRO TURBO, BIOS 0701 
   10/08/2012
  880129d779d8 8162bbdf 0006
  880129d77aa8 810780e3 0001
 0046 0004 81c3f180 
Call Trace:
 [8162bbdf] dump_stack+0x4c/0x65
 [810780e3] __lock_acquire+0x7b5/0x1a0e
 [810799ee] lock_acquire+0x97/0x10c
 [a006494e] ? cx23885_buf_queue+0x69/0x142 [cx23885]
 [8102e9bc] ? amd_set_subcaches+0x19b/0x19b
 [816313b4] _raw_spin_lock_irqsave+0x36/0x4a
 [a006494e] ? cx23885_buf_queue+0x69/0x142 [cx23885]
 [a006494e] cx23885_buf_queue+0x69/0x142 [cx23885]
 [a00662cb] buffer_queue+0x17/0x19 [cx23885]
 [a00382d5] __enqueue_in_driver+0x6a/0x6f [videobuf2_core]
 [a0038ead] vb2_start_streaming+0x37/0x129 [videobuf2_core]
 [a003a6c0] vb2_internal_streamon+0xc5/0x105 [videobuf2_core]
 [a003b889] __vb2_init_fileio+0x224/0x286 [videobuf2_core]
 [a003bcc0] ? vb2_thread_start+0x7b/0x15f [videobuf2_core]
 [a0050182] ? vb2_dvb_start_feed+0x86/0x86 [videobuf2_dvb]
 [a003bd06] vb2_thread_start+0xc1/0x15f [videobuf2_core]
 [8150d393] ? dmx_section_feed_start_filtering+0x2f/0x14f
 [a0050157] vb2_dvb_start_feed+0x5b/0x86 [videobuf2_dvb]
 [8150d461] dmx_section_feed_start_filtering+0xfd/0x14f
 [8150afc7] dvb_dmxdev_filter_start+0x23f/0x315
 [8150b6ad] dvb_demux_do_ioctl+0x1fb/0x556
 [81509e94] dvb_usercopy+0xb4/0x11c
 [8150b4b2] ? dvb_dmxdev_ts_callback+0xd0/0xd0
 [8150a11a] dvb_demux_ioctl+0x10/0x14
 [81144ac4] do_vfs_ioctl+0x3c1/0x474
 [8126f181] ? file_has_perm+0x5b/0x7f
 [810bf6ca] ? __audit_syscall_entry+0xbc/0xde
 [81144bcc] SyS_ioctl+0x55/0x7a
 [81631d52] system_call_fastpath+0x12/0x17

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/pci/cx23885/cx23885-core.c  |1 +
 drivers/media/pci/cx23885/cx23885-video.c |1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-core.c 
b/drivers/media/pci/cx23885/cx23885-core.c
index 1ad4994..7aee76a 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -825,6 +825,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
int i;
 
spin_lock_init(dev-pci_irqmask_lock);
+   spin_lock_init(dev-slock);
 
mutex_init(dev-lock);
mutex_init(dev-gpio_lock);
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 5e93c68..2232b38 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -1137,7 +1137,6 @@ int cx23885_video_register(struct cx23885_dev *dev)
int err;
 
dprintk(1, %s()\n, __func__);
-   spin_lock_init(dev-slock);
 
/* Initialize VBI template */
cx23885_vbi_template = cx23885_video_template;

--
To unsubscribe from this list: send the line unsubscribe 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] m88ts2022: Nested loops shouldn't use the same index variable

2015-03-20 Thread David Howells
There are a pair of nested loops inside m88ts2022_cmd() that use the same
index variable, but for different things.  Split the variable.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/tuners/m88ts2022.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 066e543..cdf9fe5 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -21,7 +21,7 @@
 static int m88ts2022_cmd(struct m88ts2022_dev *dev, int op, int sleep, u8 reg,
u8 mask, u8 val, u8 *reg_val)
 {
-   int ret, i;
+   int ret, i, j;
unsigned int utmp;
struct m88ts2022_reg_val reg_vals[] = {
{0x51, 0x1f - op},
@@ -35,9 +35,9 @@ static int m88ts2022_cmd(struct m88ts2022_dev *dev, int op, 
int sleep, u8 reg,
i=%d op=%02x reg=%02x mask=%02x val=%02x\n,
i, op, reg, mask, val);
 
-   for (i = 0; i  ARRAY_SIZE(reg_vals); i++) {
-   ret = regmap_write(dev-regmap, reg_vals[i].reg,
-   reg_vals[i].val);
+   for (j = 0; j  ARRAY_SIZE(reg_vals); j++) {
+   ret = regmap_write(dev-regmap, reg_vals[j].reg,
+   reg_vals[j].val);
if (ret)
goto err;
}

--
To unsubscribe from this list: send the line unsubscribe 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] cxusb: Use enum to represent table offsets rather than hard-coding numbers

2015-02-17 Thread David Howells
David Howells dhowe...@redhat.com wrote:

 That should really be:
 
   [VID_MEDION_MD95700] = {USB_VID_MEDION, USB_PID_MEDION_MD95700},
 
 since the index number is the model, not the vendor, which brings me to:
 
   [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {USB_VID_DVICO, 
 USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM},
 
 which would be excessively long.

In fact, they're both wrong, since there needs to be a USB_DEVICE() wrapper.

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


[PATCH] cxusb: Use enum to represent table offsets rather than hard-coding numbers [ver #3]

2015-02-17 Thread David Howells
Use enum to represent table offsets rather than hard-coding numbers to avoid
problems with the numbers becoming out of sync with the table.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/usb/dvb-usb/cxusb.c |  155 ++---
 1 file changed, 111 insertions(+), 44 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index f327c49..ffc3704 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1516,28 +1516,95 @@ static void cxusb_disconnect(struct usb_interface *intf)
dvb_usb_device_exit(intf);
 }
 
-static struct usb_device_id cxusb_table [] = {
-   { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
-   { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
-   { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) },
+enum cxusb_table_index {
+   MEDION_MD95700,
+   DVICO_BLUEBIRD_LG064F_COLD,
+   DVICO_BLUEBIRD_LG064F_WARM,
+   DVICO_BLUEBIRD_DUAL_1_COLD,
+   DVICO_BLUEBIRD_DUAL_1_WARM,
+   DVICO_BLUEBIRD_LGZ201_COLD,
+   DVICO_BLUEBIRD_LGZ201_WARM,
+   DVICO_BLUEBIRD_TH7579_COLD,
+   DVICO_BLUEBIRD_TH7579_WARM,
+   DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
+   DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
+   DVICO_BLUEBIRD_DUAL_2_COLD,
+   DVICO_BLUEBIRD_DUAL_2_WARM,
+   DVICO_BLUEBIRD_DUAL_4,
+   DVICO_BLUEBIRD_DVB_T_NANO_2,
+   DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
+   AVERMEDIA_VOLAR_A868R,
+   DVICO_BLUEBIRD_DUAL_4_REV_2,
+   CONEXANT_D680_DMB,
+   MYGICA_D689,
+   MYGICA_T230,
+   NR__cxusb_table_index
+};
+
+static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
+   [MEDION_MD95700] = {
+   USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
+   },
+   [DVICO_BLUEBIRD_LG064F_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
+   },
+   [DVICO_BLUEBIRD_LG064F_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
+   },
+   [DVICO_BLUEBIRD_DUAL_1_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
+   },
+   [DVICO_BLUEBIRD_DUAL_1_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
+   },
+   [DVICO_BLUEBIRD_LGZ201_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
+   },
+   [DVICO_BLUEBIRD_LGZ201_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
+   },
+   [DVICO_BLUEBIRD_TH7579_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
+   },
+   [DVICO_BLUEBIRD_TH7579_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
+   },
+   [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, 
USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
+   },
+   [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, 
USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
+   },
+   [DVICO_BLUEBIRD_DUAL_2_COLD] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
+   },
+   [DVICO_BLUEBIRD_DUAL_2_WARM] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
+   },
+   [DVICO_BLUEBIRD_DUAL_4] = {
+   USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
+   },
+   [DVICO_BLUEBIRD_DVB_T_NANO_2] = {
+   USB_DEVICE(USB_VID_DVICO

[PATCH] cxusb: Use enum to represent table offsets rather than hard-coding numbers [ver #2]

2015-02-17 Thread David Howells
Use enum to represent table offsets rather than hard-coding numbers to avoid
problems with the numbers becoming out of sync with the table.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/usb/dvb-usb/cxusb.c |  113 +++--
 1 file changed, 69 insertions(+), 44 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index f327c49..40880c6 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1516,28 +1516,53 @@ static void cxusb_disconnect(struct usb_interface *intf)
dvb_usb_device_exit(intf);
 }
 
-static struct usb_device_id cxusb_table [] = {
-   { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
-   { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
-   { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) },
+enum cxusb_table_index {
+   MEDION_MD95700,
+   DVICO_BLUEBIRD_LG064F_COLD,
+   DVICO_BLUEBIRD_LG064F_WARM,
+   DVICO_BLUEBIRD_DUAL_1_COLD,
+   DVICO_BLUEBIRD_DUAL_1_WARM,
+   DVICO_BLUEBIRD_LGZ201_COLD,
+   DVICO_BLUEBIRD_LGZ201_WARM,
+   DVICO_BLUEBIRD_TH7579_COLD,
+   DVICO_BLUEBIRD_TH7579_WARM,
+   DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
+   DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
+   DVICO_BLUEBIRD_DUAL_2_COLD,
+   DVICO_BLUEBIRD_DUAL_2_WARM,
+   DVICO_BLUEBIRD_DUAL_4,
+   DVICO_BLUEBIRD_DVB_T_NANO_2,
+   DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
+   AVERMEDIA_VOLAR_A868R,
+   DVICO_BLUEBIRD_DUAL_4_REV_2,
+   CONEXANT_D680_DMB,
+   MYGICA_D689,
+   MYGICA_T230,
+   NR__cxusb_table_index
+};
+
+static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
+   [MEDION_MD95700] = { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) 
},
+   [DVICO_BLUEBIRD_LG064F_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
+   [DVICO_BLUEBIRD_LG064F_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
+   [DVICO_BLUEBIRD_DUAL_1_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
+   [DVICO_BLUEBIRD_DUAL_1_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
+   [DVICO_BLUEBIRD_LGZ201_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
+   [DVICO_BLUEBIRD_LGZ201_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
+   [DVICO_BLUEBIRD_TH7579_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
+   [DVICO_BLUEBIRD_TH7579_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
+   [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
+   [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
+   [DVICO_BLUEBIRD_DUAL_2_COLD] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
+   [DVICO_BLUEBIRD_DUAL_2_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
+   [DVICO_BLUEBIRD_DUAL_4] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DUAL_4) },
+   [DVICO_BLUEBIRD_DVB_T_NANO_2] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
+   [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
+   [AVERMEDIA_VOLAR_A868R] = { USB_DEVICE(USB_VID_AVERMEDIA, 
USB_PID_AVERMEDIA_VOLAR_A868R) },
+   [DVICO_BLUEBIRD_DUAL_4_REV_2] = { USB_DEVICE(USB_VID_DVICO

Re: [PATCH] cxusb: Use enum to represent table offsets rather than hard-coding numbers

2015-02-17 Thread David Howells
Mauro Carvalho Chehab mche...@osg.samsung.com wrote:

 I would do a s/ix_USB_PID_// in the above, in order to simplify the
 namespace and to avoid giving the false impression that those are vendor
 IDs.

Okay.

 If you look below on your patch, even you forgot to add a ix_ prefix into
 one of the entires ;)

Bah.  I realised I'd forgotten and went back to try and fix them up.

 Just calling MEDION_MD95700..MYGICA_T230 would be enough and shorter.

True.

 static struct usb_device_id cxusb_table [] = {
   [VID_MEDION] = {USB_VID_MEDION, USB_PID_MEDION_MD95700},
 ...

That should really be:

[VID_MEDION_MD95700] = {USB_VID_MEDION, USB_PID_MEDION_MD95700},

since the index number is the model, not the vendor, which brings me to:

[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM},

which would be excessively long.

  +   _(USB_VID_MEDION,   USB_PID_MEDION_MD95700), // 0
 
 Please don't use c99 comments. Also, I don't think that the comments would
 help, as the entries on this table doesn't need to follow the same order
 as defined at the enum.

Sorry, yes, I meant those as guides purely for when I was converting numbers
to symbols.

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


[PATCH] cxusb: Use enum to represent table offsets rather than hard-coding numbers

2015-02-16 Thread David Howells
Use enum to represent table offsets rather than hard-coding numbers to avoid
problems with the numbers becoming out of sync with the table.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/usb/dvb-usb/cxusb.c |  115 +++--
 1 file changed, 71 insertions(+), 44 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index f327c49..5bb1c5c 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1516,28 +1516,55 @@ static void cxusb_disconnect(struct usb_interface *intf)
dvb_usb_device_exit(intf);
 }
 
-static struct usb_device_id cxusb_table [] = {
-   { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
-   { USB_DEVICE(USB_VID_DVICO, 
USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
-   { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
-   { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
-   { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) },
+enum cxusb_table_index {
+   ix_USB_PID_MEDION_MD95700,
+   ix_USB_PID_DVICO_BLUEBIRD_LG064F_COLD,
+   ix_USB_PID_DVICO_BLUEBIRD_LG064F_WARM,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM,
+   ix_USB_PID_DVICO_BLUEBIRD_LGZ201_COLD,
+   ix_USB_PID_DVICO_BLUEBIRD_LGZ201_WARM,
+   ix_USB_PID_DVICO_BLUEBIRD_TH7579_COLD,
+   ix_USB_PID_DVICO_BLUEBIRD_TH7579_WARM,
+   ix_USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
+   ix_USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_4,
+   ix_USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2,
+   ix_USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
+   ix_USB_PID_AVERMEDIA_VOLAR_A868R,
+   ix_USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2,
+   ix_USB_PID_CONEXANT_D680_DMB,
+   ix_USB_PID_MYGICA_D689,
+   ix_USB_PID_MYGICA_T230,
+   NR__cxusb_table_index
+};
+
+static struct usb_device_id cxusb_table [NR__cxusb_table_index + 1] = {
+#define _(vend, prod) [ix_##prod] = { vend, prod }
+   _(USB_VID_MEDION,   USB_PID_MEDION_MD95700), // 0
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_LG064F_COLD),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_LG064F_WARM), // 2
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM), // 4
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_LGZ201_COLD),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_LGZ201_WARM), // 6
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_TH7579_COLD),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_TH7579_WARM), // 8
+   _(USB_VID_DVICO,USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD),
+   _(USB_VID_DVICO,USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM), // 10
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM), // 12
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_4),
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2), // 14
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM),
+   _(USB_VID_AVERMEDIA,USB_PID_AVERMEDIA_VOLAR_A868R), // 16
+   _(USB_VID_DVICO,USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2),
+   _(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB), // 18
+   _(USB_VID_CONEXANT, USB_PID_MYGICA_D689),
+   _(USB_VID_CONEXANT, USB_PID_MYGICA_T230), // 20
+#undef _
{}  /* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, cxusb_table);
@@ -1581,7 +1608,7 @@ static struct

[PATCH] CONFIG_VIDEO_DEV needs to be enabled by MEDIA_DIGITAL_TV_SUPPORT also

2015-02-15 Thread David Howells
CONFIG_VIDEO_DEV needs to be enabled by MEDIA_DIGITAL_TV_SUPPORT so that DVB
TV receiver drivers can be enabled.

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 49cd308..52d4a20 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -102,7 +102,7 @@ config MEDIA_CONTROLLER
 config VIDEO_DEV
tristate
depends on MEDIA_SUPPORT
-   depends on MEDIA_CAMERA_SUPPORT || MEDIA_ANALOG_TV_SUPPORT || 
MEDIA_RADIO_SUPPORT || MEDIA_SDR_SUPPORT
+   depends on MEDIA_CAMERA_SUPPORT || MEDIA_ANALOG_TV_SUPPORT || 
MEDIA_DIGITAL_TV_SUPPORT || MEDIA_RADIO_SUPPORT || MEDIA_SDR_SUPPORT
default y
 
 config VIDEO_V4L2_SUBDEV_API

--
To unsubscribe from this list: send the line unsubscribe 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: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells

I think I've isolated the significant part of the demod register setup.
Discarding the reads and sorting them in address order, I see

ANTTI   DVBSKY  DIFFER?
=== === ===
demod_write(22, [ac])   demod_write(22, [ac])   no
demod_write(24, [5c])   demod_write(24, [5c])   no
demod_write(25, [8a])   YES
demod_write(29, [80])   demod_write(29, [80])   no
demod_write(30, [08])   demod_write(30, [08])   no
demod_write(33, [00])   YES
demod_write(4d, [91])   demod_write(4d, [91])   no
demod_write(56, [00])   YES
demod_write(61, [5549]) demod_write(61, [55])   no
  demod_write(62, [49])   no
demod_write(76, [38])   YES
demod_write(c3, [08])   demod_write(c3, [08])   no
demod_write(c4, [08])   demod_write(c4, [08])   no
demod_write(c7, [00])   demod_write(c7, [00])   no
demod_write(c8, [06])   demod_write(c8, [06])   no
demod_write(ea, [ff])   demod_write(ea, [ff])   no
demod_write(fd, [46])   demod_write(fd, [06])   YES
demod_write(fe, [6f])   demod_write(fe, [6f])   no

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells
Antti Palosaari cr...@iki.fi wrote:

  demod_write(33, [00])   YES
 
 That is config option already. Did you set value? If yes, then there is driver
 bug. If not, then add value.

But you don't give me the option of _not_ setting it.  The dvbsky driver sets
it to 0x35 in its init_tab[] - as does yours - and then leaves it alone.

  demod_write(76, [38])   YES
 
 on init table

Whilst that may be so, something clears it between one call to
m88ds3103_set_frontend() and the next, so you probably need to unconditionally
reload the program init table.

 So hard code those bugs, if you already didn't, 0x33=0x99, 0x56=0x00,
 0xfd=0x46 and make test. Do that same to find out all buggy registers until it
 performs as it should.

I've made my version of your driver now set up the demod regs as per the
dvbsky driver for:

S 11919000 V 2750 3/4

but:

./scan-s2/scan-s2 -a1 ./e.1 /tmp/s -O S9.0E -D S2

still doesn't work for your driver, despite two goes at tuning.  I guess I
need to check the tuner writes too.

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells
David Howells dhowe...@redhat.com wrote:

 I guess I need to check the tuner writes too.

From dvbsky:

TUNER_write(10, [0a])
TUNER_write(11, [40])

and from your driver:

TUNER_write(10, [0b40])

That would appear to be some sort of tuner frequency setting?

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells
David Howells dhowe...@redhat.com wrote:

  I guess I need to check the tuner writes too.
 
 From dvbsky:
 
   TUNER_write(10, [0a])
   TUNER_write(11, [40])
 
 and from your driver:
 
   TUNER_write(10, [0b40])
 
 That would appear to be some sort of tuner frequency setting?

Setting it to 0x0a in the driver doesn't seem to help.

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells
Antti Palosaari cr...@iki.fi wrote:

  But you don't give me the option of _not_ setting it.  The dvbsky driver
  sets it to 0x35 in its init_tab[] - as does yours - and then leaves it
  alone.
 
 So what? Do you understand meaning of init tables?

Yes.  You misunderstand what I'm saying.  You unconditionally write cfg-agc
to port 0x33 in m88ds3103_set_frontend() after loading the init tables.  Why
do you need to do that at all if the default is fine?  You don't give me the
option of saying that I want to stick with the default and not change it.

 Just set correct value there and it should be OK.
 +   .agc = 0x99,

Why is 0x99 correct?  The default is 0x35 and the dvbsky driver does not alter
it from that.

Btw, setting it to 0x99 has no obvious effect over leaving it as the default.

  Whilst that may be so, something clears it between one call to
  m88ds3103_set_frontend() and the next, so you probably need to
  unconditionally reload the program init table.
 
 It is programmed conditionally to avoid I/O.

Obviously.

Nonetheless, register 0x76 seems to change its value between passes through
your code without you touching it inbetween:-/

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-15 Thread David Howells
Antti Palosaari cr...@iki.fi wrote:

  I guess I need to check the tuner writes too.
 
 From dvbsky:
 
  TUNER_write(10, [0a])
  TUNER_write(11, [40])
 
  and from your driver:
 
  TUNER_write(10, [0b40])
 
  That would appear to be some sort of tuner frequency setting?
 
 ... and the result is same, reg 10 will be 0a and reg 11 40. It is register
 write using register address auto-increment. The later one is I/O optimized.

Yes, I understand that.  However, reg 10 is set to 0a in one driver and 0b in
the other.

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


Re: I2C transfer logs for Antti's DS3103 driver and DVBSky's DS3103 driver

2013-11-14 Thread David Howells
David Howells dhowe...@redhat.com wrote:

 Here are four logs from doing:
 
   scandvb -a1 ./e.1
 
 where the contents of file e.1 are:
 
   S 11919000 V 2750 3/4
 
 which is probing a region on the Eutelsat-9A satellite broadcast.

Here's a script for turning the logs from:

I2C cx23885[0]: RD 60 1
I2C m88ds3103: WR 60 2 [0003]
I2C cx23885[0]: WR 68 2 [0311]
I2C cx23885[0]: WR 60 2 [0003]
I2C m88ds3103: WR 60 1 [00]

into something that looks like:

demod_read(23)
demod_write(23, [1f])
TUNER_read(00)
TUNER_write(00, [03])
TUNER_read(00)

and checks for and hides the tuner gate opening commands to the ds3103.

David
---
#!/usr/bin/perl -w

use strict;

my $last_adap = 0;
my $last_dev = 0;
my $last_reg = 0;
my $tuner_gate = 0;

while () {
chomp;
if (/^I2C ([^:]*): RD ([0-9A-Fa-f]{2}) ([0-9]{1,2})/) {
my $adap = $1;
my $dev = $2;
my $n = $3;

die if ($dev ne 6b  $dev ne $last_dev);

if ($dev eq 68) {
# Demodulator register
die if ($tuner_gate);
print demod_read(, $last_reg, )\n;
} elsif ($dev eq 60) {
# Tuner register

# Ignore stuff on the internal tuner-demod bus in Antti's driver
next if ($adap eq m88ds3103);

die if (!$tuner_gate);
$tuner_gate = 0;
print TUNER_read(, $last_reg, )\n;
} else {
print RD , $adap,  , $dev,  , $n, \n;
}

} elsif (/^I2C ([^:]*): WR ([0-9A-Fa-f]{2}) ([0-9]{1,2}) 
[[]([0-9A-Fa-f]{2,})[]]/) {
my $adap = $1;
my $dev = $2;
my $n = $3;
my $data = $4;

$last_adap = $adap;
$last_dev = $dev;

die if (int($n) = 0);
die if (length($data) != int($n) * 2);

if ($dev eq 68) {
# Demodulator register
die if ($tuner_gate);
my $reg = substr($data, 0, 2);
if ($n == 2  $data eq 0311) {
$tuner_gate = 1;
} elsif ($n  1) {
print demod_write(, $reg, , [, substr($data, 2), ])\n;
$last_dev = 0;
} else {
$last_reg = $reg;
}
} elsif ($dev eq 60) {
# Tuner register

# Ignore stuff on the internal tuner-demod bus in Antti's driver
next if ($adap eq m88ds3103);

die if (!$tuner_gate);
my $reg = substr($data, 0, 2);
if ($n  1) {
print TUNER_write(, $reg, , [, substr($data, 2), ])\n;
$last_dev = 0;
$tuner_gate = 0;
} else {
$last_reg = $reg;
}
} else {
print WR , $1,  , $2,  , $3,  , $4, \n;
}
} else {
print;
print \n;
}
}
--
To unsubscribe from this list: send the line unsubscribe 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 16/28] zoran: Don't print proc_dir_entry data in debug [RFC]

2013-04-16 Thread David Howells
Don't print proc_dir_entry data in debug as we're soon to have no direct
access to the contents of the PDE.  Print what was put in there instead.

Signed-off-by: David Howells dhowe...@redhat.com
cc: mjpeg-us...@lists.sourceforge.net
cc: linux-media@vger.kernel.org
---

 drivers/media/pci/zoran/zoran_procfs.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/zoran/zoran_procfs.c 
b/drivers/media/pci/zoran/zoran_procfs.c
index 07a104d..f7ceee0 100644
--- a/drivers/media/pci/zoran/zoran_procfs.c
+++ b/drivers/media/pci/zoran/zoran_procfs.c
@@ -201,7 +201,7 @@ zoran_proc_init (struct zoran *zr)
dprintk(2,
KERN_INFO
%s: procfs entry /proc/%s allocated. data=%p\n,
-   ZR_DEVNAME(zr), name, zr-zoran_proc-data);
+   ZR_DEVNAME(zr), name, zr);
} else {
dprintk(1, KERN_ERR %s: Unable to initialise /proc/%s\n,
ZR_DEVNAME(zr), name);

--
To unsubscribe from this list: send the line unsubscribe 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/28] proc: Supply PDE attribute setting accessor functions [RFC]

2013-04-16 Thread David Howells
Supply accessor functions to set attributes in proc_dir_entry structs.

The following are supplied: proc_set_size() and proc_set_user().

Signed-off-by: David Howells dhowe...@redhat.com
cc: linuxppc-...@lists.ozlabs.org
cc: linux-media@vger.kernel.org
cc: net...@vger.kernel.org
cc: linux-wirel...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: netfilter-de...@vger.kernel.org
cc: alsa-de...@alsa-project.org
---

 arch/powerpc/kernel/proc_powerpc.c|2 +-
 arch/powerpc/platforms/pseries/reconfig.c |2 +-
 drivers/media/pci/ttpci/av7110_ir.c   |2 +-
 drivers/net/irda/vlsi_ir.c|2 +-
 drivers/net/wireless/airo.c   |   34 +
 drivers/pci/proc.c|2 +-
 fs/proc/generic.c |   13 +++
 include/linux/proc_fs.h   |5 
 kernel/configs.c  |2 +-
 kernel/profile.c  |2 +-
 net/netfilter/xt_recent.c |3 +--
 sound/core/info.c |2 +-
 12 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/kernel/proc_powerpc.c 
b/arch/powerpc/kernel/proc_powerpc.c
index 41d8ee9..feb8580 100644
--- a/arch/powerpc/kernel/proc_powerpc.c
+++ b/arch/powerpc/kernel/proc_powerpc.c
@@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void)
   page_map_fops, vdso_data);
if (!pde)
return 1;
-   pde-size = PAGE_SIZE;
+   proc_set_size(pde, PAGE_SIZE);
 
return 0;
 }
diff --git a/arch/powerpc/platforms/pseries/reconfig.c 
b/arch/powerpc/platforms/pseries/reconfig.c
index d6491bd..f93cdf5 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void)
 
ent = proc_create(powerpc/ofdt, S_IWUSR, NULL, ofdt_fops);
if (ent)
-   ent-size = 0;
+   proc_set_size(ent, 0);
 
return 0;
 }
diff --git a/drivers/media/pci/ttpci/av7110_ir.c 
b/drivers/media/pci/ttpci/av7110_ir.c
index eb82286..0e763a7 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110)
if (av_cnt == 1) {
e = proc_create(av7110_ir, S_IWUSR, NULL, 
av7110_ir_proc_fops);
if (e)
-   e-size = 4 + 256 * sizeof(u16);
+   proc_set_size(e, 4 + 256 * sizeof(u16));
}
 
tasklet_init(av7110-ir.ir_tasklet, av7110_emit_key, (unsigned long) 
av7110-ir);
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index e22cd4e..5f47584 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
IRDA_WARNING(%s: failed to create proc entry\n,
 __func__);
} else {
-   ent-size = 0;
+   proc_set_size(ent, 0);
}
idev-proc_entry = ent;
}
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 66e398d..21d0233 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev,
airo_entry);
if (!apriv-proc_entry)
goto fail;
-   apriv-proc_entry-uid = proc_kuid;
-   apriv-proc_entry-gid = proc_kgid;
+   proc_set_user(apriv-proc_entry, proc_kuid, proc_kgid);
 
/* Setup the StatsDelta */
entry = proc_create_data(StatsDelta, S_IRUGO  proc_perm,
 apriv-proc_entry, proc_statsdelta_ops, dev);
if (!entry)
goto fail_stats_delta;
-   entry-uid = proc_kuid;
-   entry-gid = proc_kgid;
+   proc_set_user(entry, proc_kuid, proc_kgid);
 
/* Setup the Stats */
entry = proc_create_data(Stats, S_IRUGO  proc_perm,
 apriv-proc_entry, proc_stats_ops, dev);
if (!entry)
goto fail_stats;
-   entry-uid = proc_kuid;
-   entry-gid = proc_kgid;
+   proc_set_user(entry, proc_kuid, proc_kgid);
 
/* Setup the Status */
entry = proc_create_data(Status, S_IRUGO  proc_perm,
 apriv-proc_entry, proc_status_ops, dev);
if (!entry)
goto fail_status;
-   entry-uid = proc_kuid;
-   entry-gid = proc_kgid;
+   proc_set_user(entry, proc_kuid, proc_kgid);
 
/* Setup the Config */
entry = proc_create_data(Config, proc_perm,
 apriv-proc_entry, proc_config_ops, dev);
if (!entry)
goto fail_config;
-   entry-uid

Re: [GIT PULL] Disintegrate UAPI for media

2012-10-11 Thread David Howells
Mauro Carvalho Chehab mche...@infradead.org wrote:

 My understanding here is that, as the file location will change
 with this series, your original concern is now void, as userspace
 will require patches to use the new location. So, if we're willing
 to do it, let's put this one-driver-only obsolete API on a separate
 place.

As far as userspace is concerned, things will not change.  The header
installation step will copy the uapi/ headers to the place it used to copy the
non-uapi header.

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


Re: [GIT PULL] Disintegrate UAPI for media

2012-10-10 Thread David Howells
Mauro Carvalho Chehab mche...@infradead.org wrote:

 Hmm... last year, it was decided that we would be putting the DVB av7110-only
 API files on a separate place, as the API there conflicts with V4L/alsa APIs
 and are used only by one upstream driver (there were two drivers using them,
 at that time). As you might notice, av7110 hardware is really old, not 
 manufactured anymore since maybe 10 years ago, and it is an unmaintained
 driver.
 
 Some developers complained, arguing that moving it to a separate file would
 be breaking the compilation on existing tools (they're basically concerned
 with it due to out-of-tree drivers - mostly propietary ones, that use this
 API).

As long as they're relying on the -I flags provided by the build tree, that
oughtn't to be a problem.  If they're doing their own -I flags, they'll need
to add -I include/uapi too (_after_ -I include).

 Now that we're moving everything, it does make sense to do that, moving 
 dvb/(audio|osd|video).h to someplace else (maybe linux/dvb/av7110.h or
 linux/dvb/legacy/*.h).

Do you want me to do anything?  I should be able to incorporate a patch prior
to the disintegration of linux/dvb/ if you have one.

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


[GIT PULL] Disintegrate UAPI for media

2012-10-09 Thread David Howells
Can you merge the following branch into the media tree please.

This is to complete part of the Userspace API (UAPI) disintegration for which
the preparatory patches were pulled recently.  After these patches, userspace
headers will be segregated into:

include/uapi/linux/.../foo.h

for the userspace interface stuff, and:

include/linux/.../foo.h

for the strictly kernel internal stuff.

---
The following changes since commit 9e2d8656f5e8aa214e66b462680cf86b210b74a8:

  Merge branch 'akpm' (Andrew's patch-bomb) (2012-10-09 16:23:15 +0900)

are available in the git repository at:


  git://git.infradead.org/users/dhowells/linux-headers.git 
tags/disintegrate-media-20121009

for you to fetch changes up to 1c436decd49665be131887b08d172a7989cdceee:

  UAPI: (Scripted) Disintegrate include/linux/dvb (2012-10-09 09:48:42 +0100)


UAPI Disintegration 2012-10-09


David Howells (1):
  UAPI: (Scripted) Disintegrate include/linux/dvb

 include/linux/dvb/Kbuild|   8 -
 include/linux/dvb/dmx.h | 130 +--
 include/linux/dvb/video.h   | 249 +
 include/uapi/linux/dvb/Kbuild   |   8 +
 include/{ = uapi}/linux/dvb/audio.h|   0
 include/{ = uapi}/linux/dvb/ca.h   |   0
 include/uapi/linux/dvb/dmx.h| 155 ++
 include/{ = uapi}/linux/dvb/frontend.h |   0
 include/{ = uapi}/linux/dvb/net.h  |   0
 include/{ = uapi}/linux/dvb/osd.h  |   0
 include/{ = uapi}/linux/dvb/version.h  |   0
 include/uapi/linux/dvb/video.h  | 274 
 12 files changed, 439 insertions(+), 385 deletions(-)
 rename include/{ = uapi}/linux/dvb/audio.h (100%)
 rename include/{ = uapi}/linux/dvb/ca.h (100%)
 create mode 100644 include/uapi/linux/dvb/dmx.h
 rename include/{ = uapi}/linux/dvb/frontend.h (100%)
 rename include/{ = uapi}/linux/dvb/net.h (100%)
 rename include/{ = uapi}/linux/dvb/osd.h (100%)
 rename include/{ = uapi}/linux/dvb/version.h (100%)
 create mode 100644 include/uapi/linux/dvb/video.h
.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Soft lockup in mb86a16_search()

2011-09-22 Thread David Howells

My mythtv receiver machine crashes when I start mythbackend with a soft lockup
warning in mb86a16_search().  Shortly thereafter the machine becomes
unresponsive and has to be reset.  Relevant highlights of dmesg attached
below.

The kernel is Fedora 15's kernel-2.6.40.4-5.fc15.x86_64.

David
---
IR Sony protocol handler initialized
dib0700: loaded with support for 20 different device-types
dvb-usb: found a 'Hauppauge Nova-T 500 Dual DVB-T' in warm state.
dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
DVB: registering new adapter (Hauppauge Nova-T 500 Dual DVB-T)
lirc_dev: IR Remote Control driver registered, major 250 
IR LIRC bridge handler initialized
DVB: registering adapter 1 frontend 0 (DiBcom 3000MC/P)...
MT2060: successfully identified (IF1 = 1257)
DVB: registering adapter 0 frontend 0 (Fujitsu MB86A16 DVB-S)...
dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
DVB: registering new adapter (Hauppauge Nova-T 500 Dual DVB-T)
DVB: registering adapter 2 frontend 0 (DiBcom 3000MC/P)...
MT2060: successfully identified (IF1 = 1243)
input: IR-receiver inside an USB DVB receiver as 
/devices/pci:00/:00:1e.0/:05:00.2/usb3/3-1/rc/rc0/input3
rc0: IR-receiver inside an USB DVB receiver as 
/devices/pci:00/:00:1e.0/:05:00.2/usb3/3-1/rc/rc0
dvb-usb: schedule remote query interval to 50 msecs.
dvb-usb: Hauppauge Nova-T 500 Dual DVB-T successfully initialized and connected.
dib0700: rc submit urb failed

usbcore: registered new interface driver dvb_usb_dib0700
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_write: writing to [0x08],Reg[0x16],Data[0x80]
mb86a16_write: writing to [0x08],Reg[0x1e],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x20],Data[0x04]
mb86a16_set_fe: freq=0 Mhz, symbrt=0 Ksps
mb86a16_write: writing to [0x08],Reg[0x32],Data[0x02]
mb86a16_write: writing to [0x08],Reg[0x06],Data[0xdf]
mb86a16_write: writing to [0x08],Reg[0x0a],Data[0x3d]
mb86a16_write: writing to [0x08],Reg[0x2b],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x2c],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x58],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x59],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x08],Data[0x16]
mb86a16_write: writing to [0x08],Reg[0x2f],Data[0x21]
mb86a16_write: writing to [0x08],Reg[0x39],Data[0x38]
mb86a16_write: writing to [0x08],Reg[0x3d],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x3e],Data[0x1c]
mb86a16_write: writing to [0x08],Reg[0x3f],Data[0x20]
mb86a16_write: writing to [0x08],Reg[0x40],Data[0x1e]
mb86a16_write: writing to [0x08],Reg[0x41],Data[0x23]
mb86a16_write: writing to [0x08],Reg[0x54],Data[0xff]
mb86a16_write: writing to [0x08],Reg[0x00],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x2d],Data[0x1a]
mb86a16_write: writing to [0x08],Reg[0x49],Data[0x7a]
mb86a16_write: writing to [0x08],Reg[0x2a],Data[0x26]
mb86a16_write: writing to [0x08],Reg[0x36],Data[0x06]
mb86a16_write: writing to [0x08],Reg[0x33],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x03],Data[0x17]
mb86a16_write: writing to [0x08],Reg[0x04],Data[0x00]
mb86a16_write: writing to [0x08],Reg[0x05],Data[0x00]
BUG: soft lockup - CPU#1 stuck for 22s! [kdvb-ad-0-fe-0:2831]
Modules linked in: sunrpc cpufreq_ondemand acpi_cpufreq mperf w83627ehf 
hwmon_vid coretemp rc_dib0700_rc5 xfs mb86a16 mt2060 ir_lirc_codec lirc_dev 
dvb_usb_dib0700 dib7000p ir_sony_decoder dib0090 dib7000m dib0070 dvb_usb 
dib8000 dib9000 dib3000mc dibx000_common ir_jvc_decoder ir_rc6_decoder iTCO_wdt 
atl1e i2c_i801 iTCO_vendor_support ir_rc5_decoder microcode mantis mantis_core 
dvb_core ir_nec_decoder asus_atk0110 rc_core ipv6 pata_acpi ata_generic 
pata_jmicron nouveau ttm drm_kms_helper drm i2c_algo_bit 

[PATCH] V4L/DVB: lgs8gxx: Use shifts rather than multiply/divide when possible

2009-12-11 Thread David Howells
If val is a u64, then following:

val *= (u64)1  32;
val /= (u64)1  32;

should surely be better represented as:

val = 32;
val = 32;

Especially as, for the division, the compiler might want to actually do a
division:

drivers/built-in.o: In function `lgs8gxx_get_afc_phase':
drivers/media/dvb/frontends/lgs8gxx.c:250: undefined reference to `__udivdi3'

Signed-off-by: David Howells dhowe...@redhat.com
---

 drivers/media/dvb/frontends/lgs8gxx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/drivers/media/dvb/frontends/lgs8gxx.c 
b/drivers/media/dvb/frontends/lgs8gxx.c
index eabcadc..dee5396 100644
--- a/drivers/media/dvb/frontends/lgs8gxx.c
+++ b/drivers/media/dvb/frontends/lgs8gxx.c
@@ -199,7 +199,7 @@ static int lgs8gxx_set_if_freq(struct lgs8gxx_state *priv, 
u32 freq /*in kHz*/)
 
val = freq;
if (freq != 0) {
-   val *= (u64)1  32;
+   val = 32;
if (if_clk != 0)
do_div(val, if_clk);
v32 = val  0x;
@@ -246,7 +246,7 @@ static int lgs8gxx_get_afc_phase(struct lgs8gxx_state *priv)
 
val = v32;
val *= priv-config-if_clk_freq;
-   val /= (u64)1  32;
+   val = 32;
dprintk(AFC = %u kHz\n, (u32)val);
return 0;
 }

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