public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* Add tuner_type to zl10353 config and use it for reporting signal directly from tuner.
@ 2011-12-21 21:07 Miroslav Slugeň
  2011-12-21 21:29 ` Devin Heitmueller
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Miroslav Slugeň @ 2011-12-21 21:07 UTC (permalink / raw)
  To: linux-media

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

XC4000 based cards are not using AGC control in normal way, so it is
not possible to get signal level from AGC registres of zl10353
demodulator, instead of this i send previous patch to implement signal
level directly in xc4000 tuner and now sending patch for zl10353 to
implement this future for digital mode. Signal reporting is very
accurate and was well tested on 3 different Leadtek XC4000 cards.

[-- Attachment #2: Add-tuner-type-for-zl10353-demodulator.patch --]
[-- Type: text/x-patch, Size: 4340 bytes --]

From 76af396e53c1dcf499f5c016ab8ddd95a4856992 Mon Sep 17 00:00:00 2001
From: Miroslav <thunder.m@email.cz>
Date: Wed, 21 Dec 2011 21:55:58 +0100
Subject: [PATCH] This patch adds tuner_type config value for zl10353 demodulator and
 fill it for Leadtek based xc4000 tuners. Extra value should be used
 in future for tuner specific functions in zl10353 demodulator, first
 usage is now for directly reading signal strength from xc4000 tuner
 which is very accurate instead of reading signal from AGC registers.

---
 drivers/media/dvb/frontends/zl10353.c     |   12 +++++++++---
 drivers/media/dvb/frontends/zl10353.h     |    3 +++
 drivers/media/video/cx23885/cx23885-dvb.c |   10 +++++++++-
 drivers/media/video/cx88/cx88-dvb.c       |    9 ++++++++-
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index adbbf6d..7ea3a2e 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -26,6 +26,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <asm/div64.h>
+#include <media/tuner.h>
 
 #include "dvb_frontend.h"
 #include "zl10353_priv.h"
@@ -521,10 +522,15 @@ static int zl10353_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
 	struct zl10353_state *state = fe->demodulator_priv;
 
-	u16 signal = zl10353_read_register(state, AGC_GAIN_1) << 10 |
-		     zl10353_read_register(state, AGC_GAIN_0) << 2 | 3;
+	/* for XC4000 we can read exact signal value directly */
+	if (state->config.tuner_type == TUNER_XC4000) {
+		fe->ops.tuner_ops.get_rf_strength(fe, strength);
+	} else {
+		u16 signal = zl10353_read_register(state, AGC_GAIN_1) << 10 |
+			     zl10353_read_register(state, AGC_GAIN_0) << 2 | 3;
 
-	*strength = ~signal;
+		*strength = ~signal;
+	}
 
 	return 0;
 }
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 6e3ca9e..64ecbae 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -45,6 +45,9 @@ struct zl10353_config
 	/* clock control registers (0x51-0x54) */
 	u8 clock_ctl_1;  /* default: 0x46 */
 	u8 pll_0;        /* default: 0x15 */
+
+	/* for tuner specific functions */
+	u8 tuner_type;
 };
 
 #if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE))
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index f0482b2..98015fe 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -408,6 +408,14 @@ static struct zl10353_config dvico_fusionhdtv_xc3028 = {
 	.disable_i2c_gate_ctrl = 1,
 };
 
+static struct zl10353_config leadtek_xc4000_config = {
+	.demod_address = 0x0f,
+	.if2           = 45600,
+	.no_tuner      = 1,
+	.disable_i2c_gate_ctrl = 1,
+	.tuner_type    = TUNER_XC4000,
+};
+
 static struct stv0900_reg stv0900_ts_regs[] = {
 	{ R0900_TSGENERAL, 0x00 },
 	{ R0900_P1_TSSPEED, 0x40 },
@@ -926,7 +934,7 @@ static int dvb_register(struct cx23885_tsport *port)
 		i2c_bus = &dev->i2c_bus[0];
 
 		fe0->dvb.frontend = dvb_attach(zl10353_attach,
-					       &dvico_fusionhdtv_xc3028,
+					       &leadtek_xc4000_config,
 					       &i2c_bus->i2c_adap);
 		if (fe0->dvb.frontend != NULL) {
 			struct dvb_frontend	*fe;
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 592f3aa..a62ca76 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -540,6 +540,13 @@ static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
 	.if2           = 45600,
 };
 
+static const struct zl10353_config leadtek_xc4000_config = {
+	.demod_address = (0x1e >> 1),
+	.no_tuner      = 1,
+	.if2           = 45600,
+	.tuner_type    = TUNER_XC4000,
+};
+
 static const struct zl10353_config cx88_geniatech_x8000_mt = {
 	.demod_address = (0x1e >> 1),
 	.no_tuner = 1,
@@ -1342,7 +1349,7 @@ static int dvb_register(struct cx8802_dev *dev)
 	case CX88_BOARD_WINFAST_DTV1800H_XC4000:
 	case CX88_BOARD_WINFAST_DTV2000H_PLUS:
 		fe0->dvb.frontend = dvb_attach(zl10353_attach,
-					       &cx88_pinnacle_hybrid_pctv,
+					       &leadtek_xc4000_config,
 					       &core->i2c_adap);
 		if (fe0->dvb.frontend) {
 			struct xc4000_config cfg = {
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-23  8:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 21:07 Add tuner_type to zl10353 config and use it for reporting signal directly from tuner Miroslav Slugeň
2011-12-21 21:29 ` Devin Heitmueller
2011-12-21 23:50   ` Miroslav Slugeň
2011-12-21 23:55     ` Miroslav Slugeň
2011-12-22 16:58 ` Antti Palosaari
2011-12-22 23:45 ` Miroslav Slugeň
2011-12-23  8:14   ` Antti Palosaari
2011-12-23  8:19     ` Antti Palosaari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox