blob: 10743a0c3ecba01e9dd725e1a9308aa3239ddf48 [file] [log] [blame]
Chia-I Wuc6fb9af2014-08-04 11:28:43 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions 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 NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef INTEL_H
26#define INTEL_H
27
Chia-I Wu214dac62014-08-05 11:07:40 +080028#include <stdlib.h>
Chia-I Wuc6fb9af2014-08-04 11:28:43 +080029#include <stdbool.h>
Chia-I Wu214dac62014-08-05 11:07:40 +080030#include <string.h>
Chia-I Wuc6fb9af2014-08-04 11:28:43 +080031#include <assert.h>
32
33#include <xgl.h>
34#include <xglDbg.h>
35
36#include "icd.h"
37
Chia-I Wu214dac62014-08-05 11:07:40 +080038#define INTEL_API_VERSION XGL_MAKE_VERSION(0, 22, 0)
39#define INTEL_DRIVER_VERSION 0
40
41#define INTEL_GEN(gen) ((int) ((gen) * 100))
42
Chia-I Wue54854a2014-08-05 10:23:50 +080043#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
44
Chia-I Wu2132b562014-08-08 21:52:26 +080045/**
46 * Return true if val is power of two, or zero.
47 */
48static inline bool u_is_pow2(unsigned int val)
Chia-I Wua02cd522014-08-07 13:36:04 +080049{
Chia-I Wu2132b562014-08-08 21:52:26 +080050 return ((val & (val - 1)) == 0);
51}
52
53static inline unsigned int u_align(unsigned int val, unsigned alignment)
54{
55 assert(alignment && u_is_pow2(alignment));
Chia-I Wua02cd522014-08-07 13:36:04 +080056 return (val + alignment - 1) & ~(alignment - 1);
57}
58
Chia-I Wu2132b562014-08-08 21:52:26 +080059static inline unsigned int u_minify(unsigned int val, unsigned level)
60{
61 return (val >> level) ? val >> level : 1;
62}
63
Chia-I Wuc6fb9af2014-08-04 11:28:43 +080064#endif /* INTEL_H */