2 Copyright 2010, The AROS Development Team. All rights reserved.
9 extern struct drm_driver
* current_drm_driver
;
11 /* FIXME: Array for now, list maybe in future */
12 struct drm_file
* drm_files
[128] = {NULL
};
15 drmCommandNone(int fd
, unsigned long drmCommandIndex
)
20 if (!current_drm_driver
|| !current_drm_driver
->ioctls
)
23 return current_drm_driver
->ioctls
[drmCommandIndex
].func(current_drm_driver
->dev
, NULL
, drm_files
[fd
]);
27 drmCommandRead(int fd
, unsigned long drmCommandIndex
, void *data
, unsigned long size
)
32 if (!current_drm_driver
|| !current_drm_driver
->ioctls
)
35 return current_drm_driver
->ioctls
[drmCommandIndex
].func(current_drm_driver
->dev
, data
, drm_files
[fd
]);
39 drmCommandWrite(int fd
, unsigned long drmCommandIndex
, void *data
, unsigned long size
)
44 if (!current_drm_driver
|| !current_drm_driver
->ioctls
)
47 return current_drm_driver
->ioctls
[drmCommandIndex
].func(current_drm_driver
->dev
, data
, drm_files
[fd
]);
51 drmCommandWriteRead(int fd
, unsigned long drmCommandIndex
, void *data
, unsigned long size
)
56 if (!current_drm_driver
|| !current_drm_driver
->ioctls
)
59 return current_drm_driver
->ioctls
[drmCommandIndex
].func(current_drm_driver
->dev
, data
, drm_files
[fd
]);
63 drmOpen(const char *name
, const char *busid
)
67 for (i
= 0; i
< 128; i
++)
69 if (drm_files
[i
] == NULL
)
71 drm_files
[i
] = HIDDNouveauAlloc(sizeof(struct drm_file
));
72 spin_lock_init(&drm_files
[i
]->table_lock
);
73 INIT_LIST_HEAD(&drm_files
[i
]->fbs
);
74 if (current_drm_driver
->open
)
75 current_drm_driver
->open(current_drm_driver
->dev
, drm_files
[i
]);
86 struct drm_file
* f
= NULL
;
88 if (!(f
= drm_files
[fd
]))
93 if (current_drm_driver
->preclose
)
94 current_drm_driver
->preclose(current_drm_driver
->dev
, f
);
96 if (current_drm_driver
->postclose
)
97 current_drm_driver
->postclose(current_drm_driver
->dev
, f
);
105 drmGetVersion(int fd
)
107 static drmVersion ver
;
108 if (current_drm_driver
)
109 ver
.version_patchlevel
= current_drm_driver
->version_patchlevel
;
111 ver
.version_patchlevel
= 0;
117 drmFreeVersion(drmVersionPtr ptr
)
119 /* This is a no-op for now */
123 drmCreateContext(int fd
, drm_context_t
* handle
)
130 drmDestroyContext(int fd
, drm_context_t handle
)
136 int drmIoctl(int fd
, unsigned long request
, void *arg
)
147 case(DRM_IOCTL_GEM_CLOSE
):
148 ret
= drm_gem_close_ioctl(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
150 case(DRM_IOCTL_GEM_OPEN
):
151 ret
= drm_gem_open_ioctl(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
153 case(DRM_IOCTL_GEM_FLINK
):
154 ret
= drm_gem_flink_ioctl(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
156 case(DRM_IOCTL_MODE_ADDFB
):
157 ret
= drm_mode_addfb(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
159 case(DRM_IOCTL_MODE_RMFB
):
160 ret
= drm_mode_rmfb(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
162 case(DRM_IOCTL_MODE_SETCRTC
):
163 ret
= drm_mode_setcrtc(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
165 case(DRM_IOCTL_MODE_GETCRTC
):
166 ret
= drm_mode_getcrtc(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
168 case(DRM_IOCTL_MODE_GETRESOURCES
):
169 ret
= drm_mode_getresources(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
171 case(DRM_IOCTL_MODE_GETCONNECTOR
):
172 ret
= drm_mode_getconnector(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
174 case(DRM_IOCTL_MODE_CURSOR
):
175 ret
= drm_mode_cursor_ioctl(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
177 case(DRM_IOCTL_MODE_GETENCODER
):
178 ret
= drm_mode_getencoder(current_drm_driver
->dev
, arg
, drm_files
[fd
]);
181 DRM_IMPL("GEM COMMAND %d\n", request
);
183 /* FIXME: It is possible that -ERESTARTSYS needs to be translated to -EAGAIN here */
184 } while (ret
== -EINTR
|| ret
== -EAGAIN
);
189 void *drmMalloc(int size
)
191 return HIDDNouveauAlloc(size
);
194 void drmFree(void *pt
)