]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: cx23885: add simple suspend/resume
authorMatthias Schwarzott <zzam@gentoo.org>
Tue, 31 Dec 2024 09:37:25 +0000 (10:37 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 21 Feb 2025 09:33:09 +0000 (10:33 +0100)
After suspend-to-memory or suspend-to-disk, additional chips are no longer
reachable via i2c. Trying to tune to DVB-C on a cx23885 based
Hauppauge WinTV-HVR-4400-HD:

  si2165 8-0064: could not set chip_mode
  tda18271: performing RF tracking filter calibration

This patch implements the simplest possible suspend/resume that is
enough to tune to dvb-c channel after resume.
Afterwards dmesg looks like this:

  si2165 8-0064: downloading firmware from file 'dvb-demod-si2165.fw' \
    size=5768
  si2165 8-0064: si2165_upload_firmware: extracted patch_version=0x9a, \
    block_count=0x27, crc_expected=0xcc0a
  si2165 8-0064: fw load finished
  tda18271: performing RF tracking filter calibration
  tda18271: RF tracking filter calibration complete

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/pci/cx23885/cx23885-core.c

index c8705d786cddca3c538ce4d29d91a71abb51173c..a39f445ce22a0d0535df82fb5e2134a99a03ced1 100644 (file)
@@ -2231,6 +2231,28 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
        kfree(dev);
 }
 
+static int __maybe_unused cx23885_suspend(struct device *dev_d)
+{
+       struct pci_dev *pci_dev = to_pci_dev(dev_d);
+       struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
+       struct cx23885_dev *dev = to_cx23885(v4l2_dev);
+
+       cx23885_shutdown(dev);
+
+       return 0;
+}
+
+static int __maybe_unused cx23885_resume(struct device *dev_d)
+{
+       struct pci_dev *pci_dev = to_pci_dev(dev_d);
+       struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
+       struct cx23885_dev *dev = to_cx23885(v4l2_dev);
+
+       cx23885_reset(dev);
+
+       return 0;
+}
+
 static const struct pci_device_id cx23885_pci_tbl[] = {
        {
                /* CX23885 */
@@ -2250,11 +2272,14 @@ static const struct pci_device_id cx23885_pci_tbl[] = {
 };
 MODULE_DEVICE_TABLE(pci, cx23885_pci_tbl);
 
+static SIMPLE_DEV_PM_OPS(cx23885_pm_ops, cx23885_suspend, cx23885_resume);
+
 static struct pci_driver cx23885_pci_driver = {
-       .name     = "cx23885",
-       .id_table = cx23885_pci_tbl,
-       .probe    = cx23885_initdev,
-       .remove   = cx23885_finidev,
+       .name      = "cx23885",
+       .id_table  = cx23885_pci_tbl,
+       .probe     = cx23885_initdev,
+       .remove    = cx23885_finidev,
+       .driver.pm = &cx23885_pm_ops,
 };
 
 static int __init cx23885_init(void)