Subversion Repositories Kolibri OS

Rev

Rev 4104 | Rev 4280 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2340 Serge 1
 
2
3
 
2338 Serge 4
#include "drm.h"
5
#include "i915_drm.h"
6
#include "i915_drv.h"
7
#include "intel_drv.h"
8
9
 
10
#include 
11
#include 
12
#include 
13
#include 
14
15
 
16
17
 
2340 Serge 18
2338 Serge 19
 
20
{
21
    kobj_t     header;
22
23
 
24
    uint32_t   hot_x;
25
    uint32_t   hot_y;
26
27
 
28
    struct drm_i915_gem_object  *cobj;
29
}cursor_t;
30
31
 
32
#define CURSOR_HEIGHT 64
33
34
 
35
 
36
{
37
    int  x;
38
    int  y;
39
    int  width;
40
    int  height;
41
    int  bpp;
42
    int  vrefresh;
43
    int  pitch;
44
    int  lfb;
45
46
 
47
    struct drm_device    *ddev;
48
    struct drm_connector *connector;
49
    struct drm_crtc      *crtc;
50
51
 
52
53
 
54
    int       (*init_cursor)(cursor_t*);
55
    cursor_t* (__stdcall *select_cursor)(cursor_t*);
56
    void      (*show_cursor)(int show);
57
    void      (__stdcall *move_cursor)(cursor_t *cursor, int x, int y);
58
    void      (__stdcall *restore_cursor)(int x, int y);
59
    void      (*disable_mouse)(void);
60
    u32  mask_seqno;
2361 Serge 61
    u32  check_mouse;
3031 serge 62
    u32  check_m_pixel;
63
64
 
2338 Serge 65
66
 
67
 
68
69
 
2340 Serge 70
u32_t cmd_offset;
71
72
 
2351 Serge 73
int  sna_init();
74
75
 
2338 Serge 76
static cursor_t*  __stdcall select_cursor_kms(cursor_t *cursor);
77
static void       __stdcall move_cursor_kms(cursor_t *cursor, int x, int y);
78
79
 
80
{};
81
82
 
83
{};
84
85
 
3031 serge 86
{
87
    static char name[4];
88
89
 
90
    name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@';
91
    name[2] = (x[1] & 0x1F) + '@';
92
    name[3] = 0;
93
94
 
95
}
96
97
 
98
              videomode_t *reqmode, bool strict)
99
{
100
    drm_i915_private_t      *dev_priv   = dev->dev_private;
101
    struct drm_fb_helper    *fb_helper  = &dev_priv->fbdev->helper;
102
103
 
104
    struct drm_display_mode *mode       = NULL, *tmpmode;
105
    struct drm_framebuffer  *fb         = NULL;
106
    struct drm_crtc         *crtc;
107
    struct drm_encoder      *encoder;
108
    struct drm_mode_set     set;
109
    char *con_name;
110
    char *enc_name;
111
    unsigned hdisplay, vdisplay;
112
    int ret;
113
114
 
115
116
 
117
    {
118
        if( (drm_mode_width(tmpmode)    == reqmode->width)  &&
119
            (drm_mode_height(tmpmode)   == reqmode->height) &&
120
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
121
        {
122
            mode = tmpmode;
123
            goto do_set;
124
        }
125
    };
126
127
 
128
    {
129
        list_for_each_entry(tmpmode, &connector->modes, head)
130
        {
131
            if( (drm_mode_width(tmpmode)  == reqmode->width)  &&
132
                (drm_mode_height(tmpmode) == reqmode->height) )
133
            {
134
                mode = tmpmode;
135
                goto do_set;
136
            }
137
        };
138
    };
139
140
 
3037 serge 141
3031 serge 142
 
143
144
 
145
146
 
147
    crtc = encoder->crtc;
148
149
 
150
    enc_name = drm_get_encoder_name(encoder);
151
152
 
153
              reqmode->width, reqmode->height, crtc->base.id,
154
              con_name, enc_name);
155
156
 
157
158
 
159
    vdisplay = mode->vdisplay;
160
161
 
162
        swap(hdisplay, vdisplay);
163
164
 
165
166
 
167
    fb->height = reqmode->height;
168
    fb->pitches[0]  = ALIGN(reqmode->width * 4, 64);
169
    fb->pitches[1]  = ALIGN(reqmode->width * 4, 64);
170
    fb->pitches[2]  = ALIGN(reqmode->width * 4, 64);
171
    fb->pitches[3]  = ALIGN(reqmode->width * 4, 64);
172
173
 
174
    fb->depth = 24;
175
176
 
177
    crtc->enabled = true;
178
    os_display->crtc = crtc;
179
180
 
181
    set.x = 0;
182
    set.y = 0;
183
    set.mode = mode;
184
    set.connectors = &connector;
185
    set.num_connectors = 1;
186
    set.fb = fb;
187
    ret = crtc->funcs->set_config(&set);
188
    mutex_unlock(&dev->mode_config.mutex);
189
190
 
191
    {
192
        os_display->width    = fb->width;
193
        os_display->height   = fb->height;
194
        os_display->pitch    = fb->pitches[0];
195
        os_display->vrefresh = drm_mode_vrefresh(mode);
196
197
 
198
199
 
3037 serge 200
                       fb->width, fb->height, fb->pitches[0]);
3031 serge 201
    }
