Oliver Endriss wrote: > Julian Scheel wrote: > >> Oliver Endriss schrieb: >> >>> Julian Scheel wrote: >>> >>> >>>> Attached is a patch with adds full support for suspend/resume in budget-av. >>>> Actually only the CI interface needs to be reinitialised as all the tuner >>>> stuff gets reinitialised at the next tuning-process anyway. >>>> So this patch should be ready to go pretty straightforward into head. >>>> >>>> >>> Please post the sub-system ids of the cards you tested and which power >>> states you tested. >>> >>> >> Going to look up the IDs later, when I have access to my dev-system. >> But it should be all current KNC DVB-C and DVB-S cards. >> >>>> diff -r c45e373bbca3 linux/drivers/media/common/saa7146_core.c >>>> --- a/linux/drivers/media/common/saa7146_core.c Sat Jul 28 00:06:44 2007 -0300 >>>> +++ b/linux/drivers/media/common/saa7146_core.c Tue Aug 07 23:22:54 2007 +0200 >>>> @@ -515,6 +515,28 @@ static void saa7146_remove_one(struct pc >>>> saa7146_num--; >>>> } >>>> >>>> +static int saa7146_suspend(struct pci_dev *pdev) >>>> +{ >>>> + struct saa7146_dev* dev = pci_get_drvdata(pdev); >>>> + DEB_EE(("dev:%p\n",dev)); >>>> + int err; >>>> + >>>> + err = dev->ext->suspend(dev); >>>> >>>> >>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>> Causes an oops if the card driver did not set the suspend hook. >>> >>> Fix: >>> int err = -EBUSY; >>> if (dev->ext->suspend) >>> err = dev->ext->suspend(dev); >>> >>> >> Agreed (c: >> >>>> + >>>> + return err; >>>> +} >>>> + >>>> +static int saa7146_resume(struct pci_dev *pdev) >>>> +{ >>>> + struct saa7146_dev* dev = pci_get_drvdata(pdev); >>>> + DEB_EE(("dev:%p\n",dev)); >>>> + int err; >>>> + >>>> + err = dev->ext->resume(dev); >>>> >>>> >>> ditto >>> >>> IMO this patch can only work with S1 state. Higher states turn off PCI >>> power and require re-initialization of saa7146, demod, tuner etc. >>> See other drivers which fully implement suspend/resume. >>> >>> >> Works perfectly fine with S3-state for me. Actually S3 always worked >> fine, only ci interface did not work anymore after S3, that is fixed >> with this patch. >> > > Hm, I did some tests with budget.c: > - "echo standby > /sys/power/state" works > - "echo mem > /sys/power/state" does not work! > - "echo disk > /sys/power/state" does not work! > I did for the Mantis branch a working solution for mem and disk cases. I haven't tested standby yet, but I think that it should be easy to extend if it doesn't work yet. I used linux/Documentation/power/*.txt while trying to understand how to implement suspend/resume. On my opinion, the easiest way to make standby+mem+disk work, is to implement suspend() so, that you assume that you might lose the power if the source transition is D0. If the source transition state is another one, you just turn some power off, but don't touch the saved state that resume() needs. (My implementation doesn't handle source transition at all now, because of my limited time.) Then you must implement resume() so, that it assumes, that you are recovering from a power loss. You might try to optimize resume() by checking from the device or from some previous kernel state, whether the device has actually lost it's power or not. My Mantis suspend/resume altered too many files, and thus it isn't final yet, but it is a working although not perfect version. In Linux code, there is a more simple PCI suspend/resume implementation in linux/drivers/pci/pci-driver.c. pci_device_suspend(): this does a very simple and basic PCI suspend operation. pci_default_resume(): this does a very simple and basic PCI resume operation. So I will try to learn from them some day to lessen changes in mantis_pci.c. My personal idea for the responsibilities is that: pci_save_state() and pci_restore_state() and other function calls found in pci-driver.c will handle saving and restoring PCI state, although I absolute must copy them into mantis_pci.c. Then on resume, I have to restore non-pci states, I mean those that aren't restored by pci_restore_state(), pci_set_master() and such. In Mantis there is according to Manu at least tuner power setting and retuning. I don't know the working and optimally small solution yet that Manu requires: there is still testing to be done for me in Mantis. With a very small understanding, I have been able to implement a working patch though. So I'd suggest for you to check out drivers/pci/pci-driver.c first to implement similar PCI functionality into budget-av. That might fix S2MEM and S2DISK. Or then there is still something more that has to be done. With my implementation I can use Kaffeine so, that after S2DISK, Kaffeine will continue showing the channel that it showed before. Kaffeine doesn't have to retune or restart DMA transfer. So only some frames were lost. Kaffeine didn't work properly with USB based sound output, and thus I needed motherboard internal sound output for the tests. > It works if the PCI bus stays 'on', i.e. the card is not powered-off. > So there is much more to be done if we want to support power states > properly. > > Btw, could you test if the CI works without reinitialisation if you > apply the attached patch? I can't test it. Without this patch the kernel > thread will die and the CI does not work anymore... > > CU > Oliver > > Best Regards and Happy Testing, Marko Ristola > ------------------------------------------------------------------------ > > _______________________________________________ > linux-dvb mailing list > linux-dvb@xxxxxxxxxxx > http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb _______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb