Commit 7f048750 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab
Browse files

media: atomisp: Remove custom ATOMISP_IOC_G_SENSOR_MODE_DATA ioctl



This ioctl returns a number of fixed sensor parameters +
a number of mode-specific parameters.

With libcamera these fixed parameters are instead stored in a table
with sensor-name to parameters mappings (camera_sensor_properties.cpp);
and the variable parameters can be derived from the set fmt.

So this custom ioctl is not necessary; and it currently has no users.

Remove the ioctl and all the sensor drivers xxxx_get_intg_factor()
helpers which return this info.

This is part of a patch-series which tries to remove atomisp specific /
custom code from the sensor drivers, with as end goal to make the atomisp
drivers regular camera sensor drivers.

Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 8b3332b2
Loading
Loading
Loading
Loading
+0 −140
Original line number Diff line number Diff line
@@ -259,140 +259,6 @@ static int gc0310_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
	return 0;
}

static int gc0310_get_intg_factor(struct i2c_client *client,
				  struct camera_mipi_info *info,
				  const struct gc0310_resolution *res)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct gc0310_device *dev = to_gc0310_sensor(sd);
	struct atomisp_sensor_mode_data *buf = &info->data;
	u16 val;
	u8 reg_val;
	int ret;
	unsigned int hori_blanking;
	unsigned int vert_blanking;
	unsigned int sh_delay;

	if (!info)
		return -EINVAL;

	/* pixel clock calculattion */
	dev->vt_pix_clk_freq_mhz = 14400000; // 16.8MHz
	buf->vt_pix_clk_freq_mhz = dev->vt_pix_clk_freq_mhz;
	dev_dbg(&client->dev, "vt_pix_clk_freq_mhz=%d\n", buf->vt_pix_clk_freq_mhz);

	/* get integration time */
	buf->coarse_integration_time_min = GC0310_COARSE_INTG_TIME_MIN;
	buf->coarse_integration_time_max_margin =
	    GC0310_COARSE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_min = GC0310_FINE_INTG_TIME_MIN;
	buf->fine_integration_time_max_margin =
	    GC0310_FINE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_def = GC0310_FINE_INTG_TIME_MIN;
	buf->read_mode = res->bin_mode;

	/* get the cropping and output resolution to ISP for this mode. */
	/* Getting crop_horizontal_start */
	ret =  gc0310_read_reg(client, GC0310_8BIT,
			       GC0310_H_CROP_START_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret =  gc0310_read_reg(client, GC0310_8BIT,
			       GC0310_H_CROP_START_L, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_start = val | (reg_val & 0xFF);
	dev_dbg(&client->dev, "crop_horizontal_start=%d\n", buf->crop_horizontal_start);

	/* Getting crop_vertical_start */
	ret =  gc0310_read_reg(client, GC0310_8BIT,
			       GC0310_V_CROP_START_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret =  gc0310_read_reg(client, GC0310_8BIT,
			       GC0310_V_CROP_START_L, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_start = val | (reg_val & 0xFF);
	dev_dbg(&client->dev, "crop_vertical_start=%d\n", buf->crop_vertical_start);

	/* Getting output_width */
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_H_OUTSIZE_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_H_OUTSIZE_L, &reg_val);
	if (ret)
		return ret;
	buf->output_width = val | (reg_val & 0xFF);
	dev_dbg(&client->dev, "output_width=%d\n", buf->output_width);

	/* Getting output_height */
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_V_OUTSIZE_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_V_OUTSIZE_L, &reg_val);
	if (ret)
		return ret;
	buf->output_height = val | (reg_val & 0xFF);
	dev_dbg(&client->dev, "output_height=%d\n", buf->output_height);

	buf->crop_horizontal_end = buf->crop_horizontal_start + buf->output_width - 1;
	buf->crop_vertical_end = buf->crop_vertical_start + buf->output_height - 1;
	dev_dbg(&client->dev, "crop_horizontal_end=%d\n", buf->crop_horizontal_end);
	dev_dbg(&client->dev, "crop_vertical_end=%d\n", buf->crop_vertical_end);

	/* Getting line_length_pck */
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_H_BLANKING_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_H_BLANKING_L, &reg_val);
	if (ret)
		return ret;
	hori_blanking = val | (reg_val & 0xFF);
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_SH_DELAY, &reg_val);
	if (ret)
		return ret;
	sh_delay = reg_val;
	buf->line_length_pck = buf->output_width + hori_blanking + sh_delay + 4;
	dev_dbg(&client->dev, "hori_blanking=%d sh_delay=%d line_length_pck=%d\n", hori_blanking,
		sh_delay, buf->line_length_pck);

	/* Getting frame_length_lines */
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_V_BLANKING_H, &reg_val);
	if (ret)
		return ret;
	val = (reg_val & 0xFF) << 8;
	ret = gc0310_read_reg(client, GC0310_8BIT,
			      GC0310_V_BLANKING_L, &reg_val);
	if (ret)
		return ret;
	vert_blanking = val | (reg_val & 0xFF);
	buf->frame_length_lines = buf->output_height + vert_blanking;
	dev_dbg(&client->dev, "vert_blanking=%d frame_length_lines=%d\n", vert_blanking,
		buf->frame_length_lines);

	buf->binning_factor_x = res->bin_factor_x ?
				res->bin_factor_x : 1;
	buf->binning_factor_y = res->bin_factor_y ?
				res->bin_factor_y : 1;
	return 0;
}