202
    else
203
        DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
204
                   fb->width, fb->height, crtc);
205
206
 
207
 
208
}
209
210
 
2338 Serge 211
{
212
    struct drm_display_mode  *mode;
213
    int count = 0;
214
215
 
216
    {
217
        count++;
218
    };
219
    return count;
220
};
221
222
 
3031 serge 223
{
224
    struct drm_connector  *connector;
225
    struct drm_connector_helper_funcs *connector_funcs;
226
227
 
228
229
 
230
    {
231
        struct drm_encoder  *encoder;
232
        struct drm_crtc     *crtc;
233
234
 
235
            continue;
236
237
 
238
        encoder = connector_funcs->best_encoder(connector);
239
        if( encoder == NULL)
240
            continue;
241
242
 
243
244
 
245
246
 
3037 serge 247
                   connector, connector->base.id,
3031 serge 248
                   connector->status, connector->encoder,
249
                   crtc);
250
251
 
252
//            continue;
253
254
 
255
256
 
257
    };
258
259
 
260
};
261
262
 
263
 
2338 Serge 264
{
265
    struct drm_connector    *connector;
266
    struct drm_connector_helper_funcs *connector_funcs;
267
    struct drm_encoder      *encoder;
268
    struct drm_crtc         *crtc = NULL;
269
    struct drm_framebuffer  *fb;
270
271
 
272
    u32_t      ifl;
273
    int        err;
3033 serge 274
2338 Serge 275
 
276
    {
277
        if( connector->status != connector_status_connected)
278
            continue;
279
280
 
281
        encoder = connector_funcs->best_encoder(connector);
282
        if( encoder == NULL)
283
        {
284
            DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n",
3037 serge 285
                      connector, connector->base.id);
2338 Serge 286
            continue;
287
        }
288
        connector->encoder = encoder;
289
        crtc = encoder->crtc;
3031 serge 290
2338 Serge 291
 
3037 serge 292
               connector, connector->base.id,
2338 Serge 293
               connector->status, connector->encoder,
294
               crtc, crtc->base.id );
3031 serge 295
2338 Serge 296
 
297
    };
298
299
 
300
    {
301
        DRM_ERROR("No active connectors!\n");
3037 serge 302
        return -1;
2338 Serge 303
    };
304
305
 
306
    {
307
        struct drm_crtc *tmp_crtc;
308
        int crtc_mask = 1;
309
310
 
311
        {
312
            if (encoder->possible_crtcs & crtc_mask)
313
            {
314
                crtc = tmp_crtc;
315
                encoder->crtc = crtc;
316
                break;
317
            };
318
            crtc_mask <<= 1;
319
        };
320
    };
321
322
 
323
    {
324
        DRM_ERROR("No CRTC for encoder %d\n", encoder->base.id);
3037 serge 325
        return -1;
2338 Serge 326
    };
327
328
 
329
 
330
331
 
332
    os_display->ddev = dev;
333
    os_display->connector = connector;
334
    os_display->crtc = crtc;
335
336
 
337
338
 
339
 
340
    {
341
        struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
342
343
 
344
        {
345
            init_cursor(cursor);
346
        };
347
348
 
349
        os_display->init_cursor    = init_cursor;
350
        os_display->select_cursor  = select_cursor_kms;
351
        os_display->show_cursor    = NULL;
352
        os_display->move_cursor    = move_cursor_kms;
353
        os_display->restore_cursor = restore_cursor;
354
        os_display->disable_mouse  = disable_mouse;
355
356
 
357
        intel_crtc->cursor_y = os_display->height/2;
358
359
 
360
    };
361
    safe_sti(ifl);
362
363
 
3243 Serge 364
    err = init_bitmaps();
2342 Serge 365
#endif
3243 Serge 366
2340 Serge 367
 
2338 Serge 368
};
369
370
 
371
 
372
{
373
    int err = -1;
374
375
 
3031 serge 376
2338 Serge 377
 
378
    {
379
        *count = os_display->supported_modes;
380
        err = 0;
381
    }
382
    else if( mode != NULL )
383
    {
384
        struct drm_display_mode  *drmmode;
385
        int i = 0;
386
387
 
388
            *count = os_display->supported_modes;
389
390
 
391
        {
392
            if( i < *count)
393
            {
394
                mode->width  = drm_mode_width(drmmode);
395
                mode->height = drm_mode_height(drmmode);
396
                mode->bpp    = 32;
397
                mode->freq   = drm_mode_vrefresh(drmmode);
398
                i++;
399
                mode++;
400
            }
401
            else break;
402
        };
403
        *count = i;
404
        err = 0;
405
    };
406
    return err;
407
};
408
409
 
410
{
411
    int err = -1;
412
413
 
3031 serge 414
//               mode->width, mode->height, mode->freq);
415
2338 Serge 416
 
417
        (mode->height != 0)  &&
418
        (mode->freq   != 0 ) &&
419
        ( (mode->width   != os_display->width)  ||
420
          (mode->height  != os_display->height) ||
421
          (mode->freq    != os_display->vrefresh) ) )
422
    {
423
        if( set_mode(os_display->ddev, os_display->connector, mode, true) )
424
            err = 0;
425
    };
426
427
 
428
};
429
430
 
4126 Serge 431
{
432
    struct drm_connector_funcs *f = os_display->connector->funcs;
433
434
 
435
};
436
437
 
2338 Serge 438
{
439
    list_del(&cursor->list);
3037 serge 440
2342 Serge 441
 
3037 serge 442
443
 
444
    drm_gem_object_unreference(&cursor->cobj->base);
445
    mutex_unlock(&main_device->struct_mutex);
446
447
 
2338 Serge 448
};
449
450
 
451
{
452
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
453
    struct drm_i915_gem_object *obj;
454
    uint32_t *bits;
455
    uint32_t *src;
456
    void     *mapped;
3037 serge 457
2338 Serge 458
 
459
    int       ret;
460
461
 
462
    {
463
        bits = (uint32_t*)KernelAlloc(CURSOR_WIDTH*CURSOR_HEIGHT*4);
464
        if (unlikely(bits == NULL))
465
            return ENOMEM;
466
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
467
    }
468
    else
469
    {
470
        obj = i915_gem_alloc_object(os_display->ddev, CURSOR_WIDTH*CURSOR_HEIGHT*4);
471
        if (unlikely(obj == NULL))
472
            return -ENOMEM;
473
474
 
4104 Serge 475
        if (ret) {
2338 Serge 476
            drm_gem_object_unreference(&obj->base);
2344 Serge 477
            return ret;
2338 Serge 478
        }
479
480
 
4104 Serge 481
        if (ret)
482
        {
483
            i915_gem_object_unpin(obj);
484
            drm_gem_object_unreference(&obj->base);
485
            return ret;
486
        }
487
/* You don't need to worry about fragmentation issues.
2338 Serge 488
 * GTT space is continuous. I guarantee it.                           */
489
490
 
4104 Serge 491
                    CURSOR_WIDTH*CURSOR_HEIGHT*4, PG_SW);
2338 Serge 492
493
 
494
        {
495
            i915_gem_object_unpin(obj);
2344 Serge 496
            drm_gem_object_unreference(&obj->base);
497
            return -ENOMEM;
2338 Serge 498
        };
499
        cursor->cobj = obj;
500
    };
