Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE

2008-03-03 Thread Andrea
[EMAIL PROTECTED] wrote:
 
 
 Possible solutions:
 
 2) enable the resize of a live ring buffer.
 Currently:
 
 dvb_dvr_write DOES lock the mutex (dmxdev-mutex)
 dvb_dvr_read  DOES NOT lock the mutex (the code to lock the mutex is there, 
 but commented out, why?)
 
 Is it enough to lock the mutex in dvb_dvr_read?

No, it isn't!

dvb_dmxdev_ts_callback is the function writing in the dvr_buffer, not 
dvb_dvr_write (which must be a 
system call I think).

Things get more complicated... I've understood that a callback function cannot 
sleep, so a mutex 
must not be used.
And a relocation of the buffer counts as reading and writing.

 Then the new function to change the buffer size could just lock the mutex, 
 change the size and unlock.

How many readers of the dvr can there be? It looks like only 1 (otherwise the 
mutex would not be 
commented out).
Is it legal to write an application that reads dvr from one thread/process, and 
calls other ioctl 
from an other? I guess not, for the same reason why it cannot read from 2 
threads.

So, if the above is true, I only need to synchronize with 
dvb_dmxdev_ts_callback, i.e. acquire the 
same spin_lock.

Does it make sense?

PS: It seems that I am replying my own emails... and I do that while I discover 
and understand more 
about the architecture of the dvr/demux.
What is a good starting point to get an idea about all those synchronization 
issues?
My next reading is the Unreliable Guide To Locking.

More to follow...


___
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE

2008-03-02 Thread Andrea
Florian Lohoff wrote:
 On Sat, Mar 01, 2008 at 12:20:05AM +, Andrea wrote:
 
 In 2.6.25-rc3 the dvr kernel side looks like this:
 
 1015 switch (cmd) {
 1016 case DMX_SET_BUFFER_SIZE:
 1017 // FIXME: implement
 1018 ret = 0;
 1019 break;
 
 i guess its clear why it doesnt make a difference ;)

I've been thinking a little about how to implement that and I came across this 
issue:
(given my limited experience of dvb kernel developing the following might not 
be 100% correct...)

Usually everything (frontend, demux) is set up and only afterwards a dvr is 
opened.

That means that a dvr is live immediately and its buffer gets filled 
immediately.
So it is a bit tricky to change the size of the buffer while the buffer is 
operating.
The demux on the other hand does not operate immediately.

Possible solutions:

1) open the DVR before starting the demux. So that it is possible to change the 
dvr buffer size
it is usually done the other way round.

2) enable the resize of a live ring buffer.
Currently:

dvb_dvr_write DOES lock the mutex (dmxdev-mutex)
dvb_dvr_read  DOES NOT lock the mutex (the code to lock the mutex is there, but 
commented out, why?)

Is it enough to lock the mutex in dvb_dvr_read?
Then the new function to change the buffer size could just lock the mutex, 
change the size and unlock.

3) don't bother.

I personally prefer option 2), which gives me the chance to learn how all that 
works.
I'd like to have an opinion about this matter, maybe just to improve my 
knowledge of the dvb mechanism.

Anyone?

___
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE

2008-03-01 Thread Florian Lohoff
On Sat, Mar 01, 2008 at 12:20:05AM +, Andrea wrote:
 Hi,
 
 I've tried to add an extra argument to gnutv to set the size of the 
 dvb_ringbuffer via 
 DMX_SET_BUFFER_SIZE.
 
 I have not really understood the difference between dvr and demux.
 It seems that gnutv uses the dvr to read from the DVB card and then copies 
 the content to a file.
 
 I call
 
 int dvbdemux_set_buffer(int fd, int bufsize)
 {
   return ioctl(fd, DMX_SET_BUFFER_SIZE, bufsize);
 }
 
 on the dvr (I think), but it does not make much of a change. The ioctl call 
 returns success.
 I've printed a lot of debug output (adding a few dprintk) and this is what I 
 see when I run gnutv.
 Now, I set the buffer to 1024 * 1024 which is nowhere in the log.
 I cannot see in the log the 2 functions (demux and dvr) handling this ioctl 
 call:
 dvb_demux_do_ioctl and dvb_dvr_do_ioctl (I've added some printk as well).

In 2.6.25-rc3 the dvr kernel side looks like this:

1015 switch (cmd) {
1016 case DMX_SET_BUFFER_SIZE:
1017 // FIXME: implement
1018 ret = 0;
1019 break;

i guess its clear why it doesnt make a difference ;)

Flo
-- 
Florian Lohoff  [EMAIL PROTECTED] +49-171-2280134
Those who would give up a little freedom to get a little 
  security shall soon have neither - Benjamin Franklin


signature.asc
Description: Digital signature
___
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE

2008-03-01 Thread Andrea
Florian Lohoff wrote:
 On Sat, Mar 01, 2008 at 12:20:05AM +, Andrea wrote:
 on the dvr (I think), but it does not make much of a change. The ioctl call 
 returns success.
 I've printed a lot of debug output (adding a few dprintk) and this is what I 
 see when I run gnutv.
 Now, I set the buffer to 1024 * 1024 which is nowhere in the log.
 I cannot see in the log the 2 functions (demux and dvr) handling this ioctl 
 call:
 dvb_demux_do_ioctl and dvb_dvr_do_ioctl (I've added some printk as well).
 
 In 2.6.25-rc3 the dvr kernel side looks like this:
 
 1015 switch (cmd) {
 1016 case DMX_SET_BUFFER_SIZE:
 1017 // FIXME: implement
 1018 ret = 0;
 1019 break;
 
 i guess its clear why it doesnt make a difference ;)
 
 Flo

Yes I had noticed that and I was trying to see what I can do.
My problem is that I replace the // FIXME with a printk() and it does not get 
called
How is it supposed to work?

I open /dev/dvb/adapter0/dvr0, I get back a file descriptor and the I call the 
ioctl with that file 
descriptor.

This code comes from gnutv_data.c plus my additional code

// open dvr device
dvrfd = dvbdemux_open_dvr(adapter_id, 0, 1, 0);
if (dvrfd  0) {
fprintf(stderr, Failed to open DVR device\n);
exit(1);
}

if (buffer_size  0)
{
  int res = dvbdemux_set_buffer(dvrfd, buffer_size);
  if (res  0) {
fprintf(stderr, Failed to set ring buffer size\n);
exit(1);
  }
}

Regardless of what is implemented or not, would that be correct?

Andrea

___
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


[linux-dvb] Help using DMX_SET_BUFFER_SIZE

2008-02-29 Thread Andrea
Hi,

I've tried to add an extra argument to gnutv to set the size of the 
dvb_ringbuffer via 
DMX_SET_BUFFER_SIZE.

I have not really understood the difference between dvr and demux.
It seems that gnutv uses the dvr to read from the DVB card and then copies the 
content to a file.

I call

int dvbdemux_set_buffer(int fd, int bufsize)
{
return ioctl(fd, DMX_SET_BUFFER_SIZE, bufsize);
}

on the dvr (I think), but it does not make much of a change. The ioctl call 
returns success.
I've printed a lot of debug output (adding a few dprintk) and this is what I 
see when I run gnutv.
Now, I set the buffer to 1024 * 1024 which is nowhere in the log.
I cannot see in the log the 2 functions (demux and dvr) handling this ioctl 
call:
dvb_demux_do_ioctl and dvb_dvr_do_ioctl (I've added some printk as well).

printk(function : %s %d\n, __FUNCTION__, cmd);


/sbin/modprobe dvb_core debug=1 dvbdev_debug=1


Feb 29 23:59:34 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:34 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:34 thinkpad kernel: function : dvb_dmxdev_filter_set
Feb 29 23:59:34 thinkpad kernel: function : dvb_dvr_open
Feb 29 23:59:34 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:34 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:34 thinkpad kernel: function : dvb_dmxdev_filter_set
Feb 29 23:59:34 thinkpad kernel: dmxdev: dvb_ringbuffer_init 1925120
Feb 29 23:59:34 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:34 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_dmxdev_filter_set
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: function : dvb_demux_open
Feb 29 23:59:35 thinkpad kernel: dmxdev: dvb_ringbuffer_init 8192
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:35 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7
Feb 29 23:59:36 thinkpad kernel: dmxdev: section callback 70 70 05 d4 fd 23
Feb 29 23:59:36 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:36 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7
Feb 29 23:59:36 thinkpad kernel: dmxdev: section callback 00 b0 25 10 04 c5
Feb 29 23:59:36 thinkpad kernel: dmxdev: section callback 02 b0 82 10 84 c7



My questions are

1) how many ringbuffers are there? 2 sizes are reported in the log.
2) in the log it seems the buffer is recreated every time.
3) why can't I see any call to dvb_demux_do_ioctl and dvb_dvr_do_ioctl?
4) ... what is the difference between demux and dvr? :-)

I'm using a Hauppauge WinTV NOVA T USB2, 2.6.24.2, letest mercurial source code.


___
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb