Subversion Repositories Kolibri OS

Rev

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

Rev 3764 Rev 5078
Line 1... Line 1...
1
#include 
1
#include 
-
 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
4
#include "radeon_drm.h"
-
 
5
#include "radeon.h"
5
#include "radeon.h"
6
#include "radeon_object.h"
6
#include "radeon_object.h"
7
#include "drm_fb_helper.h"
7
#include "drm_fb_helper.h"
8
#include "hmm.h"
8
#include "hmm.h"
9
#include "bitmap.h"
9
#include "bitmap.h"
10
#include "display.h"
10
#include "display.h"
Line 11... Line -...
11
 
-
 
12
struct radeon_fbdev {
-
 
13
    struct drm_fb_helper        helper;
11
 
14
    struct radeon_framebuffer   rfb;
-
 
15
    struct list_head fbdev_list;
12
extern struct drm_framebuffer *main_fb;
16
    struct radeon_device        *rdev;
-
 
17
};
-
 
18
 
-
 
Line -... Line 13...
-
 
13
extern struct drm_gem_object  *main_fb_obj;
Line 19... Line 14...
19
struct radeon_fbdev *kos_rfbdev;
14
 
20
 
15
display_t *os_display;
Line 21... Line 16...
21
 
16
 
Line 93... Line 88...
93
    struct radeon_crtc   *radeon_crtc;
88
    struct radeon_crtc   *radeon_crtc;
94
    cursor_t *old;
89
    cursor_t *old;
95
    uint32_t  gpu_addr;
90
    uint32_t  gpu_addr;
96
 
91
 
Line 97... Line 92...
97
    rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
92
    rdev = (struct radeon_device *)os_display->ddev->dev_private;
98
    radeon_crtc = to_radeon_crtc(rdisplay->crtc);
93
    radeon_crtc = to_radeon_crtc(os_display->crtc);
Line 99... Line 94...
99
 
94
 
Line 100... Line 95...
100
    old = rdisplay->cursor;
95
    old = os_display->cursor;
101
 
96
 
Line 102... Line 97...
102
    rdisplay->cursor = cursor;
97
    os_display->cursor = cursor;
103
    gpu_addr = radeon_bo_gpu_offset(cursor->robj);
98
    gpu_addr = radeon_bo_gpu_offset(cursor->robj);
104
 
99
 
Line 123... Line 118...
123
 
118
 
Line 124... Line 119...
124
void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y)
119
void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y)
125
{
120
{
126
    struct radeon_device *rdev;
121
    struct radeon_device *rdev;
127
    rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
122
    rdev = (struct radeon_device *)os_display->ddev->dev_private;
128
    struct drm_crtc *crtc = rdisplay->crtc;
123
    struct drm_crtc *crtc = os_display->crtc;
129
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
124
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
Line 130... Line 125...
130
 
125
 
131
    int hot_x = cursor->hot_x;
126
    int hot_x = cursor->hot_x;
132
    int hot_y = cursor->hot_y;
127
    int hot_y = cursor->hot_y;
Line 195... Line 190...
195
 
190
 
Line 196... Line 191...
196
    return name;
191
    return name;
197
}
192
}
Line 198... Line 193...
198
 
193
 
199
bool set_mode(struct drm_device *dev, struct drm_connector *connector,
194
static int set_mode(struct drm_device *dev, struct drm_connector *connector,
200
              videomode_t *reqmode, bool strict)
195
                    struct drm_crtc *crtc, videomode_t *reqmode, bool strict)
201
{
196
{
-
 
197
    struct drm_display_mode  *mode = NULL, *tmpmode;
-
 
198
    struct drm_framebuffer  *fb         = NULL;
-
 
199
    struct drm_mode_set     set;
-
 
200
    const char *con_name;
-
 
201
    unsigned hdisplay, vdisplay;
Line 202... Line -...
202
    struct drm_display_mode  *mode = NULL, *tmpmode;
-
 
203
 
-
 
204
    struct drm_fb_helper *fb_helper;
-
 
205
 
-
 
206
    fb_helper = &kos_rfbdev->helper;
-
 
207
 
202
    int ret;
208
 
-
 
209
    bool ret = false;
-
 
210
 
-
 
211
    ENTER();
-
 
212
 
-
 
Line 213... Line 203...
213
    dbgprintf("width %d height %d vrefresh %d\n",
203
 
214
               reqmode->width, reqmode->height, reqmode->freq);
204
    drm_modeset_lock_all(dev);
215
 
205
 
216
    list_for_each_entry(tmpmode, &connector->modes, head)
206
    list_for_each_entry(tmpmode, &connector->modes, head)
217
    {
207
    {
218
        if( (drm_mode_width(tmpmode)    == reqmode->width)  &&
208
        if( (tmpmode->hdisplay == reqmode->width)  &&
219
            (drm_mode_height(tmpmode)   == reqmode->height) &&
209
            (tmpmode->vdisplay == reqmode->height) &&
220
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
210
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
221
        {
211
        {
Line 227... Line 217...
227
    if( (mode == NULL) && (strict == false) )
217
    if( (mode == NULL) && (strict == false) )
228
    {
218
    {
229
        list_for_each_entry(tmpmode, &connector->modes, head)
219
        list_for_each_entry(tmpmode, &connector->modes, head)
230
        {
220
        {
231
            if( (drm_mode_width(tmpmode)  == reqmode->width)  &&
221
            if( (tmpmode->hdisplay == reqmode->width)  &&
232
                (drm_mode_height(tmpmode) == reqmode->height) )
222
                (tmpmode->vdisplay == reqmode->height) )
233
            {
223
            {
234
                mode = tmpmode;
224
                mode = tmpmode;
235
                goto do_set;
225
                goto do_set;
236
            }
226
            }
237
        };
227
       };
238
    };
228
    };
Line 239... Line -...
239
 
-
 
240
do_set:
-
 
241
 
-
 
242
    if( mode != NULL )
-
 
243
    {
-
 
244
        struct drm_framebuffer   *fb;
229
 
245
        struct drm_encoder       *encoder;
-
 
Line 246... Line -...
246
        struct drm_crtc          *crtc;
-
 
247
 
-
 
248
//        char  con_edid[128];
230
    DRM_ERROR("%s failed\n", __FUNCTION__);
Line 249... Line -...
249
        char *con_name;
-
 
250
        char *enc_name;
231
 
Line 251... Line -...
251
 
-
 
252
        encoder = connector->encoder;
232
    return -1;
Line -... Line 233...
-
 
233
 
253
        crtc = encoder->crtc;
234
do_set:
-
 
235
 
Line 254... Line -...
254
 
-
 
255
//        fb = list_first_entry(&dev->mode_config.fb_kernel_list,
236
    con_name = connector->name;
256
//                              struct drm_framebuffer, filp_head);
-
 
257
 
-
 
258
//        memcpy(con_edid, connector->edid_blob_ptr->data, 128);
-
 
Line 259... Line 237...
259
 
237
 
260
//        dbgprintf("Manufacturer: %s Model %x Serial Number %u\n",
238
    DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s\n",
Line 261... Line 239...
261
//        manufacturer_name(con_edid + 0x08),
239
              reqmode->width, reqmode->height, crtc->base.id,
262
//        (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)),
240
              con_name);
Line 263... Line 241...
263
//        (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8)
241
 
Line 264... Line 242...
264
//            + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24)));
242
    drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
265
 
243
 
Line -... Line 244...
-
 
244
    hdisplay = mode->hdisplay;
-
 
245
    vdisplay = mode->vdisplay;
266
        con_name = drm_get_connector_name(connector);
246
 
267
        enc_name = drm_get_encoder_name(encoder);
247
    if (crtc->invert_dimensions)
268
 
248
        swap(hdisplay, vdisplay);
269
        dbgprintf("set mode %d %d connector %s encoder %s\n",
249
 
Line 270... Line -...
270
                   reqmode->width, reqmode->height, con_name, enc_name);
-
 
271
 
250
    fb = main_fb;
272
        fb = fb_helper->fb;
251
 
-
 
252
    fb->width  = reqmode->width;
-
 
253
    fb->height = reqmode->height;
-
 
254
 
-
 
255
    fb->pitches[0] =
-
 
256
    fb->pitches[1] =
-
 
257
    fb->pitches[2] =
-
 
258
    fb->pitches[3] = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8);
-
 
259
    fb->bits_per_pixel = 32;
Line 273... Line 260...
273
 
260
    fb->depth = 24;
Line -... Line 261...
-
 
261
 
-
 
262
    crtc->enabled = true;
274
        fb->width  = reqmode->width;
263
    os_display->crtc = crtc;
275
        fb->height = reqmode->height;
264
 
Line 276... Line 265...
276
 
265
    set.crtc = crtc;
277
        fb->pitches[0] = fb->pitches[1] = fb->pitches[2] =
266
    set.x = 0;
278
                         fb->pitches[3] = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8);
267
    set.y = 0;
279
        fb->bits_per_pixel = 32;
268
    set.mode = mode;
280
        fb->depth = 24;
-
 
281
 
269
    set.connectors = &connector;
Line 282... Line 270...
282
        crtc->fb = fb;
270
    set.num_connectors = 1;
Line 283... Line 271...
283
        crtc->enabled = true;
271
    set.fb = fb;
284
        rdisplay->crtc = crtc;
272
 
285
 
273
    ret = drm_mode_set_config_internal(&set);
286
        ret = drm_crtc_helper_set_mode(crtc, mode, 0, 0, fb);
274
 
287
 
275
    drm_modeset_unlock_all(dev);
288
        select_cursor_kms(rdisplay->cursor);
276
 
289
        radeon_show_cursor_kms(crtc);
-
 
Line 290... Line -...
290
 
-
 
291
        if (ret == true)
277
    select_cursor_kms(os_display->cursor);
292
        {
278
    radeon_show_cursor_kms(crtc);
Line 293... Line 279...
293
            rdisplay->width    = fb->width;
279
 
294
            rdisplay->height   = fb->height;
280
    if ( !ret )
295
            rdisplay->pitch    = fb->pitches[0];
281
    {
296
            rdisplay->vrefresh = drm_mode_vrefresh(mode);
282
        os_display->width    = fb->width;
Line 320... Line 306...
320
    };
306
    };
321
    return count;
307
    return count;
322
};
308
};
323
 
309
 
Line 324... Line 310...
324
static struct drm_connector* get_def_connector(struct drm_device *dev)
310
static struct drm_crtc *get_possible_crtc(struct drm_device *dev, struct drm_encoder *encoder)
325
{
311
{
326
    struct drm_connector  *connector;
312
    struct drm_crtc *tmp_crtc;
327
    struct drm_connector_helper_funcs *connector_funcs;
313
    int crtc_mask = 1;
Line -... Line 314...
-
 
314
 
-
 
315
    list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head)
328
 
316
    {
-
 
317
        if (encoder->possible_crtcs & crtc_mask)
-
 
318
        {
-
 
319
            encoder->crtc = tmp_crtc;
-
 
320
            DRM_DEBUG_KMS("use CRTC %p ID %d\n", tmp_crtc, tmp_crtc->base.id);
-
 
321
            return tmp_crtc;
-
 
322
        };
-
 
323
        crtc_mask <<= 1;
-
 
324
    };
-
 
325
    return NULL;
Line 329... Line 326...
329
    struct drm_connector  *def_connector = NULL;
326
};
-
 
327
 
330
 
328
static int choose_config(struct drm_device *dev, struct drm_connector **boot_connector,
-
 
329
                  struct drm_crtc **boot_crtc)
-
 
330
{
331
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
331
    struct drm_connector_helper_funcs *connector_funcs;
332
    {
332
    struct drm_connector *connector;
Line -... Line 333...
-
 
333
    struct drm_encoder   *encoder;
-
 
334
    struct drm_crtc      *crtc;
333
        struct drm_encoder  *encoder;
335
 
334
        struct drm_crtc     *crtc;
336
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
Line -... Line 337...
-
 
337
    {
-
 
338
        if( connector->status != connector_status_connected)
-
 
339
            continue;
-
 
340
 
335
 
341
        encoder = connector->encoder;
336
        if( connector->status != connector_status_connected)
342
 
-
 
343
        if(encoder == NULL)
337
            continue;
344
        {
-
 
345
            connector_funcs = connector->helper_private;
-
 
346
            encoder = connector_funcs->best_encoder(connector);
-
 
347
 
338
 
348
            if( encoder == NULL)
339
        connector_funcs = connector->helper_private;
-
 
340
        encoder = connector_funcs->best_encoder(connector);
349
            {
-
 
350
                DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n",
Line 341... Line 351...
341
        if( encoder == NULL)
351
                        connector, connector->base.id);
-
 
352
                continue;
-
 
353
            };
Line -... Line 354...
-
 
354
        }
-
 
355
 
-
 
356
        crtc = encoder->crtc;
-
 
357
        if(crtc == NULL)
-
 
358
            crtc = get_possible_crtc(dev, encoder);
342
            continue;
359
 
343
 
360
        if(crtc != NULL)
344
        connector->encoder = encoder;
361
        {
345
 
362
            *boot_connector = connector;
346
        crtc = encoder->crtc;
-
 
347
 
363
            *boot_crtc = crtc;
348
        dbgprintf("CONNECTOR %x ID:  %d status %d encoder %x\n crtc %x",
364
            connector->encoder = encoder;
349
                   connector, connector->base.id,
-
 
350
                   connector->status, connector->encoder,
365
            DRM_DEBUG_KMS("CONNECTOR %p ID:%d status:%d ENCODER %p ID: %d CRTC %p ID:%d\n",
Line 351... Line -...
351
                   crtc);
-
 
352
 
366
                           connector, connector->base.id, connector->status,
Line 353... Line 367...
353
//        if (crtc == NULL)
367
                           encoder, encoder->base.id, crtc, crtc->base.id );
354
//            continue;
368
            return 0;
Line -... Line 369...
-
 
369
        }
-
 
370
        else
-
 
371
            DRM_DEBUG_KMS("No CRTC for encoder %d\n", encoder->base.id);
Line -... Line 372...
-
 
372
 
-
 
373
    };
-
 
374
 
-
 
375
    return -ENOENT;
-
 
376
};
355
 
377
 
356
        def_connector = connector;
378
static int get_boot_mode(struct drm_connector *connector, videomode_t *usermode)
-
 
379
{
-
 
380
    struct drm_display_mode *mode;
357
 
381
 
-
 
382
    list_for_each_entry(mode, &connector->modes, head)
-
 
383
    {
358
        break;
384
        DRM_DEBUG_KMS("check mode w:%d h:%d %dHz\n",
-
 
385
                mode->hdisplay, mode->vdisplay,
-
 
386
                drm_mode_vrefresh(mode));
-
 
387
 
-
 
388
        if( os_display->width  == mode->hdisplay &&
-
 
389
            os_display->height == mode->vdisplay &&
Line 359... Line 390...
359
    };
390
            drm_mode_vrefresh(mode) == 60)
-
 
391
        {
360
 
392
            usermode->width  = os_display->width;
361
    return def_connector;
393
            usermode->height = os_display->height;
362
};
394
            usermode->freq   = 60;
363
 
395
            return 1;
364
 
-
 
365
 
-
 
Line 366... Line 396...
366
bool init_display_kms(struct radeon_device *rdev, videomode_t *usermode)
396
        }
367
{
-
 
368
    struct drm_device   *dev;
397
    }
-
 
398
    return 0;
Line 369... Line 399...
369
 
399
}
370
    struct drm_connector    *connector;
-
 
371
    struct drm_connector_helper_funcs *connector_funcs;
-
 
372
    struct drm_encoder      *encoder;
-
 
373
    struct drm_crtc         *crtc = NULL;
-
 
374
    struct drm_framebuffer  *fb;
-
 
375
    struct drm_display_mode *native;
-
 
376
 
-
 
377
 
-
 
378
    cursor_t            *cursor;
-
 
379
    bool                 retval = false;
-
 
380
    u32_t                ifl;
-
 
381
 
-
 
Line 382... Line 400...
382
    struct radeon_fbdev  *rfbdev;
400
 
383
    struct drm_fb_helper *fb_helper;
-
 
384
 
401
int init_display_kms(struct drm_device *dev, videomode_t *usermode)
385
    int i;
402
{
386
 
-
 
387
    ENTER();
403
    struct drm_connector_helper_funcs *connector_funcs;
388
 
-
 
389
    dev = rdev->ddev;
-
 
390
 
-
 
391
    list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-
 
392
    {
-
 
393
        if( connector->status != connector_status_connected)
-
 
394
            continue;
-
 
395
 
-
 
396
        connector_funcs = connector->helper_private;
-
 
397
        encoder = connector_funcs->best_encoder(connector);
-
 
398
        if( encoder == NULL)
-
 
399
        {
-
 
400
            dbgprintf("CONNECTOR %x ID: %d no active encoders\n",
-
 
401
                      connector, connector->base.id);
-
 
402
            continue;
-
 
403
        }
404
    struct drm_connector    *connector = NULL;
404
        connector->encoder = encoder;
405
    struct drm_crtc         *crtc = NULL;
405
 
406
    struct drm_framebuffer  *fb;
Line 406... Line 407...
406
        dbgprintf("CONNECTOR %x ID:  %d status %d encoder %x\n crtc %x\n",
407
 
407
               connector, connector->base.id,
408
    cursor_t            *cursor;
-
 
409
    u32_t                ifl;
Line 408... Line 410...
408
               connector->status, connector->encoder,
410
    int        ret;
409
               encoder->crtc);
411
 
410
 
412
    mutex_lock(&dev->mode_config.mutex);
411
        crtc = encoder->crtc;
413
 
412
        break;
414
    ret = choose_config(dev, &connector, &crtc);
413
    };
415
    if(ret)
414
 
416
    {
415
    if(connector == NULL)
417
        DRM_DEBUG_KMS("No active connectors!\n");
416
    {
418
        mutex_unlock(&dev->mode_config.mutex);
417
        dbgprintf("No active connectors!\n");
419
        return -1;
418
        return -1;
-
 
Line 419... Line 420...
419
    };
420
    };
420
 
421
 
421
    {
-
 
422
        struct drm_display_mode *tmp;
422
    {
423
 
423
        struct drm_display_mode *tmp, *native = NULL;
424
        list_for_each_entry(tmp, &connector->modes, head) {
424
        struct radeon_device *rdev = dev->dev_private;
425
            if (drm_mode_width(tmp) > 16384 ||
425
 
-
 
426
        list_for_each_entry(tmp, &connector->modes, head) {
Line -... Line 427...
-
 
427
            if (tmp->hdisplay > 16384 ||
-
 
428
                tmp->vdisplay > 16384)
-
 
429
                continue;
Line 426... Line -...
426
                drm_mode_height(tmp) > 16384)
-
 
427
                continue;
-
 
428
            if (tmp->type & DRM_MODE_TYPE_PREFERRED)
-
 
429
            {
430
            if (tmp->type & DRM_MODE_TYPE_PREFERRED)
430
                native = tmp;
-
 
431
                break;
431
            {
432
            };
-
 
433
        }
-
 
434
    }
-
 
435
 
-
 
436
    if( ASIC_IS_AVIVO(rdev) && native )
-
 
437
    {
-
 
438
        dbgprintf("native w %d h %d\n", native->hdisplay, native->vdisplay);
-
 
439
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(connector->encoder);
-
 
440
        radeon_encoder->rmx_type = RMX_FULL;
-
 
441
        radeon_encoder->native_mode = *native;
-
 
442
    };
-
 
443
 
-
 
444
 
-
 
445
    if(crtc == NULL)
-
 
446
    {
-
 
447
        struct drm_crtc *tmp_crtc;
-
 
448
        int crtc_mask = 1;
-
 
449
 
-
 
450
        list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head)
-
 
Line -... Line 432...
-
 
432
                native = tmp;
Line -... Line 433...
-
 
433
                break;
451
        {
434
            };
Line 452... Line -...
452
            if (encoder->possible_crtcs & crtc_mask)
-
 
453
            {
-
 
454
                crtc = tmp_crtc;
435
        }
455
                encoder->crtc = crtc;
436
 
Line -... Line 437...
-
 
437
        if( ASIC_IS_AVIVO(rdev) && native )
-
 
438
        {
456
                break;
439
            struct radeon_encoder *radeon_encoder = to_radeon_encoder(connector->encoder);
-
 
440
            radeon_encoder->rmx_type = RMX_FULL;
Line -... Line 441...
-
 
441
            radeon_encoder->native_mode = *native;
-
 
442
        };
-
 
443
    }
-
 
444
 
Line -... Line 445...
-
 
445
#if 0
Line 457... Line 446...
457
            };
446
    mutex_lock(&dev->object_name_lock);
458
            crtc_mask <<= 1;
447
    idr_preload(GFP_KERNEL);
459
        };
448
 
460
    };
449
    if (!main_fb_obj->name) {
461
 
450
        ret = idr_alloc(&dev->object_name_idr, &main_fb_obj, 1, 0, GFP_NOWAIT);
462
    if(crtc == NULL)
451
 
Line -... Line 452...
-
 
452
        main_fb_obj->name = ret;
-
 
453
 
-
 
454
        /* Allocate a reference for the name table.  */
-
 
455
        drm_gem_object_reference(main_fb_obj);
-
 
456
 
-
 
457
        DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, main_fb_obj->name );
-
 
458
    }
-
 
459
 
463
    {
460
    idr_preload_end();
464
        dbgprintf("No CRTC for encoder %d\n", encoder->base.id);
461
    mutex_unlock(&dev->object_name_lock);
Line 465... Line 462...
465
        return -1;
462
    drm_gem_object_unreference(main_fb_obj);
466
    };
463
#endif
467
 
464
 
468
 
465
    os_display = GetDisplay();
Line 469... Line -...
469
    dbgprintf("[Select CRTC:%d]\n", crtc->base.id);
-
 
470
 
466
    os_display->ddev = dev;
471
 
467
    os_display->connector = connector;
472
//    drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
-
 
473
 
-
 
474
    rdisplay = GetDisplay();
-
 
475
    rdisplay->ddev = dev;
468
    os_display->crtc = crtc;
476
    rdisplay->connector = connector;
-
 
477
    rdisplay->crtc = crtc;
469
 
478
 
-
 
479
    rdisplay->supported_modes = count_connector_modes(connector);
-
 
480
 
470
    os_display->supported_modes = count_connector_modes(connector);
481
 
-
 
482
 
471
 
483
    ifl = safe_cli();
-
 
484
    {
-
 
485
        list_for_each_entry(cursor, &rdisplay->cursors, list)
-
 
486
        {
-
 
487
            init_cursor(cursor);
-
 
488
        };
-
 
489
 
-
 
490
    };
-
 
491
    safe_sti(ifl);
-
 
492
 
-
 
493
 
-
 
494
    dbgprintf("current mode %d x %d x %d\n",
-
 
495
              rdisplay->width, rdisplay->height, rdisplay->vrefresh);
-
 
Line -... Line 472...
-
 
472
    ifl = safe_cli();
496
    dbgprintf("user mode mode %d x %d x %d\n",
473
    {
497
              usermode->width, usermode->height, usermode->freq);
474
        list_for_each_entry(cursor, &os_display->cursors, list)
-
 
475
        {
498
 
476
            init_cursor(cursor);
499
 
477
        };
-
 
478
 
-
 
479
        os_display->restore_cursor(0,0);
Line 500... Line 480...
500
    if( (usermode->width  != 0) &&
480
        os_display->init_cursor    = init_cursor;
Line 501... Line 481...
501
        (usermode->height != 0) &&
481
        os_display->select_cursor  = select_cursor_kms;
Line 502... Line 482...
502
        ( (usermode->width  != rdisplay->width)  ||
482
        os_display->show_cursor    = NULL;
503
          (usermode->height != rdisplay->height) ||
483
        os_display->move_cursor    = move_cursor_kms;
Line -... Line 484...
-
 
484
        os_display->restore_cursor = restore_cursor;
504
          (usermode->freq   != rdisplay->vrefresh) ) )
485
        os_display->disable_mouse  = disable_mouse;
505
    {
486
        select_cursor_kms(os_display->cursor);
506
 
487
    };
Line 507... Line -...
507
        retval = set_mode(dev, rdisplay->connector, usermode, false);
-
 
508
    }
-
 
509
    else
-
 
510
    {
-
 
511
        usermode->width  = rdisplay->width;
488
    safe_sti(ifl);
512
        usermode->height = rdisplay->height;
489
 
513
        usermode->freq   = 60;
490
 
514
        retval = set_mode(dev, rdisplay->connector, usermode, false);
491
//    dbgprintf("current mode %d x %d x %d\n",
515
    };
492
//              os_display->width, os_display->height, os_display->vrefresh);
516
 
493
//    dbgprintf("user mode mode %d x %d x %d\n",
517
    ifl = safe_cli();
494
//              usermode->width, usermode->height, usermode->freq);
518
    {
495
 
519
        rdisplay->restore_cursor(0,0);
496
    if( (usermode->width == 0) ||
Line 520... Line 497...
520
        rdisplay->init_cursor    = init_cursor;
497
        (usermode->height == 0))
521
        rdisplay->select_cursor  = select_cursor_kms;
498
    {
Line 522... Line 499...
522
        rdisplay->show_cursor    = NULL;
499
        if( !get_boot_mode(connector, usermode))
523
        rdisplay->move_cursor    = move_cursor_kms;
500
        {
524
        rdisplay->restore_cursor = restore_cursor;
501
            struct drm_display_mode *mode;
525
        rdisplay->disable_mouse  = disable_mouse;
502
 
526
 
503
            mode = list_entry(connector->modes.next, typeof(*mode), head);
527
        select_cursor_kms(rdisplay->cursor);
504
            usermode->width  = mode->hdisplay;
528
        radeon_show_cursor_kms(rdisplay->crtc);
505
            usermode->height = mode->vdisplay;
529
    };
506
            usermode->freq   = drm_mode_vrefresh(mode);
530
    safe_sti(ifl);
507
        };
531
 
508
    };
532
//    init_bitmaps();
509
 
533
 
510
    mutex_unlock(&dev->mode_config.mutex);
534
    LEAVE();
511
 
535
 
512
    set_mode(dev, os_display->connector, os_display->crtc, usermode, false);
536
    return retval;
513
 
537
};
514
    radeon_show_cursor_kms(os_display->crtc);
538
 
-
 
539
int get_modes(videomode_t *mode, int *count)
515
 
540
{
516
    return 0;
Line 541... Line 517...
541
    int err = -1;
517
};
542
 
518
 
543
//    ENTER();
519
 
Line 544... Line -...
544
 
-
 
545
    dbgprintf("mode %x count %d\n", mode, *count);
-
 
546
 
-
 
547
    if( *count == 0 )
-
 
548
    {
-
 
549
        *count = rdisplay->supported_modes;
520
int get_videomodes(videomode_t *mode, int *count)
550
        err = 0;
521
{
551
    }
522
    int err = -1;
552
    else if( mode != NULL )
523
 
553
    {
524
    if( *count == 0 )
554
        struct drm_display_mode  *drmmode;
525
    {
555
        int i = 0;
526
        *count = os_display->supported_modes;
556
 
527
        err = 0;
557
        if( *count > rdisplay->supported_modes)
-
 
558
            *count = rdisplay->supported_modes;
528
    }
Line 559... Line -...
559
 
-
 
560
        list_for_each_entry(drmmode, &rdisplay->connector->modes, head)
529
    else if( mode != NULL )
561
        {
530
    {
Line 562... Line -...
562
            if( i < *count)
-
 
563
            {
-
 
564
                mode->width  = drm_mode_width(drmmode);
-
 
565
                mode->height = drm_mode_height(drmmode);
-
 
566
                mode->bpp    = 32;
-
 
567
                mode->freq   = drm_mode_vrefresh(drmmode);
-
 
568
                i++;
-
 
569
                mode++;
-
 
570
            }
-
 
571
            else break;
-
 
572
        };
-
 
573
        *count = i;
-
 
574
        err = 0;
-
 
575
    };
-
 
576
//    LEAVE();
-
 
577
    return err;
-
 
578
}
-
 
579
 
-
 
580
int set_user_mode(videomode_t *mode)
-
 
581
{
-
 
582
    int err = -1;
-
 
583
 
-
 
584
//    ENTER();
-
 
585
 
-
 
586
    dbgprintf("width %d height %d vrefresh %d\n",
-
 
587
               mode->width, mode->height, mode->freq);
-
 
588
 
-
 
589
    if( (mode->width  != 0)  &&
-
 
590
        (mode->height != 0)  &&
-
 
591
        (mode->freq   != 0 ) &&
-
 
592
        ( (mode->width   != rdisplay->width)  ||
-
 
593
          (mode->height  != rdisplay->height) ||
-
 
594
          (mode->freq    != rdisplay->vrefresh) ) )
-
 
595
    {
-
 
596
        if( set_mode(rdisplay->ddev, rdisplay->connector, mode, true) )
-
 
597
            err = 0;
-
 
598
    };
-
 
599
 
-
 
600
//    LEAVE();
-
 
601
    return err;
-
 
602
};
-
 
603
 
-
 
604
 
-
 
605
int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
-
 
606
                     struct drm_mode_fb_cmd2 *mode_cmd,
-
 
607
                     struct drm_gem_object **gobj_p)
-
 
608
{
-
 
609
    struct radeon_device *rdev = rfbdev->rdev;
-
 
610
    struct drm_gem_object *gobj = NULL;
-
 
611
    struct radeon_bo *rbo = NULL;
-
 
612
    bool fb_tiled = false; /* useful for testing */
-
 
613
    u32 tiling_flags = 0;
-
 
614
    int ret;
-
 
615
    int aligned_size, size;
-
 
616
    int height = mode_cmd->height;
-
 
617
    u32 bpp, depth;
-
 
618
 
-
 
619
    static struct radeon_bo kos_bo;
-
 
620
    static struct drm_mm_node  vm_node;
-
 
621
 
-
 
622
 
-
 
623
    drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
-
 
624
 
-
 
625
    /* need to align pitch with crtc limits */
-
 
626
    mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, bpp,
-
 
627
                          fb_tiled) * ((bpp + 1) / 8);
-
 
628
 
-
 
629
    if (rdev->family >= CHIP_R600)
-
 
Line 630... Line -...
630
        height = ALIGN(mode_cmd->height, 8);
-
 
631
    size = mode_cmd->pitches[0] * height;
-
 
632
    aligned_size = ALIGN(size, PAGE_SIZE);
-
 
Line 633... Line 531...
633
 
531
        struct drm_display_mode  *drmmode;
634
#ifndef __TTM__
532
        int i = 0;
635
    ret = drm_gem_object_init(rdev->ddev, &kos_bo.gem_base, aligned_size);
533
 
636
    if (unlikely(ret)) {
534
        if( *count > os_display->supported_modes)
Line 685... Line 583...
685
    int bottom;
583
    int bottom;
686
}rect_t;
584
}rect_t;
687
 
