xref: /netbsd-src/sys/external/bsd/drm2/vmwgfx/vmwgfx_task.h (revision a53f11173ae5a0eb82547dc88b62c4e22a581dd4)
1*a53f1117Sriastradh /*	$NetBSD: vmwgfx_task.h,v 1.2 2022/07/18 23:34:03 riastradh Exp $	*/
2cae04ea7Sriastradh 
3cae04ea7Sriastradh /*-
4cae04ea7Sriastradh  * Copyright (c) 2022 The NetBSD Foundation, Inc.
5cae04ea7Sriastradh  * All rights reserved.
6cae04ea7Sriastradh  *
7cae04ea7Sriastradh  * Redistribution and use in source and binary forms, with or without
8cae04ea7Sriastradh  * modification, are permitted provided that the following conditions
9cae04ea7Sriastradh  * are met:
10cae04ea7Sriastradh  * 1. Redistributions of source code must retain the above copyright
11cae04ea7Sriastradh  *    notice, this list of conditions and the following disclaimer.
12cae04ea7Sriastradh  * 2. Redistributions in binary form must reproduce the above copyright
13cae04ea7Sriastradh  *    notice, this list of conditions and the following disclaimer in the
14cae04ea7Sriastradh  *    documentation and/or other materials provided with the distribution.
15cae04ea7Sriastradh  *
16cae04ea7Sriastradh  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17cae04ea7Sriastradh  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18cae04ea7Sriastradh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19cae04ea7Sriastradh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20cae04ea7Sriastradh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21cae04ea7Sriastradh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22cae04ea7Sriastradh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23cae04ea7Sriastradh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24cae04ea7Sriastradh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25cae04ea7Sriastradh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26cae04ea7Sriastradh  * POSSIBILITY OF SUCH DAMAGE.
27cae04ea7Sriastradh  */
28cae04ea7Sriastradh 
29cae04ea7Sriastradh #ifndef	_VMWGFX_VMWGFX_TASK_H_
30cae04ea7Sriastradh #define	_VMWGFX_VMWGFX_TASK_H_
31cae04ea7Sriastradh 
32cae04ea7Sriastradh #include <sys/queue.h>
33cae04ea7Sriastradh #include <sys/workqueue.h>
34cae04ea7Sriastradh 
35cae04ea7Sriastradh struct vmwgfx_task {
36cae04ea7Sriastradh 	union {
37cae04ea7Sriastradh 		SIMPLEQ_ENTRY(vmwgfx_task)	queue;
38cae04ea7Sriastradh 		struct work			work;
39cae04ea7Sriastradh 	}			vt_u;
40cae04ea7Sriastradh 	void			(*vt_fn)(struct vmwgfx_task *);
41cae04ea7Sriastradh };
42cae04ea7Sriastradh 
43cae04ea7Sriastradh static inline void
vmwgfx_task_init(struct vmwgfx_task * task,void (* fn)(struct vmwgfx_task *))44cae04ea7Sriastradh vmwgfx_task_init(struct vmwgfx_task *task, void (*fn)(struct vmwgfx_task *))
45cae04ea7Sriastradh {
46cae04ea7Sriastradh 
47cae04ea7Sriastradh 	task->vt_fn = fn;
48cae04ea7Sriastradh }
49cae04ea7Sriastradh 
50*a53f1117Sriastradh void	vmwgfx_task_schedule(device_t, struct vmwgfx_task *);
51cae04ea7Sriastradh 
52cae04ea7Sriastradh #endif	/* _VMWGFX_VMWGFX_TASK_H_ */
53