Re: [REVIEW PATCH 08/16] rtl2832_sdr: Realtek RTL2832 SDR driver module

2014-02-26 Thread Antti Palosaari

Moikka!

On 14.02.2014 16:57, Hans Verkuil wrote:

On 02/11/2014 03:04 AM, Antti Palosaari wrote:



+static int rtl2832_sdr_stop_streaming(struct vb2_queue *vq)
+{
+   struct rtl2832_sdr_state *s = vb2_get_drv_priv(vq);
+   dev_dbg(&s->udev->dev, "%s:\n", __func__);
+
+   if (mutex_lock_interruptible(&s->v4l2_lock))
+   return -ERESTARTSYS;


Just use mutex_lock here. The return code of stop_streaming is never checked
so stop_streaming must always succeed. Personally I am in favor of changing
the return code of stop_streaming to void since it simply doesn't make sense
to return an error here.


I decided not to change that at this time. My brains are so sleepy just 
now that I cannot think about it on the level I would like. IIRC did 
similar change to DVB USB year or two back as it happens some signal was 
coming from userspace (crtl+C) and it breaks out too early without 
putting hw to sleep. So I think that there should not be interruptible 
mutex in any patch where is I/O done. But that is similarly to other 
drivers too, feel free to fix all those if you wish :)


regards
Antti

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


[REVIEW PATCH 08/16] rtl2832_sdr: Realtek RTL2832 SDR driver module

2014-02-26 Thread Antti Palosaari
Implement SDR driver for Realtek RTL2832U chip as a DVB extension
module. SDR module is attached by DVB USB RTL28XXU driver as a DVB
SEC (satellite equipment controller) module. Abusing unused SEC here
has no harm as that is DVB-T only frontend.

SDR functionality is provided by RTL2832 DVB-T demodulator. I suspect
it is originally planned for DAB and FM, but it could be abused general
SDR, due to modern silicon tuners that has wide frequency range and a
lot of configurable parameters (filters, gains, ...).

http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/44461

Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/Kconfig|2 +
 drivers/staging/media/Makefile   |2 +
 drivers/staging/media/rtl2832u_sdr/Kconfig   |7 +
 drivers/staging/media/rtl2832u_sdr/Makefile  |6 +
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 1470 ++
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h |   51 +
 6 files changed, 1538 insertions(+)
 create mode 100644 drivers/staging/media/rtl2832u_sdr/Kconfig
 create mode 100644 drivers/staging/media/rtl2832u_sdr/Makefile
 create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
 create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h

diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 22b0c9d..a9f2e63 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -41,6 +41,8 @@ source "drivers/staging/media/solo6x10/Kconfig"
 
 source "drivers/staging/media/omap4iss/Kconfig"
 
+source "drivers/staging/media/rtl2832u_sdr/Kconfig"
+
 # Keep LIRC at the end, as it has sub-menus
 source "drivers/staging/media/lirc/Kconfig"
 
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index bedc62a..8e2c5d2 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
 obj-$(CONFIG_USB_SN9C102)   += sn9c102/
 obj-$(CONFIG_VIDEO_OMAP2)   += omap24xx/
 obj-$(CONFIG_VIDEO_TCM825X) += omap24xx/
+obj-$(CONFIG_DVB_RTL2832_SDR)  += rtl2832u_sdr/
+
diff --git a/drivers/staging/media/rtl2832u_sdr/Kconfig 
b/drivers/staging/media/rtl2832u_sdr/Kconfig
new file mode 100644
index 000..3ede5fe
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Kconfig
@@ -0,0 +1,7 @@
+config DVB_RTL2832_SDR
+   tristate "Realtek RTL2832 SDR"
+   depends on USB && DVB_CORE && I2C && VIDEO_V4L2 && DVB_USB_RTL28XXU
+   select DVB_RTL2832
+   select VIDEOBUF2_VMALLOC
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+
diff --git a/drivers/staging/media/rtl2832u_sdr/Makefile 
b/drivers/staging/media/rtl2832u_sdr/Makefile
new file mode 100644
index 000..7e00a0d
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Makefile
@@ -0,0 +1,6 @@
+obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/tuners
+ccflags-y += -Idrivers/media/usb/dvb-usb-v2
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
new file mode 100644
index 000..dea7743
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -0,0 +1,1470 @@
+/*
+ * Realtek RTL2832U SDR driver
+ *
+ * Copyright (C) 2013 Antti Palosaari 
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License along
+ *with this program; if not, write to the Free Software Foundation, Inc.,
+ *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * GNU Radio plugin "gr-kernel" for device usage will be on:
+ * http://git.linuxtv.org/anttip/gr-kernel.git
+ *
+ */
+
+#include "dvb_frontend.h"
+#include "rtl2832_sdr.h"
+#include "dvb_usb.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define MAX_BULK_BUFS(10)
+#define BULK_BUFFER_SIZE (128 * 512)
+
+static const struct v4l2_frequency_band bands_adc[] = {
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  30,
+   .rangehigh  =  30,
+   },
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 1,
+ 

Re: [REVIEW PATCH 08/16] rtl2832_sdr: Realtek RTL2832 SDR driver module

2014-02-14 Thread Hans Verkuil
On 02/11/2014 03:04 AM, Antti Palosaari wrote:
> Implement SDR driver for Realtek RTL2832U chip as a DVB extension
> module. SDR module is attached by DVB USB RTL28XXU driver as a DVB
> SEC (satellite equipment controller) module. Abusing unused SEC here
> has no harm as that is DVB-T only frontend.
> 
> SDR functionality is provided by RTL2832 DVB-T demodulator. I suspect
> it is originally planned for DAB and FM, but it could be abused general
> SDR, due to modern silicon tuners that has wide frequency range and a
> lot of configurable parameters (filters, gains, ...).
> 
> http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/44461
> 
> Signed-off-by: Antti Palosaari 
> ---
>  drivers/staging/media/Kconfig|2 +
>  drivers/staging/media/Makefile   |2 +
>  drivers/staging/media/rtl2832u_sdr/Kconfig   |7 +
>  drivers/staging/media/rtl2832u_sdr/Makefile  |6 +
>  drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 1470 
> ++
>  drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h |   51 +
>  6 files changed, 1538 insertions(+)
>  create mode 100644 drivers/staging/media/rtl2832u_sdr/Kconfig
>  create mode 100644 drivers/staging/media/rtl2832u_sdr/Makefile
>  create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
>  create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h
> 
> diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
> index 22b0c9d..a9f2e63 100644
> --- a/drivers/staging/media/Kconfig
> +++ b/drivers/staging/media/Kconfig
> @@ -41,6 +41,8 @@ source "drivers/staging/media/solo6x10/Kconfig"
>  
>  source "drivers/staging/media/omap4iss/Kconfig"
>  
> +source "drivers/staging/media/rtl2832u_sdr/Kconfig"
> +
>  # Keep LIRC at the end, as it has sub-menus
>  source "drivers/staging/media/lirc/Kconfig"
>  
> diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
> index bedc62a..8e2c5d2 100644
> --- a/drivers/staging/media/Makefile
> +++ b/drivers/staging/media/Makefile
> @@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_OMAP4)   += omap4iss/
>  obj-$(CONFIG_USB_SN9C102)   += sn9c102/
>  obj-$(CONFIG_VIDEO_OMAP2)   += omap24xx/
>  obj-$(CONFIG_VIDEO_TCM825X) += omap24xx/
> +obj-$(CONFIG_DVB_RTL2832_SDR)+= rtl2832u_sdr/
> +
> diff --git a/drivers/staging/media/rtl2832u_sdr/Kconfig 
> b/drivers/staging/media/rtl2832u_sdr/Kconfig
> new file mode 100644
> index 000..3ede5fe
> --- /dev/null
> +++ b/drivers/staging/media/rtl2832u_sdr/Kconfig
> @@ -0,0 +1,7 @@
> +config DVB_RTL2832_SDR
> + tristate "Realtek RTL2832 SDR"
> + depends on USB && DVB_CORE && I2C && VIDEO_V4L2 && DVB_USB_RTL28XXU
> + select DVB_RTL2832
> + select VIDEOBUF2_VMALLOC
> + default m if !MEDIA_SUBDRV_AUTOSELECT
> +
> diff --git a/drivers/staging/media/rtl2832u_sdr/Makefile 
> b/drivers/staging/media/rtl2832u_sdr/Makefile
> new file mode 100644
> index 000..7e00a0d
> --- /dev/null
> +++ b/drivers/staging/media/rtl2832u_sdr/Makefile
> @@ -0,0 +1,6 @@
> +obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
> +
> +ccflags-y += -Idrivers/media/dvb-core
> +ccflags-y += -Idrivers/media/dvb-frontends
> +ccflags-y += -Idrivers/media/tuners
> +ccflags-y += -Idrivers/media/usb/dvb-usb-v2
> diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
> b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
> new file mode 100644
> index 000..9265424
> --- /dev/null
> +++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
> @@ -0,0 +1,1470 @@
> +/*
> + * Realtek RTL2832U SDR driver
> + *
> + * Copyright (C) 2013 Antti Palosaari 
> + *
> + *This program is free software; you can redistribute it and/or modify
> + *it under the terms of the GNU General Public License as published by
> + *the Free Software Foundation; either version 2 of the License, or
> + *(at your option) any later version.
> + *
> + *This program is distributed in the hope that it will be useful,
> + *but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *GNU General Public License for more details.
> + *
> + *You should have received a copy of the GNU General Public License along
> + *with this program; if not, write to the Free Software Foundation, Inc.,
> + *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + *
> + * GNU Radio plugin "gr-kernel" for device usage will be on:
> + * http://git.linuxtv.org/anttip/gr-kernel.git
> + *
> + */
> +
> +#include "dvb_frontend.h"
> +#include "rtl2832_sdr.h"
> +#include "dvb_usb.h"
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define MAX_BULK_BUFS(10)
> +#define BULK_BUFFER_SIZE (128 * 512)
> +
> +static const struct v4l2_frequency_band bands_adc[] = {
> + {
> + .tuner = 0,
> + .type = V4L2_TUNER_ADC,
> +

[REVIEW PATCH 08/16] rtl2832_sdr: Realtek RTL2832 SDR driver module

2014-02-10 Thread Antti Palosaari
Implement SDR driver for Realtek RTL2832U chip as a DVB extension
module. SDR module is attached by DVB USB RTL28XXU driver as a DVB
SEC (satellite equipment controller) module. Abusing unused SEC here
has no harm as that is DVB-T only frontend.

SDR functionality is provided by RTL2832 DVB-T demodulator. I suspect
it is originally planned for DAB and FM, but it could be abused general
SDR, due to modern silicon tuners that has wide frequency range and a
lot of configurable parameters (filters, gains, ...).

http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/44461

Signed-off-by: Antti Palosaari 
---
 drivers/staging/media/Kconfig|2 +
 drivers/staging/media/Makefile   |2 +
 drivers/staging/media/rtl2832u_sdr/Kconfig   |7 +
 drivers/staging/media/rtl2832u_sdr/Makefile  |6 +
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 1470 ++
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h |   51 +
 6 files changed, 1538 insertions(+)
 create mode 100644 drivers/staging/media/rtl2832u_sdr/Kconfig
 create mode 100644 drivers/staging/media/rtl2832u_sdr/Makefile
 create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
 create mode 100644 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h

diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 22b0c9d..a9f2e63 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -41,6 +41,8 @@ source "drivers/staging/media/solo6x10/Kconfig"
 
 source "drivers/staging/media/omap4iss/Kconfig"
 
+source "drivers/staging/media/rtl2832u_sdr/Kconfig"
+
 # Keep LIRC at the end, as it has sub-menus
 source "drivers/staging/media/lirc/Kconfig"
 
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index bedc62a..8e2c5d2 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
 obj-$(CONFIG_USB_SN9C102)   += sn9c102/
 obj-$(CONFIG_VIDEO_OMAP2)   += omap24xx/
 obj-$(CONFIG_VIDEO_TCM825X) += omap24xx/
+obj-$(CONFIG_DVB_RTL2832_SDR)  += rtl2832u_sdr/
+
diff --git a/drivers/staging/media/rtl2832u_sdr/Kconfig 
b/drivers/staging/media/rtl2832u_sdr/Kconfig
new file mode 100644
index 000..3ede5fe
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Kconfig
@@ -0,0 +1,7 @@
+config DVB_RTL2832_SDR
+   tristate "Realtek RTL2832 SDR"
+   depends on USB && DVB_CORE && I2C && VIDEO_V4L2 && DVB_USB_RTL28XXU
+   select DVB_RTL2832
+   select VIDEOBUF2_VMALLOC
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+
diff --git a/drivers/staging/media/rtl2832u_sdr/Makefile 
b/drivers/staging/media/rtl2832u_sdr/Makefile
new file mode 100644
index 000..7e00a0d
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Makefile
@@ -0,0 +1,6 @@
+obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/tuners
+ccflags-y += -Idrivers/media/usb/dvb-usb-v2
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
new file mode 100644
index 000..9265424
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -0,0 +1,1470 @@
+/*
+ * Realtek RTL2832U SDR driver
+ *
+ * Copyright (C) 2013 Antti Palosaari 
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License along
+ *with this program; if not, write to the Free Software Foundation, Inc.,
+ *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * GNU Radio plugin "gr-kernel" for device usage will be on:
+ * http://git.linuxtv.org/anttip/gr-kernel.git
+ *
+ */
+
+#include "dvb_frontend.h"
+#include "rtl2832_sdr.h"
+#include "dvb_usb.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define MAX_BULK_BUFS(10)
+#define BULK_BUFFER_SIZE (128 * 512)
+
+static const struct v4l2_frequency_band bands_adc[] = {
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 0,
+   .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  30,
+   .rangehigh  =  30,
+   },
+   {
+   .tuner = 0,
+   .type = V4L2_TUNER_ADC,
+   .index = 1,
+