585
 
Line 688... Line 586...
688
extern struct hmm bm_mm;
586
extern struct hmm bm_mm;
689
struct drm_device *main_drm_device;
587
struct drm_device *main_device;
Line 690... Line 588...
690
 
588
 
Line 691... Line 589...
691
void  FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect");
589
void  FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect");
Line 692... Line 590...
692
 
590
 
693
#define CURRENT_TASK             (0x80003000)
591
#define CURRENT_TASK             (0x80003000)
694
 
592
 
Line 695... Line 593...
695
static u32_t get_display_map()
593
static u32_t get_display_map()
696
{
594
{
697
    u32_t   addr;
595
    u32_t   addr;
698
 
596
 
Line 699... Line 597...
699
    addr = (u32_t)rdisplay;
597
    addr = (u32_t)os_display;
Line 790... Line 688...
790
 
688
 
Line 791... Line 689...
791
        src_offset = (u8*)(src_y*bitmap->pitch + src_x*4);
689
        src_offset = (u8*)(src_y*bitmap->pitch + src_x*4);
792
        src_offset += (u32)bitmap->uaddr;
690
        src_offset += (u32)bitmap->uaddr;
Line 793... Line 691...
793
 
691
 
794
        dst_offset = (u8*)(dst_y*rdisplay->width + dst_x);
692
        dst_offset = (u8*)(dst_y*os_display->width + dst_x);
Line 795... Line 693...
795
        dst_offset+= get_display_map();
693
        dst_offset+= get_display_map();
Line 796... Line 694...
796
 
694
 
Line 804... Line 702...
804
            u32* tmp_src = src_offset;
702
            u32* tmp_src = src_offset;
805
            u8*  tmp_dst = dst_offset;
703
            u8*  tmp_dst = dst_offset;
Line 806... Line 704...
806
 
704
 
807
            src_offset+= bitmap->pitch;
705
            src_offset+= bitmap->pitch;
Line 808... Line 706...
808
            dst_offset+= rdisplay->width;
706
            dst_offset+= os_display->width;
809
 
707
 
810
            while( tmp_w--)
708
            while( tmp_w--)
Line 864... Line 762...
864
                  RADEON_DP_SRC_SOURCE_MEMORY |
762
                  RADEON_DP_SRC_SOURCE_MEMORY |
865
                  RADEON_GMC_WR_MSK_DIS;
763
                  RADEON_GMC_WR_MSK_DIS;
866
 
764
 
Line 867... Line 765...
867
    ib->ptr[4] = ((bitmap->pitch/64) << 22) | (bitmap->gaddr >> 10);
765
    ib->ptr[4] = ((bitmap->pitch/64) << 22) | (bitmap->gaddr >> 10);
868
    ib->ptr[5] = ((rdisplay->pitch/64) << 22) | (rdev->mc.vram_start >> 10);
766
    ib->ptr[5] = ((os_display->pitch/64) << 22) | (rdev->mc.vram_start >> 10);
869
    ib->ptr[6] = (0x1fff) | (0x1fff << 16);
767
    ib->ptr[6] = (0x1fff) | (0x1fff << 16);
870
    ib->ptr[7] = 0;
768
    ib->ptr[7] = 0;
871
    ib->ptr[8] = (0x1fff) | (0x1fff << 16);
769
    ib->ptr[8] = (0x1fff) | (0x1fff << 16);
Line 872... Line 770...
872
 
770