public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [linux-dvb] Power management and dvb framework
@ 2008-09-13 21:41 Devin Heitmueller
  2008-09-13 21:53 ` Steven Toth
  0 siblings, 1 reply; 6+ messages in thread
From: Devin Heitmueller @ 2008-09-13 21:41 UTC (permalink / raw)
  To: linux-dvb

Hello,

I have been doing some debugging of a USB DVB capture device, and I
was hoping someone could answer the following question about the DVB
framework:

What facilities exist to power down a device after a user is done with it?

Let's look at an example:

I have a dib0700 based device.  I specify my own frontend_attach()
function, which twiddles various GPIOs for the demodulator, and I have
a tuner_attach() function which I use to initialize the tuner.  Both
of these are called when I plug in the device.

I had to set various GPIOs to bring components out of reset or
properly set the sleep pin, but I do not see any way to put them back
to sleep after the user is done with them.

So in my case the USB device draws 100ma when plugged in, then goes to
320ma when I start streaming, but when I stop streaming I have no hook
to put the demodulator back to sleep so it *stays* at 320ma until I
unplug the device.

I know I have similar issues with em28xx based devices I am responsible for.

Is there some part of the framework I am simply missing?  Ideally I
would like to be able to power down the tuner and demodulator when the
user is done with them.  I know there are *_sleep functions but it's
not clear how they are used and it doesn't look like they are commonly
used by other devices.  Are the sleep functions called when a user
disconnects from the frontend, or is this purely a power management
call that is used when a user suspends his workstation?

Any advise anyone can give about the basic workflow here would be very useful.

Thanks,

Devin

-- 
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller

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

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

* Re: [linux-dvb] Power management and dvb framework
  2008-09-13 21:41 [linux-dvb] Power management and dvb framework Devin Heitmueller
@ 2008-09-13 21:53 ` Steven Toth
  2008-09-13 22:28   ` Devin Heitmueller
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Toth @ 2008-09-13 21:53 UTC (permalink / raw)
  To: Devin Heitmueller; +Cc: linux-dvb

Devin Heitmueller wrote:
> Hello,
> 
> I have been doing some debugging of a USB DVB capture device, and I
> was hoping someone could answer the following question about the DVB
> framework:
> 
> What facilities exist to power down a device after a user is done with it?
> 
> Let's look at an example:
> 
> I have a dib0700 based device.  I specify my own frontend_attach()
> function, which twiddles various GPIOs for the demodulator, and I have
> a tuner_attach() function which I use to initialize the tuner.  Both
> of these are called when I plug in the device.
> 
> I had to set various GPIOs to bring components out of reset or
> properly set the sleep pin, but I do not see any way to put them back
> to sleep after the user is done with them.

See below.

> 
> So in my case the USB device draws 100ma when plugged in, then goes to
> 320ma when I start streaming, but when I stop streaming I have no hook
> to put the demodulator back to sleep so it *stays* at 320ma until I
> unplug the device.

A common problem.

> 
> I know I have similar issues with em28xx based devices I am responsible for.
> 
> Is there some part of the framework I am simply missing?  Ideally I
> would like to be able to power down the tuner and demodulator when the
> user is done with them.  I know there are *_sleep functions but it's
> not clear how they are used and it doesn't look like they are commonly
> used by other devices.  Are the sleep functions called when a user
> disconnects from the frontend, or is this purely a power management
> call that is used when a user suspends his workstation?
> 
> Any advise anyone can give about the basic workflow here would be very useful.

I looked at some power stuff for the au0828 recently. I added a couple 
of callbacks in the USB_register struct IIRC, I had those drive the 
gpios. I don't recall the details but if you look at the definition of 
the structure you should see some power related callbacks. Actually, I'm 
not even sure if those patches got merged.

Also, the demod _init() and _sleep()  callbacks get called by dvb-core 
when the demod is required (or not). These might help.

Lastly, depending on how the driver implements DVB, is might use 
videobuf - or it might do it's own buffer handing. In case of the 
latter, look at the feed_start() feed_stop() functions and the struct 
specific feed counter that usually accompanies this... you could 
probably add some useful power related stuff with these indications.

- Steve



- Steve

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

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

* Re: [linux-dvb] Power management and dvb framework
  2008-09-13 21:53 ` Steven Toth
@ 2008-09-13 22:28   ` Devin Heitmueller
  2008-09-14  3:21     ` Andreas Oberritter
  0 siblings, 1 reply; 6+ messages in thread
