[linux-dvb] Q: How to use frontend events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HTPC wrote:
> I'm just starting to explore the DVB API and thought I'd start with the
> very basics :-) I'm trying to tune my DVB-T card to a transponder and so
> far I'm able to do the actual tuning but I have to resort to a busy-wait
> loop to know when the tuning is complete (or failed due to timeout). I'm
> doing something like this:
> 
>   dvb_frontend_parameters params;
> 
>   <fill params struct here>
> 
>   ioctl(fd, FE_SET_FRONTEND, &params);
> 
>   fe_status_t status;
>   int j = 0;
> 
>   do {
>     ioctl(fd, FE_READ_STATUS, &status);
>     sleep(1);
>     ++j;
>   } while((j < 4) && ((status & FE_HAS_LOCK) == 0));
> 
> What I'd really like to do is to wait for an event (poll()) that tells
> me that the tuning is complete (or that the card has timed out
> trying...) The "examples" section in the API documentation does mention
> a "completion event" but since the examples are outdated I don't know
> how to use it, or even if it still exists.
> 
> So, to my question:
> 
> Could someone be kind enough to direct me to updated documentation or to
> an example that uses these frontend events or, better still, post some
> example code here?

The API has FE_GET_EVENT, but this is some kind of broken concept
because the data associated with the event is from a queue and
thus always stale. I recommend the following (peudocode):

	fd = open("/dev/dvb/adapter0/frontend0", O_RDWR | O_NONBLOCK);
	ioctl(fd, FE_SET_FRONTEND, &params);
	timeout = now() + five_seconds;
	for (;;) {
		poll(fd, POLLPRI);
		ioctl(fd, FE_GET_EVENT, &params); // read and discard
		ioctl(fd, FE_READ_STATUS, &status);
		if (status & FE_HAS_LOCK || now() > timeout)
			break;
	}

When the status of the frontend changes an event is genrated and pushed
into the event queue, which wakes up poll(). FE_GET_EVENT and
poll() behaviour are in the documentation.

HTH,
Johannes



[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux