118882995SDaniel Vetter /*
218882995SDaniel Vetter * Copyright © 2014 Intel Corporation
318882995SDaniel Vetter * Daniel Vetter <daniel.vetter@ffwll.ch>
418882995SDaniel Vetter *
518882995SDaniel Vetter * Permission is hereby granted, free of charge, to any person obtaining a
618882995SDaniel Vetter * copy of this software and associated documentation files (the "Software"),
718882995SDaniel Vetter * to deal in the Software without restriction, including without limitation
818882995SDaniel Vetter * the rights to use, copy, modify, merge, publish, distribute, sublicense,
918882995SDaniel Vetter * and/or sell copies of the Software, and to permit persons to whom the
1018882995SDaniel Vetter * Software is furnished to do so, subject to the following conditions:
1118882995SDaniel Vetter *
1218882995SDaniel Vetter * The above copyright notice and this permission notice shall be included in
1318882995SDaniel Vetter * all copies or substantial portions of the Software.
1418882995SDaniel Vetter *
1518882995SDaniel Vetter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1618882995SDaniel Vetter * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1718882995SDaniel Vetter * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1818882995SDaniel Vetter * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1918882995SDaniel Vetter * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2018882995SDaniel Vetter * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2118882995SDaniel Vetter * OTHER DEALINGS IN THE SOFTWARE.
2218882995SDaniel Vetter */
2318882995SDaniel Vetter
24b5d7cb76SJani Nikula #ifndef __DRM_INTERNAL_H__
25b5d7cb76SJani Nikula #define __DRM_INTERNAL_H__
26b5d7cb76SJani Nikula
275e6c2b4fSLyude Paul #include <linux/kthread.h>
288af46811SJani Nikula #include <linux/types.h>
295e6c2b4fSLyude Paul
3099f45e32SDaniel Vetter #include <drm/drm_ioctl.h>
315e6c2b4fSLyude Paul #include <drm/drm_vblank.h>
3299f45e32SDaniel Vetter
3382d5e73fSDavid Herrmann #define DRM_IF_MAJOR 1
3482d5e73fSDavid Herrmann #define DRM_IF_MINOR 4
3582d5e73fSDavid Herrmann
36ecb2e2fdSSam Ravnborg #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
37ecb2e2fdSSam Ravnborg
387a44fdceSSam Ravnborg struct dentry;
3999f45e32SDaniel Vetter struct dma_buf;
407938f421SLucas De Marchi struct iosys_map;
417a44fdceSSam Ravnborg struct drm_connector;
427a44fdceSSam Ravnborg struct drm_crtc;
437a44fdceSSam Ravnborg struct drm_framebuffer;
447a44fdceSSam Ravnborg struct drm_gem_object;
457a44fdceSSam Ravnborg struct drm_master;
467a44fdceSSam Ravnborg struct drm_minor;
477a44fdceSSam Ravnborg struct drm_prime_file_private;
487a44fdceSSam Ravnborg struct drm_printer;
495e6c2b4fSLyude Paul struct drm_vblank_crtc;
5099f45e32SDaniel Vetter
519acdac68SDaniel Vetter /* drm_file.c */
5244af3f5cSDaniel Vetter extern struct mutex drm_global_mutex;
534017ad7bSDaniel Vetter bool drm_dev_needs_global_mutex(struct drm_device *dev);
541572042aSDavid Herrmann struct drm_file *drm_file_alloc(struct drm_minor *minor);
551572042aSDavid Herrmann void drm_file_free(struct drm_file *file);
5667d0ec4eSDaniel Vetter
575c7a0bb0SThomas Zimmermann #ifdef CONFIG_PCI
585c7a0bb0SThomas Zimmermann
5967d0ec4eSDaniel Vetter /* drm_pci.c */
605c484ceeSDaniel Vetter int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
6167d0ec4eSDaniel Vetter
625c7a0bb0SThomas Zimmermann #else
635c7a0bb0SThomas Zimmermann
drm_pci_set_busid(struct drm_device * dev,struct drm_master * master)645c7a0bb0SThomas Zimmermann static inline int drm_pci_set_busid(struct drm_device *dev,
655c7a0bb0SThomas Zimmermann struct drm_master *master)
665c7a0bb0SThomas Zimmermann {
675c7a0bb0SThomas Zimmermann return -EINVAL;
685c7a0bb0SThomas Zimmermann }
695c7a0bb0SThomas Zimmermann
705c7a0bb0SThomas Zimmermann #endif
715c7a0bb0SThomas Zimmermann
7267d0ec4eSDaniel Vetter /* drm_prime.c */
7367d0ec4eSDaniel Vetter int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
7467d0ec4eSDaniel Vetter struct drm_file *file_priv);
7567d0ec4eSDaniel Vetter int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
7667d0ec4eSDaniel Vetter struct drm_file *file_priv);
7767d0ec4eSDaniel Vetter
7867d0ec4eSDaniel Vetter void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
7967d0ec4eSDaniel Vetter void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
80ea2aa97cSJeffy Chen void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
81ea2aa97cSJeffy Chen uint32_t handle);
8267d0ec4eSDaniel Vetter
83c6603c74SDaniel Vetter /* drm_managed.c */
84c6603c74SDaniel Vetter void drm_managed_release(struct drm_device *dev);
85a7d39439SDaniel Vetter void drmm_add_final_kfree(struct drm_device *dev, void *container);
86c6603c74SDaniel Vetter
873ed4351aSDaniel Vetter /* drm_vblank.c */
drm_vblank_passed(u64 seq,u64 ref)885e6c2b4fSLyude Paul static inline bool drm_vblank_passed(u64 seq, u64 ref)
895e6c2b4fSLyude Paul {
905e6c2b4fSLyude Paul return (seq - ref) <= (1 << 23);
915e6c2b4fSLyude Paul }
925e6c2b4fSLyude Paul
933ed4351aSDaniel Vetter void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
945e6c2b4fSLyude Paul int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
955e6c2b4fSLyude Paul void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
965e6c2b4fSLyude Paul u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
975e6c2b4fSLyude Paul
985e6c2b4fSLyude Paul /* drm_vblank_work.c */
drm_vblank_flush_worker(struct drm_vblank_crtc * vblank)995e6c2b4fSLyude Paul static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
1005e6c2b4fSLyude Paul {
1015e6c2b4fSLyude Paul kthread_flush_worker(vblank->worker);
1025e6c2b4fSLyude Paul }
1035e6c2b4fSLyude Paul
drm_vblank_destroy_worker(struct drm_vblank_crtc * vblank)1045e6c2b4fSLyude Paul static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
1055e6c2b4fSLyude Paul {
1064979524fSShang XiaoJing if (vblank->worker)
1075e6c2b4fSLyude Paul kthread_destroy_worker(vblank->worker);
1085e6c2b4fSLyude Paul }
1095e6c2b4fSLyude Paul
1105e6c2b4fSLyude Paul int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
1115e6c2b4fSLyude Paul void drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
1125e6c2b4fSLyude Paul void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
113b9876d50SDaniel Vetter
114b9876d50SDaniel Vetter /* IOCTLS */
115b6dcaaacSDaniel Vetter int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
116b9876d50SDaniel Vetter struct drm_file *filp);
117b6dcaaacSDaniel Vetter
118b6dcaaacSDaniel Vetter /* drm_irq.c */
119b6dcaaacSDaniel Vetter
120b6dcaaacSDaniel Vetter /* IOCTLS */
1213064abfaSKeith Packard int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
1223064abfaSKeith Packard struct drm_file *filp);
1233064abfaSKeith Packard
1243064abfaSKeith Packard int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
1253064abfaSKeith Packard struct drm_file *filp);
1263064abfaSKeith Packard
12767d0ec4eSDaniel Vetter /* drm_auth.c */
12867d0ec4eSDaniel Vetter int drm_getmagic(struct drm_device *dev, void *data,
12967d0ec4eSDaniel Vetter struct drm_file *file_priv);
13067d0ec4eSDaniel Vetter int drm_authmagic(struct drm_device *dev, void *data,
13167d0ec4eSDaniel Vetter struct drm_file *file_priv);
1326548f4e7SDaniel Vetter int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1336548f4e7SDaniel Vetter struct drm_file *file_priv);
1346548f4e7SDaniel Vetter int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1356548f4e7SDaniel Vetter struct drm_file *file_priv);
1362cbae7e6SDaniel Vetter int drm_master_open(struct drm_file *file_priv);
13714d71ebdSDaniel Vetter void drm_master_release(struct drm_file *file_priv);
13803a9606eSNoralf Trønnes bool drm_master_internal_acquire(struct drm_device *dev);
13903a9606eSNoralf Trønnes void drm_master_internal_release(struct drm_device *dev);
14067d0ec4eSDaniel Vetter
14167d0ec4eSDaniel Vetter /* drm_sysfs.c */
14200285be8SDaniel Vetter extern struct class *drm_class;
14300285be8SDaniel Vetter
144fcc90213SDavid Herrmann int drm_sysfs_init(void);
14567d0ec4eSDaniel Vetter void drm_sysfs_destroy(void);
14667d0ec4eSDaniel Vetter struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
14767d0ec4eSDaniel Vetter int drm_sysfs_connector_add(struct drm_connector *connector);
14821b6c281SVille Syrjälä int drm_sysfs_connector_add_late(struct drm_connector *connector);
14921b6c281SVille Syrjälä void drm_sysfs_connector_remove_early(struct drm_connector *connector);
15067d0ec4eSDaniel Vetter void drm_sysfs_connector_remove(struct drm_connector *connector);
15167d0ec4eSDaniel Vetter
152ce858828SDaniel Vetter void drm_sysfs_lease_event(struct drm_device *dev);
153ce858828SDaniel Vetter
15467d0ec4eSDaniel Vetter /* drm_gem.c */
15567d0ec4eSDaniel Vetter int drm_gem_init(struct drm_device *dev);
15667d0ec4eSDaniel Vetter int drm_gem_handle_create_tail(struct drm_file *file_priv,
15767d0ec4eSDaniel Vetter struct drm_gem_object *obj,
15867d0ec4eSDaniel Vetter u32 *handlep);
15967d0ec4eSDaniel Vetter int drm_gem_close_ioctl(struct drm_device *dev, void *data,
16067d0ec4eSDaniel Vetter struct drm_file *file_priv);
16167d0ec4eSDaniel Vetter int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
16267d0ec4eSDaniel Vetter struct drm_file *file_priv);
16367d0ec4eSDaniel Vetter int drm_gem_open_ioctl(struct drm_device *dev, void *data,
16467d0ec4eSDaniel Vetter struct drm_file *file_priv);
16567d0ec4eSDaniel Vetter void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
16667d0ec4eSDaniel Vetter void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
16745d58b40SNoralf Trønnes void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
16845d58b40SNoralf Trønnes const struct drm_gem_object *obj);
169e7f0a889SDaniel Vetter
170*a7802784SThomas Zimmermann int drm_gem_pin_locked(struct drm_gem_object *obj);
171*a7802784SThomas Zimmermann void drm_gem_unpin_locked(struct drm_gem_object *obj);
172eb69c8a4SDaniel Vetter int drm_gem_pin(struct drm_gem_object *obj);
173eb69c8a4SDaniel Vetter void drm_gem_unpin(struct drm_gem_object *obj);
1747938f421SLucas De Marchi int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map);
1757938f421SLucas De Marchi void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
176eb69c8a4SDaniel Vetter
1770cad7f71SDaniel Vetter /* drm_debugfs.c drm_debugfs_crc.c */
178c2611031SDaniel Vetter #if defined(CONFIG_DEBUG_FS)
1790b30d57aSChristian König void drm_debugfs_dev_fini(struct drm_device *dev);
1800b30d57aSChristian König void drm_debugfs_dev_register(struct drm_device *dev);
1810b30d57aSChristian König int drm_debugfs_register(struct drm_minor *minor, int minor_id,
182c2611031SDaniel Vetter struct dentry *root);
1838e455145SChristian König void drm_debugfs_unregister(struct drm_minor *minor);
184b792e640SGreg Kroah-Hartman void drm_debugfs_connector_add(struct drm_connector *connector);
185c2611031SDaniel Vetter void drm_debugfs_connector_remove(struct drm_connector *connector);
186b792e640SGreg Kroah-Hartman void drm_debugfs_crtc_add(struct drm_crtc *crtc);
1879edbf1faSTomeu Vizoso void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
188b792e640SGreg Kroah-Hartman void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
189caf525edSDmitry Baryshkov void drm_debugfs_encoder_add(struct drm_encoder *encoder);
190caf525edSDmitry Baryshkov void drm_debugfs_encoder_remove(struct drm_encoder *encoder);
191c2611031SDaniel Vetter #else
drm_debugfs_dev_fini(struct drm_device * dev)1920b30d57aSChristian König static inline void drm_debugfs_dev_fini(struct drm_device *dev)
1930b30d57aSChristian König {
1940b30d57aSChristian König }
1950b30d57aSChristian König
drm_debugfs_dev_register(struct drm_device * dev)1960b30d57aSChristian König static inline void drm_debugfs_dev_register(struct drm_device *dev)
1970b30d57aSChristian König {
1980b30d57aSChristian König }
1990b30d57aSChristian König
drm_debugfs_register(struct drm_minor * minor,int minor_id,struct dentry * root)2000b30d57aSChristian König static inline int drm_debugfs_register(struct drm_minor *minor, int minor_id,
201c2611031SDaniel Vetter struct dentry *root)
202c2611031SDaniel Vetter {
203c2611031SDaniel Vetter return 0;
204c2611031SDaniel Vetter }
205c2611031SDaniel Vetter
drm_debugfs_unregister(struct drm_minor * minor)2068e455145SChristian König static inline void drm_debugfs_unregister(struct drm_minor *minor)
207c2611031SDaniel Vetter {
208c2611031SDaniel Vetter }
209c2611031SDaniel Vetter
drm_debugfs_connector_add(struct drm_connector * connector)210b792e640SGreg Kroah-Hartman static inline void drm_debugfs_connector_add(struct drm_connector *connector)
211c2611031SDaniel Vetter {
212c2611031SDaniel Vetter }
drm_debugfs_connector_remove(struct drm_connector * connector)213c2611031SDaniel Vetter static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
214c2611031SDaniel Vetter {
215c2611031SDaniel Vetter }
2169edbf1faSTomeu Vizoso
drm_debugfs_crtc_add(struct drm_crtc * crtc)217b792e640SGreg Kroah-Hartman static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
2189edbf1faSTomeu Vizoso {
2199edbf1faSTomeu Vizoso }
drm_debugfs_crtc_remove(struct drm_crtc * crtc)2209edbf1faSTomeu Vizoso static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
2219edbf1faSTomeu Vizoso {
2229edbf1faSTomeu Vizoso }
2239edbf1faSTomeu Vizoso
drm_debugfs_crtc_crc_add(struct drm_crtc * crtc)224b792e640SGreg Kroah-Hartman static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
2259edbf1faSTomeu Vizoso {
2269edbf1faSTomeu Vizoso }
227e9083420SDave Airlie
drm_debugfs_encoder_add(struct drm_encoder * encoder)228caf525edSDmitry Baryshkov static inline void drm_debugfs_encoder_add(struct drm_encoder *encoder)
229caf525edSDmitry Baryshkov {
230caf525edSDmitry Baryshkov }
231caf525edSDmitry Baryshkov
drm_debugfs_encoder_remove(struct drm_encoder * encoder)232caf525edSDmitry Baryshkov static inline void drm_debugfs_encoder_remove(struct drm_encoder *encoder)
233caf525edSDmitry Baryshkov {
234caf525edSDmitry Baryshkov }
235caf525edSDmitry Baryshkov
236c2611031SDaniel Vetter #endif
237e9083420SDave Airlie
238012c6741SAl Viro drm_ioctl_t drm_version;
23917e3dadeSAl Viro drm_ioctl_t drm_getunique;
2409e92662dSAl Viro drm_ioctl_t drm_getclient;
241af3c8d98SLinus Torvalds
242e9083420SDave Airlie /* drm_syncobj.c */
243e9083420SDave Airlie void drm_syncobj_open(struct drm_file *file_private);
244e9083420SDave Airlie void drm_syncobj_release(struct drm_file *file_private);
245e9083420SDave Airlie int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
246e9083420SDave Airlie struct drm_file *file_private);
247e9083420SDave Airlie int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
248e9083420SDave Airlie struct drm_file *file_private);
249e9083420SDave Airlie int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
250e9083420SDave Airlie struct drm_file *file_private);
251e9083420SDave Airlie int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
252e9083420SDave Airlie struct drm_file *file_private);
253ea569910SChunming Zhou int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
254ea569910SChunming Zhou struct drm_file *file_private);
2555e60a10eSDave Airlie int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
2565e60a10eSDave Airlie struct drm_file *file_private);
25701d6c357SChunming Zhou int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
25801d6c357SChunming Zhou struct drm_file *file_private);
259c7a47229SSimon Ser int drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
260c7a47229SSimon Ser struct drm_file *file_private);
261aa4035d2SJason Ekstrand int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
262aa4035d2SJason Ekstrand struct drm_file *file_private);
263ffa9443fSJason Ekstrand int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
264ffa9443fSJason Ekstrand struct drm_file *file_private);
26550d1ebefSChunming Zhou int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
26650d1ebefSChunming Zhou struct drm_file *file_private);
26727b575a9SChunming Zhou int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
26827b575a9SChunming Zhou struct drm_file *file_private);
26945d58b40SNoralf Trønnes
27045d58b40SNoralf Trønnes /* drm_framebuffer.c */
27145d58b40SNoralf Trønnes void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
27245d58b40SNoralf Trønnes const struct drm_framebuffer *fb);
2730b30d57aSChristian König void drm_framebuffer_debugfs_init(struct drm_device *dev);
2748af46811SJani Nikula
275b5d7cb76SJani Nikula #endif /* __DRM_INTERNAL_H__ */
276