Subversion Repositories Kolibri OS

Rev

Rev 3290 | Rev 3480 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3290 Rev 3298
Line 13... Line 13...
13
#include 
13
#include 
14
 
14
 
Line 15... Line 15...
15
#include 
15
#include 
Line 16... Line -...
16
 
-
 
17
#include "hmm.h"
16
 
Line 18... Line 17...
18
#include "bitmap.h"
17
#include "bitmap.h"
Line 691... Line 690...
691
    }
690
    }
692
 
691
 
Line 693... Line 692...
693
    GetWindowRect(&winrc);
692
    GetWindowRect(&winrc);
694
    {
693
    {
695
        static warn_count;
694
//        static warn_count;
Line 696... Line 695...
696
 
695
 
697
        mask->width    = winrc.right - winrc.left + 1;
696
        mask->width    = winrc.right - winrc.left + 1;
698
        mask->height   = winrc.bottom - winrc.top + 1;
697
        mask->height   = winrc.bottom - winrc.top + 1;
Line -... Line 698...
-
 
698
        mask->bo_pitch = (mask->width+15) & ~15;
699
        mask->bo_pitch = (mask->width+15) & ~15;
699
 
700
 
700
#if 0
701
        if(warn_count < 1)
701
        if(warn_count < 1)
702
        {
702
        {
703
            printf("left %d top %d right %d bottom %d\n",
703
            printf("left %d top %d right %d bottom %d\n",
704
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
704
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
705
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_size);
705
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_size);
-
 
706
            warn_count++;
-
 
707
        };
706
            warn_count++;
708
#endif
Line 707... Line 709...
707
        };
709
 
Line 826... Line 828...
826
}
828
}
827
 
829
 
Line 828... Line -...
828
 
-
 
829
 
-
 
830
#ifdef __HWA__
-
 
831
 
-
 
832
extern struct hmm bm_mm;
-
 
833
 
-
 
834
 
-
 
835
typedef struct
-
 
836
{
-
 
837
    int left;
-
 
838
    int top;
-
 
839
    int right;
-
 
840
    int bottom;
-
 
841
}rect_t;
-
 
842
 
-
 
843
 
-
 
844
#include "clip.inc"
-
 
845
 
-
 
846
void  FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect");
-
 
847
 
-
 
848
#define CURRENT_TASK             (0x80003000)
-
 
849
 
-
 
850
static u32_t get_display_map()
-
 
851
{
-
 
852
    u32_t   addr;
-
 
853
 
-
 
854
    addr = (u32_t)os_display;
-
 
855
    addr+= sizeof(display_t);            /*  shoot me  */
-
 
856
    return *(u32_t*)addr;
-
 
857
}
-
 
858
 
-
 
859
#define XY_COLOR_BLT                ((2<<29)|(0x50<<22)|(0x4))
-
 
860
#define XY_SRC_COPY_BLT_CMD         ((2<<29)|(0x53<<22)|6)
-
 
861
#define XY_SRC_COPY_CHROMA_CMD      ((2<<29)|(0x73<<22)|8)
-
 
862
#define ROP_COPY_SRC                0xCC
-
 
863
#define FORMAT8888                  3
-
 
864
 
-
 
865
#define BLT_WRITE_ALPHA             (1<<21)
-
 
866
#define BLT_WRITE_RGB               (1<<20)
-
 
867
 
-
 
868
 
-
 
869
 
-
 
870
typedef int v4si __attribute__ ((vector_size (16)));
-
 
871
 
-
 
872
 
-
 
873
 
-
 
874
static void
-
 
875
i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-
 
876
                    struct drm_file *file,
-
 
877
                    struct intel_ring_buffer *ring)
-
 
878
{
-
 
879
    /* Unconditionally force add_request to emit a full flush. */
-
 
880
    ring->gpu_caches_dirty = true;
-
 
881
 
-
 
882
    /* Add a breadcrumb for the completion of the batch buffer */
-
 
883
    (void)i915_add_request(ring, file, NULL);
-
 
884
}
-
 
885
 
-
 
886
int srv_blit_bitmap(u32 hbitmap, int  dst_x, int dst_y,
-
 
887
               int src_x, int src_y, u32 w, u32 h)
-
 
888
{
-
 
889
    drm_i915_private_t *dev_priv = main_device->dev_private;
-
 
890
    struct intel_ring_buffer *ring;
-
 
891
    struct context *context;
-
 
892
 
-
 
893
    bitmap_t  *bitmap;
-
 
894
    rect_t     winrc;
-
 
895
    clip_t     dst_clip;
-
 
896
    clip_t     src_clip;
-
 
897
    u32_t      width;
-
 
898
    u32_t      height;
-
 
899
 
-
 
900
    u32_t      br13, cmd, slot_mask, *b;
-
 
901
    u32_t      offset;
-
 
902
    u8         slot;
-
 
903
    int        n=0;
-
 
904
    int        ret;
-
 
905
 
-
 
906
    if(unlikely(hbitmap==0))
-
 
907
        return -1;
-
 
908
 
-
 
909
    bitmap = (bitmap_t*)hmm_get_data(&bm_mm, hbitmap);
-
 
910
 
-
 
911
    if(unlikely(bitmap==NULL))
-
 
912
        return -1;
-
 
913
 
-
 
914
    context = get_context(main_device);
-
 
915
    if(unlikely(context == NULL))
-
 
916
        return -1;
-
 
917
 
-
 
918
    GetWindowRect(&winrc);
-
 
919
    {
-
 
920
        static warn_count;
-
 
921
 
-
 
922
        if(warn_count < 1)
-
 
923
        {
-
 
924
            printf("left %d top %d right %d bottom %d\n",
-
 
925
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
-
 
926
            printf("bitmap width %d height %d\n", w, h);
-
 
927
            warn_count++;
-
 
928
        };
-
 
929
    };
-
 
930
 
-
 
931
 
-
 
932
    dst_clip.xmin   = 0;
-
 
933
    dst_clip.ymin   = 0;
-
 
934
    dst_clip.xmax   = winrc.right-winrc.left;
-
 
935
    dst_clip.ymax   = winrc.bottom -winrc.top;
-
 
936
 
-
 
937
    src_clip.xmin   = 0;
-
 
938
    src_clip.ymin   = 0;
-
 
939
    src_clip.xmax   = bitmap->width  - 1;
-
 
940
    src_clip.ymax   = bitmap->height - 1;
-
 
941
 
-
 
942
    width  = w;
-
 
943
    height = h;
-
 
944
 
-
 
945
    if( blit_clip(&dst_clip, &dst_x, &dst_y,
-
 
946
                  &src_clip, &src_x, &src_y,
-
 
947
                  &width, &height) )
-
 
948
        return 0;
-
 
949
 
-
 
950
    dst_x+= winrc.left;
-
 
951
    dst_y+= winrc.top;
-
 
952
 
-
 
953
    slot = *((u8*)CURRENT_TASK);
-
 
954
 
-
 
955
    slot_mask = (u32_t)slot<<24;
-
 
956
 
-
 
957
    {
-
 
958
#if 0
-
 
959
        static v4si write_mask = {0xFF000000, 0xFF000000,
-
 
960
                                  0xFF000000, 0xFF000000};
-
 
961
 
-
 
962
        u8* src_offset;
-
 
963
        u8* dst_offset;
-
 
964
 
-
 
965
        src_offset = (u8*)(src_y*bitmap->pitch + src_x*4);
-
 
966
        src_offset += (u32)bitmap->uaddr;
-
 
967
 
-
 
968
        dst_offset = (u8*)(dst_y*os_display->width + dst_x);
-
 
969
        dst_offset+= get_display_map();
-
 
970
 
-
 
971
        u32_t tmp_h = height;
-
 
972
 
-
 
973
        __asm__ __volatile__ (
-
 
974
        "movdqa     %[write_mask],  %%xmm7    \n"
-
 
975
        "movd       %[slot_mask],   %%xmm6    \n"
-
 
976
        "punpckldq  %%xmm6, %%xmm6            \n"
-
 
977
        "punpcklqdq %%xmm6, %%xmm6            \n"
-
 
978
        :: [write_mask] "m" (write_mask),
-
 
979
           [slot_mask]  "g" (slot_mask)
-
 
980
        :"xmm7", "xmm6");
-
 
981
 
-
 
982
        while( tmp_h--)
-
 
983
        {
-
 
984
            u32_t tmp_w = width;
-
 
985
 
-
 
986
            u8* tmp_src = src_offset;
-
 
987
            u8* tmp_dst = dst_offset;
-
 
988
 
-
 
989
            src_offset+= bitmap->pitch;
-
 
990
            dst_offset+= os_display->width;
-
 
991
 
-
 
992
            while( tmp_w >= 8 )
-
 
993
            {
-
 
994
                __asm__ __volatile__ (
-
 
995
                "movq       (%0),   %%xmm0            \n"
-
 
996
                "punpcklbw  %%xmm0, %%xmm0            \n"
-
 
997
                "movdqa     %%xmm0, %%xmm1            \n"
-
 
998
                "punpcklwd  %%xmm0, %%xmm0            \n"
-
 
999
                "punpckhwd  %%xmm1, %%xmm1            \n"
-
 
1000
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1001
                "pcmpeqb    %%xmm6, %%xmm1            \n"
-
 
1002
                "maskmovdqu %%xmm7, %%xmm0            \n"
-
 
1003
                "addl       $16, %%edi                \n"
-
 
1004
                "maskmovdqu %%xmm7, %%xmm1            \n"
-
 
1005
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1006
                :"xmm0", "xmm1");
-
 
1007
                __asm__ __volatile__ ("":::"edi");
-
 
1008
                tmp_w -= 8;
-
 
1009
                tmp_src += 32;
-
 
1010
                tmp_dst += 8;
-
 
1011
            };
-
 
1012
 
-
 
1013
            if( tmp_w >= 4 )
-
 
1014
            {
-
 
1015
                __asm__ __volatile__ (
-
 
1016
                "movd       (%0),   %%xmm0            \n"
-
 
1017
                "punpcklbw  %%xmm0, %%xmm0            \n"
-
 
1018
                "punpcklwd  %%xmm0, %%xmm0            \n"
-
 
1019
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1020
                "maskmovdqu %%xmm7, %%xmm0            \n"
-
 
1021
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1022
                :"xmm0");
-
 
1023
                tmp_w -= 4;
-
 
1024
                tmp_src += 16;
-
 
1025
                tmp_dst += 4;
-
 
1026
            };
-
 
1027
 
-
 
1028
            while( tmp_w--)
-
 
1029
            {
-
 
1030
                *(tmp_src+3) = (*tmp_dst==slot)?0xFF:0x00;
-
 
1031
                tmp_src+=4;
-
 
1032
                tmp_dst++;
-
 
1033
            };
-
 
1034
        };
-
 
1035
#else
-
 
1036
        u8* src_offset;
-
 
1037
        u8* dst_offset;
-
 
1038
        u32 ifl;
-
 
1039
 
-
 
1040
        src_offset = (u8*)(src_y*bitmap->pitch + src_x*4);
-
 
1041
        src_offset += (u32)bitmap->uaddr;
-
 
1042
 
-
 
1043
        dst_offset = (u8*)(dst_y*os_display->width + dst_x);
-
 
1044
        dst_offset+= get_display_map();
-
 
1045
 
-
 
1046
        u32_t tmp_h = height;
-
 
1047
 
-
 
1048
      ifl = safe_cli();
-
 
1049
        while( tmp_h--)
-
 
1050
        {
-
 
1051
            u32_t tmp_w = width;
-
 
1052
 
-
 
1053
            u8* tmp_src = src_offset;
-
 
1054
            u8* tmp_dst = dst_offset;
-
 
1055
 
-
 
1056
            src_offset+= bitmap->pitch;
-
 
1057
            dst_offset+= os_display->width;
-
 
1058
 
-
 
1059
            while( tmp_w--)
-
 
1060
            {
-
 
1061
                *(tmp_src+3) = (*tmp_dst==slot)?0xFF:0x00;
-
 
1062
                tmp_src+=4;
-
 
1063
                tmp_dst++;
-
 
1064
            };
-
 
1065
        };
-
 
1066
      safe_sti(ifl);
-
 
1067
    }
-
 
1068
#endif
-
 
1069
 
-
 
1070
    {
-
 
1071
        static warn_count;
-
 
1072
 
-
 
1073
        if(warn_count < 1)
-
 
1074
        {
-
 
1075
            printf("blit width %d height %d\n",
-
 
1076
                    width, height);
-
 
1077
            warn_count++;
-
 
1078
        };
-
 
1079
    };
-
 
1080
 
-
 
1081
 
-
 
1082
    if((context->cmd_buffer & 0xFC0)==0xFC0)
-
 
1083
        context->cmd_buffer&= 0xFFFFF000;
-
 
1084
 
-
 
1085
    b = (u32_t*)ALIGN(context->cmd_buffer,16);
-
 
1086
 
-
 
1087
    offset = context->cmd_offset + ((u32_t)b & 0xFFF);
-
 
1088
 
-
 
1089
    cmd = XY_SRC_COPY_CHROMA_CMD | BLT_WRITE_RGB | BLT_WRITE_ALPHA;
-
 
1090
    cmd |= 3 << 17;
-
 
1091
 
-
 
1092
    br13 = os_display->pitch;
-
 
1093
    br13|= ROP_COPY_SRC << 16;
-
 
1094
    br13|= FORMAT8888   << 24;
-
 
1095
 
-
 
1096
    b[n++] = cmd;
-
 
1097
    b[n++] = br13;
-
 
1098
    b[n++] = (dst_y << 16) | dst_x;                   // left, top
-
 
1099
    b[n++] = ((dst_y+height)<< 16)|(dst_x+width); // bottom, right
-
 
1100
    b[n++] = 0;                          // destination
-
 
1101
    b[n++] = (src_y << 16) | src_x;      // source left & top
-
 
1102
    b[n++] = bitmap->pitch;              // source pitch
-
 
1103
    b[n++] = bitmap->gaddr;              // source
-
 
1104
 
-
 
1105
    b[n++] = 0;                          // Transparency Color Low
-
 
1106
    b[n++] = 0x00FFFFFF;                 // Transparency Color High
-
 
1107
 
-
 
1108
    b[n++] = MI_BATCH_BUFFER_END;
-
 
1109
    if( n & 1)
-
 
1110
        b[n++] = MI_NOOP;
-
 
1111
 
-
 
1112
    context->cmd_buffer+= n*4;
-
 
1113
 
-
 
1114
    context->obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND;
-
 
1115
 
-
 
1116
 
-
 
1117
    mutex_lock(&main_device->struct_mutex);
-
 
1118
 
-
 
1119
    i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
-
 
1120
 
-
 
1121
    if (HAS_BLT(main_device))
-
 
1122
    {
-
 
1123
        u32 seqno;
-
 
1124
        int i;
-
 
1125
 
-
 
1126
        ring = &dev_priv->ring[BCS];
-
 
1127
//        printf("dispatch...  ");
-
 
1128
 
-
 
1129
        i915_gem_object_sync(bitmap->obj, ring);
-
 
1130
        intel_ring_invalidate_all_caches(ring);
-
 
1131
 
-
 
1132
        seqno = i915_gem_next_request_seqno(ring);
-
 
1133
//        printf("seqno = %d\n", seqno);
-
 
1134
 
-
 
1135
        for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++) {
-
 
1136
            if (seqno < ring->sync_seqno[i]) {
-
 
1137
            /* The GPU can not handle its semaphore value wrapping,
-
 
1138
             * so every billion or so execbuffers, we need to stall
-
 
1139
             * the GPU in order to reset the counters.
-
 
1140
             */
-
 
1141
                DRM_DEBUG("wrap seqno\n");
-
 
1142
 
-
 
1143
                ret = i915_gpu_idle(main_device);
-
 
1144
                if (ret)
-
 
1145
                    goto fail;
-
 
1146
                i915_gem_retire_requests(main_device);
-
 
1147
 
-
 
1148
                BUG_ON(ring->sync_seqno[i]);
-
 
1149
            }
-
 
1150
        }
-
 
1151
 
-
 
1152
        ret = ring->dispatch_execbuffer(ring, offset, n*4);
-
 
1153
        if (ret)
-
 
1154
            goto fail;
-
 
1155
//        printf("done\n");
-
 
1156
 
-
 
1157
        bitmap->obj->base.read_domains = bitmap->obj->base.pending_read_domains;
-
 
1158
        bitmap->obj->base.write_domain = bitmap->obj->base.pending_write_domain;
-
 
1159
        bitmap->obj->fenced_gpu_access = bitmap->obj->pending_fenced_gpu_access;
-
 
1160
 
-
 
1161
        i915_gem_object_move_to_active(bitmap->obj, ring, seqno);
-
 
1162
 
-
 
1163
        i915_gem_execbuffer_retire_commands(main_device, NULL, ring);
-
 
1164
//        printf("retire\n");
-
 
1165
    }
-
 
1166
    else
-
 
1167
    {
-
 
1168
        ring = &dev_priv->ring[RCS];
-
 
1169
        ring->dispatch_execbuffer(ring, offset, n*4);
-
 
1170
        ring->flush(ring, 0, I915_GEM_DOMAIN_RENDER);
-
 
1171
    };
-
 
1172
 
-
 
1173
//    bitmap->obj->base.read_domains = I915_GEM_DOMAIN_CPU;
-
 
1174
//    bitmap->obj->base.write_domain = I915_GEM_DOMAIN_CPU;
-
 
1175
 
-
 
1176
    mutex_unlock(&main_device->struct_mutex);
-
 
1177
fail:
-
 
1178
    return ret;
-
 
1179
};
-
 
1180
 
-
 
1181
 
-
 
1182
#if 0
-
 
1183
 
-
 
1184
    i915_gem_execbuffer_retire_commands(dev, ring);
-
 
1185
/* For display hotplug interrupt */
-
 
1186
static void
-
 
1187
ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
-
 
1188
{
-
 
1189
    if ((dev_priv->irq_mask & mask) != 0) {
-
 
1190
        dev_priv->irq_mask &= ~mask;
-
 
1191
        I915_WRITE(DEIMR, dev_priv->irq_mask);
-
 
1192
        POSTING_READ(DEIMR);
-
 
1193
    }
-
 
1194
}
-
 
1195
 
-
 
1196
static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
-
 
1197
{
-
 
1198
    drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
-
 
1199
    unsigned long irqflags;
-
 
1200
 
-
 
1201
//    if (!i915_pipe_enabled(dev, pipe))
-
 
1202
//        return -EINVAL;
-
 
1203
 
-
 
1204
    spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
-
 
1205
    ironlake_enable_display_irq(dev_priv, (pipe == 0) ?
-
 
1206
                    DE_PIPEA_VBLANK : DE_PIPEB_VBLANK);
-
 
1207
    spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
-
 
1208
 
-
 
1209
    return 0;
-
 
1210
}
-
 
1211
 
-
 
1212
 
-
 
1213
 
-
 
1214
static int i915_interrupt_info(struct drm_device *dev)
-
 
1215
{
-
 
1216
    drm_i915_private_t *dev_priv = dev->dev_private;
-
 
1217
    int ret, i, pipe;
-
 
1218
 
-
 
1219
    if (!HAS_PCH_SPLIT(dev)) {
-
 
1220
        dbgprintf("Interrupt enable:    %08x\n",
-
 
1221
               I915_READ(IER));
-
 
1222
        dbgprintf("Interrupt identity:  %08x\n",
-
 
1223
               I915_READ(IIR));
-
 
1224
        dbgprintf("Interrupt mask:      %08x\n",
-
 
1225
               I915_READ(IMR));
-
 
1226
        for_each_pipe(pipe)
-
 
1227
            dbgprintf("Pipe %c stat:         %08x\n",
-
 
1228
                   pipe_name(pipe),
-
 
1229
                   I915_READ(PIPESTAT(pipe)));
-
 
1230
    } else {
-
 
1231
        dbgprintf("North Display Interrupt enable:      %08x\n",
-
 
1232
           I915_READ(DEIER));
-
 
1233
        dbgprintf("North Display Interrupt identity:    %08x\n",
-
 
1234
           I915_READ(DEIIR));
-
 
1235
        dbgprintf("North Display Interrupt mask:        %08x\n",
-
 
1236
           I915_READ(DEIMR));
-
 
1237
        dbgprintf("South Display Interrupt enable:      %08x\n",
-
 
1238
           I915_READ(SDEIER));
-
 
1239
        dbgprintf("South Display Interrupt identity:    %08x\n",
-
 
1240
           I915_READ(SDEIIR));
-
 
1241
        dbgprintf("South Display Interrupt mask:        %08x\n",
-
 
1242
           I915_READ(SDEIMR));
-
 
1243
        dbgprintf("Graphics Interrupt enable:           %08x\n",
-
 
1244
           I915_READ(GTIER));
-
 
1245
        dbgprintf("Graphics Interrupt identity:         %08x\n",
-
 
1246
           I915_READ(GTIIR));
-
 
1247
        dbgprintf("Graphics Interrupt mask:             %08x\n",
-
 
1248
               I915_READ(GTIMR));
-
 
1249
    }
-
 
1250
    dbgprintf("Interrupts received: %d\n",
-
 
1251
           atomic_read(&dev_priv->irq_received));
-
 
1252
    for (i = 0; i < I915_NUM_RINGS; i++) {
-
 
1253
        if (IS_GEN6(dev) || IS_GEN7(dev)) {
-
 
1254
            printf("Graphics Interrupt mask (%s):       %08x\n",
-
 
1255
                   dev_priv->ring[i].name,
-
 
1256
                   I915_READ_IMR(&dev_priv->ring[i]));
-
 
1257
        }
-
 
1258
//        i915_ring_seqno_info(m, &dev_priv->ring[i]);
-
 
1259
    }
-
 
1260
 
-
 
1261
    return 0;
-
 
1262
}
-
 
