media: v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
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>
This commit is contained in:
		
							parent
							
								
									bf63856a48
								
							
						
					
					
						commit
						2d95e7ed07
					
				| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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: | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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"); | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -75,14 +75,16 @@ | ||||
|  *			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, | ||||
| }; | ||||
| 
 | ||||
| /**
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user