Commit ff702eb8 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] siano: split debug logic from the status update routine

It is confusing to merge both status updates with debug stuff.
Also, it is a better idea to move those status updates to
debugfs, instead of doing a large amount of printk's like that.
So, break them into a separate block of routines.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent eab0fa0f
......@@ -61,63 +61,11 @@ static int sms_dbg;
module_param_named(debug, sms_dbg, int, 0644);
MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
/* Events that may come from DVB v3 adapter */
static void sms_board_dvb3_event(struct smsdvb_client_t *client,
enum SMS_DVB3_EVENTS event) {
struct smscore_device_t *coredev = client->coredev;
switch (event) {
case DVB3_EVENT_INIT:
sms_debug("DVB3_EVENT_INIT");
sms_board_event(coredev, BOARD_EVENT_BIND);
break;
case DVB3_EVENT_SLEEP:
sms_debug("DVB3_EVENT_SLEEP");
sms_board_event(coredev, BOARD_EVENT_POWER_SUSPEND);
break;
case DVB3_EVENT_HOTPLUG:
sms_debug("DVB3_EVENT_HOTPLUG");
sms_board_event(coredev, BOARD_EVENT_POWER_INIT);
break;
case DVB3_EVENT_FE_LOCK:
if (client->event_fe_state != DVB3_EVENT_FE_LOCK) {
client->event_fe_state = DVB3_EVENT_FE_LOCK;
sms_debug("DVB3_EVENT_FE_LOCK");
sms_board_event(coredev, BOARD_EVENT_FE_LOCK);
}
break;
case DVB3_EVENT_FE_UNLOCK:
if (client->event_fe_state != DVB3_EVENT_FE_UNLOCK) {
client->event_fe_state = DVB3_EVENT_FE_UNLOCK;
sms_debug("DVB3_EVENT_FE_UNLOCK");
sms_board_event(coredev, BOARD_EVENT_FE_UNLOCK);
}
break;
case DVB3_EVENT_UNC_OK:
if (client->event_unc_state != DVB3_EVENT_UNC_OK) {
client->event_unc_state = DVB3_EVENT_UNC_OK;
sms_debug("DVB3_EVENT_UNC_OK");
sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_OK);
}
break;
case DVB3_EVENT_UNC_ERR:
if (client->event_unc_state != DVB3_EVENT_UNC_ERR) {
client->event_unc_state = DVB3_EVENT_UNC_ERR;
sms_debug("DVB3_EVENT_UNC_ERR");
sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_ERRORS);
}
break;
default:
sms_err("Unknown dvb3 api event");
break;
}
}
static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ST *p)
static void smsdvb_print_dvb_stats(struct SMSHOSTLIB_STATISTICS_ST *p)
{
if (sms_dbg & 2) {
if (!(sms_dbg & 2))
return;
printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
......@@ -159,31 +107,15 @@ static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReception
printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP);
printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP);
printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived);
}
/* update reception data */
pReceptionData->IsRfLocked = p->IsRfLocked;
pReceptionData->IsDemodLocked = p->IsDemodLocked;
pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
pReceptionData->ModemState = p->ModemState;
pReceptionData->SNR = p->SNR;
pReceptionData->BER = p->BER;
pReceptionData->BERErrorCount = p->BERErrorCount;
pReceptionData->BERBitCount = p->BERBitCount;
pReceptionData->RSSI = p->RSSI;
CORRECT_STAT_RSSI(*pReceptionData);
pReceptionData->InBandPwr = p->InBandPwr;
pReceptionData->CarrierOffset = p->CarrierOffset;
pReceptionData->ErrorTSPackets = p->ErrorTSPackets;
pReceptionData->TotalTSPackets = p->TotalTSPackets;
};
}
static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
static void smsdvb_print_isdb_stats(struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
{
int i;
if (sms_dbg & 2) {
if (!(sms_dbg & 2))
return;
printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
......@@ -215,43 +147,16 @@ static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pRecepti
printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
}
}
/* update reception data */
pReceptionData->IsRfLocked = p->IsRfLocked;
pReceptionData->IsDemodLocked = p->IsDemodLocked;
pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
pReceptionData->ModemState = p->ModemState;
pReceptionData->SNR = p->SNR;
pReceptionData->BER = p->LayerInfo[0].BER;
pReceptionData->BERErrorCount = p->LayerInfo[0].BERErrorCount;
pReceptionData->BERBitCount = p->LayerInfo[0].BERBitCount;
pReceptionData->RSSI = p->RSSI;
CORRECT_STAT_RSSI(*pReceptionData);
pReceptionData->InBandPwr = p->InBandPwr;
pReceptionData->CarrierOffset = p->CarrierOffset;
pReceptionData->ErrorTSPackets = p->LayerInfo[0].ErrorTSPackets;
pReceptionData->TotalTSPackets = p->LayerInfo[0].TotalTSPackets;
pReceptionData->MFER = 0;
/* TS PER */
if ((p->LayerInfo[0].TotalTSPackets +
p->LayerInfo[0].ErrorTSPackets) > 0) {
pReceptionData->TS_PER = (p->LayerInfo[0].ErrorTSPackets
* 100) / (p->LayerInfo[0].TotalTSPackets
+ p->LayerInfo[0].ErrorTSPackets);
} else {
pReceptionData->TS_PER = 0;
}
}
static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
static void
smsdvb_print_isdb_stats_ex(struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
{
int i;
if (sms_dbg & 2) {
if (!(sms_dbg & 2))
return;
printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
......@@ -269,6 +174,7 @@ static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pRece
printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
printk(KERN_DEBUG "SegmentNumber = %d", p->SegmentNumber);
printk(KERN_DEBUG "TuneBW = %d", p->TuneBW);
for (i = 0; i < 3; i++) {
printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
......@@ -283,7 +189,121 @@ static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pRece
printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
}
}
/* Events that may come from DVB v3 adapter */
static void sms_board_dvb3_event(struct smsdvb_client_t *client,
enum SMS_DVB3_EVENTS event) {
struct smscore_device_t *coredev = client->coredev;
switch (event) {
case DVB3_EVENT_INIT:
sms_debug("DVB3_EVENT_INIT");
sms_board_event(coredev, BOARD_EVENT_BIND);
break;
case DVB3_EVENT_SLEEP:
sms_debug("DVB3_EVENT_SLEEP");
sms_board_event(coredev, BOARD_EVENT_POWER_SUSPEND);
break;
case DVB3_EVENT_HOTPLUG:
sms_debug("DVB3_EVENT_HOTPLUG");
sms_board_event(coredev, BOARD_EVENT_POWER_INIT);
break;
case DVB3_EVENT_FE_LOCK:
if (client->event_fe_state != DVB3_EVENT_FE_LOCK) {
client->event_fe_state = DVB3_EVENT_FE_LOCK;
sms_debug("DVB3_EVENT_FE_LOCK");
sms_board_event(coredev, BOARD_EVENT_FE_LOCK);
}
break;
case DVB3_EVENT_FE_UNLOCK:
if (client->event_fe_state != DVB3_EVENT_FE_UNLOCK) {
client->event_fe_state = DVB3_EVENT_FE_UNLOCK;
sms_debug("DVB3_EVENT_FE_UNLOCK");
sms_board_event(coredev, BOARD_EVENT_FE_UNLOCK);
}
break;
case DVB3_EVENT_UNC_OK:
if (client->event_unc_state != DVB3_EVENT_UNC_OK) {
client->event_unc_state = DVB3_EVENT_UNC_OK;
sms_debug("DVB3_EVENT_UNC_OK");
sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_OK);
}
break;
case DVB3_EVENT_UNC_ERR:
if (client->event_unc_state != DVB3_EVENT_UNC_ERR) {
client->event_unc_state = DVB3_EVENT_UNC_ERR;
sms_debug("DVB3_EVENT_UNC_ERR");
sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_ERRORS);
}
break;
default:
sms_err("Unknown dvb3 api event");
break;
}
}
static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ST *p)
{
smsdvb_print_dvb_stats(p);
/* update reception data */
pReceptionData->IsRfLocked = p->IsRfLocked;
pReceptionData->IsDemodLocked = p->IsDemodLocked;
pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
pReceptionData->ModemState = p->ModemState;
pReceptionData->SNR = p->SNR;
pReceptionData->BER = p->BER;
pReceptionData->BERErrorCount = p->BERErrorCount;
pReceptionData->BERBitCount = p->BERBitCount;
pReceptionData->RSSI = p->RSSI;
CORRECT_STAT_RSSI(*pReceptionData);
pReceptionData->InBandPwr = p->InBandPwr;
pReceptionData->CarrierOffset = p->CarrierOffset;
pReceptionData->ErrorTSPackets = p->ErrorTSPackets;
pReceptionData->TotalTSPackets = p->TotalTSPackets;
};
static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
{
smsdvb_print_isdb_stats(p);
/* update reception data */
pReceptionData->IsRfLocked = p->IsRfLocked;
pReceptionData->IsDemodLocked = p->IsDemodLocked;
pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
pReceptionData->ModemState = p->ModemState;
pReceptionData->SNR = p->SNR;
pReceptionData->BER = p->LayerInfo[0].BER;
pReceptionData->BERErrorCount = p->LayerInfo[0].BERErrorCount;
pReceptionData->BERBitCount = p->LayerInfo[0].BERBitCount;
pReceptionData->RSSI = p->RSSI;
CORRECT_STAT_RSSI(*pReceptionData);
pReceptionData->InBandPwr = p->InBandPwr;
pReceptionData->CarrierOffset = p->CarrierOffset;
pReceptionData->ErrorTSPackets = p->LayerInfo[0].ErrorTSPackets;
pReceptionData->TotalTSPackets = p->LayerInfo[0].TotalTSPackets;
pReceptionData->MFER = 0;
/* TS PER */
if ((p->LayerInfo[0].TotalTSPackets +
p->LayerInfo[0].ErrorTSPackets) > 0) {
pReceptionData->TS_PER = (p->LayerInfo[0].ErrorTSPackets
* 100) / (p->LayerInfo[0].TotalTSPackets
+ p->LayerInfo[0].ErrorTSPackets);
} else {
pReceptionData->TS_PER = 0;
}
}
static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
{
smsdvb_print_isdb_stats_ex(p);
/* update reception data */
pReceptionData->IsRfLocked = p->IsRfLocked;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment