LUT updates
[platform/upstream/libdrm.git] / shared-core / amd.h
1 /*
2  * Copyright 2007 Jérôme Glisse
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * 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  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * Authors:
25  *    Jerome Glisse <glisse@freedesktop.org>
26  */
27 #ifndef __AMD_H__
28 #define __AMD_H__
29
30 /* struct amd_cbuffer are for command buffer, this is the structure passed
31  * around during command validation (ie check that user have the right to
32  * execute the given command).
33  */
34 struct amd_cmd_bo
35 {
36         struct list_head            list;
37         uint64_t                    *offsets;
38         uint32_t                    *cdw_id;
39         struct drm_buffer_object    *bo;
40         unsigned int                handle;
41         uint64_t                    mask;
42         uint64_t                    flags;
43         uint32_t                    type;
44 };
45
46 struct amd_cmd
47 {
48         uint32_t                    *cdw;
49         uint32_t                    cdw_count;
50         struct drm_bo_kmap_obj      cdw_kmap;
51         size_t                      cdw_size;
52         struct amd_cmd_bo           *cdw_bo;
53         struct amd_cmd_bo           bo_unused;
54         struct amd_cmd_bo           bo_used;
55         struct amd_cmd_bo           *bo;
56         uint32_t                    bo_count;
57         void                        *driver;
58 };
59
60 struct amd_cmd_module
61 {
62         uint32_t numof_p0_checkers;
63         uint32_t numof_p3_checkers;
64         int (*check)(struct drm_device *dev, struct amd_cmd *cmd);
65         int (**check_p0)(struct drm_device *dev, struct amd_cmd *cmd,
66                          int cdw_id, int reg);
67         int (**check_p3)(struct drm_device *dev, struct amd_cmd *cmd,
68                          int cdw_id, int op, int count);
69 };
70
71 int amd_cmd_check(struct drm_device *dev, struct amd_cmd *cmd);
72 int amd_ioctl_cmd(struct drm_device *dev, void *data, struct drm_file *file);
73
74 static inline struct amd_cmd_bo *amd_cmd_get_bo(struct amd_cmd *cmd, int i)
75 {
76         if (i < cmd->bo_count && cmd->bo[i].type == DRM_AMD_CMD_BO_TYPE_DATA) {
77                 list_del(&cmd->bo[i].list);
78                 list_add_tail(&cmd->bo[i].list, &cmd->bo_used.list);
79                 return &cmd->bo[i]; 
80         }
81         return NULL;
82 }
83
84 /* struct amd_fb amd is for storing amd framebuffer informations
85  */
86 struct amd_fb
87 {
88         struct drm_device       *dev;
89         struct drm_crtc         *crtc;
90         struct drm_display_mode *fb_mode;
91         struct drm_framebuffer  *fb;
92 };
93
94 #endif