mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
media: rockchip: rkisp1: keep active_sensor available when stream off
Currently, it's set active_sensor to NULL when stream off. But it could be useful for ioctls (e.g. enum_frameintervals) to obtain active sensor's infomations. This patchs keep active_sensor always available and renew it every time before starting stream in case media topology changed. Meanwhile, get active_sensor info once async subdevice registered completely. Change-Id: I21eb3954d5932a4bc7c899d8f110e31b409c91d2 Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com>
This commit is contained in:
committed by
Tao Huang
parent
d63f037b70
commit
bbabed05f0
@@ -1502,8 +1502,8 @@ rkisp1_start_streaming(struct vb2_queue *queue, unsigned int count)
|
||||
if (WARN_ON(stream->streaming))
|
||||
return -EBUSY;
|
||||
|
||||
if (!dev->active_sensor &&
|
||||
dev->isp_inp != INP_DMARX_ISP) {
|
||||
if (dev->isp_inp != INP_DMARX_ISP) {
|
||||
/* Always update sensor info in case media topology changed */
|
||||
ret = rkisp1_update_sensor_info(dev);
|
||||
if (ret < 0) {
|
||||
v4l2_err(v4l2_dev,
|
||||
|
||||
@@ -397,97 +397,80 @@ static int rkisp1_create_links(struct rkisp1_device *dev)
|
||||
|
||||
static int _set_pipeline_default_fmt(struct rkisp1_device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct v4l2_subdev *isp;
|
||||
struct v4l2_subdev *sensor;
|
||||
struct v4l2_subdev_format fmt;
|
||||
struct v4l2_subdev_selection sel;
|
||||
struct v4l2_subdev_pad_config cfg;
|
||||
u32 width, height;
|
||||
u32 ori_width, ori_height, ori_code;
|
||||
|
||||
if (dev->num_sensors) {
|
||||
sensor = dev->sensors[0].sd;
|
||||
isp = &dev->isp_sdev.sd;
|
||||
isp = &dev->isp_sdev.sd;
|
||||
|
||||
/* get fmt from sensor */
|
||||
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||
ret = v4l2_subdev_call(sensor, pad, get_fmt, &cfg, &fmt);
|
||||
if (ret) {
|
||||
dev_err(dev->dev,
|
||||
"failed to get fmt for %s\n",
|
||||
sensor->name);
|
||||
fmt = dev->active_sensor->fmt;
|
||||
ori_width = fmt.format.width;
|
||||
ori_height = fmt.format.height;
|
||||
ori_code = fmt.format.code;
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
ori_width = fmt.format.width;
|
||||
ori_height = fmt.format.height;
|
||||
ori_code = fmt.format.code;
|
||||
|
||||
if (dev->isp_ver == ISP_V12) {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX_V12);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX_V12);
|
||||
} else if (dev->isp_ver == ISP_V13) {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX_V13);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX_V13);
|
||||
} else {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX);
|
||||
}
|
||||
|
||||
sel.r.left = 0;
|
||||
sel.r.top = 0;
|
||||
width = fmt.format.width;
|
||||
height = fmt.format.height;
|
||||
sel.r.width = fmt.format.width;
|
||||
sel.r.height = fmt.format.height;
|
||||
sel.target = V4L2_SEL_TGT_CROP;
|
||||
sel.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
|
||||
/* change fmt&size for RKISP1_ISP_PAD_SINK */
|
||||
fmt.pad = RKISP1_ISP_PAD_SINK;
|
||||
sel.pad = RKISP1_ISP_PAD_SINK;
|
||||
v4l2_subdev_call(isp, pad, set_fmt, &cfg, &fmt);
|
||||
v4l2_subdev_call(isp, pad, set_selection, &cfg, &sel);
|
||||
|
||||
/* change fmt&size for RKISP1_ISP_PAD_SOURCE_PATH */
|
||||
if ((fmt.format.code & RKISP1_MEDIA_BUS_FMT_MASK) ==
|
||||
RKISP1_MEDIA_BUS_FMT_BAYER)
|
||||
fmt.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
|
||||
|
||||
fmt.pad = RKISP1_ISP_PAD_SOURCE_PATH;
|
||||
sel.pad = RKISP1_ISP_PAD_SOURCE_PATH;
|
||||
v4l2_subdev_call(isp, pad, set_fmt, &cfg, &fmt);
|
||||
v4l2_subdev_call(isp, pad, set_selection, &cfg, &sel);
|
||||
|
||||
/* change fmt&size of MP/SP */
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_MP,
|
||||
width, height, V4L2_PIX_FMT_YUYV);
|
||||
if (dev->isp_ver != ISP_V10_1)
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_SP,
|
||||
width, height, V4L2_PIX_FMT_YUYV);
|
||||
if (dev->isp_ver == ISP_V12 ||
|
||||
dev->isp_ver == ISP_V13)
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_RAW,
|
||||
ori_width, ori_height,
|
||||
rkisp1_mbus_pixelcode_to_v4l2(ori_code));
|
||||
if (dev->isp_ver == ISP_V12) {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX_V12);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX_V12);
|
||||
} else if (dev->isp_ver == ISP_V13) {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX_V13);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX_V13);
|
||||
} else {
|
||||
fmt.format.width = clamp_t(u32, fmt.format.width,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX);
|
||||
fmt.format.height = clamp_t(u32, fmt.format.height,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX);
|
||||
}
|
||||
|
||||
sel.r.left = 0;
|
||||
sel.r.top = 0;
|
||||
width = fmt.format.width;
|
||||
height = fmt.format.height;
|
||||
sel.r.width = fmt.format.width;
|
||||
sel.r.height = fmt.format.height;
|
||||
sel.target = V4L2_SEL_TGT_CROP;
|
||||
sel.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
|
||||
/* change fmt&size for RKISP1_ISP_PAD_SINK */
|
||||
fmt.pad = RKISP1_ISP_PAD_SINK;
|
||||
sel.pad = RKISP1_ISP_PAD_SINK;
|
||||
v4l2_subdev_call(isp, pad, set_fmt, &cfg, &fmt);
|
||||
v4l2_subdev_call(isp, pad, set_selection, &cfg, &sel);
|
||||
|
||||
/* change fmt&size for RKISP1_ISP_PAD_SOURCE_PATH */
|
||||
if ((fmt.format.code & RKISP1_MEDIA_BUS_FMT_MASK) ==
|
||||
RKISP1_MEDIA_BUS_FMT_BAYER)
|
||||
fmt.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
|
||||
|
||||
fmt.pad = RKISP1_ISP_PAD_SOURCE_PATH;
|
||||
sel.pad = RKISP1_ISP_PAD_SOURCE_PATH;
|
||||
v4l2_subdev_call(isp, pad, set_fmt, &cfg, &fmt);
|
||||
v4l2_subdev_call(isp, pad, set_selection, &cfg, &sel);
|
||||
|
||||
/* change fmt&size of MP/SP */
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_MP,
|
||||
width, height, V4L2_PIX_FMT_YUYV);
|
||||
if (dev->isp_ver != ISP_V10_1)
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_SP,
|
||||
width, height, V4L2_PIX_FMT_YUYV);
|
||||
if (dev->isp_ver == ISP_V12 || dev->isp_ver == ISP_V13)
|
||||
rkisp1_set_stream_def_fmt(dev, RKISP1_STREAM_RAW, ori_width,
|
||||
ori_height, rkisp1_mbus_pixelcode_to_v4l2(ori_code));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -506,6 +489,12 @@ static int subdev_notifier_complete(struct v4l2_async_notifier *notifier)
|
||||
if (ret < 0)
|
||||
goto unlock;
|
||||
|
||||
ret = rkisp1_update_sensor_info(dev);
|
||||
if (ret < 0) {
|
||||
v4l2_err(&dev->v4l2_dev, "update sensor failed\n");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ret = _set_pipeline_default_fmt(dev);
|
||||
if (ret < 0)
|
||||
goto unlock;
|
||||
|
||||
@@ -798,8 +798,6 @@ static int rkisp1_isp_stop(struct rkisp1_device *dev)
|
||||
if (dev->hdr_sensor)
|
||||
dev->hdr_sensor = NULL;
|
||||
|
||||
dev->active_sensor = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user