1/*
2 * Copyright © 2015 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 "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24#include "util/macros.h"
25#include "dev/intel_device_info.h"
26
27enum gfx_ver {
28   GFX4    = (1 << 0),
29   GFX45   = (1 << 1),
30   GFX5    = (1 << 2),
31   GFX6    = (1 << 3),
32   GFX7    = (1 << 4),
33   GFX75   = (1 << 5),
34   GFX8    = (1 << 6),
35   GFX9    = (1 << 7),
36   GFX10   = (1 << 8),
37   GFX11   = (1 << 9),
38   GFX12   = (1 << 10),
39   GFX125  = (1 << 11),
40   GFX_ALL = ~0
41};
42
43#define GFX_LT(ver) ((ver) - 1)
44#define GFX_GE(ver) (~GFX_LT(ver))
45#define GFX_LE(ver) (GFX_LT(ver) | (ver))
46
47static enum gfx_ver
48gfx_ver_from_devinfo(const struct intel_device_info *devinfo)
49{
50   switch (devinfo->verx10) {
51   case 40: return GFX4;
52   case 45: return GFX45;
53   case 50: return GFX5;
54   case 60: return GFX6;
55   case 70: return GFX7;
56   case 75: return GFX75;
57   case 80: return GFX8;
58   case 90: return GFX9;
59   case 110: return GFX11;
60   case 120: return GFX12;
61   case 125: return GFX125;
62   default:
63      unreachable("not reached");
64   }
65}
66