Subversion Repositories Kolibri OS

Rev

Rev 5361 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5361 serge 1
/*
2
 * Copyright © 2009 Intel Corporation
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the
6
 * "Software"), to deal in the Software without restriction, including
7
 * without limitation the rights to use, copy, modify, merge, publish,
8
 * distribute, sub license, and/or sell copies of the Software, and to
9
 * permit persons to whom the Software is furnished to do so, subject to
10
 * 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
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 *
24
 * Authors:
25
 *    Xiang Haihao 
26
 *    Zou Nan hai 
27
 *
28
 */
29
 
30
#include "sysdeps.h"
31
 
32
#include 
33
 
34
#include "intel_batchbuffer.h"
35
#include "intel_memman.h"
36
#include "intel_driver.h"
37
uint32_t g_intel_debug_option_flags = 0;
38
 
39
static Bool
40
intel_driver_get_param(struct intel_driver_data *intel, int param, int *value)
41
{
42
   struct drm_i915_getparam gp;
43
   int ret;
44
 
45
   gp.param = param;
46
   gp.value = value;
47
 
5366 serge 48
   return drmIoctl(intel->fd, DRM_IOCTL_I915_GETPARAM, &gp) == 0;
5361 serge 49
 
50
//   return drmCommandWriteRead(intel->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)) == 0;
51
}
52
 
53
static void intel_driver_get_revid(struct intel_driver_data *intel, int *value)
54
{
55
#if 0
56
#define PCI_REVID	8
57
	FILE *fp;
58
	char config_data[16];
59
 
60
	fp = fopen("/sys/devices/pci0000:00/0000:00:02.0/config", "r");
61
 
62
        if (fp) {
63
            if (fread(config_data, 1, 16, fp))
64
                *value = config_data[PCI_REVID];
65
            else
66
                *value = 2; /* assume it is at least  B-steping */
67
            fclose(fp);
68
        } else {
69
            *value = 2; /* assume it is at least  B-steping */
70
        }
71
#endif
72
 
73
    *value = 2;
74
	return;
75
}
76
 
77
extern const struct intel_device_info *i965_get_device_info(int devid);
78
 
79
bool
80
intel_driver_init(VADriverContextP ctx)
81
{
82
    struct intel_driver_data *intel = intel_driver_data(ctx);
83
    struct drm_state * const drm_state = (struct drm_state *)ctx->drm_state;
84
    int has_exec2 = 0, has_bsd = 0, has_blt = 0, has_vebox = 0;
85
    char *env_str = NULL;
86
 
87
    g_intel_debug_option_flags = 0;
88
//    if ((env_str = getenv("VA_INTEL_DEBUG")))
89
//        g_intel_debug_option_flags = atoi(env_str);
90
 
91
//    if (g_intel_debug_option_flags)
92
//        fprintf(stderr, "g_intel_debug_option_flags:%x\n", g_intel_debug_option_flags);
93
 
94
    assert(drm_state);
95
 
96
    intel->fd = drm_state->fd;
97
    intel->dri2Enabled = 1;
98
 
99
    intel->locked = 0;
100
//    pthread_mutex_init(&intel->ctxmutex, NULL);
101
 
102
    intel_driver_get_param(intel, I915_PARAM_CHIPSET_ID, &intel->device_id);
103
    intel->device_info = i965_get_device_info(intel->device_id);
104
 
105
    if (!intel->device_info)
106
        return false;
107
 
108
    if (intel_driver_get_param(intel, I915_PARAM_HAS_EXECBUF2, &has_exec2))
109
        intel->has_exec2 = has_exec2;
110
    if (intel_driver_get_param(intel, I915_PARAM_HAS_BSD, &has_bsd))
111
        intel->has_bsd = has_bsd;
112
    if (intel_driver_get_param(intel, I915_PARAM_HAS_BLT, &has_blt))
113
        intel->has_blt = has_blt;
114
    if (intel_driver_get_param(intel, I915_PARAM_HAS_VEBOX, &has_vebox))
115
        intel->has_vebox = !!has_vebox;
116
 
117
    intel_driver_get_revid(intel, &intel->revision);
118
    intel_memman_init(intel);
119
    return true;
120
}
121
 
122
void
123
intel_driver_terminate(VADriverContextP ctx)
124
{
125
    struct intel_driver_data *intel = intel_driver_data(ctx);
126
 
127
    intel_memman_terminate(intel);
128
//    pthread_mutex_destroy(&intel->ctxmutex);
129
}