1263
 
-
 
1264
void execute_buffer (struct drm_i915_gem_object *buffer, uint32_t offset,
-
 
1265
                     int size)
-
 
1266
{
-
 
1267
    struct intel_ring_buffer *ring;
-
 
1268
    drm_i915_private_t *dev_priv = main_device->dev_private;
-
 
1269
    u32 invalidate;
-
 
1270
    u32 seqno = 2;
-
 
1271
 
-
 
1272
    offset += buffer->gtt_offset;
-
 
1273
//    dbgprintf("execute %x size %d\n", offset, size);
-
 
1274
 
-
 
1275
//    asm volatile(
-
 
1276
//    "mfence \n"
-
 
1277
//    "wbinvd \n"
-
 
1278
//    "mfence  \n"
-
 
1279
//    :::"memory");
-
 
1280
 
-
 
1281
    ring = &dev_priv->ring[RCS];
-
 
1282
    ring->dispatch_execbuffer(ring, offset, size);
-
 
1283
 
-
 
1284
    invalidate = I915_GEM_DOMAIN_COMMAND;
-
 
1285
    if (INTEL_INFO(main_device)->gen >= 4)
-
 
1286
        invalidate |= I915_GEM_DOMAIN_SAMPLER;
-
 
1287
    if (ring->flush(ring, invalidate, 0))
-
 
1288
        i915_gem_next_request_seqno(ring);
-
 
1289
 
-
 
1290
    ring->irq_get(ring);
-
 
1291
 
-
 
1292
    ring->add_request(ring, &seqno);
-
 
1293
 
-
 
1294
//    i915_interrupt_info(main_device);
-
 
1295
 
-
 
1296
};
-
 
