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

Commit 4471109e authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

media: convert g/s_parm to g/s_frame_interval in subdevs



Convert all g/s_parm calls to g/s_frame_interval. This allows us
to remove the g/s_parm ops since those are a duplicate of
g/s_frame_interval.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 672de9a7
Loading
Loading
Loading
Loading
+9 −20
Original line number Original line Diff line number Diff line
@@ -364,33 +364,22 @@ static int mt9v011_set_fmt(struct v4l2_subdev *sd,
	return 0;
	return 0;
}
}


static int mt9v011_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int mt9v011_g_frame_interval(struct v4l2_subdev *sd,
				    struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;

	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	memset(cp, 0, sizeof(struct v4l2_captureparm));
	cp->capability = V4L2_CAP_TIMEPERFRAME;
	calc_fps(sd,
	calc_fps(sd,
		 &cp->timeperframe.numerator,
		 &ival->interval.numerator,
		 &cp->timeperframe.denominator);
		 &ival->interval.denominator);


	return 0;
	return 0;
}
}


static int mt9v011_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int mt9v011_s_frame_interval(struct v4l2_subdev *sd,
				    struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &ival->interval;
	struct v4l2_fract *tpf = &cp->timeperframe;
	u16 speed;
	u16 speed;


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;
	if (cp->extendedmode != 0)
		return -EINVAL;

	speed = calc_speed(sd, tpf->numerator, tpf->denominator);
	speed = calc_speed(sd, tpf->numerator, tpf->denominator);


	mt9v011_write(sd, R0A_MT9V011_CLK_SPEED, speed);
	mt9v011_write(sd, R0A_MT9V011_CLK_SPEED, speed);
@@ -469,8 +458,8 @@ static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
};
};


static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
	.g_parm = mt9v011_g_parm,
	.g_frame_interval = mt9v011_g_frame_interval,
	.s_parm = mt9v011_s_parm,
	.s_frame_interval = mt9v011_s_frame_interval,
};
};


static const struct v4l2_subdev_pad_ops mt9v011_pad_ops = {
static const struct v4l2_subdev_pad_ops mt9v011_pad_ops = {
+11 −22
Original line number Original line Diff line number Diff line
@@ -201,7 +201,7 @@ struct ov6650 {
	struct v4l2_rect	rect;		/* sensor cropping window */
	struct v4l2_rect	rect;		/* sensor cropping window */
	unsigned long		pclk_limit;	/* from host */
	unsigned long		pclk_limit;	/* from host */
	unsigned long		pclk_max;	/* from resolution and format */
	unsigned long		pclk_max;	/* from resolution and format */
	struct v4l2_fract	tpf;		/* as requested with s_parm */
	struct v4l2_fract	tpf;		/* as requested with s_frame_interval */
	u32 code;
	u32 code;
	enum v4l2_colorspace	colorspace;
	enum v4l2_colorspace	colorspace;
};
};
@@ -723,42 +723,31 @@ static int ov6650_enum_mbus_code(struct v4l2_subdev *sd,
	return 0;
	return 0;
}
}


static int ov6650_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int ov6650_g_frame_interval(struct v4l2_subdev *sd,
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct ov6650 *priv = to_ov6650(client);
	struct ov6650 *priv = to_ov6650(client);
	struct v4l2_captureparm *cp = &parms->parm.capture;


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
	ival->interval.numerator = GET_CLKRC_DIV(to_clkrc(&priv->tpf,
		return -EINVAL;

	memset(cp, 0, sizeof(*cp));
	cp->capability = V4L2_CAP_TIMEPERFRAME;
	cp->timeperframe.numerator = GET_CLKRC_DIV(to_clkrc(&priv->tpf,
			priv->pclk_limit, priv->pclk_max));
			priv->pclk_limit, priv->pclk_max));
	cp->timeperframe.denominator = FRAME_RATE_MAX;
	ival->interval.denominator = FRAME_RATE_MAX;


	dev_dbg(&client->dev, "Frame interval: %u/%u s\n",
	dev_dbg(&client->dev, "Frame interval: %u/%u s\n",
		cp->timeperframe.numerator, cp->timeperframe.denominator);
		ival->interval.numerator, ival->interval.denominator);


	return 0;
	return 0;
}
}


