2014-07-24 12:10:04 +02:00
# ifndef __DRM_LEGACY_H__
# define __DRM_LEGACY_H__
/*
* Copyright ( c ) 2014 David Herrmann < dh . herrmann @ gmail . com >
*
* Permission is hereby granted , free of charge , to any person obtaining a
* copy of this software and associated documentation files ( the " Software " ) ,
* to deal in the Software without restriction , including without limitation
* the rights to use , copy , modify , merge , publish , distribute , sublicense ,
* and / or sell copies of the Software , and to permit persons to whom the
* Software is furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL
* THE COPYRIGHT HOLDER ( S ) OR AUTHOR ( S ) BE LIABLE FOR ANY CLAIM , DAMAGES OR
* OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE ,
* ARISING FROM , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE .
*/
2014-08-29 12:12:28 +02:00
/*
* This file contains legacy interfaces that modern drm drivers
* should no longer be using . They cannot be removed as legacy
* drivers use them , and removing them are API breaks .
*/
2014-08-29 12:12:32 +02:00
# include <linux/list.h>
2019-05-26 19:35:33 +02:00
# include <drm/drm.h>
# include <drm/drm_device.h>
2014-09-10 12:43:49 +02:00
# include <drm/drm_legacy.h>
2014-08-29 12:12:32 +02:00
struct agp_memory ;
2021-11-29 10:48:41 +01:00
struct drm_buf_desc ;
2014-07-24 12:10:04 +02:00
struct drm_device ;
struct drm_file ;
2021-11-29 10:48:41 +01:00
struct drm_hash_item ;
struct drm_open_hash ;
/*
* Hash - table Support
*/
# define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
/* drm_hashtab.c */
# if IS_ENABLED(CONFIG_DRM_LEGACY)
int drm_ht_create ( struct drm_open_hash * ht , unsigned int order ) ;
int drm_ht_insert_item ( struct drm_open_hash * ht , struct drm_hash_item * item ) ;
int drm_ht_just_insert_please ( struct drm_open_hash * ht , struct drm_hash_item * item ,
unsigned long seed , int bits , int shift ,
unsigned long add ) ;
int drm_ht_find_item ( struct drm_open_hash * ht , unsigned long key , struct drm_hash_item * * item ) ;
void drm_ht_verbose_list ( struct drm_open_hash * ht , unsigned long key ) ;
int drm_ht_remove_key ( struct drm_open_hash * ht , unsigned long key ) ;
int drm_ht_remove_item ( struct drm_open_hash * ht , struct drm_hash_item * item ) ;
void drm_ht_remove ( struct drm_open_hash * ht ) ;
# endif
/*
* RCU - safe interface
*
* The user of this API needs to make sure that two or more instances of the
* hash table manipulation functions are never run simultaneously .
* The lookup function drm_ht_find_item_rcu may , however , run simultaneously
* with any of the manipulation functions as long as it ' s called from within
* an RCU read - locked section .
*/
# define drm_ht_insert_item_rcu drm_ht_insert_item
# define drm_ht_just_insert_please_rcu drm_ht_just_insert_please
# define drm_ht_remove_key_rcu drm_ht_remove_key
# define drm_ht_remove_item_rcu drm_ht_remove_item
# define drm_ht_find_item_rcu drm_ht_find_item
2014-07-24 12:10:04 +02:00
/*
* Generic DRM Contexts
*/
# define DRM_KERNEL_CONTEXT 0
# define DRM_RESERVED_CONTEXTS 1
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2015-06-23 11:22:36 +02:00
void drm_legacy_ctxbitmap_init ( struct drm_device * dev ) ;
2014-07-24 12:10:04 +02:00
void drm_legacy_ctxbitmap_cleanup ( struct drm_device * dev ) ;
void drm_legacy_ctxbitmap_flush ( struct drm_device * dev , struct drm_file * file ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_ctxbitmap_init ( struct drm_device * dev ) { }
static inline void drm_legacy_ctxbitmap_cleanup ( struct drm_device * dev ) { }
static inline void drm_legacy_ctxbitmap_flush ( struct drm_device * dev , struct drm_file * file ) { }
# endif
2014-07-24 12:10:04 +02:00
2019-04-18 17:10:40 +10:00
void drm_legacy_ctxbitmap_free ( struct drm_device * dev , int ctx_handle ) ;
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-07-24 12:10:04 +02:00
int drm_legacy_resctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_addctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_getctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_switchctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_newctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_rmctx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_setsareactx ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_getsareactx ( struct drm_device * d , void * v , struct drm_file * f ) ;
2019-04-18 17:10:40 +10:00
# endif
2014-07-24 12:10:04 +02:00
2014-08-29 12:12:28 +02:00
/*
* Generic Buffer Management
*/
# define DRM_MAP_HASH_OFFSET 0x10000000
2019-04-23 09:56:01 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2019-04-23 09:40:54 +10:00
static inline int drm_legacy_create_map_hash ( struct drm_device * dev )
{
return drm_ht_create ( & dev - > map_hash , 12 ) ;
}
static inline void drm_legacy_remove_map_hash ( struct drm_device * dev )
{
drm_ht_remove ( & dev - > map_hash ) ;
}
2019-04-23 09:56:01 +10:00
# else
static inline int drm_legacy_create_map_hash ( struct drm_device * dev )
{
return 0 ;
}
static inline void drm_legacy_remove_map_hash ( struct drm_device * dev ) { }
# endif
2019-04-23 09:40:54 +10:00
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2016-04-26 19:29:36 +02:00
int drm_legacy_getmap_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
2014-08-29 12:12:28 +02:00
int drm_legacy_addmap_ioctl ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_rmmap_ioctl ( struct drm_device * d , void * v , struct drm_file * f ) ;
2019-04-18 17:10:40 +10:00
2014-08-29 12:12:28 +02:00
int drm_legacy_addbufs ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_infobufs ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_markbufs ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_freebufs ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_mapbufs ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_dma_ioctl ( struct drm_device * d , void * v , struct drm_file * f ) ;
2019-04-18 17:10:40 +10:00
# endif
2014-08-29 12:12:28 +02:00
2017-05-24 17:54:09 -04:00
int __drm_legacy_infobufs ( struct drm_device * , void * , int * ,
int ( * ) ( void * , int , struct drm_buf_entry * ) ) ;
2017-05-25 16:24:20 -04:00
int __drm_legacy_mapbufs ( struct drm_device * , void * , int * ,
void __user * * ,
int ( * ) ( void * , int , unsigned long , struct drm_buf * ) ,
struct drm_file * ) ;
2017-05-24 17:54:09 -04:00
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2019-04-23 08:42:23 +10:00
void drm_legacy_master_rmmaps ( struct drm_device * dev ,
struct drm_master * master ) ;
2019-04-23 08:45:12 +10:00
void drm_legacy_rmmaps ( struct drm_device * dev ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_master_rmmaps ( struct drm_device * dev ,
struct drm_master * master ) { }
static inline void drm_legacy_rmmaps ( struct drm_device * dev ) { }
# endif
2019-04-23 08:42:23 +10:00
2021-01-12 09:10:33 +01:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-09-10 12:43:48 +02:00
void drm_legacy_vma_flush ( struct drm_device * d ) ;
2017-01-04 10:12:56 +01:00
# else
static inline void drm_legacy_vma_flush ( struct drm_device * d )
{
/* do nothing */
}
# endif
2014-09-10 12:43:48 +02:00
2014-08-29 12:12:32 +02:00
/*
* AGP Support
*/
struct drm_agp_mem {
unsigned long handle ;
struct agp_memory * memory ;
unsigned long bound ;
int pages ;
struct list_head head ;
} ;
2021-05-07 20:57:09 +02:00
/* drm_agpsupport.c */
# if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
void drm_legacy_agp_clear ( struct drm_device * dev ) ;
int drm_legacy_agp_acquire_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_release_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_enable_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_info_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_alloc_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_free_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_unbind_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_agp_bind_ioctl ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
# else
static inline void drm_legacy_agp_clear ( struct drm_device * dev ) { }
# endif
2016-06-14 20:50:57 +02:00
/* drm_lock.c */
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-08-29 12:12:46 +02:00
int drm_legacy_lock ( struct drm_device * d , void * v , struct drm_file * f ) ;
int drm_legacy_unlock ( struct drm_device * d , void * v , struct drm_file * f ) ;
2016-06-14 20:50:57 +02:00
void drm_legacy_lock_release ( struct drm_device * dev , struct file * filp ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_lock_release ( struct drm_device * dev , struct file * filp ) { }
# endif
2014-08-29 12:12:46 +02:00
2014-09-11 07:41:51 +02:00
/* DMA support */
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-09-11 07:41:51 +02:00
int drm_legacy_dma_setup ( struct drm_device * dev ) ;
void drm_legacy_dma_takedown ( struct drm_device * dev ) ;
2019-04-18 17:10:40 +10:00
# else
static inline int drm_legacy_dma_setup ( struct drm_device * dev )
{
return 0 ;
}
# endif
2014-09-11 07:41:51 +02:00
void drm_legacy_free_buffer ( struct drm_device * dev ,
struct drm_buf * buf ) ;
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-09-11 07:41:51 +02:00
void drm_legacy_reclaim_buffers ( struct drm_device * dev ,
struct drm_file * filp ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_reclaim_buffers ( struct drm_device * dev ,
struct drm_file * filp ) { }
# endif
2014-09-11 07:41:51 +02:00
2014-09-11 07:42:43 +02:00
/* Scatter Gather Support */
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2014-09-11 07:42:43 +02:00
void drm_legacy_sg_cleanup ( struct drm_device * dev ) ;
int drm_legacy_sg_alloc ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
int drm_legacy_sg_free ( struct drm_device * dev , void * data ,
struct drm_file * file_priv ) ;
2019-04-18 17:10:40 +10:00
# endif
2014-09-11 07:42:43 +02:00
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2019-04-23 09:47:27 +10:00
void drm_legacy_init_members ( struct drm_device * dev ) ;
void drm_legacy_destroy_members ( struct drm_device * dev ) ;
2019-04-23 09:48:13 +10:00
void drm_legacy_dev_reinit ( struct drm_device * dev ) ;
2019-05-02 15:56:03 +02:00
int drm_legacy_setup ( struct drm_device * dev ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_init_members ( struct drm_device * dev ) { }
static inline void drm_legacy_destroy_members ( struct drm_device * dev ) { }
static inline void drm_legacy_dev_reinit ( struct drm_device * dev ) { }
2019-05-02 15:56:03 +02:00
static inline int drm_legacy_setup ( struct drm_device * dev ) { return 0 ; }
2019-04-18 17:10:40 +10:00
# endif
2019-04-23 09:47:27 +10:00
2019-04-18 17:10:40 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
2019-04-23 09:36:54 +10:00
void drm_legacy_lock_master_cleanup ( struct drm_device * dev , struct drm_master * master ) ;
2019-04-18 17:10:40 +10:00
# else
static inline void drm_legacy_lock_master_cleanup ( struct drm_device * dev , struct drm_master * master ) { }
# endif
2019-04-23 10:01:50 +10:00
# if IS_ENABLED(CONFIG_DRM_LEGACY)
void drm_master_legacy_init ( struct drm_master * master ) ;
# else
static inline void drm_master_legacy_init ( struct drm_master * master ) { }
# endif
2021-05-16 21:51:35 +02:00
/* drm_pci.c */
2021-05-07 20:57:08 +02:00
# if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
2021-05-16 21:51:35 +02:00
int drm_legacy_irq_by_busid ( struct drm_device * dev , void * data , struct drm_file * file_priv ) ;
2021-05-07 20:57:08 +02:00
void drm_legacy_pci_agp_destroy ( struct drm_device * dev ) ;
# else
2021-05-16 21:51:35 +02:00
static inline int drm_legacy_irq_by_busid ( struct drm_device * dev , void * data ,
struct drm_file * file_priv )
{
return - EINVAL ;
}
2021-05-07 20:57:08 +02:00
static inline void drm_legacy_pci_agp_destroy ( struct drm_device * dev ) { }
# endif
2014-07-24 12:10:04 +02:00
# endif /* __DRM_LEGACY_H__ */