Re: [PATCH] rtl2832.c: minor cleanup
On 15.07.2012 19:56, Hans-Frieder Vogt wrote: The current formulation of the bw_params loop uses the counter j as an index for the first dimension of the bw_params array which is later incremented by the variable i. It is evaluated correctly only, because j is initialized to 0 at the beginning of the loop. I think that explicitly using the index 0 better reflects the intent of the expression. You are right. It makes the code more readeable. Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net rtl2832.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/dvb/frontends/rtl2832.c 2012-07-06 05:45:16.0 +0200 +++ b/drivers/media/dvb/frontends/rtl2832.c 2012-07-15 19:05:28.428017449 +0200 @@ -589,7 +589,7 @@ static int rtl2832_set_frontend(struct d return -EINVAL; } - for (j = 0; j sizeof(bw_params[j]); j++) { + for (j = 0; j sizeof(bw_params[0]); j++) { ret = rtl2832_wr_regs(priv, 0x1c+j, 1, bw_params[i][j], 1); if (ret) goto err; Hans-Frieder Vogt e-mail: hfvogt at gmx .dot. net -- 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: rtl28xxu - rtl2832 frontend attach
On 26.06.2012 19:17, poma wrote: On 05/28/2012 04:48 PM, Thomas Mair wrote: On 28.05.2012 08:58, Thomas Mair wrote: On 26.05.2012 04:47, poma wrote: On 05/20/2012 11:12 PM, Thomas Mair wrote: On 20.05.2012 22:08, Antti Palosaari wrote: On 20.05.2012 20:04, poma wrote: After hard/cold boot: DVB: register adapter0/net0 @ minor: 2 (0x02) rtl2832u_frontend_attach: rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 No compatible tuner found These errors are coming from tuner probe. As it still goes to probing and did not jump out earlier when gate is opened it means that demod is answering commands but tuner are not. My guess is that tuner is still on the reset or not powered at all. It is almost 100% sure error is wrong tuner GPIO. There is an issue with GPIO, as FC0012 tuner callback will set the value of one of the GPIO outputs. However fixing that, will not resolve the issue. So I need to debug the problem further. True. Whatever a value is changed - 'rtl2832u_power_ctrl', it brakes even more. Precisely, what breaks a tuner on next soft [re]boot are apps/utils which engage tzap/scan[dvb]. To reproduce the bug it is not necessary to reboot the machine. Simply unload and load of the dvb_usb_rtl28xxu module will lead to the same situation. I suspect, that when power is turned off, the tuner power is not switched on correctly. The mistake is not related to the OUTPUT_VAL registers but probably to the OUTPUT_DIR or OUTPUT_EN registers. What makes me wonder is if no tuning operation is performed before reboot, the driver does work correctly after that, as poma already noticed. I have some spare time today and will investigate the problem further. I tried a few things regarding the problem today and could find out a few more details, but could not resolve the issue. The GPIO pin configuration for the devices with the fc0012 (and probably also with the fc0013) tuner is the following: GPIO0: demod power GPIO3: tuner power? (the realtek driver puts this to 1 and never touches it again) GPIO4: tuner power? (maybe antenna power?) GPIO5: tuner reset GPIO6: UHF/VHF band selection All of these GPIOs are configured as output. When the device is plugged in the tuner is powered up correctly, but I am not able to power it up when a reboot is performed. What I tried was the following: - on rtl28xxu_power_ctrl off: - GPIO4 = 1 (off) - GPIO5 = 0 - GPIO6 = 0 (default state) - on rtl28xxu_power_ctrl on: - GPIO3 = 1 - GPIO4 = 0 (on) - GPIO5 = 0 - GPIO6 = 0 (default state) - on rtl2832_frontend_attach: - GPIO5 = 1 - GPIO5 = 0 This sequence should ensure that the tuner is powered on when the frontend is attached, and a tuner reset is being performed before the tuner is probed. However this sequence fails the same way as it did before. I tried to add timeouts to be sure that the tuner is not probed while it is reset but that did not help either. Right now I really don't know where I should look for the solution of the problem. It seems that the tuner reset does not have any effect on the tuner whatsoever. Is there anybody who could look at the code, or maybe knows what could be the cause of the problem? I suspect I am just too blind to see my own mistakes. Regards Thomas Cheers Thomas, Hans-Frieder, Antti, Mauro! Hans-Frieder, are you having the same issue with fc0011af9035? Antti, no tricks up your sleeve? Senhor Mauro, is rtl2832 demod going to be merged? regards, poma Hi all, I will try to solve the issue as soon as I have some spare time. In the meantime I asked Realtek if they knew of any problems with the hardware, and I got a GPIO list which might help me to solve the problem. Regrads Thomas -- 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: rtl28xxu - rtl2832 frontend attach
On 26.05.2012 04:47, poma wrote: On 05/20/2012 11:12 PM, Thomas Mair wrote: On 20.05.2012 22:08, Antti Palosaari wrote: On 20.05.2012 20:04, poma wrote: After hard/cold boot: DVB: register adapter0/net0 @ minor: 2 (0x02) rtl2832u_frontend_attach: rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 No compatible tuner found These errors are coming from tuner probe. As it still goes to probing and did not jump out earlier when gate is opened it means that demod is answering commands but tuner are not. My guess is that tuner is still on the reset or not powered at all. It is almost 100% sure error is wrong tuner GPIO. There is an issue with GPIO, as FC0012 tuner callback will set the value of one of the GPIO outputs. However fixing that, will not resolve the issue. So I need to debug the problem further. True. Whatever a value is changed - 'rtl2832u_power_ctrl', it brakes even more. Precisely, what breaks a tuner on next soft [re]boot are apps/utils which engage tzap/scan[dvb]. To reproduce the bug it is not necessary to reboot the machine. Simply unload and load of the dvb_usb_rtl28xxu module will lead to the same situation. I suspect, that when power is turned off, the tuner power is not switched on correctly. The mistake is not related to the OUTPUT_VAL registers but probably to the OUTPUT_DIR or OUTPUT_EN registers. What makes me wonder is if no tuning operation is performed before reboot, the driver does work correctly after that, as poma already noticed. I have some spare time today and will investigate the problem further. Regards Thomas -- 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: rtl28xxu - rtl2832 frontend attach
On 28.05.2012 08:58, Thomas Mair wrote: On 26.05.2012 04:47, poma wrote: On 05/20/2012 11:12 PM, Thomas Mair wrote: On 20.05.2012 22:08, Antti Palosaari wrote: On 20.05.2012 20:04, poma wrote: After hard/cold boot: DVB: register adapter0/net0 @ minor: 2 (0x02) rtl2832u_frontend_attach: rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 No compatible tuner found These errors are coming from tuner probe. As it still goes to probing and did not jump out earlier when gate is opened it means that demod is answering commands but tuner are not. My guess is that tuner is still on the reset or not powered at all. It is almost 100% sure error is wrong tuner GPIO. There is an issue with GPIO, as FC0012 tuner callback will set the value of one of the GPIO outputs. However fixing that, will not resolve the issue. So I need to debug the problem further. True. Whatever a value is changed - 'rtl2832u_power_ctrl', it brakes even more. Precisely, what breaks a tuner on next soft [re]boot are apps/utils which engage tzap/scan[dvb]. To reproduce the bug it is not necessary to reboot the machine. Simply unload and load of the dvb_usb_rtl28xxu module will lead to the same situation. I suspect, that when power is turned off, the tuner power is not switched on correctly. The mistake is not related to the OUTPUT_VAL registers but probably to the OUTPUT_DIR or OUTPUT_EN registers. What makes me wonder is if no tuning operation is performed before reboot, the driver does work correctly after that, as poma already noticed. I have some spare time today and will investigate the problem further. I tried a few things regarding the problem today and could find out a few more details, but could not resolve the issue. The GPIO pin configuration for the devices with the fc0012 (and probably also with the fc0013) tuner is the following: GPIO0: demod power GPIO3: tuner power? (the realtek driver puts this to 1 and never touches it again) GPIO4: tuner power? (maybe antenna power?) GPIO5: tuner reset GPIO6: UHF/VHF band selection All of these GPIOs are configured as output. When the device is plugged in the tuner is powered up correctly, but I am not able to power it up when a reboot is performed. What I tried was the following: - on rtl28xxu_power_ctrl off: - GPIO4 = 1 (off) - GPIO5 = 0 - GPIO6 = 0 (default state) - on rtl28xxu_power_ctrl on: - GPIO3 = 1 - GPIO4 = 0 (on) - GPIO5 = 0 - GPIO6 = 0 (default state) - on rtl2832_frontend_attach: - GPIO5 = 1 - GPIO5 = 0 This sequence should ensure that the tuner is powered on when the frontend is attached, and a tuner reset is being performed before the tuner is probed. However this sequence fails the same way as it did before. I tried to add timeouts to be sure that the tuner is not probed while it is reset but that did not help either. Right now I really don't know where I should look for the solution of the problem. It seems that the tuner reset does not have any effect on the tuner whatsoever. Is there anybody who could look at the code, or maybe knows what could be the cause of the problem? I suspect I am just too blind to see my own mistakes. Regards Thomas -- 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 v5 0/5] support for rtl2832
On 18.05.2012 22:47, Antti Palosaari wrote: Good evening! On 18.05.2012 21:47, Thomas Mair wrote: Good Evening! This is the corrected version of the patch series to support the RTL2832 demodulator. There where no major changes. The majority of the changes consist in fixing style issues and adhering to proper naming conventions. Review done and seems to be OK for my eyes. Thanks Antti! You have been a big help for developing the driver. What are the next steps? I think the fc0012 and fc0013 driver need to be reviewed before the patch may be included in staging. Is that the way it works? The next question for me is how to proceed when including new devices. Poma already sent an extensive list a little while ago (http://patchwork.linuxtv.org/patch/10982/). Should they all be included at once, or should I wait until somone confirms they are working correctly and include them one by one? It has been rule that device is added after known to work. That sounds good to me. In the meantime I will try to set up a page for the driver on the linuxtv.org wiki to keep information about the driver and the devices in one place. Unfortunately DVB USB do not support dynamic USB ID. In order to workaround that I have done some small hackish solution for the dvb_usb_rtl28xxu driver. Currently it works for RTL2831U based devices, but I see it could be easily extended for RTL2832U too by adding module parameter. If I understand it right, the problem is that the tuner/demod combination is also hard coded in the dvb_usb_rtl28xxu driver? regards Antti Regards Thomas -- 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: rtl28xxu - rtl2832 frontend attach
On 20.05.2012 22:08, Antti Palosaari wrote: On 20.05.2012 20:04, poma wrote: After hard/cold boot: DVB: register adapter0/net0 @ minor: 2 (0x02) rtl2832u_frontend_attach: rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 No compatible tuner found These errors are coming from tuner probe. As it still goes to probing and did not jump out earlier when gate is opened it means that demod is answering commands but tuner are not. My guess is that tuner is still on the reset or not powered at all. It is almost 100% sure error is wrong tuner GPIO. There is an issue with GPIO, as FC0012 tuner callback will set the value of one of the GPIO outputs. However fixing that, will not resolve the issue. So I need to debug the problem further. Thanks for the bug report. Regards Thomas -- 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 v5 0/5] support for rtl2832
Good Evening! This is the corrected version of the patch series to support the RTL2832 demodulator. There where no major changes. The majority of the changes consist in fixing style issues and adhering to proper naming conventions. The next question for me is how to proceed when including new devices. Poma already sent an extensive list a little while ago (http://patchwork.linuxtv.org/patch/10982/). Should they all be included at once, or should I wait until somone confirms they are working correctly and include them one by one? Regards Thomas Thomas Mair (5): rtl2832 ver. 0.5: support for RTL2832 demod rtl28xxu: support for the rtl2832 demod driver rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr rtl28xxu: support Delock USB 2.0 DVB-T rtl28xxu: support Terratec Noxon DAB/DAB+ stick drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h|3 + drivers/media/dvb/dvb-usb/rtl28xxu.c | 516 -- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 823 drivers/media/dvb/frontends/rtl2832.h | 74 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 260 + 8 files changed, 1638 insertions(+), 49 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h -- 1.7.7.6 -- 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 v5 1/5] rtl2832 ver. 0.5: support for RTL2832 demod
Changelog for ver. 0.5: - fixed code style and naming errors Changelog for ver. 0.4: - removed statistics as their calculation was wrong - fixed bug in Makefile - indentation and code style improvements Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 823 drivers/media/dvb/frontends/rtl2832.h | 74 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 260 + 5 files changed, 1165 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index f479834..f7d67d7 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -432,6 +432,13 @@ config DVB_RTL2830 help Say Y when you want to support this frontend. +config DVB_RTL2832 + tristate Realtek RTL2832 DVB-T + depends on DVB_CORE I2C + default m if DVB_FE_CUSTOMISE + help + Say Y when you want to support this frontend. + comment DVB-C (cable) frontends depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index b0381dc..2279c5d 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o obj-$(CONFIG_DVB_A8293) += a8293.o obj-$(CONFIG_DVB_TDA10071) += tda10071.o obj-$(CONFIG_DVB_RTL2830) += rtl2830.o +obj-$(CONFIG_DVB_RTL2832) += rtl2832.o obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o obj-$(CONFIG_DVB_AF9033) += af9033.o diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..d0cbe27 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,823 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static const int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +static const struct rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN] = {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4}, + [DVBT_AD_AV_REF]= {0x0, 0x9, 6, 0}, + [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, + [DVBT_PIP_ON] = {0x0, 0x21, 3, 3
[PATCH v5 2/5] rtl28xxu: support for the rtl2832 demod driver
This only adds support for the Terratec Cinergy T Stick Black device. Changes from previous patches: - fixed compiler warnings - added fc0013 tuner handling to this patch Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 450 +-- 3 files changed, 429 insertions(+), 25 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index be1db75..98dd0d8 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -417,9 +417,12 @@ config DVB_USB_RTL28XXU tristate Realtek RTL28xxU DVB USB support depends on DVB_USB EXPERIMENTAL select DVB_RTL2830 + select DVB_RTL2832 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE help Say Y here to support the Realtek RTL28xxU DVB USB receiver. diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 7a6160b..cd9254c 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -160,6 +160,7 @@ #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 #define USB_PID_TERRATEC_CINERGY_T_STICK_RC0x0097 #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 +#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV10x00a9 #define USB_PID_TWINHAN_VP7041_COLD0x3201 #define USB_PID_TWINHAN_VP7041_WARM0x3202 #define USB_PID_TWINHAN_VP7020_COLD0x3203 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 4e69e9d..5285f3d 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -22,10 +23,13 @@ #include rtl28xxu.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h +#include fc0013.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -378,34 +382,159 @@ err: return ret; } +static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0012 +}; + +static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0013 +}; + +static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + int ret; + u8 val; + + deb_info(%s cmd=%d arg=%d\n, __func__, cmd, arg); + switch (cmd) { + case FC_FE_CALLBACK_VHF_ENABLE: + /* set output values */ + ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + + if (arg) + val = 0xbf; /* set GPIO6 low */ + else + val |= 0x40; /* set GPIO6 high */ + + + ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + break; + default: + ret = -EINVAL; + goto err; + } + return 0; + +err: + err(%s: failed=%d\n, __func__, ret); + + return ret; +} + + +static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + /* TODO implement*/ + return 0; +} + +static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) +{ + struct rtl28xxu_priv *priv = d-priv; + + switch (priv-tuner) { + case TUNER_RTL2832_FC0012: + return rtl2832u_fc0012_tuner_callback(d, cmd, arg); + + case TUNER_RTL2832_FC0013: + return rtl2832u_fc0013_tuner_callback(d, cmd, arg); + default: + break; + } + + return -ENODEV; +} + +static int rtl2832u_frontend_callback(void *adapter_priv, int component, + int cmd, int arg) +{ + struct i2c_adapter *adap = adapter_priv; + struct dvb_usb_device *d = i2c_get_adapdata(adap); + + switch (component) { + case DVB_FRONTEND_COMPONENT_TUNER
[PATCH v5 3/5] rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c | 102 +- 1 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 5285f3d..5586715 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -84,7 +84,7 @@ err: return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -120,12 +120,12 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { return rtl2831_rd_regs(d, reg, val, 1); } @@ -312,12 +312,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; /* enable as output GPIO0, GPIO2, GPIO4 */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -406,7 +406,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, switch (cmd) { case FC_FE_CALLBACK_VHF_ENABLE: /* set output values */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; @@ -416,7 +416,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, val |= 0x40; /* set GPIO6 high */ - ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; break; @@ -511,25 +511,25 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) deb_info(%s:\n, __func__); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; val = 0xbf; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; /* enable as output GPIO3 and GPIO6*/ - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; val |= 0x48; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; @@ -790,7 +790,7 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; @@ -804,11 +804,11 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) gpio = (~0x04); /* LED off */ } - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -834,7 +834,7 @@ static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) buf[1] = 0x02; /* reset EPA */ } - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -852,12 +852,12 @@ static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); /* demod adc */ - ret = rtl2831_rd_reg(d, SYS_SYS0, sys0); + ret = rtl28xx_rd_reg(d, SYS_SYS0, sys0); if (ret) goto err; /* tuner power, read GPIOs */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, gpio
[PATCH v5 4/5] rtl28xxu: support Delock USB 2.0 DVB-T
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index cd9254c..360f6b7 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -100,6 +100,7 @@ #define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 #define USB_PID_CONEXANT_D680_DMB 0x86d6 #define USB_PID_CREATIX_CTX19210x1921 +#define USB_PID_DELOCK_USB2_DVBT 0xb803 #define USB_PID_DIBCOM_HOOK_DEFAULT0x0064 #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 #define USB_PID_DIBCOM_MOD3000_COLD0x0bb8 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 5586715..b2c8f67 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -1152,6 +1152,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0160, RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, + RTL2832U_1F4D_B803, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1166,6 +1167,8 @@ static struct usb_device_id rtl28xxu_table[] = { /* RTL2832U */ [RTL2832U_0CCD_00A9] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, + [RTL2832U_1F4D_B803] = { + USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT)}, {} /* terminating entry */ }; @@ -1279,7 +1282,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1287,6 +1290,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_0CCD_00A9], }, }, + { + .name = G-Tek Electronics Group Lifeview LV5TDLX DVB-T, + .warm_ids = { + rtl28xxu_table[RTL2832U_1F4D_B803], + }, + }, } }, -- 1.7.7.6 -- 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 v5 5/5] rtl28xxu: support Terratec Noxon DAB/DAB+ stick
Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 360f6b7..26c4481 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -247,6 +247,7 @@ #define USB_PID_TERRATEC_H7_2 0x10a3 #define USB_PID_TERRATEC_T30x10a0 #define USB_PID_TERRATEC_T50x10a1 +#define USB_PID_NOXON_DAB_STICK0x00b3 #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e #define USB_PID_PINNACLE_PCTV2000E 0x022c #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index b2c8f67..0cac6fb 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -1153,6 +1153,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, RTL2832U_1F4D_B803, + RTL2832U_0CCD_00B3, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1169,6 +1170,8 @@ static struct usb_device_id rtl28xxu_table[] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, [RTL2832U_1F4D_B803] = { USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT)}, + [RTL2832U_0CCD_00B3] = { + USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, {} /* terminating entry */ }; @@ -1282,7 +1285,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 2, + .num_device_descs = 3, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1296,6 +1299,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_1F4D_B803], }, }, + { + .name = NOXON DAB/DAB+ USB dongle, + .warm_ids = { + rtl28xxu_table[RTL2832U_0CCD_00B3], + }, + }, } }, -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] rtl2832 ver. 0.4: removed signal statistics
On 17.05.2012 05:40, poma wrote: […] v4-1-5-rtl2832-ver.-0.4-v2.diff Oh thanks. That Makefile is haunting me badly ;) -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] rtl2832 ver. 0.4: removed signal statistics
On 17.05.2012 22:41, Antti Palosaari wrote: On 17.05.2012 23:27, poma wrote: On 05/17/2012 04:19 PM, Antti Palosaari wrote: Moikka Thomas, Here is the review. See comments below. And conclusion is that it is ready for the Kernel merge. I did not see any big functiuonality problems - only some small issues that are likely considered as a coding style etc. Feel free to fix those and sent new patc serie or just new patch top of that. Reviewed-by: Antti Palosaaricr...@iki.fi [...] rtl2832.c.diff: - static int - static const - struct - static const struct - newline between function call and error check - […] - 5 indications apropos 'spaces' regarding 'CodingStyle'- line 206 (/usr/share/doc/kernel-doc-3.3.5/Documentation/CodingStyle) […] Use one space around (on each side of) most binary and ternary operators, such as any of these: = + - * / % | ^== == != ? : […] grep '\|' v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig +len = (msb 3) + 1; +reading_tmp |= reading[i] ((len-1-i)*8); +*val = (reading_tmp lsb) mask; +len = (msb 3) + 1; +reading_tmp |= reading[i] ((len-1-i)*8); +writing_tmp = reading_tmp ~(mask lsb); +writing_tmp |= ((val mask) lsb); +writing[i] = (writing_tmp ((len-1-i)*8)) 0xff; +num = bw_mode 20; Bitshift operators seems to be OK. Something else? (len-1-i)*8 I almost have a new corrected version of the patch series ready, fixing this issues and the other ones you mentioned. - 1 indication apropos 'media/dvb/frontends/rtl2832_priv.h:30' Compared to 'rtl2830_priv.h' seems to be OK. ./checkpatch.pl --no-tree v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig ERROR: Missing Signed-off-by: line(s) total: 1 errors, 0 warnings, 1177 lines checked v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. How do you produce this error: ERROR: Macros with complex values should be enclosed in parenthesis…? Just running checkpatch.pl --file foo For me checkpath.pl also does not report the error you reported. It does seem strange to me, as the makros are the same as in rtl2830_priv.h Regards Thomas -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] rtl2832 ver. 0.4: removed signal statistics
On 17.05.2012 23:08, poma wrote: On 05/17/2012 10:45 PM, Thomas Mair wrote: On 17.05.2012 22:41, Antti Palosaari wrote: On 17.05.2012 23:27, poma wrote: On 05/17/2012 04:19 PM, Antti Palosaari wrote: Moikka Thomas, Here is the review. See comments below. And conclusion is that it is ready for the Kernel merge. I did not see any big functiuonality problems - only some small issues that are likely considered as a coding style etc. Feel free to fix those and sent new patc serie or just new patch top of that. Reviewed-by: Antti Palosaaricr...@iki.fi [...] rtl2832.c.diff: - static int - static const - struct - static const struct - newline between function call and error check - […] - 5 indications apropos 'spaces' regarding 'CodingStyle'- line 206 (/usr/share/doc/kernel-doc-3.3.5/Documentation/CodingStyle) […] Use one space around (on each side of) most binary and ternary operators, such as any of these: = + - * / % | ^== == != ? : […] grep '\|' v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig +len = (msb 3) + 1; +reading_tmp |= reading[i] ((len-1-i)*8); +*val = (reading_tmp lsb) mask; +len = (msb 3) + 1; +reading_tmp |= reading[i] ((len-1-i)*8); +writing_tmp = reading_tmp ~(mask lsb); +writing_tmp |= ((val mask) lsb); +writing[i] = (writing_tmp ((len-1-i)*8)) 0xff; +num = bw_mode 20; Bitshift operators seems to be OK. Something else? (len-1-i)*8 I almost have a new corrected version of the patch series ready, fixing this issues and the other ones you mentioned. - 1 indication apropos 'media/dvb/frontends/rtl2832_priv.h:30' Compared to 'rtl2830_priv.h' seems to be OK. ./checkpatch.pl --no-tree v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig ERROR: Missing Signed-off-by: line(s) total: 1 errors, 0 warnings, 1177 lines checked v4-1-5-rtl2832-ver.-0.4-removed-signal-statistics.patch.orig has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. How do you produce this error: ERROR: Macros with complex values should be enclosed in parenthesis…? Just running checkpatch.pl --file foo For me checkpath.pl also does not report the error you reported. It does seem strange to me, as the makros are the same as in rtl2830_priv.h Regards Thomas Yeah, 'rtl2830_priv.h' is the same. Fu… me, now I don't know too! :) cheers, poma Ok. I will then check the patches with the new checkpatch version tomorrow as I need some rest now ;) It should not be too difficult to remove the errors. Regards Thomas -- 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 v4 0/5] support for rtl2832
This is the new version of the patch series to add support for the rtl2832 demodulator driver. Before applying the patches you need to add the fc0012/fc0013 driver from Hans-Frider Vogt. The changes from the privious version of the patches are manly in the rtl2832 demod driver to fix code style issues, a nasty bug in the frontends Makefile and the removal of the signal statistics functionality which was badly broken in version 0.3 of the driver. The one thing that I am not really confident with is the Kconfig file for the dvb frontend driver. Are the changes I made right? And if not what kind of changes need to be made? Thanks Antti and poma for your comments! Regards Thomas Thomas Mair (5): rtl2832 ver. 0.4: removed signal statistics rtl28xxu: support for the rtl2832 demod driver rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr rtl28xxu: support G-Tek Electronics Group Lifeview LV5TDLX DVB-T rtl28xxu: support Terratec Noxon DAB/DAB+ stick drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h|3 + drivers/media/dvb/dvb-usb/rtl28xxu.c | 513 -- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 825 drivers/media/dvb/frontends/rtl2832.h | 74 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 258 + 8 files changed, 1636 insertions(+), 48 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h -- 1.7.7.6 -- 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 v4 1/5] rtl2832 ver. 0.4: removed signal statistics
Changelog for ver. 0.3: - removed statistics as their calculation was wrong - fixed bug in Makefile - indentation and code style improvements Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 825 drivers/media/dvb/frontends/rtl2832.h | 74 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 258 + 5 files changed, 1165 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index f479834..f7d67d7 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -432,6 +432,13 @@ config DVB_RTL2830 help Say Y when you want to support this frontend. +config DVB_RTL2832 + tristate Realtek RTL2832 DVB-T + depends on DVB_CORE I2C + default m if DVB_FE_CUSTOMISE + help + Say Y when you want to support this frontend. + comment DVB-C (cable) frontends depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index b0381dc..bbf2955 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o obj-$(CONFIG_DVB_A8293) += a8293.o obj-$(CONFIG_DVB_TDA10071) += tda10071.o obj-$(CONFIG_DVB_RTL2830) += rtl2830.o +obj-$(CONFIG_DVB_RTL2830) += rtl2832.o obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o obj-$(CONFIG_DVB_AF9033) += af9033.o diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..51c7927 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,825 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +struct rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN] = {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4}, + [DVBT_AD_AV_REF]= {0x0, 0x9, 6, 0}, + [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, + [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, + [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, + [DVBT_SCALE1_B93
[PATCH v4 2/5] rtl28xxu: support for the rtl2832 demod driver
This only adds support for the Terratec Cinergy T Stick Black device. Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 431 +-- 3 files changed, 411 insertions(+), 24 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index be1db75..98dd0d8 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -417,9 +417,12 @@ config DVB_USB_RTL28XXU tristate Realtek RTL28xxU DVB USB support depends on DVB_USB EXPERIMENTAL select DVB_RTL2830 + select DVB_RTL2832 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE help Say Y here to support the Realtek RTL28xxU DVB USB receiver. diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 2418e41..fd37be0 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -157,6 +157,7 @@ #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 #define USB_PID_TERRATEC_CINERGY_T_STICK_RC0x0097 #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 +#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV10x00a9 #define USB_PID_TWINHAN_VP7041_COLD0x3201 #define USB_PID_TWINHAN_VP7041_WARM0x3202 #define USB_PID_TWINHAN_VP7020_COLD0x3203 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..bb66771 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -22,10 +23,12 @@ #include rtl28xxu.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -378,34 +381,153 @@ err: return ret; } +static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0012 +}; + + +static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + int ret; + u8 val; + + deb_info(%s cmd=%d arg=%d\n, __func__, cmd, arg); + switch (cmd) { + case FC_FE_CALLBACK_VHF_ENABLE: + /* set output values */ + ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + + if (arg) + val = 0xbf; /* set GPIO6 low */ + else + val |= 0x40; /* set GPIO6 high */ + + + ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + break; + default: + ret = -EINVAL; + goto err; + } + return 0; + +err: + err(%s: failed=%d\n, __func__, ret); + + return ret; +} + + +static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + /* TODO implement*/ + return 0; +} + +static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) +{ + struct rtl28xxu_priv *priv = d-priv; + + switch (priv-tuner) { + case TUNER_RTL2832_FC0012: + return rtl2832u_fc0012_tuner_callback(d, cmd, arg); + + case TUNER_RTL2832_FC0013: + return rtl2832u_fc0013_tuner_callback(d, cmd, arg); + default: + break; + } + + return -ENODEV; +} + +static int rtl2832u_frontend_callback(void *adapter_priv, int component, + int cmd, int arg) +{ + struct i2c_adapter *adap = adapter_priv; + struct dvb_usb_device *d = i2c_get_adapdata(adap); + + switch (component) { + case DVB_FRONTEND_COMPONENT_TUNER: + return rtl2832u_tuner_callback(d, cmd, arg); + default: + break; + } + + return -EINVAL; +} + + + + static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) { int ret; struct rtl28xxu_priv *priv = adap-dev-priv; - u8 buf[1]; + struct
[PATCH v4 3/5] rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c | 102 +- 1 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index bb66771..6817ef7 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -83,7 +83,7 @@ err: return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -119,12 +119,12 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { return rtl2831_rd_regs(d, reg, val, 1); } @@ -311,12 +311,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; /* enable as output GPIO0, GPIO2, GPIO4 */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -399,7 +399,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, switch (cmd) { case FC_FE_CALLBACK_VHF_ENABLE: /* set output values */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; @@ -409,7 +409,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, val |= 0x40; /* set GPIO6 high */ - ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; break; @@ -504,25 +504,25 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) deb_info(%s:\n, __func__); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; val = 0xbf; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; /* enable as output GPIO3 and GPIO6*/ - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; val |= 0x48; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; @@ -773,7 +773,7 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; @@ -787,11 +787,11 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) gpio = (~0x04); /* LED off */ } - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -817,7 +817,7 @@ static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) buf[1] = 0x02; /* reset EPA */ } - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -835,12 +835,12 @@ static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); /* demod adc */ - ret = rtl2831_rd_reg(d, SYS_SYS0, sys0); + ret = rtl28xx_rd_reg(d, SYS_SYS0, sys0); if (ret) goto err; /* tuner power, read GPIOs */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, gpio
[PATCH v4 4/5] rtl28xxu: support G-Tek Electronics Group Lifeview LV5TDLX DVB-T
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index fd37be0..b0a86e9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -135,6 +135,7 @@ #define USB_PID_GENIUS_TVGO_DVB_T030x4012 #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 +#define USB_PID_GTEK 0xb803 #define USB_PID_INTEL_CE9500 0x9500 #define USB_PID_ITETECH_IT9135 0x9135 #define USB_PID_ITETECH_IT9135_90050x9005 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 6817ef7..9056d28 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -1135,6 +1135,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0160, RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, + RTL2832U_1F4D_B803, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1149,6 +1150,8 @@ static struct usb_device_id rtl28xxu_table[] = { /* RTL2832U */ [RTL2832U_0CCD_00A9] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, + [RTL2832U_1F4D_B803] = { + USB_DEVICE(USB_VID_GTEK, USB_PID_GTEK)}, {} /* terminating entry */ }; @@ -1262,7 +1265,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1270,6 +1273,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_0CCD_00A9], }, }, + { + .name = G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U], + .warm_ids = { + rtl28xxu_table[RTL2832U_1F4D_B803], + }, + }, } }, -- 1.7.7.6 -- 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 v4 5/5] rtl28xxu: support Terratec Noxon DAB/DAB+ stick
Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 27 ++- 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index b0a86e9..95c9c14 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -244,6 +244,7 @@ #define USB_PID_TERRATEC_H7_2 0x10a3 #define USB_PID_TERRATEC_T30x10a0 #define USB_PID_TERRATEC_T50x10a1 +#define USB_PID_NOXON_DAB_STICK0x00b3 #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e #define USB_PID_PINNACLE_PCTV2000E 0x022c #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 9056d28..f10cac2 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -29,6 +29,7 @@ #include mt2060.h #include mxl5005s.h #include fc0012.h +#include fc0013.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -388,6 +389,12 @@ static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { .tuner = TUNER_RTL2832_FC0012 }; +static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0013 +}; static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) @@ -553,6 +560,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) ret = rtl28xxu_ctrl_msg(adap-dev, req_fc0013); if (ret == 0 buf[0] == 0xa3) { priv-tuner = TUNER_RTL2832_FC0013; + rtl2832_config = rtl28xxu_rtl2832_fc0013_config; info(%s: FC0013 tuner found, __func__); goto found; } @@ -750,6 +758,14 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) fe-ops.tuner_ops.get_rf_strength; return 0; break; + case TUNER_RTL2832_FC0013: + fe = dvb_attach(fc0013_attach, adap-fe_adap[0].fe, + adap-dev-i2c_adap, 0xc61, 0, FC_XTAL_28_8_MHZ); + + /* fc0013 also supports signal strength reading */ + adap-fe_adap[0].fe-ops.read_signal_strength = adap-fe_adap[0] + .fe-ops.tuner_ops.get_rf_strength; + return 0; default: fe = NULL; err(unknown tuner=%d, priv-tuner); @@ -1136,6 +1152,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, RTL2832U_1F4D_B803, + RTL2832U_0CCD_00B3, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1152,6 +1169,8 @@ static struct usb_device_id rtl28xxu_table[] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, [RTL2832U_1F4D_B803] = { USB_DEVICE(USB_VID_GTEK, USB_PID_GTEK)}, + [RTL2832U_0CCD_00B3] = { + USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, {} /* terminating entry */ }; @@ -1265,7 +1284,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 2, + .num_device_descs = 3, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1279,6 +1298,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_1F4D_B803], }, }, + { + .name = NOXON DAB/DAB+ USB dongle, + .warm_ids = { + rtl28xxu_table[RTL2832U_0CCD_00B3], + }, + }, } }, -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] rtl2832 ver 0.3: suport for RTL2832 demodulator revised version
On 13.05.2012 20:53, Antti Palosaari wrote: On 12.05.2012 21:08, Thomas Mair wrote: Changes compared to version 0.2: - removed reading of signal strength for tuners FC0012,FC0013 (is now supported by fc0012,fc0013 driver) - moved definition of register names to rtl2832_priv.h - cleaned up demod private structure - replaced rtl2832_log2 function with intlog2 from dvb_math Signed-off-by: Thomas Mairthomas.mai...@googlemail.com Testing shows UCB counter is totally broken. It does that all the time, 64 = some number = 64 status SCVYL | signal 2b2b | snr b08c | ber 0024 | unc 0064 | FE_HAS_LOCK status SCVYL | signal 2b2b | snr a7b8 | ber 007d | unc 005e | FE_HAS_LOCK status SCVYL | signal 2b2b | snr b08c | ber 002c | unc 0064 | FE_HAS_LOCK Ok. I will have a look into that. When I test it the count is always 64. status SCVYL | signal 4545 | snr | ber | unc 0064 | FE_HAS_LOCK status SCVYL | signal 4545 | snr | ber | unc 0064 | FE_HAS_LOCK status SCVYL | signal 4545 | snr | ber | unc 0064 | FE_HAS_LOCK Also other small issue. You have added new line to the log writings provided by DVB USB. DVB USB log writing has already new line! That is 2nd time I point out line errors. Did you use some special set-up during the development ? May 13 21:33:06 localhost kernel: [204738.354039] rtl28xxu: rtl2832u_frontend_attach: FC0012 tuner found May 13 21:33:06 localhost kernel: [204738.354040] May 13 21:33:06 localhost kernel: [204738.361304] DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))... I missed that one. I really tried to get rid of all of them. I'll fix that soon. I quickly looked patches through and those looked very good. I will try to review those tonight. And here is whole set (tuner+rtl2832u) if someone else would like to test: http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/rtl2832u regards Antti Regrads Thomas -- 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] rtl28xxu: removed newlines from info strings
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c | 20 ++-- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index ef02f0f..f10cac2 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -552,7 +552,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0xa1) { priv-tuner = TUNER_RTL2832_FC0012; rtl2832_config = rtl28xxu_rtl2832_fc0012_config; - info(%s: FC0012 tuner found\n, __func__); + info(%s: FC0012 tuner found, __func__); goto found; } @@ -561,7 +561,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0xa3) { priv-tuner = TUNER_RTL2832_FC0013; rtl2832_config = rtl28xxu_rtl2832_fc0013_config; - info(%s: FC0013 tuner found\n, __func__); + info(%s: FC0013 tuner found, __func__); goto found; } @@ -570,7 +570,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x85) { priv-tuner = TUNER_RTL2832_MT2266; /* TODO implement tuner */ - info(%s: MT2266 tuner found\n, __func__); + info(%s: MT2266 tuner found, __func__); goto found; } @@ -579,7 +579,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x56) { priv-tuner = TUNER_RTL2832_FC2580; /* TODO implement tuner */ - info(%s: FC2580 tuner found\n, __func__); + info(%s: FC2580 tuner found, __func__); goto found; } @@ -588,7 +588,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 (buf[0] == 0x9e || buf[0] == 0x9c)) { priv-tuner = TUNER_RTL2832_MT2063; /* TODO implement tuner */ - info(%s: MT2063 tuner found\n, __func__); + info(%s: MT2063 tuner found, __func__); goto found; } @@ -597,7 +597,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x38) { priv-tuner = TUNER_RTL2832_MAX3543; /* TODO implement tuner */ - info(%s: MAX3534 tuner found\n, __func__); + info(%s: MAX3534 tuner found, __func__); goto found; } @@ -606,7 +606,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x23 buf[1] == 0x28) { priv-tuner = TUNER_RTL2832_TUA9001; /* TODO implement tuner */ - info(%s: TUA9001 tuner found\n, __func__); + info(%s: TUA9001 tuner found, __func__); goto found; } @@ -615,7 +615,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x14) { priv-tuner = TUNER_RTL2832_MXL5007T; /* TODO implement tuner */ - info(%s: MXL5007T tuner found\n, __func__); + info(%s: MXL5007T tuner found, __func__); goto found; } @@ -624,7 +624,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 buf[0] == 0x40) { priv-tuner = TUNER_RTL2832_E4000; /* TODO implement tuner */ - info(%s: E4000 tuner found\n, __func__); + info(%s: E4000 tuner found, __func__); goto found; } @@ -633,7 +633,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) if (ret == 0 (buf[0] == 0xc7 || buf[1] == 0x60)) { priv-tuner = TUNER_RTL2832_TDA18272; /* TODO implement tuner */ - info(%s: TDA18272 tuner found\n, __func__); + info(%s: TDA18272 tuner found, __func__); goto found; } -- 1.7.7.6 -- 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] fc0012 ver. 0.6: introduction of get_rf_strength function
On 12.05.2012 11:11, Hans-Frieder Vogt wrote: Changes compared to version 0.5 of driver (sent 6 May): - Initial implementation of get_rf_strength function. Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net fc0012.c | 72 ++- 1 file changed, 71 insertions(+), 1 deletion(-) diff -up --new-file --recursive a/drivers/media/common/tuners/fc0012.c b/drivers/media/common/tuners/fc0012.c --- a/drivers/media/common/tuners/fc0012.c2012-05-12 10:53:55.330058209 +0200 +++ b/drivers/media/common/tuners/fc0012.c2012-05-09 23:27:37.781193720 +0200 @@ -343,6 +343,74 @@ static int fc0012_get_bandwidth(struct d return 0; } +#define INPUT_ADC_LEVEL -8 + +static int fc0012_get_rf_strength(struct dvb_frontend *fe, u16 *strength) +{ + struct fc0012_priv *priv = fe-tuner_priv; + int ret; + unsigned char tmp; + int int_temp, lna_gain, int_lna, tot_agc_gain, power; + const int fc0012_lna_gain_table[] = { + /* low gain */ + -63, -58, -99, -73, + -63, -65, -54, -60, + /* middle gain */ + 71, 70, 68, 67, + 65, 63, 61, 58, + /* high gain */ + 197, 191, 188, 186, + 184, 182, 181, 179, + }; + + if (fe-ops.i2c_gate_ctrl) + fe-ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ + + ret = fc0012_writereg(priv, 0x12, 0x00); + if (ret) + goto err; + + ret = fc0012_readreg(priv, 0x12, tmp); + if (ret) + goto err; + int_temp = tmp; + + ret = fc0012_readreg(priv, 0x13, tmp); + if (ret) + goto err; + lna_gain = tmp 0x1f; + + if (fe-ops.i2c_gate_ctrl) + fe-ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ + + if (lna_gain ARRAY_SIZE(fc0012_lna_gain_table)) { + int_lna = fc0012_lna_gain_table[lna_gain]; + tot_agc_gain = (abs((int_temp 5) - 7) - 2 + + (int_temp 0x1f)) * 2; + power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; + + if (power = 45) + *strength = 255;/* 100% */ + else if (power -95) + *strength = 0; + else + *strength = (power + 95) * 255 / 140; + + *strength |= *strength 8; + } else { + ret = -1; + } + + goto exit; + +err: + if (fe-ops.i2c_gate_ctrl) + fe-ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ +exit: + if (ret) + warn(%s: failed: %d, __func__, ret); + return ret; +} static const struct dvb_tuner_ops fc0012_tuner_ops = { .info = { @@ -363,6 +431,8 @@ static const struct dvb_tuner_ops fc0012 .get_frequency = fc0012_get_frequency, .get_if_frequency = fc0012_get_if_frequency, .get_bandwidth = fc0012_get_bandwidth, + + .get_rf_strength = fc0012_get_rf_strength, }; struct dvb_frontend *fc0012_attach(struct dvb_frontend *fe, @@ -394,4 +464,4 @@ EXPORT_SYMBOL(fc0012_attach); MODULE_DESCRIPTION(Fitipower FC0012 silicon tuner driver); MODULE_AUTHOR(Hans-Frieder Vogt hfv...@gmx.net); MODULE_LICENSE(GPL); -MODULE_VERSION(0.5); +MODULE_VERSION(0.6); Hans-Frieder Vogt e-mail: hfvogt at gmx .dot. net Thanks! I was just doing the same to get it to work with the rtl2832 demod. I will test the fc0012 driver with the rtl2832 driver today. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/5] support rtl2832 demodulator
This series of patches contains the rtl2832 demodulator driver. In order to work the fc0012 and fc0013 driver from Hans-Frieder Vogt have to be applied first. The current version includes all the comments on the previous patches. I currently only own a Cinergy Terratec T Stick Black (rev 1) device, that is why i could only test it with that device. Feel free to comment on the patch and report issues you are having with it. Thanks again for all the comments, especially to Antti. Regards Thomas Thomas Mair (5): rtl2832 ver 0.3: suport for RTL2832 demodulator revised version rtl28xxu: support for the rtl2832 demod driver rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr rtl28xxu: support G-Tek Electronics Group Lifeview LV5TDLX DVB-T rtl28xxu: support Terratec Noxon DAB/DAB+ stick drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h|3 + drivers/media/dvb/dvb-usb/rtl28xxu.c | 513 +-- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 1009 drivers/media/dvb/frontends/rtl2832.h | 81 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 260 +++ 8 files changed, 1829 insertions(+), 48 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] rtl2832 ver 0.3: suport for RTL2832 demodulator revised version
Changes compared to version 0.2: - removed reading of signal strength for tuners FC0012,FC0013 (is now supported by fc0012,fc0013 driver) - moved definition of register names to rtl2832_priv.h - cleaned up demod private structure - replaced rtl2832_log2 function with intlog2 from dvb_math Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/Kconfig|7 + drivers/media/dvb/frontends/Makefile |1 + drivers/media/dvb/frontends/rtl2832.c | 1009 drivers/media/dvb/frontends/rtl2832.h | 81 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 260 +++ 5 files changed, 1358 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index f479834..f7d67d7 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -432,6 +432,13 @@ config DVB_RTL2830 help Say Y when you want to support this frontend. +config DVB_RTL2832 + tristate Realtek RTL2832 DVB-T + depends on DVB_CORE I2C + default m if DVB_FE_CUSTOMISE + help + Say Y when you want to support this frontend. + comment DVB-C (cable) frontends depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index b0381dc..9731192 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o obj-$(CONFIG_DVB_A8293) += a8293.o obj-$(CONFIG_DVB_TDA10071) += tda10071.o obj-$(CONFIG_DVB_RTL2830) += rtl2830.o +obj-$(CONFIG_DVB_RTL2832) = rtl2832.o obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o obj-$(CONFIG_DVB_AF9033) += af9033.o diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..1936c50 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,1009 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h +#include dvb_math.h + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +static const rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN]= {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4
[PATCH 2/5] rtl28xxu: support for the rtl2832 demod driver
This only adds support for the Terratec Cinergy T Stick Black device. Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/Kconfig |3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 431 +-- 3 files changed, 411 insertions(+), 24 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index be1db75..98dd0d8 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -417,9 +417,12 @@ config DVB_USB_RTL28XXU tristate Realtek RTL28xxU DVB USB support depends on DVB_USB EXPERIMENTAL select DVB_RTL2830 + select DVB_RTL2832 select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE + select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE help Say Y here to support the Realtek RTL28xxU DVB USB receiver. diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 2418e41..fd37be0 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -157,6 +157,7 @@ #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 #define USB_PID_TERRATEC_CINERGY_T_STICK_RC0x0097 #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 +#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9 #define USB_PID_TWINHAN_VP7041_COLD0x3201 #define USB_PID_TWINHAN_VP7041_WARM0x3202 #define USB_PID_TWINHAN_VP7020_COLD0x3203 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..a2b3d73 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -22,10 +23,12 @@ #include rtl28xxu.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -378,34 +381,153 @@ err: return ret; } +static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0012 +}; + + +static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + int ret; + u8 val; + + deb_info(%s cmd=%d arg=%d\n, __func__, cmd, arg); + switch (cmd) { + case FC_FE_CALLBACK_VHF_ENABLE: + /* set output values */ + ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + + if (arg) + val = 0xbf; /* set GPIO6 low */ + else + val |= 0x40; /* set GPIO6 high */ + + + ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + if (ret) + goto err; + break; + default: + ret = -EINVAL; + goto err; + } + return 0; + +err: + err(%s: failed=%d\n, __func__, ret); + + return ret; +} + + +static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, + int cmd, int arg) +{ + /* TODO implement*/ + return 0; +} + +static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) +{ + struct rtl28xxu_priv *priv = d-priv; + + switch (priv-tuner) { + case TUNER_RTL2832_FC0012: + return rtl2832u_fc0012_tuner_callback(d, cmd, arg); + + case TUNER_RTL2832_FC0013: + return rtl2832u_fc0013_tuner_callback(d, cmd, arg); + default: + break; + } + + return -ENODEV; +} + +static int rtl2832u_frontend_callback(void *adapter_priv, int component, + int cmd, int arg) +{ + struct i2c_adapter *adap = adapter_priv; + struct dvb_usb_device *d = i2c_get_adapdata(adap); + + switch (component) { + case DVB_FRONTEND_COMPONENT_TUNER: + return rtl2832u_tuner_callback(d, cmd, arg); + default: + break; + } + + return -EINVAL; +} + + + + static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) { int ret; struct rtl28xxu_priv *priv = adap-dev-priv; - u8 buf[1]; + struct
[PATCH 3/5] rtl28xxu: renamed rtl2831_rd/rtl2831_wr to rtl28xx_rd/rtl28xx_wr
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c | 102 +- 1 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index a2b3d73..86304c6 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -83,7 +83,7 @@ err: return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -119,12 +119,12 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { return rtl2831_rd_regs(d, reg, val, 1); } @@ -311,12 +311,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; /* enable as output GPIO0, GPIO2, GPIO4 */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -399,7 +399,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, switch (cmd) { case FC_FE_CALLBACK_VHF_ENABLE: /* set output values */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; @@ -409,7 +409,7 @@ static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, val |= 0x40; /* set GPIO6 high */ - ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); + ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); if (ret) goto err; break; @@ -504,25 +504,25 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) deb_info(%s:\n, __func__); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; val = 0xbf; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, val); if (ret) goto err; /* enable as output GPIO3 and GPIO6*/ - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; val |= 0x48; - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, val); if (ret) goto err; @@ -773,7 +773,7 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); - ret = rtl2831_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; @@ -787,11 +787,11 @@ static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) gpio = (~0x04); /* LED off */ } - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_VAL, gpio); if (ret) goto err; - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -817,7 +817,7 @@ static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) buf[1] = 0x02; /* reset EPA */ } - ret = rtl2831_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); + ret = rtl28xx_wr_regs(adap-dev, USB_EPA_CTL, buf, 2); if (ret) goto err; @@ -835,12 +835,12 @@ static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) deb_info(%s: onoff=%d\n, __func__, onoff); /* demod adc */ - ret = rtl2831_rd_reg(d, SYS_SYS0, sys0); + ret = rtl28xx_rd_reg(d, SYS_SYS0, sys0); if (ret) goto err; /* tuner power, read GPIOs */ - ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, gpio); + ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, gpio
[PATCH 4/5] rtl28xxu: support G-Tek Electronics Group Lifeview LV5TDLX DVB-T
Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index fd37be0..b0a86e9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -135,6 +135,7 @@ #define USB_PID_GENIUS_TVGO_DVB_T030x4012 #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 +#define USB_PID_GTEK 0xb803 #define USB_PID_INTEL_CE9500 0x9500 #define USB_PID_ITETECH_IT9135 0x9135 #define USB_PID_ITETECH_IT9135_90050x9005 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 86304c6..699da68 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -1135,6 +1135,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0160, RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, + RTL2832U_1F4D_B803, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1149,6 +1150,8 @@ static struct usb_device_id rtl28xxu_table[] = { /* RTL2832U */ [RTL2832U_0CCD_00A9] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, + [RTL2832U_1F4D_B803] = { + USB_DEVICE(USB_VID_GTEK, USB_PID_GTEK)}, {} /* terminating entry */ }; @@ -1262,7 +1265,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1270,6 +1273,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_0CCD_00A9], }, }, + { + .name = G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U], + .warm_ids = { + rtl28xxu_table[RTL2832U_1F4D_B803], + }, + }, } }, -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/5] rtl28xxu: support Terratec Noxon DAB/DAB+ stick
Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 27 ++- 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index b0a86e9..95c9c14 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -244,6 +244,7 @@ #define USB_PID_TERRATEC_H7_2 0x10a3 #define USB_PID_TERRATEC_T30x10a0 #define USB_PID_TERRATEC_T50x10a1 +#define USB_PID_NOXON_DAB_STICK0x00b3 #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e #define USB_PID_PINNACLE_PCTV2000E 0x022c #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 699da68..bacc783 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -29,6 +29,7 @@ #include mt2060.h #include mxl5005s.h #include fc0012.h +#include fc0013.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -388,6 +389,12 @@ static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { .tuner = TUNER_RTL2832_FC0012 }; +static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0013 +}; static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) @@ -553,6 +560,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) ret = rtl28xxu_ctrl_msg(adap-dev, req_fc0013); if (ret == 0 buf[0] == 0xa3) { priv-tuner = TUNER_RTL2832_FC0013; + rtl2832_config = rtl28xxu_rtl2832_fc0013_config; info(%s: FC0013 tuner found\n, __func__); goto found; } @@ -750,6 +758,14 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) fe-ops.tuner_ops.get_rf_strength; return 0; break; + case TUNER_RTL2832_FC0013: + fe = dvb_attach(fc0013_attach, adap-fe_adap[0].fe, + adap-dev-i2c_adap, 0xc61, 0, FC_XTAL_28_8_MHZ); + + /* fc0013 also supports signal strength reading */ + adap-fe_adap[0].fe-ops.read_signal_strength = adap-fe_adap[0] + .fe-ops.tuner_ops.get_rf_strength; + return 0; default: fe = NULL; err(unknown tuner=%d, priv-tuner); @@ -1136,6 +1152,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, RTL2832U_1F4D_B803, + RTL2832U_0CCD_00B3, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1152,6 +1169,8 @@ static struct usb_device_id rtl28xxu_table[] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, [RTL2832U_1F4D_B803] = { USB_DEVICE(USB_VID_GTEK, USB_PID_GTEK)}, + [RTL2832U_0CCD_00B3] = { + USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, {} /* terminating entry */ }; @@ -1265,7 +1284,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 2, + .num_device_descs = 3, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1279,6 +1298,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_1F4D_B803], }, }, + { + .name = NOXON DAB/DAB+ USB dongle, + .warm_ids = { + rtl28xxu_table[RTL2832U_0CCD_00B3], + }, + }, } }, -- 1.7.7.6 -- 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 5/5] rtl28xxu: support Terratec Noxon DAB/DAB+ stick
The patch contains two small errors that prevent its application. This is the fixed version. Signed-off-by: Hans-Frieder Vogt hfv...@gmx.net Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |1 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 27 ++- 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index b0a86e9..95c9c14 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -244,6 +244,7 @@ #define USB_PID_TERRATEC_H7_2 0x10a3 #define USB_PID_TERRATEC_T30x10a0 #define USB_PID_TERRATEC_T50x10a1 +#define USB_PID_NOXON_DAB_STICK0x00b3 #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e #define USB_PID_PINNACLE_PCTV2000E 0x022c #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 699da68..bacc783 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -29,6 +29,7 @@ #include mt2060.h #include mxl5005s.h #include fc0012.h +#include fc0013.h /* debug */ static int dvb_usb_rtl28xxu_debug; @@ -388,6 +389,12 @@ static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { .tuner = TUNER_RTL2832_FC0012 }; +static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { + .i2c_addr = 0x10, /* 0x20 */ + .xtal = 2880, + .if_dvbt = 0, + .tuner = TUNER_RTL2832_FC0013 +}; static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) @@ -553,6 +560,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) ret = rtl28xxu_ctrl_msg(adap-dev, req_fc0013); if (ret == 0 buf[0] == 0xa3) { priv-tuner = TUNER_RTL2832_FC0013; + rtl2832_config = rtl28xxu_rtl2832_fc0013_config; info(%s: FC0013 tuner found\n, __func__); goto found; } @@ -750,6 +758,14 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) fe-ops.tuner_ops.get_rf_strength; return 0; break; + case TUNER_RTL2832_FC0013: + fe = dvb_attach(fc0013_attach, adap-fe_adap[0].fe, + adap-dev-i2c_adap, 0xc61, 0, FC_XTAL_28_8_MHZ); + + /* fc0013 also supports signal strength reading */ + adap-fe_adap[0].fe-ops.read_signal_strength = adap-fe_adap[0] + .fe-ops.tuner_ops.get_rf_strength; + return 0; default: fe = NULL; err(unknown tuner=%d, priv-tuner); @@ -1136,6 +1152,7 @@ enum rtl28xxu_usb_table_entry { RTL2831U_14AA_0161, RTL2832U_0CCD_00A9, RTL2832U_1F4D_B803, + RTL2832U_0CCD_00B3, }; static struct usb_device_id rtl28xxu_table[] = { @@ -1152,6 +1169,8 @@ static struct usb_device_id rtl28xxu_table[] = { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, [RTL2832U_1F4D_B803] = { USB_DEVICE(USB_VID_GTEK, USB_PID_GTEK)}, + [RTL2832U_0CCD_00B3] = { + USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, {} /* terminating entry */ }; @@ -1265,7 +1284,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { .i2c_algo = rtl28xxu_i2c_algo, - .num_device_descs = 2, + .num_device_descs = 3, .devices = { { .name = Terratec Cinergy T Stick Black, @@ -1279,6 +1298,12 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { rtl28xxu_table[RTL2832U_1F4D_B803], }, }, + { + .name = NOXON DAB/DAB+ USB dongle, + .warm_ids = { + rtl28xxu_table[RTL2832U_0CCD_00B3], + }, + }, } }, -- 1.7.7.6 -- 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 v3 1/3] Modified RTL28xxU driver to work with RTL2832
On 07.05.2012 09:59, Antti Palosaari wrote: Good morning! Comments below. On 06.05.2012 15:46, Thomas Mair wrote: Hi everyone, this is the first complete version of the rtl2832 demod driver. I splitted the patches in three parts: 1. changes in the dvb-usb part (dvb_usb_rtl28xxu) 2. demod driver (rtl2832) 3. tuner driver (fc0012) - added tuner probing with log output - added callback for tuners to change UHF/VHF band - moved and renamed tuner enums to own header file - supported devices: - Terratec Cinergy T Stick Black - G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U] Signed-off-by: Thomas Mairthomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c| 604 ++- drivers/media/dvb/dvb-usb/rtl28xxu.h| 19 - drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h | 42 ++ 3 files changed, 544 insertions(+), 121 deletions(-) create mode 100644 drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..00bd712 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaaricr...@iki.fi * Copyright (C) 2011 Antti Palosaaricr...@iki.fi + * Copyright (C) 2012 Thomas Mairthomas.mai...@googlemail.com * *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 @@ -20,17 +21,20 @@ */ #include rtl28xxu.h +#include rtl28xxu_tuners.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h + -/* debug */ static int dvb_usb_rtl28xxu_debug; module_param_named(debug, dvb_usb_rtl28xxu_debug, int, 0644); -MODULE_PARM_DESC(debug, set debugging level DVB_USB_DEBUG_STATUS); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); Why you changed that at all? And it is DVB USB driver, not frontend (demodulator), as it now says. Ok that was a bad idea. I'll revert that. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) @@ -76,11 +80,11 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) return ret; err: -deb_info(%s: failed=%d\n, __func__, ret); +deb_info(%s: failed=%d, __func__, ret); Why you have removed new line from all the existing debugs? return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) That's renaming OK, my mistake originally... { struct rtl28xxu_req req; @@ -98,7 +102,7 @@ static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d,req); } -static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -116,14 +120,14 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d,req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { -return rtl2831_wr_regs(d, reg,val, 1); +return rtl28xx_wr_regs(d, reg,val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { -return rtl2831_rd_regs(d, reg, val, 1); +return rtl28xx_rd_regs(d, reg, val, 1); } /* I2C */ @@ -297,7 +301,7 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* for QT1010 tuner probe */ struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; -deb_info(%s:\n, __func__); +deb_info(%s:, __func__); /* * RTL2831U GPIOs @@ -308,12 +312,13 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ -ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); +ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; + /* enable as output GPIO0, GPIO2, GPIO4 */ -ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); +ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -330,12 +335,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* check QT1010 ID(?) register; reg=0f val=2c */ ret = rtl28xxu_ctrl_msg(adap-dev,req_qt1010); if (ret == 0 buf[0] == 0x2c) { -priv-tuner = TUNER_RTL2830_QT1010; +priv-tuner
[PATCH v3 1/3] Modified RTL28xxU driver to work with RTL2832
Hi everyone, this is the first complete version of the rtl2832 demod driver. I splitted the patches in three parts: 1. changes in the dvb-usb part (dvb_usb_rtl28xxu) 2. demod driver (rtl2832) 3. tuner driver (fc0012) - added tuner probing with log output - added callback for tuners to change UHF/VHF band - moved and renamed tuner enums to own header file - supported devices: - Terratec Cinergy T Stick Black - G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U] Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c| 604 ++- drivers/media/dvb/dvb-usb/rtl28xxu.h| 19 - drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h | 42 ++ 3 files changed, 544 insertions(+), 121 deletions(-) create mode 100644 drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..00bd712 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -20,17 +21,20 @@ */ #include rtl28xxu.h +#include rtl28xxu_tuners.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h + -/* debug */ static int dvb_usb_rtl28xxu_debug; module_param_named(debug, dvb_usb_rtl28xxu_debug, int, 0644); -MODULE_PARM_DESC(debug, set debugging level DVB_USB_DEBUG_STATUS); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) @@ -76,11 +80,11 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) return ret; err: - deb_info(%s: failed=%d\n, __func__, ret); + deb_info(%s: failed=%d, __func__, ret); return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -98,7 +102,7 @@ static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -116,14 +120,14 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { - return rtl2831_rd_regs(d, reg, val, 1); + return rtl28xx_rd_regs(d, reg, val, 1); } /* I2C */ @@ -297,7 +301,7 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* for QT1010 tuner probe */ struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; - deb_info(%s:\n, __func__); + deb_info(%s:, __func__); /* * RTL2831U GPIOs @@ -308,12 +312,13 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; + /* enable as output GPIO0, GPIO2, GPIO4 */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -330,12 +335,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* check QT1010 ID(?) register; reg=0f val=2c */ ret = rtl28xxu_ctrl_msg(adap-dev, req_qt1010); if (ret == 0 buf[0] == 0x2c) { - priv-tuner = TUNER_RTL2830_QT1010; + priv-tuner = TUNER_RTL28XX_QT1010; rtl2830_config = rtl28xxu_rtl2830_qt1010_config; - deb_info(%s: QT1010\n, __func__); + deb_info(%s: QT1010, __func__); goto found; } else { - deb_info(%s: QT1010 probe failed=%d - %02x\n, + deb_info(%s: QT1010 probe failed=%d - %02x, __func__, ret, buf[0]); } @@ -347,20 +352,20 @@ static int
[PATCH v3 2/3] RTL2832 demodulator driver.
- currently only support for the FC0012 tuner is included - The driver uses a custom log2 function. Maybe it should be changed to use ilog2 or a similar function. Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/rtl2832.c | 1214 drivers/media/dvb/frontends/rtl2832.h | 296 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 60 ++ 3 files changed, 1570 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..fb4f577 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,1214 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h +#include rtl28xxu_tuners.h + + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +static const rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN]= {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4}, + [DVBT_AD_AV_REF]= {0x0, 0x9, 6, 0}, + [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, + [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, + [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, + [DVBT_SCALE1_B93] = {0x2, 0x93, 7, 0}, + [DVBT_SCALE1_BA7] = {0x2, 0xa7, 7, 0}, + [DVBT_SCALE1_BA9] = {0x2, 0xa9, 7, 0}, + [DVBT_SCALE1_BAA] = {0x2, 0xaa, 7, 0}, + [DVBT_SCALE1_BAB] = {0x2, 0xab, 7, 0}, + [DVBT_SCALE1_BAC] = {0x2, 0xac, 7, 0}, + [DVBT_SCALE1_BB0] = {0x2, 0xb0, 7, 0}, + [DVBT_SCALE1_BB1] = {0x2, 0xb1, 7, 0}, + [DVBT_KB_P1]= {0x1, 0x64, 3, 1}, + [DVBT_KB_P2]= {0x1, 0x64, 6, 4}, + [DVBT_KB_P3]= {0x1, 0x65, 2, 0}, + [DVBT_OPT_ADC_IQ] = {0x0, 0x6, 5, 4}, + [DVBT_AD_AVI] = {0x0, 0x9, 1, 0}, + [DVBT_AD_AVQ] = {0x0, 0x9, 3, 2}, + [DVBT_K1_CR_STEP12] = {0x2, 0xad, 9, 4}, + [DVBT_TRK_KS_P2]= {0x1, 0x6f, 2, 0}, + [DVBT_TRK_KS_I2]= {0x1, 0x70, 5, 3}, + [DVBT_TR_THD_SET2]= {0x1
[PATCH v3 3/3] FC0012 tuner driver.
This driver is based on the driver written by Hans-Frieder Vogt. The following modifications hav been made - added callback for UHF/VFH band selection in fc0012_set_params (needed by Cinergy T Stick Black) - modified some parameters when initialiting the tuner (maybe the initialization should be done by passing parameters to the init functions to be usable with different demods) Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/common/tuners/fc0012-priv.h | 42 +++ drivers/media/common/tuners/fc0012.c | 398 + drivers/media/common/tuners/fc0012.h | 60 + 3 files changed, 500 insertions(+), 0 deletions(-) create mode 100644 drivers/media/common/tuners/fc0012-priv.h create mode 100644 drivers/media/common/tuners/fc0012.c create mode 100644 drivers/media/common/tuners/fc0012.h diff --git a/drivers/media/common/tuners/fc0012-priv.h b/drivers/media/common/tuners/fc0012-priv.h new file mode 100644 index 000..c2c3c47 --- /dev/null +++ b/drivers/media/common/tuners/fc0012-priv.h @@ -0,0 +1,42 @@ +/* + * Fitipower FC0012 tuner driver - private includes + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _FC0012_PRIV_H_ +#define _FC0012_PRIV_H_ + +#define LOG_PREFIX fc0012 + +#undef err +#define err(f, arg...) printk(KERN_ERR LOG_PREFIX: f \n , ## arg) +#undef info +#define info(f, arg...) printk(KERN_INFOLOG_PREFIX: f \n , ## arg) +#undef warn +#define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX: f \n , ## arg) + +struct fc0012_priv { + struct i2c_adapter *i2c; + u8 addr; + u8 xtal_freq; + + u32 frequency; + u32 bandwidth; +}; + +#endif diff --git a/drivers/media/common/tuners/fc0012.c b/drivers/media/common/tuners/fc0012.c new file mode 100644 index 000..5beae31 --- /dev/null +++ b/drivers/media/common/tuners/fc0012.c @@ -0,0 +1,398 @@ +/* + * Fitipower FC0012 tuner driver + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include fc0012.h +#include fc0012-priv.h + +static int fc0012_writereg(struct fc0012_priv *priv, u8 reg, u8 val) +{ + u8 buf[2] = {reg, val}; + struct i2c_msg msg = { .addr = priv-addr, .flags = 0, .buf = buf, + .len = 2 }; + + if (i2c_transfer(priv-i2c, msg, 1) != 1) { + err(I2C write reg failed, reg: %02x, val: %02x, reg, val); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_readreg(struct fc0012_priv *priv, u8 reg, u8 *val) +{ + struct i2c_msg msg[2] = { + { .addr = priv-addr, .flags = 0, .buf = reg, .len = 1 }, + { .addr = priv-addr, .flags = I2C_M_RD, .buf = val, + .len = 1 }, + }; + + if (i2c_transfer(priv-i2c, msg, 2) != 2) { + err(I2C read failed, reg: %02x, reg); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_release(struct dvb_frontend *fe) +{ + kfree(fe-tuner_priv); + fe-tuner_priv = NULL; + return 0; +} + +static int fc0012_init(struct dvb_frontend *fe) +{ + struct fc0012_priv *priv = fe-tuner_priv; + int i, ret = 0; + unsigned char reg[] = { + 0x00, /* dummy reg. 0 */ + 0x05, /* reg. 0x01 */ + 0x10, /* reg. 0x02 */ + 0x00, /* reg. 0x03 */ + 0x00, /* reg. 0x04 */ + 0x0f, /* reg. 0x05 CHECK: correct? */ + /* changed for rtl2832 */ + 0x00, /* reg. 0x06: divider
Re: [PATCH v3 1/3] Modified RTL28xxU driver to work with RTL2832
On 06.05.2012 17:37, Hans-Frieder Vogt wrote: line wrapped. This prevents the patch to apply. Please switch off the automatic line wrap in your mailer! Sorry. Now the issue should be resolved. - added tuner probing with log output - added callback for tuners to change UHF/VHF band - moved and renamed tuner enums to own header file - supported devices: - Terratec Cinergy T Stick Black - G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U] Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/rtl28xxu.c| 604 ++- drivers/media/dvb/dvb-usb/rtl28xxu.h| 19 - drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h | 42 ++ 3 files changed, 544 insertions(+), 121 deletions(-) create mode 100644 drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..00bd712 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -20,17 +21,20 @@ */ #include rtl28xxu.h +#include rtl28xxu_tuners.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h + -/* debug */ static int dvb_usb_rtl28xxu_debug; module_param_named(debug, dvb_usb_rtl28xxu_debug, int, 0644); -MODULE_PARM_DESC(debug, set debugging level DVB_USB_DEBUG_STATUS); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) @@ -76,11 +80,11 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) return ret; err: - deb_info(%s: failed=%d\n, __func__, ret); + deb_info(%s: failed=%d, __func__, ret); return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -98,7 +102,7 @@ static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -116,14 +120,14 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { - return rtl2831_rd_regs(d, reg, val, 1); + return rtl28xx_rd_regs(d, reg, val, 1); } /* I2C */ @@ -297,7 +301,7 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* for QT1010 tuner probe */ struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; - deb_info(%s:\n, __func__); + deb_info(%s:, __func__); /* * RTL2831U GPIOs @@ -308,12 +312,13 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret) goto err; + /* enable as output GPIO0, GPIO2, GPIO4 */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_OUT_EN, 0x15); if (ret) goto err; @@ -330,12 +335,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* check QT1010 ID(?) register; reg=0f val=2c */ ret = rtl28xxu_ctrl_msg(adap-dev, req_qt1010); if (ret == 0 buf[0] == 0x2c) { - priv-tuner = TUNER_RTL2830_QT1010; + priv-tuner = TUNER_RTL28XX_QT1010; rtl2830_config = rtl28xxu_rtl2830_qt1010_config; - deb_info(%s: QT1010\n, __func__); + deb_info(%s: QT1010, __func__); goto found; } else { - deb_info(%s: QT1010 probe failed=%d - %02x\n, + deb_info(%s: QT1010 probe failed=%d - %02x, __func__, ret, buf[0]); } @@ -347,20 +352,20
Re: [PATCH v3 2/3] RTL2832 demodulator driver.
- currently only support for the FC0012 tuner is included - The driver uses a custom log2 function. Maybe it should be changed to use ilog2 or a similar function. Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/rtl2832.c | 1214 drivers/media/dvb/frontends/rtl2832.h | 296 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 60 ++ 3 files changed, 1570 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..fb4f577 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,1214 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h +#include rtl28xxu_tuners.h + + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +static const rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN]= {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4}, + [DVBT_AD_AV_REF]= {0x0, 0x9, 6, 0}, + [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, + [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, + [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, + [DVBT_SCALE1_B93] = {0x2, 0x93, 7, 0}, + [DVBT_SCALE1_BA7] = {0x2, 0xa7, 7, 0}, + [DVBT_SCALE1_BA9] = {0x2, 0xa9, 7, 0}, + [DVBT_SCALE1_BAA] = {0x2, 0xaa, 7, 0}, + [DVBT_SCALE1_BAB] = {0x2, 0xab, 7, 0}, + [DVBT_SCALE1_BAC] = {0x2, 0xac, 7, 0}, + [DVBT_SCALE1_BB0] = {0x2, 0xb0, 7, 0}, + [DVBT_SCALE1_BB1] = {0x2, 0xb1, 7, 0}, + [DVBT_KB_P1]= {0x1, 0x64, 3, 1}, + [DVBT_KB_P2]= {0x1, 0x64, 6, 4}, + [DVBT_KB_P3]= {0x1, 0x65, 2, 0}, + [DVBT_OPT_ADC_IQ] = {0x0, 0x6, 5, 4}, + [DVBT_AD_AVI] = {0x0, 0x9, 1, 0}, + [DVBT_AD_AVQ] = {0x0, 0x9, 3, 2}, + [DVBT_K1_CR_STEP12] = {0x2, 0xad, 9, 4}, + [DVBT_TRK_KS_P2]= {0x1, 0x6f, 2, 0}, + [DVBT_TRK_KS_I2]= {0x1, 0x70, 5, 3}, + [DVBT_TR_THD_SET2]= {0x1
Re: [PATCH v3 3/3] FC0012 tuner driver.
This driver is based on the driver written by Hans-Frieder Vogt. The following modifications hav been made - added callback for UHF/VFH band selection in fc0012_set_params (needed by Cinergy T Stick Black) - modified some parameters when initialiting the tuner (maybe the initialization should be done by passing parameters to the init functions to be usable with different demods) Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/common/tuners/fc0012-priv.h | 42 +++ drivers/media/common/tuners/fc0012.c | 398 + drivers/media/common/tuners/fc0012.h | 60 + 3 files changed, 500 insertions(+), 0 deletions(-) create mode 100644 drivers/media/common/tuners/fc0012-priv.h create mode 100644 drivers/media/common/tuners/fc0012.c create mode 100644 drivers/media/common/tuners/fc0012.h diff --git a/drivers/media/common/tuners/fc0012-priv.h b/drivers/media/common/tuners/fc0012-priv.h new file mode 100644 index 000..c2c3c47 --- /dev/null +++ b/drivers/media/common/tuners/fc0012-priv.h @@ -0,0 +1,42 @@ +/* + * Fitipower FC0012 tuner driver - private includes + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _FC0012_PRIV_H_ +#define _FC0012_PRIV_H_ + +#define LOG_PREFIX fc0012 + +#undef err +#define err(f, arg...) printk(KERN_ERR LOG_PREFIX: f \n , ## arg) +#undef info +#define info(f, arg...) printk(KERN_INFOLOG_PREFIX: f \n , ## arg) +#undef warn +#define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX: f \n , ## arg) + +struct fc0012_priv { + struct i2c_adapter *i2c; + u8 addr; + u8 xtal_freq; + + u32 frequency; + u32 bandwidth; +}; + +#endif diff --git a/drivers/media/common/tuners/fc0012.c b/drivers/media/common/tuners/fc0012.c new file mode 100644 index 000..5beae31 --- /dev/null +++ b/drivers/media/common/tuners/fc0012.c @@ -0,0 +1,398 @@ +/* + * Fitipower FC0012 tuner driver + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include fc0012.h +#include fc0012-priv.h + +static int fc0012_writereg(struct fc0012_priv *priv, u8 reg, u8 val) +{ + u8 buf[2] = {reg, val}; + struct i2c_msg msg = { .addr = priv-addr, .flags = 0, .buf = buf, + .len = 2 }; + + if (i2c_transfer(priv-i2c, msg, 1) != 1) { + err(I2C write reg failed, reg: %02x, val: %02x, reg, val); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_readreg(struct fc0012_priv *priv, u8 reg, u8 *val) +{ + struct i2c_msg msg[2] = { + { .addr = priv-addr, .flags = 0, .buf = reg, .len = 1 }, + { .addr = priv-addr, .flags = I2C_M_RD, .buf = val, + .len = 1 }, + }; + + if (i2c_transfer(priv-i2c, msg, 2) != 2) { + err(I2C read failed, reg: %02x, reg); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_release(struct dvb_frontend *fe) +{ + kfree(fe-tuner_priv); + fe-tuner_priv = NULL; + return 0; +} + +static int fc0012_init(struct dvb_frontend *fe) +{ + struct fc0012_priv *priv = fe-tuner_priv; + int i, ret = 0; + unsigned char reg[] = { + 0x00, /* dummy reg. 0 */ + 0x05, /* reg. 0x01 */ + 0x10, /* reg. 0x02 */ + 0x00, /* reg. 0x03 */ + 0x00, /* reg. 0x04 */ + 0x0f, /* reg. 0x05 CHECK: correct? */ + /* changed for rtl2832 */ + 0x00, /* reg. 0x06
Re: [RFC] tuner callback name in RTL28xxu driver
On 06.05.2012 19:29, Hans-Frieder Vogt wrote: Thomas, in your patch for the RTL28xxu you introduce a tuner callback (see below). You called the command FC0012_FE_CALLBACK_UHF_ENABLE. Since the argument is currently defined to be true if the frequency is below 300MHz, i.e. the argument is true if the frequency is a VHF frequency. Therefore I would rather recommend to call the command ..._FE_CALLBACK_VHF_ENABLE. What do you think? Yes. I changed that 5 times. That is why it ended up wrong. I am currently resolving your issues and will rename it too in other patches. I am just about to send out a patch for the fc0013 tuner, and since this tuner has a lot in common with the fc0012, I intend to put the callback definition into a separate fc001x-common.h header. I just like to know if you have any objections me renaming the callback command. Cheers, Hans-Frieder + + +static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, +int cmd, int arg) +{ +int ret; +u8 val; + +deb_info(%s cmd=%d arg=%d, __func__, cmd, arg); +switch (cmd) { +case FC0012_FE_CALLBACK_UHF_ENABLE: +/* set output values */ + +ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, val); +if (ret) +goto err; + +val = 0xbf; + +ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val); +if (ret) +goto err; + + +ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, val); +if (ret) +goto err; + +val |= 0x40; + +ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val); +if (ret) +goto err; + + +ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, val); +if (ret) +goto err; + +if (arg) +val = 0xbf; /* set GPIO6 low */ +else +val |= 0x40; /* set GPIO6 high */ + + +ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); +if (ret) +goto err; +break; +default: +ret = -EINVAL; +goto err; +} +return 0; + +err: +err(%s: failed=%d, __func__, ret); + return ret; } Hans-Frieder Vogt e-mail: hfvogt at gmx .dot. net -- 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 v4 1/3] Modified RTL28xxU driver to work with RTL2832
- added tuner probing with log output - added callback for tuners to change UHF/VHF band - moved and renamed tuner enums to own header file - supported devices: - Terratec Cinergy T Stick Black - G-Tek Electronics Group Lifeview LV5TDLX DVB-T [RTL2832U] Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/dvb-usb/dvb-usb-ids.h |2 + drivers/media/dvb/dvb-usb/rtl28xxu.c| 604 ++- drivers/media/dvb/dvb-usb/rtl28xxu.h| 19 - drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h | 42 ++ 4 files changed, 546 insertions(+), 121 deletions(-) create mode 100644 drivers/media/dvb/dvb-usb/rtl28xxu_tuners.h diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 2418e41..22df252 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -135,6 +135,7 @@ #define USB_PID_GENIUS_TVGO_DVB_T030x4012 #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 #define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 +#define USB_PID_GTEK 0xb803 #define USB_PID_INTEL_CE9500 0x9500 #define USB_PID_ITETECH_IT9135 0x9135 #define USB_PID_ITETECH_IT9135_90050x9005 @@ -157,6 +158,7 @@ #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 #define USB_PID_TERRATEC_CINERGY_T_STICK_RC0x0097 #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 +#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV10x00a9 #define USB_PID_TWINHAN_VP7041_COLD0x3201 #define USB_PID_TWINHAN_VP7041_WARM0x3202 #define USB_PID_TWINHAN_VP7020_COLD0x3203 diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 8f4736a..1a735be 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Antti Palosaari cr...@iki.fi * Copyright (C) 2011 Antti Palosaari cr...@iki.fi + * Copyright (C) 2012 Thomas Mair thomas.mai...@googlemail.com * *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 @@ -20,17 +21,20 @@ */ #include rtl28xxu.h +#include rtl28xxu_tuners.h #include rtl2830.h +#include rtl2832.h #include qt1010.h #include mt2060.h #include mxl5005s.h +#include fc0012.h + -/* debug */ static int dvb_usb_rtl28xxu_debug; module_param_named(debug, dvb_usb_rtl28xxu_debug, int, 0644); -MODULE_PARM_DESC(debug, set debugging level DVB_USB_DEBUG_STATUS); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) @@ -76,11 +80,11 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) return ret; err: - deb_info(%s: failed=%d\n, __func__, ret); + deb_info(%s: failed=%d, __func__, ret); return ret; } -static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -98,7 +102,7 @@ static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) +static int rtl28xx_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) { struct rtl28xxu_req req; @@ -116,14 +120,14 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) return rtl28xxu_ctrl_msg(d, req); } -static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) +static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) { - return rtl2831_wr_regs(d, reg, val, 1); + return rtl28xx_wr_regs(d, reg, val, 1); } -static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) +static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) { - return rtl2831_rd_regs(d, reg, val, 1); + return rtl28xx_rd_regs(d, reg, val, 1); } /* I2C */ @@ -297,7 +301,7 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) /* for QT1010 tuner probe */ struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; - deb_info(%s:\n, __func__); + deb_info(%s:, __func__); /* * RTL2831U GPIOs @@ -308,12 +312,13 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) */ /* GPIO direction */ - ret = rtl2831_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); + ret = rtl28xx_wr_reg(adap-dev, SYS_GPIO_DIR, 0x0a); if (ret
[PATCH v4 2/3] RTL2832 demodulator driver
- currently only support for the FC0012 tuner is included - The driver uses a custom log2 function. Maybe it should be changed to use ilog2 or a similar function. Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/dvb/frontends/rtl2832.c | 1214 drivers/media/dvb/frontends/rtl2832.h | 296 +++ drivers/media/dvb/frontends/rtl2832_priv.h | 60 ++ 3 files changed, 1570 insertions(+), 0 deletions(-) create mode 100644 drivers/media/dvb/frontends/rtl2832.c create mode 100644 drivers/media/dvb/frontends/rtl2832.h create mode 100644 drivers/media/dvb/frontends/rtl2832_priv.h diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000..93ae960 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c @@ -0,0 +1,1214 @@ +/* + * Realtek RTL2832 DVB-T demodulator driver + * + * Copyright (C) 2012 Thomas Mair thomas.mai...@gmail.com + * + * 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. + */ + +#include rtl2832_priv.h +#include rtl28xxu_tuners.h + + + +int rtl2832_debug; +module_param_named(debug, rtl2832_debug, int, 0644); +MODULE_PARM_DESC(debug, Turn on/off frontend debugging (default:off).); + + +static int reg_mask[32] = { + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x, + 0x0001, + 0x0003, + 0x0007, + 0x000f, + 0x001f, + 0x003f, + 0x007f, + 0x00ff, + 0x01ff, + 0x03ff, + 0x07ff, + 0x0fff, + 0x1fff, + 0x3fff, + 0x7fff, + 0x +}; + +static const rtl2832_reg_entry registers[] = { + [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, + [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, + [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, + [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, + [DVBT_EN_BK_TRK]= {0x1, 0xa6, 7, 7}, + [DVBT_AD_EN_REG]= {0x0, 0x8, 7, 7}, + [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, + [DVBT_EN_BBIN]= {0x1, 0xb1, 0, 0}, + [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, + [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, + [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, + [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, + [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, + [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, + [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, + [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, + [DVBT_EN_CACQ_NOTCH]= {0x1, 0x61, 4, 4}, + [DVBT_AD_AV_REF]= {0x0, 0x9, 6, 0}, + [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, + [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, + [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, + [DVBT_SCALE1_B93] = {0x2, 0x93, 7, 0}, + [DVBT_SCALE1_BA7] = {0x2, 0xa7, 7, 0}, + [DVBT_SCALE1_BA9] = {0x2, 0xa9, 7, 0}, + [DVBT_SCALE1_BAA] = {0x2, 0xaa, 7, 0}, + [DVBT_SCALE1_BAB] = {0x2, 0xab, 7, 0}, + [DVBT_SCALE1_BAC] = {0x2, 0xac, 7, 0}, + [DVBT_SCALE1_BB0] = {0x2, 0xb0, 7, 0}, + [DVBT_SCALE1_BB1] = {0x2, 0xb1, 7, 0}, + [DVBT_KB_P1]= {0x1, 0x64, 3, 1}, + [DVBT_KB_P2]= {0x1, 0x64, 6, 4}, + [DVBT_KB_P3]= {0x1, 0x65, 2, 0}, + [DVBT_OPT_ADC_IQ] = {0x0, 0x6, 5, 4}, + [DVBT_AD_AVI] = {0x0, 0x9, 1, 0}, + [DVBT_AD_AVQ] = {0x0, 0x9, 3, 2}, + [DVBT_K1_CR_STEP12] = {0x2, 0xad, 9, 4}, + [DVBT_TRK_KS_P2]= {0x1, 0x6f, 2, 0}, + [DVBT_TRK_KS_I2]= {0x1, 0x70, 5, 3}, + [DVBT_TR_THD_SET2]= {0x1
[PATCH v4 3/3] FC0012 tuner driver
This driver is based on the driver written by Hans-Frieder Vogt. The following modifications hav been made - added callback for UHF/VFH band selection in fc0012_set_params (needed by Cinergy T Stick Black) - modified some parameters when initialiting the tuner (maybe the initialization should be done by passing parameters to the init functions to be usable with different demods) Signed-off-by: Thomas Mair thomas.mai...@googlemail.com --- drivers/media/common/tuners/fc0012-priv.h | 42 +++ drivers/media/common/tuners/fc0012.c | 398 + drivers/media/common/tuners/fc0012.h | 60 + 3 files changed, 500 insertions(+), 0 deletions(-) create mode 100644 drivers/media/common/tuners/fc0012-priv.h create mode 100644 drivers/media/common/tuners/fc0012.c create mode 100644 drivers/media/common/tuners/fc0012.h diff --git a/drivers/media/common/tuners/fc0012-priv.h b/drivers/media/common/tuners/fc0012-priv.h new file mode 100644 index 000..c2c3c47 --- /dev/null +++ b/drivers/media/common/tuners/fc0012-priv.h @@ -0,0 +1,42 @@ +/* + * Fitipower FC0012 tuner driver - private includes + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _FC0012_PRIV_H_ +#define _FC0012_PRIV_H_ + +#define LOG_PREFIX fc0012 + +#undef err +#define err(f, arg...) printk(KERN_ERR LOG_PREFIX: f \n , ## arg) +#undef info +#define info(f, arg...) printk(KERN_INFOLOG_PREFIX: f \n , ## arg) +#undef warn +#define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX: f \n , ## arg) + +struct fc0012_priv { + struct i2c_adapter *i2c; + u8 addr; + u8 xtal_freq; + + u32 frequency; + u32 bandwidth; +}; + +#endif diff --git a/drivers/media/common/tuners/fc0012.c b/drivers/media/common/tuners/fc0012.c new file mode 100644 index 000..93db194 --- /dev/null +++ b/drivers/media/common/tuners/fc0012.c @@ -0,0 +1,398 @@ +/* + * Fitipower FC0012 tuner driver + * + * Copyright (C) 2012 Hans-Frieder Vogt hfv...@gmx.net + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include fc0012.h +#include fc0012-priv.h + +static int fc0012_writereg(struct fc0012_priv *priv, u8 reg, u8 val) +{ + u8 buf[2] = {reg, val}; + struct i2c_msg msg = { .addr = priv-addr, .flags = 0, .buf = buf, + .len = 2 }; + + if (i2c_transfer(priv-i2c, msg, 1) != 1) { + err(I2C write reg failed, reg: %02x, val: %02x, reg, val); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_readreg(struct fc0012_priv *priv, u8 reg, u8 *val) +{ + struct i2c_msg msg[2] = { + { .addr = priv-addr, .flags = 0, .buf = reg, .len = 1 }, + { .addr = priv-addr, .flags = I2C_M_RD, .buf = val, + .len = 1 }, + }; + + if (i2c_transfer(priv-i2c, msg, 2) != 2) { + err(I2C read failed, reg: %02x, reg); + return -EREMOTEIO; + } + return 0; +} + +static int fc0012_release(struct dvb_frontend *fe) +{ + kfree(fe-tuner_priv); + fe-tuner_priv = NULL; + return 0; +} + +static int fc0012_init(struct dvb_frontend *fe) +{ + struct fc0012_priv *priv = fe-tuner_priv; + int i, ret = 0; + unsigned char reg[] = { + 0x00, /* dummy reg. 0 */ + 0x05, /* reg. 0x01 */ + 0x10, /* reg. 0x02 */ + 0x00, /* reg. 0x03 */ + 0x00, /* reg. 0x04 */ + 0x0f, /* reg. 0x05 CHECK: correct? */ + /* changed for rtl2832 */ + 0x00, /* reg. 0x06
Re: [PATCH v2] add support for DeLOCK-USB-2.0-DVB-T-Receiver-61744
I am currently finishing up the work at the demod driver and will probably send a new version to the list tomorrow. As I don't own a device with a different tuner than the fc0012 I will include an error message about the unsupported tuner and print its type. So It is easier to get the information about the tuners. Right now I am writing the signal_strength callback and stumbled upon the following problem: The signal strength is read from the fc0012 tuner (only for fc0012). How should the driver implement this situation. Is there a callback I could implement within the tuner or should I just read the tuner registers from the demodulator? Regards Thomas 2012/5/5 poma pomidorabelis...@gmail.com: On 05/04/2012 03:49 PM, Gianluca Gennari wrote: Hi poma, thanks for the very interesting links. ;) Il 04/05/2012 03:27, poma ha scritto: On 05/03/2012 11:03 AM, Gianluca Gennari wrote: Hi poma, I have a 0BDA:2838 (Easycap EZTV646) and a 0BDA:2832 (no name 20x20mm mini DVB-T stick) and both are based on the E4000 tuner, which is not supported in the kernel at the moment. I have no idea if there are sticks with the same USB PID and the fc0012 tuner. OK, second one - no name device is Realtek RTL2832U reference design**. First one: Once upon a time there was a EasyCAP� After while crocodile! �and EzCAP was born. http://szforwardvideo.en.alibaba.com/aboutus.html Obviously Easycap EZTV646 != EzCAP EzTV646 http://www.reddit.com/r/RTLSDR/comments/s6ddo/rtlsdr_compatibility_list_v2_work_in_progress/ ezcap EzTV646 0BDA:2838 RTL2832U/FC0012 Some revisions may have the E4000* http://i.imgur.com/mFD1X.jpg (Generic) 0BDa:2838 RTL2832U/E4000* � And, in addition: http://sdr.osmocom.org/trac/wiki/rtl-sdr 0x0bda 0x2832 all of them Generic RTL2832U (e.g. hama nano)** 0x0bda 0x2838 E4000 ezcap USB 2.0 DVB-T/DAB/FM dongle � Maybe? https://sites.google.com/site/myrtlsdr/ That's it. Opening the device enclosure, I can read this on the PCB: EzTV668 1.0 and it looks identical to the picture posted there. Groovy! EzCap EZTV646 has got RTL2832U/FC0012. However rtl-sdr must be tweaked to force FC0012 tuner because it has the same PID as EZTV668 (PID: 0x2838) so running it whithout a tweak will select Elonics E4000 tuner. Works, not so good at filtering. � Conclusion: At least two devices share same vid/pid with different tuners - fc0012 vs e4000. How to resolve this from a drivers perspective in a proper way? This is not a big problem: the rtl2832 driver should read the tuner type from an internal register and load the proper module (or exit with an error message if the tuner is unsupported). Ack, thanks! Beside, there is GPL'ed 'e4k' tuner source code aka 'e4000 improved'*** (Elonics E4000) by Harald Welte http://cgit.osmocom.org/cgit/osmo-sdr/tree/firmware/src/tuner_e4k.c http://sdr.osmocom.org/trac/ http://sdr.osmocom.org/trac/wiki/rtl-sdr http://wiki.spench.net/wiki/RTL2832U*** Very nice. So we should ask Harald Welte if he is willing to have his driver merged in the kernel. Undoubtedly! Please ping Thomas and Antti, accordingly. regards, poma Regards, Gianluca regards, poma -- 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 -- 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: RTL28XX driver
I have been working on the driver over the past days and been making some progress. Right now I am stuck with a small problem that I have no idea how to deal with. It seems that the fc0012 tuner supports V-Band and U-Band. To switch between those modes a GPIO output value needs to be changed. In the original Realtek driver this is done at the beginning of the set_parameters callback. Is there a different callback that can be used for this or is it ok to write a RTL2832u register from the demodulator code? Regards Thomas 2012/4/12 Antti Palosaari cr...@iki.fi: On 12.04.2012 15:54, Thomas Mair wrote: It is not my driver ;) And at the beginning it looks quite scary but it may help together with the dump. You can find it here:https://github.com/tmair/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0/blob/master/RTL2832-2.2.2_kernel-3.0.0/tuner_fc2580.c 2012/4/12 Oliver Schinagloliver+l...@schinagl.nl: I accept the challenge :p but where is your fc2580 driver? And in that thought, where is antti's stub driver :) That might help me get started :) On 12-04-12 14:18, Thomas Mair wrote: Hi Oliver, the Realtek driver sources I have also contain a fc2580 driver. Maybe the source code will help you together with the usb sniff. 2012/4/12 Oliver Schinagloliver+l...@schinagl.nl: Would love to, even tried a bit, but don't really know how to start, what to use as a template. I think I can extract the i2c messages from the dreaded ugly af903 driver however, using src or usbsniff. On 11-04-12 23:57, Antti Palosaari wrote: On 12.04.2012 00:33, Oliver Schinagl wrote: On 04/11/12 21:12, Antti Palosaari wrote: I have some old stubbed drivers that just works for one frequency using combination of RTL2832U + FC2580. Also I have rather well commented USB sniff from that device. I can sent those if you wish. FC2580? Do you have anything for/from that driver? My USB stick as an AFA9035 based one, using that specific tuner. Nothing but stubbed driver that contains static register values taken from the sniff and it just tunes to one channel (IIRC 634 MHz / 8 MHz BW). Feel free to contribute new tuner driver in order to add support for your AF9035 device. Here are my sniffs and stubbed driver etc. what I found from the HD. Those well commented sniffs, both RTL2831U and RTL2832U, are surely most valuable material. http://palosaari.fi/linux/v4l-dvb/rtl283xu/ FC2580 can be found from both AF9035 and RTL2832U codes. Generally, as coding new demod driver for example, you want to use that kind of stubbed tuner driver for example: /* FC0011: 634 MHz / BW 8 MHz */ struct { u8 r[8]; int len; } regs[] = { {{ 0x07, 0x0f }, 2 }, {{ 0x08, 0x3e }, 2 }, {{ 0x0a, 0xb8 }, 2 }, {{ 0x0b, 0x80 }, 2 }, {{ 0x0d, 0x04 }, 2 }, {{ 0x00, 0x00, 0x05, 0x11, 0xf1, 0xc7, 0x0a, 0x30 }, 8 }, {{ 0x0e, 0x80 }, 2 }, {{ 0x0e, 0x00 }, 2 }, {{ 0x0e, 0x00 }, 2 }, {{ 0x0e }, 1 }, {{ 0x06, 0x30 }, 2 }, {{ 0x0d }, 1 }, {{ 0x0d, 0x14 }, 2 }, {{ 0x10, 0x0b }, 2 }, }; for (i = 0; i ARRAY_SIZE(regs); i++) { pr_debug(%s: i=%d len=%d data=%02x\n, __func__, i, regs[i].len, regs[i].r[0]); struct i2c_msg msg[1] = { { .addr = 0x60, .flags = 0, .len = regs[i].len, .buf = regs[i].r, } }; ret = i2c_transfer(state-i2c, msg, 1); if (ret != 1) pr_debug(%s: I2C write failed i=%d len=%d data=%02x\n, __func__, i, regs[i].len, regs[i].r[0]); } regards Antti -- http://palosaari.fi/ -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RTL28XX driver
I don't know what it really is either but the comments are the following. if (frequency 3) { printk( %s : Tuner :FC0012 V-band (GPIO6 high)\n, __FUNCTION__); } else { printk( %s : Tuner :FC0012 U-band (GPIO6 low)\n, __FUNCTION__); } I looked into both mechanisms but can't really decide which one would be the best one for this. What is the correct ioctl constant to listen for or do I define an own constant? And how is the ioctl command issued within the demod driver? Thomas 2012/4/18 Antti Palosaari cr...@iki.fi: On 18.04.2012 20:18, Thomas Mair wrote: I have been working on the driver over the past days and been making some progress. Right now I am stuck with a small problem that I have no idea how to deal with. It seems that the fc0012 tuner supports V-Band and U-Band. To switch between those modes a GPIO output value needs to be changed. In the original Realtek driver this is done at the beginning of the set_parameters callback. Is there a different callback that can be used for this or is it ok to write a RTL2832u register from the demodulator code? Aah, I suspect it is antenna switch or LNA GPIO. You don't say what is meaning of that GPIO... If it is FC0012 input, which I think it is not, then you should use FE callback (named as callback too) with DVB_FRONTEND_COMPONENT_TUNER param. But I suspect it is not issue. So lets introduce another solution. It is fe_ioctl_override. Use it. You will find good examples both cases using following GIT greps git grep fe_ioctl_override drivers/media git grep FRONTEND_COMPONENT Antti -- http://palosaari.fi/ -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RTL28XX driver
Hi Oliver, the Realtek driver sources I have also contain a fc2580 driver. Maybe the source code will help you together with the usb sniff. 2012/4/12 Oliver Schinagl oliver+l...@schinagl.nl: Would love to, even tried a bit, but don't really know how to start, what to use as a template. I think I can extract the i2c messages from the dreaded ugly af903 driver however, using src or usbsniff. On 11-04-12 23:57, Antti Palosaari wrote: On 12.04.2012 00:33, Oliver Schinagl wrote: On 04/11/12 21:12, Antti Palosaari wrote: I have some old stubbed drivers that just works for one frequency using combination of RTL2832U + FC2580. Also I have rather well commented USB sniff from that device. I can sent those if you wish. FC2580? Do you have anything for/from that driver? My USB stick as an AFA9035 based one, using that specific tuner. Nothing but stubbed driver that contains static register values taken from the sniff and it just tunes to one channel (IIRC 634 MHz / 8 MHz BW). Feel free to contribute new tuner driver in order to add support for your AF9035 device. -- 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: RTL28XX driver
It is not my driver ;) And at the beginning it looks quite scary but it may help together with the dump. You can find it here:https://github.com/tmair/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0/blob/master/RTL2832-2.2.2_kernel-3.0.0/tuner_fc2580.c 2012/4/12 Oliver Schinagl oliver+l...@schinagl.nl: I accept the challenge :p but where is your fc2580 driver? And in that thought, where is antti's stub driver :) That might help me get started :) On 12-04-12 14:18, Thomas Mair wrote: Hi Oliver, the Realtek driver sources I have also contain a fc2580 driver. Maybe the source code will help you together with the usb sniff. 2012/4/12 Oliver Schinagloliver+l...@schinagl.nl: Would love to, even tried a bit, but don't really know how to start, what to use as a template. I think I can extract the i2c messages from the dreaded ugly af903 driver however, using src or usbsniff. On 11-04-12 23:57, Antti Palosaari wrote: On 12.04.2012 00:33, Oliver Schinagl wrote: On 04/11/12 21:12, Antti Palosaari wrote: I have some old stubbed drivers that just works for one frequency using combination of RTL2832U + FC2580. Also I have rather well commented USB sniff from that device. I can sent those if you wish. FC2580? Do you have anything for/from that driver? My USB stick as an AFA9035 based one, using that specific tuner. Nothing but stubbed driver that contains static register values taken from the sniff and it just tunes to one channel (IIRC 634 MHz / 8 MHz BW). Feel free to contribute new tuner driver in order to add support for your AF9035 device. -- 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 -- 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: RTL28XX driver
Hi Gainluca, thanks for your information. I did get in touch with Realtek and they provided me with the datasheet for the RTL2832U. So what I will try to do is write a demodulator driver for the RTL2832 demod chip following the information of the datasheet and the Realtek driver. I will follow Antti's RTL2830 driver structure. For now there is only one question left regarding the testing of the drivers. What is the best way to test and debug the drivers. Sould I compile the 3.4 kernel and use it, or is it safer to set up a structure like the one I already have to test the driver with a stable kernel? Greetings Thomas 2012/4/7 Gianluca Gennari gennar...@gmail.com: Il 06/04/2012 11:11, Thomas Mair ha scritto: Hello everyone, i own a TerraTec Cinergy T Stick Black device, and was able to find a working driver for the device. It seems to be, that the driver was originally written by Realtek and has since been updated by different Developers to meet DVB API changes. I was wondering what would be the necessary steps to include the driver into the kernel sources? The one thing that needs to be solved before even thinking about the integration, is the licencing of the code. I did find it on two different locations, but without any licencing information. So probably Realtek should be contacted. I am willing to deal with that, but need furter information on under whitch lisence the code has to be relased. So far, I put up a Github repository for the driver, which enables me to compile the proper kernel modue at https://github.com/tmair/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0 The modificatioins to the driver where taken from openpli http://openpli.git.sourceforge.net/git/gitweb.cgi?p=openpli/openembedded;a=blob;f=recipes/linux/linux-etxx00/dvb-usb-rtl2832.patch;h=063114c8ce4a2dbcf8c8dde1b4ab4f8e329a2afa;hb=HEAD In the driver sources I stumbled accross many different devices containig the RTL28XX chipset, so I suppose the driver would enably quite many products to work. As I am relatively new to the developement of dvb drivers I appreciate any help in stabilizing the driver and proper integration into the dvb API. Hi Thomas, the Realtek driver you mention is the full version, which supports 3 demodulators (2832=DVB-T, 2836=DTMB, 2840=DVB-C) and 10 different tuners. There is also a simplified version of the driver which supports only DVB-T and 4 tuners: this is probably a better starting base for your project. You can find the simplified driver here: https://github.com/ambrosa/DVB-Realtek-RTL2832U-2.2.2-4_tuner My friend Ambrosa got it directly from Realtek. You can mail the 2 driver authors directly: author: Dean Chung deanch...@realtek.com author: Chialing Lu chial...@realtek.com as they have been quite collaborative last year. I think they can also provide you some information about the code license. The rtl2832 devices I've seen so far use either the Fitipower fc0012 or the Elonics E4000 tuner. For the first one there is a driver from Hans-Frieder Vogt that is not yet included in the development tree, but it has been posted recently on this list. If your stick uses this tuner, then the problem reduces to write the demodulator driver (as Antti already explained). Best regards, Gianluca -- 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
RTL28XX driver
Hello everyone, i own a TerraTec Cinergy T Stick Black device, and was able to find a working driver for the device. It seems to be, that the driver was originally written by Realtek and has since been updated by different Developers to meet DVB API changes. I was wondering what would be the necessary steps to include the driver into the kernel sources? The one thing that needs to be solved before even thinking about the integration, is the licencing of the code. I did find it on two different locations, but without any licencing information. So probably Realtek should be contacted. I am willing to deal with that, but need furter information on under whitch lisence the code has to be relased. So far, I put up a Github repository for the driver, which enables me to compile the proper kernel modue at https://github.com/tmair/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0 The modificatioins to the driver where taken from openpli http://openpli.git.sourceforge.net/git/gitweb.cgi?p=openpli/openembedded;a=blob;f=recipes/linux/linux-etxx00/dvb-usb-rtl2832.patch;h=063114c8ce4a2dbcf8c8dde1b4ab4f8e329a2afa;hb=HEAD In the driver sources I stumbled accross many different devices containig the RTL28XX chipset, so I suppose the driver would enably quite many products to work. As I am relatively new to the developement of dvb drivers I appreciate any help in stabilizing the driver and proper integration into the dvb API. Greetings Thomas -- 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