linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@casper.infradead.org
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH RFCv10 03/15] dvb: the core logic to handle the DVBv5 QoS properties
Date: Tue, 15 Jan 2013 00:30:49 -0200	[thread overview]
Message-ID: <1358217061-14982-4-git-send-email-mchehab@redhat.com> (raw)
In-Reply-To: <1358217061-14982-1-git-send-email-mchehab@redhat.com>

Add the logic to poll, reset counters and report the QoS stats
to the end user.

The idea is that the core will periodically poll the frontend for
the stats. The frontend may return -EBUSY, if the previous collect
didn't finish, or it may fill the cached data.

The value returned to the end user is always the cached data.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb-core/dvb_frontend.c | 53 +++++++++++++++++++++++++++++++++++
 drivers/media/dvb-core/dvb_frontend.h | 11 ++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index dd35fa9..e48e46fb 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1053,6 +1053,15 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
 	_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_B, 0, 0),
 	_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_C, 0, 0),
 	_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_D, 0, 0),
+
+	/* Statistics API */
+	_DTV_CMD(DTV_QOS_ENUM, 0, 0),
+	_DTV_CMD(DTV_QOS_SIGNAL_STRENGTH, 0, 0),
+	_DTV_CMD(DTV_QOS_CNR, 0, 0),
+	_DTV_CMD(DTV_QOS_BIT_ERROR_COUNT, 0, 0),
+	_DTV_CMD(DTV_QOS_TOTAL_BITS_COUNT, 0, 0),
+	_DTV_CMD(DTV_QOS_ERROR_BLOCK_COUNT, 0, 0),
+	_DTV_CMD(DTV_QOS_TOTAL_BLOCKS_COUNT, 0, 0),
 };
 
 static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp)
@@ -1443,6 +1452,25 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
 		tvp->u.data = c->lna;
 		break;
 
+	/* Fill quality measures */
+	case DTV_QOS_SIGNAL_STRENGTH:
+		tvp->u.st = c->strength;
+		break;
+	case DTV_QOS_CNR:
+		tvp->u.st = c->cnr;
+		break;
+	case DTV_QOS_BIT_ERROR_COUNT:
+		tvp->u.st = c->bit_error;
+		break;
+	case DTV_QOS_TOTAL_BITS_COUNT:
+		tvp->u.st = c->bit_count;
+		break;
+	case DTV_QOS_ERROR_BLOCK_COUNT:
+		tvp->u.st = c->block_error;
+		break;
+	case DTV_QOS_TOTAL_BLOCKS_COUNT:
+		tvp->u.st = c->block_count;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1646,6 +1674,26 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
 	return 0;
 }
 
+static int reset_qos_counters(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+	/* Reset QoS cache */
+
+	memset (&c->strength, 0, sizeof(c->strength));
+	memset (&c->cnr, 0, sizeof(c->cnr));
+	memset (&c->bit_error, 0, sizeof(c->bit_error));
+	memset (&c->bit_count, 0, sizeof(c->bit_count));
+	memset (&c->block_error, 0, sizeof(c->block_error));
+	memset (&c->block_count, 0, sizeof(c->block_count));
+
+	/* Call frontend reset counter method, if available */
+	if (fe->ops.reset_qos_counters)
+		return fe->ops.reset_qos_counters(fe);
+
+	return 0;
+}
+
 static int dtv_property_process_set(struct dvb_frontend *fe,
 				    struct dtv_property *tvp,
 				    struct file *file)
@@ -1705,6 +1753,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
 		break;
 	case DTV_DELIVERY_SYSTEM:
 		r = set_delivery_system(fe, tvp->u.data);
+		if (r >= 0)
+			reset_qos_counters(fe);
 		break;
 	case DTV_VOLTAGE:
 		c->voltage = tvp->u.data;
@@ -2305,6 +2355,9 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
 		if (err)
 			break;
 		err = dtv_set_frontend(fe);
+		if (err >= 0)
+			reset_qos_counters(fe);
+
 		break;
 	case FE_GET_EVENT:
 		err = dvb_frontend_get_event (fe, parg, file->f_flags);
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 97112cd..b7aa815 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -315,6 +315,9 @@ struct dvb_frontend_ops {
 
 	int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
 	int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
+
+	/* QoS statistics callbacks */
+	int (*reset_qos_counters)(struct dvb_frontend *fe);
 };
 
 #ifdef __DVB_CORE__
@@ -393,6 +396,14 @@ struct dtv_frontend_properties {
 	u8			atscmh_sccc_code_mode_d;
 
 	u32			lna;
+
+	/* QoS statistics data */
+	struct dtv_fe_stats 	strength;
+	struct dtv_fe_stats	cnr;
+	struct dtv_fe_stats	bit_error;
+	struct dtv_fe_stats	bit_count;
+	struct dtv_fe_stats	block_error;
+	struct dtv_fe_stats	block_count;
 };
 
 struct dvb_frontend {
-- 
1.7.11.7


  parent reply	other threads:[~2013-01-15  2:31 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15  2:30 [PATCH RFCv10 00/15] DVB QoS statistics API Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 01/15] mb86a20s: improve error handling at get_frontend Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 02/15] dvb: Add DVBv5 stats properties for Quality of Service Mauro Carvalho Chehab
