OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [drm/] [via_map.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3
 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice (including the
13
 * next paragraph) shall be included in all copies or substantial portions
14
 * of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19
 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
23
 */
24
#define __NO_VERSION__
25
#include "via.h"
26
#include "drmP.h"
27
#include "via_drv.h"
28
 
29
int via_do_init_map(drm_device_t *dev, drm_via_init_t *init)
30
{
31
        drm_via_private_t *dev_priv;
32
        struct list_head *list;
33
 
34
        DRM_DEBUG("%s\n", __FUNCTION__);
35
 
36
        dev_priv = DRM(alloc)(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
37
        if (dev_priv == NULL)
38
                return -ENOMEM;
39
 
40
        memset(dev_priv, 0, sizeof(drm_via_private_t));
41
 
42
        list_for_each(list, &dev->maplist->head) {
43
                drm_map_list_t *r_list = (drm_map_list_t *)list;
44
                if ( r_list->map &&
45
                    r_list->map->type == _DRM_SHM &&
46
                    r_list->map->flags & _DRM_CONTAINS_LOCK) {
47
                        dev_priv->sarea = r_list->map;
48
                        break;
49
                }
50
        }
51
        if (!dev_priv->sarea) {
52
                DRM_ERROR("could not find sarea!\n");
53
                dev->dev_private = (void *)dev_priv;
54
                via_do_cleanup_map(dev);
55
                return -EINVAL;
56
        }
57
 
58
        DRM_FIND_MAP(dev_priv->fb, init->fb_offset);
59
        if (!dev_priv->fb) {
60
                DRM_ERROR("could not find framebuffer!\n");
61
                dev->dev_private = (void *)dev_priv;
62
                via_do_cleanup_map(dev);
63
                return -EINVAL;
64
        }
65
        DRM_FIND_MAP(dev_priv->mmio, init->mmio_offset);
66
        if (!dev_priv->mmio) {
67
                DRM_ERROR("could not find mmio region!\n");
68
                dev->dev_private = (void *)dev_priv;
69
                via_do_cleanup_map(dev);
70
                return -EINVAL;
71
        }
72
 
73
        dev_priv->sarea_priv =  (drm_via_sarea_t *)((u8 *)dev_priv->sarea->handle +
74
                                     init->sarea_priv_offset);
75
 
76
        dev_priv->agpAddr = init->agpAddr;
77
 
78
        dev->dev_private = (void *)dev_priv;
79
 
80
        return 0;
81
}
82
 
83
int via_do_cleanup_map(drm_device_t *dev)
84
{
85
        if (dev->dev_private) {
86
 
87
                drm_via_private_t *dev_priv = dev->dev_private;
88
 
89
                DRM(free)(dev_priv, sizeof(drm_via_private_t),
90
                           DRM_MEM_DRIVER);
91
                dev->dev_private = NULL;
92
        }
93
 
94
        return 0;
95
}
96
 
97
int via_map_init(struct inode *inode, struct file *filp,
98
                   unsigned int cmd, unsigned long arg)
99
{
100
        drm_file_t *priv = filp->private_data;
101
        drm_device_t *dev = priv->dev;
102
        drm_via_init_t init;
103
 
104
        DRM_DEBUG("%s\n", __FUNCTION__);
105
 
106
        if (copy_from_user(&init, (drm_via_init_t *)arg, sizeof(init)))
107
                return -EFAULT;
108
 
109
        switch (init.func) {
110
            case VIA_INIT_MAP:
111
                return via_do_init_map(dev, &init);
112
            case VIA_CLEANUP_MAP:
113
                return via_do_cleanup_map(dev);
114
        }
115
 
116
        return -EINVAL;
117
}
118
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.