Rev 4075 | Rev 4111 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4075 | Rev 4080 | ||
---|---|---|---|
Line 57... | Line 57... | ||
57 | int driver_wq_state; |
57 | int driver_wq_state; |
Line 58... | Line 58... | ||
58 | 58 | ||
59 | int x86_clflush_size; |
59 | int x86_clflush_size; |
Line 60... | Line 60... | ||
60 | unsigned int tsc_khz; |
60 | unsigned int tsc_khz; |
Line 61... | Line 61... | ||
61 | 61 | ||
62 | int i915_modeset = 1; |
62 | int kms_modeset = 1; |
Line 63... | Line 63... | ||
63 | 63 | ||
Line 96... | Line 96... | ||
96 | dbgprintf("\ncache line size %d\n", x86_clflush_size); |
96 | dbgprintf("\ncache line size %d\n", x86_clflush_size); |
Line 97... | Line 97... | ||
97 | 97 | ||
Line 98... | Line 98... | ||
98 | enum_pci_devices(); |
98 | enum_pci_devices(); |
99 | - | ||
100 | err = vmw_init(); |
99 | |
101 | 100 | err = vmw_init(); |
|
102 | if(err) |
101 | if(err) |
103 | { |
102 | { |
104 | dbgprintf("Epic Fail :(\n"); |
103 | dbgprintf("Epic Fail :(\n"); |
Line 185... | Line 184... | ||
185 | case SRV_GETVERSION: |
184 | case SRV_GETVERSION: |
186 | check_output(4); |
185 | check_output(4); |
187 | *outp = DISPLAY_VERSION; |
186 | *outp = DISPLAY_VERSION; |
188 | retval = 0; |
187 | retval = 0; |
189 | break; |
188 | break; |
190 | #if 0 |
189 | |
191 | case SRV_ENUM_MODES: |
190 | case SRV_ENUM_MODES: |
192 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
191 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
193 | // inp, io->inp_size, io->out_size ); |
192 | inp, io->inp_size, io->out_size ); |
194 | check_output(4); |
193 | check_output(4); |
195 | // check_input(*outp * sizeof(videomode_t)); |
194 | // check_input(*outp * sizeof(videomode_t)); |
196 | if( i915_modeset) |
195 | if( kms_modeset) |
197 | retval = get_videomodes((videomode_t*)inp, outp); |
196 | retval = get_videomodes((videomode_t*)inp, outp); |
198 | break; |
197 | break; |
Line 199... | Line 198... | ||
199 | 198 | ||
200 | case SRV_SET_MODE: |
199 | case SRV_SET_MODE: |
201 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
200 | dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
202 | // inp, io->inp_size); |
201 | inp, io->inp_size); |
203 | check_input(sizeof(videomode_t)); |
202 | check_input(sizeof(videomode_t)); |
204 | if( i915_modeset ) |
203 | if( kms_modeset ) |
205 | retval = set_user_mode((videomode_t*)inp); |
204 | retval = set_user_mode((videomode_t*)inp); |
Line -... | Line 205... | ||
- | 205 | break; |
|
206 | break; |
206 | |
207 | 207 | #if 0 |
|
208 | case SRV_GET_CAPS: |
208 | case SRV_GET_CAPS: |
Line 209... | Line 209... | ||
209 | retval = get_driver_caps((hwcaps_t*)inp); |
209 | retval = get_driver_caps((hwcaps_t*)inp); |
Line 808... | Line 808... | ||
808 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, 16, 1, |
808 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, 16, 1, |
809 | buf, len, true); |
809 | buf, len, true); |
810 | }>>>>>=>>>>>><>>>=>=>=0x7f) |
810 | } |
Line -... | Line 811... | ||
- | 811 | ||
- | 812 | ||
- | 813 | ||
- | 814 | ||
- | 815 | ||
- | 816 | ||
- | 817 | ||
- | 818 | ||
- | 819 | ||
- | 820 | ||
- | 821 | ||
- | 822 | ||
- | 823 | #include "vmwgfx_kms.h" |
|
- | 824 | ||
- | 825 | void kms_update(); |
|
- | 826 | ||
- | 827 | //#define iowrite32(v, addr) writel((v), (addr)) |
|
- | 828 | ||
- | 829 | //#include "bitmap.h" |
|
- | 830 | ||
- | 831 | extern struct drm_device *main_device; |
|
- | 832 | ||
- | 833 | typedef struct |
|
- | 834 | { |
|
- | 835 | kobj_t header; |
|
- | 836 | ||
- | 837 | uint32_t *data; |
|
- | 838 | uint32_t hot_x; |
|
- | 839 | uint32_t hot_y; |
|
- | 840 | ||
- | 841 | struct list_head list; |
|
- | 842 | // struct drm_i915_gem_object *cobj; |
|
- | 843 | }cursor_t; |
|
- | 844 | ||
- | 845 | #define CURSOR_WIDTH 64 |
|
- | 846 | #define CURSOR_HEIGHT 64 |
|
- | 847 | ||
- | 848 | struct tag_display |
|
- | 849 | { |
|
- | 850 | int x; |
|
- | 851 | int y; |
|
- | 852 | int width; |
|
- | 853 | int height; |
|
- | 854 | int bpp; |
|
- | 855 | int vrefresh; |
|
- | 856 | int pitch; |
|
- | 857 | int lfb; |
|
- | 858 | ||
- | 859 | int supported_modes; |
|
- | 860 | struct drm_device *ddev; |
|
- | 861 | struct drm_connector *connector; |
|
- | 862 | struct drm_crtc *crtc; |
|
- | 863 | ||
- | 864 | struct list_head cursors; |
|
- | 865 | ||
- | 866 | cursor_t *cursor; |
|
- | 867 | int (*init_cursor)(cursor_t*); |
|
- | 868 | cursor_t* (__stdcall *select_cursor)(cursor_t*); |
|
- | 869 | void (*show_cursor)(int show); |
|
- | 870 | void (__stdcall *move_cursor)(cursor_t *cursor, int x, int y); |
|
- | 871 | void (__stdcall *restore_cursor)(int x, int y); |
|
- | 872 | void (*disable_mouse)(void); |
|
- | 873 | u32 mask_seqno; |
|
- | 874 | u32 check_mouse; |
|
- | 875 | u32 check_m_pixel; |
|
- | 876 | u32 dirty; |
|
- | 877 | void (*update)(void); |
|
- | 878 | }; |
|
- | 879 | ||
- | 880 | static display_t *os_display; |
|
- | 881 | ||
- | 882 | static int count_connector_modes(struct drm_connector* connector) |
|
- | 883 | { |
|
- | 884 | struct drm_display_mode *mode; |
|
- | 885 | int count = 0; |
|
- | 886 | ||
- | 887 | list_for_each_entry(mode, &connector->modes, head) |
|
- | 888 | { |
|
- | 889 | count++; |
|
- | 890 | }; |
|
- | 891 | return count; |
|
- | 892 | }; |
|
- | 893 | ||
- | 894 | int kms_init(struct drm_device *dev) |
|
- | 895 | { |
|
- | 896 | struct drm_connector *connector; |
|
- | 897 | struct drm_connector_helper_funcs *connector_funcs; |
|
- | 898 | struct drm_encoder *encoder; |
|
- | 899 | struct drm_crtc *crtc = NULL; |
|
- | 900 | struct drm_framebuffer *fb; |
|
- | 901 | ||
- | 902 | cursor_t *cursor; |
|
- | 903 | int mode_count; |
|
- | 904 | u32_t ifl; |
|
- | 905 | int err; |
|
- | 906 | ||
- | 907 | ENTER(); |
|
- | 908 | ||
- | 909 | crtc = list_entry(dev->mode_config.crtc_list.next, typeof(*crtc), head); |
|
- | 910 | encoder = list_entry(dev->mode_config.encoder_list.next, typeof(*encoder), head); |
|
- | 911 | connector = list_entry(dev->mode_config.connector_list.next, typeof(*connector), head); |
|
- | 912 | connector->encoder = encoder; |
|
- | 913 | ||
- | 914 | mode_count = count_connector_modes(connector); |
|
- | 915 | if(mode_count == 0) |
|
- | 916 | { |
|
- | 917 | struct drm_display_mode *mode; |
|
- | 918 | ||
- | 919 | connector->funcs->fill_modes(connector, |
|
- | 920 | dev->mode_config.max_width, |
|
- | 921 | dev->mode_config.max_height); |
|
- | 922 | ||
- | 923 | list_for_each_entry(mode, &connector->modes, head) |
|
- | 924 | mode_count++; |
|
- | 925 | }; |
|
- | 926 | ||
- | 927 | printf("%s %d\n",__FUNCTION__, mode_count); |
|
- | 928 | ||
- | 929 | DRM_DEBUG_KMS("CONNECTOR %x ID:%d status:%d ENCODER %x CRTC %x ID:%d\n", |
|
- | 930 | connector, connector->base.id, |
|
- | 931 | connector->status, connector->encoder, |
|
- | 932 | crtc, crtc->base.id ); |
|
- | 933 | ||
- | 934 | DRM_DEBUG_KMS("[Select CRTC:%d]\n", crtc->base.id); |
|
- | 935 | ||
- | 936 | os_display = GetDisplay(); |
|
- | 937 | ||
- | 938 | ifl = safe_cli(); |
|
- | 939 | { |
|
- | 940 | os_display->ddev = dev; |
|
- | 941 | os_display->connector = connector; |
|
- | 942 | os_display->crtc = crtc; |
|
- | 943 | os_display->supported_modes = mode_count; |
|
- | 944 | os_display->update = kms_update; |
|
- | 945 | ||
- | 946 | // struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc); |
|
- | 947 | ||
- | 948 | // list_for_each_entry(cursor, &os_display->cursors, list) |
|
- | 949 | // { |
|
- | 950 | // init_cursor(cursor); |
|
- | 951 | // }; |
|
- | 952 | ||
- | 953 | // os_display->restore_cursor(0,0); |
|
- | 954 | // os_display->init_cursor = init_cursor; |
|
- | 955 | // os_display->select_cursor = select_cursor_kms; |
|
- | 956 | // os_display->show_cursor = NULL; |
|
- | 957 | // os_display->move_cursor = move_cursor_kms; |
|
- | 958 | // os_display->restore_cursor = restore_cursor; |
|
- | 959 | // os_display->disable_mouse = disable_mouse; |
|
- | 960 | ||
- | 961 | // intel_crtc->cursor_x = os_display->width/2; |
|
- | 962 | // intel_crtc->cursor_y = os_display->height/2; |
|
- | 963 | ||
- | 964 | // select_cursor_kms(os_display->cursor); |
|
- | 965 | }; |
|
- | 966 | safe_sti(ifl); |
|
- | 967 | ||
- | 968 | main_device = dev; |
|
- | 969 | ||
- | 970 | #ifdef __HWA__ |
|
- | 971 | err = init_bitmaps(); |
|
- | 972 | #endif |
|
- | 973 | ||
- | 974 | LEAVE(); |
|
- | 975 | ||
- | 976 | return 0; |
|
- | 977 | }; |
|
- | 978 | ||
- | 979 | ||
- | 980 | void kms_update() |
|
- | 981 | { |
|
- | 982 | struct vmw_private *dev_priv = vmw_priv(main_device); |
|
- | 983 | size_t fifo_size; |
|
- | 984 | int i; |
|
- | 985 | ||
- | 986 | struct { |
|
- | 987 | uint32_t header; |
|
- | 988 | SVGAFifoCmdUpdate body; |
|
- | 989 | } *cmd; |
|
- | 990 | ||
- | 991 | fifo_size = sizeof(*cmd); |
|
- | 992 | ||
- | 993 | cmd = vmw_fifo_reserve(dev_priv, fifo_size); |
|
- | 994 | if (unlikely(cmd == NULL)) { |
|
- | 995 | DRM_ERROR("Fifo reserve failed.\n"); |
|
- | 996 | return; |
|
- | 997 | } |
|
- | 998 | ||
- | 999 | cmd->header = cpu_to_le32(SVGA_CMD_UPDATE); |
|
- | 1000 | cmd->body.x = 0; |
|
- | 1001 | cmd->body.y = 0; |
|
- | 1002 | cmd->body.width = os_display->width; //cpu_to_le32(clips->x2 - clips->x1); |
|
- | 1003 | cmd->body.height = os_display->height; //cpu_to_le32(clips->y2 - clips->y1); |
|
- | 1004 | ||
- | 1005 | vmw_fifo_commit(dev_priv, fifo_size); |
|
- | 1006 | } |
|
- | 1007 | ||
- | 1008 | int get_videomodes(videomode_t *mode, int *count) |
|
- | 1009 | { |
|
- | 1010 | int err = -1; |
|
- | 1011 | ||
- | 1012 | dbgprintf("mode %x count %d\n", mode, *count); |
|
- | 1013 | ||
- | 1014 | if( *count == 0 ) |
|
- | 1015 | { |
|
- | 1016 | *count = os_display->supported_modes; |
|
- | 1017 | err = 0; |
|
- | 1018 | } |
|
- | 1019 | else if( mode != NULL ) |
|
- | 1020 | { |
|
- | 1021 | struct drm_display_mode *drmmode; |
|
- | 1022 | int i = 0; |
|
- | 1023 | ||
- | 1024 | if( *count > os_display->supported_modes) |
|
- | 1025 | *count = os_display->supported_modes; |
|
- | 1026 | ||
- | 1027 | list_for_each_entry(drmmode, &os_display->connector->modes, head) |
|
- | 1028 | { |
|
- | 1029 | if( i < *count) |
|
- | 1030 | { |
|
- | 1031 | mode->width = drm_mode_width(drmmode); |
|
- | 1032 | mode->height = drm_mode_height(drmmode); |
|
- | 1033 | mode->bpp = 32; |
|
- | 1034 | mode->freq = drm_mode_vrefresh(drmmode); |
|
- | 1035 | i++; |
|
- | 1036 | mode++; |
|
- | 1037 | } |
|
- | 1038 | else break; |
|
- | 1039 | }; |
|
- | 1040 | *count = i; |
|
- | 1041 | err = 0; |
|
- | 1042 | }; |
|
- | 1043 | return err; |
|
- | 1044 | }; |
|
- | 1045 | ||
- | 1046 | ||
- | 1047 | bool set_mode(struct drm_device *dev, struct drm_connector *connector, |
|
- | 1048 | videomode_t *reqmode, bool strict); |
|
- | 1049 | ||
- | 1050 | ||
- | 1051 | int set_user_mode(videomode_t *mode) |
|
- | 1052 | { |
|
- | 1053 | int err = -1; |
|
- | 1054 | ||
- | 1055 | dbgprintf("width %d height %d vrefresh %d\n", |
|
- | 1056 | mode->width, mode->height, mode->freq); |
|
- | 1057 | ||
- | 1058 | if( (mode->width != 0) && |
|
- | 1059 | (mode->height != 0) && |
|
- | 1060 | (mode->freq != 0 ) && |
|
- | 1061 | ( (mode->width != os_display->width) || |
|
- | 1062 | (mode->height != os_display->height) || |
|
- | 1063 | (mode->freq != os_display->vrefresh) ) ) |
|
- | 1064 | { |
|
- | 1065 | if( set_mode(os_display->ddev, os_display->connector, mode, true) ) |
|
- | 1066 | err = 0; |
|
- | 1067 | }; |
|
- | 1068 | ||
- | 1069 | return err; |