123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- struct v4l2_ctrl_handler;
- struct v4l2_device {
- struct device *dev;
- struct media_device *mdev;
- struct list_head subdevs;
- spinlock_t lock;
- char name[V4L2_DEVICE_NAME_SIZE];
- void (*notify)(struct v4l2_subdev *sd,
- unsigned int notification, void *arg);
- struct v4l2_ctrl_handler *ctrl_handler;
- struct v4l2_prio_state prio;
- struct kref ref;
- void (*release)(struct v4l2_device *v4l2_dev);
- };
- static inline void v4l2_device_get(struct v4l2_device *v4l2_dev)
- {
- kref_get(&v4l2_dev->ref);
- }
- int v4l2_device_put(struct v4l2_device *v4l2_dev);
- int __must_check v4l2_device_register(struct device *dev,
- struct v4l2_device *v4l2_dev);
- int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
- atomic_t *instance);
- void v4l2_device_disconnect(struct v4l2_device *v4l2_dev);
- void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
- int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
- struct v4l2_subdev *sd);
- void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
- int __must_check
- v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
- static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
- unsigned int notification, void *arg)
- {
- if (sd && sd->v4l2_dev && sd->v4l2_dev->notify)
- sd->v4l2_dev->notify(sd, notification, arg);
- }
- list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
- /* Call the specified callback for all subdevs matching the condition.
- Ignore any errors. Note that you cannot add or delete a subdev
- while walking the subdevs list. */
- #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
- do { \
- list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
- if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
- (sd)->ops->o->f((sd) ,
- } while (0)
- do { \
- struct v4l2_subdev *__sd; \
- \
- __v4l2_device_call_subdevs_p(v4l2_dev, __sd, cond, o, \
- f ,
- } while (0)
- ({ \
- long __err = 0; \
- \
- list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) { \
- if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
- __err = (sd)->ops->o->f((sd) ,
- if (__err && __err != -ENOIOCTLCMD) \
- break; \
- } \
- (__err == -ENOIOCTLCMD) ? 0 : __err; \
- })
- ({ \
- struct v4l2_subdev *__sd; \
- __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, cond, o, \
- f ,
- })
- do { \
- struct v4l2_subdev *__sd; \
- \
- __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
- !(grpid) || __sd->grp_id == (grpid), o, f , \
-
- } while (0)
- ({ \
- struct v4l2_subdev *__sd; \
- __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
- !(grpid) || __sd->grp_id == (grpid), o, f , \
-
- })
- do { \
- struct v4l2_subdev *__sd; \
- \
- __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
- !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \
-
- } while (0)
- ({ \
- struct v4l2_subdev *__sd; \
- __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
- !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \
-
- })
- ({ \
- struct v4l2_subdev *__sd; \
- bool __result = false; \
- list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \
- if ((grpid) && __sd->grp_id != (grpid)) \
- continue; \
- if (v4l2_subdev_has_op(__sd, o, f)) { \
- __result = true; \
- break; \
- } \
- } \
- __result; \
- })
- /*
- * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given
- * op?
- */
- #define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \
- ({ \
- struct v4l2_subdev *__sd; \
- bool __result = false; \
- list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \
- if ((grpmsk) && !(__sd->grp_id & (grpmsk))) \
- continue; \
- if (v4l2_subdev_has_op(__sd, o, f)) { \
- __result = true; \
- break; \
- } \
- } \
- __result; \
- })
- #endif
|