Subversion Repositories Kolibri OS

Rev

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

Rev 4560 Rev 5060
Line 1... Line 1...
1
#define iowrite32(v, addr)      writel((v), (addr))
1
#define iowrite32(v, addr)      writel((v), (addr))
Line 2... Line 2...
2
 
2
 
3
#include "drmP.h"
-
 
4
#include "drm.h"
3
#include 
5
#include "i915_drm.h"
4
#include 
6
#include "i915_drv.h"
5
#include "i915_drv.h"
7
#include "intel_drv.h"
-
 
8
 
6
#include "intel_drv.h"
9
#include 
7
#include 
10
#include 
8
#include 
11
#include 
9
#include 
12
#include 
10
#include 
Line 27... Line 25...
27
    struct list_head   list;
25
    struct list_head   list;
28
    struct drm_i915_gem_object  *cobj;
26
    struct drm_i915_gem_object  *cobj;
29
}cursor_t;
27
}cursor_t;
Line 30... Line 28...
30
 
28
 
31
#define CURSOR_WIDTH 64
29
#define KMS_CURSOR_WIDTH 64
Line 32... Line 30...
32
#define CURSOR_HEIGHT 64
30
#define KMS_CURSOR_HEIGHT 64
33
 
31
 
34
 
32
 
Line 94... Line 92...
94
 
92
 
Line 95... Line 93...
95
    return name;
93
    return name;
96
}
94
}
Line 97... Line 95...
97
 
95
 
98
bool set_mode(struct drm_device *dev, struct drm_connector *connector,
96
static int set_mode(struct drm_device *dev, struct drm_connector *connector,
99
              videomode_t *reqmode, bool strict)
97
                    struct drm_crtc *crtc, videomode_t *reqmode, bool strict)
100
{
98
{
101
    drm_i915_private_t      *dev_priv   = dev->dev_private;
-
 
Line 102... Line 99...
102
    struct drm_fb_helper    *fb_helper  = &dev_priv->fbdev->helper;
99
    struct drm_i915_private *dev_priv   = dev->dev_private;
103
 
100
 
104
    struct drm_mode_config  *config     = &dev->mode_config;
101
    struct drm_mode_config  *config     = &dev->mode_config;
105
    struct drm_display_mode *mode       = NULL, *tmpmode;
-
 
106
    struct drm_framebuffer  *fb         = NULL;
-
 
107
    struct drm_crtc         *crtc;
102
    struct drm_display_mode *mode       = NULL, *tmpmode;
108
    struct drm_encoder      *encoder;
103
    struct drm_framebuffer  *fb         = NULL;
109
    struct drm_mode_set     set;
-
 
110
    const char *con_name;
104
    struct drm_mode_set     set;
111
    const char *enc_name;
105
    const char *con_name;
112
    unsigned hdisplay, vdisplay;
106
    unsigned hdisplay, vdisplay;
Line 113... Line 107...
113
    int stride;
107
    int stride;
Line 114... Line 108...
114
    int ret;
108
    int ret;
115
 
109
 
116
    mutex_lock(&dev->mode_config.mutex);
110
    drm_modeset_lock_all(dev);
117
 
111
 
118
    list_for_each_entry(tmpmode, &connector->modes, head)
112
    list_for_each_entry(tmpmode, &connector->modes, head)
119
    {
113
    {
120
        if( (drm_mode_width(tmpmode)    == reqmode->width)  &&
114
        if( (tmpmode->hdisplay == reqmode->width)  &&
121
            (drm_mode_height(tmpmode)   == reqmode->height) &&
115
            (tmpmode->vdisplay == reqmode->height) &&
122
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
116
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
Line 129... Line 123...
129
    if( (mode == NULL) && (strict == false) )
123
    if( (mode == NULL) && (strict == false) )
130
    {
124
    {
131
        list_for_each_entry(tmpmode, &connector->modes, head)
125
        list_for_each_entry(tmpmode, &connector->modes, head)
132
        {
126
        {
133
            if( (drm_mode_width(tmpmode)  == reqmode->width)  &&
127
            if( (tmpmode->hdisplay == reqmode->width)  &&
134
                (drm_mode_height(tmpmode) == reqmode->height) )
128
                (tmpmode->vdisplay == reqmode->height) )
135
            {
129
            {
136
                mode = tmpmode;
130
                mode = tmpmode;
137
                goto do_set;
131
                goto do_set;
138
            }
132
            }
139
        };
133
        };
Line 144... Line 138...
144
    return -1;
138
    return -1;
Line 145... Line 139...
145
 
139
 
Line 146... Line 140...
146
do_set:
140
do_set:
147
 
-
 
148
    encoder = connector->encoder;
-
 
149
    crtc = encoder->crtc;
-
 
150
 
-
 
Line 151... Line 141...
151
    con_name = drm_get_connector_name(connector);
141
 
152
    enc_name = drm_get_encoder_name(encoder);
142
    con_name = connector->name;
153
 
143
 
Line 154... Line 144...
154
    DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s encoder %s\n",
144
    DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s\n",
Line 155... Line 145...
155
              reqmode->width, reqmode->height, crtc->base.id,
145
              reqmode->width, reqmode->height, crtc->base.id,
156
              con_name, enc_name);
146
              con_name);
Line 157... Line 147...
157
 
147
 
158
    drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
148
    drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
Line 159... Line 149...
159
 
149
 
Line 160... Line 150...
160
    hdisplay = mode->hdisplay;
150
    hdisplay = mode->hdisplay;
161
    vdisplay = mode->vdisplay;
151
    vdisplay = mode->vdisplay;
Line 162... Line -...
162
 
-
 
163
    if (crtc->invert_dimensions)
-
 
164
        swap(hdisplay, vdisplay);
152
 
Line -... Line 153...
-
 
153
    if (crtc->invert_dimensions)
-
 
154
        swap(hdisplay, vdisplay);
165
 
155
 
166
    fb = fb_helper->fb;
156
    fb = crtc->primary->fb;
167
 
157
 
168
    fb->width  = reqmode->width;
158
    fb->width  = reqmode->width;
169
    fb->height = reqmode->height;
159
    fb->height = reqmode->height;
170
 
160
 
171
    if(dev_priv->mm.bit_6_swizzle_x != I915_BIT_6_SWIZZLE_NONE)
161
        main_fb_obj->tiling_mode = I915_TILING_X;
172
    {
-
 
173
        main_fb_obj->tiling_mode = I915_TILING_X;
162
 
174
 
163
    if( main_fb_obj->tiling_mode == I915_TILING_X)
Line 175... Line 164...
175
        if(IS_GEN3(dev))
164
    {
176
            for (stride = 512; stride < reqmode->width * 4; stride <<= 1);
165
        if(IS_GEN3(dev))
Line 192... Line 181...
192
 
181
 
Line 193... Line 182...
193
    fb->bits_per_pixel = 32;
182
    fb->bits_per_pixel = 32;
194
    fb->depth = 24;
183
    fb->depth = 24;
Line 195... Line -...
195
 
-
 
196
    crtc->fb = fb;
184
 
197
    crtc->enabled = true;
185
    crtc->enabled = true;
Line -... Line 186...
-
 
186
    os_display->crtc = crtc;
198
    os_display->crtc = crtc;
187
 
Line 199... Line 188...
199
 
188
//    i915_gem_object_unpin_fence(main_fb_obj);
200
    i915_gem_object_put_fence(main_fb_obj);
189
    i915_gem_object_put_fence(main_fb_obj);
201
 
190
 
202
    set.crtc = crtc;
191
    set.crtc = crtc;
203
    set.x = 0;
192
    set.x = 0;
204
    set.y = 0;
193
    set.y = 0;
205
    set.mode = mode;
194
    set.mode = mode;
-
 
195
    set.connectors = &connector;
206
    set.connectors = &connector;
196
    set.num_connectors = 1;
-
 
197
    set.fb = fb;
207
    set.num_connectors = 1;
198
 
Line 208... Line 199...
208
    set.fb = fb;
199
    ret = drm_mode_set_config_internal(&set);
209
    ret = crtc->funcs->set_config(&set);
200
 
210
    mutex_unlock(&dev->mode_config.mutex);
201
    drm_modeset_unlock_all(dev);
211
 
202
 
Line 238... Line 229...
238
    };
229
    };
239
    return count;
230
    return count;
240
};
231
};
241
 
232
 
Line 242... Line 233...
242
static struct drm_connector* get_def_connector(struct drm_device *dev)
233
static struct drm_crtc *get_possible_crtc(struct drm_device *dev, struct drm_encoder *encoder)
243
{
234
{
244
    struct drm_connector  *connector;
235
    struct drm_crtc *tmp_crtc;
245
    struct drm_connector_helper_funcs *connector_funcs;
-
 
246
 
-
 
247
    struct drm_connector  *def_connector = NULL;
236
    int crtc_mask = 1;
Line 248... Line 237...
248
 
237
 
249
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
238
    list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head)
250
    {
-
 
251
        struct drm_encoder  *encoder;
-
 
252
        struct drm_crtc     *crtc;
-
 
253
 
-
 
254
        if( connector->status != connector_status_connected)
-
 
255
            continue;
-
 
256
 
-
 
257
        connector_funcs = connector->helper_private;
-
 
258
        encoder = connector_funcs->best_encoder(connector);
-
 
259
        if( encoder == NULL)
-
 
260
            continue;
-
 
261
 
239
    {
262
        connector->encoder = encoder;
240
        if (encoder->possible_crtcs & crtc_mask)
263
 
241
    {
264
        crtc = encoder->crtc;
-
 
265
 
242
            encoder->crtc = tmp_crtc;
266
        DRM_DEBUG_KMS("CONNECTOR %x ID:  %d status %d encoder %x\n crtc %x",
-
 
267
                   connector, connector->base.id,
-
 
268
                   connector->status, connector->encoder,
243
            DRM_DEBUG_KMS("use CRTC %p ID %d\n", tmp_crtc, tmp_crtc->base.id);
269
                   crtc);
-
 
270
 
-
 
271
//        if (crtc == NULL)
-
 
272
//            continue;
-
 
273
 
-
 
274
        def_connector = connector;
-
 
275
 
-
 
276
        break;
244
            return tmp_crtc;
-
 
245
        };
277
    };
246
        crtc_mask <<= 1;
278
 
247
    };
279
    return def_connector;
248
    return NULL;
Line 280... Line 249...
280
};
249
};
-
 
250
 
281
 
251
static int choose_config(struct drm_device *dev, struct drm_connector **boot_connector,
282
struct drm_connector *get_active_connector(struct drm_device *dev)
-
 
283
{
252
                  struct drm_crtc **boot_crtc)
-
 
253
{
284
    struct drm_connector *tmp = NULL;
254
    struct drm_connector_helper_funcs *connector_funcs;
-
 
255
    struct drm_connector *connector;
Line 285... Line 256...
285
    struct drm_connector_helper_funcs *connector_funcs;
256
    struct drm_encoder   *encoder;
286
    struct drm_encoder   *encoder;
257
    struct drm_crtc      *crtc;
287
 
258
 
288
    list_for_each_entry(tmp, &dev->mode_config.connector_list, head)
259
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
Line -... Line 260...
-
 
260
    {
-
 
261
        if( connector->status != connector_status_connected)
-
 
262
            continue;
-
 
263
 
289
    {
264
        encoder = connector->encoder;
290
        if( tmp->status != connector_status_connected)
265
 
-
 
266
        if(encoder == NULL)
291
            continue;
267
        {
292
 
268
            connector_funcs = connector->helper_private;
293
        connector_funcs = tmp->helper_private;
269
            encoder = connector_funcs->best_encoder(connector);
294
        encoder = connector_funcs->best_encoder(tmp);
270
 
295
        if( encoder == NULL)
271
        if( encoder == NULL)
296
        {
272
        {
-
 
273
            DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n",
Line 297... Line 274...
297
            DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n",
274
                        connector, connector->base.id);
298
                      tmp, tmp->base.id);
-
 
299
            continue;
-
 
300
        };
275
            continue;
301
 
276
        };
Line 302... Line 277...
302
        tmp->encoder = encoder;
277
        }
303
 
278
 
-
 
279
        crtc = encoder->crtc;
-
 
280
        if(crtc == NULL)
Line -... Line 281...
-
 
281
            crtc = get_possible_crtc(dev, encoder);
-
 
282
 
-
 
283
        if(crtc != NULL)
304
        DRM_DEBUG_KMS("CONNECTOR %p ID:%d status:%d ENCODER %x CRTC %p ID:%d\n",
284
        {
305
               tmp, tmp->base.id, tmp->status, tmp->encoder,
285
            *boot_connector = connector;
-
 
286
            *boot_crtc = crtc;
-
 
287
 
Line 306... Line -...
306
               tmp->encoder->crtc, tmp->encoder->crtc->base.id );
-
 
307
 
-
 
308
        return tmp;
-
 
309
    };
-
 
310
 
-
 
311
    return NULL;
-
 
312
}
-
 
313
 
-
 
314
struct drm_crtc *get_possible_crtc(struct drm_device *dev, struct drm_encoder *encoder)
-
 
315
{
-
 
316
    struct drm_crtc *tmp_crtc;
-
 
317
    int crtc_mask = 1;
-
 
318
 
288
            DRM_DEBUG_KMS("CONNECTOR %p ID:%d status:%d ENCODER %p ID: %d CRTC %p ID:%d\n",
319
    list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head)
-
 
320
    {
289
                           connector, connector->base.id, connector->status,
321
        if (encoder->possible_crtcs & crtc_mask)
290
                           encoder, encoder->base.id, crtc, crtc->base.id );
322
        {
291
            return 0;
Line 323... Line 292...
323
            encoder->crtc = tmp_crtc;
292
        }
324
            dbgprintf("CRTC %p\n", tmp_crtc);
293
        else
325
            return tmp_crtc;
294
            DRM_DEBUG_KMS("No CRTC for encoder %d\n", encoder->base.id);
Line 326... Line 295...
326
        };
295
 
327
        crtc_mask <<= 1;
296
    };
328
    };
297
 
329
    return NULL;
298
    return -ENOENT;
330
};
299
};
Line 331... Line 300...
331
 
300
 
332
int get_boot_mode(struct drm_connector *connector, videomode_t *usermode)
301
static int get_boot_mode(struct drm_connector *connector, videomode_t *usermode)
333
{
302
{
334
    struct drm_display_mode *mode;
303
    struct drm_display_mode *mode;
335
 
304
 
336
    list_for_each_entry(mode, &connector->modes, head)
305
    list_for_each_entry(mode, &connector->modes, head)
337
    {
306
    {
Line 353... Line 322...
353
}
322
}
354
 
323
 
Line 355... Line 324...
355
int init_display_kms(struct drm_device *dev, videomode_t *usermode)
324
int init_display_kms(struct drm_device *dev, videomode_t *usermode)
356
{
325
{
357
    struct drm_connector    *connector;
-
 
358
    struct drm_connector_helper_funcs *connector_funcs;
326
    struct drm_connector_helper_funcs *connector_funcs;
359
    struct drm_encoder      *encoder;
327
    struct drm_connector    *connector = NULL;
360
    struct drm_crtc         *crtc;
328
    struct drm_crtc         *crtc = NULL;
361
    struct drm_framebuffer  *fb;
329
    struct drm_framebuffer  *fb;
Line 362... Line 330...
362
 
330
 
363
    cursor_t  *cursor;
331
    cursor_t  *cursor;
364
    u32_t      ifl;
332
    u32_t      ifl;
Line 365... Line 333...
365
    int        err;
333
    int        ret;
Line 366... Line 334...
366
 
334
 
367
    mutex_lock(&dev->mode_config.mutex);
335
    mutex_lock(&dev->mode_config.mutex);
368
 
336
 
369
    connector = get_active_connector(dev) ;
337
    ret = choose_config(dev, &connector, &crtc);
370
    if(connector == NULL)
338
    if(ret)
371
    {
339
    {
372
        DRM_DEBUG_KMS("No active connectors!\n");
340
        DRM_DEBUG_KMS("No active connectors!\n");
Line 373... Line 341...
373
        mutex_unlock(&dev->mode_config.mutex);
341
        mutex_unlock(&dev->mode_config.mutex);
374
        return -1;
342
        return -1;
Line 375... Line 343...
375
    };
343
    };
376
 
344
 
Line 377... Line -...
377
    encoder = connector->encoder;
-
 
378
    crtc = encoder->crtc;
-
 
379
 
-
 
380
    if(crtc == NULL)
345
    mutex_lock(&dev->object_name_lock);
381
        crtc = get_possible_crtc(dev, encoder);
-
 
382
 
-
 
Line -... Line 346...
-
 
346
    idr_preload(GFP_KERNEL);
-
 
347
 
-
 
348
    if (!main_fb_obj->base.name) {
383
    if(crtc == NULL)
349
        ret = idr_alloc(&dev->object_name_idr, &main_fb_obj->base, 1, 0, GFP_NOWAIT);
-
 
350
 
-
 
351
        main_fb_obj->base.name = ret;
-
 
352
 
-
 
353
        /* Allocate a reference for the name table.  */
-
 
354
        drm_gem_object_reference(&main_fb_obj->base);
Line 384... Line 355...
384
    {
355
 
385
        DRM_DEBUG_KMS("No CRTC for encoder %d\n", encoder->base.id);
356
        DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, main_fb_obj->base.name );
386
        mutex_unlock(&dev->mode_config.mutex);
357
    }
387
        return -1;
358
 
Line 388... Line 359...
388
    };
359
    idr_preload_end();
Line 389... Line -...
389
 
-
 
390
    DRM_DEBUG_KMS("[Select CRTC: %p ID:%d]\n",crtc, crtc->base.id);
360
    mutex_unlock(&dev->object_name_lock);
391
 
361
    drm_gem_object_unreference(&main_fb_obj->base);
392
    os_display = GetDisplay();
-
 
393
    os_display->ddev = dev;
-
 
394
    os_display->connector = connector;
362
 
395
    os_display->crtc = crtc;
363
    os_display = GetDisplay();
396
 
364
    os_display->ddev = dev;
397
    os_display->supported_modes = count_connector_modes(connector);
365
    os_display->connector = connector;
Line 413... Line 381...
413
        os_display->move_cursor    = move_cursor_kms;
381
        os_display->move_cursor    = move_cursor_kms;
414
        os_display->restore_cursor = restore_cursor;
382
        os_display->restore_cursor = restore_cursor;
415
        os_display->disable_mouse  = disable_mouse;
383
        os_display->disable_mouse  = disable_mouse;
416
 
384
 
Line 417... Line 385...
417
        intel_crtc->cursor_x = os_display->width/2;
385
        crtc->cursor_x = os_display->width/2;
418
        intel_crtc->cursor_y = os_display->height/2;
386
        crtc->cursor_y = os_display->height/2;
Line 419... Line 387...
419
 
387
 
420
        select_cursor_kms(os_display->cursor);
388
        select_cursor_kms(os_display->cursor);
421
    };
389
    };
Line 428... Line 396...
428
        {
396
        {
429
            struct drm_display_mode *mode;
397
            struct drm_display_mode *mode;
430
 
398
 
Line 431... Line 399...
431
            mode = list_entry(connector->modes.next, typeof(*mode), head);
399
            mode = list_entry(connector->modes.next, typeof(*mode), head);
432
            usermode->width  = drm_mode_width(mode);
400
            usermode->width  = mode->hdisplay;
433
            usermode->height = drm_mode_height(mode);
401
            usermode->height = mode->vdisplay;
434
            usermode->freq   = drm_mode_vrefresh(mode);
402
            usermode->freq   = drm_mode_vrefresh(mode);
435
        };
403
        };
436
    };
404
    };
Line 437... Line 405...
437
 
405
 
Line 438... Line 406...
438
    mutex_unlock(&dev->mode_config.mutex);
406
    mutex_unlock(&dev->mode_config.mutex);
Line 439... Line 407...
439
 
407
 
440
    set_mode(dev, os_display->connector, usermode, false);
408
    set_mode(dev, os_display->connector, os_display->crtc, usermode, false);
441
 
409
 
Line 471... Line 439...
471
        list_for_each_entry(drmmode, &os_display->connector->modes, head)
439
        list_for_each_entry(drmmode, &os_display->connector->modes, head)
472
        {
440
        {
473
            if( i < *count)
441
            if( i < *count)
474
            {
442
            {
475
                mode->width  = drm_mode_width(drmmode);
443
                mode->width  = drmmode->hdisplay;
476
                mode->height = drm_mode_height(drmmode);
444
                mode->height = drmmode->vdisplay;
477
                mode->bpp    = 32;
445
                mode->bpp    = 32;
478
                mode->freq   = drm_mode_vrefresh(drmmode);
446
                mode->freq   = drm_mode_vrefresh(drmmode);
479
                i++;
447
                i++;
480
                mode++;
448
                mode++;
481
            }
449
            }
Line 488... Line 456...
488
};
456
};
489
 
457
 
Line 490... Line 458...
490
int set_user_mode(videomode_t *mode)
458
int set_user_mode(videomode_t *mode)
491
{
459
{
492
    int err = -1;
-
 
Line 493... Line 460...
493
 
460
 
494
//    dbgprintf("width %d height %d vrefresh %d\n",
461
//    dbgprintf("width %d height %d vrefresh %d\n",
Line 495... Line 462...
495
//               mode->width, mode->height, mode->freq);
462
//               mode->width, mode->height, mode->freq);
Line 500... Line 467...
500
        ( (mode->width   != os_display->width)  ||
467
        ( (mode->width   != os_display->width)  ||
501
          (mode->height  != os_display->height) ||
468
          (mode->height  != os_display->height) ||
502
          (mode->freq    != os_display->vrefresh) ) )
469
          (mode->freq    != os_display->vrefresh) ) )
503
    {
470
    {
504
        if( set_mode(os_display->ddev, os_display->connector, mode, true) )
471
        return set_mode(os_display->ddev, os_display->connector, os_display->crtc, mode, true);
505
            err = 0;
472
    };
506
    };
-
 
507
 
473
 
Line 508... Line 474...
508
    return err;
474
    return -1;
509
};
475
};
Line 510... Line 476...
510
 
476
 
