*padding_h = max_t(u32, *padding_h, min_pad_h);
}
+int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on)
+{
+ int ret;
+
+ if (isp->inputs[input].camera_on == on)
+ return 0;
+
+ ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, on);
+ if (ret && ret != -ENOIOCTLCMD) {
+ dev_err(isp->dev, "Error setting sensor power %d: %d\n", on, ret);
+ return ret;
+ }
+
+ isp->inputs[input].camera_on = on;
+ return 0;
+}
+
static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp,
struct v4l2_mbus_framefmt *ffmt,
int which)
void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height,
u32 *padding_w, u32 *padding_h);
+/* Set sensor power (no-op if already on/off) */
+int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on);
+
/* This function looks up the closest available resolution. */
int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,
const struct atomisp_format_bridge **fmt_ret,
static void atomisp_dev_init_struct(struct atomisp_device *isp)
{
- unsigned int i;
-
isp->isp_fatal_error = false;
- for (i = 0; i < isp->input_cnt; i++)
- isp->inputs[i].asd = NULL;
/*
* For Merrifield, frequency is scalable.
* After boot-up, the default frequency is 200MHz.
atomisp_css_free_stat_buffers(asd);
atomisp_free_internal_buffers(asd);
- if (isp->inputs[asd->input_curr].asd == asd) {
- ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
- core, s_power, 0);
- if (ret && ret != -ENOIOCTLCMD)
- dev_warn(isp->dev, "Failed to power-off sensor\n");
-
- /* clear the asd field to show this camera is not used */
- isp->inputs[asd->input_curr].asd = NULL;
- }
+ atomisp_s_sensor_power(isp, asd->input_curr, 0);
atomisp_destroy_pipes_stream(asd);
u32 code; /* MEDIA_BUS_FMT_* */
bool binning_support;
bool crop_support;
+ bool camera_on;
struct v4l2_subdev *camera;
/* Sensor rects for sensors which support crop */
struct v4l2_rect native_rect;
struct v4l2_rect active_rect;
/* Sensor state for which == V4L2_SUBDEV_FORMAT_TRY calls */
struct v4l2_subdev_state *try_sd_state;
- /*
- * To show this resource is used by
- * which stream, in ISP multiple stream mode
- */
- struct atomisp_sub_device *asd;
};
enum atomisp_dfs_mode {
}
/* power off the current owned sensor, as it is not used this time */
- if (isp->inputs[asd->input_curr].asd == asd &&
- asd->input_curr != input) {
- ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
- core, s_power, 0);
- if (ret && ret != -ENOIOCTLCMD)
- dev_warn(isp->dev,
- "Failed to power-off sensor\n");
- /* clear the asd field to show this camera is not used */
- isp->inputs[asd->input_curr].asd = NULL;
- }
+ if (input != isp->asd.input_curr)
+ atomisp_s_sensor_power(isp, isp->asd.input_curr, 0);
/* powe on the new sensor */
- ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, 1);
- if (ret && ret != -ENOIOCTLCMD) {
- dev_err(isp->dev, "Failed to power-on sensor\n");
+ ret = atomisp_s_sensor_power(isp, input, 1);
+ if (ret)
return ret;
- }
asd->input_curr = input;
- /* mark this camera is used by the current stream */
- isp->inputs[input].asd = asd;
-
return 0;
}