2 * Copyright © 2009 Intel Corporation
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 * Xiang Haihao <haihao.xiang@intel.com>
26 * Zou Nan hai <nanhai.zou@intel.com>
31 #include "intel_batchbuffer.h"
32 #include "intel_memman.h"
33 #include "intel_driver.h"
36 intel_driver_get_param(struct intel_driver_data *intel, int param, int *value)
38 struct drm_i915_getparam gp;
43 return drmCommandWriteRead(intel->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)) == 0;
46 static void intel_driver_get_revid(struct intel_driver_data *intel, int *value)
52 fp = fopen("/sys/devices/pci0000:00/0000:00:02.0/config", "r");
55 if (fread(config_data, 1, 16, fp))
56 *value = config_data[PCI_REVID];
58 *value = 2; /* assume it is at least B-steping */
61 *value = 2; /* assume it is at least B-steping */
68 intel_driver_init(VADriverContextP ctx)
70 struct intel_driver_data *intel = intel_driver_data(ctx);
71 struct drm_state * const drm_state = (struct drm_state *)ctx->drm_state;
72 int has_exec2, has_bsd, has_blt;
75 assert(VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI1) ||
76 VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2) ||
77 VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_CUSTOM));
79 intel->fd = drm_state->fd;
80 intel->dri2Enabled = (VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2) ||
81 VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_CUSTOM));
83 if (!intel->dri2Enabled) {
88 pthread_mutex_init(&intel->ctxmutex, NULL);
90 intel_driver_get_param(intel, I915_PARAM_CHIPSET_ID, &intel->device_id);
91 if (intel_driver_get_param(intel, I915_PARAM_HAS_EXECBUF2, &has_exec2))
92 intel->has_exec2 = has_exec2;
93 if (intel_driver_get_param(intel, I915_PARAM_HAS_BSD, &has_bsd))
94 intel->has_bsd = has_bsd;
95 if (intel_driver_get_param(intel, I915_PARAM_HAS_BLT, &has_blt))
96 intel->has_blt = has_blt;
98 intel_driver_get_revid(intel, &intel->revision);
99 intel_memman_init(intel);
104 intel_driver_terminate(VADriverContextP ctx)
106 struct intel_driver_data *intel = intel_driver_data(ctx);
108 intel_memman_terminate(intel);
109 pthread_mutex_destroy(&intel->ctxmutex);