diff options
Diffstat (limited to 'drivers/media/dvb/siano/smsdvb.c')
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 372 |
1 files changed, 237 insertions, 135 deletions
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index ba080b95befb..3ee1c3902c56 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -1,28 +1,34 @@ | |||
1 | /* | 1 | /**************************************************************** |
2 | * Driver for the Siano SMS1xxx USB dongle | 2 | |
3 | * | 3 | Siano Mobile Silicon, Inc. |
4 | * Author: Uri Shkolni | 4 | MDTV receiver kernel modules. |
5 | * | 5 | Copyright (C) 2006-2008, Uri Shkolnik |
6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | 6 | |
7 | * | 7 | This program is free software: you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify | 8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License version 2 as | 9 | the Free Software Foundation, either version 2 of the License, or |
10 | * published by the Free Software Foundation; | 10 | (at your option) any later version. |
11 | * | 11 | |
12 | * Software distributed under the License is distributed on an "AS IS" | 12 | This program is distributed in the hope that it will be useful, |
13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * See the GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | * | 16 | |
17 | * You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | |
20 | */ | 20 | ****************************************************************/ |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | 24 | ||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | |||
25 | #include "smscoreapi.h" | 30 | #include "smscoreapi.h" |
31 | #include "smsendian.h" | ||
26 | #include "sms-cards.h" | 32 | #include "sms-cards.h" |
27 | 33 | ||
28 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 34 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
@@ -39,12 +45,15 @@ struct smsdvb_client_t { | |||
39 | struct dvb_frontend frontend; | 45 | struct dvb_frontend frontend; |
40 | 46 | ||
41 | fe_status_t fe_status; | 47 | fe_status_t fe_status; |
42 | int fe_ber, fe_snr, fe_unc, fe_signal_strength; | ||
43 | 48 | ||
44 | struct completion tune_done, stat_done; | 49 | struct completion tune_done; |
45 | 50 | ||
46 | /* todo: save freq/band instead whole struct */ | 51 | /* todo: save freq/band instead whole struct */ |
47 | struct dvb_frontend_parameters fe_params; | 52 | struct dvb_frontend_parameters fe_params; |
53 | |||
54 | struct SMSHOSTLIB_STATISTICS_DVB_S sms_stat_dvb; | ||
55 | int event_fe_state; | ||
56 | int event_unc_state; | ||
48 | }; | 57 | }; |
49 | 58 | ||
50 | static struct list_head g_smsdvb_clients; | 59 | static struct list_head g_smsdvb_clients; |
@@ -54,11 +63,69 @@ static int sms_dbg; | |||
54 | module_param_named(debug, sms_dbg, int, 0644); | 63 | module_param_named(debug, sms_dbg, int, 0644); |
55 | MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))"); | 64 | MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))"); |
56 | 65 | ||
66 | /* Events that may come from DVB v3 adapter */ | ||
67 | static void sms_board_dvb3_event(struct smsdvb_client_t *client, | ||
68 | enum SMS_DVB3_EVENTS event) { | ||
69 | |||
70 | struct smscore_device_t *coredev = client->coredev; | ||
71 | switch (event) { | ||
72 | case DVB3_EVENT_INIT: | ||
73 | sms_debug("DVB3_EVENT_INIT"); | ||
74 | sms_board_event(coredev, BOARD_EVENT_BIND); | ||
75 | break; | ||
76 | case DVB3_EVENT_SLEEP: | ||
77 | sms_debug("DVB3_EVENT_SLEEP"); | ||
78 | sms_board_event(coredev, BOARD_EVENT_POWER_SUSPEND); | ||
79 | break; | ||
80 | case DVB3_EVENT_HOTPLUG: | ||
81 | sms_debug("DVB3_EVENT_HOTPLUG"); | ||
82 | sms_board_event(coredev, BOARD_EVENT_POWER_INIT); | ||
83 | break; | ||
84 | case DVB3_EVENT_FE_LOCK: | ||
85 | if (client->event_fe_state != DVB3_EVENT_FE_LOCK) { | ||
86 | client->event_fe_state = DVB3_EVENT_FE_LOCK; | ||
87 | sms_debug("DVB3_EVENT_FE_LOCK"); | ||
88 | sms_board_event(coredev, BOARD_EVENT_FE_LOCK); | ||
89 | } | ||
90 | break; | ||
91 | case DVB3_EVENT_FE_UNLOCK: | ||
92 | if (client->event_fe_state != DVB3_EVENT_FE_UNLOCK) { | ||
93 | client->event_fe_state = DVB3_EVENT_FE_UNLOCK; | ||
94 | sms_debug("DVB3_EVENT_FE_UNLOCK"); | ||
95 | sms_board_event(coredev, BOARD_EVENT_FE_UNLOCK); | ||
96 | } | ||
97 | break; | ||
98 | case DVB3_EVENT_UNC_OK: | ||
99 | if (client->event_unc_state != DVB3_EVENT_UNC_OK) { | ||
100 | client->event_unc_state = DVB3_EVENT_UNC_OK; | ||
101 | sms_debug("DVB3_EVENT_UNC_OK"); | ||
102 | sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_OK); | ||
103 | } | ||
104 | break; | ||
105 | case DVB3_EVENT_UNC_ERR: | ||
106 | if (client->event_unc_state != DVB3_EVENT_UNC_ERR) { | ||
107 | client->event_unc_state = DVB3_EVENT_UNC_ERR; | ||
108 | sms_debug("DVB3_EVENT_UNC_ERR"); | ||
109 | sms_board_event(coredev, BOARD_EVENT_MULTIPLEX_ERRORS); | ||
110 | } | ||
111 | break; | ||
112 | |||
113 | default: | ||
114 | sms_err("Unknown dvb3 api event"); | ||
115 | break; | ||
116 | } | ||
117 | } | ||
118 | |||
57 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | 119 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) |
58 | { | 120 | { |
59 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; | 121 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; |
60 | struct SmsMsgHdr_ST *phdr = | 122 | struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) (((u8 *) cb->p) |
61 | (struct SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); | 123 | + cb->offset); |
124 | u32 *pMsgData = (u32 *) phdr + 1; | ||
125 | /*u32 MsgDataLen = phdr->msgLength - sizeof(struct SmsMsgHdr_ST);*/ | ||
126 | bool is_status_update = false; | ||
127 | |||
128 | smsendian_handle_rx_message((struct SmsMsgData_ST *) phdr); | ||
62 | 129 | ||
63 | switch (phdr->msgType) { | 130 | switch (phdr->msgType) { |
64 | case MSG_SMS_DVBT_BDA_DATA: | 131 | case MSG_SMS_DVBT_BDA_DATA: |
@@ -70,43 +137,110 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | |||
70 | complete(&client->tune_done); | 137 | complete(&client->tune_done); |
71 | break; | 138 | break; |
72 | 139 | ||
73 | case MSG_SMS_GET_STATISTICS_RES: | 140 | case MSG_SMS_SIGNAL_DETECTED_IND: |
74 | { | 141 | sms_info("MSG_SMS_SIGNAL_DETECTED_IND"); |
75 | struct SmsMsgStatisticsInfo_ST *p = | 142 | client->sms_stat_dvb.TransmissionData.IsDemodLocked = true; |
76 | (struct SmsMsgStatisticsInfo_ST *)(phdr + 1); | 143 | is_status_update = true; |
77 | 144 | break; | |
78 | if (p->Stat.IsDemodLocked) { | 145 | |
79 | client->fe_status = FE_HAS_SIGNAL | | 146 | case MSG_SMS_NO_SIGNAL_IND: |
80 | FE_HAS_CARRIER | | 147 | sms_info("MSG_SMS_NO_SIGNAL_IND"); |
81 | FE_HAS_VITERBI | | 148 | client->sms_stat_dvb.TransmissionData.IsDemodLocked = false; |
82 | FE_HAS_SYNC | | 149 | is_status_update = true; |
83 | FE_HAS_LOCK; | 150 | break; |
84 | 151 | ||
85 | client->fe_snr = p->Stat.SNR; | 152 | case MSG_SMS_TRANSMISSION_IND: { |
86 | client->fe_ber = p->Stat.BER; | 153 | sms_info("MSG_SMS_TRANSMISSION_IND"); |
87 | client->fe_unc = p->Stat.BERErrorCount; | 154 | |
88 | 155 | pMsgData++; | |
89 | if (p->Stat.InBandPwr < -95) | 156 | memcpy(&client->sms_stat_dvb.TransmissionData, pMsgData, |
90 | client->fe_signal_strength = 0; | 157 | sizeof(struct TRANSMISSION_STATISTICS_S)); |
91 | else if (p->Stat.InBandPwr > -29) | 158 | |
92 | client->fe_signal_strength = 100; | 159 | /* Mo need to correct guard interval |
93 | else | 160 | * (as opposed to old statistics message). |
94 | client->fe_signal_strength = | 161 | */ |
95 | (p->Stat.InBandPwr + 95) * 3 / 2; | 162 | CORRECT_STAT_BANDWIDTH(client->sms_stat_dvb.TransmissionData); |
163 | CORRECT_STAT_TRANSMISSON_MODE( | ||
164 | client->sms_stat_dvb.TransmissionData); | ||
165 | is_status_update = true; | ||
166 | break; | ||
167 | } | ||
168 | case MSG_SMS_HO_PER_SLICES_IND: { | ||
169 | struct RECEPTION_STATISTICS_S *pReceptionData = | ||
170 | &client->sms_stat_dvb.ReceptionData; | ||
171 | struct SRVM_SIGNAL_STATUS_S SignalStatusData; | ||
172 | |||
173 | /*sms_info("MSG_SMS_HO_PER_SLICES_IND");*/ | ||
174 | pMsgData++; | ||
175 | SignalStatusData.result = pMsgData[0]; | ||
176 | SignalStatusData.snr = pMsgData[1]; | ||
177 | SignalStatusData.inBandPower = (s32) pMsgData[2]; | ||
178 | SignalStatusData.tsPackets = pMsgData[3]; | ||
179 | SignalStatusData.etsPackets = pMsgData[4]; | ||
180 | SignalStatusData.constellation = pMsgData[5]; | ||
181 | SignalStatusData.hpCode = pMsgData[6]; | ||
182 | SignalStatusData.tpsSrvIndLP = pMsgData[7] & 0x03; | ||
183 | SignalStatusData.tpsSrvIndHP = pMsgData[8] & 0x03; | ||
184 | SignalStatusData.cellId = pMsgData[9] & 0xFFFF; | ||
185 | SignalStatusData.reason = pMsgData[10]; | ||
186 | SignalStatusData.requestId = pMsgData[11]; | ||
187 | pReceptionData->IsRfLocked = pMsgData[16]; | ||
188 | pReceptionData->IsDemodLocked = pMsgData[17]; | ||
189 | pReceptionData->ModemState = pMsgData[12]; | ||
190 | pReceptionData->SNR = pMsgData[1]; | ||
191 | pReceptionData->BER = pMsgData[13]; | ||
192 | pReceptionData->RSSI = pMsgData[14]; | ||
193 | CORRECT_STAT_RSSI(client->sms_stat_dvb.ReceptionData); | ||
194 | |||
195 | pReceptionData->InBandPwr = (s32) pMsgData[2]; | ||
196 | pReceptionData->CarrierOffset = (s32) pMsgData[15]; | ||
197 | pReceptionData->TotalTSPackets = pMsgData[3]; | ||
198 | pReceptionData->ErrorTSPackets = pMsgData[4]; | ||
199 | |||
200 | /* TS PER */ | ||
201 | if ((SignalStatusData.tsPackets + SignalStatusData.etsPackets) | ||
202 | > 0) { | ||
203 | pReceptionData->TS_PER = (SignalStatusData.etsPackets | ||
204 | * 100) / (SignalStatusData.tsPackets | ||
205 | + SignalStatusData.etsPackets); | ||
96 | } else { | 206 | } else { |
97 | client->fe_status = 0; | 207 | pReceptionData->TS_PER = 0; |
98 | client->fe_snr = | ||
99 | client->fe_ber = | ||
100 | client->fe_unc = | ||
101 | client->fe_signal_strength = 0; | ||
102 | } | 208 | } |
103 | 209 | ||
104 | complete(&client->stat_done); | 210 | pReceptionData->BERBitCount = pMsgData[18]; |
105 | break; | 211 | pReceptionData->BERErrorCount = pMsgData[19]; |
106 | } } | ||
107 | 212 | ||
213 | pReceptionData->MRC_SNR = pMsgData[20]; | ||
214 | pReceptionData->MRC_InBandPwr = pMsgData[21]; | ||
215 | pReceptionData->MRC_RSSI = pMsgData[22]; | ||
216 | |||
217 | is_status_update = true; | ||
218 | break; | ||
219 | } | ||
220 | } | ||
108 | smscore_putbuffer(client->coredev, cb); | 221 | smscore_putbuffer(client->coredev, cb); |
109 | 222 | ||
223 | if (is_status_update) { | ||
224 | if (client->sms_stat_dvb.ReceptionData.IsDemodLocked) { | ||
225 | client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER | ||
226 | | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | ||
227 | sms_board_dvb3_event(client, DVB3_EVENT_FE_LOCK); | ||
228 | if (client->sms_stat_dvb.ReceptionData.ErrorTSPackets | ||
229 | == 0) | ||
230 | sms_board_dvb3_event(client, DVB3_EVENT_UNC_OK); | ||
231 | else | ||
232 | sms_board_dvb3_event(client, | ||
233 | DVB3_EVENT_UNC_ERR); | ||
234 | |||
235 | } else { | ||
236 | /*client->fe_status = | ||
237 | (phdr->msgType == MSG_SMS_NO_SIGNAL_IND) ? | ||
238 | 0 : FE_HAS_SIGNAL;*/ | ||
239 | client->fe_status = 0; | ||
240 | sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK); | ||
241 | } | ||
242 | } | ||
243 | |||
110 | return 0; | 244 | return 0; |
111 | } | 245 | } |
112 | 246 | ||
@@ -149,6 +283,7 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed) | |||
149 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | 283 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); |
150 | PidMsg.msgData[0] = feed->pid; | 284 | PidMsg.msgData[0] = feed->pid; |
151 | 285 | ||
286 | smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&PidMsg); | ||
152 | return smsclient_sendrequest(client->smsclient, | 287 | return smsclient_sendrequest(client->smsclient, |
153 | &PidMsg, sizeof(PidMsg)); | 288 | &PidMsg, sizeof(PidMsg)); |
154 | } | 289 | } |
@@ -169,6 +304,7 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed) | |||
169 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | 304 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); |
170 | PidMsg.msgData[0] = feed->pid; | 305 | PidMsg.msgData[0] = feed->pid; |
171 | 306 | ||
307 | smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&PidMsg); | ||
172 | return smsclient_sendrequest(client->smsclient, | 308 | return smsclient_sendrequest(client->smsclient, |
173 | &PidMsg, sizeof(PidMsg)); | 309 | &PidMsg, sizeof(PidMsg)); |
174 | } | 310 | } |
@@ -177,7 +313,10 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client, | |||
177 | void *buffer, size_t size, | 313 | void *buffer, size_t size, |
178 | struct completion *completion) | 314 | struct completion *completion) |
179 | { | 315 | { |
180 | int rc = smsclient_sendrequest(client->smsclient, buffer, size); | 316 | int rc; |
317 | |||
318 | smsendian_handle_tx_message((struct SmsMsgHdr_ST *)buffer); | ||
319 | rc = smsclient_sendrequest(client->smsclient, buffer, size); | ||
181 | if (rc < 0) | 320 | if (rc < 0) |
182 | return rc; | 321 | return rc; |
183 | 322 | ||
@@ -186,83 +325,61 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client, | |||
186 | 0 : -ETIME; | 325 | 0 : -ETIME; |
187 | } | 326 | } |
188 | 327 | ||
189 | static int smsdvb_send_statistics_request(struct smsdvb_client_t *client) | ||
190 | { | ||
191 | struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, | ||
192 | DVBT_BDA_CONTROL_MSG_ID, | ||
193 | HIF_TASK, sizeof(struct SmsMsgHdr_ST), 0 }; | ||
194 | int ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | ||
195 | &client->stat_done); | ||
196 | if (ret < 0) | ||
197 | return ret; | ||
198 | |||
199 | if (client->fe_status & FE_HAS_LOCK) | ||
200 | sms_board_led_feedback(client->coredev, | ||
201 | (client->fe_unc == 0) ? | ||
202 | SMS_LED_HI : SMS_LED_LO); | ||
203 | else | ||
204 | sms_board_led_feedback(client->coredev, SMS_LED_OFF); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) | 328 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) |
209 | { | 329 | { |
210 | struct smsdvb_client_t *client = | 330 | struct smsdvb_client_t *client; |
211 | container_of(fe, struct smsdvb_client_t, frontend); | 331 | client = container_of(fe, struct smsdvb_client_t, frontend); |
212 | int rc = smsdvb_send_statistics_request(client); | ||
213 | 332 | ||
214 | if (!rc) | 333 | *stat = client->fe_status; |
215 | *stat = client->fe_status; | ||
216 | 334 | ||
217 | return rc; | 335 | return 0; |
218 | } | 336 | } |
219 | 337 | ||
220 | static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) | 338 | static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) |
221 | { | 339 | { |
222 | struct smsdvb_client_t *client = | 340 | struct smsdvb_client_t *client; |
223 | container_of(fe, struct smsdvb_client_t, frontend); | 341 | client = container_of(fe, struct smsdvb_client_t, frontend); |
224 | int rc = smsdvb_send_statistics_request(client); | ||
225 | 342 | ||
226 | if (!rc) | 343 | *ber = client->sms_stat_dvb.ReceptionData.BER; |
227 | *ber = client->fe_ber; | ||
228 | 344 | ||
229 | return rc; | 345 | return 0; |
230 | } | 346 | } |
231 | 347 | ||
232 | static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | 348 | static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
233 | { | 349 | { |
234 | struct smsdvb_client_t *client = | 350 | struct smsdvb_client_t *client; |
235 | container_of(fe, struct smsdvb_client_t, frontend); | 351 | client = container_of(fe, struct smsdvb_client_t, frontend); |
236 | int rc = smsdvb_send_statistics_request(client); | ||
237 | 352 | ||
238 | if (!rc) | 353 | if (client->sms_stat_dvb.ReceptionData.InBandPwr < -95) |
239 | *strength = client->fe_signal_strength; | 354 | *strength = 0; |
355 | else if (client->sms_stat_dvb.ReceptionData.InBandPwr > -29) | ||
356 | *strength = 100; | ||
357 | else | ||
358 | *strength = | ||
359 | (client->sms_stat_dvb.ReceptionData.InBandPwr | ||
360 | + 95) * 3 / 2; | ||
240 | 361 | ||
241 | return rc; | 362 | return 0; |
242 | } | 363 | } |
243 | 364 | ||
244 | static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) | 365 | static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) |
245 | { | 366 | { |
246 | struct smsdvb_client_t *client = | 367 | struct smsdvb_client_t *client; |
247 | container_of(fe, struct smsdvb_client_t, frontend); | 368 | client = container_of(fe, struct smsdvb_client_t, frontend); |
248 | int rc = smsdvb_send_statistics_request(client); | ||
249 | 369 | ||
250 | if (!rc) | 370 | *snr = client->sms_stat_dvb.ReceptionData.SNR; |
251 | *snr = client->fe_snr; | ||
252 | 371 | ||
253 | return rc; | 372 | return 0; |
254 | } | 373 | } |
255 | 374 | ||
256 | static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | 375 | static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
257 | { | 376 | { |
258 | struct smsdvb_client_t *client = | 377 | struct smsdvb_client_t *client; |
259 | container_of(fe, struct smsdvb_client_t, frontend); | 378 | client = container_of(fe, struct smsdvb_client_t, frontend); |
260 | int rc = smsdvb_send_statistics_request(client); | ||
261 | 379 | ||
262 | if (!rc) | 380 | *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets; |
263 | *ucblocks = client->fe_unc; | ||
264 | 381 | ||
265 | return rc; | 382 | return 0; |
266 | } | 383 | } |
267 | 384 | ||
268 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, | 385 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, |
@@ -286,12 +403,15 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, | |||
286 | struct SmsMsgHdr_ST Msg; | 403 | struct SmsMsgHdr_ST Msg; |
287 | u32 Data[3]; | 404 | u32 Data[3]; |
288 | } Msg; | 405 | } Msg; |
289 | int ret; | ||
290 | 406 | ||
291 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | 407 | client->fe_status = FE_HAS_SIGNAL; |
292 | Msg.Msg.msgDstId = HIF_TASK; | 408 | client->event_fe_state = -1; |
293 | Msg.Msg.msgFlags = 0; | 409 | client->event_unc_state = -1; |
294 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; | 410 | |
411 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | ||
412 | Msg.Msg.msgDstId = HIF_TASK; | ||
413 | Msg.Msg.msgFlags = 0; | ||
414 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; | ||
295 | Msg.Msg.msgLength = sizeof(Msg); | 415 | Msg.Msg.msgLength = sizeof(Msg); |
296 | Msg.Data[0] = fep->frequency; | 416 | Msg.Data[0] = fep->frequency; |
297 | Msg.Data[2] = 12000000; | 417 | Msg.Data[2] = 12000000; |
@@ -307,24 +427,6 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, | |||
307 | default: return -EINVAL; | 427 | default: return -EINVAL; |
308 | } | 428 | } |
309 | 429 | ||
310 | /* Disable LNA, if any. An error is returned if no LNA is present */ | ||
311 | ret = sms_board_lna_control(client->coredev, 0); | ||
312 | if (ret == 0) { | ||
313 | fe_status_t status; | ||
314 | |||
315 | /* tune with LNA off at first */ | ||
316 | ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | ||
317 | &client->tune_done); | ||
318 | |||
319 | smsdvb_read_status(fe, &status); | ||
320 | |||
321 | if (status & FE_HAS_LOCK) | ||
322 | return ret; | ||
323 | |||
324 | /* previous tune didnt lock - enable LNA and tune again */ | ||
325 | sms_board_lna_control(client->coredev, 1); | ||
326 | } | ||
327 | |||
328 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | 430 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), |
329 | &client->tune_done); | 431 | &client->tune_done); |
330 | } | 432 | } |
@@ -349,8 +451,7 @@ static int smsdvb_init(struct dvb_frontend *fe) | |||
349 | struct smsdvb_client_t *client = | 451 | struct smsdvb_client_t *client = |
350 | container_of(fe, struct smsdvb_client_t, frontend); | 452 | container_of(fe, struct smsdvb_client_t, frontend); |
351 | 453 | ||
352 | sms_board_power(client->coredev, 1); | 454 | sms_board_dvb3_event(client, DVB3_EVENT_INIT); |
353 | |||
354 | return 0; | 455 | return 0; |
355 | } | 456 | } |
356 | 457 | ||
@@ -359,8 +460,7 @@ static int smsdvb_sleep(struct dvb_frontend *fe) | |||
359 | struct smsdvb_client_t *client = | 460 | struct smsdvb_client_t *client = |
360 | container_of(fe, struct smsdvb_client_t, frontend); | 461 | container_of(fe, struct smsdvb_client_t, frontend); |
361 | 462 | ||
362 | sms_board_led_feedback(client->coredev, SMS_LED_OFF); | 463 | sms_board_dvb3_event(client, DVB3_EVENT_SLEEP); |
363 | sms_board_power(client->coredev, 0); | ||
364 | 464 | ||
365 | return 0; | 465 | return 0; |
366 | } | 466 | } |
@@ -485,7 +585,6 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev, | |||
485 | client->coredev = coredev; | 585 | client->coredev = coredev; |
486 | 586 | ||
487 | init_completion(&client->tune_done); | 587 | init_completion(&client->tune_done); |
488 | init_completion(&client->stat_done); | ||
489 | 588 | ||
490 | kmutex_lock(&g_smsdvb_clientslock); | 589 | kmutex_lock(&g_smsdvb_clientslock); |
491 | 590 | ||
@@ -493,8 +592,11 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev, | |||
493 | 592 | ||
494 | kmutex_unlock(&g_smsdvb_clientslock); | 593 | kmutex_unlock(&g_smsdvb_clientslock); |
495 | 594 | ||
496 | sms_info("success"); | 595 | client->event_fe_state = -1; |
596 | client->event_unc_state = -1; | ||
597 | sms_board_dvb3_event(client, DVB3_EVENT_HOTPLUG); | ||
497 | 598 | ||
599 | sms_info("success"); | ||
498 | sms_board_setup(coredev); | 600 | sms_board_setup(coredev); |
499 | 601 | ||
500 | return 0; | 602 | return 0; |
@@ -547,5 +649,5 @@ module_init(smsdvb_module_init); | |||
547 | module_exit(smsdvb_module_exit); | 649 | module_exit(smsdvb_module_exit); |
548 | 650 | ||
549 | MODULE_DESCRIPTION("SMS DVB subsystem adaptation module"); | 651 | MODULE_DESCRIPTION("SMS DVB subsystem adaptation module"); |
550 | MODULE_AUTHOR("Siano Mobile Silicon, INC. (uris@siano-ms.com)"); | 652 | MODULE_AUTHOR("Siano Mobile Silicon, Inc. (uris@siano-ms.com)"); |
551 | MODULE_LICENSE("GPL"); | 653 | MODULE_LICENSE("GPL"); |