static int ov6650_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int ov6650_s_frame_interval(struct v4l2_subdev *sd,
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct ov6650 *priv = to_ov6650(client);
	struct ov6650 *priv = to_ov6650(client);
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &ival->interval;
	struct v4l2_fract *tpf = &cp->timeperframe;
	int div, ret;
	int div, ret;
	u8 clkrc;
	u8 clkrc;


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	if (cp->extendedmode != 0)
		return -EINVAL;

	if (tpf->numerator == 0 || tpf->denominator == 0)
	if (tpf->numerator == 0 || tpf->denominator == 0)
		div = 1;  /* Reset to full rate */
		div = 1;  /* Reset to full rate */
	else
	else
@@ -921,8 +910,8 @@ static int ov6650_s_mbus_config(struct v4l2_subdev *sd,


static const struct v4l2_subdev_video_ops ov6650_video_ops = {
static const struct v4l2_subdev_video_ops ov6650_video_ops = {
	.s_stream	= ov6650_s_stream,
	.s_stream	= ov6650_s_stream,
	.g_parm		= ov6650_g_parm,
	.g_frame_interval = ov6650_g_frame_interval,
	.s_parm		= ov6650_s_parm,
	.s_frame_interval = ov6650_s_frame_interval,
	.g_mbus_config	= ov6650_g_mbus_config,
	.g_mbus_config	= ov6650_g_mbus_config,
	.s_mbus_config	= ov6650_s_mbus_config,
	.s_mbus_config	= ov6650_s_mbus_config,
};
};
+8 −14
Original line number Original line Diff line number Diff line
@@ -1100,30 +1100,24 @@ static int ov7670_get_fmt(struct v4l2_subdev *sd,
 * Implement G/S_PARM.  There is a "high quality" mode we could try
 * Implement G/S_PARM.  There is a "high quality" mode we could try
 * to do someday; for now, we just do the frame rate tweak.
 * to do someday; for now, we just do the frame rate tweak.
 */
 */
static int ov7670_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int ov7670_g_frame_interval(struct v4l2_subdev *sd,
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct ov7670_info *info = to_state(sd);
	struct ov7670_info *info = to_state(sd);


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;


	cp->capability = V4L2_CAP_TIMEPERFRAME;
	info->devtype->get_framerate(sd, &ival->interval);
	info->devtype->get_framerate(sd, &cp->timeperframe);


	return 0;
	return 0;
}
}


static int ov7670_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
static int ov7670_s_frame_interval(struct v4l2_subdev *sd,
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &ival->interval;
	struct v4l2_fract *tpf = &cp->timeperframe;
	struct ov7670_info *info = to_state(sd);
	struct ov7670_info *info = to_state(sd);


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;


	cp->capability = V4L2_CAP_TIMEPERFRAME;
	return info->devtype->set_framerate(sd, tpf);
	return info->devtype->set_framerate(sd, tpf);
}
}


@@ -1636,8 +1630,8 @@ static const struct v4l2_subdev_core_ops ov7670_core_ops = {
};
};


static const struct v4l2_subdev_video_ops ov7670_video_ops = {
static const struct v4l2_subdev_video_ops ov7670_video_ops = {
	.s_parm = ov7670_s_parm,
	.s_frame_interval = ov7670_s_frame_interval,
	.g_parm = ov7670_g_parm,
	.g_frame_interval = ov7670_g_frame_interval,
};
};


static const struct v4l2_subdev_pad_ops ov7670_pad_ops = {
static const struct v4l2_subdev_pad_ops ov7670_pad_ops = {
+8 −21
Original line number Original line Diff line number Diff line
@@ -624,17 +624,11 @@ static int ov7740_set_stream(struct v4l2_subdev *sd, int enable)
	return ret;
	return ret;
}
}


static int ov7740_get_parm(struct v4l2_subdev *sd,
static int ov7740_g_frame_interval(struct v4l2_subdev *sd,
			   struct v4l2_streamparm *parms)
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &ival->interval;
	struct v4l2_fract *tpf = &cp->timeperframe;


	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	memset(cp, 0, sizeof(struct v4l2_captureparm));
	cp->capability = V4L2_CAP_TIMEPERFRAME;


	tpf->numerator = 1;
	tpf->numerator = 1;
	tpf->denominator = 60;
	tpf->denominator = 60;
@@ -642,18 +636,11 @@ static int ov7740_get_parm(struct v4l2_subdev *sd,
	return 0;
	return 0;
}
}


static int ov7740_set_parm(struct v4l2_subdev *sd,
static int ov7740_s_frame_interval(struct v4l2_subdev *sd,
			   struct v4l2_streamparm *parms)
				   struct v4l2_subdev_frame_interval *ival)
{
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &ival->interval;
	struct v4l2_fract *tpf = &cp->timeperframe;

	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;
	if (cp->extendedmode != 0)
		return -EINVAL;


	cp->capability = V4L2_CAP_TIMEPERFRAME;


