Skip to content

Commit a67fc8b

Browse files
ezequielgarciajc-kynesim
authored andcommitted
RFC: media: Add media_request_{pin,unpin} API
This is probably not the API we will want to add, but it should show what semantics are needed by drivers. The goal is to allow the OUTPUT (aka source) buffer and the controls associated to a request to be released from the request, and in particular return the OUTPUT buffer back to userspace, without signalling the media request fd. This is useful for devices that are able to pre-process the OUTPUT buffer, therefore able to release it before the decoding is finished. These drivers should signal the media request fd only after the CAPTURE buffer is done. Tested-by: John Cox <jc@kynesim.co.uk> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
1 parent 3cac2c6 commit a67fc8b

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎drivers/media/mc/mc-request.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,3 +504,38 @@ void media_request_object_complete(struct media_request_object *obj)
504504
media_request_put(req);
505505
}
506506
EXPORT_SYMBOL_GPL(media_request_object_complete);
507+
508+
void media_request_pin(struct media_request *req)
509+
{
510+
unsigned long flags;
511+
512+
spin_lock_irqsave(&req->lock, flags);
513+
if (WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED))
514+
goto unlock;
515+
req->num_incomplete_objects++;
516+
unlock:
517+
spin_unlock_irqrestore(&req->lock, flags);
518+
}
519+
EXPORT_SYMBOL_GPL(media_request_pin);
520+
521+
void media_request_unpin(struct media_request *req)
522+
{
523+
unsigned long flags;
524+
bool completed = false;
525+
526+
spin_lock_irqsave(&req->lock, flags);
527+
if (WARN_ON(!req->num_incomplete_objects) ||
528+
WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED))
529+
goto unlock;
530+
531+
if (!--req->num_incomplete_objects) {
532+
req->state = MEDIA_REQUEST_STATE_COMPLETE;
533+
wake_up_interruptible_all(&req->poll_wait);
534+
completed = true;
535+
}
536+
unlock:
537+
spin_unlock_irqrestore(&req->lock, flags);
538+
if (completed)
539+
media_request_put(req);
540+
}
541+
EXPORT_SYMBOL_GPL(media_request_unpin);

‎include/media/media-request.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ static inline void media_request_get(struct media_request *req)
189189
*/
190190
void media_request_put(struct media_request *req);
191191

192+
void media_request_pin(struct media_request *req);
193+
194+
void media_request_unpin(struct media_request *req);
195+
192196
/**
193197
* media_request_get_by_fd - Get a media request by fd
194198
*
@@ -228,6 +232,14 @@ static inline void media_request_put(struct media_request *req)
228232
{
229233
}
230234

235+
static inline void media_request_pin(struct media_request *req)
236+
{
237+
}
238+
239+
static inline void media_request_unpin(struct media_request *req)
240+
{
241+
}
242+
231243
static inline struct media_request *
232244
media_request_get_by_fd(struct media_device *mdev, int request_fd)
233245
{

0 commit comments

Comments
 (0)