v4l2-ctrls-priv.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * V4L2 controls framework private header.
  4. *
  5. * Copyright (C) 2010-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>
  6. */
  7. #ifndef _V4L2_CTRLS_PRIV_H_
  8. #define _V4L2_CTRLS_PRIV_H_
  9. #define dprintk(vdev, fmt, arg...) do { \
  10. if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
  11. printk(KERN_DEBUG pr_fmt("%s: %s: " fmt), \
  12. __func__, video_device_node_name(vdev), ##arg); \
  13. } while (0)
  14. #define has_op(master, op) \
  15. ((master)->ops && (master)->ops->op)
  16. #define call_op(master, op) \
  17. (has_op(master, op) ? (master)->ops->op(master) : 0)
  18. static inline u32 node2id(struct list_head *node)
  19. {
  20. return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id;
  21. }
  22. /*
  23. * Small helper function to determine if the autocluster is set to manual
  24. * mode.
  25. */
  26. static inline bool is_cur_manual(const struct v4l2_ctrl *master)
  27. {
  28. return master->is_auto && master->cur.val == master->manual_mode_value;
  29. }
  30. /*
  31. * Small helper function to determine if the autocluster will be set to manual
  32. * mode.
  33. */
  34. static inline bool is_new_manual(const struct v4l2_ctrl *master)
  35. {
  36. return master->is_auto && master->val == master->manual_mode_value;
  37. }
  38. static inline u32 user_flags(const struct v4l2_ctrl *ctrl)
  39. {
  40. u32 flags = ctrl->flags;
  41. if (ctrl->is_ptr)
  42. flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
  43. return flags;
  44. }
  45. /* v4l2-ctrls-core.c */
  46. void cur_to_new(struct v4l2_ctrl *ctrl);
  47. void cur_to_req(struct v4l2_ctrl_ref *ref);
  48. void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 ch_flags);
  49. void new_to_req(struct v4l2_ctrl_ref *ref);
  50. int req_to_new(struct v4l2_ctrl_ref *ref);
  51. void send_initial_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl);
  52. void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes);
  53. int handler_new_ref(struct v4l2_ctrl_handler *hdl,
  54. struct v4l2_ctrl *ctrl,
  55. struct v4l2_ctrl_ref **ctrl_ref,
  56. bool from_other_dev, bool allocate_req);
  57. struct v4l2_ctrl_ref *find_ref(struct v4l2_ctrl_handler *hdl, u32 id);
  58. struct v4l2_ctrl_ref *find_ref_lock(struct v4l2_ctrl_handler *hdl, u32 id);
  59. int check_range(enum v4l2_ctrl_type type,
  60. s64 min, s64 max, u64 step, s64 def);
  61. void update_from_auto_cluster(struct v4l2_ctrl *master);
  62. int try_or_set_cluster(struct v4l2_fh *fh, struct v4l2_ctrl *master,
  63. bool set, u32 ch_flags);
  64. /* v4l2-ctrls-api.c */
  65. int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl,
  66. struct v4l2_ext_controls *cs,
  67. struct video_device *vdev);
  68. int try_set_ext_ctrls_common(struct v4l2_fh *fh,
  69. struct v4l2_ctrl_handler *hdl,
  70. struct v4l2_ext_controls *cs,
  71. struct video_device *vdev, bool set);
  72. /* v4l2-ctrls-request.c */
  73. void v4l2_ctrl_handler_init_request(struct v4l2_ctrl_handler *hdl);
  74. void v4l2_ctrl_handler_free_request(struct v4l2_ctrl_handler *hdl);
  75. int v4l2_g_ext_ctrls_request(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
  76. struct media_device *mdev, struct v4l2_ext_controls *cs);
  77. int try_set_ext_ctrls_request(struct v4l2_fh *fh,
  78. struct v4l2_ctrl_handler *hdl,
  79. struct video_device *vdev,
  80. struct media_device *mdev,
  81. struct v4l2_ext_controls *cs, bool set);
  82. #endif