aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/vp702x-fe.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/media/dvb/dvb-usb/vp702x-fe.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/media/dvb/dvb-usb/vp702x-fe.c')
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c80
1 files changed, 59 insertions, 21 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index ccc7e4452664..2bb8d4cc8d88 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -41,14 +41,23 @@ struct vp702x_fe_state {
41 41
42static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) 42static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
43{ 43{
44 u8 buf[10]; 44 struct vp702x_device_state *dst = st->d->priv;
45 if (time_after(jiffies,st->next_status_check)) { 45 u8 *buf;
46 vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10);
47 46
47 if (time_after(jiffies, st->next_status_check)) {
48 mutex_lock(&dst->buf_mutex);
49 buf = dst->buf;
50
51 vp702x_usb_in_op(st->d, READ_STATUS, 0, 0, buf, 10);
48 st->lock = buf[4]; 52 st->lock = buf[4];
49 vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1);
50 vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1);
51 53
54 vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x11, 0, buf, 1);
55 st->snr = buf[0];
56
57 vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x15, 0, buf, 1);
58 st->sig = buf[0];
59
60 mutex_unlock(&dst->buf_mutex);
52 st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; 61 st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
53 } 62 }
54 return 0; 63 return 0;
@@ -130,11 +139,17 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
130 struct dvb_frontend_parameters *fep) 139 struct dvb_frontend_parameters *fep)
131{ 140{
132 struct vp702x_fe_state *st = fe->demodulator_priv; 141 struct vp702x_fe_state *st = fe->demodulator_priv;
142 struct vp702x_device_state *dst = st->d->priv;
133 u32 freq = fep->frequency/1000; 143 u32 freq = fep->frequency/1000;
134 /*CalFrequency*/ 144 /*CalFrequency*/
135/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ 145/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */
136 u64 sr; 146 u64 sr;
137 u8 cmd[8] = { 0 },ibuf[10]; 147 u8 *cmd;
148
149 mutex_lock(&dst->buf_mutex);
150
151 cmd = dst->buf;
152 memset(cmd, 0, 10);
138 153
139 cmd[0] = (freq >> 8) & 0x7f; 154 cmd[0] = (freq >> 8) & 0x7f;
140 cmd[1] = freq & 0xff; 155 cmd[1] = freq & 0xff;
@@ -170,13 +185,15 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
170 st->status_check_interval = 250; 185 st->status_check_interval = 250;
171 st->next_status_check = jiffies; 186 st->next_status_check = jiffies;
172 187
173 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); 188 vp702x_usb_inout_op(st->d, cmd, 8, cmd, 10, 100);
174 189
175 if (ibuf[2] == 0 && ibuf[3] == 0) 190 if (cmd[2] == 0 && cmd[3] == 0)
176 deb_fe("tuning failed.\n"); 191 deb_fe("tuning failed.\n");
177 else 192 else
178 deb_fe("tuning succeeded.\n"); 193 deb_fe("tuning succeeded.\n");
179 194
195 mutex_unlock(&dst->buf_mutex);
196
180 return 0; 197 return 0;
181} 198}
182 199
@@ -204,27 +221,32 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
204static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, 221static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
205 struct dvb_diseqc_master_cmd *m) 222 struct dvb_diseqc_master_cmd *m)
206{ 223{
224 u8 *cmd;
207 struct vp702x_fe_state *st = fe->demodulator_priv; 225 struct vp702x_fe_state *st = fe->demodulator_priv;
208 u8 cmd[8],ibuf[10]; 226 struct vp702x_device_state *dst = st->d->priv;
209 memset(cmd,0,8);
210 227
211 deb_fe("%s\n",__func__); 228 deb_fe("%s\n",__func__);
212 229
213 if (m->msg_len > 4) 230 if (m->msg_len > 4)
214 return -EINVAL; 231 return -EINVAL;
215 232
233 mutex_lock(&dst->buf_mutex);
234
235 cmd = dst->buf;
216 cmd[1] = SET_DISEQC_CMD; 236 cmd[1] = SET_DISEQC_CMD;
217 cmd[2] = m->msg_len; 237 cmd[2] = m->msg_len;
218 memcpy(&cmd[3], m->msg, m->msg_len); 238 memcpy(&cmd[3], m->msg, m->msg_len);
219 cmd[7] = vp702x_chksum(cmd,0,7); 239 cmd[7] = vp702x_chksum(cmd, 0, 7);
220 240
221 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); 241 vp702x_usb_inout_op(st->d, cmd, 8, cmd, 10, 100);
222 242
223 if (ibuf[2] == 0 && ibuf[3] == 0) 243 if (cmd[2] == 0 && cmd[3] == 0)
224 deb_fe("diseqc cmd failed.\n"); 244 deb_fe("diseqc cmd failed.\n");
225 else 245 else
226 deb_fe("diseqc cmd succeeded.\n"); 246 deb_fe("diseqc cmd succeeded.\n");
227 247
248 mutex_unlock(&dst->buf_mutex);
249
228 return 0; 250 return 0;
229} 251}
230 252
@@ -237,7 +259,9 @@ static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd
237static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 259static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
238{ 260{
239 struct vp702x_fe_state *st = fe->demodulator_priv; 261 struct vp702x_fe_state *st = fe->demodulator_priv;
240 u8 ibuf[10]; 262 struct vp702x_device_state *dst = st->d->priv;
263 u8 *buf;
264
241 deb_fe("%s\n",__func__); 265 deb_fe("%s\n",__func__);
242 266
243 st->tone_mode = tone; 267 st->tone_mode = tone;
@@ -247,14 +271,21 @@ static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
247 else 271 else
248 st->lnb_buf[2] = 0x00; 272 st->lnb_buf[2] = 0x00;
249 273
250 st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); 274 st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);
275
276 mutex_lock(&dst->buf_mutex);
277
278 buf = dst->buf;
279 memcpy(buf, st->lnb_buf, 8);
251 280
252 vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); 281 vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
253 if (ibuf[2] == 0 && ibuf[3] == 0) 282 if (buf[2] == 0 && buf[3] == 0)
254 deb_fe("set_tone cmd failed.\n"); 283 deb_fe("set_tone cmd failed.\n");
255 else 284 else
256 deb_fe("set_tone cmd succeeded.\n"); 285 deb_fe("set_tone cmd succeeded.\n");
257 286
287 mutex_unlock(&dst->buf_mutex);
288
258 return 0; 289 return 0;
259} 290}
260 291
@@ -262,7 +293,8 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
262 voltage) 293 voltage)
263{ 294{
264 struct vp702x_fe_state *st = fe->demodulator_priv; 295 struct vp702x_fe_state *st = fe->demodulator_priv;
265 u8 ibuf[10]; 296 struct vp702x_device_state *dst = st->d->priv;
297 u8 *buf;
266 deb_fe("%s\n",__func__); 298 deb_fe("%s\n",__func__);
267 299
268 st->voltage = voltage; 300 st->voltage = voltage;
@@ -272,14 +304,20 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
272 else 304 else
273 st->lnb_buf[4] = 0x00; 305 st->lnb_buf[4] = 0x00;
274 306
275 st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); 307 st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);
308
309 mutex_lock(&dst->buf_mutex);
310
311 buf = dst->buf;
312 memcpy(buf, st->lnb_buf, 8);
276 313
277 vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); 314 vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
278 if (ibuf[2] == 0 && ibuf[3] == 0) 315 if (buf[2] == 0 && buf[3] == 0)
279 deb_fe("set_voltage cmd failed.\n"); 316 deb_fe("set_voltage cmd failed.\n");
280 else 317 else
281 deb_fe("set_voltage cmd succeeded.\n"); 318 deb_fe("set_voltage cmd succeeded.\n");
282 319
320 mutex_unlock(&dst->buf_mutex);
283 return 0; 321 return 0;
284} 322}
285 323