511
void i915_dpms(struct drm_device *dev, int mode)
477
void i915_dpms(struct drm_device *dev, int mode)
512
{
478
{
Line 518... Line 484...
518
void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor)
484
void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor)
519
{
485
{
520
    list_del(&cursor->list);
486
    list_del(&cursor->list);
Line 521... Line 487...
521
 
487
 
Line 522... Line 488...
522
    i915_gem_object_unpin(cursor->cobj);
488
    i915_gem_object_ggtt_unpin(cursor->cobj);
523
 
489
 
524
    mutex_lock(&main_device->struct_mutex);
490
    mutex_lock(&main_device->struct_mutex);
Line 538... Line 504...
538
 
504
 
Line 539... Line 505...
539
    int       i,j;
505
    int       i,j;
540
    int       ret;
506
    int       ret;
Line 541... Line 507...
541
 
507
 
542
    if (dev_priv->info->cursor_needs_physical)
508
    if (dev_priv->info.cursor_needs_physical)
543
    {
509
    {
544
        bits = (uint32_t*)KernelAlloc(CURSOR_WIDTH*CURSOR_HEIGHT*4);
510
        bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4);
545
        if (unlikely(bits == NULL))
511
        if (unlikely(bits == NULL))
546
            return ENOMEM;
512
            return ENOMEM;
547
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
513
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
548
    }
514
    }
549
    else
515
    else
550
    {
516
    {
551
        obj = i915_gem_alloc_object(os_display->ddev, CURSOR_WIDTH*CURSOR_HEIGHT*4);
517
        obj = i915_gem_alloc_object(os_display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4);
552
        if (unlikely(obj == NULL))
518
        if (unlikely(obj == NULL))
Line 553... Line 519...
553
            return -ENOMEM;
519
            return -ENOMEM;
554
 
520
 
555
        ret = i915_gem_obj_ggtt_pin(obj, CURSOR_WIDTH*CURSOR_HEIGHT*4, true, true);
521
        ret = i915_gem_obj_ggtt_pin(obj, 0,PIN_MAPPABLE | PIN_NONBLOCK);
556
        if (ret) {
522
        if (ret) {
557
            drm_gem_object_unreference(&obj->base);
523
            drm_gem_object_unreference(&obj->base);
Line 558... Line 524...
558
            return ret;
524
            return ret;
559
        }
525
        }
560
 
526
 
561
        ret = i915_gem_object_set_to_gtt_domain(obj, true);
527
        ret = i915_gem_object_set_to_gtt_domain(obj, true);
562
        if (ret)
528
        if (ret)
563
        {
529
        {
564
            i915_gem_object_unpin(obj);
530
            i915_gem_object_ggtt_unpin(obj);
565
            drm_gem_object_unreference(&obj->base);
531
            drm_gem_object_unreference(&obj->base);
566
            return ret;
532
            return ret;
Line 567... Line 533...
567
        }
533
        }
568
/* You don't need to worry about fragmentation issues.
534
/* You don't need to worry about fragmentation issues.
Line 569... Line 535...
569
 * GTT space is continuous. I guarantee it.                           */
535
 * GTT space is continuous. I guarantee it.                           */
570
 
536
 
571
        mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
537
        mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
572
                    CURSOR_WIDTH*CURSOR_HEIGHT*4, PG_SW);
538
                    KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW);
573
 
539
 
574
        if (unlikely(bits == NULL))
540
        if (unlikely(bits == NULL))
575
        {
541
        {
576
            i915_gem_object_unpin(obj);
542
            i915_gem_object_ggtt_unpin(obj);
Line 585... Line 551...
585
    for(i = 0; i < 32; i++)
551
    for(i = 0; i < 32; i++)
586
    {
552
    {
587
        for(j = 0; j < 32; j++)
553
        for(j = 0; j < 32; j++)
588
            *bits++ = *src++;
554
            *bits++ = *src++;
589
        for(j = 32; j < CURSOR_WIDTH; j++)
555
        for(j = 32; j < KMS_CURSOR_WIDTH; j++)
590
            *bits++ = 0;
556
            *bits++ = 0;
591
    }
557
    }
592
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
558
    for(i = 0; i < KMS_CURSOR_WIDTH*(KMS_CURSOR_HEIGHT-32); i++)
593
        *bits++ = 0;
559
        *bits++ = 0;
Line 594... Line 560...
594
 
560
 
Line 595... Line 561...
595
    FreeKernelSpace(mapped);
561
    FreeKernelSpace(mapped);
Line 611... Line 577...
611
    struct drm_crtc *crtc = os_display->crtc;
577
    struct drm_crtc *crtc = os_display->crtc;
612
    x-= cursor->hot_x;
578
    x-= cursor->hot_x;
613
    y-= cursor->hot_y;
579
    y-= cursor->hot_y;
614
 
580
 
Line -... Line 581...
-
 
581
	crtc->cursor_x = x;
-
 
582
	crtc->cursor_y = y;
-
 
583
 
-
 
584
	intel_crtc_update_cursor(crtc, 1);
-
 
585
 
615
    if (crtc->funcs->cursor_move)
586
//    if (crtc->funcs->cursor_move)
616
        crtc->funcs->cursor_move(crtc, x, y);
587
//        crtc->funcs->cursor_move(crtc, x, y);
Line 617... Line 588...
617
 
588
 
Line 618... Line 589...
618
};
589
};
619
 
590
 
620
 
591
 
-
 
592
cursor_t* __stdcall select_cursor_kms(cursor_t *cursor)
621
cursor_t* __stdcall select_cursor_kms(cursor_t *cursor)
593
{
-
 
594
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
622
{
595
    struct drm_crtc   *crtc = os_display->crtc;
Line 623... Line 596...
623
    struct drm_i915_private *dev_priv = os_display->ddev->dev_private;
596
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
624
    struct intel_crtc *intel_crtc = to_intel_crtc(os_display->crtc);
597
 
Line 625... Line 598...
625
    cursor_t *old;
598
    cursor_t *old;
Line 626... Line 599...
626
 
599
 
627
    old = os_display->cursor;
600
    old = os_display->cursor;
628
    os_display->cursor = cursor;
601
    os_display->cursor = cursor;
629
 
602
 
Line 630... Line 603...
630
    intel_crtc->cursor_bo = cursor->cobj;
603
    intel_crtc->cursor_bo = cursor->cobj;
631
 
604
 
Line 632... Line 605...
632
    if (!dev_priv->info->cursor_needs_physical)
605
    if (!dev_priv->info.cursor_needs_physical)
633
       intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj);
606
       intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj);
634
    else
607
    else
Line 635... Line 608...
635
        intel_crtc->cursor_addr = (addr_t)cursor->cobj;
608
        intel_crtc->cursor_addr = (addr_t)cursor->cobj;
636
 
609
 
Line 713... Line 686...
713
        if(warn_count < 1)
686
        if(warn_count < 1)
714
        {
687
        {
715
            printf("left %d top %d right %d bottom %d\n",
688
            printf("left %d top %d right %d bottom %d\n",
716
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
689
                    winrc.left, winrc.top, winrc.right, winrc.bottom);
717
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_size);
690
            printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_map);
718
            warn_count++;
691
            warn_count++;
719
        };
692
        };
720
#endif
693
#endif
721
 
694
 
Line 722... Line 695...
722
     };
695
     };