Subversion Repositories Kolibri OS

Rev

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

Rev 3033 Rev 3037
Line 140... Line 140...
140
            }
140
            }
141
        };
141
        };
142
    };
142
    };
143
 
143
 
Line 144... Line 144...
144
    printf("%s failed\n", __FUNCTION__);
144
    DRM_ERROR("%s failed\n", __FUNCTION__);
Line 145... Line 145...
145
 
145
 
Line 146... Line 146...
146
    return -1;
146
    return -1;
Line 200... Line 200...
200
        os_display->vrefresh = drm_mode_vrefresh(mode);
200
        os_display->vrefresh = drm_mode_vrefresh(mode);
201
 
201
 
Line 202... Line 202...
202
        sysSetScreen(fb->width, fb->height, fb->pitches[0]);
202
        sysSetScreen(fb->width, fb->height, fb->pitches[0]);
Line 203... Line 203...
203
 
203
 
204
        dbgprintf("new mode %d x %d pitch %d\n",
204
        DRM_DEBUG_KMS("new mode %d x %d pitch %d\n",
205
                       fb->width, fb->height, fb->pitches[0]);
205
                       fb->width, fb->height, fb->pitches[0]);
206
    }
206
    }
207
    else
207
    else
208
        DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
208
        DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
Line 247... Line 247...
247
        connector->encoder = encoder;
247
        connector->encoder = encoder;
Line 248... Line 248...
248
 
248
 
Line 249... Line 249...
249
        crtc = encoder->crtc;
249
        crtc = encoder->crtc;
250
 
250
 
251
        dbgprintf("CONNECTOR %x ID:  %d status %d encoder %x\n crtc %x",
251
        DRM_DEBUG_KMS("CONNECTOR %x ID:  %d status %d encoder %x\n crtc %x",
252
                   connector, connector->base.id,
252
                   connector, connector->base.id,
Line 253... Line 253...
253
                   connector->status, connector->encoder,
253
                   connector->status, connector->encoder,
Line 276... Line 276...
276
    cursor_t  *cursor;
276
    cursor_t  *cursor;
277
    u32_t      ifl;
277
    u32_t      ifl;
278
    int        err;
278
    int        err;
Line 279... Line -...
279
 
-
 
280
//    ENTER();
-
 
281
 
279
 
282
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
280
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
283
    {
281
    {
284
        if( connector->status != connector_status_connected)
282
        if( connector->status != connector_status_connected)
Line 285... Line 283...
285
            continue;
283
            continue;
286
 
284
 
287
        connector_funcs = connector->helper_private;
285
        connector_funcs = connector->helper_private;
288
        encoder = connector_funcs->best_encoder(connector);
286
        encoder = connector_funcs->best_encoder(connector);
289
        if( encoder == NULL)
287
        if( encoder == NULL)
290
        {
288
        {
291
            dbgprintf("CONNECTOR %x ID: %d no active encoders\n",
289
            DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n",
292
                      connector, connector->base.id);
290
                      connector, connector->base.id);
293
            continue;
291
            continue;
294
        }
292
        }
Line 295... Line 293...
295
        connector->encoder = encoder;
293
        connector->encoder = encoder;
296
        crtc = encoder->crtc;
294
        crtc = encoder->crtc;
297
 
295
 
298
        dbgprintf("CONNECTOR %x ID:%d status:%d ENCODER %x CRTC %x ID:%d\n",
296
        DRM_DEBUG_KMS("CONNECTOR %x ID:%d status:%d ENCODER %x CRTC %x ID:%d\n",
Line 299... Line 297...
299
               connector, connector->base.id,
297
               connector, connector->base.id,
300
               connector->status, connector->encoder,
298
               connector->status, connector->encoder,
Line 301... Line 299...
301
               crtc, crtc->base.id );
299
               crtc, crtc->base.id );
302
 
300
 
303
        break;
301
        break;
304
    };
302
    };
305
 
303
 
Line 306... Line 304...
306
    if(connector == NULL)
304
    if(connector == NULL)
307
    {
305
    {
Line 327... Line 325...
327
    };
325
    };
328
 
326
 
Line 329... Line 327...
329
    if(crtc == NULL)
327
    if(crtc == NULL)
330
    {
328
    {
331
        dbgprintf("No CRTC for encoder %d\n", encoder->base.id);
329
        DRM_ERROR("No CRTC for encoder %d\n", encoder->base.id);
332
        return -1;
330
        return -1;
333
    };
331
    };
Line 334... Line 332...
334
 
332
 
Line 369... Line 367...
369
 
367
 
Line 370... Line 368...
370
    main_device = dev;
368
    main_device = dev;
Line 371... Line 369...
371
 
369
 
372
    err = init_bitmaps();
-
 
373
    if( !err )
-
 
374
    {
-
 
375
        printf("Initialize bitmap manager\n");
-
 
376
    };
-
 
377
 
-
 
378
 
-
 
Line 379... Line 370...
379
//    LEAVE();
370
    err = init_bitmaps();
380
 
371
 
Line 381... Line 372...
381
    return 0;
372
    return 0;
382
};
373
};
383
 
