Wed Jul 24 03:24:03 2013 UTC ()
Kludge up Linux PCI device shims.

. New drm_pci_attach/drm_pci_detach simplify initialization of
autoconf-derived struct pci_dev.

. New linux_pci_dev_init initializes struct pci_dev so that there's
one place where all its fields are listed.  The kludge parameter is,
well, kludgey.  Sorry.

. Replace pci_kludgey_find_dev by pci_get_bus_and_slot with the same
interface as Linux's, but some kasserts requiring it to look for the
one bus/device/function tuple that i915drm is interested in.

. Add pci_get_class which does similarly, for intel_detect_pch.

Later pci_get_bus_and_slot and pci_get_class should be fixed once we
can pass a cookie through PCI bus enumeration and pci_find_device.


(riastradh)
diff -r1.1.1.1.2.48 -r1.1.1.1.2.49 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
diff -r1.1.2.12 -r1.1.2.13 src/sys/external/bsd/drm2/include/linux/pci.h
diff -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/pci/drm_pci.c

cvs diff -r1.1.1.1.2.48 -r1.1.1.1.2.49 src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h (switch to unified diff)

--- src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2013/07/24 03:23:31 1.1.1.1.2.48
+++ src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2013/07/24 03:24:03 1.1.1.1.2.49
@@ -834,1336 +834,1341 @@ struct drm_master { @@ -834,1336 +834,1341 @@ struct drm_master {
834 834
835 struct drm_lock_data lock; /**< Information on hardware lock */ 835 struct drm_lock_data lock; /**< Information on hardware lock */
836 836
837 void *driver_priv; /**< Private structure for driver to use */ 837 void *driver_priv; /**< Private structure for driver to use */
838}; 838};
839 839
840/* Size of ringbuffer for vblank timestamps. Just double-buffer 840/* Size of ringbuffer for vblank timestamps. Just double-buffer
841 * in initial implementation. 841 * in initial implementation.
842 */ 842 */
843#define DRM_VBLANKTIME_RBSIZE 2 843#define DRM_VBLANKTIME_RBSIZE 2
844 844
845/* Flags and return codes for get_vblank_timestamp() driver function. */ 845/* Flags and return codes for get_vblank_timestamp() driver function. */
846#define DRM_CALLED_FROM_VBLIRQ 1 846#define DRM_CALLED_FROM_VBLIRQ 1
847#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) 847#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
848#define DRM_VBLANKTIME_INVBL (1 << 1) 848#define DRM_VBLANKTIME_INVBL (1 << 1)
849 849
850/* get_scanout_position() return flags */ 850/* get_scanout_position() return flags */
851#define DRM_SCANOUTPOS_VALID (1 << 0) 851#define DRM_SCANOUTPOS_VALID (1 << 0)
852#define DRM_SCANOUTPOS_INVBL (1 << 1) 852#define DRM_SCANOUTPOS_INVBL (1 << 1)
853#define DRM_SCANOUTPOS_ACCURATE (1 << 2) 853#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
854 854
855struct drm_bus_irq_cookie; 855struct drm_bus_irq_cookie;
856 856
857struct drm_bus { 857struct drm_bus {
858 int bus_type; 858 int bus_type;
859 /* 859 /*
860 * XXX NetBSD will have a problem with this: pci_intr_handle_t 860 * XXX NetBSD will have a problem with this: pci_intr_handle_t
861 * is a long on some LP64 architectures, where int is 32-bit, 861 * is a long on some LP64 architectures, where int is 32-bit,
862 * such as alpha and mips64. 862 * such as alpha and mips64.
863 */ 863 */
864 int (*get_irq)(struct drm_device *dev); 864 int (*get_irq)(struct drm_device *dev);
865#ifdef __NetBSD__ 865#ifdef __NetBSD__
866 int (*irq_install)(struct drm_device *, irqreturn_t (*)(void *), int, 866 int (*irq_install)(struct drm_device *, irqreturn_t (*)(void *), int,
867 const char *, void *, struct drm_bus_irq_cookie **); 867 const char *, void *, struct drm_bus_irq_cookie **);
868 void (*irq_uninstall)(struct drm_device *, 868 void (*irq_uninstall)(struct drm_device *,
869 struct drm_bus_irq_cookie *); 869 struct drm_bus_irq_cookie *);
870#endif 870#endif
871 const char *(*get_name)(struct drm_device *dev); 871 const char *(*get_name)(struct drm_device *dev);
872 int (*set_busid)(struct drm_device *dev, struct drm_master *master); 872 int (*set_busid)(struct drm_device *dev, struct drm_master *master);
873 int (*set_unique)(struct drm_device *dev, struct drm_master *master, 873 int (*set_unique)(struct drm_device *dev, struct drm_master *master,
874 struct drm_unique *unique); 874 struct drm_unique *unique);
875 int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); 875 int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
876 /* hooks that are for PCI */ 876 /* hooks that are for PCI */
877 int (*agp_init)(struct drm_device *dev); 877 int (*agp_init)(struct drm_device *dev);
878 878
879}; 879};
880 880
881/** 881/**
882 * DRM driver structure. This structure represent the common code for 882 * DRM driver structure. This structure represent the common code for
883 * a family of cards. There will one drm_device for each card present 883 * a family of cards. There will one drm_device for each card present
884 * in this family 884 * in this family
885 */ 885 */
886struct drm_driver { 886struct drm_driver {
887 int (*load) (struct drm_device *, unsigned long flags); 887 int (*load) (struct drm_device *, unsigned long flags);
888 int (*firstopen) (struct drm_device *); 888 int (*firstopen) (struct drm_device *);
889 int (*open) (struct drm_device *, struct drm_file *); 889 int (*open) (struct drm_device *, struct drm_file *);
890 void (*preclose) (struct drm_device *, struct drm_file *file_priv); 890 void (*preclose) (struct drm_device *, struct drm_file *file_priv);
891 void (*postclose) (struct drm_device *, struct drm_file *); 891 void (*postclose) (struct drm_device *, struct drm_file *);
892 void (*lastclose) (struct drm_device *); 892 void (*lastclose) (struct drm_device *);
893 int (*unload) (struct drm_device *); 893 int (*unload) (struct drm_device *);
894 int (*suspend) (struct drm_device *, pm_message_t state); 894 int (*suspend) (struct drm_device *, pm_message_t state);
895 int (*resume) (struct drm_device *); 895 int (*resume) (struct drm_device *);
896 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 896 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
897 int (*dma_quiescent) (struct drm_device *); 897 int (*dma_quiescent) (struct drm_device *);
898 int (*context_dtor) (struct drm_device *dev, int context); 898 int (*context_dtor) (struct drm_device *dev, int context);
899 899
900 /** 900 /**
901 * get_vblank_counter - get raw hardware vblank counter 901 * get_vblank_counter - get raw hardware vblank counter
902 * @dev: DRM device 902 * @dev: DRM device
903 * @crtc: counter to fetch 903 * @crtc: counter to fetch
904 * 904 *
905 * Driver callback for fetching a raw hardware vblank counter for @crtc. 905 * Driver callback for fetching a raw hardware vblank counter for @crtc.
906 * If a device doesn't have a hardware counter, the driver can simply 906 * If a device doesn't have a hardware counter, the driver can simply
907 * return the value of drm_vblank_count. The DRM core will account for 907 * return the value of drm_vblank_count. The DRM core will account for
908 * missed vblank events while interrupts where disabled based on system 908 * missed vblank events while interrupts where disabled based on system
909 * timestamps. 909 * timestamps.
910 * 910 *
911 * Wraparound handling and loss of events due to modesetting is dealt 911 * Wraparound handling and loss of events due to modesetting is dealt
912 * with in the DRM core code. 912 * with in the DRM core code.
913 * 913 *
914 * RETURNS 914 * RETURNS
915 * Raw vblank counter value. 915 * Raw vblank counter value.
916 */ 916 */
917 u32 (*get_vblank_counter) (struct drm_device *dev, int crtc); 917 u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
918 918
919 /** 919 /**
920 * enable_vblank - enable vblank interrupt events 920 * enable_vblank - enable vblank interrupt events
921 * @dev: DRM device 921 * @dev: DRM device
922 * @crtc: which irq to enable 922 * @crtc: which irq to enable
923 * 923 *
924 * Enable vblank interrupts for @crtc. If the device doesn't have 924 * Enable vblank interrupts for @crtc. If the device doesn't have
925 * a hardware vblank counter, this routine should be a no-op, since 925 * a hardware vblank counter, this routine should be a no-op, since
926 * interrupts will have to stay on to keep the count accurate. 926 * interrupts will have to stay on to keep the count accurate.
927 * 927 *
928 * RETURNS 928 * RETURNS
929 * Zero on success, appropriate errno if the given @crtc's vblank 929 * Zero on success, appropriate errno if the given @crtc's vblank
930 * interrupt cannot be enabled. 930 * interrupt cannot be enabled.
931 */ 931 */
932 int (*enable_vblank) (struct drm_device *dev, int crtc); 932 int (*enable_vblank) (struct drm_device *dev, int crtc);
933 933
934 /** 934 /**
935 * disable_vblank - disable vblank interrupt events 935 * disable_vblank - disable vblank interrupt events
936 * @dev: DRM device 936 * @dev: DRM device
937 * @crtc: which irq to enable 937 * @crtc: which irq to enable
938 * 938 *
939 * Disable vblank interrupts for @crtc. If the device doesn't have 939 * Disable vblank interrupts for @crtc. If the device doesn't have
940 * a hardware vblank counter, this routine should be a no-op, since 940 * a hardware vblank counter, this routine should be a no-op, since
941 * interrupts will have to stay on to keep the count accurate. 941 * interrupts will have to stay on to keep the count accurate.
942 */ 942 */
943 void (*disable_vblank) (struct drm_device *dev, int crtc); 943 void (*disable_vblank) (struct drm_device *dev, int crtc);
944 944
945 /** 945 /**
946 * Called by \c drm_device_is_agp. Typically used to determine if a 946 * Called by \c drm_device_is_agp. Typically used to determine if a
947 * card is really attached to AGP or not. 947 * card is really attached to AGP or not.
948 * 948 *
949 * \param dev DRM device handle 949 * \param dev DRM device handle
950 * 950 *
951 * \returns 951 * \returns
952 * One of three values is returned depending on whether or not the 952 * One of three values is returned depending on whether or not the
953 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP 953 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
954 * (return of 1), or may or may not be AGP (return of 2). 954 * (return of 1), or may or may not be AGP (return of 2).
955 */ 955 */
956 int (*device_is_agp) (struct drm_device *dev); 956 int (*device_is_agp) (struct drm_device *dev);
957 957
958 /** 958 /**
959 * Called by vblank timestamping code. 959 * Called by vblank timestamping code.
960 * 960 *
961 * Return the current display scanout position from a crtc. 961 * Return the current display scanout position from a crtc.
962 * 962 *
963 * \param dev DRM device. 963 * \param dev DRM device.
964 * \param crtc Id of the crtc to query. 964 * \param crtc Id of the crtc to query.
965 * \param *vpos Target location for current vertical scanout position. 965 * \param *vpos Target location for current vertical scanout position.
966 * \param *hpos Target location for current horizontal scanout position. 966 * \param *hpos Target location for current horizontal scanout position.
967 * 967 *
968 * Returns vpos as a positive number while in active scanout area. 968 * Returns vpos as a positive number while in active scanout area.
969 * Returns vpos as a negative number inside vblank, counting the number 969 * Returns vpos as a negative number inside vblank, counting the number
970 * of scanlines to go until end of vblank, e.g., -1 means "one scanline 970 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
971 * until start of active scanout / end of vblank." 971 * until start of active scanout / end of vblank."
972 * 972 *
973 * \return Flags, or'ed together as follows: 973 * \return Flags, or'ed together as follows:
974 * 974 *
975 * DRM_SCANOUTPOS_VALID = Query successful. 975 * DRM_SCANOUTPOS_VALID = Query successful.
976 * DRM_SCANOUTPOS_INVBL = Inside vblank. 976 * DRM_SCANOUTPOS_INVBL = Inside vblank.
977 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of 977 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
978 * this flag means that returned position may be offset by a constant 978 * this flag means that returned position may be offset by a constant
979 * but unknown small number of scanlines wrt. real scanout position. 979 * but unknown small number of scanlines wrt. real scanout position.
980 * 980 *
981 */ 981 */
982 int (*get_scanout_position) (struct drm_device *dev, int crtc, 982 int (*get_scanout_position) (struct drm_device *dev, int crtc,
983 int *vpos, int *hpos); 983 int *vpos, int *hpos);
984 984
985 /** 985 /**
986 * Called by \c drm_get_last_vbltimestamp. Should return a precise 986 * Called by \c drm_get_last_vbltimestamp. Should return a precise
987 * timestamp when the most recent VBLANK interval ended or will end. 987 * timestamp when the most recent VBLANK interval ended or will end.
988 * 988 *
989 * Specifically, the timestamp in @vblank_time should correspond as 989 * Specifically, the timestamp in @vblank_time should correspond as
990 * closely as possible to the time when the first video scanline of 990 * closely as possible to the time when the first video scanline of
991 * the video frame after the end of VBLANK will start scanning out, 991 * the video frame after the end of VBLANK will start scanning out,
992 * the time immediately after end of the VBLANK interval. If the 992 * the time immediately after end of the VBLANK interval. If the
993 * @crtc is currently inside VBLANK, this will be a time in the future. 993 * @crtc is currently inside VBLANK, this will be a time in the future.
994 * If the @crtc is currently scanning out a frame, this will be the 994 * If the @crtc is currently scanning out a frame, this will be the
995 * past start time of the current scanout. This is meant to adhere 995 * past start time of the current scanout. This is meant to adhere
996 * to the OpenML OML_sync_control extension specification. 996 * to the OpenML OML_sync_control extension specification.
997 * 997 *
998 * \param dev dev DRM device handle. 998 * \param dev dev DRM device handle.
999 * \param crtc crtc for which timestamp should be returned. 999 * \param crtc crtc for which timestamp should be returned.
1000 * \param *max_error Maximum allowable timestamp error in nanoseconds. 1000 * \param *max_error Maximum allowable timestamp error in nanoseconds.
1001 * Implementation should strive to provide timestamp 1001 * Implementation should strive to provide timestamp
1002 * with an error of at most *max_error nanoseconds. 1002 * with an error of at most *max_error nanoseconds.
1003 * Returns true upper bound on error for timestamp. 1003 * Returns true upper bound on error for timestamp.
1004 * \param *vblank_time Target location for returned vblank timestamp. 1004 * \param *vblank_time Target location for returned vblank timestamp.
1005 * \param flags 0 = Defaults, no special treatment needed. 1005 * \param flags 0 = Defaults, no special treatment needed.
1006 * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank 1006 * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
1007 * irq handler. Some drivers need to apply some workarounds 1007 * irq handler. Some drivers need to apply some workarounds
1008 * for gpu-specific vblank irq quirks if flag is set. 1008 * for gpu-specific vblank irq quirks if flag is set.
1009 * 1009 *
1010 * \returns 1010 * \returns
1011 * Zero if timestamping isn't supported in current display mode or a 1011 * Zero if timestamping isn't supported in current display mode or a
1012 * negative number on failure. A positive status code on success, 1012 * negative number on failure. A positive status code on success,
1013 * which describes how the vblank_time timestamp was computed. 1013 * which describes how the vblank_time timestamp was computed.
1014 */ 1014 */
1015 int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, 1015 int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
1016 int *max_error, 1016 int *max_error,
1017 struct timeval *vblank_time, 1017 struct timeval *vblank_time,
1018 unsigned flags); 1018 unsigned flags);
1019 1019
1020 /* these have to be filled in */ 1020 /* these have to be filled in */
1021 1021
1022 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); 1022 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
1023 void (*irq_preinstall) (struct drm_device *dev); 1023 void (*irq_preinstall) (struct drm_device *dev);
1024 int (*irq_postinstall) (struct drm_device *dev); 1024 int (*irq_postinstall) (struct drm_device *dev);
1025 void (*irq_uninstall) (struct drm_device *dev); 1025 void (*irq_uninstall) (struct drm_device *dev);
1026 void (*set_version) (struct drm_device *dev, 1026 void (*set_version) (struct drm_device *dev,
1027 struct drm_set_version *sv); 1027 struct drm_set_version *sv);
1028 1028
1029 /* Master routines */ 1029 /* Master routines */
1030 int (*master_create)(struct drm_device *dev, struct drm_master *master); 1030 int (*master_create)(struct drm_device *dev, struct drm_master *master);
1031 void (*master_destroy)(struct drm_device *dev, struct drm_master *master); 1031 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
1032 /** 1032 /**
1033 * master_set is called whenever the minor master is set. 1033 * master_set is called whenever the minor master is set.
1034 * master_drop is called whenever the minor master is dropped. 1034 * master_drop is called whenever the minor master is dropped.
1035 */ 1035 */
1036 1036
1037 int (*master_set)(struct drm_device *dev, struct drm_file *file_priv, 1037 int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
1038 bool from_open); 1038 bool from_open);
1039 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv, 1039 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
1040 bool from_release); 1040 bool from_release);
1041 1041
1042 int (*debugfs_init)(struct drm_minor *minor); 1042 int (*debugfs_init)(struct drm_minor *minor);
1043 void (*debugfs_cleanup)(struct drm_minor *minor); 1043 void (*debugfs_cleanup)(struct drm_minor *minor);
1044 1044
1045 /** 1045 /**
1046 * Driver-specific constructor for drm_gem_objects, to set up 1046 * Driver-specific constructor for drm_gem_objects, to set up
1047 * obj->driver_private. 1047 * obj->driver_private.
1048 * 1048 *
1049 * Returns 0 on success. 1049 * Returns 0 on success.
1050 */ 1050 */
1051 int (*gem_init_object) (struct drm_gem_object *obj); 1051 int (*gem_init_object) (struct drm_gem_object *obj);
1052 void (*gem_free_object) (struct drm_gem_object *obj); 1052 void (*gem_free_object) (struct drm_gem_object *obj);
1053 int (*gem_open_object) (struct drm_gem_object *, struct drm_file *); 1053 int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
1054 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *); 1054 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
1055 1055
1056 /* prime: */ 1056 /* prime: */
1057 /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */ 1057 /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
1058 int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv, 1058 int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
1059 uint32_t handle, uint32_t flags, int *prime_fd); 1059 uint32_t handle, uint32_t flags, int *prime_fd);
1060 /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */ 1060 /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
1061 int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv, 1061 int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
1062 int prime_fd, uint32_t *handle); 1062 int prime_fd, uint32_t *handle);
1063 /* export GEM -> dmabuf */ 1063 /* export GEM -> dmabuf */
1064 struct dma_buf * (*gem_prime_export)(struct drm_device *dev, 1064 struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
1065 struct drm_gem_object *obj, int flags); 1065 struct drm_gem_object *obj, int flags);
1066 /* import dmabuf -> GEM */ 1066 /* import dmabuf -> GEM */
1067 struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, 1067 struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
1068 struct dma_buf *dma_buf); 1068 struct dma_buf *dma_buf);
1069 1069
1070 /* vga arb irq handler */ 1070 /* vga arb irq handler */
1071 void (*vgaarb_irq)(struct drm_device *dev, bool state); 1071 void (*vgaarb_irq)(struct drm_device *dev, bool state);
1072 1072
1073 /* dumb alloc support */ 1073 /* dumb alloc support */
1074 int (*dumb_create)(struct drm_file *file_priv, 1074 int (*dumb_create)(struct drm_file *file_priv,
1075 struct drm_device *dev, 1075 struct drm_device *dev,
1076 struct drm_mode_create_dumb *args); 1076 struct drm_mode_create_dumb *args);
1077 int (*dumb_map_offset)(struct drm_file *file_priv, 1077 int (*dumb_map_offset)(struct drm_file *file_priv,
1078 struct drm_device *dev, uint32_t handle, 1078 struct drm_device *dev, uint32_t handle,
1079 uint64_t *offset); 1079 uint64_t *offset);
1080 int (*dumb_destroy)(struct drm_file *file_priv, 1080 int (*dumb_destroy)(struct drm_file *file_priv,
1081 struct drm_device *dev, 1081 struct drm_device *dev,
1082 uint32_t handle); 1082 uint32_t handle);
1083 1083
1084 /* Driver private ops for this object */ 1084 /* Driver private ops for this object */
1085#ifdef __NetBSD__ 1085#ifdef __NetBSD__
1086 const struct uvm_pagerops *gem_uvm_ops; 1086 const struct uvm_pagerops *gem_uvm_ops;
1087#else 1087#else
1088 const struct vm_operations_struct *gem_vm_ops; 1088 const struct vm_operations_struct *gem_vm_ops;
1089#endif 1089#endif
1090 1090
1091 int major; 1091 int major;
1092 int minor; 1092 int minor;
1093 int patchlevel; 1093 int patchlevel;
1094#ifdef __NetBSD__ 1094#ifdef __NetBSD__
1095 const char *name; 1095 const char *name;
1096 const char *desc; 1096 const char *desc;
1097 const char *date; 1097 const char *date;
1098#else 1098#else
1099 char *name; 1099 char *name;
1100 char *desc; 1100 char *desc;
1101 char *date; 1101 char *date;
1102#endif 1102#endif
1103 1103
1104 u32 driver_features; 1104 u32 driver_features;
1105 int dev_priv_size; 1105 int dev_priv_size;
1106 struct drm_ioctl_desc *ioctls; 1106 struct drm_ioctl_desc *ioctls;
1107 int num_ioctls; 1107 int num_ioctls;
1108 const struct file_operations *fops; 1108 const struct file_operations *fops;
1109 union { 1109 union {
1110 struct pci_driver *pci; 1110 struct pci_driver *pci;
1111 struct platform_device *platform_device; 1111 struct platform_device *platform_device;
1112 struct usb_driver *usb; 1112 struct usb_driver *usb;
1113 } kdriver; 1113 } kdriver;
1114 struct drm_bus *bus; 1114 struct drm_bus *bus;
1115 1115
1116 /* List of devices hanging off this driver */ 1116 /* List of devices hanging off this driver */
1117 struct list_head device_list; 1117 struct list_head device_list;
1118}; 1118};
1119 1119
1120#define DRM_MINOR_UNASSIGNED 0 1120#define DRM_MINOR_UNASSIGNED 0
1121#define DRM_MINOR_LEGACY 1 1121#define DRM_MINOR_LEGACY 1
1122#define DRM_MINOR_CONTROL 2 1122#define DRM_MINOR_CONTROL 2
1123#define DRM_MINOR_RENDER 3 1123#define DRM_MINOR_RENDER 3
1124 1124
1125 1125
1126#ifndef __NetBSD__ 1126#ifndef __NetBSD__
1127/** 1127/**
1128 * debugfs node list. This structure represents a debugfs file to 1128 * debugfs node list. This structure represents a debugfs file to
1129 * be created by the drm core 1129 * be created by the drm core
1130 */ 1130 */
1131struct drm_debugfs_list { 1131struct drm_debugfs_list {
1132 const char *name; /** file name */ 1132 const char *name; /** file name */
1133 int (*show)(struct seq_file*, void*); /** show callback */ 1133 int (*show)(struct seq_file*, void*); /** show callback */
1134 u32 driver_features; /**< Required driver features for this entry */ 1134 u32 driver_features; /**< Required driver features for this entry */
1135}; 1135};
1136 1136
1137/** 1137/**
1138 * debugfs node structure. This structure represents a debugfs file. 1138 * debugfs node structure. This structure represents a debugfs file.
1139 */ 1139 */
1140struct drm_debugfs_node { 1140struct drm_debugfs_node {
1141 struct list_head list; 1141 struct list_head list;
1142 struct drm_minor *minor; 1142 struct drm_minor *minor;
1143 struct drm_debugfs_list *debugfs_ent; 1143 struct drm_debugfs_list *debugfs_ent;
1144 struct dentry *dent; 1144 struct dentry *dent;
1145}; 1145};
1146 1146
1147/** 1147/**
1148 * Info file list entry. This structure represents a debugfs or proc file to 1148 * Info file list entry. This structure represents a debugfs or proc file to
1149 * be created by the drm core 1149 * be created by the drm core
1150 */ 1150 */
1151struct drm_info_list { 1151struct drm_info_list {
1152 const char *name; /** file name */ 1152 const char *name; /** file name */
1153 int (*show)(struct seq_file*, void*); /** show callback */ 1153 int (*show)(struct seq_file*, void*); /** show callback */
1154 u32 driver_features; /**< Required driver features for this entry */ 1154 u32 driver_features; /**< Required driver features for this entry */
1155 void *data; 1155 void *data;
1156}; 1156};
1157 1157
1158/** 1158/**
1159 * debugfs node structure. This structure represents a debugfs file. 1159 * debugfs node structure. This structure represents a debugfs file.
1160 */ 1160 */
1161struct drm_info_node { 1161struct drm_info_node {
1162 struct list_head list; 1162 struct list_head list;
1163 struct drm_minor *minor; 1163 struct drm_minor *minor;
1164 struct drm_info_list *info_ent; 1164 struct drm_info_list *info_ent;
1165 struct dentry *dent; 1165 struct dentry *dent;
1166}; 1166};
1167#endif 1167#endif
1168 1168
1169/** 1169/**
1170 * DRM minor structure. This structure represents a drm minor number. 1170 * DRM minor structure. This structure represents a drm minor number.
1171 */ 1171 */
1172struct drm_minor { 1172struct drm_minor {
1173 int index; /**< Minor device number */ 1173 int index; /**< Minor device number */
1174 int type; /**< Control or render */ 1174 int type; /**< Control or render */
1175 dev_t device; /**< Device number for mknod */ 1175 dev_t device; /**< Device number for mknod */
1176#ifdef __NetBSD__ 1176#ifdef __NetBSD__
1177 device_t kdev; /* NetBSD device */ 1177 device_t kdev; /* NetBSD device */
1178#else 1178#else
1179 struct device kdev; /**< Linux device */ 1179 struct device kdev; /**< Linux device */
1180#endif 1180#endif
1181 struct drm_device *dev; 1181 struct drm_device *dev;
1182 1182
1183#ifndef __NetBSD__ 1183#ifndef __NetBSD__
1184 struct proc_dir_entry *proc_root; /**< proc directory entry */ 1184 struct proc_dir_entry *proc_root; /**< proc directory entry */
1185 struct drm_info_node proc_nodes; 1185 struct drm_info_node proc_nodes;
1186 struct dentry *debugfs_root; 1186 struct dentry *debugfs_root;
1187 1187
1188 struct list_head debugfs_list; 1188 struct list_head debugfs_list;
1189 struct mutex debugfs_lock; /* Protects debugfs_list. */ 1189 struct mutex debugfs_lock; /* Protects debugfs_list. */
1190#endif 1190#endif
1191 1191
1192 struct drm_master *master; /* currently active master for this node */ 1192 struct drm_master *master; /* currently active master for this node */
1193 struct list_head master_list; 1193 struct list_head master_list;
1194 struct drm_mode_group mode_group; 1194 struct drm_mode_group mode_group;
1195}; 1195};
1196 1196
1197/* mode specified on the command line */ 1197/* mode specified on the command line */
1198struct drm_cmdline_mode { 1198struct drm_cmdline_mode {
1199 bool specified; 1199 bool specified;
1200 bool refresh_specified; 1200 bool refresh_specified;
1201 bool bpp_specified; 1201 bool bpp_specified;
1202 int xres, yres; 1202 int xres, yres;
1203 int bpp; 1203 int bpp;
1204 int refresh; 1204 int refresh;
1205 bool rb; 1205 bool rb;
1206 bool interlace; 1206 bool interlace;
1207 bool cvt; 1207 bool cvt;
1208 bool margins; 1208 bool margins;
1209 enum drm_connector_force force; 1209 enum drm_connector_force force;
1210}; 1210};
1211 1211
1212 1212
1213struct drm_pending_vblank_event { 1213struct drm_pending_vblank_event {
1214 struct drm_pending_event base; 1214 struct drm_pending_event base;
1215 int pipe; 1215 int pipe;
1216 struct drm_event_vblank event; 1216 struct drm_event_vblank event;
1217}; 1217};
1218 1218
1219/** 1219/**
1220 * DRM device structure. This structure represent a complete card that 1220 * DRM device structure. This structure represent a complete card that
1221 * may contain multiple heads. 1221 * may contain multiple heads.
1222 */ 1222 */
1223struct drm_device { 1223struct drm_device {
1224 struct list_head driver_item; /**< list of devices per driver */ 1224 struct list_head driver_item; /**< list of devices per driver */
1225 char *devname; /**< For /proc/interrupts */ 1225 char *devname; /**< For /proc/interrupts */
1226 int if_version; /**< Highest interface version set */ 1226 int if_version; /**< Highest interface version set */
1227 1227
1228 /** \name Locks */ 1228 /** \name Locks */
1229 /*@{ */ 1229 /*@{ */
1230 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 1230 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
1231 struct mutex struct_mutex; /**< For others */ 1231 struct mutex struct_mutex; /**< For others */
1232 /*@} */ 1232 /*@} */
1233 1233
1234 /** \name Usage Counters */ 1234 /** \name Usage Counters */
1235 /*@{ */ 1235 /*@{ */
1236 int open_count; /**< Outstanding files open */ 1236 int open_count; /**< Outstanding files open */
1237 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */ 1237 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
1238 atomic_t vma_count; /**< Outstanding vma areas open */ 1238 atomic_t vma_count; /**< Outstanding vma areas open */
1239 int buf_use; /**< Buffers in use -- cannot alloc */ 1239 int buf_use; /**< Buffers in use -- cannot alloc */
1240 atomic_t buf_alloc; /**< Buffer allocation in progress */ 1240 atomic_t buf_alloc; /**< Buffer allocation in progress */
1241 /*@} */ 1241 /*@} */
1242 1242
1243 /** \name Performance counters */ 1243 /** \name Performance counters */
1244 /*@{ */ 1244 /*@{ */
1245 unsigned long counters; 1245 unsigned long counters;
1246 enum drm_stat_type types[15]; 1246 enum drm_stat_type types[15];
1247 atomic_t counts[15]; 1247 atomic_t counts[15];
1248 /*@} */ 1248 /*@} */
1249 1249
1250 struct list_head filelist; 1250 struct list_head filelist;
1251 1251
1252 /** \name Memory management */ 1252 /** \name Memory management */
1253 /*@{ */ 1253 /*@{ */
1254 struct list_head maplist; /**< Linked list of regions */ 1254 struct list_head maplist; /**< Linked list of regions */
1255 int map_count; /**< Number of mappable regions */ 1255 int map_count; /**< Number of mappable regions */
1256 struct drm_open_hash map_hash; /**< User token hash table for maps */ 1256 struct drm_open_hash map_hash; /**< User token hash table for maps */
1257 1257
1258 /** \name Context handle management */ 1258 /** \name Context handle management */
1259 /*@{ */ 1259 /*@{ */
1260 struct list_head ctxlist; /**< Linked list of context handles */ 1260 struct list_head ctxlist; /**< Linked list of context handles */
1261 int ctx_count; /**< Number of context handles */ 1261 int ctx_count; /**< Number of context handles */
1262 struct mutex ctxlist_mutex; /**< For ctxlist */ 1262 struct mutex ctxlist_mutex; /**< For ctxlist */
1263 1263
1264 struct idr ctx_idr; 1264 struct idr ctx_idr;
1265 1265
1266 struct list_head vmalist; /**< List of vmas (for debugging) */ 1266 struct list_head vmalist; /**< List of vmas (for debugging) */
1267 1267
1268 /*@} */ 1268 /*@} */
1269 1269
1270 /** \name DMA support */ 1270 /** \name DMA support */
1271 /*@{ */ 1271 /*@{ */
1272 struct drm_device_dma *dma; /**< Optional pointer for DMA support */ 1272 struct drm_device_dma *dma; /**< Optional pointer for DMA support */
1273 /*@} */ 1273 /*@} */
1274 1274
1275 /** \name Context support */ 1275 /** \name Context support */
1276 /*@{ */ 1276 /*@{ */
1277 int irq_enabled; /**< True if irq handler is enabled */ 1277 int irq_enabled; /**< True if irq handler is enabled */
1278#ifdef __NetBSD__ 1278#ifdef __NetBSD__
1279 struct drm_bus_irq_cookie *irq_cookie; 1279 struct drm_bus_irq_cookie *irq_cookie;
1280#endif 1280#endif
1281 __volatile__ long context_flag; /**< Context swapping flag */ 1281 __volatile__ long context_flag; /**< Context swapping flag */
1282 __volatile__ long interrupt_flag; /**< Interruption handler flag */ 1282 __volatile__ long interrupt_flag; /**< Interruption handler flag */
1283 __volatile__ long dma_flag; /**< DMA dispatch flag */ 1283 __volatile__ long dma_flag; /**< DMA dispatch flag */
1284#ifdef __NetBSD__ 1284#ifdef __NetBSD__
1285 drm_waitqueue_t context_wait; /**< Processes waiting on ctx switch */ 1285 drm_waitqueue_t context_wait; /**< Processes waiting on ctx switch */
1286#else 1286#else
1287 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ 1287 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
1288#endif 1288#endif
1289 int last_checked; /**< Last context checked for DMA */ 1289 int last_checked; /**< Last context checked for DMA */
1290 int last_context; /**< Last current context */ 1290 int last_context; /**< Last current context */
1291#ifndef __NetBSD__ 1291#ifndef __NetBSD__
1292 /* XXX Nobody seems to use this. */ 1292 /* XXX Nobody seems to use this. */
1293 unsigned long last_switch; /**< jiffies at last context switch */ 1293 unsigned long last_switch; /**< jiffies at last context switch */
1294#endif 1294#endif
1295 /*@} */ 1295 /*@} */
1296 1296
1297 struct work_struct work; 1297 struct work_struct work;
1298 /** \name VBLANK IRQ support */ 1298 /** \name VBLANK IRQ support */
1299 /*@{ */ 1299 /*@{ */
1300 1300
1301 /* 1301 /*
1302 * At load time, disabling the vblank interrupt won't be allowed since 1302 * At load time, disabling the vblank interrupt won't be allowed since
1303 * old clients may not call the modeset ioctl and therefore misbehave. 1303 * old clients may not call the modeset ioctl and therefore misbehave.
1304 * Once the modeset ioctl *has* been called though, we can safely 1304 * Once the modeset ioctl *has* been called though, we can safely
1305 * disable them when unused. 1305 * disable them when unused.
1306 */ 1306 */
1307 int vblank_disable_allowed; 1307 int vblank_disable_allowed;
1308 1308
1309#ifdef __NetBSD__ 1309#ifdef __NetBSD__
1310 drm_waitqueue_t *vbl_queue; /**< VBLANK wait queue */ 1310 drm_waitqueue_t *vbl_queue; /**< VBLANK wait queue */
1311#else 1311#else
1312 wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */ 1312 wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */
1313#endif 1313#endif
1314 atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */ 1314 atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
1315 struct timeval *_vblank_time; /**< timestamp of current vblank_count (drivers must alloc right number of fields) */ 1315 struct timeval *_vblank_time; /**< timestamp of current vblank_count (drivers must alloc right number of fields) */
1316 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ 1316 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
1317 spinlock_t vbl_lock; 1317 spinlock_t vbl_lock;
1318 atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */ 1318 atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */
1319 u32 *last_vblank; /* protected by dev->vbl_lock, used */ 1319 u32 *last_vblank; /* protected by dev->vbl_lock, used */
1320 /* for wraparound handling */ 1320 /* for wraparound handling */
1321 int *vblank_enabled; /* so we don't call enable more than 1321 int *vblank_enabled; /* so we don't call enable more than
1322 once per disable */ 1322 once per disable */
1323 int *vblank_inmodeset; /* Display driver is setting mode */ 1323 int *vblank_inmodeset; /* Display driver is setting mode */
1324 u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */ 1324 u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */
1325 struct timer_list vblank_disable_timer; 1325 struct timer_list vblank_disable_timer;
1326 1326
1327 u32 max_vblank_count; /**< size of vblank counter register */ 1327 u32 max_vblank_count; /**< size of vblank counter register */
1328 1328
1329 /** 1329 /**
1330 * List of events 1330 * List of events
1331 */ 1331 */
1332 struct list_head vblank_event_list; 1332 struct list_head vblank_event_list;
1333 spinlock_t event_lock; 1333 spinlock_t event_lock;
1334 1334
1335 /*@} */ 1335 /*@} */
1336 cycles_t ctx_start; 1336 cycles_t ctx_start;
1337 cycles_t lck_start; 1337 cycles_t lck_start;
1338 1338
1339 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ 1339 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
1340#ifdef __NetBSD__ 1340#ifdef __NetBSD__
1341 drm_waitqueue_t buf_readers; /**< Processes waiting to read */ 1341 drm_waitqueue_t buf_readers; /**< Processes waiting to read */
1342 drm_waitqueue_t buf_writers; /**< Processes waiting to ctx switch */ 1342 drm_waitqueue_t buf_writers; /**< Processes waiting to ctx switch */
1343#else 1343#else
1344 wait_queue_head_t buf_readers; /**< Processes waiting to read */ 1344 wait_queue_head_t buf_readers; /**< Processes waiting to read */
1345 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ 1345 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
1346#endif 1346#endif
1347 1347
1348 struct drm_agp_head *agp; /**< AGP data */ 1348 struct drm_agp_head *agp; /**< AGP data */
1349 1349
1350 struct device *dev; /**< Device structure */ 1350 struct device *dev; /**< Device structure */
1351 struct pci_dev *pdev; /**< PCI device structure */ 1351 struct pci_dev *pdev; /**< PCI device structure */
1352 int pci_vendor; /**< PCI vendor id */ 1352 int pci_vendor; /**< PCI vendor id */
1353 int pci_device; /**< PCI device id */ 1353 int pci_device; /**< PCI device id */
1354#ifdef __alpha__ 1354#ifdef __alpha__
1355 struct pci_controller *hose; 1355 struct pci_controller *hose;
1356#endif 1356#endif
1357 1357
1358 struct platform_device *platformdev; /**< Platform device struture */ 1358 struct platform_device *platformdev; /**< Platform device struture */
1359 struct usb_device *usbdev; 1359 struct usb_device *usbdev;
1360 1360
1361#ifdef __NetBSD__ 1361#ifdef __NetBSD__
1362 bus_space_tag_t bst; 1362 bus_space_tag_t bst;
1363 struct drm_bus_map *bus_maps; 1363 struct drm_bus_map *bus_maps;
1364 size_t bus_nmaps; 1364 size_t bus_nmaps;
1365 /* XXX What does this have to do with AGP? */ 1365 /* XXX What does this have to do with AGP? */
1366 struct drm_bus_map *agp_maps; 1366 struct drm_bus_map *agp_maps;
1367 size_t agp_nmaps; 1367 size_t agp_nmaps;
1368 bus_dma_tag_t bus_dmat; 1368 bus_dma_tag_t bus_dmat;
1369 bus_dma_tag_t dmat; 1369 bus_dma_tag_t dmat;
1370 bool dmat_subregion_p; 1370 bool dmat_subregion_p;
1371 bus_addr_t dmat_subregion_min; 1371 bus_addr_t dmat_subregion_min;
1372 bus_addr_t dmat_subregion_max; 1372 bus_addr_t dmat_subregion_max;
1373#endif 1373#endif
1374 1374
1375 struct drm_sg_mem *sg; /**< Scatter gather memory */ 1375 struct drm_sg_mem *sg; /**< Scatter gather memory */
1376 unsigned int num_crtcs; /**< Number of CRTCs on this device */ 1376 unsigned int num_crtcs; /**< Number of CRTCs on this device */
1377 void *dev_private; /**< device private data */ 1377 void *dev_private; /**< device private data */
1378 void *mm_private; 1378 void *mm_private;
1379 struct address_space *dev_mapping; 1379 struct address_space *dev_mapping;
1380 struct drm_sigdata sigdata; /**< For block_all_signals */ 1380 struct drm_sigdata sigdata; /**< For block_all_signals */
1381#ifndef __NetBSD__ 1381#ifndef __NetBSD__
1382 sigset_t sigmask; 1382 sigset_t sigmask;
1383#endif 1383#endif
1384 1384
1385 struct drm_driver *driver; 1385 struct drm_driver *driver;
1386 struct drm_local_map *agp_buffer_map; 1386 struct drm_local_map *agp_buffer_map;
1387 unsigned int agp_buffer_token; 1387 unsigned int agp_buffer_token;
1388 struct drm_minor *control; /**< Control node for card */ 1388 struct drm_minor *control; /**< Control node for card */
1389 struct drm_minor *primary; /**< render type primary screen head */ 1389 struct drm_minor *primary; /**< render type primary screen head */
1390 1390
1391 struct drm_mode_config mode_config; /**< Current mode config */ 1391 struct drm_mode_config mode_config; /**< Current mode config */
1392 1392
1393 /** \name GEM information */ 1393 /** \name GEM information */
1394 /*@{ */ 1394 /*@{ */
1395 spinlock_t object_name_lock; 1395 spinlock_t object_name_lock;
1396 struct idr object_name_idr; 1396 struct idr object_name_idr;
1397 /*@} */ 1397 /*@} */
1398 int switch_power_state; 1398 int switch_power_state;
1399 1399
1400 atomic_t unplugged; /* device has been unplugged or gone away */ 1400 atomic_t unplugged; /* device has been unplugged or gone away */
1401}; 1401};
1402 1402
1403#define DRM_SWITCH_POWER_ON 0 1403#define DRM_SWITCH_POWER_ON 0
1404#define DRM_SWITCH_POWER_OFF 1 1404#define DRM_SWITCH_POWER_OFF 1
1405#define DRM_SWITCH_POWER_CHANGING 2 1405#define DRM_SWITCH_POWER_CHANGING 2
1406 1406
1407static __inline__ int drm_core_check_feature(struct drm_device *dev, 1407static __inline__ int drm_core_check_feature(struct drm_device *dev,
1408 int feature) 1408 int feature)
1409{ 1409{
1410 return ((dev->driver->driver_features & feature) ? 1 : 0); 1410 return ((dev->driver->driver_features & feature) ? 1 : 0);
1411} 1411}
1412 1412
1413static inline int drm_dev_to_irq(struct drm_device *dev) 1413static inline int drm_dev_to_irq(struct drm_device *dev)
1414{ 1414{
1415 return dev->driver->bus->get_irq(dev); 1415 return dev->driver->bus->get_irq(dev);
1416} 1416}
1417 1417
1418 1418
1419#if __OS_HAS_AGP 1419#if __OS_HAS_AGP
1420static inline int drm_core_has_AGP(struct drm_device *dev) 1420static inline int drm_core_has_AGP(struct drm_device *dev)
1421{ 1421{
1422 return drm_core_check_feature(dev, DRIVER_USE_AGP); 1422 return drm_core_check_feature(dev, DRIVER_USE_AGP);
1423} 1423}
1424#else 1424#else
1425#define drm_core_has_AGP(dev) (0) 1425#define drm_core_has_AGP(dev) (0)
1426#endif 1426#endif
1427 1427
1428#if __OS_HAS_MTRR 1428#if __OS_HAS_MTRR
1429static inline int drm_core_has_MTRR(struct drm_device *dev) 1429static inline int drm_core_has_MTRR(struct drm_device *dev)
1430{ 1430{
1431 return drm_core_check_feature(dev, DRIVER_USE_MTRR); 1431 return drm_core_check_feature(dev, DRIVER_USE_MTRR);
1432} 1432}
1433 1433
1434#define DRM_MTRR_WC MTRR_TYPE_WRCOMB 1434#define DRM_MTRR_WC MTRR_TYPE_WRCOMB
1435 1435
1436static inline int drm_mtrr_add(unsigned long offset, unsigned long size, 1436static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1437 unsigned int flags) 1437 unsigned int flags)
1438{ 1438{
1439 return mtrr_add(offset, size, flags, 1); 1439 return mtrr_add(offset, size, flags, 1);
1440} 1440}
1441 1441
1442static inline int drm_mtrr_del(int handle, unsigned long offset, 1442static inline int drm_mtrr_del(int handle, unsigned long offset,
1443 unsigned long size, unsigned int flags) 1443 unsigned long size, unsigned int flags)
1444{ 1444{
1445 return mtrr_del(handle, offset, size); 1445 return mtrr_del(handle, offset, size);
1446} 1446}
1447 1447
1448#else 1448#else
1449#define drm_core_has_MTRR(dev) (0) 1449#define drm_core_has_MTRR(dev) (0)
1450 1450
1451#define DRM_MTRR_WC 0 1451#define DRM_MTRR_WC 0
1452 1452
1453static inline int drm_mtrr_add(unsigned long offset, unsigned long size, 1453static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1454 unsigned int flags) 1454 unsigned int flags)
1455{ 1455{
1456 return 0; 1456 return 0;
1457} 1457}
1458 1458
1459static inline int drm_mtrr_del(int handle, unsigned long offset, 1459static inline int drm_mtrr_del(int handle, unsigned long offset,
1460 unsigned long size, unsigned int flags) 1460 unsigned long size, unsigned int flags)
1461{ 1461{
1462 return 0; 1462 return 0;
1463} 1463}
1464#endif 1464#endif
1465 1465
1466static inline void drm_device_set_unplugged(struct drm_device *dev) 1466static inline void drm_device_set_unplugged(struct drm_device *dev)
1467{ 1467{
1468 smp_wmb(); 1468 smp_wmb();
1469 atomic_set(&dev->unplugged, 1); 1469 atomic_set(&dev->unplugged, 1);
1470} 1470}
1471 1471
1472static inline int drm_device_is_unplugged(struct drm_device *dev) 1472static inline int drm_device_is_unplugged(struct drm_device *dev)
1473{ 1473{
1474 int ret = atomic_read(&dev->unplugged); 1474 int ret = atomic_read(&dev->unplugged);
1475 smp_rmb(); 1475 smp_rmb();
1476 return ret; 1476 return ret;
1477} 1477}
1478 1478
1479/******************************************************************/ 1479/******************************************************************/
1480/** \name Internal function definitions */ 1480/** \name Internal function definitions */
1481/*@{*/ 1481/*@{*/
1482 1482
1483#ifndef __NetBSD__ /* XXX temporary measure 20130212 */ 1483#ifndef __NetBSD__ /* XXX temporary measure 20130212 */
1484 1484
1485 /* Driver support (drm_drv.h) */ 1485 /* Driver support (drm_drv.h) */
1486extern long drm_ioctl(struct file *filp, 1486extern long drm_ioctl(struct file *filp,
1487 unsigned int cmd, unsigned long arg); 1487 unsigned int cmd, unsigned long arg);
1488extern long drm_compat_ioctl(struct file *filp, 1488extern long drm_compat_ioctl(struct file *filp,
1489 unsigned int cmd, unsigned long arg); 1489 unsigned int cmd, unsigned long arg);
1490extern int drm_lastclose(struct drm_device *dev); 1490extern int drm_lastclose(struct drm_device *dev);
1491#endif 1491#endif
1492 1492
1493#ifdef __NetBSD__ 1493#ifdef __NetBSD__
1494extern void drm_config_found(device_t, /* XXXX const */ struct drm_driver *, 1494extern void drm_config_found(device_t, /* XXXX const */ struct drm_driver *,
1495 unsigned long, struct drm_device *); 1495 unsigned long, struct drm_device *);
1496#endif 1496#endif
1497 1497
1498 /* Device support (drm_fops.h) */ 1498 /* Device support (drm_fops.h) */
1499extern struct mutex drm_global_mutex; 1499extern struct mutex drm_global_mutex;
1500#ifdef __NetBSD__ 1500#ifdef __NetBSD__
1501extern int drm_open_file(struct drm_file *, void *, struct drm_minor *); 1501extern int drm_open_file(struct drm_file *, void *, struct drm_minor *);
1502extern int drm_close_file(struct drm_file *); 1502extern int drm_close_file(struct drm_file *);
1503#if 0 /* XXX drm event poll */ 1503#if 0 /* XXX drm event poll */
1504extern int drm_dequeue_event(struct drm_file *, size_t, 1504extern int drm_dequeue_event(struct drm_file *, size_t,
1505 struct drm_pending_event **); 1505 struct drm_pending_event **);
1506#endif 1506#endif
1507extern void drm_lastclose(struct drm_device *); 1507extern void drm_lastclose(struct drm_device *);
1508#else 1508#else
1509extern int drm_open(struct inode *inode, struct file *filp); 1509extern int drm_open(struct inode *inode, struct file *filp);
1510extern int drm_stub_open(struct inode *inode, struct file *filp); 1510extern int drm_stub_open(struct inode *inode, struct file *filp);
1511extern int drm_fasync(int fd, struct file *filp, int on); 1511extern int drm_fasync(int fd, struct file *filp, int on);
1512extern ssize_t drm_read(struct file *filp, char __user *buffer, 1512extern ssize_t drm_read(struct file *filp, char __user *buffer,
1513 size_t count, loff_t *offset); 1513 size_t count, loff_t *offset);
1514extern int drm_release(struct inode *inode, struct file *filp); 1514extern int drm_release(struct inode *inode, struct file *filp);
1515#endif 1515#endif
1516 1516
1517 /* Mapping support (drm_vm.h) */ 1517 /* Mapping support (drm_vm.h) */
1518#ifdef __NetBSD__ 1518#ifdef __NetBSD__
1519extern paddr_t drm_mmap_paddr(struct drm_device *, off_t, int); 1519extern paddr_t drm_mmap_paddr(struct drm_device *, off_t, int);
1520#else 1520#else
1521extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 1521extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1522extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); 1522extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1523extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); 1523extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
1524extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); 1524extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
1525extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 1525extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1526 1526
1527#endif 1527#endif
1528 1528
1529 /* Memory management support (drm_memory.h) */ 1529 /* Memory management support (drm_memory.h) */
1530#include <drm/drm_memory.h> 1530#include <drm/drm_memory.h>
1531#ifndef __NetBSD__ 1531#ifndef __NetBSD__
1532extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); 1532extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
1533extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); 1533extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1534extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, 1534extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
1535 struct page **pages, 1535 struct page **pages,
1536 unsigned long num_pages, 1536 unsigned long num_pages,
1537 uint32_t gtt_offset, 1537 uint32_t gtt_offset,
1538 uint32_t type); 1538 uint32_t type);
1539extern int drm_unbind_agp(DRM_AGP_MEM * handle); 1539extern int drm_unbind_agp(DRM_AGP_MEM * handle);
1540#endif 1540#endif
1541#ifdef __NetBSD__ 1541#ifdef __NetBSD__
1542extern void *drm_ioremap(struct drm_device *dev, struct drm_local_map *map); 1542extern void *drm_ioremap(struct drm_device *dev, struct drm_local_map *map);
1543extern void drm_iounmap(struct drm_device *dev, struct drm_local_map *map); 1543extern void drm_iounmap(struct drm_device *dev, struct drm_local_map *map);
1544extern int drm_limit_dma_space(struct drm_device *, resource_size_t, 1544extern int drm_limit_dma_space(struct drm_device *, resource_size_t,
1545 resource_size_t); 1545 resource_size_t);
1546#endif 1546#endif
1547 1547
1548 /* Misc. IOCTL support (drm_ioctl.h) */ 1548 /* Misc. IOCTL support (drm_ioctl.h) */
1549extern int drm_irq_by_busid(struct drm_device *dev, void *data, 1549extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1550 struct drm_file *file_priv); 1550 struct drm_file *file_priv);
1551extern int drm_getunique(struct drm_device *dev, void *data, 1551extern int drm_getunique(struct drm_device *dev, void *data,
1552 struct drm_file *file_priv); 1552 struct drm_file *file_priv);
1553extern int drm_setunique(struct drm_device *dev, void *data, 1553extern int drm_setunique(struct drm_device *dev, void *data,
1554 struct drm_file *file_priv); 1554 struct drm_file *file_priv);
1555extern int drm_getmap(struct drm_device *dev, void *data, 1555extern int drm_getmap(struct drm_device *dev, void *data,
1556 struct drm_file *file_priv); 1556 struct drm_file *file_priv);
1557extern int drm_getclient(struct drm_device *dev, void *data, 1557extern int drm_getclient(struct drm_device *dev, void *data,
1558 struct drm_file *file_priv); 1558 struct drm_file *file_priv);
1559extern int drm_getstats(struct drm_device *dev, void *data, 1559extern int drm_getstats(struct drm_device *dev, void *data,
1560 struct drm_file *file_priv); 1560 struct drm_file *file_priv);
1561extern int drm_getcap(struct drm_device *dev, void *data, 1561extern int drm_getcap(struct drm_device *dev, void *data,
1562 struct drm_file *file_priv); 1562 struct drm_file *file_priv);
1563extern int drm_setversion(struct drm_device *dev, void *data, 1563extern int drm_setversion(struct drm_device *dev, void *data,
1564 struct drm_file *file_priv); 1564 struct drm_file *file_priv);
1565extern int drm_noop(struct drm_device *dev, void *data, 1565extern int drm_noop(struct drm_device *dev, void *data,
1566 struct drm_file *file_priv); 1566 struct drm_file *file_priv);
1567 1567
1568 /* Context IOCTL support (drm_context.h) */ 1568 /* Context IOCTL support (drm_context.h) */
1569extern int drm_resctx(struct drm_device *dev, void *data, 1569extern int drm_resctx(struct drm_device *dev, void *data,
1570 struct drm_file *file_priv); 1570 struct drm_file *file_priv);
1571extern int drm_addctx(struct drm_device *dev, void *data, 1571extern int drm_addctx(struct drm_device *dev, void *data,
1572 struct drm_file *file_priv); 1572 struct drm_file *file_priv);
1573extern int drm_modctx(struct drm_device *dev, void *data, 1573extern int drm_modctx(struct drm_device *dev, void *data,
1574 struct drm_file *file_priv); 1574 struct drm_file *file_priv);
1575extern int drm_getctx(struct drm_device *dev, void *data, 1575extern int drm_getctx(struct drm_device *dev, void *data,
1576 struct drm_file *file_priv); 1576 struct drm_file *file_priv);
1577extern int drm_switchctx(struct drm_device *dev, void *data, 1577extern int drm_switchctx(struct drm_device *dev, void *data,
1578 struct drm_file *file_priv); 1578 struct drm_file *file_priv);
1579extern int drm_newctx(struct drm_device *dev, void *data, 1579extern int drm_newctx(struct drm_device *dev, void *data,
1580 struct drm_file *file_priv); 1580 struct drm_file *file_priv);
1581extern int drm_rmctx(struct drm_device *dev, void *data, 1581extern int drm_rmctx(struct drm_device *dev, void *data,
1582 struct drm_file *file_priv); 1582 struct drm_file *file_priv);
1583 1583
1584extern int drm_ctxbitmap_init(struct drm_device *dev); 1584extern int drm_ctxbitmap_init(struct drm_device *dev);
1585extern void drm_ctxbitmap_cleanup(struct drm_device *dev); 1585extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
1586extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); 1586extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
1587 1587
1588extern int drm_setsareactx(struct drm_device *dev, void *data, 1588extern int drm_setsareactx(struct drm_device *dev, void *data,
1589 struct drm_file *file_priv); 1589 struct drm_file *file_priv);
1590extern int drm_getsareactx(struct drm_device *dev, void *data, 1590extern int drm_getsareactx(struct drm_device *dev, void *data,
1591 struct drm_file *file_priv); 1591 struct drm_file *file_priv);
1592 1592
1593 /* Authentication IOCTL support (drm_auth.h) */ 1593 /* Authentication IOCTL support (drm_auth.h) */
1594extern int drm_getmagic(struct drm_device *dev, void *data, 1594extern int drm_getmagic(struct drm_device *dev, void *data,
1595 struct drm_file *file_priv); 1595 struct drm_file *file_priv);
1596extern int drm_authmagic(struct drm_device *dev, void *data, 1596extern int drm_authmagic(struct drm_device *dev, void *data,
1597 struct drm_file *file_priv); 1597 struct drm_file *file_priv);
1598extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic); 1598extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
1599 1599
1600#ifndef __NetBSD__ /* XXX temporary measure 20130212 */ 1600#ifndef __NetBSD__ /* XXX temporary measure 20130212 */
1601/* Cache management (drm_cache.c) */ 1601/* Cache management (drm_cache.c) */
1602void drm_clflush_pages(struct page *pages[], unsigned long num_pages); 1602void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1603void drm_clflush_sg(struct sg_table *st); 1603void drm_clflush_sg(struct sg_table *st);
1604void drm_clflush_virt_range(char *addr, unsigned long length); 1604void drm_clflush_virt_range(char *addr, unsigned long length);
1605#endif 1605#endif
1606 1606
1607 /* Locking IOCTL support (drm_lock.h) */ 1607 /* Locking IOCTL support (drm_lock.h) */
1608extern int drm_lock(struct drm_device *dev, void *data, 1608extern int drm_lock(struct drm_device *dev, void *data,
1609 struct drm_file *file_priv); 1609 struct drm_file *file_priv);
1610extern int drm_unlock(struct drm_device *dev, void *data, 1610extern int drm_unlock(struct drm_device *dev, void *data,
1611 struct drm_file *file_priv); 1611 struct drm_file *file_priv);
1612extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); 1612extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1613extern void drm_idlelock_take(struct drm_lock_data *lock_data); 1613extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1614extern void drm_idlelock_release(struct drm_lock_data *lock_data); 1614extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1615 1615
1616/* 1616/*
1617 * These are exported to drivers so that they can implement fencing using 1617 * These are exported to drivers so that they can implement fencing using
1618 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 1618 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1619 */ 1619 */
1620 1620
1621extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); 1621extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1622 1622
1623 /* Buffer management support (drm_bufs.h) */ 1623 /* Buffer management support (drm_bufs.h) */
1624extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); 1624extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1625extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); 1625extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1626extern int drm_addmap(struct drm_device *dev, resource_size_t offset, 1626extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
1627 unsigned int size, enum drm_map_type type, 1627 unsigned int size, enum drm_map_type type,
1628 enum drm_map_flags flags, struct drm_local_map **map_ptr); 1628 enum drm_map_flags flags, struct drm_local_map **map_ptr);
1629extern int drm_addmap_ioctl(struct drm_device *dev, void *data, 1629extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1630 struct drm_file *file_priv); 1630 struct drm_file *file_priv);
1631extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); 1631extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
1632extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); 1632extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
1633extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, 1633extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1634 struct drm_file *file_priv); 1634 struct drm_file *file_priv);
1635extern int drm_addbufs(struct drm_device *dev, void *data, 1635extern int drm_addbufs(struct drm_device *dev, void *data,
1636 struct drm_file *file_priv); 1636 struct drm_file *file_priv);
1637extern int drm_infobufs(struct drm_device *dev, void *data, 1637extern int drm_infobufs(struct drm_device *dev, void *data,
1638 struct drm_file *file_priv); 1638 struct drm_file *file_priv);
1639extern int drm_markbufs(struct drm_device *dev, void *data, 1639extern int drm_markbufs(struct drm_device *dev, void *data,
1640 struct drm_file *file_priv); 1640 struct drm_file *file_priv);
1641extern int drm_freebufs(struct drm_device *dev, void *data, 1641extern int drm_freebufs(struct drm_device *dev, void *data,
1642 struct drm_file *file_priv); 1642 struct drm_file *file_priv);
1643extern int drm_mapbufs(struct drm_device *dev, void *data, 1643extern int drm_mapbufs(struct drm_device *dev, void *data,
1644 struct drm_file *file_priv); 1644 struct drm_file *file_priv);
1645extern int drm_order(unsigned long size); 1645extern int drm_order(unsigned long size);
1646 1646
1647 /* DMA support (drm_dma.h) */ 1647 /* DMA support (drm_dma.h) */
1648extern int drm_dma_setup(struct drm_device *dev); 1648extern int drm_dma_setup(struct drm_device *dev);
1649extern void drm_dma_takedown(struct drm_device *dev); 1649extern void drm_dma_takedown(struct drm_device *dev);
1650extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); 1650extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1651extern void drm_core_reclaim_buffers(struct drm_device *dev, 1651extern void drm_core_reclaim_buffers(struct drm_device *dev,
1652 struct drm_file *filp); 1652 struct drm_file *filp);
1653 1653
1654 /* IRQ support (drm_irq.h) */ 1654 /* IRQ support (drm_irq.h) */
1655extern int drm_control(struct drm_device *dev, void *data, 1655extern int drm_control(struct drm_device *dev, void *data,
1656 struct drm_file *file_priv); 1656 struct drm_file *file_priv);
1657extern int drm_irq_install(struct drm_device *dev); 1657extern int drm_irq_install(struct drm_device *dev);
1658extern int drm_irq_uninstall(struct drm_device *dev); 1658extern int drm_irq_uninstall(struct drm_device *dev);
1659 1659
1660extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); 1660extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1661extern int drm_wait_vblank(struct drm_device *dev, void *data, 1661extern int drm_wait_vblank(struct drm_device *dev, void *data,
1662 struct drm_file *filp); 1662 struct drm_file *filp);
1663extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); 1663extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
1664extern u32 drm_vblank_count(struct drm_device *dev, int crtc); 1664extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1665extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, 1665extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1666 struct timeval *vblanktime); 1666 struct timeval *vblanktime);
1667extern void drm_send_vblank_event(struct drm_device *dev, int crtc, 1667extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1668 struct drm_pending_vblank_event *e); 1668 struct drm_pending_vblank_event *e);
1669extern bool drm_handle_vblank(struct drm_device *dev, int crtc); 1669extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1670extern int drm_vblank_get(struct drm_device *dev, int crtc); 1670extern int drm_vblank_get(struct drm_device *dev, int crtc);
1671extern void drm_vblank_put(struct drm_device *dev, int crtc); 1671extern void drm_vblank_put(struct drm_device *dev, int crtc);
1672extern void drm_vblank_off(struct drm_device *dev, int crtc); 1672extern void drm_vblank_off(struct drm_device *dev, int crtc);
1673extern void drm_vblank_cleanup(struct drm_device *dev); 1673extern void drm_vblank_cleanup(struct drm_device *dev);
1674extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, 1674extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1675 struct timeval *tvblank, unsigned flags); 1675 struct timeval *tvblank, unsigned flags);
1676extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, 1676extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1677 int crtc, int *max_error, 1677 int crtc, int *max_error,
1678 struct timeval *vblank_time, 1678 struct timeval *vblank_time,
1679 unsigned flags, 1679 unsigned flags,
1680 struct drm_crtc *refcrtc); 1680 struct drm_crtc *refcrtc);
1681extern void drm_calc_timestamping_constants(struct drm_crtc *crtc); 1681extern void drm_calc_timestamping_constants(struct drm_crtc *crtc);
1682 1682
1683extern bool 1683extern bool
1684drm_mode_parse_command_line_for_connector(const char *mode_option, 1684drm_mode_parse_command_line_for_connector(const char *mode_option,
1685 struct drm_connector *connector, 1685 struct drm_connector *connector,
1686 struct drm_cmdline_mode *mode); 1686 struct drm_cmdline_mode *mode);
1687 1687
1688extern struct drm_display_mode * 1688extern struct drm_display_mode *
1689drm_mode_create_from_cmdline_mode(struct drm_device *dev, 1689drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1690 struct drm_cmdline_mode *cmd); 1690 struct drm_cmdline_mode *cmd);
1691 1691
1692/* Modesetting support */ 1692/* Modesetting support */
1693extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); 1693extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1694extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); 1694extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1695extern int drm_modeset_ctl(struct drm_device *dev, void *data, 1695extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1696 struct drm_file *file_priv); 1696 struct drm_file *file_priv);
1697 1697
1698 /* AGP/GART support (drm_agpsupport.h) */ 1698 /* AGP/GART support (drm_agpsupport.h) */
1699extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); 1699extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
1700extern int drm_agp_acquire(struct drm_device *dev); 1700extern int drm_agp_acquire(struct drm_device *dev);
1701extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, 1701extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
1702 struct drm_file *file_priv); 1702 struct drm_file *file_priv);
1703extern int drm_agp_release(struct drm_device *dev); 1703extern int drm_agp_release(struct drm_device *dev);
1704extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, 1704extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
1705 struct drm_file *file_priv); 1705 struct drm_file *file_priv);
1706extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); 1706extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
1707extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, 1707extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
1708 struct drm_file *file_priv); 1708 struct drm_file *file_priv);
1709extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); 1709extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
1710extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, 1710extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
1711 struct drm_file *file_priv); 1711 struct drm_file *file_priv);
1712extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); 1712extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
1713extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, 1713extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
1714 struct drm_file *file_priv); 1714 struct drm_file *file_priv);
1715extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); 1715extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
1716extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, 1716extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
1717 struct drm_file *file_priv); 1717 struct drm_file *file_priv);
1718extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); 1718extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
1719extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, 1719extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
1720 struct drm_file *file_priv); 1720 struct drm_file *file_priv);
1721extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); 1721extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1722extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, 1722extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
1723 struct drm_file *file_priv); 1723 struct drm_file *file_priv);
1724 1724
1725 /* Stub support (drm_stub.h) */ 1725 /* Stub support (drm_stub.h) */
1726extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, 1726extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1727 struct drm_file *file_priv); 1727 struct drm_file *file_priv);
1728extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, 1728extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1729 struct drm_file *file_priv); 1729 struct drm_file *file_priv);
1730struct drm_master *drm_master_create(struct drm_minor *minor); 1730struct drm_master *drm_master_create(struct drm_minor *minor);
1731extern struct drm_master *drm_master_get(struct drm_master *master); 1731extern struct drm_master *drm_master_get(struct drm_master *master);
1732extern void drm_master_put(struct drm_master **master); 1732extern void drm_master_put(struct drm_master **master);
1733 1733
1734extern void drm_put_dev(struct drm_device *dev); 1734extern void drm_put_dev(struct drm_device *dev);
1735extern int drm_put_minor(struct drm_minor **minor); 1735extern int drm_put_minor(struct drm_minor **minor);
1736extern void drm_unplug_dev(struct drm_device *dev); 1736extern void drm_unplug_dev(struct drm_device *dev);
1737extern unsigned int drm_debug; 1737extern unsigned int drm_debug;
1738 1738
1739extern unsigned int drm_vblank_offdelay; 1739extern unsigned int drm_vblank_offdelay;
1740extern unsigned int drm_timestamp_precision; 1740extern unsigned int drm_timestamp_precision;
1741extern unsigned int drm_timestamp_monotonic; 1741extern unsigned int drm_timestamp_monotonic;
1742 1742
1743extern struct class *drm_class; 1743extern struct class *drm_class;
1744extern struct proc_dir_entry *drm_proc_root; 1744extern struct proc_dir_entry *drm_proc_root;
1745extern struct dentry *drm_debugfs_root; 1745extern struct dentry *drm_debugfs_root;
1746 1746
1747extern struct idr drm_minors_idr; 1747extern struct idr drm_minors_idr;
1748 1748
1749extern struct drm_local_map *drm_getsarea(struct drm_device *dev); 1749extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
1750 1750
1751 /* Proc support (drm_proc.h) */ 1751 /* Proc support (drm_proc.h) */
1752extern int drm_proc_init(struct drm_minor *minor, int minor_id, 1752extern int drm_proc_init(struct drm_minor *minor, int minor_id,
1753 struct proc_dir_entry *root); 1753 struct proc_dir_entry *root);
1754extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); 1754extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
1755 1755
1756 /* Debugfs support */ 1756 /* Debugfs support */
1757#if defined(CONFIG_DEBUG_FS) 1757#if defined(CONFIG_DEBUG_FS)
1758extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, 1758extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
1759 struct dentry *root); 1759 struct dentry *root);
1760extern int drm_debugfs_create_files(struct drm_info_list *files, int count, 1760extern int drm_debugfs_create_files(struct drm_info_list *files, int count,
1761 struct dentry *root, struct drm_minor *minor); 1761 struct dentry *root, struct drm_minor *minor);
1762extern int drm_debugfs_remove_files(struct drm_info_list *files, int count, 1762extern int drm_debugfs_remove_files(struct drm_info_list *files, int count,
1763 struct drm_minor *minor); 1763 struct drm_minor *minor);
1764extern int drm_debugfs_cleanup(struct drm_minor *minor); 1764extern int drm_debugfs_cleanup(struct drm_minor *minor);
1765#endif 1765#endif
1766 1766
1767#ifndef __NetBSD__ 1767#ifndef __NetBSD__
1768 /* Info file support */ 1768 /* Info file support */
1769extern int drm_name_info(struct seq_file *m, void *data); 1769extern int drm_name_info(struct seq_file *m, void *data);
1770extern int drm_vm_info(struct seq_file *m, void *data); 1770extern int drm_vm_info(struct seq_file *m, void *data);
1771extern int drm_bufs_info(struct seq_file *m, void *data); 1771extern int drm_bufs_info(struct seq_file *m, void *data);
1772extern int drm_vblank_info(struct seq_file *m, void *data); 1772extern int drm_vblank_info(struct seq_file *m, void *data);
1773extern int drm_clients_info(struct seq_file *m, void* data); 1773extern int drm_clients_info(struct seq_file *m, void* data);
1774extern int drm_gem_name_info(struct seq_file *m, void *data); 1774extern int drm_gem_name_info(struct seq_file *m, void *data);
1775#endif 1775#endif
1776 1776
1777 1777
1778extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, 1778extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
1779 struct drm_file *file_priv, uint32_t handle, uint32_t flags, 1779 struct drm_file *file_priv, uint32_t handle, uint32_t flags,
1780 int *prime_fd); 1780 int *prime_fd);
1781extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, 1781extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
1782 struct drm_file *file_priv, int prime_fd, uint32_t *handle); 1782 struct drm_file *file_priv, int prime_fd, uint32_t *handle);
1783 1783
1784extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, 1784extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
1785 struct drm_file *file_priv); 1785 struct drm_file *file_priv);
1786extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data, 1786extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
1787 struct drm_file *file_priv); 1787 struct drm_file *file_priv);
1788 1788
1789#ifndef __NetBSD__ /* XXX temporary measure 20130212 */ 1789#ifndef __NetBSD__ /* XXX temporary measure 20130212 */
1790extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, 1790extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
1791 dma_addr_t *addrs, int max_pages); 1791 dma_addr_t *addrs, int max_pages);
1792extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); 1792extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages);
1793extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 1793extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
1794#endif 1794#endif
1795 1795
1796 1796
1797#ifndef __NetBSD__ /* XXX drm prime */ 1797#ifndef __NetBSD__ /* XXX drm prime */
1798void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); 1798void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
1799void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); 1799void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
1800int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle); 1800int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
1801int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle); 1801int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle);
1802void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); 1802void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
1803 1803
1804int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj); 1804int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj);
1805int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf, 1805int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf,
1806 struct drm_gem_object **obj); 1806 struct drm_gem_object **obj);
1807#endif 1807#endif
1808 1808
1809#if DRM_DEBUG_CODE 1809#if DRM_DEBUG_CODE
1810#ifndef __NetBSD__ 1810#ifndef __NetBSD__
1811extern int drm_vma_info(struct seq_file *m, void *data); 1811extern int drm_vma_info(struct seq_file *m, void *data);
1812#endif 1812#endif
1813#endif 1813#endif
1814 1814
1815 /* Scatter Gather Support (drm_scatter.h) */ 1815 /* Scatter Gather Support (drm_scatter.h) */
1816extern void drm_sg_cleanup(struct drm_sg_mem * entry); 1816extern void drm_sg_cleanup(struct drm_sg_mem * entry);
1817extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, 1817extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
1818 struct drm_file *file_priv); 1818 struct drm_file *file_priv);
1819extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); 1819extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
1820extern int drm_sg_free(struct drm_device *dev, void *data, 1820extern int drm_sg_free(struct drm_device *dev, void *data,
1821 struct drm_file *file_priv); 1821 struct drm_file *file_priv);
1822 1822
1823 /* ATI PCIGART support (ati_pcigart.h) */ 1823 /* ATI PCIGART support (ati_pcigart.h) */
1824extern int drm_ati_pcigart_init(struct drm_device *dev, 1824extern int drm_ati_pcigart_init(struct drm_device *dev,
1825 struct drm_ati_pcigart_info * gart_info); 1825 struct drm_ati_pcigart_info * gart_info);
1826extern int drm_ati_pcigart_cleanup(struct drm_device *dev, 1826extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
1827 struct drm_ati_pcigart_info * gart_info); 1827 struct drm_ati_pcigart_info * gart_info);
1828 1828
1829extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, 1829extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1830 size_t align); 1830 size_t align);
1831extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); 1831extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1832extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); 1832extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
 1833#ifdef __NetBSD__
 1834extern void drm_pci_attach(device_t, const struct pci_attach_args *,
 1835 struct pci_dev *, struct drm_device *);
 1836extern int drm_pci_detach(struct drm_device *, int);
 1837#endif
