Subversion Repositories Kolibri OS

Rev

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

Rev 3031 Rev 3033
Line 13... Line 13...
13
#include 
13
#include 
14
 
14
 
Line 15... Line 15...
15
#include 
15
#include 
Line -... Line 16...
-
 
16
 
16
 
17
#include "hmm.h"
Line 17... Line 18...
17
#include "bitmap.h"
18
#include "bitmap.h"
Line 273... Line 274...
273
    struct drm_framebuffer  *fb;
274
    struct drm_framebuffer  *fb;
274
 
275
 
Line 275... Line 276...
275
    cursor_t  *cursor;
276
    cursor_t  *cursor;
276
    u32_t      ifl;
277
    u32_t      ifl;
-
 
278
    int        err;
Line 277... Line 279...
277
 
279
 
Line 278... Line 280...
278
//    ENTER();
280
//    ENTER();
279
 
281
 
Line 364... Line 366...
364
        select_cursor_kms(os_display->cursor);
366
        select_cursor_kms(os_display->cursor);
365
    };
367
    };
366
    safe_sti(ifl);
368
    safe_sti(ifl);
Line 367... Line -...
367
 
-
 
368
#define XY_COLOR_BLT        ((2<<29)|(0x50<<22)|(0x4))
-
 
369
#define BLT_WRITE_ALPHA     (1<<21)
-
 
370
#define BLT_WRITE_RGB       (1<<20)
-
 
371
 
-
 
372
#if 0
-
 
373
 
-
 
374
#if 1
-
 
375
    {
-
 
376
 
-
 
377
        drm_i915_private_t *dev_priv = dev->dev_private;
-
 
378
        struct drm_i915_gem_object *obj;
-
 
379
        struct intel_ring_buffer *ring;
-
 
380
 
-
 
381
        obj = i915_gem_alloc_object(dev, 4096);
-
 
382
        i915_gem_object_pin(obj, 4096, true, true);
-
 
383
 
-
 
384
        cmd_buffer = MapIoMem((addr_t)obj->pages.page[0], 4096, PG_SW|PG_NOCACHE);
-
 
385
        cmd_offset = obj->gtt_offset;
-
 
386
    };
-
 
387
#endif
-
 
388
 
369
 
Line 389... Line -...
389
    main_device = dev;
-
 
390
 
-
 
391
    int err;
370
    main_device = dev;
392
 
371
 
393
    err = init_bitmaps();
372
    err = init_bitmaps();
394
    if( !err )
373
    if( !err )
395
    {
374
    {
Line 396... Line -...
396
        printf("Initialize bitmap manager\n");
-
 
397
    };
-
 
Line 398... Line 375...
398
 
375
        printf("Initialize bitmap manager\n");
Line 399... Line 376...
399
    sna_init();
376
    };
400
#endif
377
 
Line 655... Line 632...
655
    move_cursor_kms(cursor, intel_crtc->cursor_x, intel_crtc->cursor_y);
632
    move_cursor_kms(cursor, intel_crtc->cursor_x, intel_crtc->cursor_y);
656
    return old;
633
    return old;
657
};
634
};
Line 658... Line -...
658
 
-
 
Line -... Line 635...
-
 
635
 
-
 
636
 
-
 
637
 
659
#if 0
638
 
Line 660... Line 639...
660
 
639
 
661
#define XY_SRC_COPY_BLT_CMD     ((2<<29)|(0x53<<22)|6)
640
extern struct hmm bm_mm;
662
 
641
 
Line 684... Line 663...
684
    addr+= sizeof(display_t);            /*  shoot me  */
663
    addr+= sizeof(display_t);            /*  shoot me  */
685
    return *(u32_t*)addr;
664
    return *(u32_t*)addr;
686
}
665
}
687
 
666
 
Line -... Line 667...
-
 
667
#define XY_COLOR_BLT                ((2<<29)|(0x50<<22)|(0x4))
-
 
668
#define XY_SRC_COPY_BLT_CMD         ((2<<29)|(0x53<<22)|6)
688
#define XY_SRC_COPY_CHROMA_CMD     ((2<<29)|(0x73<<22)|8)
669
#define XY_SRC_COPY_CHROMA_CMD     ((2<<29)|(0x73<<22)|8)
689
#define ROP_COPY_SRC               0xCC
670
#define ROP_COPY_SRC               0xCC
690
#define FORMAT8888                 3
671
#define FORMAT8888                 3
Line -... Line 672...
-
 
672
 
-
 
673
#define BLT_WRITE_ALPHA             (1<<21)
-
 
674
#define BLT_WRITE_RGB               (1<<20)
-
 
675
 
-
 
676
 
691
 
677
 
Line -... Line 678...
-
 
678
typedef int v4si __attribute__ ((vector_size (16)));
-
 
679
 
-
 
680
 
-
 
681
static void
-
 
682
i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-
 
683
                    struct intel_ring_buffer *ring)
-
 