2013-01-15  2:30 ` Mauro Carvalho Chehab [this message]
2013-01-15  2:30 ` [PATCH RFCv10 04/15] mb86a20s: Update QoS statistics at FE read_status Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 05/15] mb86a20s: functions reorder Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 06/15] mb86a20s: Fix i2c gate on error Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 07/15] mb86a20s: improve debug for RF level Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 08/15] mb86a20s: fix interleaving and FEC retrival Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 09/15] mb86a20s: convert it to use dev_info/dev_err/dev_dbg Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 10/15] mb86a20s: -EBUSY is expected when getting QoS measures Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 11/15] mb86a20s: make AGC work better Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 12/15] mb86a20s: Some improvements for BER measurement Mauro Carvalho Chehab
2013-01-15  2:30 ` [PATCH RFCv10 13/15] mb86a20s: improve bit error count for BER Mauro Carvalho Chehab
2013-01-15  2:31 ` [PATCH RFCv10 14/15] dvb: increase API version Mauro Carvalho Chehab
2013-01-15  8:20 ` [PATCH RFCv10 00/15] DVB QoS statistics API Johannes Stezenbach
2013-01-15  8:55   ` Antti Palosaari
2013-01-15 12:23     ` Mauro Carvalho Chehab
2013-01-15  9:34 ` Antti Palosaari
2013-01-15 13:10   ` Mauro Carvalho Chehab
2013-01-15 14:49     ` Antti Palosaari
2013-01-15 15:21       ` Mauro Carvalho Chehab
2013-01-15 15:47         ` Devin Heitmueller
2013-01-15 17:02           ` Mauro Carvalho Chehab
2013-01-15 15:26       ` Antti Palosaari
2013-01-15 17:12         ` Mauro Carvalho Chehab
2013-01-15 20:37           ` Antti Palosaari
2013-01-16  4:26             ` Manu Abraham
2013-01-16 11:41               ` Luca Olivetti
2013-01-16 13:56               ` Mauro Carvalho Chehab
2013-01-16 15:19                 ` Manu Abraham
2013-01-16 17:21                   ` Mauro Carvalho Chehab
2013-01-16 18:26                     ` Manu Abraham
2013-01-16 19:22                       ` Mauro Carvalho Chehab
2013-01-16 21:40                         ` Manu Abraham
2013-01-16 19:29                       ` Simon Farnsworth
2013-01-16 21:37                         ` Manu Abraham
2013-01-16 22:11                           ` Mauro Carvalho Chehab
2013-01-17  3:26                             ` Manu Abraham
2013-01-16 22:01                         ` Mauro Carvalho Chehab
2013-01-17  3:40                           ` Manu Abraham
2013-01-17  9:33                             ` Antti Palosaari
2013-01-17 16:50                               ` Mauro Carvalho Chehab
2013-01-17 17:15                                 ` Antti Palosaari
2013-01-17 18:11                                   ` Mauro Carvalho Chehab
2013-01-17 18:27                                     ` Antti Palosaari
2013-01-17 18:37                                       ` Manu Abraham
2013-01-17 18:50                                         ` Mauro Carvalho Chehab
2013-01-17 19:11                                           ` Antti Palosaari
2013-01-17 19:35                                             ` Mauro Carvalho Chehab
2013-01-17 21:29                                             ` Manu Abraham
2013-01-17 22:22                                               ` Antti Palosaari
2013-01-17 22:46                                                 ` Mauro Carvalho Chehab
2013-01-22 12:16                                             ` Mauro Carvalho Chehab
2013-01-23 15:08                                               ` Antti Palosaari
2013-01-23 15:12                                                 ` Antti Palosaari
2013-01-23 18:18                                                 ` Mauro Carvalho Chehab
2013-01-23 18:57                                                   ` Mauro Carvalho Chehab
2013-01-23 19:55                                                     ` Antti Palosaari
2013-01-23 21:00                                                       ` Mauro Carvalho Chehab
2013-01-23 22:02                                                         ` Mauro Carvalho Chehab
2013-01-17 17:16                               ` Manu Abraham
2013-01-17 17:22                                 ` Antti Palosaari
2013-01-17 17:37                                   ` [linux-media] " Klaus Schmidinger
2013-01-17 17:39                                     ` [linux-media] " Klaus Schmidinger
2013-01-17 18:36                                   ` Mauro Carvalho Chehab
2013-01-19 12:04                           ` Mauro Carvalho Chehab
2013-01-16 13:24             ` Mauro Carvalho Chehab
2013-01-15 10:38 ` Manu Abraham
2013-01-15 15:23   ` 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=1358217061-14982-4-git-send-email-mchehab@redhat.com \
    --to=mchehab@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).