All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@casper.infradead.org
Cc: Doron Cohen <doronc@siano-ms.com>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH 36/46] [media] siano: Only feed DVB data when there's a feed
Date: Tue, 19 Mar 2013 13:49:25 -0300	[thread overview]
Message-ID: <1363711775-2120-37-git-send-email-mchehab@redhat.com> (raw)
In-Reply-To: <1363711775-2120-1-git-send-email-mchehab@redhat.com>

Right now, the driver sends DVB data even before tunning.

It was noticed that this may lead into some mistakes at DVB
decode, as the PIDs from wrong channels may be associated with
another frequency, as they may already be inside the PID buffers.

So, prevent it by not feeding DVB demux with data while there's no
feed or while the device is not tuned.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/common/siano/smsdvb-main.c | 18 +++++++++++++++---
 drivers/media/common/siano/smsdvb.h      |  3 +++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index b146064..114fe57 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -511,8 +511,13 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 
 	switch (phdr->msgType) {
 	case MSG_SMS_DVBT_BDA_DATA:
-		dvb_dmx_swfilter(&client->demux, p,
-				 cb->size - sizeof(struct SmsMsgHdr_ST));
+		/*
+		 * Only feed data to dvb demux if are there any feed listening
+		 * to it and if the device has tuned
+		 */
+		if (client->feed_users && client->has_tuned)
+			dvb_dmx_swfilter(&client->demux, p,
+					 cb->size - sizeof(struct SmsMsgHdr_ST));
 		break;
 
 	case MSG_SMS_RF_TUNE_RES:
@@ -578,9 +583,10 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_OK);
 			else
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_ERR);
+			client->has_tuned = true;
 		} else {
 			smsdvb_stats_not_ready(fe);
-
+			client->has_tuned = false;
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK);
 		}
 		complete(&client->stats_done);
@@ -622,6 +628,8 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
 	sms_debug("add pid %d(%x)",
 		  feed->pid, feed->pid);
 
+	client->feed_users++;
+
 	PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
 	PidMsg.xMsgHeader.msgDstId = HIF_TASK;
 	PidMsg.xMsgHeader.msgFlags = 0;
@@ -642,6 +650,8 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
 	sms_debug("remove pid %d(%x)",
 		  feed->pid, feed->pid);
 
+	client->feed_users--;
+
 	PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
 	PidMsg.xMsgHeader.msgDstId = HIF_TASK;
 	PidMsg.xMsgHeader.msgFlags = 0;
@@ -962,6 +972,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
 	c->strength.stat[0].uvalue = 0;
 	c->cnr.stat[0].uvalue = 0;
 
+	client->has_tuned = false;
+
 	switch (smscore_get_device_mode(coredev)) {
 	case DEVICE_MODE_DVBT:
 	case DEVICE_MODE_DVBT_BDA:
diff --git a/drivers/media/common/siano/smsdvb.h b/drivers/media/common/siano/smsdvb.h
index 3422069..63cdd75 100644
--- a/drivers/media/common/siano/smsdvb.h
+++ b/drivers/media/common/siano/smsdvb.h
@@ -54,6 +54,9 @@ struct smsdvb_client_t {
 
 	unsigned long		get_stats_jiffies;
 
+	int			feed_users;
+	bool			has_tuned;
+
 	/* Stats debugfs data */
 	struct dentry		*debugfs;
 
-- 
1.8.1.4


  parent reply	other threads:[~2013-03-19 16:50 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19 16:48 [PATCH 00/46] Add sms2270 support to siano driver Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 01/46] [media] siano: Change GPIO voltage setting names Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 02/46] [media] siano: Add the new voltage definitions for GPIO Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 03/46] [media] siano: remove a duplicated structure definition Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 04/46] [media] siano: update message macros Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 05/46] [media] siano: better debug send/receive messages Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 06/46] [media] siano: add the remaining new defines from new driver Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 07/46] [media] siano: Properly initialize board information Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 08/46] [media] siano: add additional attributes to cards entries Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 09/46] [media] siano: use USB endpoint descriptors for in/out endp Mauro Carvalho Chehab
2013-03-19 16:48 ` [PATCH 10/46] [media] siano: store firmware version Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 11/46] [media] siano: make load firmware logic to work with newer firmwares Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 12/46] [media] siano: report the choosed firmware in debug Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 13/46] [media] siano: fix the debug message Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 14/46] [media] siano: always load smsdvb Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 15/46] [media] siano: cleanups at smscoreapi.c Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 16/46] [media] siano: add some new messages to the smscoreapi Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 17/46] [media] siano: use a separate completion for stats Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 18/46] [media] siano: add support for ISDB-T full-seg Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 19/46] [media] siano: add support for LNA on ISDB-T Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 20/46] [media] siano: use the newer stats message for recent firmwares Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 21/46] [media] siano: add new devices to the Siano Driver Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 22/46] [media] siano: Configure board's mtu and xtal Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 23/46] [media] siano: call MSG_SMS_INIT_DEVICE_REQ Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 24/46] [media] siano: simplify message endianness logic Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 25/46] [media] siano: split get_frontend into per-std functions Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 26/46] [media] siano: split debug logic from the status update routine Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 27/46] [media] siano: Convert it to report DVBv5 stats Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 28/46] [media] siano: fix start of statistics Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 29/46] [media] siano: allow showing the complete statistics via debugfs Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 30/46] [media] siano: split debugfs code into a separate file Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 31/46] [media] siano: add two missing fields to ISDB-T stats debugfs Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 32/46] [media] siano: don't request statistics too fast Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 33/46] [media] siano: fix signal strength and CNR stats measurements Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 34/46] [media] siano: fix PER/BER report on DVBv5 Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 35/46] [media] siano: Fix bandwidth report Mauro Carvalho Chehab
2013-03-19 16:49 ` Mauro Carvalho Chehab [this message]
2013-03-19 16:49 ` [PATCH 37/46] [media] siano: fix status report with old firmware and ISDB-T Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 38/46] [media] siano: add support for .poll on debugfs Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 39/46] [media] siano: simplify firmware lookup logic Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 40/46] [media] siano: honour per-card default mode Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 41/46] [media] siano: remove the bogus firmware lookup code Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 42/46] [media] siano: reorder smscore_get_fw_filename() function Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 43/46] [media] siano: add a MAINTAINERS entry for it Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 44/46] [media] siano: remove a bogus printk line Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 45/46] [media] siano: remove doubled new line Mauro Carvalho Chehab
2013-03-19 16:49 ` [PATCH 46/46] [media] siano: Remove bogus complain about MSG_SMS_DVBT_BDA_DATA Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363711775-2120-37-git-send-email-mchehab@redhat.com \
    --to=mchehab@redhat.com \
    --cc=doronc@siano-ms.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.