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 cr...@iki.fi
---
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 cr...@iki.fi
+ *
+ *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 media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-event.h
+#include media/videobuf2-vmalloc.h
+
+#include linux/jiffies.h
+#include linux/math64.h
+
+#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,
+