Subversion Repositories Kolibri OS

Rev

Rev 3482 | Rev 4126 | 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
 
431
{
432
    list_del(&cursor->list);
3037 serge 433
2342 Serge 434
 
3037 serge 435
436
 
437
    drm_gem_object_unreference(&cursor->cobj->base);
438
    mutex_unlock(&main_device->struct_mutex);
439
440
 
2338 Serge 441
};
442
443
 
444
{
445
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
446
    struct drm_i915_gem_object *obj;
447
    uint32_t *bits;
448
    uint32_t *src;
449
    void     *mapped;
3037 serge 450
2338 Serge 451
 
452
    int       ret;
453
454
 
455
    {
456
        bits = (uint32_t*)KernelAlloc(CURSOR_WIDTH*CURSOR_HEIGHT*4);
457
        if (unlikely(bits == NULL))
458
            return ENOMEM;
459
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
460
    }
461
    else
462
    {
463
        obj = i915_gem_alloc_object(os_display->ddev, CURSOR_WIDTH*CURSOR_HEIGHT*4);
464
        if (unlikely(obj == NULL))
465
            return -ENOMEM;
466
467
 
4104 Serge 468
        if (ret) {
2338 Serge 469
            drm_gem_object_unreference(&obj->base);
2344 Serge 470
            return ret;
2338 Serge 471
        }
472
473
 
4104 Serge 474
        if (ret)
475
        {
476
            i915_gem_object_unpin(obj);
477
            drm_gem_object_unreference(&obj->base);
478
            return ret;
479
        }
480
/* You don't need to worry about fragmentation issues.
2338 Serge 481
 * GTT space is continuous. I guarantee it.                           */
482
483
 
4104 Serge 484
                    CURSOR_WIDTH*CURSOR_HEIGHT*4, PG_SW);
2338 Serge 485
486
 
487
        {
488
            i915_gem_object_unpin(obj);
2344 Serge 489
            drm_gem_object_unreference(&obj->base);
490
            return -ENOMEM;
2338 Serge 491
        };
492
        cursor->cobj = obj;
493
    };
494
495
 
496
497
 
498
    {
499
        for(j = 0; j < 32; j++)
500
            *bits++ = *src++;
501
        for(j = 32; j < CURSOR_WIDTH; j++)
502
            *bits++ = 0;
503
    }
504
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
505
        *bits++ = 0;
506
507
 
3037 serge 508
509
 
2338 Serge 510
511
 
2340 Serge 512
2338 Serge 513
 
514
515
 
516
517
 
518
}
519
520
 
521
 
522
{
523
    struct drm_device *dev = crtc->dev;
524
    struct drm_i915_private *dev_priv = dev->dev_private;
525
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
526
    int pipe = intel_crtc->pipe;
527
    bool visible = base != 0;
528
529
 
530
        uint32_t cntl = I915_READ(CURCNTR(pipe));
531
        if (base) {
532
            cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
533
            cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
534
            cntl |= pipe << 28; /* Connect to correct pipe */
535
        } else {
536
            cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
537
            cntl |= CURSOR_MODE_DISABLE;
538
        }
539
        I915_WRITE(CURCNTR(pipe), cntl);
540
541
 
542
    }
543
    /* and commit changes on next vblank */
544
    I915_WRITE(CURBASE(pipe), base);
545
}
546
547
 
548
{
549
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
550
    struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
551
    u32 base, pos;
552
    bool visible;
553
554
 
555
556
 
557
    intel_crtc->cursor_y = y;
558
559
 
560
    y = y - cursor->hot_y;
561
562
 
563
 
564
565
 
566
    if (x >= os_display->width)
567
        base = 0;
568
569
 
570
        base = 0;
571
572
 
573
    {
574
        if (x + intel_crtc->cursor_width < 0)
575
            base = 0;
576
577
 
578
        x = -x;
579
    }
580
    pos |= x << CURSOR_X_SHIFT;
581
582
 
583
    {
584
        if (y + intel_crtc->cursor_height < 0)
585
            base = 0;
586
587
 
588
        y = -y;
589
    }
590
    pos |= y << CURSOR_Y_SHIFT;
591
592
 
593
    if (!visible && !intel_crtc->cursor_visible)
594
        return;
595
596
 
597
//    if (IS_845G(dev) || IS_I865G(dev))
598
//        i845_update_cursor(crtc, base);
599
//    else
600
        i9xx_update_cursor(os_display->crtc, base);
601
602
 
603
604
 
605
 
606
{
607
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
608
    struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
609
    cursor_t *old;
610
611
 
612
    os_display->cursor = cursor;
613
614
 
615
       intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj);
4104 Serge 616
    else
2338 Serge 617
        intel_crtc->cursor_addr = (addr_t)cursor->cobj;
2352 Serge 618
2338 Serge 619
 
620
    intel_crtc->cursor_height = 32;
621
622
 
623
    return old;
624
};
625
626
 