684
{
-
 
685
    struct drm_i915_gem_request *request;
-
 
686
    u32 invalidate;
-
 
687
    u32 req;
-
 
688
    /*
-
 
689
     * Ensure that the commands in the batch buffer are
-
 
690
     * finished before the interrupt fires.
-
 
691
     *
-
 
692
     * The sampler always gets flushed on i965 (sigh).
-
 
693
     */
-
 
694
    invalidate = I915_GEM_DOMAIN_COMMAND;
-
 
695
    if (INTEL_INFO(dev)->gen >= 4)
-
 
696
        invalidate |= I915_GEM_DOMAIN_SAMPLER;
-
 
697
    if (ring->flush(ring, invalidate, 0)) {
-
 
698
        i915_gem_next_request_seqno(ring);
-
 
699
        return;
-
 
700
    }
-
 
701
 
-
 
702
    /* Add a breadcrumb for the completion of the batch buffer */
-
 
703
    if (request == NULL || i915_add_request(ring, NULL, &req)) {
-
 
704
        i915_gem_next_request_seqno(ring);
-
 
705
    }
-
 
706
}
-
 
707
 
-
 
708
 
692
typedef int v4si __attribute__ ((vector_size (16)));
709
 
693
 
710
 
694
 
711
 
695
int blit_video(u32 hbitmap, int  dst_x, int dst_y,
712
int blit_video(u32 hbitmap, int  dst_x, int dst_y,
696
               int src_x, int src_y, u32 w, u32 h)
713
               int src_x, int src_y, u32 w, u32 h)
-
 
714
{
Line 697... Line 715...
697
{
715
    drm_i915_private_t *dev_priv = main_device->dev_private;
698
    drm_i915_private_t *dev_priv = main_device->dev_private;
716
    struct intel_ring_buffer *ring;
699
    struct intel_ring_buffer *ring;
717
    struct context *context;
700
 
718
 
Line 712... Line 730...
712
 
730
 
Line 713... Line 731...
713
    if(unlikely(hbitmap==0))
731
    if(unlikely(hbitmap==0))
714
        return -1;
732
        return -1;
Line 715... Line 733...
715
 
733
 
Line 716... Line 734...
716
    bitmap = (bitmap_t*)hman_get_data(&bm_man, hbitmap);
734
    bitmap = (bitmap_t*)hmm_get_data(&bm_mm, hbitmap);
717
 
735
 
Line -... Line 736...
-
 
736
    if(unlikely(bitmap==NULL))
-
 
737
        return -1;
-
 
738
 
Line 718... Line 739...
718
    if(unlikely(bitmap==NULL))
739
    context = get_context(main_device);
Line 719... Line 740...
719
        return -1;
740
    if(unlikely(context == NULL))
720
 
741
        return -1;
Line 858... Line 879...
858
      safe_sti(ifl);
879
      safe_sti(ifl);
859
    }
880
    }
860
#endif
881
#endif
861
 
882
 
Line 862... Line 883...
862
    if((cmd_buffer & 0xFC0)==0xFC0)
883
    if((context->cmd_buffer & 0xFC0)==0xFC0)
863
        cmd_buffer&= 0xFFFFF000;
884
        context->cmd_buffer&= 0xFFFFF000;
Line 864... Line 885...
864
 
885
 
Line 865... Line 886...
865
    b = (u32_t*)ALIGN(cmd_buffer,16);
886
    b = (u32_t*)ALIGN(context->cmd_buffer,16);
Line 866... Line 887...
866
 
887
 
867
    offset = cmd_offset + ((u32_t)b & 0xFFF);
888
    offset = context->cmd_offset + ((u32_t)b & 0xFFF);
Line 868... Line 889...
868
 
889
 
Line 888... Line 909...
888
    b[n++] = MI_BATCH_BUFFER_END;
909
    b[n++] = MI_BATCH_BUFFER_END;
889
    if( n & 1)
910
    if( n & 1)
890
        b[n++] = MI_NOOP;
911
        b[n++] = MI_NOOP;
Line -... Line 912...
-
 
912
 
-
 
913
    context->cmd_buffer+= n*4;
891
 
914
 
Line 892... Line 915...
892
    i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
915
//    i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
893
 
916
 
894
    if (HAS_BLT(main_device))
917
    if (HAS_BLT(main_device))
Line 895... Line 918...
895
    {
918
    {
-
 
919
        int ret;
896
        int ret;
920
 
-
 
921
        ring = &dev_priv->ring[BCS];
Line 897... Line 922...
897
 
922
//        printf("dispatch...  ");
898
        ring = &dev_priv->ring[BCS];
-
 
899
        ring->dispatch_execbuffer(ring, cmd_offset, n*4);
923
        ring->dispatch_execbuffer(ring, offset, n*4);
900
 
-
 
901
        ret = intel_ring_begin(ring, 4);
-
 
902
        if (ret)
-
 
903
            return ret;
-
 
904
 
-
 
905
        intel_ring_emit(ring, MI_FLUSH_DW);
-
 
906
        intel_ring_emit(ring, 0);
924
//        printf("done\n");
907
        intel_ring_emit(ring, 0);
925
 
908
        intel_ring_emit(ring, MI_NOOP);
926
        i915_gem_execbuffer_retire_commands(main_device, ring);
909
        intel_ring_advance(ring);
927
//        printf("retire\n");
910
    }
928
    }
