aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalcolm Priestley <tvboxspy@gmail.com>2011-04-22 05:20:57 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-20 08:29:27 -0400
commit449a0bada34e5e554ef52aca86aeaa81ed35533e (patch)
treefb10ccdd3a0d68b50cae261588b03280ca0ff2b7
parenta760d63878b21fc16997b79e8ebee531b40c8b26 (diff)
[media] lmedm04: PID filtering changes
Improve PID filtering and program register 20 correctly. Make sure stream_on message is sent if streaming is off, otherwise PIDs are not registered. Move mutex outside lme2510_enable_pid. Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
index 4b457e7e5d33..f36f471deae2 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -127,6 +127,7 @@ struct lme2510_state {
127 u8 i2c_tuner_gate_r; 127 u8 i2c_tuner_gate_r;
128 u8 i2c_tuner_addr; 128 u8 i2c_tuner_addr;
129 u8 stream_on; 129 u8 stream_on;
130 u8 pid_size;
130 void *buffer; 131 void *buffer;
131 struct urb *lme_urb; 132 struct urb *lme_urb;
132 void *usb_buffer; 133 void *usb_buffer;
@@ -224,29 +225,28 @@ static int lme2510_enable_pid(struct dvb_usb_device *d, u8 index, u16 pid_out)
224 static u8 pid_buff[] = LME_ZERO_PID; 225 static u8 pid_buff[] = LME_ZERO_PID;
225 static u8 rbuf[1]; 226 static u8 rbuf[1];
226 u8 pid_no = index * 2; 227 u8 pid_no = index * 2;
228 u8 pid_len = pid_no + 2;
227 int ret = 0; 229 int ret = 0;
228 deb_info(1, "PID Setting Pid %04x", pid_out); 230 deb_info(1, "PID Setting Pid %04x", pid_out);
229 231
232 if (st->pid_size == 0)
233 ret |= lme2510_stream_restart(d);
234
230 pid_buff[2] = pid_no; 235 pid_buff[2] = pid_no;
231 pid_buff[3] = (u8)pid_out & 0xff; 236 pid_buff[3] = (u8)pid_out & 0xff;
232 pid_buff[4] = pid_no + 1; 237 pid_buff[4] = pid_no + 1;
233 pid_buff[5] = (u8)(pid_out >> 8); 238 pid_buff[5] = (u8)(pid_out >> 8);
234 239
235 /* wait for i2c mutex */ 240 if (pid_len > st->pid_size)
236 ret = mutex_lock_interruptible(&d->i2c_mutex); 241 st->pid_size = pid_len;
237 if (ret < 0) { 242 pid_buff[7] = 0x80 + st->pid_size;
238 ret = -EAGAIN;
239 return ret;
240 }
241 243
242 ret |= lme2510_usb_talk(d, pid_buff , 244 ret |= lme2510_usb_talk(d, pid_buff ,
243 sizeof(pid_buff) , rbuf, sizeof(rbuf)); 245 sizeof(pid_buff) , rbuf, sizeof(rbuf));
244 246
245 if (st->stream_on & 1) 247 if (st->stream_on)
246 ret |= lme2510_stream_restart(d); 248 ret |= lme2510_stream_restart(d);
247 249
248 mutex_unlock(&d->i2c_mutex);
249
250 return ret; 250 return ret;
251} 251}
252 252
@@ -362,18 +362,23 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
362 362
363static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) 363static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
364{ 364{
365 struct lme2510_state *st = adap->dev->priv;
365 static u8 clear_pid_reg[] = LME_CLEAR_PID; 366 static u8 clear_pid_reg[] = LME_CLEAR_PID;
366 static u8 rbuf[1]; 367 static u8 rbuf[1];
367 int ret = 0; 368 int ret;
368 369
369 deb_info(1, "PID Clearing Filter"); 370 deb_info(1, "PID Clearing Filter");
370 371
371 ret = mutex_lock_interruptible(&adap->dev->i2c_mutex); 372 ret = mutex_lock_interruptible(&adap->dev->i2c_mutex);
373 if (ret < 0)
374 return -EAGAIN;
372 375
373 if (!onoff) 376 if (!onoff)
374 ret |= lme2510_usb_talk(adap->dev, clear_pid_reg, 377 ret |= lme2510_usb_talk(adap->dev, clear_pid_reg,
375 sizeof(clear_pid_reg), rbuf, sizeof(rbuf)); 378 sizeof(clear_pid_reg), rbuf, sizeof(rbuf));
376 379
380 st->pid_size = 0;
381
377 mutex_unlock(&adap->dev->i2c_mutex); 382 mutex_unlock(&adap->dev->i2c_mutex);
378 383
379 return 0; 384 return 0;
@@ -388,8 +393,14 @@ static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
388 pid, index, onoff); 393 pid, index, onoff);
389 394
390 if (onoff) 395 if (onoff)
391 if (!pid_filter) 396 if (!pid_filter) {
392 ret = lme2510_enable_pid(adap->dev, index, pid); 397 ret = mutex_lock_interruptible(&adap->dev->i2c_mutex);
398 if (ret < 0)
399 return -EAGAIN;
400 ret |= lme2510_enable_pid(adap->dev, index, pid);
401 mutex_unlock(&adap->dev->i2c_mutex);
402 }
403
393 404
394 return ret; 405 return ret;
395} 406}
@@ -1316,5 +1327,5 @@ module_exit(lme2510_module_exit);
1316 1327
1317MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 1328MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1318MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0"); 1329MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1319MODULE_VERSION("1.85"); 1330MODULE_VERSION("1.86");
1320MODULE_LICENSE("GPL"); 1331MODULE_LICENSE("GPL");