162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright © 2014 Intel Corporation
362306a36Sopenharmony_ci *   Daniel Vetter <daniel.vetter@ffwll.ch>
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
662306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
762306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
862306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
962306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
1062306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1362306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1662306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1762306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1862306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1962306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2062306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2162306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#include <linux/kthread.h>
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#include <drm/drm_ioctl.h>
2762306a36Sopenharmony_ci#include <drm/drm_vblank.h>
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define DRM_IF_MAJOR 1
3062306a36Sopenharmony_ci#define DRM_IF_MINOR 4
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistruct dentry;
3562306a36Sopenharmony_cistruct dma_buf;
3662306a36Sopenharmony_cistruct iosys_map;
3762306a36Sopenharmony_cistruct drm_connector;
3862306a36Sopenharmony_cistruct drm_crtc;
3962306a36Sopenharmony_cistruct drm_framebuffer;
4062306a36Sopenharmony_cistruct drm_gem_object;
4162306a36Sopenharmony_cistruct drm_master;
4262306a36Sopenharmony_cistruct drm_minor;
4362306a36Sopenharmony_cistruct drm_prime_file_private;
4462306a36Sopenharmony_cistruct drm_printer;
4562306a36Sopenharmony_cistruct drm_vblank_crtc;
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/* drm_file.c */
4862306a36Sopenharmony_ciextern struct mutex drm_global_mutex;
4962306a36Sopenharmony_cibool drm_dev_needs_global_mutex(struct drm_device *dev);
5062306a36Sopenharmony_cistruct drm_file *drm_file_alloc(struct drm_minor *minor);
5162306a36Sopenharmony_civoid drm_file_free(struct drm_file *file);
5262306a36Sopenharmony_civoid drm_lastclose(struct drm_device *dev);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#ifdef CONFIG_PCI
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* drm_pci.c */
5762306a36Sopenharmony_ciint drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#else
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_cistatic inline int drm_pci_set_busid(struct drm_device *dev,
6262306a36Sopenharmony_ci				    struct drm_master *master)
6362306a36Sopenharmony_ci{
6462306a36Sopenharmony_ci	return -EINVAL;
6562306a36Sopenharmony_ci}
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#endif
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci/* drm_prime.c */
7062306a36Sopenharmony_ciint drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
7162306a36Sopenharmony_ci				 struct drm_file *file_priv);
7262306a36Sopenharmony_ciint drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
7362306a36Sopenharmony_ci				 struct drm_file *file_priv);
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_civoid drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
7662306a36Sopenharmony_civoid drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
7762306a36Sopenharmony_civoid drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
7862306a36Sopenharmony_ci				 uint32_t handle);
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* drm_drv.c */
8162306a36Sopenharmony_cistruct drm_minor *drm_minor_acquire(unsigned int minor_id);
8262306a36Sopenharmony_civoid drm_minor_release(struct drm_minor *minor);
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* drm_managed.c */
8562306a36Sopenharmony_civoid drm_managed_release(struct drm_device *dev);
8662306a36Sopenharmony_civoid drmm_add_final_kfree(struct drm_device *dev, void *container);
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* drm_vblank.c */
8962306a36Sopenharmony_cistatic inline bool drm_vblank_passed(u64 seq, u64 ref)
9062306a36Sopenharmony_ci{
9162306a36Sopenharmony_ci	return (seq - ref) <= (1 << 23);
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_civoid drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
9562306a36Sopenharmony_ciint drm_vblank_get(struct drm_device *dev, unsigned int pipe);
9662306a36Sopenharmony_civoid drm_vblank_put(struct drm_device *dev, unsigned int pipe);
9762306a36Sopenharmony_ciu64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci/* drm_vblank_work.c */
10062306a36Sopenharmony_cistatic inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
10162306a36Sopenharmony_ci{
10262306a36Sopenharmony_ci	kthread_flush_worker(vblank->worker);
10362306a36Sopenharmony_ci}
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_cistatic inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
10662306a36Sopenharmony_ci{
10762306a36Sopenharmony_ci	if (vblank->worker)
10862306a36Sopenharmony_ci		kthread_destroy_worker(vblank->worker);
10962306a36Sopenharmony_ci}
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ciint drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
11262306a36Sopenharmony_civoid drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
11362306a36Sopenharmony_civoid drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* IOCTLS */
11662306a36Sopenharmony_ciint drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
11762306a36Sopenharmony_ci			  struct drm_file *filp);
11862306a36Sopenharmony_ciint drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
11962306a36Sopenharmony_ci				 struct drm_file *file_priv);
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/* drm_irq.c */
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/* IOCTLS */
12462306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_DRM_LEGACY)
12562306a36Sopenharmony_ciint drm_legacy_irq_control(struct drm_device *dev, void *data,
12662306a36Sopenharmony_ci			   struct drm_file *file_priv);
12762306a36Sopenharmony_ci#endif
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ciint drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
13062306a36Sopenharmony_ci				struct drm_file *filp);
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ciint drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
13362306a36Sopenharmony_ci				  struct drm_file *filp);
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/* drm_auth.c */
13662306a36Sopenharmony_ciint drm_getmagic(struct drm_device *dev, void *data,
13762306a36Sopenharmony_ci		 struct drm_file *file_priv);
13862306a36Sopenharmony_ciint drm_authmagic(struct drm_device *dev, void *data,
13962306a36Sopenharmony_ci		  struct drm_file *file_priv);
14062306a36Sopenharmony_ciint drm_setmaster_ioctl(struct drm_device *dev, void *data,
14162306a36Sopenharmony_ci			struct drm_file *file_priv);
14262306a36Sopenharmony_ciint drm_dropmaster_ioctl(struct drm_device *dev, void *data,
14362306a36Sopenharmony_ci			 struct drm_file *file_priv);
14462306a36Sopenharmony_ciint drm_master_open(struct drm_file *file_priv);
14562306a36Sopenharmony_civoid drm_master_release(struct drm_file *file_priv);
14662306a36Sopenharmony_cibool drm_master_internal_acquire(struct drm_device *dev);
14762306a36Sopenharmony_civoid drm_master_internal_release(struct drm_device *dev);
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci/* drm_sysfs.c */
15062306a36Sopenharmony_ciextern struct class *drm_class;
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ciint drm_sysfs_init(void);
15362306a36Sopenharmony_civoid drm_sysfs_destroy(void);
15462306a36Sopenharmony_cistruct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
15562306a36Sopenharmony_ciint drm_sysfs_connector_add(struct drm_connector *connector);
15662306a36Sopenharmony_civoid drm_sysfs_connector_remove(struct drm_connector *connector);
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_civoid drm_sysfs_lease_event(struct drm_device *dev);
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* drm_gem.c */
16162306a36Sopenharmony_ciint drm_gem_init(struct drm_device *dev);
16262306a36Sopenharmony_ciint drm_gem_handle_create_tail(struct drm_file *file_priv,
16362306a36Sopenharmony_ci			       struct drm_gem_object *obj,
16462306a36Sopenharmony_ci			       u32 *handlep);
16562306a36Sopenharmony_ciint drm_gem_close_ioctl(struct drm_device *dev, void *data,
16662306a36Sopenharmony_ci			struct drm_file *file_priv);
16762306a36Sopenharmony_ciint drm_gem_flink_ioctl(struct drm_device *dev, void *data,
16862306a36Sopenharmony_ci			struct drm_file *file_priv);
16962306a36Sopenharmony_ciint drm_gem_open_ioctl(struct drm_device *dev, void *data,
17062306a36Sopenharmony_ci		       struct drm_file *file_priv);
17162306a36Sopenharmony_civoid drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
17262306a36Sopenharmony_civoid drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
17362306a36Sopenharmony_civoid drm_gem_print_info(struct drm_printer *p, unsigned int indent,
17462306a36Sopenharmony_ci			const struct drm_gem_object *obj);
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ciint drm_gem_pin(struct drm_gem_object *obj);
17762306a36Sopenharmony_civoid drm_gem_unpin(struct drm_gem_object *obj);
17862306a36Sopenharmony_ciint drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map);
17962306a36Sopenharmony_civoid drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci/* drm_debugfs.c drm_debugfs_crc.c */
18262306a36Sopenharmony_ci#if defined(CONFIG_DEBUG_FS)
18362306a36Sopenharmony_ciint drm_debugfs_init(struct drm_minor *minor, int minor_id,
18462306a36Sopenharmony_ci		     struct dentry *root);
18562306a36Sopenharmony_civoid drm_debugfs_cleanup(struct drm_minor *minor);
18662306a36Sopenharmony_civoid drm_debugfs_late_register(struct drm_device *dev);
18762306a36Sopenharmony_civoid drm_debugfs_connector_add(struct drm_connector *connector);
18862306a36Sopenharmony_civoid drm_debugfs_connector_remove(struct drm_connector *connector);
18962306a36Sopenharmony_civoid drm_debugfs_crtc_add(struct drm_crtc *crtc);
19062306a36Sopenharmony_civoid drm_debugfs_crtc_remove(struct drm_crtc *crtc);
19162306a36Sopenharmony_civoid drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
19262306a36Sopenharmony_ci#else
19362306a36Sopenharmony_cistatic inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
19462306a36Sopenharmony_ci				   struct dentry *root)
19562306a36Sopenharmony_ci{
19662306a36Sopenharmony_ci	return 0;
19762306a36Sopenharmony_ci}
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_cistatic inline void drm_debugfs_cleanup(struct drm_minor *minor)
20062306a36Sopenharmony_ci{
20162306a36Sopenharmony_ci}
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_cistatic inline void drm_debugfs_late_register(struct drm_device *dev)
20462306a36Sopenharmony_ci{
20562306a36Sopenharmony_ci}
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_cistatic inline void drm_debugfs_connector_add(struct drm_connector *connector)
20862306a36Sopenharmony_ci{
20962306a36Sopenharmony_ci}
21062306a36Sopenharmony_cistatic inline void drm_debugfs_connector_remove(struct drm_connector *connector)
21162306a36Sopenharmony_ci{
21262306a36Sopenharmony_ci}
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_cistatic inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
21562306a36Sopenharmony_ci{
21662306a36Sopenharmony_ci}
21762306a36Sopenharmony_cistatic inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
21862306a36Sopenharmony_ci{
21962306a36Sopenharmony_ci}
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_cistatic inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
22262306a36Sopenharmony_ci{
22362306a36Sopenharmony_ci}
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci#endif
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_cidrm_ioctl_t drm_version;
22862306a36Sopenharmony_cidrm_ioctl_t drm_getunique;
22962306a36Sopenharmony_cidrm_ioctl_t drm_getclient;
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci/* drm_syncobj.c */
23262306a36Sopenharmony_civoid drm_syncobj_open(struct drm_file *file_private);
23362306a36Sopenharmony_civoid drm_syncobj_release(struct drm_file *file_private);
23462306a36Sopenharmony_ciint drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
23562306a36Sopenharmony_ci			     struct drm_file *file_private);
23662306a36Sopenharmony_ciint drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
23762306a36Sopenharmony_ci			      struct drm_file *file_private);
23862306a36Sopenharmony_ciint drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
23962306a36Sopenharmony_ci				   struct drm_file *file_private);
24062306a36Sopenharmony_ciint drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
24162306a36Sopenharmony_ci				   struct drm_file *file_private);
24262306a36Sopenharmony_ciint drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
24362306a36Sopenharmony_ci			       struct drm_file *file_private);
24462306a36Sopenharmony_ciint drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
24562306a36Sopenharmony_ci			   struct drm_file *file_private);
24662306a36Sopenharmony_ciint drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
24762306a36Sopenharmony_ci				    struct drm_file *file_private);
24862306a36Sopenharmony_ciint drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
24962306a36Sopenharmony_ci			      struct drm_file *file_private);
25062306a36Sopenharmony_ciint drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
25162306a36Sopenharmony_ci			    struct drm_file *file_private);
25262306a36Sopenharmony_ciint drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
25362306a36Sopenharmony_ci			     struct drm_file *file_private);
25462306a36Sopenharmony_ciint drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
25562306a36Sopenharmony_ci				      struct drm_file *file_private);
25662306a36Sopenharmony_ciint drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
25762306a36Sopenharmony_ci			    struct drm_file *file_private);
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci/* drm_framebuffer.c */
26062306a36Sopenharmony_civoid drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
26162306a36Sopenharmony_ci				const struct drm_framebuffer *fb);
26262306a36Sopenharmony_civoid drm_framebuffer_debugfs_init(struct drm_minor *minor);
263