911
    else
929
    else
912
    {
930
    {
Line 913... Line 931...
913
        ring = &dev_priv->ring[RCS];
931
        ring = &dev_priv->ring[RCS];
914
        ring->dispatch_execbuffer(ring, cmd_offset, n*4);
932
        ring->dispatch_execbuffer(ring, offset, n*4);
Line 923... Line 941...
923
    return -1;
941
    return -1;
924
};
942
};
925
 
943
 
Line -... Line 944...
-
 
944
 
-
 
945
#if 0
-
 
946
 
926
 
947
    i915_gem_execbuffer_retire_commands(dev, ring);
927
/* For display hotplug interrupt */
948
/* For display hotplug interrupt */
928
static void
949
static void
929
ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
950
ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
930
{
951
{
Line 1080... Line 1101...
1080
int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
1101
int sna_blit_tex(bitmap_t *dst_bitmap, int dst_x, int dst_y,
1081
                  int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
1102
                  int w, int h, bitmap_t *src_bitmap, int src_x, int src_y,
1082
                  bitmap_t *mask_bitmap);
1103
                  bitmap_t *mask_bitmap);
Line 1083... Line -...
1083
 
-
 
1084
int create_context();
-
 
Line 1085... Line 1104...
1085
struct context *get_context();
1104
 
1086
 
1105
 
1087
int blit_tex(u32 hbitmap, int  dst_x, int dst_y,
1106
int blit_tex(u32 hbitmap, int  dst_x, int dst_y,
1088
             int src_x, int src_y, u32 w, u32 h)
1107
             int src_x, int src_y, u32 w, u32 h)
Line 1255... Line 1274...
1255
//    asm volatile ("int3");
1274
//    asm volatile ("int3");
1256
};
1275
};
Line 1257... Line -...
1257
 
-
 
1258
 
-
 
1259
struct context *context_map[256];
-
 
1260
 
-
 
1261
void __attribute__((regparm(1))) destroy_context(struct context *context)
-
 
1262
{
-
 
1263
    printf("destroy context %x\n", context);
-
 
1264
 
-
 
1265
    context_map[context->slot] = NULL;
-
 
1266
    __DestroyObject(context);
-
 
1267
};
-
 
1268
 
-
 
1269
 
-
 
1270
int create_context()
-
 
1271
{
-
 
1272
    struct context *context;
-
 
1273
 
-
 
1274
    bitmap_t  *mask;
-
 
1275
    int        slot;
-
 
1276
 
-
 
1277
    struct io_call_10 io_10;
-
 
1278
    int    ret;
-
 
1279
 
-
 
1280
    slot = *((u8*)CURRENT_TASK);
-
 
1281
 
-
 
1282
    if(context_map[slot] != NULL)
-
 
1283
        return 0;
-
 
1284
 
-
 
1285
    context = CreateObject(GetPid(), sizeof(*context));
-
 
1286
//    printf("context %x\n", coontext);
-
 
1287
    if( context == NULL)
-
 
1288
        goto err1;
-
 
1289
    context->header.destroy = destroy_context;
-
 
1290
 
-
 
1291
    dbgprintf("Create mask surface\n");
-
 
1292
 
-
 
1293
    io_10.width  = os_display->width/4;     /* need bitmap format here */
-
 
1294
    io_10.height = os_display->height+1;
-
 
1295
    io_10.max_width  = os_display->width/4;
-
 
1296
    io_10.max_height = os_display->height+1;
-
 
1297
 
-
 
1298
    ret = create_surface(&io_10);
-
 
1299
    if(ret)
-
 
1300
        goto err2;
-
 
1301
 
-
 
1302
    mask= (bitmap_t*)hman_get_data(&bm_man, io_10.handle);
-
 
1303
    if(unlikely(mask == NULL)) /* something really terrible happend */
-
 
1304
        goto err2;
-
 
1305
    dbgprintf("done\n");
-
 
1306
 
-
 
1307
    context->mask  = mask;
-
 
1308
    context->seqno = os_display->mask_seqno-1;
-
 
1309
    context->slot  = slot;
-
 
1310
 
-
 
1311
    context_map[slot] = context;
-
 
1312
    return 0;
-
 
1313
 
-
 
1314
err2:
-
 
1315
    __DestroyObject(context);
-
 
1316
err1:
-
 
1317
    return -1;
-
 
1318
};
-
 
1319
 
-
 
1320
struct context *get_context()
-
 
1321
{
-
 
1322
 
-
 
1323
    int slot = *((u8*)CURRENT_TASK);
-
 
1324
 
-
 
1325
    return context_map[slot];
-
 
1326
}
1276