374
 
Line 384... Line -...
384
 
-
 
385
int get_videomodes(videomode_t *mode, int *count)
-
 
386
{
375
 
Line 387... Line 376...
387
    int err = -1;
376
int get_videomodes(videomode_t *mode, int *count)
388
 
377
{
389
//    ENTER();
378
    int err = -1;
Line 418... Line 407...
418
        };
407
        };
419
        *count = i;
408
        *count = i;
420
        err = 0;
409
        err = 0;
421
    };
410
    };
422
//    LEAVE();
411
    return err;
423
    return err;
-
 
424
};
412
};
425
 
413
 
Line 426... Line 414...
426
int set_user_mode(videomode_t *mode)
414
int set_user_mode(videomode_t *mode)
427
{
415
{
428
    int err = -1;
416
    int err = -1;
Line 429... Line -...
429
 
-
 
430
//    ENTER();
-
 
431
 
417
 
432
//    dbgprintf("width %d height %d vrefresh %d\n",
418
//    dbgprintf("width %d height %d vrefresh %d\n",
Line 433... Line 419...
433
//               mode->width, mode->height, mode->freq);
419
//               mode->width, mode->height, mode->freq);
434
 
420
 
Line 442... Line 428...
442
        if( set_mode(os_display->ddev, os_display->connector, mode, true) )
428
        if( set_mode(os_display->ddev, os_display->connector, mode, true) )
443
            err = 0;
429
            err = 0;
444
    };
430
    };
445
 
431
 
Line 446... Line -...
446
//    LEAVE();
-
 
447
    return err;
432
    return err;
448
};
433
};
Line 449... Line 434...
449
 
434
 
450
void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor)
435
void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor)
451
{
-
 
452
/*  FIXME    synchronization */
-
 
453
 
436
{
-
 
437
    list_del(&cursor->list);
454
    list_del(&cursor->list);
438
 
-
 
439
    i915_gem_object_unpin(cursor->cobj);
-
 
440
 
455
//    radeon_bo_unpin(cursor->robj);
441
    mutex_lock(&main_device->struct_mutex);
-
 
442
    drm_gem_object_unreference(&cursor->cobj->base);
-
 
443
    mutex_unlock(&main_device->struct_mutex);
456
//    KernelFree(cursor->data);
444
 
457
    __DestroyObject(cursor);
445
    __DestroyObject(cursor);
Line 458... Line 446...
458
};
446
};
459
 
447
 
460
int init_cursor(cursor_t *cursor)
448
int init_cursor(cursor_t *cursor)
461
{
449
{
462
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
450
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
463
    struct drm_i915_gem_object *obj;
451
    struct drm_i915_gem_object *obj;
-
 
452
    uint32_t *bits;
Line 464... Line 453...
464
    uint32_t *bits;
453
    uint32_t *src;
465
    uint32_t *src;
454
    void     *mapped;
Line 466... Line -...
466
 
-
 
467
    int       i,j;
-
 
468
    int       ret;
455
 
469
 
456
    int       i,j;
470
//    ENTER();
457
    int       ret;
471
 
458
 
472
    if (dev_priv->info->cursor_needs_physical)
459
    if (dev_priv->info->cursor_needs_physical)
Line 490... Line 477...
490
 
477
 
Line 491... Line 478...
491
/* You don't need to worry about fragmentation issues.
478
/* You don't need to worry about fragmentation issues.
492
 * GTT space is continuous. I guarantee it.                           */
479
 * GTT space is continuous. I guarantee it.                           */
Line 493... Line 480...
493
 
480
 
494
        bits = (u32*)MapIoMem(dev_priv->mm.gtt->gma_bus_addr + obj->gtt_offset,
481
        mapped = bits = (u32*)MapIoMem(dev_priv->mm.gtt->gma_bus_addr + obj->gtt_offset,
Line 495... Line 482...
495
                    CURSOR_WIDTH*CURSOR_HEIGHT*4, PG_SW);
482
                    CURSOR_WIDTH*CURSOR_HEIGHT*4, PG_SW);
496
 
483
 
497
        if (unlikely(bits == NULL))
484
        if (unlikely(bits == NULL))
Line 514... Line 501...
514
    }
501
    }
515
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
502
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
516
        *bits++ = 0;
503
        *bits++ = 0;
517
 
504
 
Line -... Line 505...
-
 
505
    FreeKernelSpace(mapped);
-
 
506
 