3263 Serge 627
{
628
    uint32_t  width;
629
    uint32_t  height;
630
    uint32_t  pitch;
631
    uint32_t  tiling;
632
};
633
2340 Serge 634
 
3263 Serge 635
{
636
    fb->width  = os_display->width;
637
    fb->height = os_display->height;
638
    fb->pitch  = os_display->pitch;
639
    fb->tiling = 0;
640
2340 Serge 641
 
3263 Serge 642
};
643
644
 
3277 Serge 645
{
646
    int left;
647
    int top;
648
    int right;
649
    int bottom;
650
}rect_t;
651
3263 Serge 652
 
3277 Serge 653
    __u32 handle;
654
    __u32 width;
3290 Serge 655
    __u32 height;
656
    __u32 bo_size;
3277 Serge 657
    __u32 bo_pitch;
658
    __u32 bo_map;
659
};
660
661
 
662
663
 
664
{
665
    u32_t   addr;
666
667
 
668
    addr+= sizeof(display_t);            /*  shoot me  */
669
    return *(u32_t*)addr;
670
}
671
672
 
673
674
 
675
            struct drm_file *file)
676
{
677
    struct drm_i915_mask *mask = data;
678
    struct drm_gem_object *obj;
679
    static unsigned int mask_seqno[256];
680
    rect_t winrc;
681
    u32    slot;
682
    int    ret;
683
684
 
3480 Serge 685
     {
686
        printf("%s handle %d\n", __FUNCTION__, mask->handle);
687
        return 0;
688
     }
689
690
 
3277 Serge 691
    if (obj == NULL)
692
        return -ENOENT;
693
694
 
695
        drm_gem_object_unreference_unlocked(obj);
696
        return -EINVAL;
697
    }
698
699
 
700
    {
701
//        static warn_count;
3298 Serge 702
3277 Serge 703
 
3290 Serge 704
        mask->height   = winrc.bottom - winrc.top + 1;
705
        mask->bo_pitch = (mask->width+15) & ~15;
706
707
 
3298 Serge 708
        if(warn_count < 1)
3277 Serge 709
        {
710
            printf("left %d top %d right %d bottom %d\n",
711
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
712
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_size);
713
            warn_count++;
714
        };
715
#endif
3298 Serge 716
717
 
4104 Serge 718
3277 Serge 719
 
3290 Serge 720
 
3277 Serge 721
722
 
723
    {
724
        u8* src_offset;
725
        u8* dst_offset;
726
        u32 ifl;
727
728
 
729
        if (ret)
730
            return ret;
731
732
 
733
        if(ret !=0 )
734
        {
735
            dbgprintf("%s fail\n", __FUNCTION__);
736
            return ret;
737
        };
738
739
 
740
741
 
742
743
 
744
 
745
        src_offset+= get_display_map();
746
        dst_offset = (u8*)mask->bo_map;
747
748
 
3290 Serge 749
3277 Serge 750
 
751
        {
752
            mask_seqno[slot] = os_display->mask_seqno;
753
754
 
755
756
 
757
                "movd       %[slot],   %%xmm6    \n"
758
            "punpckldq  %%xmm6, %%xmm6            \n"
759
            "punpcklqdq %%xmm6, %%xmm6            \n"
760
            :: [slot]  "m" (slot)
761
            :"xmm6");
762
763
 
764
            {
765
                int tmp_w = mask->bo_pitch;
766
767
 
768
                u8* tmp_dst = dst_offset;
769
770
 
771
                dst_offset+= mask->bo_pitch;
772
773
 
774
                {
775
                    __asm__ __volatile__ (
776
                    "movdqu     (%0),   %%xmm0            \n"
777
                    "movdqu   16(%0),   %%xmm1            \n"
778
                    "movdqu   32(%0),   %%xmm2            \n"
779
                    "movdqu   48(%0),   %%xmm3            \n"
780
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
781
                    "pcmpeqb    %%xmm6, %%xmm1            \n"
782
                    "pcmpeqb    %%xmm6, %%xmm2            \n"
783
                    "pcmpeqb    %%xmm6, %%xmm3            \n"
784
                    "movdqa     %%xmm0,   (%%edi)         \n"
785
                    "movdqa     %%xmm1, 16(%%edi)         \n"
786
                    "movdqa     %%xmm2, 32(%%edi)         \n"
787
                    "movdqa     %%xmm3, 48(%%edi)         \n"
788
789
 
790
                    :"xmm0","xmm1","xmm2","xmm3");
791
                    tmp_w -= 64;
792
                    tmp_src += 64;
793
                    tmp_dst += 64;
794
                }
795
796
 
797
                {
798
                    __asm__ __volatile__ (
799
                    "movdqu     (%0),   %%xmm0            \n"
800
                    "movdqu   16(%0),   %%xmm1            \n"
801
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
802
                    "pcmpeqb    %%xmm6, %%xmm1            \n"
803
                    "movdqa     %%xmm0,   (%%edi)         \n"
804
                    "movdqa     %%xmm1, 16(%%edi)         \n"
805
806
 
807
                    :"xmm0","xmm1");
808
                    tmp_w -= 32;
809
                    tmp_src += 32;
810
                    tmp_dst += 32;
811
                }
812
813
 
814
                {
815
                    __asm__ __volatile__ (
816
                    "movdqu     (%0),   %%xmm0            \n"
817
                    "pcmpeqb    %%xmm6, %%xmm0            \n"
818
                    "movdqa     %%xmm0,   (%%edi)         \n"
819
                    :: "r" (tmp_src), "D" (tmp_dst)
820
                    :"xmm0");
821
                    tmp_w -= 16;
822
                    tmp_src += 16;
823
                    tmp_dst += 16;
824
                }
825
            };
826
        };
827
        safe_sti(ifl);
828
    }