static int gc0310_set_gain(struct v4l2_subdev *sd, int gain)

{
@@ -889,12 +755,6 @@ static int gc0310_set_fmt(struct v4l2_subdev *sd,
		goto err;
	}

	ret = gc0310_get_intg_factor(client, gc0310_info, dev->res);
	if (ret) {
		dev_err(&client->dev, "failed to get integration_factor\n");
		goto err;
	}

err:
	mutex_unlock(&dev->input_lock);
	return ret;
+0 −113
Original line number Diff line number Diff line
@@ -220,114 +220,6 @@ static int gc2235_write_reg_array(struct i2c_client *client,
	return __gc2235_flush_reg_array(client, &ctrl);
}

static int gc2235_get_intg_factor(struct i2c_client *client,
				  struct camera_mipi_info *info,
				  const struct gc2235_resolution *res)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct gc2235_device *dev = to_gc2235_sensor(sd);
	struct atomisp_sensor_mode_data *buf = &info->data;
	u16 reg_val, reg_val_h;
	int ret;

	if (!info)
		return -EINVAL;

	/* pixel clock calculattion */
	buf->vt_pix_clk_freq_mhz = dev->vt_pix_clk_freq_mhz = 30000000;

	/* get integration time */
	buf->coarse_integration_time_min = GC2235_COARSE_INTG_TIME_MIN;
	buf->coarse_integration_time_max_margin =
	    GC2235_COARSE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_min = GC2235_FINE_INTG_TIME_MIN;
	buf->fine_integration_time_max_margin =
	    GC2235_FINE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_def = GC2235_FINE_INTG_TIME_MIN;
	buf->frame_length_lines = res->lines_per_frame;
	buf->line_length_pck = res->pixels_per_line;
	buf->read_mode = res->bin_mode;

	/* get the cropping and output resolution to ISP for this mode. */
	ret =  gc2235_read_reg(client, GC2235_8BIT,
			       GC2235_H_CROP_START_H, &reg_val_h);
	ret =  gc2235_read_reg(client, GC2235_8BIT,
			       GC2235_H_CROP_START_L, &reg_val);
	if (ret)
		return ret;

	buf->crop_horizontal_start = (reg_val_h << 8) | reg_val;

	ret =  gc2235_read_reg(client, GC2235_8BIT,
			       GC2235_V_CROP_START_H, &reg_val_h);
	ret =  gc2235_read_reg(client, GC2235_8BIT,
			       GC2235_V_CROP_START_L, &reg_val);
	if (ret)
		return ret;

	buf->crop_vertical_start = (reg_val_h << 8) | reg_val;

	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_H_OUTSIZE_H, &reg_val_h);
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_H_OUTSIZE_L, &reg_val);
	if (ret)
		return ret;
	buf->output_width = (reg_val_h << 8) | reg_val;

	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_V_OUTSIZE_H, &reg_val_h);
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_V_OUTSIZE_L, &reg_val);
	if (ret)
		return ret;
	buf->output_height = (reg_val_h << 8) | reg_val;

	buf->crop_horizontal_end = buf->crop_horizontal_start +
				   buf->output_width - 1;
	buf->crop_vertical_end = buf->crop_vertical_start +
				 buf->output_height - 1;

	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_HB_H, &reg_val_h);
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_HB_L, &reg_val);
	if (ret)
		return ret;

#if 0
	u16 dummy = (reg_val_h << 8) | reg_val;
#endif

	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_SH_DELAY_H, &reg_val_h);
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_SH_DELAY_L, &reg_val);

#if 0
	buf->line_length_pck = buf->output_width + 16 + dummy +
			       (((u16)reg_val_h << 8) | (u16)reg_val) + 4;
#endif
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_VB_H, &reg_val_h);
	ret = gc2235_read_reg(client, GC2235_8BIT,
			      GC2235_VB_L, &reg_val);
	if (ret)
		return ret;

#if 0
	buf->frame_length_lines = buf->output_height + 32 +
				  (((u16)reg_val_h << 8) | (u16)reg_val);
#endif
	buf->binning_factor_x = res->bin_factor_x ?
				res->bin_factor_x : 1;
	buf->binning_factor_y = res->bin_factor_y ?
				res->bin_factor_y : 1;
	return 0;
}

static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
				  int gain, int digitgain)

@@ -680,11 +572,6 @@ static int gc2235_set_fmt(struct v4l2_subdev *sd,
		goto err;
	}

	ret = gc2235_get_intg_factor(client, gc2235_info,
				     dev->res);
	if (ret)
		dev_err(&client->dev, "failed to get integration_factor\n");

err:
	mutex_unlock(&dev->input_lock);
	return ret;
+0 −96
Original line number Diff line number Diff line
@@ -612,96 +612,6 @@ static int mt9m114_res2size(struct v4l2_subdev *sd, int *h_size, int *v_size)
	return 0;
}

static int mt9m114_get_intg_factor(struct i2c_client *client,
				   struct camera_mipi_info *info,
				   const struct mt9m114_res_struct *res)
{
	struct atomisp_sensor_mode_data *buf;
	u32 reg_val;
	int ret;

	if (!info)
		return -EINVAL;

	buf = &info->data;

	ret =  mt9m114_read_reg(client, MISENSOR_32BIT,
				REG_PIXEL_CLK, &reg_val);
	if (ret)
		return ret;
	buf->vt_pix_clk_freq_mhz = reg_val;

	/* get integration time */
	buf->coarse_integration_time_min = MT9M114_COARSE_INTG_TIME_MIN;
	buf->coarse_integration_time_max_margin =
	    MT9M114_COARSE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_min = MT9M114_FINE_INTG_TIME_MIN;
	buf->fine_integration_time_max_margin =
	    MT9M114_FINE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_def = MT9M114_FINE_INTG_TIME_MIN;

	buf->frame_length_lines = res->lines_per_frame;
	buf->line_length_pck = res->pixels_per_line;
	buf->read_mode = res->bin_mode;

	/* get the cropping and output resolution to ISP for this mode. */
	ret =  mt9m114_read_reg(client, MISENSOR_16BIT,
				REG_H_START, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_start = reg_val;

	ret =  mt9m114_read_reg(client, MISENSOR_16BIT,
				REG_V_START, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_start = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_H_END, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_end = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_V_END, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_end = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_WIDTH, &reg_val);
	if (ret)
		return ret;
	buf->output_width = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_HEIGHT, &reg_val);
	if (ret)
		return ret;
	buf->output_height = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_TIMING_HTS, &reg_val);
	if (ret)
		return ret;
	buf->line_length_pck = reg_val;

	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
			       REG_TIMING_VTS, &reg_val);
	if (ret)
		return ret;
	buf->frame_length_lines = reg_val;

	buf->binning_factor_x = res->bin_factor_x ?
				res->bin_factor_x : 1;
	buf->binning_factor_y = res->bin_factor_y ?
				res->bin_factor_y : 1;
	return 0;
}

