Skip to contentSkip to conversation

Help using DMX_SET_BUFFER_SIZE

linux-dvb Andrea 2 participants 4 messages Mar 1, 2008 – Mar 2, 2008 Media (V4L/DVB)

lore
Share & tools
lore

Andrea

author
#0 lore raw

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
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#1 lore raw
Quoted 15 lines · 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);
}
Quoted 5 lines

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

Signature · 3 lines
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

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#2 lore raw
Quoted 11 lines · Florian Lohoff
Quoted 5 lines · Andrea

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:

Quoted 7 lines
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
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#3 lore raw
In reply to Florian Lohoff
Quoted 11 lines · Florian Lohoff

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
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb