aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/stv0299.c
diff options
context:
space:
mode:
authorNooneImportant <nxhxzi702@sneakemail.com>2005-11-09 00:35:27 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:03 -0500
commit83b75b049be981e579ba2cb88aa9bf3534bbbdb1 (patch)
treec7d6199e9c6b5373b373439148da7dc4f48a0698 /drivers/media/dvb/frontends/stv0299.c
parentb90ed914e513a6ad6184f7a46a0df0888dcfc177 (diff)
[PATCH] dvb: let other frontends support FE_DISHNETWORK_SEND_LEGACY_CMD
Add support to FE_DISHNETWORK_SEND_LEGACY_CMD code to support other frontends besides stv0299. The generic code is a fallback in the case that it doesn't work for some specific frontends (again stv0299 being a good example). Signed-off-by: NooneImportant <nxhxzi702@sneakemail.com> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Cc: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/dvb/frontends/stv0299.c')
-rw-r--r--drivers/media/dvb/frontends/stv0299.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index b1876618a37d..ae00d7a40d7c 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -387,36 +387,6 @@ static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag
387 }; 387 };
388} 388}
389 389
390static inline s32 stv0299_calc_usec_delay (struct timeval lasttime, struct timeval curtime)
391{
392 return ((curtime.tv_usec < lasttime.tv_usec) ?
393 1000000 - lasttime.tv_usec + curtime.tv_usec :
394 curtime.tv_usec - lasttime.tv_usec);
395}
396
397static void stv0299_sleep_until (struct timeval *waketime, u32 add_usec)
398{
399 struct timeval lasttime;
400 s32 delta, newdelta;
401
402 waketime->tv_usec += add_usec;
403 if (waketime->tv_usec >= 1000000) {
404 waketime->tv_usec -= 1000000;
405 waketime->tv_sec++;
406 }
407
408 do_gettimeofday (&lasttime);
409 delta = stv0299_calc_usec_delay (lasttime, *waketime);
410 if (delta > 2500) {
411 msleep ((delta - 1500) / 1000);
412 do_gettimeofday (&lasttime);
413 newdelta = stv0299_calc_usec_delay (lasttime, *waketime);
414 delta = (newdelta > delta) ? 0 : newdelta;
415 }
416 if (delta > 0)
417 udelay (delta);
418}
419
420static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd) 390static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)
421{ 391{
422 struct stv0299_state* state = fe->demodulator_priv; 392 struct stv0299_state* state = fe->demodulator_priv;
@@ -444,7 +414,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)
444 memcpy (&tv[0], &nexttime, sizeof (struct timeval)); 414 memcpy (&tv[0], &nexttime, sizeof (struct timeval));
445 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */ 415 stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */
446 416
447 stv0299_sleep_until (&nexttime, 32000); 417 dvb_frontend_sleep_until(&nexttime, 32000);
448 418
449 for (i=0; i<9; i++) { 419 for (i=0; i<9; i++) {
450 if (debug_legacy_dish_switch) 420 if (debug_legacy_dish_switch)
@@ -458,13 +428,13 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)
458 cmd = cmd >> 1; 428 cmd = cmd >> 1;
459 429
460 if (i != 8) 430 if (i != 8)
461 stv0299_sleep_until (&nexttime, 8000); 431 dvb_frontend_sleep_until(&nexttime, 8000);
462 } 432 }
463 if (debug_legacy_dish_switch) { 433 if (debug_legacy_dish_switch) {
464 printk ("%s(%d): switch delay (should be 32k followed by all 8k\n", 434 printk ("%s(%d): switch delay (should be 32k followed by all 8k\n",
465 __FUNCTION__, fe->dvb->num); 435 __FUNCTION__, fe->dvb->num);
466 for (i=1; i < 10; i++) 436 for (i = 1; i < 10; i++)
467 printk ("%d: %d\n", i, stv0299_calc_usec_delay (tv[i-1] , tv[i])); 437 printk ("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i]));
468 } 438 }
469 439
470 return 0; 440 return 0;