/****************************************************************
Siano Mobile Silicon, Inc.
MDTV receiver kernel modules.
Copyright (C) 2006-2008, Uri Shkolnik
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************/
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
#include "dmxdev.h"
#include "dvbdev.h"
#include "dvb_demux.h"
#include "dvb_frontend.h"
#include "smscoreapi.h"
#include "smsendian.h"
#include "sms-cards.h"
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
struct smsdvb_client_t {
struct list_head entry;
struct smscore_device_t *coredev;
struct smscore_client_t *smsclient;
struct dvb_adapter adapter;
struct dvb_demux demux;
struct dmxdev dmxdev;
struct dvb_frontend frontend;
fe_status_t fe_status;
struct completion tune_done;
/* todo: save freq/band instead whole struct */
struct dtv_frontend_properties fe_params;
struct SMSHOSTLIB_STATISTICS_DVB_S sms_stat_dvb;
int event_fe_state;
int event_unc_state;
};
static struct list_head g_smsdvb_clients;
static struct mutex g_smsdvb_clientslock;
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_S *pReceptionData,
struct SMSHOSTLIB_STATISTICS_ST *p)
{
if (sms_dbg & 2) {
printk(KERN_DEBUG "Reserved = %d", p->Reserved);
printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
printk(KERN_DEBUG "SNR = %d", p->SNR);
printk(KERN_DEBUG "BER = %d", p->BER);
printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC);
printk(KERN_DEBUG "TS_PER = %d", p->TS_PER);
printk(KERN_DEBUG "MFER = %d", p->MFER);
printk(KERN_DEBUG "RSSI = %d", p->RSSI);
printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
printk(KERN_DEBUG "Frequency = %d", p->Frequency);
printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
printk(KERN_DEBUG "ModemState = %d", p->ModemState);
printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
printk(KERN_DEBUG "CodeRate = %d", p->CodeRate);
printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate);
printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy);
printk(KERN_DEBUG "Constellation = %d", p->Constellation);
printk(KERN_DEBUG "BurstSize = %d", p->BurstSize);
printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration);
printk(KERN_DEBUG