518
// release old cursor
507
// release old cursor
Line 519... Line 508...
519
 
508
 
Line 520... Line 509...
520
    KernelFree(cursor->data);
509
    KernelFree(cursor->data);
Line 521... Line 510...
521
 
510
 
522
    cursor->data = bits;
-
 
Line 523... Line 511...
523
 
511
    cursor->data = bits;
524
    cursor->header.destroy = destroy_cursor;
512
 
Line 677... Line 665...
677
 
665
 
Line -... Line 666...
-
 
666
typedef int v4si __attribute__ ((vector_size (16)));
678
typedef int v4si __attribute__ ((vector_size (16)));
667
 
679
 
668
 
-
 
669
 
680
 
670
static void
681
static void
671
i915_gem_execbuffer_retire_commands(struct drm_device *dev,
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;
672
                    struct drm_file *file,
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;
673
                    struct intel_ring_buffer *ring)
695
    if (INTEL_INFO(dev)->gen >= 4)
-
 
696
        invalidate |= I915_GEM_DOMAIN_SAMPLER;
-
 
697
    if (ring->flush(ring, invalidate, 0)) {
-
 
Line 698... Line 674...
698
        i915_gem_next_request_seqno(ring);
674
{
699
        return;
675
    /* Unconditionally force add_request to emit a full flush. */
700
    }
-
 
701
 
-
 
702
    /* Add a breadcrumb for the completion of the batch buffer */
676
    ring->gpu_caches_dirty = true;
Line 703... Line -...
703
    if (request == NULL || i915_add_request(ring, NULL, &req)) {
-
 
704
        i915_gem_next_request_seqno(ring);
-
 
705
    }
-
 
706
}
-
 
707
 
677
 
708
 
678
    /* Add a breadcrumb for the completion of the batch buffer */
709
 
679
    (void)i915_add_request(ring, file, NULL);
710
 
680
}
711
 
681
 
Line 726... Line 696...
726
    u32_t      br13, cmd, slot_mask, *b;
696
    u32_t      br13, cmd, slot_mask, *b;
727
    u32_t      offset;
697
    u32_t      offset;
728
    u8         slot;
698
    u8         slot;
729
    int      n=0;
699
    int      n=0;
-
 
700
    int        ret;
Line 730... Line 701...
730
 
701
 
731
    if(unlikely(hbitmap==0))
702
    if(unlikely(hbitmap==0))
Line 732... Line 703...
732
        return -1;
703
        return -1;
Line 911... Line 882...
911
        b[n++] = MI_NOOP;
882
        b[n++] = MI_NOOP;
912
 
883
 
Line 913... Line 884...
913
    context->cmd_buffer+= n*4;
884
    context->cmd_buffer+= n*4;
Line -... Line 885...
-
 
885
 
-
 
886
    context->obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND;
-
 
887
 
-
 
888
 
-
 
889
    mutex_lock(&main_device->struct_mutex);
914
 
890
 
Line 915... Line 891...
915
//    i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
891
    i915_gem_object_set_to_gtt_domain(bitmap->obj, false);
916
 
892
 
-
 
893
    if (HAS_BLT(main_device))
917
    if (HAS_BLT(main_device))
894
    {
Line 918... Line 895...
918
    {
895
        u32 seqno;
919
        int ret;
896
        int i;
-
 
897
 
-
 
898
        ring = &dev_priv->ring[BCS];
-
 
899
//        printf("dispatch...  ");
-
 
900
 
-
 
901
        i915_gem_object_sync(bitmap->obj, ring);
-
 
902
        intel_ring_invalidate_all_caches(ring);
-
 
903
 
-
 
904
        seqno = i915_gem_next_request_seqno(ring);
-
 
905
//        printf("seqno = %d\n", seqno);
-
 
906
 
-
 
907
        for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++) {
-
 
908
            if (seqno < ring->sync_seqno[i]) {
-
 
909
            /* The GPU can not handle its semaphore value wrapping,
-
 
910
             * so every billion or so execbuffers, we need to stall
-
 
911
             * the GPU in order to reset the counters.
-
 
912
             */
-
 
913
                DRM_DEBUG("wrap seqno\n");
-
 
914
 
-
 
915
                ret = i915_gpu_idle(main_device);
-
 
916
                if (ret)
-
 
917
                    goto fail;
-
 
918
                i915_gem_retire_requests(main_device);
-
 
919
 
-
 
920
                BUG_ON(ring->sync_seqno[i]);
920
 
921
            }
-
 
922
        }
-
 
923
 
921
        ring = &dev_priv->ring[BCS];
924
        ret = ring->dispatch_execbuffer(ring, offset, n*4);
Line -... Line 925...
-
 
925
        if (ret)
-
 
926
            goto fail;
-
 
927
//        printf("done\n");
-
 
928
 
-
 
929
        bitmap->obj->base.read_domains = bitmap->obj->base.pending_read_domains;
-
 
930
        bitmap->obj->base.write_domain = bitmap->obj->base.pending_write_domain;
922
//        printf("dispatch...  ");
931
        bitmap->obj->fenced_gpu_access = bitmap->obj->pending_fenced_gpu_access;
923
        ring->dispatch_execbuffer(ring, offset, n*4);
932
 
924
//        printf("done\n");
933
        i915_gem_object_move_to_active(bitmap->obj, ring, seqno);
925
 
934
 
926
        i915_gem_execbuffer_retire_commands(main_device, ring);
935
        i915_gem_execbuffer_retire_commands(main_device, NULL, ring);
927
//        printf("retire\n");
936
//        printf("retire\n");
928
    }
