]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: mgb4: Added support for additional GMSL modules variants
authorMartin Tůma <martin.tuma@digiteqautomotive.com>
Mon, 27 Jan 2025 15:59:56 +0000 (16:59 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 21 Feb 2025 09:33:03 +0000 (10:33 +0100)
Added support for GMSL modules variants 3 and 4. Variant 3 is the same as
variant 2 from the driver's point of view. Variant 4 has "hardwired" daisy
chain loopback outputs and thus missing the v4l2 outputs.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/pci/mgb4/mgb4_core.c
drivers/media/pci/mgb4/mgb4_core.h

index f90ffc4dad523a6e33db3cd5fa3daa329e45568e..3ce6b717ca32048e230da1635c52a43a28ab8e63 100644 (file)
@@ -406,8 +406,9 @@ static int get_module_version(struct mgb4_dev *mgbdev)
                dev_err(dev, "unknown module type\n");
                return -EINVAL;
        }
-       fw_version = mgb4_read_reg(&mgbdev->video, 0xC4);
-       if (fw_version >> 24 != mgbdev->module_version >> 4) {
+       fw_version = mgb4_read_reg(&mgbdev->video, 0xC4) >> 24;
+       if ((MGB4_IS_FPDL3(mgbdev) && fw_version != 1) ||
+           (MGB4_IS_GMSL(mgbdev) && fw_version != 2)) {
                dev_err(dev, "module/firmware type mismatch\n");
                return -EINVAL;
        }
@@ -599,14 +600,18 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        rv = get_module_version(mgbdev);
        if (rv < 0)
                goto exit;
+       /* Propagate the module type(version) to the FPGA */
+       mgb4_write_reg(&mgbdev->video, 0xD4, mgbdev->module_version);
 
        /* Video input v4l2 devices */
        for (i = 0; i < MGB4_VIN_DEVICES; i++)
                mgbdev->vin[i] = mgb4_vin_create(mgbdev, i);
 
        /* Video output v4l2 devices */
-       for (i = 0; i < MGB4_VOUT_DEVICES; i++)
-               mgbdev->vout[i] = mgb4_vout_create(mgbdev, i);
+       if (MGB4_HAS_VOUT(mgbdev)) {
+               for (i = 0; i < MGB4_VOUT_DEVICES; i++)
+                       mgbdev->vout[i] = mgb4_vout_create(mgbdev, i);
+       }
 
        /* Triggers */
        mgbdev->indio_dev = mgb4_trigger_create(mgbdev);
index e86742d7b6c4352ac28d369c2e1fcd5daade7115..cc24068400a29054c365e5e4fee2a899548364f5 100644 (file)
 #define MGB4_VOUT_DEVICES 2
 
 #define MGB4_IS_GMSL(mgbdev) \
-       ((mgbdev)->module_version >> 4 == 2)
+       ((((mgbdev)->module_version >> 4) >= 2) && \
+        (((mgbdev)->module_version >> 4) <= 4))
 #define MGB4_IS_FPDL3(mgbdev) \
-       ((mgbdev)->module_version >> 4 == 1)
+       (((mgbdev)->module_version >> 4) == 1)
+#define MGB4_HAS_VOUT(mgbdev) \
+       ((((mgbdev)->module_version >> 4) >= 1) && \
+        (((mgbdev)->module_version >> 4) <= 3))
 
 struct mgb4_dma_channel {
        struct dma_chan *chan;