media: atomisp: change the code to properly wait for sensor
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 19 May 2020 08:35:38 +0000 (10:35 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 20 May 2020 12:51:29 +0000 (14:51 +0200)
The sensor should finish its init before atomisp driver, as
otherwise the atomisp driver won't be able to talk with it.

So, we need to turn atomisp_gmin_platform into a module
again, for it to not depend on atomisp driver to finish
probing, and add some delay at atomisp to let the sensor
driver to finish probing.

Yeah, this is hacky. The real solution here would be to use
the async framework, but for now, our goal is to make the
driver to work. So, let's postpone such change to be done
later.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/Makefile
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
drivers/staging/media/atomisp/pci/atomisp_v4l2.c

index 30b3168c4358c70cf9b20c4908a5f54d089f9f82..eedecd49bbf459cd2a779214f8a544216e529a0c 100644 (file)
@@ -3,6 +3,7 @@
 #
 obj-$(CONFIG_INTEL_ATOMISP) += i2c/
 obj-$(CONFIG_VIDEO_ATOMISP) += atomisp.o
+obj-$(CONFIG_VIDEO_ATOMISP) += pci/atomisp_gmin_platform.o
 
 # While on staging, keep debug enabled
 DEFINES += -DDEBUG
@@ -23,7 +24,6 @@ atomisp-objs += \
        pci/atomisp_subdev.o \
        pci/atomisp_tpg.o \
        pci/atomisp_v4l2.o \
-       pci/atomisp_gmin_platform.o \
        pci/sh_css_firmware.o \
        pci/sh_css_host_data.o \
        pci/sh_css_hrt.o \
index 9e9dc9a564c5cbbabd1334aeb587c894bc8a9900..b096b7d304634d66e02ff79da87bee6bc08cc27d 100644 (file)
@@ -1076,3 +1076,6 @@ static void isp_pm_cap_fixup(struct pci_dev *dev)
        dev->pm_cap = 0;
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0f38, isp_pm_cap_fixup);
+
+MODULE_DESCRIPTION("Ancillary routines for binding ACPI devices");
+MODULE_LICENSE("GPL");
index 4395ca0e3e11a709e0f396081c8004b27a0ba3bf..592c41bb516603b3f2f5aa7598120eacb5a218b4 100644 (file)
@@ -1083,6 +1083,22 @@ static int atomisp_subdev_probe(struct atomisp_device *isp)
                return 0;
        }
 
+       /* FIXME: should return -EPROBE_DEFER if not all subdevs were probed */
+       for (count = 0; count < SUBDEV_WAIT_TIMEOUT_MAX_COUNT; count++) {
+               int camera_count = 0;
+               for (subdevs = pdata->subdevs; subdevs->type; ++subdevs) {
+                       if (subdevs->type == RAW_CAMERA ||
+                           subdevs->type == SOC_CAMERA)
+                               camera_count ++;
+               }
+               if (camera_count)
+                       break;
+               msleep(SUBDEV_WAIT_TIMEOUT);
+               count++;
+       }
+       /* Wait more time to give more time for subdev init code to finish */
+       msleep(5 * SUBDEV_WAIT_TIMEOUT);
+
        /* FIXME: should, instead, use I2C probe */
 
        for (subdevs = pdata->subdevs; subdevs->type; ++subdevs) {
@@ -1192,16 +1208,6 @@ static int atomisp_subdev_probe(struct atomisp_device *isp)
                }
        }
 
-       /* FIXME: should return -EPROBE_DEFER if not all subdevs were probed */
-       for (count = 0; count < SUBDEV_WAIT_TIMEOUT_MAX_COUNT; count++) {
-               if (isp->input_cnt)
-                       break;
-               msleep(SUBDEV_WAIT_TIMEOUT);
-               count++;
-       }
-       /* Wait more time to give more time for subdev init code */
-       msleep(5 * SUBDEV_WAIT_TIMEOUT);
-
        /*
         * HACK: Currently VCM belongs to primary sensor only, but correct
         * approach must be to acquire from platform code which sensor