Home | History | Annotate | Line # | Download | only in drm
      1  1.10  riastrad /*	$NetBSD: drm_agpsupport.h,v 1.10 2022/07/19 22:24:34 riastradh Exp $	*/
      2   1.6  riastrad 
      3   1.9  riastrad /* SPDX-License-Identifier: GPL-2.0 */
      4   1.1  riastrad #ifndef _DRM_AGPSUPPORT_H_
      5   1.1  riastrad #define _DRM_AGPSUPPORT_H_
      6   1.1  riastrad 
      7   1.6  riastrad #include <linux/agp_backend.h>
      8   1.1  riastrad #include <linux/kernel.h>
      9   1.6  riastrad #include <linux/list.h>
     10   1.1  riastrad #include <linux/mm.h>
     11   1.1  riastrad #include <linux/mutex.h>
     12   1.1  riastrad #include <linux/types.h>
     13   1.6  riastrad #include <uapi/drm/drm.h>
     14   1.6  riastrad 
     15   1.7  riastrad #ifdef __NetBSD__
     16   1.7  riastrad #include <drm/drm_agp_netbsd.h>
     17   1.7  riastrad #endif
     18   1.7  riastrad 
     19   1.6  riastrad struct drm_device;
     20   1.6  riastrad struct drm_file;
     21   1.6  riastrad 
     22   1.8  riastrad struct drm_agp_hooks {
     23   1.8  riastrad 	void	(*agph_flush)(void);
     24   1.8  riastrad 
     25   1.8  riastrad 	struct drm_agp_head *
     26   1.8  riastrad 		(*agph_init)(struct drm_device *);
     27   1.8  riastrad 	void	(*agph_clear)(struct drm_device *);
     28   1.8  riastrad 	int	(*agph_acquire)(struct drm_device *);
     29   1.8  riastrad 	int	(*agph_release)(struct drm_device *);
     30   1.8  riastrad 	int	(*agph_enable)(struct drm_device *, struct drm_agp_mode);
     31   1.8  riastrad 	int	(*agph_info)(struct drm_device *, struct drm_agp_info *);
     32   1.8  riastrad 	int	(*agph_alloc)(struct drm_device *, struct drm_agp_buffer *);
     33   1.8  riastrad 	int	(*agph_free)(struct drm_device *, struct drm_agp_buffer *);
     34   1.8  riastrad 	int	(*agph_bind)(struct drm_device *, struct drm_agp_binding *);
     35   1.8  riastrad 	int	(*agph_unbind)(struct drm_device *, struct drm_agp_binding *);
     36   1.8  riastrad 
     37   1.8  riastrad 	int	(*agph_acquire_ioctl)(struct drm_device *, void *,
     38   1.8  riastrad 		    struct drm_file *);
     39   1.8  riastrad 	int	(*agph_release_ioctl)(struct drm_device *, void *,
     40   1.8  riastrad 		    struct drm_file *);
     41   1.8  riastrad 	int	(*agph_enable_ioctl)(struct drm_device *, void *,
     42   1.8  riastrad 		    struct drm_file *);
     43   1.8  riastrad 	int	(*agph_info_ioctl)(struct drm_device *, void *,
     44   1.8  riastrad 		    struct drm_file *);
     45   1.8  riastrad 	int	(*agph_alloc_ioctl)(struct drm_device *, void *,
     46   1.8  riastrad 		    struct drm_file *);
     47   1.8  riastrad 	int	(*agph_free_ioctl)(struct drm_device *, void *,
     48   1.8  riastrad 		    struct drm_file *);
     49   1.8  riastrad 	int	(*agph_bind_ioctl)(struct drm_device *, void *,
     50   1.8  riastrad 		    struct drm_file *);
     51   1.8  riastrad 	int	(*agph_unbind_ioctl)(struct drm_device *, void *,
     52   1.8  riastrad 		    struct drm_file *);
     53   1.8  riastrad };
     54   1.8  riastrad 
     55   1.6  riastrad struct drm_agp_head {
     56   1.8  riastrad 	const struct drm_agp_hooks *hooks;
     57   1.6  riastrad 	struct agp_kern_info agp_info;
     58   1.6  riastrad 	struct list_head memory;
     59   1.6  riastrad 	unsigned long mode;
     60   1.6  riastrad 	struct agp_bridge_data *bridge;
     61   1.6  riastrad 	int enabled;
     62   1.6  riastrad 	int acquired;
     63   1.6  riastrad 	unsigned long base;
     64   1.6  riastrad 	int agp_mtrr;
     65   1.6  riastrad 	int cant_use_aperture;
     66   1.6  riastrad 	unsigned long page_mask;
     67   1.6  riastrad };
     68   1.1  riastrad 
     69   1.6  riastrad #if IS_ENABLED(CONFIG_AGP)
     70   1.1  riastrad 
     71   1.2  riastrad #ifdef __NetBSD__
     72   1.2  riastrad static inline void drm_free_agp(struct agp_bridge_data *, struct agp_memory *, int);
     73   1.2  riastrad static inline int drm_bind_agp(struct agp_bridge_data *, struct agp_memory *, unsigned);
     74   1.2  riastrad static inline int drm_unbind_agp(struct agp_bridge_data *, struct agp_memory *);
     75   1.2  riastrad #else
     76   1.1  riastrad void drm_free_agp(struct agp_memory * handle, int pages);
     77   1.1  riastrad int drm_bind_agp(struct agp_memory * handle, unsigned int start);
     78   1.1  riastrad int drm_unbind_agp(struct agp_memory * handle);
     79   1.2  riastrad #endif
     80   1.1  riastrad 
     81   1.1  riastrad struct drm_agp_head *drm_agp_init(struct drm_device *dev);
     82   1.9  riastrad void drm_legacy_agp_clear(struct drm_device *dev);
     83   1.1  riastrad int drm_agp_acquire(struct drm_device *dev);
     84   1.1  riastrad int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
     85   1.1  riastrad 			  struct drm_file *file_priv);
     86   1.1  riastrad int drm_agp_release(struct drm_device *dev);
     87   1.1  riastrad int drm_agp_release_ioctl(struct drm_device *dev, void *data,
     88   1.1  riastrad 			  struct drm_file *file_priv);
     89   1.1  riastrad int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
     90   1.1  riastrad int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
     91   1.1  riastrad 			 struct drm_file *file_priv);
     92   1.1  riastrad int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
     93   1.1  riastrad int drm_agp_info_ioctl(struct drm_device *dev, void *data,
     94   1.1  riastrad 		       struct drm_file *file_priv);
     95   1.1  riastrad int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
     96   1.1  riastrad int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
     97   1.1  riastrad 			struct drm_file *file_priv);
     98   1.1  riastrad int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
     99   1.1  riastrad int drm_agp_free_ioctl(struct drm_device *dev, void *data,
    100   1.1  riastrad 		       struct drm_file *file_priv);
    101   1.1  riastrad int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
    102   1.1  riastrad int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
    103   1.1  riastrad 			 struct drm_file *file_priv);
    104   1.1  riastrad int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
    105   1.1  riastrad int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
    106   1.1  riastrad 		       struct drm_file *file_priv);
    107   1.6  riastrad 
    108   1.8  riastrad #ifdef __NetBSD__
    109   1.8  riastrad void drm_agp_flush(void);
    110   1.8  riastrad void drm_agp_fini(struct drm_device *);
    111   1.8  riastrad int drm_agp_register(const struct drm_agp_hooks *);
    112   1.8  riastrad int drm_agp_deregister(const struct drm_agp_hooks *);
    113   1.8  riastrad void drm_agp_hooks_init(void);
    114   1.8  riastrad void drm_agp_hooks_fini(void);
    115   1.8  riastrad int drmkms_agp_guarantee_initialized(void);
    116   1.8  riastrad #endif
    117   1.8  riastrad 
    118   1.6  riastrad #else /* CONFIG_AGP */
    119   1.1  riastrad 
    120   1.5  jmcneill #if !defined(__NetBSD__)
    121   1.5  jmcneill 
    122   1.1  riastrad static inline void drm_free_agp(struct agp_memory * handle, int pages)
    123   1.1  riastrad {
    124   1.1  riastrad }
    125   1.1  riastrad 
    126   1.1  riastrad static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
    127   1.1  riastrad {
    128   1.1  riastrad 	return -ENODEV;
    129   1.1  riastrad }
    130   1.1  riastrad 
    131   1.1  riastrad static inline int drm_unbind_agp(struct agp_memory * handle)
    132   1.1  riastrad {
    133   1.1  riastrad 	return -ENODEV;
    134   1.1  riastrad }
    135   1.5  jmcneill #endif
    136   1.5  jmcneill 
    137   1.1  riastrad static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
    138   1.1  riastrad {
    139   1.1  riastrad 	return NULL;
    140   1.1  riastrad }
    141   1.1  riastrad 
    142   1.9  riastrad static inline void drm_legacy_agp_clear(struct drm_device *dev)
    143   1.1  riastrad {
    144   1.1  riastrad }
    145   1.1  riastrad 
    146   1.1  riastrad static inline int drm_agp_acquire(struct drm_device *dev)
    147   1.1  riastrad {
    148   1.1  riastrad 	return -ENODEV;
    149   1.1  riastrad }
    150   1.1  riastrad 
    151   1.1  riastrad static inline int drm_agp_release(struct drm_device *dev)
    152   1.1  riastrad {
    153   1.1  riastrad 	return -ENODEV;
    154   1.1  riastrad }
    155   1.1  riastrad 
    156   1.1  riastrad static inline int drm_agp_enable(struct drm_device *dev,
    157   1.1  riastrad 				 struct drm_agp_mode mode)
    158   1.1  riastrad {
    159   1.1  riastrad 	return -ENODEV;
    160   1.1  riastrad }
    161   1.1  riastrad 
    162   1.1  riastrad static inline int drm_agp_info(struct drm_device *dev,
    163   1.1  riastrad 			       struct drm_agp_info *info)
    164   1.1  riastrad {
    165   1.1  riastrad 	return -ENODEV;
    166   1.1  riastrad }
    167   1.1  riastrad 
    168   1.1  riastrad static inline int drm_agp_alloc(struct drm_device *dev,
    169   1.1  riastrad 				struct drm_agp_buffer *request)
    170   1.1  riastrad {
    171   1.1  riastrad 	return -ENODEV;
    172   1.1  riastrad }
    173   1.1  riastrad 
    174   1.1  riastrad static inline int drm_agp_free(struct drm_device *dev,
    175   1.1  riastrad 			       struct drm_agp_buffer *request)
    176   1.1  riastrad {
    177   1.1  riastrad 	return -ENODEV;
    178   1.1  riastrad }
    179   1.1  riastrad 
    180   1.1  riastrad static inline int drm_agp_unbind(struct drm_device *dev,
    181   1.1  riastrad 				 struct drm_agp_binding *request)
    182   1.1  riastrad {
    183   1.1  riastrad 	return -ENODEV;
    184   1.1  riastrad }
    185   1.1  riastrad 
    186   1.1  riastrad static inline int drm_agp_bind(struct drm_device *dev,
    187   1.1  riastrad 			       struct drm_agp_binding *request)
    188   1.1  riastrad {
    189   1.1  riastrad 	return -ENODEV;
    190   1.1  riastrad }
    191   1.1  riastrad 
    192   1.6  riastrad #endif /* CONFIG_AGP */
    193   1.1  riastrad 
    194   1.1  riastrad #endif /* _DRM_AGPSUPPORT_H_ */
    195