501
502
 
503
504
 
505
    {
506
        for(j = 0; j < 32; j++)
507
            *bits++ = *src++;
508
        for(j = 32; j < CURSOR_WIDTH; j++)
509
            *bits++ = 0;
510
    }
511
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
512
        *bits++ = 0;
513
514
 
3037 serge 515
516
 
2338 Serge 517
518
 
2340 Serge 519
2338 Serge 520
 
521
522
 
523
524
 
525
}
526
527
 
528
 
529
{
530
    struct drm_device *dev = crtc->dev;
531
    struct drm_i915_private *dev_priv = dev->dev_private;
532
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
533
    int pipe = intel_crtc->pipe;
534
    bool visible = base != 0;
535
536
 
537
        uint32_t cntl = I915_READ(CURCNTR(pipe));
538
        if (base) {
539
            cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
540
            cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
541
            cntl |= pipe << 28; /* Connect to correct pipe */
542
        } else {
543
            cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
544
            cntl |= CURSOR_MODE_DISABLE;
545
        }
546
        I915_WRITE(CURCNTR(pipe), cntl);
547
548
 
549
    }
550
    /* and commit changes on next vblank */
551
    I915_WRITE(CURBASE(pipe), base);
552
}
553
554
 
555
{
556
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
557
    struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
558
    u32 base, pos;
559
    bool visible;
560
561
 
562
563
 
564
    intel_crtc->cursor_y = y;
565
566
 
567
    y = y - cursor->hot_y;
568
569
 
570
 
571
572
 
573
    if (x >= os_display->width)
574
        base = 0;
575
576
 
577
        base = 0;
578
579
 
580
    {
581
        if (x + intel_crtc->cursor_width < 0)
582
            base = 0;
583
584
 
585
        x = -x;
586
    }
587
    pos |= x << CURSOR_X_SHIFT;
588
589
 
590
    {
591
        if (y + intel_crtc->cursor_height < 0)
592
            base = 0;
593
594
 
595
        y = -y;
596
    }
597
    pos |= y << CURSOR_Y_SHIFT;
598
599
 
600
    if (!visible && !intel_crtc->cursor_visible)
601
        return;
602
603
 
604
//    if (IS_845G(dev) || IS_I865G(dev))
605
//        i845_update_cursor(crtc, base);
606
//    else
607
        i9xx_update_cursor(os_display->crtc, base);
608
609
 
610
611
 
612
 
613
{
614
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
615
    struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
616
    cursor_t *old;
617
618
 
619
    os_display->cursor = cursor;
620
621
 
622
       intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj);
4104 Serge 623
    else
2338 Serge 624
        intel_crtc->cursor_addr = (addr_t)cursor->cobj;
2352 Serge 625
2338 Serge 626
 
627
    intel_crtc->cursor_height = 32;
628
629
 
630
    return old;
631
};
632
633
 
3263 Serge 634
{
635
    uint32_t  width;
636
    uint32_t  height;
637
    uint32_t  pitch;
638
    uint32_t  tiling;
639
};
640
2340 Serge 641
 
3263 Serge 642
{
643
    fb->width  = os_display->width;
644
    fb->height = os_display->height;
645
    fb->pitch  = os_display->pitch;
646
    fb->tiling = 0;
647
2340 Serge 648
 
3263 Serge 649
};
650
651
 
3277 Serge 652
{
653
    int left;
654
    int top;
655
    int right;
656
    int bottom;
657
}rect_t;
658
3263 Serge 659
 
3277 Serge 660
    __u32 handle;
661
    __u32 width;
3290 Serge 662
    __u32 height;
663
    __u32 bo_size;
3277 Serge 664
    __u32 bo_pitch;
665
    __u32 bo_map;
666
};
667
668
 
669
670
 
