v4l2-subdev.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * V4L2 sub-device
  3. *
  4. * Copyright (C) 2010 Nokia Corporation
  5. *
  6. * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  7. * Sakari Ailus <sakari.ailus@iki.fi>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/types.h>
  23. #include <linux/ioctl.h>
  24. #include <linux/videodev2.h>
  25. #include <media/v4l2-device.h>
  26. #include <media/v4l2-ioctl.h>
  27. static int subdev_open(struct file *file)
  28. {
  29. return 0;
  30. }
  31. static int subdev_close(struct file *file)
  32. {
  33. return 0;
  34. }
  35. static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
  36. {
  37. switch (cmd) {
  38. default:
  39. return -ENOIOCTLCMD;
  40. }
  41. return 0;
  42. }
  43. static long subdev_ioctl(struct file *file, unsigned int cmd,
  44. unsigned long arg)
  45. {
  46. return video_usercopy(file, cmd, arg, subdev_do_ioctl);
  47. }
  48. const struct v4l2_file_operations v4l2_subdev_fops = {
  49. .owner = THIS_MODULE,
  50. .open = subdev_open,
  51. .unlocked_ioctl = subdev_ioctl,
  52. .release = subdev_close,
  53. };
  54. void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
  55. {
  56. INIT_LIST_HEAD(&sd->list);
  57. BUG_ON(!ops);
  58. sd->ops = ops;
  59. sd->v4l2_dev = NULL;
  60. sd->flags = 0;
  61. sd->name[0] = '\0';
  62. sd->grp_id = 0;
  63. sd->dev_priv = NULL;
  64. sd->host_priv = NULL;
  65. }
  66. EXPORT_SYMBOL(v4l2_subdev_init);