Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3769 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
#include "intel_batchbuffer.h"
32
#include "intel_memman.h"
33
#include "intel_driver.h"
34
 
35
static Bool
36
intel_driver_get_param(struct intel_driver_data *intel, int param, int *value)
37
{
38
   struct drm_i915_getparam gp;
39
 
40
   gp.param = param;
41
   gp.value = value;
42
 
43
   return (drmIoctl(intel->fd, DRM_IOCTL_I915_GETPARAM, &gp) == 0);
44
 
45
}
46
 
47
static void intel_driver_get_revid(struct intel_driver_data *intel, int *value)
48
{
49
    *value = 2; /* assume it is at least  B-steping */
50
 
51
	return;
52
}
53
 
54
Bool
55
intel_driver_init(VADriverContextP ctx)
56
{
57
    struct intel_driver_data *intel = intel_driver_data(ctx);
58
    struct drm_state * const drm_state = (struct drm_state *)ctx->drm_state;
59
    int has_exec2, has_bsd, has_blt;
60
 
61
    assert(drm_state);
62
    assert(VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI1) ||
63
           VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2) ||
64
           VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_CUSTOM));
65
 
66
   printf("%s context %p\n", __FUNCTION__, ctx);
67
 
68
    intel->fd = drm_state->fd;
69
    intel->dri2Enabled = 1;
70
 
71
    intel->locked = 0;
72
//    pthread_mutex_init(&intel->ctxmutex, NULL);
73
 
74
    intel_driver_get_param(intel, I915_PARAM_CHIPSET_ID, &intel->device_id);
75
    if (intel_driver_get_param(intel, I915_PARAM_HAS_EXECBUF2, &has_exec2))
76
        intel->has_exec2 = has_exec2;
77
    if (intel_driver_get_param(intel, I915_PARAM_HAS_BSD, &has_bsd))
78
        intel->has_bsd = has_bsd;
79
    if (intel_driver_get_param(intel, I915_PARAM_HAS_BLT, &has_blt))
80
        intel->has_blt = has_blt;
81
 
82
    printf("device_id=%x has_exec2=%d has_bsd=%d has_blt=%d\n",
83
           intel->device_id, intel->has_exec2, intel->has_bsd, intel->has_blt);
84
 
85
    intel_driver_get_revid(intel, &intel->revision);
86
    intel_memman_init(intel);
87
    return True;
88
}
89
 
90
Bool
91
intel_driver_terminate(VADriverContextP ctx)
92
{
93
    struct intel_driver_data *intel = intel_driver_data(ctx);
94
 
95
    intel_memman_terminate(intel);
96
//    pthread_mutex_destroy(&intel->ctxmutex);
97
 
98
    return True;
99
}