From: Devin Heitmueller @ 2008-09-13 22:28 UTC (permalink / raw)
  To: Steven Toth; +Cc: linux-dvb

Hello Steven,

On Sat, Sep 13, 2008 at 5:53 PM, Steven Toth <stoth@linuxtv.org> wrote:
> I looked at some power stuff for the au0828 recently. I added a couple of
> callbacks in the USB_register struct IIRC, I had those drive the gpios. I
> don't recall the details but if you look at the definition of the structure
> you should see some power related callbacks. Actually, I'm not even sure if
> those patches got merged.
>
> Also, the demod _init() and _sleep()  callbacks get called by dvb-core when
> the demod is required (or not). These might help.
>
> Lastly, depending on how the driver implements DVB, is might use videobuf -
> or it might do it's own buffer handing. In case of the latter, look at the
> feed_start() feed_stop() functions and the struct specific feed counter that
> usually accompanies this... you could probably add some useful power related
> stuff with these indications.

Thanks for the suggestions.  At this point my best bet is to just
litter the code with some printk() messages so I can see what the
complete workflow is for the life of a device.  That will help alot
with figuring out where at what point which hooks get called.

Thanks,

Devin

-- 
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller

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

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

* Re: [linux-dvb] Power management and dvb framework
  2008-09-13 22:28   ` Devin Heitmueller
@ 2008-09-14  3:21     ` Andreas Oberritter
  2008-09-14 12:50       ` Devin Heitmueller
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Oberritter @ 2008-09-14  3:21 UTC (permalink / raw)
  To: Devin Heitmueller; +Cc: linux-dvb

Devin Heitmueller wrote:
> Thanks for the suggestions.  At this point my best bet is to just
> litter the code with some printk() messages so I can see what the
> complete workflow is for the life of a device.  That will help alot
> with figuring out where at what point which hooks get called.

The sleep callback gets called automatically some seconds after the last
user closed the frontend device.

Regards,
Andreas

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

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

* Re: [linux-dvb] Power management and dvb framework
  2008-09-14  3:21     ` Andreas Oberritter
@ 2008-09-14 12:50       ` Devin Heitmueller
  2008-09-14 16:03         ` Andreas Oberritter
  0 siblings, 1 reply; 6+ messages in thread
From: Devin Heitmueller @ 2008-09-14 12:50 UTC (permalink / raw)
  To: Andreas Oberritter; +Cc: linux-dvb

On Sat, Sep 13, 2008 at 11:21 PM, Andreas Oberritter <obi@linuxtv.org> wrote:
> The sleep callback gets called automatically some seconds after the last
> user closed the frontend device.

Great.  That sounds like the ideal place to bring everything down.  Is
that scheduled via a timer?  And does it still get called if the
frontend gets reopened before the timer expires?

Thanks,

Devin

-- 
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller

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

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

* Re: [linux-dvb] Power management and dvb framework
  2008-09-14 12:50       ` Devin Heitmueller
@ 2008-09-14 16:03         ` Andreas Oberritter
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Oberritter @ 2008-09-14 16:03 UTC (permalink / raw)
  To: Devin Heitmueller; +Cc: linux-dvb

Devin Heitmueller wrote:
> On Sat, Sep 13, 2008 at 11:21 PM, Andreas Oberritter <obi@linuxtv.org> wrote:
>> The sleep callback gets called automatically some seconds after the last
>> user closed the frontend device.
> 
> Great.  That sounds like the ideal place to bring everything down.  Is
> that scheduled via a timer?

No. I just saw that the timeout defaults to 0 seconds now. For each
frontend a kernel thread gets started when open() is called. After the
call to close(), the thread will be stopped after 'dvb_shutdown_timeout'
seconds. It compares the jiffies value to accomplish that. See
dvb_frontend_is_exiting() in dvb_frontend.c.

> And does it still get called if the
> frontend gets reopened before the timer expires?

No, and the old kernel thread will be reused.

Regards,
Andreas

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

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

end of thread, other threads:[~2008-09-14 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-13 21:41 [linux-dvb] Power management and dvb framework Devin Heitmueller
2008-09-13 21:53 ` Steven Toth
2008-09-13 22:28   ` Devin Heitmueller
2008-09-14  3:21     ` Andreas Oberritter
2008-09-14 12:50       ` Devin Heitmueller
2008-09-14 16:03         ` Andreas Oberritter

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