1833 1838
1834 /* sysfs support (drm_sysfs.c) */ 1839 /* sysfs support (drm_sysfs.c) */
1835struct drm_sysfs_class; 1840struct drm_sysfs_class;
1836extern struct class *drm_sysfs_create(struct module *owner, char *name); 1841extern struct class *drm_sysfs_create(struct module *owner, char *name);
1837extern void drm_sysfs_destroy(void); 1842extern void drm_sysfs_destroy(void);
1838extern int drm_sysfs_device_add(struct drm_minor *minor); 1843extern int drm_sysfs_device_add(struct drm_minor *minor);
1839extern void drm_sysfs_hotplug_event(struct drm_device *dev); 1844extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1840extern void drm_sysfs_device_remove(struct drm_minor *minor); 1845extern void drm_sysfs_device_remove(struct drm_minor *minor);
1841#ifndef __NetBSD__ 1846#ifndef __NetBSD__
1842extern char *drm_get_connector_status_name(enum drm_connector_status status); 1847extern char *drm_get_connector_status_name(enum drm_connector_status status);
1843#endif 1848#endif
1844extern int drm_sysfs_connector_add(struct drm_connector *connector); 1849extern int drm_sysfs_connector_add(struct drm_connector *connector);
1845extern void drm_sysfs_connector_remove(struct drm_connector *connector); 1850extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1846 1851
1847/* Graphics Execution Manager library functions (drm_gem.c) */ 1852/* Graphics Execution Manager library functions (drm_gem.c) */
1848int drm_gem_init(struct drm_device *dev); 1853int drm_gem_init(struct drm_device *dev);
1849void drm_gem_destroy(struct drm_device *dev); 1854void drm_gem_destroy(struct drm_device *dev);
1850void drm_gem_object_release(struct drm_gem_object *obj); 1855void drm_gem_object_release(struct drm_gem_object *obj);
1851void drm_gem_object_free(struct kref *kref); 1856void drm_gem_object_free(struct kref *kref);
1852struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1857struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1853 size_t size); 1858 size_t size);
1854int drm_gem_object_init(struct drm_device *dev, 1859int drm_gem_object_init(struct drm_device *dev,
1855 struct drm_gem_object *obj, size_t size); 1860 struct drm_gem_object *obj, size_t size);
1856int drm_gem_private_object_init(struct drm_device *dev, 1861int drm_gem_private_object_init(struct drm_device *dev,
1857 struct drm_gem_object *obj, size_t size); 1862 struct drm_gem_object *obj, size_t size);
1858void drm_gem_object_handle_free(struct drm_gem_object *obj); 1863void drm_gem_object_handle_free(struct drm_gem_object *obj);
1859#ifdef __NetBSD__ 1864#ifdef __NetBSD__
1860void drm_gem_pager_reference(struct uvm_object *); 1865void drm_gem_pager_reference(struct uvm_object *);
1861void drm_gem_pager_detach(struct uvm_object *); 1866void drm_gem_pager_detach(struct uvm_object *);
1862int drm_gem_mmap_object(struct drm_device *, off_t *, size_t, 1867int drm_gem_mmap_object(struct drm_device *, off_t *, size_t,
1863 struct uvm_object **); 1868 struct uvm_object **);
1864#else 1869#else
1865void drm_gem_vm_open(struct vm_area_struct *vma); 1870void drm_gem_vm_open(struct vm_area_struct *vma);
1866void drm_gem_vm_close(struct vm_area_struct *vma); 1871void drm_gem_vm_close(struct vm_area_struct *vma);
1867int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 1872int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1868#endif 1873#endif
1869 1874
1870#include <drm/drm_global.h> 1875#include <drm/drm_global.h>
1871 1876
1872static inline void 1877static inline void
1873drm_gem_object_reference(struct drm_gem_object *obj) 1878drm_gem_object_reference(struct drm_gem_object *obj)
1874{ 1879{
1875 kref_get(&obj->refcount); 1880 kref_get(&obj->refcount);
1876} 1881}
1877 1882
1878static inline void 1883static inline void
1879drm_gem_object_unreference(struct drm_gem_object *obj) 1884drm_gem_object_unreference(struct drm_gem_object *obj)
1880{ 1885{
1881 if (obj != NULL) 1886 if (obj != NULL)
1882 kref_put(&obj->refcount, drm_gem_object_free); 1887 kref_put(&obj->refcount, drm_gem_object_free);
1883} 1888}
1884 1889
1885static inline void 1890static inline void
1886drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) 1891drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1887{ 1892{
1888 if (obj != NULL) { 1893 if (obj != NULL) {
1889 struct drm_device *dev = obj->dev; 1894 struct drm_device *dev = obj->dev;
1890 mutex_lock(&dev->struct_mutex); 1895 mutex_lock(&dev->struct_mutex);
1891 kref_put(&obj->refcount, drm_gem_object_free); 1896 kref_put(&obj->refcount, drm_gem_object_free);
1892 mutex_unlock(&dev->struct_mutex); 1897 mutex_unlock(&dev->struct_mutex);
1893 } 1898 }
1894} 1899}
1895 1900
1896int drm_gem_handle_create(struct drm_file *file_priv, 1901int drm_gem_handle_create(struct drm_file *file_priv,
1897 struct drm_gem_object *obj, 1902 struct drm_gem_object *obj,
1898 u32 *handlep); 1903 u32 *handlep);
1899int drm_gem_handle_delete(struct drm_file *filp, u32 handle); 1904int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1900 1905
1901static inline void 1906static inline void
1902drm_gem_object_handle_reference(struct drm_gem_object *obj) 1907drm_gem_object_handle_reference(struct drm_gem_object *obj)
1903{ 1908{
1904 drm_gem_object_reference(obj); 1909 drm_gem_object_reference(obj);
1905 atomic_inc(&obj->handle_count); 1910 atomic_inc(&obj->handle_count);
1906} 1911}
1907 1912
1908static inline void 1913static inline void
1909drm_gem_object_handle_unreference(struct drm_gem_object *obj) 1914drm_gem_object_handle_unreference(struct drm_gem_object *obj)
1910{ 1915{
1911 if (obj == NULL) 1916 if (obj == NULL)
1912 return; 1917 return;
1913 1918
1914 if (atomic_read(&obj->handle_count) == 0) 1919 if (atomic_read(&obj->handle_count) == 0)
1915 return; 1920 return;
1916 /* 1921 /*
1917 * Must bump handle count first as this may be the last 1922 * Must bump handle count first as this may be the last
1918 * ref, in which case the object would disappear before we 1923 * ref, in which case the object would disappear before we
1919 * checked for a name 1924 * checked for a name
1920 */ 1925 */
1921 if (atomic_dec_and_test(&obj->handle_count)) 1926 if (atomic_dec_and_test(&obj->handle_count))
1922 drm_gem_object_handle_free(obj); 1927 drm_gem_object_handle_free(obj);
1923 drm_gem_object_unreference(obj); 1928 drm_gem_object_unreference(obj);
1924} 1929}
1925 1930
1926static inline void 1931static inline void
1927drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) 1932drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
1928{ 1933{
1929 if (obj == NULL) 1934 if (obj == NULL)
1930 return; 1935 return;
1931 1936
1932 if (atomic_read(&obj->handle_count) == 0) 1937 if (atomic_read(&obj->handle_count) == 0)
1933 return; 1938 return;
1934 1939
1935 /* 1940 /*
1936 * Must bump handle count first as this may be the last 1941 * Must bump handle count first as this may be the last
1937 * ref, in which case the object would disappear before we 1942 * ref, in which case the object would disappear before we
1938 * checked for a name 1943 * checked for a name
1939 */ 1944 */
1940 1945
1941 if (atomic_dec_and_test(&obj->handle_count)) 1946 if (atomic_dec_and_test(&obj->handle_count))
1942 drm_gem_object_handle_free(obj); 1947 drm_gem_object_handle_free(obj);
1943 drm_gem_object_unreference_unlocked(obj); 1948 drm_gem_object_unreference_unlocked(obj);
1944} 1949}
1945 1950
1946void drm_gem_free_mmap_offset(struct drm_gem_object *obj); 1951void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1947int drm_gem_create_mmap_offset(struct drm_gem_object *obj); 1952int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1948 1953
1949struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, 1954struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1950 struct drm_file *filp, 1955 struct drm_file *filp,
1951 u32 handle); 1956 u32 handle);
1952int drm_gem_close_ioctl(struct drm_device *dev, void *data, 1957int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1953 struct drm_file *file_priv); 1958 struct drm_file *file_priv);
1954int drm_gem_flink_ioctl(struct drm_device *dev, void *data, 1959int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1955 struct drm_file *file_priv); 1960 struct drm_file *file_priv);
1956int drm_gem_open_ioctl(struct drm_device *dev, void *data, 1961int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1957 struct drm_file *file_priv); 1962 struct drm_file *file_priv);
1958void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); 1963void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1959void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); 1964void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1960 1965
1961extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); 1966extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
1962extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); 1967extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
1963extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); 1968extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
1964 1969
1965static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, 1970static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1966 unsigned int token) 1971 unsigned int token)
1967{ 1972{
1968 struct drm_map_list *_entry; 1973 struct drm_map_list *_entry;
1969 list_for_each_entry(_entry, &dev->maplist, head) 1974 list_for_each_entry(_entry, &dev->maplist, head)
1970 if (_entry->user_token == token) 1975 if (_entry->user_token == token)
1971 return _entry->map; 1976 return _entry->map;
1972 return NULL; 1977 return NULL;
1973} 1978}
1974 1979
1975static __inline__ void drm_core_dropmap(struct drm_local_map *map) 1980static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1976{ 1981{
1977} 1982}
1978 1983
1979#include <drm/drm_mem_util.h> 1984#include <drm/drm_mem_util.h>
1980 1985
1981extern int drm_fill_in_dev(struct drm_device *dev, 1986extern int drm_fill_in_dev(struct drm_device *dev,
1982 const struct pci_device_id *ent, 1987 const struct pci_device_id *ent,
1983 struct drm_driver *driver); 1988 struct drm_driver *driver);
1984int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); 1989int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1985/*@}*/ 1990/*@}*/
1986 1991
1987/* PCI section */ 1992/* PCI section */
1988static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) 1993static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
1989{ 1994{
1990 if (dev->driver->device_is_agp != NULL) { 1995 if (dev->driver->device_is_agp != NULL) {
1991 int err = (*dev->driver->device_is_agp) (dev); 1996 int err = (*dev->driver->device_is_agp) (dev);
1992 1997
1993 if (err != 2) { 1998 if (err != 2) {
1994 return err; 1999 return err;
1995 } 2000 }
1996 } 2001 }
1997 2002
1998 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); 2003 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1999} 2004}
2000 2005
2001extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); 2006extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
2002extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); 2007extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
2003extern int drm_get_pci_dev(struct pci_dev *pdev, 2008extern int drm_get_pci_dev(struct pci_dev *pdev,
2004 const struct pci_device_id *ent, 2009 const struct pci_device_id *ent,
2005 struct drm_driver *driver); 2010 struct drm_driver *driver);
2006 2011
2007#define DRM_PCIE_SPEED_25 1 2012#define DRM_PCIE_SPEED_25 1
2008#define DRM_PCIE_SPEED_50 2 2013#define DRM_PCIE_SPEED_50 2
2009#define DRM_PCIE_SPEED_80 4 2014#define DRM_PCIE_SPEED_80 4
2010 2015
2011extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); 2016extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
2012 2017
2013/* platform section */ 2018/* platform section */
2014extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); 2019extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
2015extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); 2020extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device);
2016 2021
2017extern int drm_get_platform_dev(struct platform_device *pdev, 2022extern int drm_get_platform_dev(struct platform_device *pdev,
2018 struct drm_driver *driver); 2023 struct drm_driver *driver);
2019 2024
2020/* returns true if currently okay to sleep */ 2025/* returns true if currently okay to sleep */
2021static __inline__ bool drm_can_sleep(void) 2026static __inline__ bool drm_can_sleep(void)
2022{ 2027{
2023#ifdef __NetBSD__ 2028#ifdef __NetBSD__
2024 return false; /* XXX */ 2029 return false; /* XXX */
2025#else 2030#else
2026 if (in_atomic() || in_dbg_master() || irqs_disabled()) 2031 if (in_atomic() || in_dbg_master() || irqs_disabled())
2027 return false; 2032 return false;
2028 return true; 2033 return true;
2029#endif 2034#endif
2030} 2035}
2031 2036
2032#ifdef __NetBSD__ 2037#ifdef __NetBSD__
2033static inline bool 2038static inline bool
2034DRM_IS_BUS_SPACE(struct drm_local_map *map) 2039DRM_IS_BUS_SPACE(struct drm_local_map *map)
2035{ 2040{
2036 switch (map->type) { 2041 switch (map->type) {
2037 case _DRM_FRAME_BUFFER: 2042 case _DRM_FRAME_BUFFER:
2038 panic("I don't know how to access drm frame buffer memory!"); 2043 panic("I don't know how to access drm frame buffer memory!");
2039 2044
2040 case _DRM_REGISTERS: 2045 case _DRM_REGISTERS:
2041 return true; 2046 return true;
2042 2047
2043 case _DRM_SHM: 2048 case _DRM_SHM:
2044 panic("I don't know how to access drm shared memory!"); 2049 panic("I don't know how to access drm shared memory!");
2045 2050
2046 case _DRM_AGP: 2051 case _DRM_AGP:
2047 panic("I don't know how to access drm agp memory!"); 2052 panic("I don't know how to access drm agp memory!");
2048 2053
2049 case _DRM_SCATTER_GATHER: 2054 case _DRM_SCATTER_GATHER:
2050 panic("I don't know how to access drm scatter-gather memory!"); 2055 panic("I don't know how to access drm scatter-gather memory!");
2051 2056
2052 case _DRM_CONSISTENT: 2057 case _DRM_CONSISTENT:
2053 /* 2058 /*
2054 * XXX Old drm uses bus space access for this, but 2059 * XXX Old drm uses bus space access for this, but
2055 * consistent maps don't have bus space handles! They 2060 * consistent maps don't have bus space handles! They
2056 * do, however, have kernel virtual addresses in the 2061 * do, however, have kernel virtual addresses in the
2057 * map->handle, so maybe that's right. 2062 * map->handle, so maybe that's right.
2058 */ 2063 */
2059#if 0 2064#if 0
2060 return false; 2065 return false;
2061#endif 2066#endif
2062 panic("I don't know how to access drm consistent memory!"); 2067 panic("I don't know how to access drm consistent memory!");
2063 2068
2064 case _DRM_GEM: 2069 case _DRM_GEM:
2065 panic("I don't know how to access drm gem memory!"); 2070 panic("I don't know how to access drm gem memory!");
2066 2071
2067 default: 2072 default:
2068 panic("I don't know what kind of memory you mean!"); 2073 panic("I don't know what kind of memory you mean!");
2069 } 2074 }
2070} 2075}
2071 2076
2072static inline uint8_t 2077static inline uint8_t
2073DRM_READ8(struct drm_local_map *map, bus_size_t offset) 2078DRM_READ8(struct drm_local_map *map, bus_size_t offset)
2074{ 2079{
2075 if (DRM_IS_BUS_SPACE(map)) 2080 if (DRM_IS_BUS_SPACE(map))
2076 return bus_space_read_1(map->lm_data.bus_space.bst, 2081 return bus_space_read_1(map->lm_data.bus_space.bst,
2077 map->lm_data.bus_space.bsh, offset); 2082 map->lm_data.bus_space.bsh, offset);
2078 else 2083 else
2079 return *(volatile uint8_t *)((vaddr_t)map->handle + offset); 2084 return *(volatile uint8_t *)((vaddr_t)map->handle + offset);
2080} 2085}
2081 2086
2082static inline uint16_t 2087static inline uint16_t
2083DRM_READ16(struct drm_local_map *map, bus_size_t offset) 2088DRM_READ16(struct drm_local_map *map, bus_size_t offset)
2084{ 2089{
2085 if (DRM_IS_BUS_SPACE(map)) 2090 if (DRM_IS_BUS_SPACE(map))
2086 return bus_space_read_2(map->lm_data.bus_space.bst, 2091 return bus_space_read_2(map->lm_data.bus_space.bst,
2087 map->lm_data.bus_space.bsh, offset); 2092 map->lm_data.bus_space.bsh, offset);
2088 else 2093 else
2089 return *(volatile uint16_t *)((vaddr_t)map->handle + offset); 2094 return *(volatile uint16_t *)((vaddr_t)map->handle + offset);
2090} 2095}
2091 2096
2092static inline uint32_t 2097static inline uint32_t
2093DRM_READ32(struct drm_local_map *map, bus_size_t offset) 2098DRM_READ32(struct drm_local_map *map, bus_size_t offset)
2094{ 2099{
2095 if (DRM_IS_BUS_SPACE(map)) 2100 if (DRM_IS_BUS_SPACE(map))
2096 return bus_space_read_4(map->lm_data.bus_space.bst, 2101 return bus_space_read_4(map->lm_data.bus_space.bst,
2097 map->lm_data.bus_space.bsh, offset); 2102 map->lm_data.bus_space.bsh, offset);
2098 else 2103 else
2099 return *(volatile uint32_t *)((vaddr_t)map->handle + offset); 2104 return *(volatile uint32_t *)((vaddr_t)map->handle + offset);
2100} 2105}
2101 2106
2102static inline uint64_t 2107static inline uint64_t
2103DRM_READ64(struct drm_local_map *map, bus_size_t offset) 2108DRM_READ64(struct drm_local_map *map, bus_size_t offset)
2104{ 2109{
2105 if (DRM_IS_BUS_SPACE(map)) 2110 if (DRM_IS_BUS_SPACE(map))
2106 return bus_space_read_8(map->lm_data.bus_space.bst, 2111 return bus_space_read_8(map->lm_data.bus_space.bst,
2107 map->lm_data.bus_space.bsh, offset); 2112 map->lm_data.bus_space.bsh, offset);
2108 else 2113 else
2109 return *(volatile uint64_t *)((vaddr_t)map->handle + offset); 2114 return *(volatile uint64_t *)((vaddr_t)map->handle + offset);
2110} 2115}
2111 2116
2112static inline void 2117static inline void
2113DRM_WRITE8(struct drm_local_map *map, bus_size_t offset, uint8_t value) 2118DRM_WRITE8(struct drm_local_map *map, bus_size_t offset, uint8_t value)
2114{ 2119{
2115 if (DRM_IS_BUS_SPACE(map)) 2120 if (DRM_IS_BUS_SPACE(map))
2116 bus_space_write_1(map->lm_data.bus_space.bst, 2121 bus_space_write_1(map->lm_data.bus_space.bst,
2117 map->lm_data.bus_space.bsh, offset, value); 2122 map->lm_data.bus_space.bsh, offset, value);
2118 else 2123 else
2119 *(volatile uint8_t *)((vaddr_t)map->handle + offset) = value; 2124 *(volatile uint8_t *)((vaddr_t)map->handle + offset) = value;
2120} 2125}
2121 2126
2122static inline void 2127static inline void
2123DRM_WRITE16(struct drm_local_map *map, bus_size_t offset, uint16_t value) 2128DRM_WRITE16(struct drm_local_map *map, bus_size_t offset, uint16_t value)
2124{ 2129{
2125 if (DRM_IS_BUS_SPACE(map)) 2130 if (DRM_IS_BUS_SPACE(map))
2126 bus_space_write_2(map->lm_data.bus_space.bst, 2131 bus_space_write_2(map->lm_data.bus_space.bst,
2127 map->lm_data.bus_space.bsh, offset, value); 2132 map->lm_data.bus_space.bsh, offset, value);
2128 else 2133 else
2129 *(volatile uint16_t *)((vaddr_t)map->handle + offset) = value; 2134 *(volatile uint16_t *)((vaddr_t)map->handle + offset) = value;
2130} 2135}
2131 2136
2132static inline void 2137static inline void
2133DRM_WRITE32(struct drm_local_map *map, bus_size_t offset, uint32_t value) 2138DRM_WRITE32(struct drm_local_map *map, bus_size_t offset, uint32_t value)
2134{ 2139{
2135 if (DRM_IS_BUS_SPACE(map)) 2140 if (DRM_IS_BUS_SPACE(map))
2136 bus_space_write_4(map->lm_data.bus_space.bst, 2141 bus_space_write_4(map->lm_data.bus_space.bst,
2137 map->lm_data.bus_space.bsh, offset, value); 2142 map->lm_data.bus_space.bsh, offset, value);
2138 else 2143 else
2139 *(volatile uint32_t *)((vaddr_t)map->handle + offset) = value; 2144 *(volatile uint32_t *)((vaddr_t)map->handle + offset) = value;
2140} 2145}
2141 2146
2142static inline void 2147static inline void
2143DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value) 2148DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value)
2144{ 2149{
2145 if (DRM_IS_BUS_SPACE(map)) 2150 if (DRM_IS_BUS_SPACE(map))
2146 bus_space_write_8(map->lm_data.bus_space.bst, 2151 bus_space_write_8(map->lm_data.bus_space.bst,
2147 map->lm_data.bus_space.bsh, offset, value); 2152 map->lm_data.bus_space.bsh, offset, value);
2148 else 2153 else
2149 *(volatile uint64_t *)((vaddr_t)map->handle + offset) = value; 2154 *(volatile uint64_t *)((vaddr_t)map->handle + offset) = value;
2150} 2155}
2151#endif /* defined(__NetBSD__) */ 2156#endif /* defined(__NetBSD__) */
2152 2157
2153#ifdef __NetBSD__ 2158#ifdef __NetBSD__
2154 2159
2155/* XXX This is pretty kludgerific. */ 2160/* XXX This is pretty kludgerific. */
2156 2161
2157#include <linux/io-mapping.h> 2162#include <linux/io-mapping.h>
2158 2163
2159static inline struct io_mapping * 2164static inline struct io_mapping *
2160drm_io_mapping_create_wc(struct drm_device *dev, resource_size_t addr, 2165drm_io_mapping_create_wc(struct drm_device *dev, resource_size_t addr,
2161 unsigned long size) 2166 unsigned long size)
2162{ 2167{
2163 return bus_space_io_mapping_create_wc(dev->bst, addr, size); 2168 return bus_space_io_mapping_create_wc(dev->bst, addr, size);
2164} 2169}
2165 2170
2166#endif /* defined(__NetBSD__) */ 2171#endif /* defined(__NetBSD__) */
2167 2172
2168#endif /* __KERNEL__ */ 2173#endif /* __KERNEL__ */
2169#endif 2174#endif

cvs diff -r1.1.2.12 -r1.1.2.13 src/sys/external/bsd/drm2/include/linux/pci.h (switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:20:05 1.1.2.12
+++ src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:24:03 1.1.2.13
@@ -1,272 +1,332 @@ @@ -1,272 +1,332 @@
1/* $NetBSD: pci.h,v 1.1.2.12 2013/07/24 03:20:05 riastradh Exp $ */ 1/* $NetBSD: pci.h,v 1.1.2.13 2013/07/24 03:24:03 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _LINUX_PCI_H_ 32#ifndef _LINUX_PCI_H_
33#define _LINUX_PCI_H_ 33#define _LINUX_PCI_H_
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/bus.h> 36#include <sys/bus.h>
37#include <sys/kmem.h> 37#include <sys/kmem.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39 39
40#include <dev/pci/pcidevs.h> 40#include <dev/pci/pcidevs.h>
41#include <dev/pci/pcireg.h> 41#include <dev/pci/pcireg.h>
42#include <dev/pci/pcivar.h> 42#include <dev/pci/pcivar.h>
43 43
44#include <linux/ioport.h> 44#include <linux/ioport.h>
45 45
46struct pci_bus; 46struct pci_bus;
47 47
48struct pci_device_id { 48struct pci_device_id {
49 uint32_t vendor; 49 uint32_t vendor;
50 uint32_t device; 50 uint32_t device;
51 uint32_t subvendor; 51 uint32_t subvendor;
52 uint32_t subdevice; 52 uint32_t subdevice;
53 uint32_t class; 53 uint32_t class;
54 uint32_t class_mask; 54 uint32_t class_mask;
55 unsigned long driver_data; 55 unsigned long driver_data;
56}; 56};
57 57
58#define PCI_ANY_ID ((pcireg_t)-1) 58#define PCI_ANY_ID ((pcireg_t)-1)
59 59
60#define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY 60#define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY
61 61
62#define PCI_CLASS_BRIDGE_ISA PCI_SUBCLASS_BRIDGE_ISA 62#define PCI_CLASS_BRIDGE_ISA \
 63 ((PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_ISA)
 64CTASSERT(PCI_CLASS_BRIDGE_ISA == 0x0601);
63 65
64#define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL 66#define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL
65 67
 68#define PCI_DEVFN(DEV, FN) \
 69 (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2)))
 70#define PCI_SLOT(DEVFN) __SHIFTOUT((DEVFN), __BITS(3, 7))
 71#define PCI_FUNC(DEVFN) __SHIFTOUT((DEVFN), __BITS(0, 2))
 72
 73#define PCI_CAP_ID_AGP PCI_CAP_AGP
 74
66struct pci_dev { 75struct pci_dev {
67 struct pci_attach_args pd_pa; 76 struct pci_attach_args pd_pa;
68 bool pd_kludged; /* XXX pci_kludgey_find_dev */ 77 bool pd_kludged; /* XXX pci_kludgey_find_dev */
69 device_t pd_dev; 78 device_t pd_dev;
70 struct pci_bus *bus; 79 struct pci_bus *bus;
71 uint32_t devfn; 80 uint32_t devfn;
72 uint16_t vendor; 81 uint16_t vendor;
73 uint16_t device; 82 uint16_t device;
74 uint16_t subsystem_vendor; 83 uint16_t subsystem_vendor;
75 uint16_t subsystem_device; 84 uint16_t subsystem_device;
76 uint8_t revision; 85 uint8_t revision;
77 uint32_t class; 86 uint32_t class;
78 bool msi_enabled; 87 bool msi_enabled;
79}; 88};
80 89
81static inline device_t 90static inline device_t
82pci_dev_dev(struct pci_dev *pdev) 91pci_dev_dev(struct pci_dev *pdev)
83{ 92{
84 return pdev->pd_dev; 93 return pdev->pd_dev;
85} 94}
86 95
87#define PCI_DEVFN(DEV, FN) \ 96static inline void
88 (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2))) 97linux_pci_dev_init(struct pci_dev *pdev, device_t dev,
89#define PCI_SLOT(DEVFN) __SHIFTOUT((DEVFN), __BITS(3, 7)) 98 const struct pci_attach_args *pa, bool kludged)
90#define PCI_FUNC(DEVFN) __SHIFTOUT((DEVFN), __BITS(0, 2)) 99{
 100 const uint32_t subsystem_id = pci_conf_read(pa->pa_pc, pa->pa_tag,
 101 PCI_SUBSYS_ID_REG);
91 102
92#define PCI_CAP_ID_AGP PCI_CAP_AGP 103 pdev->pd_pa = *pa;
 104 pdev->pd_kludged = kludged;
 105 pdev->pd_dev = dev;
 106 pdev->bus = NULL; /* XXX struct pci_dev::bus */
 107 pdev->devfn = PCI_DEVFN(pa->pa_device, pa->pa_function);
 108 pdev->vendor = PCI_VENDOR(pa->pa_id);
 109 pdev->device = PCI_PRODUCT(pa->pa_id);
 110 pdev->subsystem_vendor = PCI_SUBSYS_VENDOR(subsystem_id);
 111 pdev->subsystem_device = PCI_SUBSYS_ID(subsystem_id);
 112 pdev->revision = PCI_REVISION(pa->pa_class);
 113 pdev->class = __SHIFTOUT(pa->pa_class, 0xffffff00UL); /* ? */
 114 pdev->msi_enabled = false;
 115}
93 116
94static inline int 117static inline int
95pci_find_capability(struct pci_dev *pdev, int cap) 118pci_find_capability(struct pci_dev *pdev, int cap)
96{ 119{
97 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap, 120 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap,
98 NULL, NULL); 121 NULL, NULL);
99} 122}
100 123
101static inline void 124static inline void
102pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep) 125pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep)
103{ 126{
104 KASSERT(!ISSET(reg, 3)); 127 KASSERT(!ISSET(reg, 3));
105 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg); 128 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg);
106} 129}
107 130
108static inline void 131static inline void
109pci_read_config_word(struct pci_dev *pdev, int reg, uint16_t *valuep) 132pci_read_config_word(struct pci_dev *pdev, int reg, uint16_t *valuep)
110{ 133{
111 KASSERT(!ISSET(reg, 1)); 134 KASSERT(!ISSET(reg, 1));
112 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, 135 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
113 (reg &~ 3)) >> (8 * (reg & 3)); 136 (reg &~ 3)) >> (8 * (reg & 3));
114} 137}
115 138
116static inline void 139static inline void
117pci_read_config_byte(struct pci_dev *pdev, int reg, uint8_t *valuep) 140pci_read_config_byte(struct pci_dev *pdev, int reg, uint8_t *valuep)
118{ 141{
119 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, 142 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
120 (reg &~ 1)) >> (8 * (reg & 1)); 143 (reg &~ 1)) >> (8 * (reg & 1));
121} 144}
122 145
123static inline void 146static inline void
124pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value) 147pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value)
125{ 148{
126 KASSERT(!ISSET(reg, 3)); 149 KASSERT(!ISSET(reg, 3));
127 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value); 150 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value);
128} 151}
129 152
130static inline void 153static inline void
131pci_rmw_config(struct pci_dev *pdev, int reg, unsigned int bytes, 154pci_rmw_config(struct pci_dev *pdev, int reg, unsigned int bytes,
132 uint32_t value) 155 uint32_t value)
133{ 156{
134 const uint32_t mask = ~((~0UL) << (8 * bytes)); 157 const uint32_t mask = ~((~0UL) << (8 * bytes));
135 const int reg32 = (reg &~ 3); 158 const int reg32 = (reg &~ 3);
136 const unsigned int shift = (8 * (reg & 3)); 159 const unsigned int shift = (8 * (reg & 3));
137 uint32_t value32; 160 uint32_t value32;
138 161
139 KASSERT(bytes <= 4); 162 KASSERT(bytes <= 4);
140 KASSERT(!ISSET(value, ~mask)); 163 KASSERT(!ISSET(value, ~mask));
141 pci_read_config_dword(pdev, reg32, &value32); 164 pci_read_config_dword(pdev, reg32, &value32);
142 value32 &=~ (mask << shift); 165 value32 &=~ (mask << shift);
143 value32 |= (value << shift); 166 value32 |= (value << shift);
144 pci_write_config_dword(pdev, reg32, value32); 167 pci_write_config_dword(pdev, reg32, value32);
145} 168}
146 169
147static inline void 170static inline void
148pci_write_config_word(struct pci_dev *pdev, int reg, uint16_t value) 171pci_write_config_word(struct pci_dev *pdev, int reg, uint16_t value)
149{ 172{
150 KASSERT(!ISSET(reg, 1)); 173 KASSERT(!ISSET(reg, 1));
151 pci_rmw_config(pdev, reg, 2, value); 174 pci_rmw_config(pdev, reg, 2, value);
152} 175}
153 176
154static inline void 177static inline void
155pci_write_config_byte(struct pci_dev *pdev, int reg, uint8_t value) 178pci_write_config_byte(struct pci_dev *pdev, int reg, uint8_t value)
156{ 179{
157 pci_rmw_config(pdev, reg, 1, value); 180 pci_rmw_config(pdev, reg, 1, value);
158} 181}
159 182
160/* 183/*
161 * XXX pci msi 184 * XXX pci msi
162 */ 185 */
163static inline void 186static inline void
164pci_enable_msi(struct pci_dev *pdev) 187pci_enable_msi(struct pci_dev *pdev)
165{ 188{
166 KASSERT(!pdev->msi_enabled); 189 KASSERT(!pdev->msi_enabled);
167 pdev->msi_enabled = true; 190 pdev->msi_enabled = true;
168} 191}
169 192
170static inline void 193static inline void
171pci_disable_msi(struct pci_dev *pdev) 194pci_disable_msi(struct pci_dev *pdev)
172{ 195{
173 KASSERT(pdev->msi_enabled); 196 KASSERT(pdev->msi_enabled);
174 pdev->msi_enabled = false; 197 pdev->msi_enabled = false;
175} 198}
176 199
177static inline void 200static inline void
178pci_set_master(struct pci_dev *pdev) 201pci_set_master(struct pci_dev *pdev)
179{ 202{
180 pcireg_t csr; 203 pcireg_t csr;
181 204
182 csr = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, 205 csr = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
183 PCI_COMMAND_STATUS_REG); 206 PCI_COMMAND_STATUS_REG);
184 csr |= PCI_COMMAND_MASTER_ENABLE; 207 csr |= PCI_COMMAND_MASTER_ENABLE;
185 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, 208 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
186 PCI_COMMAND_STATUS_REG, csr); 209 PCI_COMMAND_STATUS_REG, csr);
187} 210}
188 211
189#define PCIBIOS_MIN_MEM 0 /* XXX bogus x86 kludge bollocks */ 212#define PCIBIOS_MIN_MEM 0 /* XXX bogus x86 kludge bollocks */
190 213
191static inline bus_addr_t 214static inline bus_addr_t
192pcibios_align_resource(void *p, const struct resource *resource, 215pcibios_align_resource(void *p, const struct resource *resource,
193 bus_addr_t addr, bus_size_t size) 216 bus_addr_t addr, bus_size_t size)
194{ 217{
195 panic("pcibios_align_resource has accessed unaligned neurons!"); 218 panic("pcibios_align_resource has accessed unaligned neurons!");
196} 219}
197 220
198static inline int 221static inline int
199pci_bus_alloc_resource(struct pci_bus *bus, struct resource *resource, 222pci_bus_alloc_resource(struct pci_bus *bus, struct resource *resource,
200 bus_size_t size, bus_size_t align, bus_addr_t start, int type __unused, 223 bus_size_t size, bus_size_t align, bus_addr_t start, int type __unused,
201 bus_addr_t (*align_fn)(void *, const struct resource *, bus_addr_t, 224 bus_addr_t (*align_fn)(void *, const struct resource *, bus_addr_t,
202 bus_size_t) __unused, 225 bus_size_t) __unused,
203 struct pci_dev *pdev) 226 struct pci_dev *pdev)
204{ 227{
205 const struct pci_attach_args *const pa = &pdev->pd_pa; 228 const struct pci_attach_args *const pa = &pdev->pd_pa;
206 bus_space_tag_t bst; 229 bus_space_tag_t bst;
207 int error; 230 int error;
208 231
209 switch (resource->flags) { 232 switch (resource->flags) {
210 case IORESOURCE_MEM: 233 case IORESOURCE_MEM:
211 bst = pa->pa_memt; 234 bst = pa->pa_memt;
212 break; 235 break;
213 236
214 case IORESOURCE_IO: 237 case IORESOURCE_IO:
215 bst = pa->pa_iot; 238 bst = pa->pa_iot;
216 break; 239 break;
217 240
218 default: 241 default:
219 panic("I don't know what kind of resource you want!"); 242 panic("I don't know what kind of resource you want!");
220 } 243 }
221 244
222 resource->r_bst = bst; 245 resource->r_bst = bst;
223 error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */, 246 error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */,
224 size, align, 0, 0, &resource->start, &resource->r_bsh); 247 size, align, 0, 0, &resource->start, &resource->r_bsh);
225 if (error) 248 if (error)
226 return error; 249 return error;
227 250
228 resource->size = size; 251 resource->size = size;
229 return 0; 252 return 0;
230} 253}
231 254
232/* 255/*
233 * XXX Mega-kludgerific! 256 * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are
234 * 257 * defined only for their single purposes in i915drm, in
235 * XXX Doesn't check whether any such device actually exists. 258 * i915_get_bridge_dev and intel_detect_pch. We can't define them more
 259 * generally without adapting pci_find_device (and pci_enumerate_bus
 260 * internally) to pass a cookie through.
236 */ 261 */
237 262
 263static inline int /* XXX inline? */
 264pci_kludgey_match_bus0_dev0_func0(const struct pci_attach_args *pa)
 265{
 266
 267 if (pa->pa_bus != 0)
 268 return 0;
 269 if (pa->pa_device != 0)
 270 return 0;
 271 if (pa->pa_function != 0)
 272 return 0;
 273
 274 return 1;
 275}
 276
238static inline struct pci_dev * 277static inline struct pci_dev *
239pci_kludgey_find_dev(struct pci_dev *pdev, int bus, int dev, int func) 278pci_get_bus_and_slot(int bus, int slot)
240{ 279{
241 struct pci_dev *const otherdev = kmem_zalloc(sizeof(*otherdev), 280 struct pci_attach_args pa;
242 KM_SLEEP); 
243 281
244#ifdef DIAGNOSTIC 282 KASSERT(bus == 0);
245 { 283 KASSERT(slot == PCI_DEVFN(0, 0));
246 int obus, odev, ofunc; 284
247 285 if (!pci_find_device(&pa, &pci_kludgey_match_bus0_dev0_func0))
248 pci_decompose_tag(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, &obus, 286 return NULL;
249 &odev, &ofunc); 287
250 KASSERT(obus == bus); 288 struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP);
251 } 289 linux_pci_dev_init(pdev, NULL, &pa, true);
252#endif 290
 291 return pdev;
 292}
 293
 294static inline int /* XXX inline? */
 295pci_kludgey_match_isa_bridge(const struct pci_attach_args *pa)
 296{
 297
 298 if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE)
 299 return 0;
 300 if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
 301 return 0;
 302
 303 return 1;
 304}
 305
 306static inline struct pci_dev *
 307pci_get_class(uint32_t class_subclass_shifted __unused,
 308 struct pci_dev *from __unused)
 309{
 310 struct pci_attach_args pa;
 311
 312 KASSERT(class_subclass_shifted == (PCI_CLASS_BRIDGE_ISA << 8));
 313 KASSERT(from == NULL);
 314
 315 if (!pci_find_device(&pa, &pci_kludgey_match_isa_bridge))
 316 return NULL;
253 317
254 otherdev->bus = NULL; /* XXX struct pci_dev::bus */ 318 struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP);
255 otherdev->device = dev; 319 linux_pci_dev_init(pdev, NULL, &pa, true);
256 otherdev->pd_pa = pdev->pd_pa; 
257 otherdev->pd_pa.pa_tag = pci_make_tag(otherdev->pd_pa.pa_pc, 
258 bus, dev, func); 
259 otherdev->pd_kludged = true; 
260 320
261 return otherdev; 321 return pdev;
262} 322}
263 323
264static inline void 324static inline void
265pci_dev_put(struct pci_dev *pdev) 325pci_dev_put(struct pci_dev *pdev)
266{ 326{
267 327
268 KASSERT(pdev->pd_kludged); 328 KASSERT(pdev->pd_kludged);
269 kmem_free(pdev, sizeof(*pdev)); 329 kmem_free(pdev, sizeof(*pdev));
270} 330}
271 331
272#endif /* _LINUX_PCI_H_ */ 332#endif /* _LINUX_PCI_H_ */

cvs diff -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/pci/drm_pci.c (switch to unified diff)

--- src/sys/external/bsd/drm2/pci/drm_pci.c 2013/07/24 02:35:07 1.1.2.1
+++ src/sys/external/bsd/drm2/pci/drm_pci.c 2013/07/24 03:24:03 1.1.2.2
@@ -1,162 +1,184 @@ @@ -1,162 +1,184 @@
1/* $NetBSD: drm_pci.c,v 1.1.2.1 2013/07/24 02:35:07 riastradh Exp $ */ 1/* $NetBSD: drm_pci.c,v 1.1.2.2 2013/07/24 03:24:03 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.1.2.1 2013/07/24 02:35:07 riastradh Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.1.2.2 2013/07/24 03:24:03 riastradh Exp $");
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/errno.h> 36#include <sys/errno.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38 38
39#include <dev/pci/pcivar.h> 39#include <dev/pci/pcivar.h>
40 40
41#include <drm/drmP.h> 41#include <drm/drmP.h>
42 42
43static int drm_pci_get_irq(struct drm_device *); 43static int drm_pci_get_irq(struct drm_device *);
44static int drm_pci_irq_install(struct drm_device *, 44static int drm_pci_irq_install(struct drm_device *,
45 irqreturn_t (*)(void *), int, const char *, void *, 45 irqreturn_t (*)(void *), int, const char *, void *,
46 struct drm_bus_irq_cookie **); 46 struct drm_bus_irq_cookie **);
47static void drm_pci_irq_uninstall(struct drm_device *, 47static void drm_pci_irq_uninstall(struct drm_device *,
48 struct drm_bus_irq_cookie *); 48 struct drm_bus_irq_cookie *);
49static const char * 49static const char *
50 drm_pci_get_name(struct drm_device *); 50 drm_pci_get_name(struct drm_device *);
51static int drm_pci_set_busid(struct drm_device *, struct drm_master *); 51static int drm_pci_set_busid(struct drm_device *, struct drm_master *);
52static int drm_pci_set_unique(struct drm_device *, struct drm_master *, 52static int drm_pci_set_unique(struct drm_device *, struct drm_master *,
53 struct drm_unique *); 53 struct drm_unique *);
54static int drm_pci_irq_by_busid(struct drm_device *, 54static int drm_pci_irq_by_busid(struct drm_device *,
55 struct drm_irq_busid *); 55 struct drm_irq_busid *);
56static int drm_pci_agp_init(struct drm_device *); 56static int drm_pci_agp_init(struct drm_device *);
57 57
58const struct drm_bus drm_pci_bus = { 58const struct drm_bus drm_pci_bus = {
59 .bus_type = DRIVER_BUS_PCI, 59 .bus_type = DRIVER_BUS_PCI,
60 .get_irq = drm_pci_get_irq, 60 .get_irq = drm_pci_get_irq,
61 .irq_install = drm_pci_irq_install, 61 .irq_install = drm_pci_irq_install,
62 .irq_uninstall = drm_pci_irq_uninstall, 62 .irq_uninstall = drm_pci_irq_uninstall,
63 .get_name = drm_pci_get_name, 63 .get_name = drm_pci_get_name,
64 .set_busid = drm_pci_set_busid, 64 .set_busid = drm_pci_set_busid,
65 .set_unique = drm_pci_set_unique, 65 .set_unique = drm_pci_set_unique,
66 .irq_by_busid = drm_pci_irq_by_busid, 66 .irq_by_busid = drm_pci_irq_by_busid,
67 .agp_init = drm_pci_agp_init, 67 .agp_init = drm_pci_agp_init,
68}; 68};
69 69
70static const struct pci_attach_args * 70static const struct pci_attach_args *
71drm_pci_attach_args(struct drm_device *dev) 71drm_pci_attach_args(struct drm_device *dev)
72{ 72{
73 return &dev->pdev->pd_pa; 73 return &dev->pdev->pd_pa;
74} 74}
75 75
 76void
 77drm_pci_attach(device_t self, const struct pci_attach_args *pa,
 78 struct pci_dev *pdev, struct drm_device *dev)
 79{
 80
 81 linux_pci_dev_init(pdev, self, pa, false);
 82
 83 dev->pdev = pdev;
 84 dev->pci_vendor = pdev->vendor;
 85 dev->pci_device = pdev->device;
 86
 87 /* XXX Set the power state to D0? */
 88}
 89
 90int
 91drm_pci_detach(struct drm_device *dev __unused, int flags __unused)
 92{
 93
 94 /* XXX Disestablish irqs or anything? */
 95 return 0;
 96}
 97
76static int 98static int
77drm_pci_get_irq(struct drm_device *dev) 99drm_pci_get_irq(struct drm_device *dev)
78{ 100{
79 pci_intr_handle_t ih_pih; 101 pci_intr_handle_t ih_pih;
80 int ih_int; 102 int ih_int;
81 103
82 /* 104 /*
83 * This is a compile-time assertion that the types match. If 105 * This is a compile-time assertion that the types match. If
84 * this fails, we have to change a bunch of drm code that uses 106 * this fails, we have to change a bunch of drm code that uses
85 * int for intr handles. 107 * int for intr handles.
86 */ 108 */
87 KASSERT(&ih_pih != &ih_int); 109 KASSERT(&ih_pih != &ih_int);
88 110
89 if (pci_intr_map(drm_pci_attach_args(dev), &ih_pih)) 111 if (pci_intr_map(drm_pci_attach_args(dev), &ih_pih))
90 return -1; /* XXX Hope -1 is an invalid intr handle. */ 112 return -1; /* XXX Hope -1 is an invalid intr handle. */
91 113
92 ih_int = ih_pih; 114 ih_int = ih_pih;
93 return ih_int; 115 return ih_int;
94} 116}
95 117
96static int 118static int
97drm_pci_irq_install(struct drm_device *dev, irqreturn_t (*handler)(void *), 119drm_pci_irq_install(struct drm_device *dev, irqreturn_t (*handler)(void *),
98 int flags, const char *name, void *arg, 120 int flags, const char *name, void *arg,
99 struct drm_bus_irq_cookie **cookiep) 121 struct drm_bus_irq_cookie **cookiep)
100{ 122{
101 const struct pci_attach_args *const pa = drm_pci_attach_args(dev); 123 const struct pci_attach_args *const pa = drm_pci_attach_args(dev);
102 pci_intr_handle_t ih; 124 pci_intr_handle_t ih;
103 const char *intrstr; 125 const char *intrstr;
104 void *ih_cookie; 126 void *ih_cookie;
105 127
106 if (pci_intr_map(pa, &ih)) 128 if (pci_intr_map(pa, &ih))
107 return -ENOENT; 129 return -ENOENT;
108 130
109 intrstr = pci_intr_string(pa->pa_pc, ih); 131 intrstr = pci_intr_string(pa->pa_pc, ih);
110 ih_cookie = pci_intr_establish(pa->pa_pc, ih, IPL_DRM, handler, arg); 132 ih_cookie = pci_intr_establish(pa->pa_pc, ih, IPL_DRM, handler, arg);
111 if (ih_cookie == NULL) { 133 if (ih_cookie == NULL) {
112 aprint_error_dev(dev->dev, 134 aprint_error_dev(dev->dev,
113 "couldn't establish interrupt at %s (%s)\n", 135 "couldn't establish interrupt at %s (%s)\n",
114 intrstr, name); 136 intrstr, name);
115 return -ENOENT; 137 return -ENOENT;
116 } 138 }
117 139
118 aprint_normal_dev(dev->dev, "interrupting at %s (%s)\n", 140 aprint_normal_dev(dev->dev, "interrupting at %s (%s)\n",
119 intrstr, name); 141 intrstr, name);
120 *cookiep = (struct drm_bus_irq_cookie *)ih_cookie; 142 *cookiep = (struct drm_bus_irq_cookie *)ih_cookie;
121 return 0; 143 return 0;
122} 144}
123 145
124static void 146static void
125drm_pci_irq_uninstall(struct drm_device *dev, 147drm_pci_irq_uninstall(struct drm_device *dev,
126 struct drm_bus_irq_cookie *cookie) 148 struct drm_bus_irq_cookie *cookie)
127{ 149{
128 const struct pci_attach_args *pa = drm_pci_attach_args(dev); 150 const struct pci_attach_args *pa = drm_pci_attach_args(dev);
129 151
130 pci_intr_disestablish(pa->pa_pc, (void *)cookie); 152 pci_intr_disestablish(pa->pa_pc, (void *)cookie);
131} 153}
132 154
133static const char * 155static const char *
134drm_pci_get_name(struct drm_device *dev) 156drm_pci_get_name(struct drm_device *dev)
135{ 157{
136 return "pci"; /* XXX PCI bus names? */ 158 return "pci"; /* XXX PCI bus names? */
137} 159}
138 160
139static int 161static int
140drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) 162drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
141{ 163{
142 return -ENOSYS; /* XXX PCI bus ids? */ 164 return -ENOSYS; /* XXX PCI bus ids? */
143} 165}
144 166
145static int 167static int
146drm_pci_set_unique(struct drm_device *dev, struct drm_master *master, 168drm_pci_set_unique(struct drm_device *dev, struct drm_master *master,
147 struct drm_unique *unique) 169 struct drm_unique *unique)
148{ 170{
149 return -ENOSYS; /* XXX */ 171 return -ENOSYS; /* XXX */
150} 172}
151 173
152static int 174static int
153drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *busid) 175drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *busid)
154{ 176{
155 return -ENOSYS; /* XXX */ 177 return -ENOSYS; /* XXX */
156} 178}
157 179
158static int 180static int
159drm_pci_agp_init(struct drm_device *dev) 181drm_pci_agp_init(struct drm_device *dev)
160{ 182{
161 return -ENOSYS; /* XXX */ 183 return -ENOSYS; /* XXX */
162} 184}