[linux-dvb] [PATCH] Some additions to the tusb_dec driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex

Are you still maintaining the ttusb_dec driver?
If yes, I would just throw a couple of patches at you with the hope that you could commit
them to cvs ;)
Otherwise I would need somebody else here on the list (with cvs access) to do that.

The first patch contains just some small minor fixes.

The only real "new" thing is the second patch, which adds the readout of the signal
status. And as the frontend thread now gets the tuning status we need it to stop trying to
do zigzag scanning, which a) doesn't make sense for dvbt(as I am being told) and b)
sometimes confuses the box so that it doesn't lock successfully.

The last patch changes the behaviour if a filter is requested that the driver doesn't
support. It now returns an error back to the applications instead of silently accepting it
while doing nothing.
This is usefull for example for the mythtv people who needs are way to determine whether
the driver supports the DMX_PES_OTHER filter or not.

Thanks
Peter
-------------- next part --------------
Some minor fixes:
Add new model id for the DEC3000-S as reported on the mailing-list:
http://www.linuxtv.org/pipermail/linux-dvb/2005-December/006699.html

Add symbolrates to the dvbs frontend description. The values are just guessed but they are reported to work,
so unless somebody comes up with something better it's better than nothing.

Fix capability flags in dvbs frontend describtion:
Seems to be a copy&paste from the dvbt frontend as it doesn't make sense for dvbs the way it is  ;)
So turn it into something sensible.

Remove void casts.

Signed-off-by: Peter Beutner <p.beutner@xxxxxxx>

Index: linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
===================================================================
--- linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c.orig
+++ linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -369,7 +369,7 @@ static int ttusb_dec_get_stb_state (stru
 
 static int ttusb_dec_audio_pes2ts_cb(void *priv, unsigned char *data)
 {
-	struct ttusb_dec *dec = (struct ttusb_dec *)priv;
+	struct ttusb_dec *dec = priv;
 
 	dec->audio_filter->feed->cb.ts(data, 188, NULL, 0,
 				       &dec->audio_filter->feed->feed.ts,
@@ -380,7 +380,7 @@ static int ttusb_dec_audio_pes2ts_cb(voi
 
 static int ttusb_dec_video_pes2ts_cb(void *priv, unsigned char *data)
 {
-	struct ttusb_dec *dec = (struct ttusb_dec *)priv;
+	struct ttusb_dec *dec = priv;
 
 	dec->video_filter->feed->cb.ts(data, 188, NULL, 0,
 				       &dec->video_filter->feed->feed.ts,
@@ -1394,6 +1394,7 @@ static int ttusb_dec_init_stb(struct ttu
 			/* We can't trust the USB IDs that some firmwares
 			   give the box */
 			switch (model) {
+			case 0x00070001:
 			case 0x00070008:
 			case 0x0007000c:
 				ttusb_dec_set_model(dec, TTUSB_DEC3000S);
@@ -1587,7 +1588,7 @@ static int fe_send_command(struct dvb_fr
 			   int param_length, const u8 params[],
 			   int *result_length, u8 cmd_result[])
 {
-	struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv;
+	struct ttusb_dec* dec = fe->dvb->priv;
 	return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);
 }
 
Index: linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
===================================================================
--- linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c.orig
+++ linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
@@ -223,11 +223,11 @@ static struct dvb_frontend_ops ttusbdecf
 		.frequency_min		= 950000,
 		.frequency_max		= 2150000,
 		.frequency_stepsize	= 125,
+		.symbol_rate_min        = 1000000,  /* guessed */
+		.symbol_rate_max        = 45000000, /* guessed */
 		.caps =	FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
 			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
-			FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-			FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
-			FE_CAN_HIERARCHY_AUTO,
+			FE_CAN_QPSK
 	},
 
 	.release = ttusbdecfe_release,
-------------- next part --------------
Implement the read out of the signal status(locked/not locked)
implement get_tune_setting for the dvbt frontend to:
- disable zigzag scanning as it makes no sense for DVB-T.
- set sensible min_delay value as the hardware sometime needs some time tune.

Signed-off-by: Peter Beutner <p.beutner@xxxxxxx>
Index: linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
===================================================================
--- linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c.orig
+++ linux/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
@@ -42,8 +42,39 @@ struct ttusbdecfe_state {
 
 static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status)
 {
-	*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
-		  FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
+	struct ttusbdecfe_state* state = fe->demodulator_priv;
+	u8 b[] = { 0x00, 0x00, 0x00, 0x00,
+		   0x00, 0x00, 0x00, 0x00 };
+	u8 result[4];
+	int len, ret;
+
+	*status=0;
+
+	ret=state->config->send_command(fe, 0x73, sizeof(b), b, &len, result);
+	if(ret)
+		return ret;
+
+	if(len != 4) {
+		printk(KERN_ERR "%s: unexpected reply\n", __FUNCTION__);
+		return -EIO;
+	}
+
+	switch(result[3]) {
+		case 1:  /* not tuned yet */
+		case 2:  /* no signal/no lock*/
+			break;
+		case 3:	 /* signal found and locked*/
+			*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
+			FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
+			break;
+		case 4:
+			*status = FE_TIMEDOUT;
+			break;
+		default:
+			pr_info("%s: returned unknown value: %d\n",
+				__FUNCTION__, result[3]);
+			return -EIO;
+	}
 
 	return 0;
 }
@@ -64,6 +95,16 @@ static int ttusbdecfe_dvbt_set_frontend(
 	return 0;
 }
 
+static int ttusbdecfe_dvbt_get_tune_settings(struct dvb_frontend* fe,
+					struct dvb_frontend_tune_settings* fesettings)
+{
+		fesettings->min_delay_ms = 1500;
+		/* Drift compensation makes no sense for DVB-T */
+		fesettings->step_size = 0;
+		fesettings->max_drift = 0;
+		return 0;
+}
+
 static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
 {
 	struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
@@ -212,6 +253,8 @@ static struct dvb_frontend_ops ttusbdecf
 
 	.set_frontend = ttusbdecfe_dvbt_set_frontend,
 
+	.get_tune_settings = ttusbdecfe_dvbt_get_tune_settings,
+
 	.read_status = ttusbdecfe_read_status,
 };
 
-------------- next part --------------
Return an error for requested filter types the driver can't handle.
Don't pretend to do something while actually doing nothing.We know that the driver can't handle these filters,
so be nice and report back to the user that we don't support it.

Signed-off-by: Peter Beutner <p.beutner@xxxxxxx>

Index: linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
===================================================================
--- linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c.orig
+++ linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -965,8 +965,8 @@ static int ttusb_dec_start_ts_feed(struc
 
 	case DMX_TS_PES_TELETEXT:
 		dec->pid[DMX_PES_TELETEXT] = dvbdmxfeed->pid;
-		dprintk("  pes_type: DMX_TS_PES_TELETEXT\n");
-		break;
+		dprintk("  pes_type: DMX_TS_PES_TELETEXT(not supported)\n");
+		return -ENOSYS;
 
 	case DMX_TS_PES_PCR:
 		dprintk("  pes_type: DMX_TS_PES_PCR\n");
@@ -975,8 +975,8 @@ static int ttusb_dec_start_ts_feed(struc
 		break;
 
 	case DMX_TS_PES_OTHER:
-		dprintk("  pes_type: DMX_TS_PES_OTHER\n");
-		break;
+		dprintk("  pes_type: DMX_TS_PES_OTHER(not supported)\n");
+		return -ENOSYS;
 
 	default:
 		dprintk("  pes_type: unknown (%d)\n", dvbdmxfeed->pes_type);

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux