#include "stfcamss.h"
#include "stf_video.h"
#include <media/media-entity.h>
+#include <media/v4l2-event.h>
#include <media/v4l2-mc.h>
#include <media/videobuf2-dma-sg.h>
#include <media/videobuf2-vmalloc.h>
break;
entity = pad->entity;
}
- if (!strncmp(vin_name, entity->name, 13)) {
- st_err(ST_VIDEO, "===== [%s] Please configure pipeline first =====\n", name);
+ if (!strncmp(vin_name, entity->name, STFCAMSS_MAX_ENTITY_NAME_LEN)) {
+ st_err(ST_VIDEO, " [%s] Please configure pipeline first!\n", name);
return NULL;
}
subdev = media_entity_to_v4l2_subdev(entity);
sensor = stfcamss_find_sensor(entity);
if (!sensor)
- return -EINVAL;
+ return -ENOTTY;
fie.index = fival->index;
fie.width = fival->width;
fie.height = fival->height;
code.index = 0;
code.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+ /* Don't care about the code, just find by pixelformat */
+ ret = video_find_format(0, fival->pixel_format,
+ video->formats, video->nformats);
+ if (ret < 0)
+ return -EINVAL;
+
ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code);
if (ret < 0)
return -EINVAL;
}
} else {
st_err(ST_VIDEO, "Can't find sensor\n");
- return -EINVAL;
+ return -ENOTTY;
}
/*
* Starting from sensor subdevice, walk within
return ret;
}
-#ifdef UNUSED_CODE
static int video_query_ext_ctrl(struct file *file, void *fh,
struct v4l2_query_ext_ctrl *qec)
{
return ret;
}
-#endif
static int video_g_ext_ctrls(struct file *file, void *fh,
struct v4l2_ext_controls *ctrls)
struct stfcamss_video *video = video_drvdata(file);
struct video_device *vdev = &video->vdev;
struct v4l2_subdev *subdev;
+ struct v4l2_fh *vfh;
int ret;
subdev = get_senname(file, (char *)__func__);
if (!subdev)
return -EINVAL;
+ vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh, ctrl_handler);
+ if (!vfh->ctrl_handler)
+ return -ENOTTY;
+
ret = v4l2_g_ext_ctrls(subdev->ctrl_handler,
vdev, subdev->v4l2_dev->mdev, ctrls);
ret = v4l2_queryctrl(subdev->ctrl_handler, qc);
} else {
// st_err(ST_VIDEO, "== [%s] Please configure pipeline first ==\n", __func__);
- return -EINVAL;
+ return -ENOTTY;
}
return ret;
}
-#ifdef UNUSED_CODE
static int video_querymenu(struct file *file, void *fh,
struct v4l2_querymenu *qm)
{
return ret;
}
-#endif
+
+static int video_subscribe_event(struct v4l2_fh *fh,
+ const struct v4l2_event_subscription *sub)
+{
+ struct v4l2_subdev *subdev = NULL;
+ struct media_entity *entity = &fh->vdev->entity;
+ struct media_entity *sensor;
+
+ sensor = stfcamss_find_sensor(entity);
+ if (sensor)
+ subdev = media_entity_to_v4l2_subdev(sensor);
+
+ if (!subdev)
+ return -ENOTTY;
+
+ fh->ctrl_handler = subdev->ctrl_handler;
+ return v4l2_ctrl_subscribe_event(fh, sub);
+}
+
+static int video_unsubscribe_event(struct v4l2_fh *fh,
+ const struct v4l2_event_subscription *sub)
+{
+ struct v4l2_subdev *subdev = NULL;
+ struct media_entity *entity = &fh->vdev->entity;
+ struct media_entity *sensor;
+
+ sensor = stfcamss_find_sensor(entity);
+ if (sensor)
+ subdev = media_entity_to_v4l2_subdev(sensor);
+
+ if (!subdev)
+ return -ENOTTY;
+
+ fh->ctrl_handler = subdev->ctrl_handler;
+ return v4l2_event_unsubscribe(fh, sub);
+}
static const struct v4l2_ioctl_ops stf_vid_ioctl_ops = {
.vidioc_querycap = video_querycap,
.vidioc_s_ctrl = video_s_ctrl,
.vidioc_g_ext_ctrls = video_g_ext_ctrls,
.vidioc_queryctrl = video_queryctrl,
+ .vidioc_query_ext_ctrl = video_query_ext_ctrl,
.vidioc_s_ext_ctrls = video_s_ext_ctrls,
.vidioc_try_ext_ctrls = video_try_ext_ctrls,
+ .vidioc_querymenu = video_querymenu,
+ .vidioc_subscribe_event = video_subscribe_event,
+ .vidioc_unsubscribe_event = video_unsubscribe_event,
};
static const struct v4l2_ioctl_ops stf_vid_ioctl_ops_mp = {
.vidioc_s_ctrl = video_s_ctrl,
.vidioc_g_ext_ctrls = video_g_ext_ctrls,
.vidioc_queryctrl = video_queryctrl,
+ .vidioc_query_ext_ctrl = video_query_ext_ctrl,
.vidioc_s_ext_ctrls = video_s_ext_ctrls,
.vidioc_try_ext_ctrls = video_try_ext_ctrls,
+ .vidioc_querymenu = video_querymenu,
+ .vidioc_subscribe_event = video_subscribe_event,
+ .vidioc_unsubscribe_event = video_unsubscribe_event,
+
};
static const struct v4l2_ioctl_ops stf_vid_ioctl_ops_out = {