	tpf->numerator = 1;
	tpf->numerator = 1;
	tpf->denominator = 60;
	tpf->denominator = 60;
@@ -663,8 +650,8 @@ static int ov7740_set_parm(struct v4l2_subdev *sd,


static struct v4l2_subdev_video_ops ov7740_subdev_video_ops = {
static struct v4l2_subdev_video_ops ov7740_subdev_video_ops = {
	.s_stream = ov7740_set_stream,
	.s_stream = ov7740_set_stream,
	.s_parm = ov7740_set_parm,
	.s_frame_interval = ov7740_s_frame_interval,
	.g_parm = ov7740_get_parm,
	.g_frame_interval = ov7740_g_frame_interval,
};
};


static const struct reg_sequence ov7740_format_yuyv[] = {
static const struct reg_sequence ov7740_format_yuyv[] = {
+12 −25
Original line number Original line Diff line number Diff line
@@ -747,60 +747,47 @@ static int tvp514x_s_ctrl(struct v4l2_ctrl *ctrl)
}
}


/**
/**
 * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
 * tvp514x_g_frame_interval() - V4L2 decoder interface handler
 * @sd: pointer to standard V4L2 sub-device structure
 * @sd: pointer to standard V4L2 sub-device structure
 * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
 * @a: pointer to a v4l2_subdev_frame_interval structure
 *
 *
 * Returns the decoder's video CAPTURE parameters.
 * Returns the decoder's video CAPTURE parameters.
 */
 */
static int
static int
tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
tvp514x_g_frame_interval(struct v4l2_subdev *sd,
			 struct v4l2_subdev_frame_interval *ival)
{
{
	struct tvp514x_decoder *decoder = to_decoder(sd);
	struct tvp514x_decoder *decoder = to_decoder(sd);
	struct v4l2_captureparm *cparm;
	enum tvp514x_std current_std;
	enum tvp514x_std current_std;


	if (a == NULL)
		return -EINVAL;

	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		/* only capture is supported */
		return -EINVAL;


	/* get the current standard */
	/* get the current standard */
	current_std = decoder->current_std;
	current_std = decoder->current_std;


	cparm = &a->parm.capture;
	ival->interval =
	cparm->capability = V4L2_CAP_TIMEPERFRAME;
	cparm->timeperframe =
		decoder->std_list[current_std].standard.frameperiod;
		decoder->std_list[current_std].standard.frameperiod;


	return 0;
	return 0;
}
}


/**
/**
 * tvp514x_s_parm() - V4L2 decoder interface handler for s_parm
 * tvp514x_s_frame_interval() - V4L2 decoder interface handler
 * @sd: pointer to standard V4L2 sub-device structure
 * @sd: pointer to standard V4L2 sub-device structure
 * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure
 * @a: pointer to a v4l2_subdev_frame_interval structure
 *
 *
 * Configures the decoder to use the input parameters, if possible. If
 * Configures the decoder to use the input parameters, if possible. If
 * not possible, returns the appropriate error code.
 * not possible, returns the appropriate error code.
 */
 */
static int
static int
tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
tvp514x_s_frame_interval(struct v4l2_subdev *sd,
			 struct v4l2_subdev_frame_interval *ival)
{
{
	struct tvp514x_decoder *decoder = to_decoder(sd);
	struct tvp514x_decoder *decoder = to_decoder(sd);
	struct v4l2_fract *timeperframe;
	struct v4l2_fract *timeperframe;
	enum tvp514x_std current_std;
	enum tvp514x_std current_std;


	if (a == NULL)
		return -EINVAL;

	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		/* only capture is supported */
		return -EINVAL;


	timeperframe = &a->parm.capture.timeperframe;
	timeperframe = &ival->interval;


	/* get the current standard */
	/* get the current standard */
	current_std = decoder->current_std;
	current_std = decoder->current_std;
@@ -961,8 +948,8 @@ static const struct v4l2_subdev_video_ops tvp514x_video_ops = {
	.s_std = tvp514x_s_std,
	.s_std = tvp514x_s_std,
	.s_routing = tvp514x_s_routing,
	.s_routing = tvp514x_s_routing,
	.querystd = tvp514x_querystd,
	.querystd = tvp514x_querystd,
	.g_parm = tvp514x_g_parm,
	.g_frame_interval = tvp514x_g_frame_interval,
	.s_parm = tvp514x_s_parm,
	.s_frame_interval = tvp514x_s_frame_interval,
	.s_stream = tvp514x_s_stream,
	.s_stream = tvp514x_s_stream,
};
};


Loading