Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14178aa5 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab
Browse files

[media] V4L: soc-camera: start removing struct soc_camera_device from client drivers



Remove most trivial uses of struct soc_camera_device from most client
drivers, abstracting some of them inside inline functions. Next steps
will eliminate remaining uses and modify inline functions to not use
struct soc_camera_device.

Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 09362ec2
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -298,8 +298,7 @@ static struct v4l2_subdev_ops imx074_subdev_ops = {
	.video	= &imx074_subdev_video_ops,
};

static int imx074_video_probe(struct soc_camera_device *icd,
			      struct i2c_client *client)
static int imx074_video_probe(struct i2c_client *client)
{
	int ret;
	u16 id;
@@ -409,17 +408,10 @@ static int imx074_probe(struct i2c_client *client,
			const struct i2c_device_id *did)
{
	struct imx074 *priv;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct soc_camera_link *icl;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	int ret;

	if (!icd) {
		dev_err(&client->dev, "IMX074: missing soc-camera data!\n");
		return -EINVAL;
	}

	icl = to_soc_camera_link(icd);
	if (!icl) {
		dev_err(&client->dev, "IMX074: missing platform data!\n");
		return -EINVAL;
@@ -439,7 +431,7 @@ static int imx074_probe(struct i2c_client *client,

	priv->fmt	= &imx074_colour_fmts[0];

	ret = imx074_video_probe(icd, client);
	ret = imx074_video_probe(client);
	if (ret < 0) {
		kfree(priv);
		return ret;
@@ -451,8 +443,7 @@ static int imx074_probe(struct i2c_client *client,
static int imx074_remove(struct i2c_client *client)
{
	struct imx074 *priv = to_imx074(client);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	if (icl->free_bus)
		icl->free_bus(icl);
+11 −28
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)

	/*
	 * The caller provides a supported format, as verified per
	 * call to icd->try_fmt()
	 * call to .try_mbus_fmt()
	 */
	if (!ret)
		ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
@@ -474,19 +474,14 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl)
 * Interface active, can use i2c. If it fails, it can indeed mean, that
 * this wasn't our capture interface, so, we wait for the right one
 */
static int mt9m001_video_probe(struct soc_camera_device *icd,
static int mt9m001_video_probe(struct soc_camera_link *icl,
			       struct i2c_client *client)
{
	struct mt9m001 *mt9m001 = to_mt9m001(client);
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	s32 data;
	unsigned long flags;
	int ret;

	/* We must have a parent by now. And it cannot be a wrong one. */
	BUG_ON(!icd->parent ||
	       to_soc_camera_host(icd->parent)->nr != icd->iface);

	/* Enable the chip */
	data = reg_write(client, MT9M001_CHIP_ENABLE, 1);
	dev_dbg(&client->dev, "write: %d\n", data);
@@ -544,12 +539,8 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
	return v4l2_ctrl_handler_setup(&mt9m001->hdl);
}

static void mt9m001_video_remove(struct soc_camera_device *icd)
static void mt9m001_video_remove(struct soc_camera_link *icl)
{
	struct soc_camera_link *icl = to_soc_camera_link(icd);

	dev_dbg(icd->pdev, "Video removed: %p, %p\n",
		icd->parent, icd->vdev);
	if (icl->free_bus)
		icl->free_bus(icl);
}
@@ -594,8 +585,7 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
				struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	/* MT9M001 has all capture_format parameters fixed */
	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
@@ -610,9 +600,9 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
				const struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	const struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = soc_camera_from_i2c(client);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	/*
	 * Cannot use icd->current_fmt->host_fmt->bits_per_sample, because that
	 * is the number of bits, that the host has to sample, not the number of
@@ -658,17 +648,10 @@ static int mt9m001_probe(struct i2c_client *client,
			 const struct i2c_device_id *did)
{
	struct mt9m001 *mt9m001;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct soc_camera_link *icl;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	int ret;

	if (!icd) {
		dev_err(&client->dev, "MT9M001: missing soc-camera data!\n");
		return -EINVAL;
	}

	icl = to_soc_camera_link(icd);
	if (!icl) {
		dev_err(&client->dev, "MT9M001 driver needs platform data\n");
		return -EINVAL;
@@ -716,7 +699,7 @@ static int mt9m001_probe(struct i2c_client *client,
	mt9m001->rect.width	= MT9M001_MAX_WIDTH;
	mt9m001->rect.height	= MT9M001_MAX_HEIGHT;

	ret = mt9m001_video_probe(icd, client);
	ret = mt9m001_video_probe(icl, client);
	if (ret) {
		v4l2_ctrl_handler_free(&mt9m001->hdl);
		kfree(mt9m001);
@@ -728,11 +711,11 @@ static int mt9m001_probe(struct i2c_client *client,
static int mt9m001_remove(struct i2c_client *client)
{
	struct mt9m001 *mt9m001 = to_mt9m001(client);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	v4l2_device_unregister_subdev(&mt9m001->subdev);
	v4l2_ctrl_handler_free(&mt9m001->hdl);
	mt9m001_video_remove(icd);
	mt9m001_video_remove(icl);
	kfree(mt9m001);

	return 0;
+5 −19
Original line number Diff line number Diff line
@@ -784,19 +784,12 @@ static int mt9m111_init(struct mt9m111 *mt9m111)
 * Interface active, can use i2c. If it fails, it can indeed mean, that
 * this wasn't our capture interface, so, we wait for the right one
 */
static int mt9m111_video_probe(struct soc_camera_device *icd,
			       struct i2c_client *client)
static int mt9m111_video_probe(struct i2c_client *client)
{
	struct mt9m111 *mt9m111 = to_mt9m111(client);
	s32 data;
	int ret;

	/* We must have a parent by now. And it cannot be a wrong one. */
	BUG_ON(!icd->parent ||
	       to_soc_camera_host(icd->parent)->nr != icd->iface);

	mt9m111->lastpage = -1;

	data = reg_read(CHIP_VERSION);

	switch (data) {
@@ -883,8 +876,7 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
				struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
@@ -915,17 +907,10 @@ static int mt9m111_probe(struct i2c_client *client,
			 const struct i2c_device_id *did)
{
	struct mt9m111 *mt9m111;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct soc_camera_link *icl;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	int ret;

	if (!icd) {
		dev_err(&client->dev, "mt9m111: soc-camera data missing!\n");
		return -EINVAL;
	}

	icl = to_soc_camera_link(icd);
	if (!icl) {
		dev_err(&client->dev, "mt9m111: driver needs platform data\n");
		return -EINVAL;
@@ -968,8 +953,9 @@ static int mt9m111_probe(struct i2c_client *client,
	mt9m111->rect.width	= MT9M111_MAX_WIDTH;
	mt9m111->rect.height	= MT9M111_MAX_HEIGHT;
	mt9m111->fmt		= &mt9m111_colour_fmts[0];
	mt9m111->lastpage	= -1;

	ret = mt9m111_video_probe(icd, client);
	ret = mt9m111_video_probe(client);
	if (ret) {
		v4l2_ctrl_handler_free(&mt9m111->hdl);
		kfree(mt9m111);
+8 −14
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ static int mt9t031_set_params(struct i2c_client *client,

	/*
	 * The caller provides a supported format, as guaranteed by
	 * icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap()
	 * .try_mbus_fmt(), soc_camera_s_crop() and soc_camera_cropcap()
	 */
	if (ret >= 0)
		ret = reg_write(client, MT9T031_COLUMN_START, rect->left);
@@ -573,8 +573,7 @@ static int mt9t031_runtime_suspend(struct device *dev)
static int mt9t031_runtime_resume(struct device *dev)
{
	struct video_device *vdev = to_video_device(dev);
	struct soc_camera_device *icd = dev_get_drvdata(vdev->parent);
	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
	struct v4l2_subdev *sd = soc_camera_vdev_to_subdev(vdev);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct mt9t031 *mt9t031 = to_mt9t031(client);

@@ -684,8 +683,7 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd,
				struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
		V4L2_MBUS_PCLK_SAMPLE_FALLING | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
@@ -700,8 +698,7 @@ static int mt9t031_s_mbus_config(struct v4l2_subdev *sd,
				const struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	if (soc_camera_apply_board_flags(icl, cfg) &
	    V4L2_MBUS_PCLK_SAMPLE_FALLING)
@@ -737,17 +734,14 @@ static int mt9t031_probe(struct i2c_client *client,
			 const struct i2c_device_id *did)
{
	struct mt9t031 *mt9t031;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	int ret;

	if (icd) {
		struct soc_camera_link *icl = to_soc_camera_link(icd);
	if (!icl) {
		dev_err(&client->dev, "MT9T031 driver needs platform data\n");
		return -EINVAL;
	}
	}

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
		dev_warn(&adapter->dev,
+16 −29
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ struct mt9t112_priv {
	struct v4l2_subdev		 subdev;
	struct mt9t112_camera_info	*info;
	struct i2c_client		*client;
	struct soc_camera_device	 icd;
	struct v4l2_rect		 frame;
	const struct mt9t112_format	*format;
	int				 model;
@@ -306,38 +305,38 @@ static int mt9t112_clock_info(const struct i2c_client *client, u32 ext)
	n = (n >> 8) & 0x003f;

	enable = ((6000 > ext) || (54000 < ext)) ? "X" : "";
	dev_info(&client->dev, "EXTCLK          : %10u K %s\n", ext, enable);
	dev_dbg(&client->dev, "EXTCLK          : %10u K %s\n", ext, enable);

	vco = 2 * m * ext / (n+1);
	enable = ((384000 > vco) || (768000 < vco)) ? "X" : "";
	dev_info(&client->dev, "VCO             : %10u K %s\n", vco, enable);
	dev_dbg(&client->dev, "VCO             : %10u K %s\n", vco, enable);

	clk = vco / (p1+1) / (p2+1);
	enable = (96000 < clk) ? "X" : "";
	dev_info(&client->dev, "PIXCLK          : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "PIXCLK          : %10u K %s\n", clk, enable);

	clk = vco / (p3+1);
	enable = (768000 < clk) ? "X" : "";
	dev_info(&client->dev, "MIPICLK         : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "MIPICLK         : %10u K %s\n", clk, enable);

	clk = vco / (p6+1);
	enable = (96000 < clk) ? "X" : "";
	dev_info(&client->dev, "MCU CLK         : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "MCU CLK         : %10u K %s\n", clk, enable);

	clk = vco / (p5+1);
	enable = (54000 < clk) ? "X" : "";
	dev_info(&client->dev, "SOC CLK         : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "SOC CLK         : %10u K %s\n", clk, enable);

	clk = vco / (p4+1);
	enable = (70000 < clk) ? "X" : "";
	dev_info(&client->dev, "Sensor CLK      : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "Sensor CLK      : %10u K %s\n", clk, enable);

	clk = vco / (p7+1);
	dev_info(&client->dev, "External sensor : %10u K\n", clk);
	dev_dbg(&client->dev, "External sensor : %10u K\n", clk);

	clk = ext / (n+1);
	enable = ((2000 > clk) || (24000 < clk)) ? "X" : "";
	dev_info(&client->dev, "PFD             : %10u K %s\n", clk, enable);
	dev_dbg(&client->dev, "PFD             : %10u K %s\n", clk, enable);

	return 0;
}
@@ -982,8 +981,7 @@ static int mt9t112_g_mbus_config(struct v4l2_subdev *sd,
				 struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);

	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH |
@@ -998,8 +996,7 @@ static int mt9t112_s_mbus_config(struct v4l2_subdev *sd,
				 const struct v4l2_mbus_config *cfg)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl = to_soc_camera_link(icd);
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	struct mt9t112_priv *priv = to_mt9t112(client);

	if (soc_camera_apply_board_flags(icl, cfg) & V4L2_MBUS_PCLK_SAMPLE_RISING)
@@ -1029,17 +1026,12 @@ static struct v4l2_subdev_ops mt9t112_subdev_ops = {
	.video	= &mt9t112_subdev_video_ops,
};

static int mt9t112_camera_probe(struct soc_camera_device *icd,
				struct i2c_client *client)
static int mt9t112_camera_probe(struct i2c_client *client)
{
	struct mt9t112_priv *priv = to_mt9t112(client);
	const char          *devname;
	int                  chipid;

	/* We must have a parent by now. And it cannot be a wrong one. */
	BUG_ON(!icd->parent ||
	       to_soc_camera_host(icd->parent)->nr != icd->iface);

	/*
	 * check and show chip ID
	 */
@@ -1068,8 +1060,7 @@ static int mt9t112_probe(struct i2c_client *client,
			 const struct i2c_device_id *did)
{
	struct mt9t112_priv *priv;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct soc_camera_link *icl;
	struct soc_camera_link *icl = soc_camera_i2c_to_link(client);
	struct v4l2_rect rect = {
		.width = VGA_WIDTH,
		.height = VGA_HEIGHT,
@@ -1078,15 +1069,11 @@ static int mt9t112_probe(struct i2c_client *client,
	};
	int ret;

	if (!icd) {
		dev_err(&client->dev, "mt9t112: missing soc-camera data!\n");
	if (!icl || !icl->priv) {
		dev_err(&client->dev, "mt9t112: missing platform data!\n");
		return -EINVAL;
	}

	icl = to_soc_camera_link(icd);
	if (!icl || !icl->priv)
		return -EINVAL;

	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;
@@ -1095,7 +1082,7 @@ static int mt9t112_probe(struct i2c_client *client,

	v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);

	ret = mt9t112_camera_probe(icd, client);
	ret = mt9t112_camera_probe(client);
	if (ret)
		kfree(priv);

Loading