media: v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 3 Jul 2018 21:19:27 +0000 (17:19 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 4 Oct 2018 20:06:15 +0000 (16:06 -0400)
The CSI-2 bus may use either D-PHY or C-PHY. Make this visible in media
bus enum.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
27 files changed:
drivers/gpu/ipu-v3/ipu-csi.c
drivers/media/i2c/adv7180.c
drivers/media/i2c/ov5640.c
drivers/media/i2c/ov5645.c
drivers/media/i2c/ov7251.c
drivers/media/i2c/s5c73m3/s5c73m3-core.c
drivers/media/i2c/s5k5baf.c
drivers/media/i2c/s5k6aa.c
drivers/media/i2c/smiapp/smiapp-core.c
drivers/media/i2c/soc_camera/ov5642.c
drivers/media/i2c/tc358743.c
drivers/media/pci/intel/ipu3/ipu3-cio2.c
drivers/media/platform/cadence/cdns-csi2rx.c
drivers/media/platform/cadence/cdns-csi2tx.c
drivers/media/platform/marvell-ccic/mcam-core.c
drivers/media/platform/marvell-ccic/mmp-driver.c
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/pxa_camera.c
drivers/media/platform/rcar-vin/rcar-csi2.c
drivers/media/platform/soc_camera/soc_mediabus.c
drivers/media/platform/stm32/stm32-dcmi.c
drivers/media/platform/ti-vpe/cal.c
drivers/media/v4l2-core/v4l2-fwnode.c
drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/imx/imx6-mipi-csi2.c
drivers/staging/media/imx074/imx074.c
include/media/v4l2-mediabus.h

index 954eefe..aa0e30a 100644 (file)
@@ -232,7 +232,7 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code,
        case MEDIA_BUS_FMT_BGR565_2X8_LE:
        case MEDIA_BUS_FMT_RGB565_2X8_BE:
        case MEDIA_BUS_FMT_RGB565_2X8_LE:
-               if (mbus_type == V4L2_MBUS_CSI2)
+               if (mbus_type == V4L2_MBUS_CSI2_DPHY)
                        cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
                else
                        cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
@@ -359,7 +359,7 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
                else
                        csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
                break;
-       case V4L2_MBUS_CSI2:
+       case V4L2_MBUS_CSI2_DPHY:
                /*
                 * MIPI CSI-2 requires non gated clock mode, all other
                 * parameters are not applicable for MIPI CSI-2 bus.
@@ -611,7 +611,7 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc,
        if (vc > 3)
                return -EINVAL;
 
-       ret = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code, V4L2_MBUS_CSI2);
+       ret = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code, V4L2_MBUS_CSI2_DPHY);
        if (ret < 0)
                return ret;
 
index 5a10ce3..99697ba 100644 (file)
@@ -752,7 +752,7 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
        struct adv7180_state *state = to_state(sd);
 
        if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
-               cfg->type = V4L2_MBUS_CSI2;
+               cfg->type = V4L2_MBUS_CSI2_DPHY;
                cfg->flags = V4L2_MBUS_CSI2_1_LANE |
                                V4L2_MBUS_CSI2_CHANNEL_0 |
                                V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
index 664ffac..73a4bd7 100644 (file)
@@ -1820,7 +1820,7 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
                        goto power_off;
 
                /* We're done here for DVP bus, while CSI-2 needs setup. */
-               if (sensor->ep.bus_type != V4L2_MBUS_CSI2)
+               if (sensor->ep.bus_type != V4L2_MBUS_CSI2_DPHY)
                        return 0;
 
                /*
@@ -1867,7 +1867,7 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
                usleep_range(500, 1000);
 
        } else {
-               if (sensor->ep.bus_type == V4L2_MBUS_CSI2) {
+               if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
                        /* Reset MIPI bus settings to their default values. */
                        ov5640_write_reg(sensor,
                                         OV5640_REG_IO_MIPI_CTRL00, 0x58);
@@ -2625,7 +2625,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
                        sensor->pending_fmt_change = false;
                }
 
