Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
v4l2-ctrls.h
Go to the documentation of this file.
1 /*
2  V4L2 controls support header.
3 
4  Copyright (C) 2010 Hans Verkuil <[email protected]>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef _V4L2_CTRLS_H
22 #define _V4L2_CTRLS_H
23 
24 #include <linux/list.h>
25 #include <linux/videodev2.h>
26 
27 /* forward references */
28 struct file;
29 struct v4l2_ctrl_handler;
30 struct v4l2_ctrl_helper;
31 struct v4l2_ctrl;
32 struct video_device;
33 struct v4l2_subdev;
35 struct v4l2_fh;
36 struct poll_table_struct;
37 
50 struct v4l2_ctrl_ops {
52  int (*try_ctrl)(struct v4l2_ctrl *ctrl);
53  int (*s_ctrl)(struct v4l2_ctrl *ctrl);
54 };
55 
109 struct v4l2_ctrl {
110  /* Administrative fields */
111  struct list_head node;
114  struct v4l2_ctrl **cluster;
115  unsigned ncontrols;
116  unsigned int done:1;
117 
118  unsigned int is_new:1;
119  unsigned int is_private:1;
120  unsigned int is_auto:1;
121  unsigned int has_volatiles:1;
122  unsigned int manual_mode_value:8;
123 
124  const struct v4l2_ctrl_ops *ops;
126  const char *name;
129  union {
132  };
133  union {
134  const char * const *qmenu;
135  const s64 *qmenu_int;
136  };
137  unsigned long flags;
138  union {
141  char *string;
142  } cur;
143  union {
144  s32 val;
145  s64 val64;
146  char *string;
147  };
148  void *priv;
149 };
150 
162  struct list_head node;
164  struct v4l2_ctrl *ctrl;
166 };
167 
184  struct mutex _lock;
185  struct mutex *lock;
186  struct list_head ctrls;
191  int error;
192 };
193 
218  const struct v4l2_ctrl_ops *ops;
220  const char *name;
228  const char * const *qmenu;
229  const s64 *qmenu_int;
230  unsigned int is_private:1;
231 };
232 
247 void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
248  s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags);
249 
250 
265  unsigned nr_of_controls_hint);
266 
273 void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
274 
284 
297  const char *prefix);
298 
309  const struct v4l2_ctrl_config *cfg, void *priv);
310 
328 struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
329  const struct v4l2_ctrl_ops *ops,
330  u32 id, s32 min, s32 max, u32 step, s32 def);
331 
351  const struct v4l2_ctrl_ops *ops,
352  u32 id, s32 max, s32 mask, s32 def);
353 
374  const struct v4l2_ctrl_ops *ops, u32 id, s32 max,
375  s32 mask, s32 def, const char * const *qmenu);
376 
391  const struct v4l2_ctrl_ops *ops,
392  u32 id, s32 max, s32 def, const s64 *qmenu_int);
393 
403  struct v4l2_ctrl *ctrl);
404 
419  struct v4l2_ctrl_handler *add,
420  bool (*filter)(const struct v4l2_ctrl *ctrl));
421 
431 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
432 
437 void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
438 
439 
469 void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
470  u8 manual_val, bool set_volatile);
471 
472 
480 struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
481 
493 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
494 
508 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
509 
514 static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
515 {
516  mutex_lock(ctrl->handler->lock);
517 }
518 
523 static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
524 {
525  mutex_unlock(ctrl->handler->lock);
526 }
527 
538 
549 int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
550 
561 
573 
574 /* Internal helper functions that deal with control events. */
576 void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
577 void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
578 
579 /* Can be used as a vidioc_log_status function that just dumps all controls
580  associated with the filehandle. */
581 int v4l2_ctrl_log_status(struct file *file, void *fh);
582 
583 /* Can be used as a vidioc_subscribe_event function that just subscribes
584  control events. */
585 int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
586  const struct v4l2_event_subscription *sub);
587 
588 /* Can be used as a poll function that just polls for control events. */
589 unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
590 
591 /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
592 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
593 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
594 int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
595 int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
596  struct v4l2_control *ctrl);
597 int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
598 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
599 int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
600  struct v4l2_ext_controls *c);
601 
602 /* Helpers for subdevices. If the associated ctrl_handler == NULL then they
603  will all return -EINVAL. */
604 int v4l2_subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
605 int v4l2_subdev_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
609 int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
610 int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
611 
612 #endif