diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-04-03 16:44:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-04-20 15:08:42 -0400 |
commit | 96655553e5f9af6a8d908386685b7c865a138283 (patch) | |
tree | 81c4587c0f0afd612672cfe064de15ccc35879ca | |
parent | bae4c757a5255a149249294dab3a6ab16e5d598b (diff) |
[media] v4l2-device.h: add v4l2_device_mask_ variants
The v4l2_device_call_* defines filter subdevs based on the grp_id value.
But some drivers use a bitmask, so instead of filtering by grp_id == value,
you want to filter by grp_id & value.
Make variants of these defines to do this.
The 'has_op' define has been extended to have a grp_id argument as well, and
a mask variant has been added.
This extra argument required a change to go7007.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/usb/go7007/go7007-v4l2.c | 2 | ||||
-rw-r--r-- | include/media/v4l2-device.h | 55 |
2 files changed, 55 insertions, 2 deletions
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c b/drivers/media/usb/go7007/go7007-v4l2.c index 358c1c186d03..ea01ee5df60a 100644 --- a/drivers/media/usb/go7007/go7007-v4l2.c +++ b/drivers/media/usb/go7007/go7007-v4l2.c | |||
@@ -1125,7 +1125,7 @@ int go7007_v4l2_init(struct go7007 *go) | |||
1125 | vdev->queue = &go->vidq; | 1125 | vdev->queue = &go->vidq; |
1126 | video_set_drvdata(vdev, go); | 1126 | video_set_drvdata(vdev, go); |
1127 | vdev->v4l2_dev = &go->v4l2_dev; | 1127 | vdev->v4l2_dev = &go->v4l2_dev; |
1128 | if (!v4l2_device_has_op(&go->v4l2_dev, video, querystd)) | 1128 | if (!v4l2_device_has_op(&go->v4l2_dev, 0, video, querystd)) |
1129 | v4l2_disable_ioctl(vdev, VIDIOC_QUERYSTD); | 1129 | v4l2_disable_ioctl(vdev, VIDIOC_QUERYSTD); |
1130 | if (!(go->board_info->flags & GO7007_BOARD_HAS_TUNER)) { | 1130 | if (!(go->board_info->flags & GO7007_BOARD_HAS_TUNER)) { |
1131 | v4l2_disable_ioctl(vdev, VIDIOC_S_FREQUENCY); | 1131 | v4l2_disable_ioctl(vdev, VIDIOC_S_FREQUENCY); |
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index 9c581578783f..d5d45a8d3998 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h | |||
@@ -196,11 +196,64 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, | |||
196 | ##args); \ | 196 | ##args); \ |
197 | }) | 197 | }) |
198 | 198 | ||
199 | #define v4l2_device_has_op(v4l2_dev, o, f) \ | 199 | /* |
200 | * Call the specified callback for all subdevs where grp_id & grpmsk != 0 | ||
201 | * (if grpmsk == `0, then match them all). Ignore any errors. Note that you | ||
202 | * cannot add or delete a subdev while walking the subdevs list. | ||
203 | */ | ||
204 | #define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \ | ||
205 | do { \ | ||
206 | struct v4l2_subdev *__sd; \ | ||
207 | \ | ||
208 | __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \ | ||
209 | !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ | ||
210 | ##args); \ | ||
211 | } while (0) | ||
212 | |||
213 | /* | ||
214 | * Call the specified callback for all subdevs where grp_id & grpmsk != 0 | ||
215 | * (if grpmsk == `0, then match them all). If the callback returns an error | ||
216 | * other than 0 or -ENOIOCTLCMD, then return with that error code. Note that | ||
217 | * you cannot add or delete a subdev while walking the subdevs list. | ||
218 | */ | ||
219 | #define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \ | ||
220 | ({ \ | ||
221 | struct v4l2_subdev *__sd; \ | ||
222 | __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \ | ||
223 | !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ | ||
224 | ##args); \ | ||
225 | }) | ||
226 | |||
227 | /* | ||
228 | * Does any subdev with matching grpid (or all if grpid == 0) has the given | ||
229 | * op? | ||
230 | */ | ||
231 | #define v4l2_device_has_op(v4l2_dev, grpid, o, f) \ | ||
232 | ({ \ | ||
233 | struct v4l2_subdev *__sd; \ | ||
234 | bool __result = false; \ | ||
235 | list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \ | ||
236 | if ((grpid) && __sd->grp_id != (grpid)) \ | ||
237 | continue; \ | ||
238 | if (v4l2_subdev_has_op(__sd, o, f)) { \ | ||
239 | __result = true; \ | ||
240 | break; \ | ||
241 | } \ | ||
242 | } \ | ||
243 | __result; \ | ||
244 | }) | ||
245 | |||
246 | /* | ||
247 | * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given | ||
248 | * op? | ||
249 | */ | ||
250 | #define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \ | ||
200 | ({ \ | 251 | ({ \ |
201 | struct v4l2_subdev *__sd; \ | 252 | struct v4l2_subdev *__sd; \ |
202 | bool __result = false; \ | 253 | bool __result = false; \ |
203 | list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \ | 254 | list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \ |
255 | if ((grpmsk) && !(__sd->grp_id & (grpmsk))) \ | ||
256 | continue; \ | ||
204 | if (v4l2_subdev_has_op(__sd, o, f)) { \ | 257 | if (v4l2_subdev_has_op(__sd, o, f)) { \ |
205 | __result = true; \ | 258 | __result = true; \ |
206 | break; \ | 259 | break; \ |