Commit 756e6e14 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] exynos4-is: Make fimc-lite independent of the pipeline->subdevs array

Get the sensor subdev by walking media graph in both cases: when the
device is used as a subdev only and through video node. This allows
to not dereference the pipeline->subdevs[] array and makes the module
more generic and easier to re-use in other media driver.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 488f29d0
...@@ -130,23 +130,43 @@ static const struct fimc_fmt *fimc_lite_find_format(const u32 *pixelformat, ...@@ -130,23 +130,43 @@ static const struct fimc_fmt *fimc_lite_find_format(const u32 *pixelformat,
return def_fmt; return def_fmt;
} }
/* Called with the media graph mutex held or @me stream_count > 0. */
static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me)
{
struct media_pad *pad = &me->pads[0];
struct v4l2_subdev *sd;
while (pad->flags & MEDIA_PAD_FL_SINK) {
/* source pad */
pad = media_entity_remote_source(pad);
if (pad == NULL ||
media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
break;
sd = media_entity_to_v4l2_subdev(pad->entity);
if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR ||
sd->grp_id == GRP_ID_SENSOR)
return sd;
/* sink pad */
pad = &sd->entity.pads[0];
}
return NULL;
}
static int fimc_lite_hw_init(struct fimc_lite *fimc, bool isp_output) static int fimc_lite_hw_init(struct fimc_lite *fimc, bool isp_output)
{ {
struct fimc_pipeline *pipeline = &fimc->pipeline;
struct v4l2_subdev *sensor;
struct fimc_sensor_info *si; struct fimc_sensor_info *si;
unsigned long flags; unsigned long flags;
sensor = isp_output ? fimc->sensor : pipeline->subdevs[IDX_SENSOR]; if (fimc->sensor == NULL)
if (sensor == NULL)
return -ENXIO; return -ENXIO;
if (fimc->inp_frame.fmt == NULL || fimc->out_frame.fmt == NULL) if (fimc->inp_frame.fmt == NULL || fimc->out_frame.fmt == NULL)
return -EINVAL; return -EINVAL;
/* Get sensor configuration data from the sensor subdev */ /* Get sensor configuration data from the sensor subdev */
si = v4l2_get_subdev_hostdata(sensor); si = v4l2_get_subdev_hostdata(fimc->sensor);
spin_lock_irqsave(&fimc->slock, flags); spin_lock_irqsave(&fimc->slock, flags);
flite_hw_set_camera_bus(fimc, &si->pdata); flite_hw_set_camera_bus(fimc, &si->pdata);
...@@ -801,6 +821,8 @@ static int fimc_lite_streamon(struct file *file, void *priv, ...@@ -801,6 +821,8 @@ static int fimc_lite_streamon(struct file *file, void *priv,
if (ret < 0) if (ret < 0)
goto err_p_stop; goto err_p_stop;
fimc->sensor = __find_remote_sensor(&fimc->subdev.entity);
ret = vb2_ioctl_streamon(file, priv, type); ret = vb2_ioctl_streamon(file, priv, type);
if (!ret) { if (!ret) {
fimc->streaming = true; fimc->streaming = true;
...@@ -929,29 +951,6 @@ static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = { ...@@ -929,29 +951,6 @@ static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = {
.vidioc_streamoff = fimc_lite_streamoff, .vidioc_streamoff = fimc_lite_streamoff,
}; };
/* Called with the media graph mutex held */
static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me)
{
struct media_pad *pad = &me->pads[0];
struct v4l2_subdev *sd;
while (pad->flags & MEDIA_PAD_FL_SINK) {
/* source pad */
pad = media_entity_remote_source(pad);
if (pad == NULL ||
media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
break;
sd = media_entity_to_v4l2_subdev(pad->entity);
if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR)
return sd;
/* sink pad */
pad = &sd->entity.pads[0];
}
return NULL;
}
/* Capture subdev media entity operations */ /* Capture subdev media entity operations */
static int fimc_lite_link_setup(struct media_entity *entity, static int fimc_lite_link_setup(struct media_entity *entity,
const struct media_pad *local, const struct media_pad *local,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment