drm: lindent the drm directory.
[deliverable/linux.git] / drivers / char / drm / via_video.c
CommitLineData
22f579c6
DA
1/*
2 * Copyright 2005 Thomas Hellstrom. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S), AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Thomas Hellstrom 2005.
24 *
25 * Video and XvMC related functions.
26 */
27
28#include "drmP.h"
29#include "via_drm.h"
30#include "via_drv.h"
31
b5e89ed5 32void via_init_futex(drm_via_private_t * dev_priv)
22f579c6
DA
33{
34 unsigned int i;
35
36 DRM_DEBUG("%s\n", __FUNCTION__);
37
38 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
39 DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
40 XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
41 }
42}
43
b5e89ed5 44void via_cleanup_futex(drm_via_private_t * dev_priv)
22f579c6 45{
b5e89ed5 46}
22f579c6 47
b5e89ed5 48void via_release_futex(drm_via_private_t * dev_priv, int context)
22f579c6
DA
49{
50 unsigned int i;
51 volatile int *lock;
52
b5e89ed5
DA
53 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
54 lock = (int *)XVMCLOCKPTR(dev_priv->sarea_priv, i);
55 if ((_DRM_LOCKING_CONTEXT(*lock) == context)) {
56 if (_DRM_LOCK_IS_HELD(*lock)
57 && (*lock & _DRM_LOCK_CONT)) {
58 DRM_WAKEUP(&(dev_priv->decoder_queue[i]));
22f579c6
DA
59 }
60 *lock = 0;
61 }
b5e89ed5
DA
62 }
63}
22f579c6 64
b5e89ed5 65int via_decoder_futex(DRM_IOCTL_ARGS)
22f579c6
DA
66{
67 DRM_DEVICE;
68 drm_via_futex_t fx;
69 volatile int *lock;
70 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
71 drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
72 int ret = 0;
73
74 DRM_DEBUG("%s\n", __FUNCTION__);
75
bbaf3641
AD
76 DRM_COPY_FROM_USER_IOCTL(fx, (drm_via_futex_t __user *) data,
77 sizeof(fx));
22f579c6
DA
78
79 if (fx.lock > VIA_NR_XVMC_LOCKS)
80 return -EFAULT;
81
82 lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);
83
84 switch (fx.func) {
85 case VIA_FUTEX_WAIT:
86 DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock],
87 (fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val);
88 return ret;
89 case VIA_FUTEX_WAKE:
90 DRM_WAKEUP(&(dev_priv->decoder_queue[fx.lock]));
91 return 0;
92 }
93 return 0;
94}
This page took 0.192277 seconds and 5 git commands to generate.