omap: add omapdrm support
[platform/upstream/libdrm.git] / omap / omap_drm.h
1 /*
2  * include/drm/omap_drm.h
3  *
4  * Copyright (C) 2011 Texas Instruments
5  * Author: Rob Clark <rob@ti.com>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __OMAP_DRM_H__
21 #define __OMAP_DRM_H__
22
23 #include "drm.h"
24
25 /* Please note that modifications to all structs defined here are
26  * subject to backwards-compatibility constraints.
27  */
28
29 #define OMAP_PARAM_CHIPSET_ID   1       /* ie. 0x3430, 0x4430, etc */
30
31 struct drm_omap_param {
32         uint64_t param;                 /* in */
33         uint64_t value;                 /* in (set_param), out (get_param) */
34 };
35
36 struct drm_omap_get_base {
37         char plugin_name[64];           /* in */
38         uint32_t ioctl_base;            /* out */
39         uint32_t __pad;
40 };
41
42 #define OMAP_BO_SCANOUT         0x00000001      /* scanout capable (phys contiguous) */
43 #define OMAP_BO_CACHE_MASK      0x00000006      /* cache type mask, see cache modes */
44 #define OMAP_BO_TILED_MASK      0x00000f00      /* tiled mapping mask, see tiled modes */
45
46 /* cache modes */
47 #define OMAP_BO_CACHED          0x00000000      /* default */
48 #define OMAP_BO_WC              0x00000002      /* write-combine */
49 #define OMAP_BO_UNCACHED        0x00000004      /* strongly-ordered (uncached) */
50
51 /* tiled modes */
52 #define OMAP_BO_TILED_8         0x00000100
53 #define OMAP_BO_TILED_16        0x00000200
54 #define OMAP_BO_TILED_32        0x00000300
55 #define OMAP_BO_TILED           (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32)
56
57 union omap_gem_size {
58         uint32_t bytes;         /* (for non-tiled formats) */
59         struct {
60                 uint16_t width;
61                 uint16_t height;
62         } tiled;                /* (for tiled formats) */
63 };
64
65 struct drm_omap_gem_new {
66         union omap_gem_size size;       /* in */
67         uint32_t flags;                 /* in */
68         uint32_t handle;                /* out */
69         uint32_t __pad;
70 };
71
72 /* mask of operations: */
73 enum omap_gem_op {
74         OMAP_GEM_READ = 0x01,
75         OMAP_GEM_WRITE = 0x02,
76 };
77
78 struct drm_omap_gem_cpu_prep {
79         uint32_t handle;                /* buffer handle (in) */
80         uint32_t op;                    /* mask of omap_gem_op (in) */
81 };
82
83 struct drm_omap_gem_cpu_fini {
84         uint32_t handle;                /* buffer handle (in) */
85         uint32_t op;                    /* mask of omap_gem_op (in) */
86         /* TODO maybe here we pass down info about what regions are touched
87          * by sw so we can be clever about cache ops?  For now a placeholder,
88          * set to zero and we just do full buffer flush..
89          */
90         uint32_t nregions;
91         uint32_t __pad;
92 };
93
94 struct drm_omap_gem_info {
95         uint32_t handle;                /* buffer handle (in) */
96         uint32_t pad;
97         uint64_t offset;                /* mmap offset (out) */
98         /* note: in case of tiled buffers, the user virtual size can be
99          * different from the physical size (ie. how many pages are needed
100          * to back the object) which is returned in DRM_IOCTL_GEM_OPEN..
101          * This size here is the one that should be used if you want to
102          * mmap() the buffer:
103          */
104         uint32_t size;                  /* virtual size for mmap'ing (out) */
105         uint32_t __pad;
106 };
107
108 #define DRM_OMAP_GET_PARAM              0x00
109 #define DRM_OMAP_SET_PARAM              0x01
110 #define DRM_OMAP_GET_BASE               0x02
111 #define DRM_OMAP_GEM_NEW                0x03
112 #define DRM_OMAP_GEM_CPU_PREP           0x04
113 #define DRM_OMAP_GEM_CPU_FINI           0x05
114 #define DRM_OMAP_GEM_INFO               0x06
115 #define DRM_OMAP_NUM_IOCTLS             0x07
116
117 #define DRM_IOCTL_OMAP_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GET_PARAM, struct drm_omap_param)
118 #define DRM_IOCTL_OMAP_SET_PARAM        DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_SET_PARAM, struct drm_omap_param)
119 #define DRM_IOCTL_OMAP_GET_BASE         DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GET_BASE, struct drm_omap_get_base)
120 #define DRM_IOCTL_OMAP_GEM_NEW          DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GEM_NEW, struct drm_omap_gem_new)
121 #define DRM_IOCTL_OMAP_GEM_CPU_PREP     DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_PREP, struct drm_omap_gem_cpu_prep)
122 #define DRM_IOCTL_OMAP_GEM_CPU_FINI     DRM_IOW (DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_FINI, struct drm_omap_gem_cpu_fini)
123 #define DRM_IOCTL_OMAP_GEM_INFO         DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GEM_INFO, struct drm_omap_gem_info)
124
125 #endif /* __OMAP_DRM_H__ */