Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] lmedm04: rs2000 check if interrupt urb is over due

Change handling of signal_lock on rs2000. Use ibuf[2] to detect
lock as there is a longer wait for lock to appear in ibuf[6].

Remove last_key and key_timeout and use jiffies plus 60ms
to detect that streaming is still active.

If the current jiffies is time_after the interrupt urb overdue and
clear signal lock.

This results in far faster recovery of lock and streaming.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Malcolm Priestley and committed by
Mauro Carvalho Chehab
3a370222 3c1e7f27

+14 -11
+14 -11
drivers/media/usb/dvb-usb-v2/lmedm04.c
··· 125 125 #define TUNER_RS2000 0x4 126 126 127 127 struct lme2510_state { 128 + unsigned long int_urb_due; 128 129 u8 id; 129 130 u8 tuner_config; 130 131 u8 signal_lock; 131 132 u8 signal_level; 132 133 u8 signal_sn; 133 134 u8 time_key; 134 - u8 last_key; 135 - u8 key_timeout; 136 135 u8 i2c_talk_onoff; 137 136 u8 i2c_gate; 138 137 u8 i2c_tuner_gate_w; ··· 322 323 } 323 324 break; 324 325 case TUNER_RS2000: 325 - if (ibuf[1] == 0x3 && ibuf[6] == 0xff) 326 + if (ibuf[2] & 0x1) 326 327 st->signal_lock = 0xff; 327 328 else 328 329 st->signal_lock = 0x00; ··· 342 343 break; 343 344 } 344 345 } 346 + 345 347 usb_submit_urb(lme_urb, GFP_ATOMIC); 348 + 349 + /* interrupt urb is due every 48 msecs while streaming 350 + * add 12msecs for system lag */ 351 + st->int_urb_due = jiffies + msecs_to_jiffies(60); 346 352 } 347 353 348 354 static int lme2510_int_read(struct dvb_usb_adapter *adap) ··· 588 584 switch (wbuf[3]) { 589 585 case 0x8c: 590 586 rbuf[0] = 0x55; 591 - rbuf[1] = 0xff; 592 - if (st->last_key == st->time_key) { 593 - st->key_timeout++; 594 - if (st->key_timeout > 5) 595 - rbuf[1] = 0; 596 - } else 597 - st->key_timeout = 0; 598 - st->last_key = st->time_key; 587 + rbuf[1] = st->signal_lock; 588 + 589 + /* If int_urb_due overdue 590 + * set rbuf[1] to 0 to clear lock */ 591 + if (time_after(jiffies, st->int_urb_due)) 592 + rbuf[1] = 0; 593 + 599 594 break; 600 595 default: 601 596 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);