671
{
672
    u32_t   addr;
673
674
 
675
    addr+= sizeof(display_t);            /*  shoot me  */
676
    return *(u32_t*)addr;
677
}
678
679
 
680
681
 
682
            struct drm_file *file)
683
{
684
    struct drm_i915_mask *mask = data;
685
    struct drm_gem_object *obj;
686
    static unsigned int mask_seqno[256];
687
    rect_t winrc;
688
    u32    slot;
689
    int    ret;
690
691
 
3480 Serge 692
     {
693
        printf("%s handle %d\n", __FUNCTION__, mask->handle);
694
        return 0;
695
     }
696
697
 
3277 Serge 698
    if (obj == NULL)
699
        return -ENOENT;
700
701
 
702
        drm_gem_object_unreference_unlocked(obj);
703
        return -EINVAL;
704
    }
705
706
 
707
    {
708
//        static warn_count;
3298 Serge 709
3277 Serge 710
 
3290 Serge 711
        mask->height   = winrc.bottom - winrc.top + 1;
712
        mask->bo_pitch = (mask->width+15) & ~15;
713
714
 
3298 Serge 715
        if(warn_count < 1)
3277 Serge 716
        {
717
            printf("left %d top %d right %d bottom %d\n",
718
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
719
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_size);
720
            warn_count++;
721
        };
722
#endif
3298 Serge 723
724
 
4104 Serge 725
3277 Serge 726
 
3290 Serge 727
 
3277 Serge 728
729
 
730
    {
731
        u8* src_offset;
732
        u8* dst_offset;
733
        u32 ifl;
734
735
 
736
        if (ret)
737
            return ret;
738
739
 
740
        if(ret !=0 )
741
        {
742
            dbgprintf("%s fail\n", __FUNCTION__);
743
            return ret;
744
        };
745
746
 
747
748
 
749
750
 
751
 
752
        src_offset+= get_display_map();
753
        dst_offset = (u8*)mask->bo_map;
754
755
 
3290 Serge 756
3277 Serge 757
 
758
        {
759
            mask_seqno[slot] = os_display->mask_seqno;
760
761
 
762
763
 
764
                "movd       %[slot],   %%xmm6    \n"
765
            "punpckldq  %%xmm6, %%xmm6            \n"
766
            "punpcklqdq %%xmm6, %%xmm6            \n"
767
            :: [slot]  "m" (slot)
768
            :"xmm6");
769
770
 
771
            {
772
                int tmp_w = mask->bo_pitch;
773
774
 
775
                u8* tmp_dst = dst_offset;
776
777
 
778
                dst_offset+= mask->bo_pitch;
779
780
 
781
                {
782
                    __asm__ __volatile__ (
783
                    "movdqu     (%0),   %%xmm0            \n"
784
                    "movdqu   16(%0),   %%xmm1            \n"
785
                    "movdqu   32(%0),   %%xmm2            \n"
786
                    "movdqu   48(%0),   %%xmm3            \n"
787
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
788
                    "pcmpeqb    %%xmm6, %%xmm1            \n"
789
                    "pcmpeqb    %%xmm6, %%xmm2            \n"
790
                    "pcmpeqb    %%xmm6, %%xmm3            \n"
791
                    "movdqa     %%xmm0,   (%%edi)         \n"
792
                    "movdqa     %%xmm1, 16(%%edi)         \n"
793
                    "movdqa     %%xmm2, 32(%%edi)         \n"
794
                    "movdqa     %%xmm3, 48(%%edi)         \n"
795
796
 
797
                    :"xmm0","xmm1","xmm2","xmm3");
798
                    tmp_w -= 64;
799
                    tmp_src += 64;
800
                    tmp_dst += 64;
801
                }
802
803
 
804
                {
805
                    __asm__ __volatile__ (
806
                    "movdqu     (%0),   %%xmm0            \n"
807
                    "movdqu   16(%0),   %%xmm1            \n"
808
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
809
                    "pcmpeqb    %%xmm6, %%xmm1            \n"
810
                    "movdqa     %%xmm0,   (%%edi)         \n"
811
                    "movdqa     %%xmm1, 16(%%edi)         \n"
812
813
 
814
                    :"xmm0","xmm1");
815
                    tmp_w -= 32;
816
                    tmp_src += 32;
817
                    tmp_dst += 32;
818
                }
819
820
 
821
                {
822
                    __asm__ __volatile__ (
823
                    "movdqu     (%0),   %%xmm0            \n"
824
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
825
                    "movdqa     %%xmm0,   (%%edi)         \n"
826
                    :: "r" (tmp_src), "D" (tmp_dst)
827
                    :"xmm0");
828
                    tmp_w -= 16;
829
                    tmp_src += 16;
830
                    tmp_dst += 16;
831
                }
832
            };
833
        };
834
        safe_sti(ifl);
835
    }
