public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [linux-dvb] Help using DMX_SET_BUFFER_SIZE
@ 2008-03-01  0:20 Andrea
  2008-03-01  8:55 ` Florian Lohoff
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea @ 2008-03-01  0:20 UTC (permalink / raw)
  To: linux-dvb

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE
  2008-03-01  0:20 Andrea
@ 2008-03-01  8:55 ` Florian Lohoff
  2008-03-01  9:11   ` Andrea
  2008-03-02 23:08   ` Andrea
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Lohoff @ 2008-03-01  8:55 UTC (permalink / raw)
  To: Andrea; +Cc: linux-dvb


[-- Attachment #1.1: Type: text/plain, Size: 1414 bytes --]

On Sat, Mar 01, 2008 at 12:20:05AM +0000, 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                  flo@rfc822.org             +49-171-2280134
	Those who would give up a little freedom to get a little 
          security shall soon have neither - Benjamin Franklin

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE
  2008-03-01  8:55 ` Florian Lohoff
@ 2008-03-01  9:11   ` Andrea
  2008-03-02 23:08   ` Andrea
  1 sibling, 0 replies; 5+ messages in thread
From: Andrea @ 2008-03-01  9:11 UTC (permalink / raw)
  To: Florian Lohoff; +Cc: linux-dvb

Florian Lohoff wrote:
> On Sat, Mar 01, 2008 at 12:20:05AM +0000, 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE
  2008-03-01  8:55 ` Florian Lohoff
  2008-03-01  9:11   ` Andrea
@ 2008-03-02 23:08   ` Andrea
  1 sibling, 0 replies; 5+ messages in thread
From: Andrea @ 2008-03-02 23:08 UTC (permalink / raw)
  To: Florian Lohoff; +Cc: linux-dvb

Florian Lohoff wrote:
> On Sat, Mar 01, 2008 at 12:20:05AM +0000, 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-dvb] Help using DMX_SET_BUFFER_SIZE
       [not found] <mailman.7.1204534746.20845.linux-dvb@linuxtv.org>
@ 2008-03-03 19:49 ` Andrea
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea @ 2008-03-03 19:49 UTC (permalink / raw)
  To: linux-dvb

linux-dvb-request@linuxtv.org 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-03-03 19:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7.1204534746.20845.linux-dvb@linuxtv.org>
2008-03-03 19:49 ` [linux-dvb] Help using DMX_SET_BUFFER_SIZE Andrea
2008-03-01  0:20 Andrea
2008-03-01  8:55 ` Florian Lohoff
2008-03-01  9:11   ` Andrea
2008-03-02 23:08   ` Andrea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox