| @@ -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 | |
855 | struct drm_bus_irq_cookie; | | 855 | struct drm_bus_irq_cookie; |
856 | | | 856 | |
857 | struct drm_bus { | | 857 | struct 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 | */ |
886 | struct drm_driver { | | 886 | struct 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 | */ |
1131 | struct drm_debugfs_list { | | 1131 | struct 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 | */ |
1140 | struct drm_debugfs_node { | | 1140 | struct 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 | */ |
1151 | struct drm_info_list { | | 1151 | struct 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 | */ |
1161 | struct drm_info_node { | | 1161 | struct 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 | */ |
1172 | struct drm_minor { | | 1172 | struct 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 */ |
1198 | struct drm_cmdline_mode { | | 1198 | struct 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 | |
1213 | struct drm_pending_vblank_event { | | 1213 | struct 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 | */ |
1223 | struct drm_device { | | 1223 | struct 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 | |
1407 | static __inline__ int drm_core_check_feature(struct drm_device *dev, | | 1407 | static __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 | |
1413 | static inline int drm_dev_to_irq(struct drm_device *dev) | | 1413 | static 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 |
1420 | static inline int drm_core_has_AGP(struct drm_device *dev) | | 1420 | static 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 |
1429 | static inline int drm_core_has_MTRR(struct drm_device *dev) | | 1429 | static 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 | |
1436 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, | | 1436 | static 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 | |
1442 | static inline int drm_mtrr_del(int handle, unsigned long offset, | | 1442 | static 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 | |
1453 | static inline int drm_mtrr_add(unsigned long offset, unsigned long size, | | 1453 | static 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 | |
1459 | static inline int drm_mtrr_del(int handle, unsigned long offset, | | 1459 | static 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 | |
1466 | static inline void drm_device_set_unplugged(struct drm_device *dev) | | 1466 | static 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 | |
1472 | static inline int drm_device_is_unplugged(struct drm_device *dev) | | 1472 | static 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) */ |
1486 | extern long drm_ioctl(struct file *filp, | | 1486 | extern long drm_ioctl(struct file *filp, |
1487 | unsigned int cmd, unsigned long arg); | | 1487 | unsigned int cmd, unsigned long arg); |
1488 | extern long drm_compat_ioctl(struct file *filp, | | 1488 | extern long drm_compat_ioctl(struct file *filp, |
1489 | unsigned int cmd, unsigned long arg); | | 1489 | unsigned int cmd, unsigned long arg); |
1490 | extern int drm_lastclose(struct drm_device *dev); | | 1490 | extern int drm_lastclose(struct drm_device *dev); |
1491 | #endif | | 1491 | #endif |
1492 | | | 1492 | |
1493 | #ifdef __NetBSD__ | | 1493 | #ifdef __NetBSD__ |
1494 | extern void drm_config_found(device_t, /* XXXX const */ struct drm_driver *, | | 1494 | extern 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) */ |
1499 | extern struct mutex drm_global_mutex; | | 1499 | extern struct mutex drm_global_mutex; |
1500 | #ifdef __NetBSD__ | | 1500 | #ifdef __NetBSD__ |
1501 | extern int drm_open_file(struct drm_file *, void *, struct drm_minor *); | | 1501 | extern int drm_open_file(struct drm_file *, void *, struct drm_minor *); |
1502 | extern int drm_close_file(struct drm_file *); | | 1502 | extern int drm_close_file(struct drm_file *); |
1503 | #if 0 /* XXX drm event poll */ | | 1503 | #if 0 /* XXX drm event poll */ |
1504 | extern int drm_dequeue_event(struct drm_file *, size_t, | | 1504 | extern int drm_dequeue_event(struct drm_file *, size_t, |
1505 | struct drm_pending_event **); | | 1505 | struct drm_pending_event **); |
1506 | #endif | | 1506 | #endif |
1507 | extern void drm_lastclose(struct drm_device *); | | 1507 | extern void drm_lastclose(struct drm_device *); |
1508 | #else | | 1508 | #else |
1509 | extern int drm_open(struct inode *inode, struct file *filp); | | 1509 | extern int drm_open(struct inode *inode, struct file *filp); |
1510 | extern int drm_stub_open(struct inode *inode, struct file *filp); | | 1510 | extern int drm_stub_open(struct inode *inode, struct file *filp); |
1511 | extern int drm_fasync(int fd, struct file *filp, int on); | | 1511 | extern int drm_fasync(int fd, struct file *filp, int on); |
1512 | extern ssize_t drm_read(struct file *filp, char __user *buffer, | | 1512 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
1513 | size_t count, loff_t *offset); | | 1513 | size_t count, loff_t *offset); |
1514 | extern int drm_release(struct inode *inode, struct file *filp); | | 1514 | extern 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__ |
1519 | extern paddr_t drm_mmap_paddr(struct drm_device *, off_t, int); | | 1519 | extern paddr_t drm_mmap_paddr(struct drm_device *, off_t, int); |
1520 | #else | | 1520 | #else |
1521 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); | | 1521 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
1522 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); | | 1522 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
1523 | extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); | | 1523 | extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1524 | extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); | | 1524 | extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma); |
1525 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | | 1525 | extern 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__ |
1532 | extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); | | 1532 | extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); |
1533 | extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); | | 1533 | extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); |
1534 | extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, | | 1534 | extern 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); |
1539 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); | | 1539 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); |
1540 | #endif | | 1540 | #endif |
1541 | #ifdef __NetBSD__ | | 1541 | #ifdef __NetBSD__ |
1542 | extern void *drm_ioremap(struct drm_device *dev, struct drm_local_map *map); | | 1542 | extern void *drm_ioremap(struct drm_device *dev, struct drm_local_map *map); |
1543 | extern void drm_iounmap(struct drm_device *dev, struct drm_local_map *map); | | 1543 | extern void drm_iounmap(struct drm_device *dev, struct drm_local_map *map); |
1544 | extern int drm_limit_dma_space(struct drm_device *, resource_size_t, | | 1544 | extern 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) */ |
1549 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, | | 1549 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
1550 | struct drm_file *file_priv); | | 1550 | struct drm_file *file_priv); |
1551 | extern int drm_getunique(struct drm_device *dev, void *data, | | 1551 | extern int drm_getunique(struct drm_device *dev, void *data, |
1552 | struct drm_file *file_priv); | | 1552 | struct drm_file *file_priv); |
1553 | extern int drm_setunique(struct drm_device *dev, void *data, | | 1553 | extern int drm_setunique(struct drm_device *dev, void *data, |
1554 | struct drm_file *file_priv); | | 1554 | struct drm_file *file_priv); |
1555 | extern int drm_getmap(struct drm_device *dev, void *data, | | 1555 | extern int drm_getmap(struct drm_device *dev, void *data, |
1556 | struct drm_file *file_priv); | | 1556 | struct drm_file *file_priv); |
1557 | extern int drm_getclient(struct drm_device *dev, void *data, | | 1557 | extern int drm_getclient(struct drm_device *dev, void *data, |
1558 | struct drm_file *file_priv); | | 1558 | struct drm_file *file_priv); |
1559 | extern int drm_getstats(struct drm_device *dev, void *data, | | 1559 | extern int drm_getstats(struct drm_device *dev, void *data, |
1560 | struct drm_file *file_priv); | | 1560 | struct drm_file *file_priv); |
1561 | extern int drm_getcap(struct drm_device *dev, void *data, | | 1561 | extern int drm_getcap(struct drm_device *dev, void *data, |
1562 | struct drm_file *file_priv); | | 1562 | struct drm_file *file_priv); |
1563 | extern int drm_setversion(struct drm_device *dev, void *data, | | 1563 | extern int drm_setversion(struct drm_device *dev, void *data, |
1564 | struct drm_file *file_priv); | | 1564 | struct drm_file *file_priv); |
1565 | extern int drm_noop(struct drm_device *dev, void *data, | | 1565 | extern 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) */ |
1569 | extern int drm_resctx(struct drm_device *dev, void *data, | | 1569 | extern int drm_resctx(struct drm_device *dev, void *data, |
1570 | struct drm_file *file_priv); | | 1570 | struct drm_file *file_priv); |
1571 | extern int drm_addctx(struct drm_device *dev, void *data, | | 1571 | extern int drm_addctx(struct drm_device *dev, void *data, |
1572 | struct drm_file *file_priv); | | 1572 | struct drm_file *file_priv); |
1573 | extern int drm_modctx(struct drm_device *dev, void *data, | | 1573 | extern int drm_modctx(struct drm_device *dev, void *data, |
1574 | struct drm_file *file_priv); | | 1574 | struct drm_file *file_priv); |
1575 | extern int drm_getctx(struct drm_device *dev, void *data, | | 1575 | extern int drm_getctx(struct drm_device *dev, void *data, |
1576 | struct drm_file *file_priv); | | 1576 | struct drm_file *file_priv); |
1577 | extern int drm_switchctx(struct drm_device *dev, void *data, | | 1577 | extern int drm_switchctx(struct drm_device *dev, void *data, |
1578 | struct drm_file *file_priv); | | 1578 | struct drm_file *file_priv); |
1579 | extern int drm_newctx(struct drm_device *dev, void *data, | | 1579 | extern int drm_newctx(struct drm_device *dev, void *data, |
1580 | struct drm_file *file_priv); | | 1580 | struct drm_file *file_priv); |
1581 | extern int drm_rmctx(struct drm_device *dev, void *data, | | 1581 | extern int drm_rmctx(struct drm_device *dev, void *data, |
1582 | struct drm_file *file_priv); | | 1582 | struct drm_file *file_priv); |
1583 | | | 1583 | |
1584 | extern int drm_ctxbitmap_init(struct drm_device *dev); | | 1584 | extern int drm_ctxbitmap_init(struct drm_device *dev); |
1585 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); | | 1585 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); |
1586 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); | | 1586 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
1587 | | | 1587 | |
1588 | extern int drm_setsareactx(struct drm_device *dev, void *data, | | 1588 | extern int drm_setsareactx(struct drm_device *dev, void *data, |
1589 | struct drm_file *file_priv); | | 1589 | struct drm_file *file_priv); |
1590 | extern int drm_getsareactx(struct drm_device *dev, void *data, | | 1590 | extern 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) */ |
1594 | extern int drm_getmagic(struct drm_device *dev, void *data, | | 1594 | extern int drm_getmagic(struct drm_device *dev, void *data, |
1595 | struct drm_file *file_priv); | | 1595 | struct drm_file *file_priv); |
1596 | extern int drm_authmagic(struct drm_device *dev, void *data, | | 1596 | extern int drm_authmagic(struct drm_device *dev, void *data, |
1597 | struct drm_file *file_priv); | | 1597 | struct drm_file *file_priv); |
1598 | extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic); | | 1598 | extern 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) */ |
1602 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); | | 1602 | void drm_clflush_pages(struct page *pages[], unsigned long num_pages); |
1603 | void drm_clflush_sg(struct sg_table *st); | | 1603 | void drm_clflush_sg(struct sg_table *st); |
1604 | void drm_clflush_virt_range(char *addr, unsigned long length); | | 1604 | void 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) */ |
1608 | extern int drm_lock(struct drm_device *dev, void *data, | | 1608 | extern int drm_lock(struct drm_device *dev, void *data, |
1609 | struct drm_file *file_priv); | | 1609 | struct drm_file *file_priv); |
1610 | extern int drm_unlock(struct drm_device *dev, void *data, | | 1610 | extern int drm_unlock(struct drm_device *dev, void *data, |
1611 | struct drm_file *file_priv); | | 1611 | struct drm_file *file_priv); |
1612 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); | | 1612 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
1613 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); | | 1613 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
1614 | extern void drm_idlelock_release(struct drm_lock_data *lock_data); | | 1614 | extern 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 | |
1621 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); | | 1621 | extern 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) */ |
1624 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); | | 1624 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
1625 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); | | 1625 | extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request); |
1626 | extern int drm_addmap(struct drm_device *dev, resource_size_t offset, | | 1626 | extern 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); |
1629 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, | | 1629 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
1630 | struct drm_file *file_priv); | | 1630 | struct drm_file *file_priv); |
1631 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); | | 1631 | extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map); |
1632 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); | | 1632 | extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map); |
1633 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, | | 1633 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
1634 | struct drm_file *file_priv); | | 1634 | struct drm_file *file_priv); |
1635 | extern int drm_addbufs(struct drm_device *dev, void *data, | | 1635 | extern int drm_addbufs(struct drm_device *dev, void *data, |
1636 | struct drm_file *file_priv); | | 1636 | struct drm_file *file_priv); |
1637 | extern int drm_infobufs(struct drm_device *dev, void *data, | | 1637 | extern int drm_infobufs(struct drm_device *dev, void *data, |
1638 | struct drm_file *file_priv); | | 1638 | struct drm_file *file_priv); |
1639 | extern int drm_markbufs(struct drm_device *dev, void *data, | | 1639 | extern int drm_markbufs(struct drm_device *dev, void *data, |
1640 | struct drm_file *file_priv); | | 1640 | struct drm_file *file_priv); |
1641 | extern int drm_freebufs(struct drm_device *dev, void *data, | | 1641 | extern int drm_freebufs(struct drm_device *dev, void *data, |
1642 | struct drm_file *file_priv); | | 1642 | struct drm_file *file_priv); |
1643 | extern int drm_mapbufs(struct drm_device *dev, void *data, | | 1643 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
1644 | struct drm_file *file_priv); | | 1644 | struct drm_file *file_priv); |
1645 | extern int drm_order(unsigned long size); | | 1645 | extern int drm_order(unsigned long size); |
1646 | | | 1646 | |
1647 | /* DMA support (drm_dma.h) */ | | 1647 | /* DMA support (drm_dma.h) */ |
1648 | extern int drm_dma_setup(struct drm_device *dev); | | 1648 | extern int drm_dma_setup(struct drm_device *dev); |
1649 | extern void drm_dma_takedown(struct drm_device *dev); | | 1649 | extern void drm_dma_takedown(struct drm_device *dev); |
1650 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); | | 1650 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
1651 | extern void drm_core_reclaim_buffers(struct drm_device *dev, | | 1651 | extern 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) */ |
1655 | extern int drm_control(struct drm_device *dev, void *data, | | 1655 | extern int drm_control(struct drm_device *dev, void *data, |
1656 | struct drm_file *file_priv); | | 1656 | struct drm_file *file_priv); |
1657 | extern int drm_irq_install(struct drm_device *dev); | | 1657 | extern int drm_irq_install(struct drm_device *dev); |
1658 | extern int drm_irq_uninstall(struct drm_device *dev); | | 1658 | extern int drm_irq_uninstall(struct drm_device *dev); |
1659 | | | 1659 | |
1660 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); | | 1660 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
1661 | extern int drm_wait_vblank(struct drm_device *dev, void *data, | | 1661 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
1662 | struct drm_file *filp); | | 1662 | struct drm_file *filp); |
1663 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); | | 1663 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
1664 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); | | 1664 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
1665 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, | | 1665 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
1666 | struct timeval *vblanktime); | | 1666 | struct timeval *vblanktime); |
1667 | extern void drm_send_vblank_event(struct drm_device *dev, int crtc, | | 1667 | extern 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); |
1669 | extern bool drm_handle_vblank(struct drm_device *dev, int crtc); | | 1669 | extern bool drm_handle_vblank(struct drm_device *dev, int crtc); |
1670 | extern int drm_vblank_get(struct drm_device *dev, int crtc); | | 1670 | extern int drm_vblank_get(struct drm_device *dev, int crtc); |
1671 | extern void drm_vblank_put(struct drm_device *dev, int crtc); | | 1671 | extern void drm_vblank_put(struct drm_device *dev, int crtc); |
1672 | extern void drm_vblank_off(struct drm_device *dev, int crtc); | | 1672 | extern void drm_vblank_off(struct drm_device *dev, int crtc); |
1673 | extern void drm_vblank_cleanup(struct drm_device *dev); | | 1673 | extern void drm_vblank_cleanup(struct drm_device *dev); |
1674 | extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, | | 1674 | extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, |
1675 | struct timeval *tvblank, unsigned flags); | | 1675 | struct timeval *tvblank, unsigned flags); |
1676 | extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | | 1676 | extern 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); |
1681 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc); | | 1681 | extern void drm_calc_timestamping_constants(struct drm_crtc *crtc); |
1682 | | | 1682 | |
1683 | extern bool | | 1683 | extern bool |
1684 | drm_mode_parse_command_line_for_connector(const char *mode_option, | | 1684 | drm_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 | |
1688 | extern struct drm_display_mode * | | 1688 | extern struct drm_display_mode * |
1689 | drm_mode_create_from_cmdline_mode(struct drm_device *dev, | | 1689 | drm_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 */ |
1693 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); | | 1693 | extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
1694 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); | | 1694 | extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
1695 | extern int drm_modeset_ctl(struct drm_device *dev, void *data, | | 1695 | extern 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) */ |
1699 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); | | 1699 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); |
1700 | extern int drm_agp_acquire(struct drm_device *dev); | | 1700 | extern int drm_agp_acquire(struct drm_device *dev); |
1701 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, | | 1701 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
1702 | struct drm_file *file_priv); | | 1702 | struct drm_file *file_priv); |
1703 | extern int drm_agp_release(struct drm_device *dev); | | 1703 | extern int drm_agp_release(struct drm_device *dev); |
1704 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, | | 1704 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
1705 | struct drm_file *file_priv); | | 1705 | struct drm_file *file_priv); |
1706 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); | | 1706 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
1707 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, | | 1707 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
1708 | struct drm_file *file_priv); | | 1708 | struct drm_file *file_priv); |
1709 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); | | 1709 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); |
1710 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, | | 1710 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
1711 | struct drm_file *file_priv); | | 1711 | struct drm_file *file_priv); |
1712 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); | | 1712 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
1713 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, | | 1713 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
1714 | struct drm_file *file_priv); | | 1714 | struct drm_file *file_priv); |
1715 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | | 1715 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
1716 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, | | 1716 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
1717 | struct drm_file *file_priv); | | 1717 | struct drm_file *file_priv); |
1718 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | | 1718 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
1719 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | | 1719 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
1720 | struct drm_file *file_priv); | | 1720 | struct drm_file *file_priv); |
1721 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | | 1721 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
1722 | extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | | 1722 | extern 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) */ |
1726 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, | | 1726 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
1727 | struct drm_file *file_priv); | | 1727 | struct drm_file *file_priv); |
1728 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, | | 1728 | extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
1729 | struct drm_file *file_priv); | | 1729 | struct drm_file *file_priv); |
1730 | struct drm_master *drm_master_create(struct drm_minor *minor); | | 1730 | struct drm_master *drm_master_create(struct drm_minor *minor); |
1731 | extern struct drm_master *drm_master_get(struct drm_master *master); | | 1731 | extern struct drm_master *drm_master_get(struct drm_master *master); |
1732 | extern void drm_master_put(struct drm_master **master); | | 1732 | extern void drm_master_put(struct drm_master **master); |
1733 | | | 1733 | |
1734 | extern void drm_put_dev(struct drm_device *dev); | | 1734 | extern void drm_put_dev(struct drm_device *dev); |
1735 | extern int drm_put_minor(struct drm_minor **minor); | | 1735 | extern int drm_put_minor(struct drm_minor **minor); |
1736 | extern void drm_unplug_dev(struct drm_device *dev); | | 1736 | extern void drm_unplug_dev(struct drm_device *dev); |
1737 | extern unsigned int drm_debug; | | 1737 | extern unsigned int drm_debug; |
1738 | | | 1738 | |
1739 | extern unsigned int drm_vblank_offdelay; | | 1739 | extern unsigned int drm_vblank_offdelay; |
1740 | extern unsigned int drm_timestamp_precision; | | 1740 | extern unsigned int drm_timestamp_precision; |
1741 | extern unsigned int drm_timestamp_monotonic; | | 1741 | extern unsigned int drm_timestamp_monotonic; |
1742 | | | 1742 | |
1743 | extern struct class *drm_class; | | 1743 | extern struct class *drm_class; |
1744 | extern struct proc_dir_entry *drm_proc_root; | | 1744 | extern struct proc_dir_entry *drm_proc_root; |
1745 | extern struct dentry *drm_debugfs_root; | | 1745 | extern struct dentry *drm_debugfs_root; |
1746 | | | 1746 | |
1747 | extern struct idr drm_minors_idr; | | 1747 | extern struct idr drm_minors_idr; |
1748 | | | 1748 | |
1749 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); | | 1749 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
1750 | | | 1750 | |
1751 | /* Proc support (drm_proc.h) */ | | 1751 | /* Proc support (drm_proc.h) */ |
1752 | extern int drm_proc_init(struct drm_minor *minor, int minor_id, | | 1752 | extern int drm_proc_init(struct drm_minor *minor, int minor_id, |
1753 | struct proc_dir_entry *root); | | 1753 | struct proc_dir_entry *root); |
1754 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); | | 1754 | extern 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) |
1758 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, | | 1758 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1759 | struct dentry *root); | | 1759 | struct dentry *root); |
1760 | extern int drm_debugfs_create_files(struct drm_info_list *files, int count, | | 1760 | extern 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); |
1762 | extern int drm_debugfs_remove_files(struct drm_info_list *files, int count, | | 1762 | extern int drm_debugfs_remove_files(struct drm_info_list *files, int count, |
1763 | struct drm_minor *minor); | | 1763 | struct drm_minor *minor); |
1764 | extern int drm_debugfs_cleanup(struct drm_minor *minor); | | 1764 | extern 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 */ |
1769 | extern int drm_name_info(struct seq_file *m, void *data); | | 1769 | extern int drm_name_info(struct seq_file *m, void *data); |
1770 | extern int drm_vm_info(struct seq_file *m, void *data); | | 1770 | extern int drm_vm_info(struct seq_file *m, void *data); |
1771 | extern int drm_bufs_info(struct seq_file *m, void *data); | | 1771 | extern int drm_bufs_info(struct seq_file *m, void *data); |
1772 | extern int drm_vblank_info(struct seq_file *m, void *data); | | 1772 | extern int drm_vblank_info(struct seq_file *m, void *data); |
1773 | extern int drm_clients_info(struct seq_file *m, void* data); | | 1773 | extern int drm_clients_info(struct seq_file *m, void* data); |
1774 | extern int drm_gem_name_info(struct seq_file *m, void *data); | | 1774 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
1775 | #endif | | 1775 | #endif |
1776 | | | 1776 | |
1777 | | | 1777 | |
1778 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, | | 1778 | extern 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); |
1781 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, | | 1781 | extern 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 | |
1784 | extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, | | 1784 | extern 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); |
1786 | extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data, | | 1786 | extern 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 */ |
1790 | extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, | | 1790 | extern 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); |
1792 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); | | 1792 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); |
1793 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); | | 1793 | extern 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 */ |
1798 | void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); | | 1798 | void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); |
1799 | void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); | | 1799 | void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); |
1800 | int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle); | | 1800 | int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle); |
1801 | int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle); | | 1801 | int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle); |
1802 | void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); | | 1802 | void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); |
1803 | | | 1803 | |
1804 | int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj); | | 1804 | int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj); |
1805 | int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf, | | 1805 | int 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__ |
1811 | extern int drm_vma_info(struct seq_file *m, void *data); | | 1811 | extern 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) */ |
1816 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); | | 1816 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); |
1817 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, | | 1817 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
1818 | struct drm_file *file_priv); | | 1818 | struct drm_file *file_priv); |
1819 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); | | 1819 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
1820 | extern int drm_sg_free(struct drm_device *dev, void *data, | | 1820 | extern 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) */ |
1824 | extern int drm_ati_pcigart_init(struct drm_device *dev, | | 1824 | extern 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); |
1826 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, | | 1826 | extern 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 | |
1829 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | | 1829 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
1830 | size_t align); | | 1830 | size_t align); |
1831 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | | 1831 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
1832 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | | 1832 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); |
| | | 1833 | #ifdef __NetBSD__ |
| | | 1834 | extern void drm_pci_attach(device_t, const struct pci_attach_args *, |
| | | 1835 | struct pci_dev *, struct drm_device *); |
| | | 1836 | extern int drm_pci_detach(struct drm_device *, int); |
| | | 1837 | #endif |
1833 | | | 1838 | |
1834 | /* sysfs support (drm_sysfs.c) */ | | 1839 | /* sysfs support (drm_sysfs.c) */ |
1835 | struct drm_sysfs_class; | | 1840 | struct drm_sysfs_class; |
1836 | extern struct class *drm_sysfs_create(struct module *owner, char *name); | | 1841 | extern struct class *drm_sysfs_create(struct module *owner, char *name); |
1837 | extern void drm_sysfs_destroy(void); | | 1842 | extern void drm_sysfs_destroy(void); |
1838 | extern int drm_sysfs_device_add(struct drm_minor *minor); | | 1843 | extern int drm_sysfs_device_add(struct drm_minor *minor); |
1839 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | | 1844 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
1840 | extern void drm_sysfs_device_remove(struct drm_minor *minor); | | 1845 | extern void drm_sysfs_device_remove(struct drm_minor *minor); |
1841 | #ifndef __NetBSD__ | | 1846 | #ifndef __NetBSD__ |
1842 | extern char *drm_get_connector_status_name(enum drm_connector_status status); | | 1847 | extern char *drm_get_connector_status_name(enum drm_connector_status status); |
1843 | #endif | | 1848 | #endif |
1844 | extern int drm_sysfs_connector_add(struct drm_connector *connector); | | 1849 | extern int drm_sysfs_connector_add(struct drm_connector *connector); |
1845 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); | | 1850 | extern 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) */ |
1848 | int drm_gem_init(struct drm_device *dev); | | 1853 | int drm_gem_init(struct drm_device *dev); |
1849 | void drm_gem_destroy(struct drm_device *dev); | | 1854 | void drm_gem_destroy(struct drm_device *dev); |
1850 | void drm_gem_object_release(struct drm_gem_object *obj); | | 1855 | void drm_gem_object_release(struct drm_gem_object *obj); |
1851 | void drm_gem_object_free(struct kref *kref); | | 1856 | void drm_gem_object_free(struct kref *kref); |
1852 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, | | 1857 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
1853 | size_t size); | | 1858 | size_t size); |
1854 | int drm_gem_object_init(struct drm_device *dev, | | 1859 | int 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); |
1856 | int drm_gem_private_object_init(struct drm_device *dev, | | 1861 | int 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); |
1858 | void drm_gem_object_handle_free(struct drm_gem_object *obj); | | 1863 | void drm_gem_object_handle_free(struct drm_gem_object *obj); |
1859 | #ifdef __NetBSD__ | | 1864 | #ifdef __NetBSD__ |
1860 | void drm_gem_pager_reference(struct uvm_object *); | | 1865 | void drm_gem_pager_reference(struct uvm_object *); |
1861 | void drm_gem_pager_detach(struct uvm_object *); | | 1866 | void drm_gem_pager_detach(struct uvm_object *); |
1862 | int drm_gem_mmap_object(struct drm_device *, off_t *, size_t, | | 1867 | int drm_gem_mmap_object(struct drm_device *, off_t *, size_t, |
1863 | struct uvm_object **); | | 1868 | struct uvm_object **); |
1864 | #else | | 1869 | #else |
1865 | void drm_gem_vm_open(struct vm_area_struct *vma); | | 1870 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1866 | void drm_gem_vm_close(struct vm_area_struct *vma); | | 1871 | void drm_gem_vm_close(struct vm_area_struct *vma); |
1867 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | | 1872 | int 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 | |
1872 | static inline void | | 1877 | static inline void |
1873 | drm_gem_object_reference(struct drm_gem_object *obj) | | 1878 | drm_gem_object_reference(struct drm_gem_object *obj) |
1874 | { | | 1879 | { |
1875 | kref_get(&obj->refcount); | | 1880 | kref_get(&obj->refcount); |
1876 | } | | 1881 | } |
1877 | | | 1882 | |
1878 | static inline void | | 1883 | static inline void |
1879 | drm_gem_object_unreference(struct drm_gem_object *obj) | | 1884 | drm_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 | |
1885 | static inline void | | 1890 | static inline void |
1886 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | | 1891 | drm_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 | |
1896 | int drm_gem_handle_create(struct drm_file *file_priv, | | 1901 | int 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); |
1899 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); | | 1904 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
1900 | | | 1905 | |
1901 | static inline void | | 1906 | static inline void |
1902 | drm_gem_object_handle_reference(struct drm_gem_object *obj) | | 1907 | drm_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 | |
1908 | static inline void | | 1913 | static inline void |
1909 | drm_gem_object_handle_unreference(struct drm_gem_object *obj) | | 1914 | drm_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 | |
1926 | static inline void | | 1931 | static inline void |
1927 | drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) | | 1932 | drm_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 | |
1946 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); | | 1951 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
1947 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); | | 1952 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
1948 | | | 1953 | |
1949 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, | | 1954 | struct 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); |
1952 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, | | 1957 | int drm_gem_close_ioctl(struct drm_device *dev, void *data, |
1953 | struct drm_file *file_priv); | | 1958 | struct drm_file *file_priv); |
1954 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, | | 1959 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data, |
1955 | struct drm_file *file_priv); | | 1960 | struct drm_file *file_priv); |
1956 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, | | 1961 | int drm_gem_open_ioctl(struct drm_device *dev, void *data, |
1957 | struct drm_file *file_priv); | | 1962 | struct drm_file *file_priv); |
1958 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); | | 1963 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); |
1959 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); | | 1964 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private); |
1960 | | | 1965 | |
1961 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); | | 1966 | extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev); |
1962 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); | | 1967 | extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
1963 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); | | 1968 | extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
1964 | | | 1969 | |
1965 | static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, | | 1970 | static __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 | |
1975 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) | | 1980 | static __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 | |
1981 | extern int drm_fill_in_dev(struct drm_device *dev, | | 1986 | extern 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); |
1984 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); | | 1989 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); |
1985 | /*@}*/ | | 1990 | /*@}*/ |
1986 | | | 1991 | |
1987 | /* PCI section */ | | 1992 | /* PCI section */ |
1988 | static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) | | 1993 | static __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 | |
2001 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); | | 2006 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
2002 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); | | 2007 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
2003 | extern int drm_get_pci_dev(struct pci_dev *pdev, | | 2008 | extern 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 | |
2011 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); | | 2016 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
2012 | | | 2017 | |
2013 | /* platform section */ | | 2018 | /* platform section */ |
2014 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); | | 2019 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |
2015 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); | | 2020 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); |
2016 | | | 2021 | |
2017 | extern int drm_get_platform_dev(struct platform_device *pdev, | | 2022 | extern 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 */ |
2021 | static __inline__ bool drm_can_sleep(void) | | 2026 | static __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__ |
2033 | static inline bool | | 2038 | static inline bool |
2034 | DRM_IS_BUS_SPACE(struct drm_local_map *map) | | 2039 | DRM_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 | |
2072 | static inline uint8_t | | 2077 | static inline uint8_t |
2073 | DRM_READ8(struct drm_local_map *map, bus_size_t offset) | | 2078 | DRM_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 | |
2082 | static inline uint16_t | | 2087 | static inline uint16_t |
2083 | DRM_READ16(struct drm_local_map *map, bus_size_t offset) | | 2088 | DRM_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 | |
2092 | static inline uint32_t | | 2097 | static inline uint32_t |
2093 | DRM_READ32(struct drm_local_map *map, bus_size_t offset) | | 2098 | DRM_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 | |
2102 | static inline uint64_t | | 2107 | static inline uint64_t |
2103 | DRM_READ64(struct drm_local_map *map, bus_size_t offset) | | 2108 | DRM_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 | |
2112 | static inline void | | 2117 | static inline void |
2113 | DRM_WRITE8(struct drm_local_map *map, bus_size_t offset, uint8_t value) | | 2118 | DRM_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 | |
2122 | static inline void | | 2127 | static inline void |
2123 | DRM_WRITE16(struct drm_local_map *map, bus_size_t offset, uint16_t value) | | 2128 | DRM_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 | |
2132 | static inline void | | 2137 | static inline void |
2133 | DRM_WRITE32(struct drm_local_map *map, bus_size_t offset, uint32_t value) | | 2138 | DRM_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 | |
2142 | static inline void | | 2147 | static inline void |
2143 | DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value) | | 2148 | DRM_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 | |
2159 | static inline struct io_mapping * | | 2164 | static inline struct io_mapping * |
2160 | drm_io_mapping_create_wc(struct drm_device *dev, resource_size_t addr, | | 2165 | drm_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 |