836
837
 
838
839
 
840
841
 
842
}
843
844
 
845
 
846
 
2360 Serge 847
 
848
 
849
 
850
 
851
 
852
 
853
 
854
 
855
 
3031 serge 856
2360 Serge 857
 
3031 serge 858
{
859
    u32 tmp = GetTimerTicks();
860
2360 Serge 861
 
3031 serge 862
    ts->tv_nsec = (tmp - ts->tv_sec*100)*10000000;
863
}
864
2360 Serge 865
 
4104 Serge 866
{
3031 serge 867
    while (nsec >= NSEC_PER_SEC) {
4104 Serge 868
        /*
869
         * The following asm() prevents the compiler from
870
         * optimising this loop into a modulo operation. See
871
         * also __iter_div_u64_rem() in include/linux/time.h
872
         */
873
        asm("" : "+rm"(nsec));
874
        nsec -= NSEC_PER_SEC;
875
        ++sec;
876
    }
877
    while (nsec < 0) {
878
        asm("" : "+rm"(nsec));
879
        nsec += NSEC_PER_SEC;
880
        --sec;
881
    }
882
    ts->tv_sec = sec;
883
    ts->tv_nsec = nsec;
884
}
3031 serge 885
2360 Serge 886
 
3480 Serge 887
prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
888
{
889
    unsigned long flags;
890
3031 serge 891
 
3480 Serge 892
    spin_lock_irqsave(&q->lock, flags);
893
    if (list_empty(&wait->task_list))
894
            __add_wait_queue(q, wait);
895
    spin_unlock_irqrestore(&q->lock, flags);
896
}
897
898
 
899
 * finish_wait - clean up after waiting in a queue
900
 * @q: waitqueue waited on
901
 * @wait: wait descriptor
902
 *
903
 * Sets current thread back to running state and removes
904
 * the wait descriptor from the given waitqueue if still
905
 * queued.
906
 */
907
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
908
{
909
    unsigned long flags;
910
911
 
912
    /*
913
     * We can check for list emptiness outside the lock
914
     * IFF:
915
     *  - we use the "careful" check that verifies both
916
     *    the next and prev pointers, so that there cannot
917
     *    be any half-pending updates in progress on other
918
     *    CPU's that we haven't seen yet (and that might
919
     *    still change the stack area.
920
     * and
921
     *  - all other users take the lock (ie we can only
922
     *    have _one_ other CPU that looks at or modifies
923
     *    the list).
924
     */
925
    if (!list_empty_careful(&wait->task_list)) {
926
            spin_lock_irqsave(&q->lock, flags);
927
            list_del_init(&wait->task_list);
928
            spin_unlock_irqrestore(&q->lock, flags);
929
    }
930
931
 
932
}
933
934
 
935
{
936
    list_del_init(&wait->task_list);
937
    return 1;
938
}
939
940
 
3482 Serge 941
{
942
    unsigned int res = w - ((w >> 1) & 0x5555);
943
    res = (res & 0x3333) + ((res >> 2) & 0x3333);
944
    res = (res + (res >> 4)) & 0x0F0F;
945
    return (res + (res >> 8)) & 0x00FF;
946
}
947
3480 Serge 948
 
949
 
3482 Serge 950
{
951
    unsigned long j0 = GetTimerTicks();
952
3480 Serge 953
 
3482 Serge 954
    return round_jiffies_common(j + j0, true) - j0;
955
}
956
3480 Serge 957
 
3482 Serge 958