static int mt9m114_get_fmt(struct v4l2_subdev *sd,
			   struct v4l2_subdev_state *sd_state,
			   struct v4l2_subdev_format *format)
@@ -823,12 +733,6 @@ static int mt9m114_set_fmt(struct v4l2_subdev *sd,
			mt9m114_res[index].used = false;
		}
	}
	ret = mt9m114_get_intg_factor(c, mt9m114_info,
				      &mt9m114_res[res->res]);
	if (ret) {
		dev_err(&c->dev, "failed to get integration_factor\n");
		return -EINVAL;
	}
	/*
	 * mt9m114 - we don't poll for context switch
	 * because it does not happen with streaming disabled.
+0 −82
Original line number Diff line number Diff line
@@ -140,82 +140,6 @@ static int ov2680_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
	return 0;
}

static int ov2680_get_intg_factor(struct i2c_client *client,
				  struct camera_mipi_info *info,
				  const struct ov2680_resolution *res)
{
	struct atomisp_sensor_mode_data *buf = &info->data;
	unsigned int pix_clk_freq_hz;
	u32 reg_val;
	int ret;

	dev_dbg(&client->dev,  "++++ov2680_get_intg_factor\n");
	if (!info)
		return -EINVAL;

	/* pixel clock */
	pix_clk_freq_hz = res->pix_clk_freq * 1000000;

	buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz;

	/* get integration time */
	buf->coarse_integration_time_min = OV2680_COARSE_INTG_TIME_MIN;
	buf->coarse_integration_time_max_margin =
	    OV2680_COARSE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_min = OV2680_FINE_INTG_TIME_MIN;
	buf->fine_integration_time_max_margin =
	    OV2680_FINE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_def = OV2680_FINE_INTG_TIME_MIN;
	buf->frame_length_lines = res->lines_per_frame;
	buf->line_length_pck = res->pixels_per_line;
	buf->read_mode = res->bin_mode;

	/* get the cropping and output resolution to ISP for this mode. */
	ret =  ov2680_read_reg(client, 2,
			       OV2680_HORIZONTAL_START_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_start = reg_val;

	ret =  ov2680_read_reg(client, 2,
			       OV2680_VERTICAL_START_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_start = reg_val;

	ret = ov2680_read_reg(client, 2,
			      OV2680_HORIZONTAL_END_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_end = reg_val;

	ret = ov2680_read_reg(client, 2,
			      OV2680_VERTICAL_END_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_end = reg_val;

	ret = ov2680_read_reg(client, 2,
			      OV2680_HORIZONTAL_OUTPUT_SIZE_H, &reg_val);
	if (ret)
		return ret;
	buf->output_width = reg_val;

	ret = ov2680_read_reg(client, 2,
			      OV2680_VERTICAL_OUTPUT_SIZE_H, &reg_val);
	if (ret)
		return ret;
	buf->output_height = reg_val;

	buf->binning_factor_x = res->bin_factor_x ?
				(res->bin_factor_x * 2) : 1;
	buf->binning_factor_y = res->bin_factor_y ?
				(res->bin_factor_y * 2) : 1;
	return 0;
}

static long __ov2680_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
				  int gain, int digitgain)

@@ -818,12 +742,6 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
		goto err;
	}

	ret = ov2680_get_intg_factor(client, ov2680_info, res);
	if (ret) {
		dev_err(&client->dev, "failed to get integration factor\n");
		goto err;
	}

	/*
	 * recall flip functions to avoid flip registers
	 * were overridden by default setting
+0 −111
Original line number Diff line number Diff line
@@ -261,113 +261,6 @@ static int ov2722_write_reg_array(struct i2c_client *client,
	return __ov2722_flush_reg_array(client, &ctrl);
}

static int ov2722_get_intg_factor(struct i2c_client *client,
				  struct camera_mipi_info *info,
				  const struct ov2722_resolution *res)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct ov2722_device *dev = NULL;
	struct atomisp_sensor_mode_data *buf = &info->data;
	const unsigned int ext_clk_freq_hz = 19200000;
	const unsigned int pll_invariant_div = 10;
	unsigned int pix_clk_freq_hz;
	u16 pre_pll_clk_div;
	u16 pll_multiplier;
	u16 op_pix_clk_div;
	u16 reg_val;
	int ret;

	if (!info)
		return -EINVAL;

	dev = to_ov2722_sensor(sd);

	/* pixel clock calculattion */
	ret =  ov2722_read_reg(client, OV2722_8BIT,
			       OV2722_SC_CMMN_PLL_CTRL3, &pre_pll_clk_div);
	if (ret)
		return ret;

	ret =  ov2722_read_reg(client, OV2722_8BIT,
			       OV2722_SC_CMMN_PLL_MULTIPLIER, &pll_multiplier);
	if (ret)
		return ret;

	ret =  ov2722_read_reg(client, OV2722_8BIT,
			       OV2722_SC_CMMN_PLL_DEBUG_OPT, &op_pix_clk_div);
	if (ret)
		return ret;

	pre_pll_clk_div = (pre_pll_clk_div & 0x70) >> 4;
	if (!pre_pll_clk_div)
		return -EINVAL;

	pll_multiplier = pll_multiplier & 0x7f;
	op_pix_clk_div = op_pix_clk_div & 0x03;
	pix_clk_freq_hz = ext_clk_freq_hz / pre_pll_clk_div * pll_multiplier
			  * op_pix_clk_div / pll_invariant_div;

	dev->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
	buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz;

	/* get integration time */
	buf->coarse_integration_time_min = OV2722_COARSE_INTG_TIME_MIN;
	buf->coarse_integration_time_max_margin =
	    OV2722_COARSE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_min = OV2722_FINE_INTG_TIME_MIN;
	buf->fine_integration_time_max_margin =
	    OV2722_FINE_INTG_TIME_MAX_MARGIN;

	buf->fine_integration_time_def = OV2722_FINE_INTG_TIME_MIN;
	buf->frame_length_lines = res->lines_per_frame;
	buf->line_length_pck = res->pixels_per_line;
	buf->read_mode = res->bin_mode;

	/* get the cropping and output resolution to ISP for this mode. */
	ret =  ov2722_read_reg(client, OV2722_16BIT,
			       OV2722_H_CROP_START_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_start = reg_val;

	ret =  ov2722_read_reg(client, OV2722_16BIT,
			       OV2722_V_CROP_START_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_start = reg_val;

	ret = ov2722_read_reg(client, OV2722_16BIT,
			      OV2722_H_CROP_END_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_horizontal_end = reg_val;

	ret = ov2722_read_reg(client, OV2722_16BIT,
			      OV2722_V_CROP_END_H, &reg_val);
	if (ret)
		return ret;
	buf->crop_vertical_end = reg_val;

	ret = ov2722_read_reg(client, OV2722_16BIT,
			      OV2722_H_OUTSIZE_H, &reg_val);
	if (ret)
		return ret;
	buf->output_width = reg_val;

	ret = ov2722_read_reg(client, OV2722_16BIT,
			      OV2722_V_OUTSIZE_H, &reg_val);
	if (ret)
		return ret;
	buf->output_height = reg_val;

	buf->binning_factor_x = res->bin_factor_x ?
				res->bin_factor_x : 1;
	buf->binning_factor_y = res->bin_factor_y ?
				res->bin_factor_y : 1;
	return 0;
}

static long __ov2722_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
				  int gain, int digitgain)

@@ -812,10 +705,6 @@ static int ov2722_set_fmt(struct v4l2_subdev *sd,
		}
	}

	ret = ov2722_get_intg_factor(client, ov2722_info, dev->res);
	if (ret)
		dev_err(&client->dev, "failed to get integration_factor\n");

err:
	mutex_unlock(&dev->input_lock);
	return ret;
Loading