-               if (sensor->ep.bus_type == V4L2_MBUS_CSI2)
+               if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
                        ret = ov5640_set_stream_mipi(sensor, enable);
                else
                        ret = ov5640_set_stream_dvp(sensor, enable);
index 1722cda..5eba8dd 100644 (file)
@@ -1127,7 +1127,7 @@ static int ov5645_probe(struct i2c_client *client,
                return ret;
        }
 
-       if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) {
+       if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(dev, "invalid bus type, must be CSI2\n");
                return -EINVAL;
        }
index d3ebb75..0c10203 100644 (file)
@@ -1279,9 +1279,9 @@ static int ov7251_probe(struct i2c_client *client)
                return ret;
        }
 
-       if (ov7251->ep.bus_type != V4L2_MBUS_CSI2) {
+       if (ov7251->ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(dev, "invalid bus type (%u), must be CSI2 (%u)\n",
-                       ov7251->ep.bus_type, V4L2_MBUS_CSI2);
+                       ov7251->ep.bus_type, V4L2_MBUS_CSI2_DPHY);
                return -EINVAL;
        }
 
index c414519..ed7348a 100644 (file)
@@ -1644,7 +1644,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
        if (ret)
                return ret;
 
-       if (ep.bus_type != V4L2_MBUS_CSI2) {
+       if (ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(dev, "unsupported bus type\n");
                return -EINVAL;
        }
index 5007c96..4c41a77 100644 (file)
@@ -766,7 +766,7 @@ static int s5k5baf_hw_set_video_bus(struct s5k5baf *state)
 {
        u16 en_pkts;
 
-       if (state->bus_type == V4L2_MBUS_CSI2)
+       if (state->bus_type == V4L2_MBUS_CSI2_DPHY)
                en_pkts = EN_PACKETS_CSI2;
        else
                en_pkts = 0;
@@ -1875,7 +1875,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
        state->bus_type = ep.bus_type;
 
        switch (state->bus_type) {
-       case V4L2_MBUS_CSI2:
+       case V4L2_MBUS_CSI2_DPHY:
                state->nlanes = ep.bus.mipi_csi2.num_data_lanes;
                break;
        case V4L2_MBUS_PARALLEL:
index 63cf8db..ab26f54 100644 (file)
@@ -688,7 +688,7 @@ static int s5k6aa_configure_video_bus(struct s5k6aa *s5k6aa,
         * but there is nothing indicating how to switch between both
         * in the datasheet. For now default BT.601 interface is assumed.
         */
-       if (bus_type == V4L2_MBUS_CSI2)
+       if (bus_type == V4L2_MBUS_CSI2_DPHY)
                cfg = nlanes;
        else if (bus_type != V4L2_MBUS_PARALLEL)
                return -EINVAL;
index bccbf4c..69495c6 100644 (file)
@@ -2780,7 +2780,7 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
                goto out_err;
 
        switch (bus_cfg->bus_type) {
-       case V4L2_MBUS_CSI2:
+       case V4L2_MBUS_CSI2_DPHY:
                hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
                hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
                break;
index c6c41b0..0931898 100644 (file)
@@ -912,7 +912,7 @@ static int ov5642_get_selection(struct v4l2_subdev *sd,
 static int ov5642_g_mbus_config(struct v4l2_subdev *sd,
                                struct v4l2_mbus_config *cfg)
 {
-       cfg->type = V4L2_MBUS_CSI2;
+       cfg->type = V4L2_MBUS_CSI2_DPHY;
        cfg->flags = V4L2_MBUS_CSI2_2_LANE | V4L2_MBUS_CSI2_CHANNEL_0 |
                                        V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 
index 7415915..0834f25 100644 (file)
@@ -1607,7 +1607,7 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd,
 {
        struct tc358743_state *state = to_state(sd);
 
-       cfg->type = V4L2_MBUS_CSI2;
+       cfg->type = V4L2_MBUS_CSI2_DPHY;
 
        /* Support for non-continuous CSI-2 clock is missing in the driver */
        cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
@@ -1922,7 +1922,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
                goto put_node;
        }
 
-       if (endpoint->bus_type != V4L2_MBUS_CSI2 ||
+       if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY ||
            endpoint->bus.mipi_csi2.num_data_lanes == 0 ||
            endpoint->nr_of_link_frequencies == 0) {
                dev_err(dev, "missing CSI-2 properties in endpoint\n");
index 06b4222..452eb9b 100644 (file)
@@ -1482,7 +1482,7 @@ static int cio2_fwnode_parse(struct device *dev,
        struct sensor_async_subdev *s_asd =
                        container_of(asd, struct sensor_async_subdev, asd);
 
-       if (vep->bus_type != V4L2_MBUS_CSI2) {
+       if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(dev, "Only CSI2 bus type is currently supported\n");
                return -EINVAL;
        }
index da3eb34..0776a34 100644 (file)
@@ -378,7 +378,7 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx)
                return ret;
        }
 
-       if (v4l2_ep.bus_type != V4L2_MBUS_CSI2) {
+       if (v4l2_ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(csi2rx->dev, "Unsupported media bus type: 0x%x\n",
                        v4l2_ep.bus_type);
                of_node_put(ep);
index 40d0de6..6224daf 100644 (file)
@@ -446,7 +446,7 @@ static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx)
                goto out;
        }
 
-       if (v4l2_ep.bus_type != V4L2_MBUS_CSI2) {
+       if (v4l2_ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(csi2tx->dev, "Unsupported media bus type: 0x%x\n",
                        v4l2_ep.bus_type);
                ret = -EINVAL;
index f8e1af1..f1b3018 100644 (file)
@@ -794,7 +794,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
        /*
         * This field controls the generation of EOF(DVP only)
         */
-       if (cam->bus_type != V4L2_MBUS_CSI2)
+       if (cam->bus_type != V4L2_MBUS_CSI2_DPHY)
                mcam_reg_set_bit(cam, REG_CTRL0,
                                C0_EOF_VSYNC | C0_VEDGE_CTRL);
 }
@@ -1023,7 +1023,7 @@ static int mcam_read_setup(struct mcam_camera *cam)
                cam->calc_dphy(cam);
        cam_dbg(cam, "camera: DPHY sets: dphy3=0x%x, dphy5=0x%x, dphy6=0x%x\n",
                        cam->dphy[0], cam->dphy[1], cam->dphy[2]);
-       if (cam->bus_type == V4L2_MBUS_CSI2)
+       if (cam->bus_type == V4L2_MBUS_CSI2_DPHY)
                mcam_enable_mipi(cam);
        else
                mcam_disable_mipi(cam);
index 41968cd..70a2833 100644 (file)
@@ -362,7 +362,7 @@ static int mmpcam_probe(struct platform_device *pdev)
        mcam->mclk_div = pdata->mclk_div;
        mcam->bus_type = pdata->bus_type;
        mcam->dphy = pdata->dphy;
-       if (mcam->bus_type == V4L2_MBUS_CSI2) {
+       if (mcam->bus_type == V4L2_MBUS_CSI2_DPHY) {
                cam->mipi_clk = devm_clk_get(mcam->dev, "mipi");
                if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0))
                        return PTR_ERR(cam->mipi_clk);
index f5dde87..77fb798 100644 (file)
@@ -2054,7 +2054,7 @@ static int isp_fwnode_parse(struct device *dev,
                        dev_dbg(dev, "CSI-1/CCP-2 configuration\n");
                        csi1 = true;
                        break;
-               case V4L2_MBUS_CSI2:
+               case V4L2_MBUS_CSI2_DPHY:
                        dev_dbg(dev, "CSI-2 configuration\n");
                        csi1 = false;
                        break;
index 2f083ac..6f01d09 100644 (file)
@@ -633,7 +633,7 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cf
                mode = common_flags & (V4L2_MBUS_MASTER | V4L2_MBUS_SLAVE);
                return (!hsync || !vsync || !pclk || !data || !mode) ?
                        0 : common_flags;
-       case V4L2_MBUS_CSI2:
+       case V4L2_MBUS_CSI2_DPHY:
                mipi_lanes = common_flags & V4L2_MBUS_CSI2_LANES;
                mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |
                                             V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
index 75ebd9c..25edc2e 100644 (file)
@@ -714,7 +714,7 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,
        if (vep->base.port || vep->base.id)
                return -ENOTCONN;
 
-       if (vep->bus_type != V4L2_MBUS_CSI2) {
+       if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
                dev_err(priv->dev, "Unsupported bus: %u\n", vep->bus_type);
                return -EINVAL;
        }
index 0ad4b28..be74008 100644 (file)
@@ -503,7 +503,7 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
                mode = common_flags & (V4L2_MBUS_MASTER | V4L2_MBUS_SLAVE);
                return (!hsync || !vsync || !pclk || !data || !mode) ?
                        0 : common_flags;
-       case V4L2_MBUS_CSI2:
+       case V4L2_MBUS_CSI2_DPHY:
                mipi_lanes = common_flags & V4L2_MBUS_CSI2_LANES;
                mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |
                                             V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
index 48f514d..9719a2e 100644 (file)
@@ -1663,7 +1663,7 @@ static int dcmi_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       if (ep.bus_type == V4L2_MBUS_CSI2) {
+       if (ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
                dev_err(&pdev->dev, "CSI bus not supported\n");
                return -ENODEV;
        }
index 51f6043..95a093f 100644 (file)
@@ -1710,7 +1710,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
        }
        v4l2_fwnode_endpoint_parse(of_fwnode_handle(remote_ep), endpoint);
 
-       if (endpoint->bus_type != V4L2_MBUS_CSI2) {
+       if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY) {
                ctx_err(ctx, "Port:%d sub-device %pOFn is not a CSI2 device\n",
                        inst, sensor_node);
                goto cleanup_exit;
index 104ef7f..5416221 100644 (file)
@@ -115,7 +115,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
        }
 
        bus->flags = flags;
-       vep->bus_type = V4L2_MBUS_CSI2;
+       vep->bus_type = V4L2_MBUS_CSI2_DPHY;
 
        return 0;
 }
index bca1384..beb7c12 100644 (file)
@@ -124,7 +124,7 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev)
 
 static inline bool is_parallel_bus(struct v4l2_fwnode_endpoint *ep)
 {
-       return ep->bus_type != V4L2_MBUS_CSI2;
+       return ep->bus_type != V4L2_MBUS_CSI2_DPHY;
 }
 
 static inline bool is_parallel_16bit_bus(struct v4l2_fwnode_endpoint *ep)
index d60a52c..6a1cee5 100644 (file)
@@ -563,7 +563,7 @@ static int csi2_parse_endpoint(struct device *dev,
                return -EINVAL;
        }
 
-       if (vep->bus_type != V4L2_MBUS_CSI2) {
+       if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
                v4l2_err(&csi2->sd, "invalid bus type, must be MIPI CSI2\n");
                return -EINVAL;
        }
index c525690..1676c16 100644 (file)
@@ -262,7 +262,7 @@ static int imx074_s_power(struct v4l2_subdev *sd, int on)
 static int imx074_g_mbus_config(struct v4l2_subdev *sd,
                                struct v4l2_mbus_config *cfg)
 {
-       cfg->type = V4L2_MBUS_CSI2;
+       cfg->type = V4L2_MBUS_CSI2_DPHY;
        cfg->flags = V4L2_MBUS_CSI2_2_LANE |
                V4L2_MBUS_CSI2_CHANNEL_0 |
                V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
index 4bbb5f3..26e1c64 100644 (file)
  *                     also be used for BT.1120
  * @V4L2_MBUS_CSI1:    MIPI CSI-1 serial interface
  * @V4L2_MBUS_CCP2:    CCP2 (Compact Camera Port 2)
- * @V4L2_MBUS_CSI2:    MIPI CSI-2 serial interface
+ * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY
+ * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY
  */
 enum v4l2_mbus_type {
        V4L2_MBUS_PARALLEL,
        V4L2_MBUS_BT656,
        V4L2_MBUS_CSI1,
        V4L2_MBUS_CCP2,
-       V4L2_MBUS_CSI2,
+       V4L2_MBUS_CSI2_DPHY,
+       V4L2_MBUS_CSI2_CPHY,
 };
 
 /**