24 #include <linux/slab.h>
25 #include <linux/types.h>
26 #include <linux/videodev2.h>
27 #include <linux/export.h>
37 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
38 fh->pad = kzalloc(
sizeof(*fh->pad) * sd->entity.num_pads,
GFP_KERNEL);
47 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
53 static int subdev_open(
struct file *
file)
58 #if defined(CONFIG_MEDIA_CONTROLLER)
63 subdev_fh = kzalloc(
sizeof(*subdev_fh),
GFP_KERNEL);
64 if (subdev_fh ==
NULL)
67 ret = subdev_fh_init(subdev_fh, sd);
76 #if defined(CONFIG_MEDIA_CONTROLLER)
95 #if defined(CONFIG_MEDIA_CONTROLLER)
101 subdev_fh_free(subdev_fh);
107 static int subdev_close(
struct file *file)
116 #if defined(CONFIG_MEDIA_CONTROLLER)
122 subdev_fh_free(subdev_fh);
129 static long subdev_do_ioctl(
struct file *file,
unsigned int cmd,
void *
arg)
134 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
172 #ifdef CONFIG_VIDEO_ADV_DEBUG
194 pr_info(
"%s: ================= START STATUS =================\n",
197 pr_info(
"%s: ================== END STATUS ==================\n",
202 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
210 if (format->
pad >= sd->entity.num_pads)
223 if (format->
pad >= sd->entity.num_pads)
231 struct v4l2_subdev_selection
sel;
238 if (crop->
pad >= sd->entity.num_pads)
251 sd,
pad, get_selection, subdev_fh, &
sel);
260 struct v4l2_subdev_selection
sel;
267 if (crop->
pad >= sd->entity.num_pads)
289 struct v4l2_subdev_mbus_code_enum *
code =
arg;
291 if (code->pad >= sd->entity.num_pads)
299 struct v4l2_subdev_frame_size_enum *fse =
arg;
301 if (fse->pad >= sd->entity.num_pads)
315 struct v4l2_subdev_frame_interval_enum *fie =
arg;
317 if (fie->pad >= sd->entity.num_pads)
325 struct v4l2_subdev_selection *
sel =
arg;
331 if (sel->pad >= sd->entity.num_pads)
335 sd,
pad, get_selection, subdev_fh, sel);
339 struct v4l2_subdev_selection *sel =
arg;
345 if (sel->pad >= sd->entity.num_pads)
365 static long subdev_ioctl(
struct file *file,
unsigned int cmd,
371 static unsigned int subdev_poll(
struct file *file,
poll_table *
wait)
380 poll_wait(file, &fh->
wait, wait);
391 .unlocked_ioctl = subdev_ioctl,
392 .release = subdev_close,
396 #ifdef CONFIG_MEDIA_CONTROLLER
397 int v4l2_subdev_link_validate_default(
struct v4l2_subdev *sd,
412 v4l2_subdev_link_validate_get_format(
struct media_pad *
pad,
415 switch (media_entity_type(pad->
entity)) {
421 pad, get_fmt,
NULL, fmt);
423 WARN(1,
"Driver bug! Wrong media entity type %d, entity %s\n",
431 int v4l2_subdev_link_validate(
struct media_link *link)
437 rval = v4l2_subdev_link_validate_get_format(
438 link->
source, &source_fmt);
442 rval = v4l2_subdev_link_validate_get_format(
443 link->
sink, &sink_fmt);
450 &source_fmt, &sink_fmt);
454 return v4l2_subdev_link_validate_default(
455 sink, link, &source_fmt, &sink_fmt);
462 INIT_LIST_HEAD(&sd->
list);
471 #if defined(CONFIG_MEDIA_CONTROLLER)