1297
 
-
 
1298
 
-
 
1299
int blit_textured(u32 hbitmap, int  dst_x, int dst_y,
-
 
1300
               int src_x, int src_y, u32 w, u32 h)
-
 
1301
{
-
 
1302
    drm_i915_private_t *dev_priv = main_device->dev_private;
-
 
1303
 
-
 
1304
    bitmap_t  *src_bitmap, *dst_bitmap;
-
 
1305
    bitmap_t   screen;
-
 
1306
 
-
 
1307
    rect_t     winrc;
-
 
1308
 
-
 
1309
//    dbgprintf("  handle: %d dx %d dy %d sx %d sy %d w %d h %d\n",
-
 
1310
//              hbitmap, dst_x, dst_y, src_x, src_y, w, h);
-
 
1311
 
-
 
1312
    if(unlikely(hbitmap==0))
-
 
1313
        return -1;
-
 
1314
 
-
 
1315
    src_bitmap = (bitmap_t*)hman_get_data(&bm_man, hbitmap);
-
 
1316
//    dbgprintf("bitmap %x\n", src_bitmap);
-
 
1317
 
-
 
1318
    if(unlikely(src_bitmap==NULL))
-
 
1319
        return -1;
-
 
1320
 
-
 
1321
    GetWindowRect(&winrc);
-
 
1322
 
-
 
1323
    screen.pitch  = os_display->pitch;
-
 
1324
    screen.gaddr  = 0;
-
 
1325
    screen.width  = os_display->width;
-
 
1326
    screen.height = os_display->height;
-
 
1327
    screen.obj    = (void*)-1;
-
 
1328
 
-
 
1329
    dst_bitmap = &screen;
-
 
1330
 
-
 
1331
    dst_x+= winrc.left;
-
 
1332
    dst_y+= winrc.top;
-
 
1333
 
-
 
1334
    sna_blit_copy(dst_bitmap, dst_x, dst_y, w, h, src_bitmap, src_x, src_y);
-
 
1335
 
-
 
1336
};
-
 
1337
 
-
 
1338
int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
-
 
1339
                  int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
-
 
1340
                  bitmap_t *mask_bitmap);
-
 
1341
 
-
 
1342
 
-
 
1343
int blit_tex(u32 hbitmap, int  dst_x, int dst_y,
-
 
1344
             int src_x, int src_y, u32 w, u32 h)
-
 
1345
{
-
 
1346
    drm_i915_private_t *dev_priv = main_device->dev_private;
-
 
1347
    struct context *ctx;
-
 
1348
 
-
 
1349
    bitmap_t  *src_bitmap, *dst_bitmap;
-
 
1350
    bitmap_t   screen;
-
 
1351
    int        ret;
-
 
1352
 
-
 
1353
    bitmap_t *mask_bitmap;
-
 
1354
    rect_t     winrc;
-
 
1355
 
-
 
1356
//    dbgprintf("  handle: %d dx %d dy %d sx %d sy %d w %d h %d\n",
-
 
1357
//              hbitmap, dst_x, dst_y, src_x, src_y, w, h);
-
 
1358
 
-
 
1359
    if(unlikely(hbitmap==0))
-
 
1360
        return -1;
-
 
1361
 
-
 
1362
    src_bitmap = (bitmap_t*)hman_get_data(&bm_man, hbitmap);
-
 
1363
//    dbgprintf("bitmap %x\n", src_bitmap);
-
 
1364
 
-
 
1365
    if(unlikely(src_bitmap==NULL))
-
 
1366
        return -1;
-
 
1367
 
-
 
1368
    ctx = get_context();
-
 
1369
    if(unlikely(ctx==NULL))
-
 
1370
    {
-
 
1371
        ret = create_context();
-
 
1372
        if(ret!=0)
-
 
1373
            return -1;
-
 
1374
 
-
 
1375
        ctx = get_context();
-
 
1376
    };
-
 
1377
 
-
 
1378
    mask_bitmap = ctx->mask;
-
 
1379
 
-
 
1380
    GetWindowRect(&winrc);
-
 
1381
    dst_x+= winrc.left;
-
 
1382
    dst_y+= winrc.top;
-
 
1383
 
-
 
1384
 
-
 
1385
    if(ctx->seqno != os_display->mask_seqno)
-
 
1386
    {
-
 
1387
        u8* src_offset;
-
 
1388
        u8* dst_offset;
-
 
1389
        u32 slot;
-
 
1390
        u32 ifl;
-
 
1391
 
-
 
1392
        ret = gem_object_lock(mask_bitmap->obj);
-
 
1393
        if(ret !=0 )
-
 
1394
        {
-
 
1395
            dbgprintf("%s fail\n", __FUNCTION__);
-
 
1396
            return ret;
-
 
1397
        };
-
 
1398
 
-
 
1399
//        printf("width %d height %d\n", winrc.right, winrc.bottom);
-
 
1400
 
-
 
1401
        mask_bitmap->width  = winrc.right;
-
 
1402
        mask_bitmap->height = winrc.bottom;
-
 
1403
        mask_bitmap->pitch =  ALIGN(w,64);
-
 
1404
 
-
 
1405
        slot = *((u8*)CURRENT_TASK);
-
 
1406
//        slot = 0x01;
-
 
1407
 
-
 
1408
        slot|= (slot<<8)|(slot<<16)|(slot<<24);
-
 
1409
 
-
 
1410
 
-
 
1411
        __asm__ __volatile__ (
-
 
1412
        "movd       %[slot],   %%xmm6    \n"
-
 
1413
        "punpckldq  %%xmm6, %%xmm6            \n"
-
 
1414
        "punpcklqdq %%xmm6, %%xmm6            \n"
-
 
1415
        :: [slot]  "m" (slot)
-
 
1416
        :"xmm6");
-
 
1417
 
-
 
1418
        src_offset = mask_bitmap->uaddr;
-
 
1419
 
-
 
1420
        dst_offset = (u8*)(dst_y*os_display->width + dst_x);
-
 
1421
        dst_offset+= get_display_map();
-
 
1422
 
-
 
1423
        u32_t tmp_h = mask_bitmap->height;
-
 
1424
 
-
 
1425
      ifl = safe_cli();
-
 
1426
        while( tmp_h--)
-
 
1427
        {
-
 
1428
            int tmp_w = mask_bitmap->width;
-
 
1429
 
-
 
1430
            u8* tmp_src = src_offset;
-
 
1431
            u8* tmp_dst = dst_offset;
-
 
1432
 
-
 
1433
            src_offset+= mask_bitmap->pitch;
-
 
1434
            dst_offset+= os_display->width;
-
 
1435
 
-
 
1436
//            while( tmp_w--)
-
 
1437
//            {
-
 
1438
//                *(tmp_src) = (*tmp_dst==slot)?0x1:0x00;
-
 
1439
//                tmp_src++;
-
 
1440
//                tmp_dst++;
-
 
1441
//            };
-
 
1442
            while(tmp_w >= 64)
-
 
1443
            {
-
 
1444
                __asm__ __volatile__ (
-
 
1445
                "movdqu     (%0),   %%xmm0            \n"
-
 
1446
                "movdqu   16(%0),   %%xmm1            \n"
-
 
1447
                "movdqu   32(%0),   %%xmm2            \n"
-
 
1448
                "movdqu   48(%0),   %%xmm3            \n"
-
 
1449
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1450
                "pcmpeqb    %%xmm6, %%xmm1            \n"
-
 
1451
                "pcmpeqb    %%xmm6, %%xmm2            \n"
-
 
1452
                "pcmpeqb    %%xmm6, %%xmm3            \n"
-
 
1453
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1454
                "movdqa     %%xmm1, 16(%%edi)         \n"
-
 
1455
                "movdqa     %%xmm2, 32(%%edi)         \n"
-
 
1456
                "movdqa     %%xmm3, 48(%%edi)         \n"
-
 
1457
 
-
 
1458
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1459
                :"xmm0","xmm1","xmm2","xmm3");
-
 
1460
                tmp_w -= 64;
-
 
1461
                tmp_src += 64;
-
 
1462
                tmp_dst += 64;
-
 
1463
            }
-
 
1464
 
-
 
1465
            if( tmp_w >= 32 )
-
 
1466
            {
-
 
1467
                __asm__ __volatile__ (
-
 
1468
                "movdqu     (%0),   %%xmm0            \n"
-
 
1469
                "movdqu   16(%0),   %%xmm1            \n"
-
 
1470
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1471
                "pcmpeqb    %%xmm6, %%xmm1            \n"
-
 
1472
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1473
                "movdqa     %%xmm1, 16(%%edi)         \n"
-
 
1474
 
-
 
1475
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1476
                :"xmm0","xmm1");
-
 
1477
                tmp_w -= 32;
-
 
1478
                tmp_src += 32;
-
 
1479
                tmp_dst += 32;
-
 
1480
            }
-
 
1481
 
-
 
1482
            while( tmp_w > 0 )
-
 
1483
            {
-
 
1484
                __asm__ __volatile__ (
-
 
1485
                "movdqu     (%0),   %%xmm0            \n"
-
 
1486
                "pcmpeqb    %%xmm6, %%xmm0            \n"
-
 
1487
                "movdqa     %%xmm0,   (%%edi)         \n"
-
 
1488
                :: "r" (tmp_dst), "D" (tmp_src)
-
 
1489
                :"xmm0");
-
 
1490
                tmp_w -= 16;
-
 
1491
                tmp_src += 16;
-
 
1492
                tmp_dst += 16;
-
 
1493
            }
-
 
1494
        };
-
 
1495
      safe_sti(ifl);
-
 
1496
      ctx->seqno = os_display->mask_seqno;
-
 
1497
    }
-
 
1498
 
-
 
1499
    screen.pitch  = os_display->pitch;
-
 
1500
    screen.gaddr  = 0;
-
 
1501
    screen.width  = os_display->width;
-
 
1502
    screen.height = os_display->height;
-
 
1503
    screen.obj    = (void*)-1;
-
 
1504
 
-
 
1505
    dst_bitmap = &screen;
-
 
1506
 
-
 
1507
 
-
 
1508
    sna_blit_tex(dst_bitmap, dst_x, dst_y, w, h, src_bitmap, src_x, src_y,
-
 
1509
                 mask_bitmap);
-
 
1510
 
-
 
1511
//    asm volatile ("int3");
-
 
1512
};
-
 
1513
 
-
 
1514
 
-
 
1515
#endif
-
 
1516
 
-
 
1517
 
-
 
1518
#endif
-
 
1519
 
-
 
1520
 
-
 
1521
 
-
 
1522
 
830
 
1523
 
831
 
1524
void __stdcall run_workqueue(struct workqueue_struct *cwq)
832
void __stdcall run_workqueue(struct workqueue_struct *cwq)
Line 1525... Line 833...
1525
{
833
{