937
    }
929
    else
938
    else
930
    {
939
    {
Line 931... Line 940...
931
        ring = &dev_priv->ring[RCS];
940
        ring = &dev_priv->ring[RCS];
932
        ring->dispatch_execbuffer(ring, offset, n*4);
941
        ring->dispatch_execbuffer(ring, offset, n*4);
Line 933... Line 942...
933
        ring->flush(ring, 0, I915_GEM_DOMAIN_RENDER);
942
        ring->flush(ring, 0, I915_GEM_DOMAIN_RENDER);
934
    };
943
    };
935
 
944
 
936
    bitmap->obj->base.read_domains = I915_GEM_DOMAIN_CPU;
945
//    bitmap->obj->base.read_domains = I915_GEM_DOMAIN_CPU;
Line 937... Line 946...
937
    bitmap->obj->base.write_domain = I915_GEM_DOMAIN_CPU;
946
//    bitmap->obj->base.write_domain = I915_GEM_DOMAIN_CPU;
Line 1315... Line 1324...
1315
int __queue_work(struct workqueue_struct *wq,
1324
int __queue_work(struct workqueue_struct *wq,
1316
                         struct work_struct *work)
1325
                         struct work_struct *work)
1317
{
1326
{
1318
    unsigned long flags;
1327
    unsigned long flags;
1319
//    ENTER();
1328
 
1320
 
-
 
Line 1321... Line 1329...
1321
//    dbgprintf("wq: %x, work: %x\n",
1329
//    dbgprintf("wq: %x, work: %x\n",
1322
//               wq, work );
1330
//               wq, work );
Line 1323... Line 1331...
1323
 
1331
 
Line 1334... Line 1342...
1334
    spin_unlock_irqrestore(&wq->lock, flags);
1342
    spin_unlock_irqrestore(&wq->lock, flags);
1335
//    dbgprintf("wq: %x head %x, next %x\n",
1343
//    dbgprintf("wq: %x head %x, next %x\n",
1336
//               wq, &wq->worklist, wq->worklist.next);
1344
//               wq, &wq->worklist, wq->worklist.next);
Line 1337... Line -...
1337
 
-
 
1338
//    LEAVE();
1345
 
1339
    return 1;
1346
    return 1;
Line 1340... Line 1347...
1340
};
1347
};
1341
 
1348
 
1342
void __stdcall delayed_work_timer_fn(unsigned long __data)
-
 
1343
{
1349
void __stdcall delayed_work_timer_fn(unsigned long __data)
1344
//    ENTER();
1350
{
Line 1345... Line 1351...
1345
    struct delayed_work *dwork = (struct delayed_work *)__data;
1351
    struct delayed_work *dwork = (struct delayed_work *)__data;
1346
    struct workqueue_struct *wq = dwork->work.data;
1352
    struct workqueue_struct *wq = dwork->work.data;
Line 1347... Line 1353...
1347
 
1353
 
1348
//    dbgprintf("wq: %x, work: %x\n",
-
 
1349
//               wq, &dwork->work );
1354
//    dbgprintf("wq: %x, work: %x\n",
Line 1350... Line 1355...
1350
 
1355
//               wq, &dwork->work );
1351
    __queue_work(wq, &dwork->work);
1356
 
Line 1366... Line 1371...
1366
int queue_delayed_work(struct workqueue_struct *wq,
1371
int queue_delayed_work(struct workqueue_struct *wq,
1367
                        struct delayed_work *dwork, unsigned long delay)
1372
                        struct delayed_work *dwork, unsigned long delay)
1368
{
1373
{
1369
    u32  flags;
1374
    u32  flags;
1370
//    ENTER();
-
 
Line 1371... Line 1375...
1371
 
1375
 
1372
//    dbgprintf("wq: %x, work: %x\n",
1376
//    dbgprintf("wq: %x, work: %x\n",
Line 1373... Line 1377...
1373
//               wq, &dwork->work );
1377
//               wq, &dwork->work );