This source file includes following definitions.
- via_init_futex
- via_cleanup_futex
- via_release_futex
- via_decoder_futex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #include <drm/drm_device.h>
29 #include <drm/via_drm.h>
30
31 #include "via_drv.h"
32
33 void via_init_futex(drm_via_private_t *dev_priv)
34 {
35 unsigned int i;
36
37 DRM_DEBUG("\n");
38
39 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
40 init_waitqueue_head(&(dev_priv->decoder_queue[i]));
41 XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
42 }
43 }
44
45 void via_cleanup_futex(drm_via_private_t *dev_priv)
46 {
47 }
48
49 void via_release_futex(drm_via_private_t *dev_priv, int context)
50 {
51 unsigned int i;
52 volatile int *lock;
53
54 if (!dev_priv->sarea_priv)
55 return;
56
57 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
58 lock = (volatile int *)XVMCLOCKPTR(dev_priv->sarea_priv, i);
59 if ((_DRM_LOCKING_CONTEXT(*lock) == context)) {
60 if (_DRM_LOCK_IS_HELD(*lock)
61 && (*lock & _DRM_LOCK_CONT)) {
62 wake_up(&(dev_priv->decoder_queue[i]));
63 }
64 *lock = 0;
65 }
66 }
67 }
68
69 int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv)
70 {
71 drm_via_futex_t *fx = data;
72 volatile int *lock;
73 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
74 drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
75 int ret = 0;
76
77 DRM_DEBUG("\n");
78
79 if (fx->lock >= VIA_NR_XVMC_LOCKS)
80 return -EFAULT;
81
82 lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock);
83
84 switch (fx->func) {
85 case VIA_FUTEX_WAIT:
86 VIA_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock],
87 (fx->ms / 10) * (HZ / 100), *lock != fx->val);
88 return ret;
89 case VIA_FUTEX_WAKE:
90 wake_up(&(dev_priv->decoder_queue[fx->lock]));
91 return 0;
92 }
93 return 0;
94 }