Lines Matching refs:sev
21 static unsigned int sev_pos(const struct v4l2_subscribed_event *sev, unsigned int idx) in sev_pos() argument
23 idx += sev->first; in sev_pos()
24 return idx >= sev->elems ? idx - sev->elems : idx; in sev_pos()
51 kev->sev->first = sev_pos(kev->sev, 1); in __v4l2_event_dequeue()
52 kev->sev->in_use--; in __v4l2_event_dequeue()
91 struct v4l2_subscribed_event *sev; in v4l2_event_subscribed() local
95 list_for_each_entry(sev, &fh->subscribed, list) in v4l2_event_subscribed()
96 if (sev->type == type && sev->id == id) in v4l2_event_subscribed()
97 return sev; in v4l2_event_subscribed()
105 struct v4l2_subscribed_event *sev; in __v4l2_event_queue_fh() local
110 sev = v4l2_event_subscribed(fh, ev->type, ev->id); in __v4l2_event_queue_fh()
111 if (sev == NULL) in __v4l2_event_queue_fh()
118 if (sev->in_use == sev->elems) { in __v4l2_event_queue_fh()
120 kev = sev->events + sev_pos(sev, 0); in __v4l2_event_queue_fh()
122 sev->in_use--; in __v4l2_event_queue_fh()
123 sev->first = sev_pos(sev, 1); in __v4l2_event_queue_fh()
125 if (sev->elems == 1) { in __v4l2_event_queue_fh()
126 if (sev->ops && sev->ops->replace) { in __v4l2_event_queue_fh()
127 sev->ops->replace(&kev->event, ev); in __v4l2_event_queue_fh()
130 } else if (sev->ops && sev->ops->merge) { in __v4l2_event_queue_fh()
132 sev->events + sev_pos(sev, 0); in __v4l2_event_queue_fh()
133 sev->ops->merge(&kev->event, &second_oldest->event); in __v4l2_event_queue_fh()
138 kev = sev->events + sev_pos(sev, sev->in_use); in __v4l2_event_queue_fh()
145 sev->in_use++; in __v4l2_event_queue_fh()
207 static void __v4l2_event_unsubscribe(struct v4l2_subscribed_event *sev) in __v4l2_event_unsubscribe() argument
209 struct v4l2_fh *fh = sev->fh; in __v4l2_event_unsubscribe()
216 for (i = 0; i < sev->in_use; i++) { in __v4l2_event_unsubscribe()
217 list_del(&sev->events[sev_pos(sev, i)].list); in __v4l2_event_unsubscribe()
220 list_del(&sev->list); in __v4l2_event_unsubscribe()
227 struct v4l2_subscribed_event *sev, *found_ev; in v4l2_event_subscribe() local
238 sev = kvzalloc(struct_size(sev, events, elems), GFP_KERNEL); in v4l2_event_subscribe()
239 if (!sev) in v4l2_event_subscribe()
242 sev->events[i].sev = sev; in v4l2_event_subscribe()
243 sev->type = sub->type; in v4l2_event_subscribe()
244 sev->id = sub->id; in v4l2_event_subscribe()
245 sev->flags = sub->flags; in v4l2_event_subscribe()
246 sev->fh = fh; in v4l2_event_subscribe()
247 sev->ops = ops; in v4l2_event_subscribe()
248 sev->elems = elems; in v4l2_event_subscribe()
255 list_add(&sev->list, &fh->subscribed); in v4l2_event_subscribe()
260 kvfree(sev); in v4l2_event_subscribe()
261 } else if (sev->ops && sev->ops->add) { in v4l2_event_subscribe()
262 ret = sev->ops->add(sev, elems); in v4l2_event_subscribe()
265 __v4l2_event_unsubscribe(sev); in v4l2_event_subscribe()
267 kvfree(sev); in v4l2_event_subscribe()
280 struct v4l2_subscribed_event *sev; in v4l2_event_unsubscribe_all() local
284 sev = NULL; in v4l2_event_unsubscribe_all()
288 sev = list_first_entry(&fh->subscribed, in v4l2_event_unsubscribe_all()
290 sub.type = sev->type; in v4l2_event_unsubscribe_all()
291 sub.id = sev->id; in v4l2_event_unsubscribe_all()
294 if (sev) in v4l2_event_unsubscribe_all()
296 } while (sev); in v4l2_event_unsubscribe_all()
303 struct v4l2_subscribed_event *sev; in v4l2_event_unsubscribe() local
315 sev = v4l2_event_subscribed(fh, sub->type, sub->id); in v4l2_event_unsubscribe()
316 if (sev != NULL) in v4l2_event_unsubscribe()
317 __v4l2_event_unsubscribe(sev); in v4l2_event_unsubscribe()
321 if (sev && sev->ops && sev->ops->del) in v4l2_event_unsubscribe()
322 sev->ops->del(sev); in v4l2_event_unsubscribe()
326 kvfree(sev); in v4l2_event_unsubscribe()