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

Commit efcb07c1 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab
Browse files

[media] m5mols: Add image stabilization control

parent 4eb3419d
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -170,6 +170,7 @@ struct m5mols_version {
 * @saturation: saturation control
 * @saturation: saturation control
 * @zoom: zoom control
 * @zoom: zoom control
 * @wdr: wide dynamic range control
 * @wdr: wide dynamic range control
 * @stabilization: image stabilization control
 * @ver: information of the version
 * @ver: information of the version
 * @cap: the capture mode attributes
 * @cap: the capture mode attributes
 * @power: current sensor's power status
 * @power: current sensor's power status
@@ -209,6 +210,7 @@ struct m5mols_info {
	struct v4l2_ctrl *saturation;
	struct v4l2_ctrl *saturation;
	struct v4l2_ctrl *zoom;
	struct v4l2_ctrl *zoom;
	struct v4l2_ctrl *wdr;
	struct v4l2_ctrl *wdr;
	struct v4l2_ctrl *stabilization;


	struct m5mols_version ver;
	struct m5mols_version ver;
	struct m5mols_capture cap;
	struct m5mols_capture cap;
+20 −0
Original line number Original line Diff line number Diff line
@@ -375,6 +375,19 @@ static int m5mols_set_wdr(struct m5mols_info *info, int wdr)
	return m5mols_write(&info->sd, CAPP_WDR_EN, wdr);
	return m5mols_write(&info->sd, CAPP_WDR_EN, wdr);
}
}


static int m5mols_set_stabilization(struct m5mols_info *info, int val)
{
	struct v4l2_subdev *sd = &info->sd;
	unsigned int evp = val ? 0xe : 0x0;
	int ret;

	ret = m5mols_write(sd, AE_EV_PRESET_MONITOR, evp);
	if (ret < 0)
		return ret;

	return m5mols_write(sd, AE_EV_PRESET_CAPTURE, evp);
}

static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
static int m5mols_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
{
	struct v4l2_subdev *sd = to_sd(ctrl);
	struct v4l2_subdev *sd = to_sd(ctrl);
@@ -455,6 +468,10 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl)
	case V4L2_CID_WIDE_DYNAMIC_RANGE:
	case V4L2_CID_WIDE_DYNAMIC_RANGE:
		ret = m5mols_set_wdr(info, ctrl->val);
		ret = m5mols_set_wdr(info, ctrl->val);
		break;
		break;

	case V4L2_CID_IMAGE_STABILIZATION:
		ret = m5mols_set_stabilization(info, ctrl->val);
		break;
	}
	}


	if (ret == 0 && info->mode != last_mode)
	if (ret == 0 && info->mode != last_mode)
@@ -535,6 +552,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
	info->wdr = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
	info->wdr = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
			V4L2_CID_WIDE_DYNAMIC_RANGE, 0, 1, 1, 0);
			V4L2_CID_WIDE_DYNAMIC_RANGE, 0, 1, 1, 0);


	info->stabilization = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops,
			V4L2_CID_IMAGE_STABILIZATION, 0, 1, 1, 0);

	if (info->handle.error) {
	if (info->handle.error) {
		int ret = info->handle.error;
		int ret = info->handle.error;
		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);
		v4l2_err(sd, "Failed to initialize controls: %d\n", ret);