829
830
 
831
832
 
833
834
 
835
}
836
837
 
838
 
839
 
2360 Serge 840
 
841
 
842
 
843
 
844
 
845
 
846
 
847
 
848
 
3031 serge 849
2360 Serge 850
 
3031 serge 851
{
852
    u32 tmp = GetTimerTicks();
853
2360 Serge 854
 
3031 serge 855
    ts->tv_nsec = (tmp - ts->tv_sec*100)*10000000;
856
}
857
2360 Serge 858
 
4104 Serge 859
{
3031 serge 860
    while (nsec >= NSEC_PER_SEC) {
4104 Serge 861
        /*
862
         * The following asm() prevents the compiler from
863
         * optimising this loop into a modulo operation. See
864
         * also __iter_div_u64_rem() in include/linux/time.h
865
         */
866
        asm("" : "+rm"(nsec));
867
        nsec -= NSEC_PER_SEC;
868
        ++sec;
869
    }
870
    while (nsec < 0) {
871
        asm("" : "+rm"(nsec));
872
        nsec += NSEC_PER_SEC;
873
        --sec;
874
    }
875
    ts->tv_sec = sec;
876
    ts->tv_nsec = nsec;
877
}
3031 serge 878
2360 Serge 879
 
3480 Serge 880
prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
881
{
882
    unsigned long flags;
883
3031 serge 884
 
3480 Serge 885
    spin_lock_irqsave(&q->lock, flags);
886
    if (list_empty(&wait->task_list))
887
            __add_wait_queue(q, wait);
888
    spin_unlock_irqrestore(&q->lock, flags);
889
}
890
891
 
892
 * finish_wait - clean up after waiting in a queue
893
 * @q: waitqueue waited on
894
 * @wait: wait descriptor
895
 *
896
 * Sets current thread back to running state and removes
897
 * the wait descriptor from the given waitqueue if still
898
 * queued.
899
 */
900
void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
901
{
902
    unsigned long flags;
903
904
 
905
    /*
906
     * We can check for list emptiness outside the lock
907
     * IFF:
908
     *  - we use the "careful" check that verifies both
909
     *    the next and prev pointers, so that there cannot
910
     *    be any half-pending updates in progress on other
911
     *    CPU's that we haven't seen yet (and that might
912
     *    still change the stack area.
913
     * and
914
     *  - all other users take the lock (ie we can only
915
     *    have _one_ other CPU that looks at or modifies
916
     *    the list).
917
     */
918
    if (!list_empty_careful(&wait->task_list)) {
919
            spin_lock_irqsave(&q->lock, flags);
920
            list_del_init(&wait->task_list);
921
            spin_unlock_irqrestore(&q->lock, flags);
922
    }
923
924
 
925
}
926
927
 
928
{
929
    list_del_init(&wait->task_list);
930
    return 1;
931
}
932
933
 
3482 Serge 934
{
935
    unsigned int res = w - ((w >> 1) & 0x5555);
936
    res = (res & 0x3333) + ((res >> 2) & 0x3333);
937
    res = (res + (res >> 4)) & 0x0F0F;
938
    return (res + (res >> 8)) & 0x00FF;
939
}
940
3480 Serge 941
 
942
 
3482 Serge 943
{
944
    unsigned long j0 = GetTimerTicks();
945
3480 Serge 946
 
3482 Serge 947
    return round_jiffies_common(j + j0, true) - j0;
948
}
949
3480 Serge 950
 
3482 Serge 951