79 lines · c
1/*2 * Copyright (C) 2013 Red Hat3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 * and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice (including the next12 * paragraph) shall be included in all copies or substantial portions of the13 * Software.14 *15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21 * SOFTWARE.22 */23 24#ifndef DRM_FLIP_WORK_H25#define DRM_FLIP_WORK_H26 27#include <linux/kfifo.h>28#include <linux/spinlock.h>29#include <linux/workqueue.h>30 31/**32 * DOC: flip utils33 *34 * Utility to queue up work to run from work-queue context after flip/vblank.35 * Typically this can be used to defer unref of framebuffer's, cursor36 * bo's, etc until after vblank. The APIs are all thread-safe. Moreover,37 * drm_flip_work_commit() can be called in atomic context.38 */39 40struct drm_flip_work;41 42/*43 * drm_flip_func_t - callback function44 *45 * @work: the flip work46 * @val: value queued via drm_flip_work_queue()47 *48 * Callback function to be called for each of the queue'd work items after49 * drm_flip_work_commit() is called.50 */51typedef void (*drm_flip_func_t)(struct drm_flip_work *work, void *val);52 53/**54 * struct drm_flip_work - flip work queue55 * @name: debug name56 * @func: callback fxn called for each committed item57 * @worker: worker which calls @func58 * @queued: queued tasks59 * @commited: commited tasks60 * @lock: lock to access queued and commited lists61 */62struct drm_flip_work {63 const char *name;64 drm_flip_func_t func;65 struct work_struct worker;66 struct list_head queued;67 struct list_head commited;68 spinlock_t lock;69};70 71void drm_flip_work_queue(struct drm_flip_work *work, void *val);72void drm_flip_work_commit(struct drm_flip_work *work,73 struct workqueue_struct *wq);74void drm_flip_work_init(struct drm_flip_work *work,75 const char *name, drm_flip_func_t func);76void drm_flip_work_cleanup(struct drm_flip_work *work);77 78#endif /* DRM_FLIP_WORK_H */79