Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1246 serge 1
 
2
#include 
3
#include 
4
#include 
5
#include "radeon_drm.h"
6
#include "radeon.h"
7
#include "radeon_object.h"
8
#include "display.h"
9
10
 
11
 
12
static void       __stdcall move_cursor_kms(cursor_t *cursor, int x, int y);
13
14
 
15
16
 
17
{
18
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
19
    struct radeon_device *rdev = crtc->dev->dev_private;
20
21
 
22
        WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset);
23
        WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN |
24
                 (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT));
25
    } else {
26
        switch (radeon_crtc->crtc_id) {
27
        case 0:
28
            WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL);
29
            break;
30
        case 1:
31
            WREG32(RADEON_MM_INDEX, RADEON_CRTC2_GEN_CNTL);
32
            break;
33
        default:
34
            return;
35
        }
36
37
 
38
                      (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)),
39
             ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK));
40
    }
41
}
42
43
 
44
{
45
    struct radeon_device *rdev = crtc->dev->dev_private;
46
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
47
    uint32_t cur_lock;
48
49
 
50
        cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset);
51
        if (lock)
52
            cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK;
53
        else
54
            cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK;
55
        WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock);
56
    } else {
57
        cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset);
58
        if (lock)
59
            cur_lock |= RADEON_CUR_LOCK;
60
        else
61
            cur_lock &= ~RADEON_CUR_LOCK;
62
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock);
63
    }
64
}
65
66
 
67
{
68
    struct radeon_device *rdev;
69
    struct radeon_crtc   *radeon_crtc;
70
    cursor_t *old;
71
    uint32_t  gpu_addr;
72
73
 
74
    radeon_crtc = to_radeon_crtc(rdisplay->crtc);
75
76
 
77
78
 
79
    gpu_addr = cursor->robj->gpu_addr;
80
81
 
82
        WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr);
83
    else {
84
        radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr;
85
        /* offset is from DISP(2)_BASE_ADDRESS */
86
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset);
87
    }
88
89
 
90
};
91
92
 
93
{
94
    struct radeon_device *rdev;
95
    rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
96
    struct drm_crtc *crtc = rdisplay->crtc;
97
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
98
99
 
100
    int hot_y = cursor->hot_y;
101
102
 
103
    if (ASIC_IS_AVIVO(rdev))
104
    {
105
        int w = 32;
106
        int i = 0;
107
        struct drm_crtc *crtc_p;
108
109
 
110
//        x += crtc->x;
111
//        y += crtc->y;
112
113
 
114
#if 0
115
        /* avivo cursor image can't end on 128 pixel boundry or
116
         * go past the end of the frame if both crtcs are enabled
117
         */
118
        list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) {
119
            if (crtc_p->enabled)
120
                i++;
121
        }
122
        if (i > 1) {
123
            int cursor_end, frame_end;
124
125
 
126
            frame_end = crtc->x + crtc->mode.crtc_hdisplay;
127
            if (cursor_end >= frame_end) {
128
                w = w - (cursor_end - frame_end);
129
                if (!(frame_end & 0x7f))
130
                    w--;
131
            } else {
132
                if (!(cursor_end & 0x7f))
133
                    w--;
134
            }
135
            if (w <= 0)
136
                w = 1;
137
        }
138
#endif
139
        WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset,
140
               (x << 16) | y);
141
        WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset,
142
               (hot_x << 16) | hot_y);
143
        WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
144
               ((w - 1) << 16) | 31);
145
    } else {
146
        if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)
147
            y *= 2;
148
149
 
150
               (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16)));
151
        WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset,
152
               (RADEON_CUR_LOCK | (x << 16) | y));
153
154
 
155
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset,
156
         (radeon_crtc->legacy_cursor_offset + (hot_y * 256)));
157
    }
158
    radeon_lock_cursor_kms(crtc, false);
159
}
160
161
 
162
{
163
    static char name[4];
164
165
 
166
    name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@';
167
    name[2] = (x[1] & 0x1F) + '@';
168
    name[3] = 0;
169
170
 
171
}
172
173
 
174
              mode_t *reqmode, bool strict)
175
{
176
    struct drm_display_mode  *mode = NULL, *tmpmode;
177
178
 
179
180
 
181
182
 
183
               reqmode->width, reqmode->height, reqmode->freq);
184
185
 
186
    {
187
        if( (drm_mode_width(tmpmode)    == reqmode->width)  &&
188
            (drm_mode_height(tmpmode)   == reqmode->height) &&
189
            (drm_mode_vrefresh(tmpmode) == reqmode->freq) )
190
        {
191
            mode = tmpmode;
192
            goto do_set;
193
        }
194
    };
195
196
 
197
    {
198
        list_for_each_entry(tmpmode, &connector->modes, head)
199
        {
200
            if( (drm_mode_width(tmpmode)  == reqmode->width)  &&
201
                (drm_mode_height(tmpmode) == reqmode->height) )
202
            {
203
                mode = tmpmode;
204
                goto do_set;
205
            }
206
        };
207
    };
208
209
 
210
211
 
212
    {
213
        struct drm_framebuffer   *fb;
214
        struct drm_encoder       *encoder;
215
        struct drm_crtc          *crtc;
216
217
 
218
        char *con_name;
219
        char *enc_name;
220
221
 
222
        crtc = encoder->crtc;
223
224
 
225
                              struct drm_framebuffer, filp_head);
226
227
 
228
229
 
230
//        manufacturer_name(con_edid + 0x08),
231
//        (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)),
232
//        (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8)
233
//            + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24)));
234
235
 
236
        enc_name = drm_get_encoder_name(encoder);
237
238
 
239
                   reqmode->width, reqmode->height, con_name, enc_name);
240
241
 
242
        fb->height = reqmode->height;
243
        fb->pitch  = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8);
244
245
 
246
        crtc->enabled = true;
247
        rdisplay->crtc = crtc;
248
249
 
250
251
 
252
        radeon_show_cursor_kms(crtc);
253
254
 
255
        {
256
            rdisplay->width    = fb->width;
257
            rdisplay->height   = fb->height;
258
            rdisplay->pitch    = fb->pitch;
259
            rdisplay->vrefresh = drm_mode_vrefresh(mode);
260
261
 
262
263
 
264
                       fb->width, fb->height, fb->pitch);
265
        }
266
        else
267
            DRM_ERROR("failed to set mode %d_%d on crtc %p\n",
268
                       fb->width, fb->height, crtc);
269
    }
270
271
 
272
    return ret;
273
};
274
275
 
276
{
277
    struct drm_display_mode  *mode;
278
    int count = 0;
279
280
 
281
    {
282
        count++;
283
    };
284
    return count;
285
};
286
287
 
288
{
289
    struct drm_connector  *connector;
290
    struct drm_connector  *def_connector = NULL;
291
292
 
293
    {
294
        struct drm_encoder  *encoder;
295
        struct drm_crtc     *crtc;
296
297
 
298
            continue;
299
300
 
301
        if( encoder == NULL)
302
            continue;
303
304
 
305
        if(crtc == NULL)
306
            continue;
307
308
 
309
        break;
310
    };
311
312
 
313
};
314
315
 
316
{
317
    struct drm_device   *dev;
318
319
 
320
    bool                 retval = false;
321
    u32_t                ifl;
322
323
 
324
325
 
326
327
 
328
329
 
330
    {
331
        list_for_each_entry(cursor, &rdisplay->cursors, list)
332
        {
333
            init_cursor(cursor);
334
        };
335
    };
336
    safe_sti(ifl);
337
338
 
339
    if( rdisplay->connector == 0 )
340
    {
341
        dbgprintf("no active connectors\n");
342
        return false;
343
    };
344
345
 
346
    rdisplay->supported_modes = count_connector_modes(rdisplay->connector);
347
348
 
1268 serge 349
              rdisplay->width, rdisplay->height, rdisplay->vrefresh);
350
    dbgprintf("user mode mode %d x %d x %d\n",
351
              usermode->width, usermode->height, usermode->freq);
352
353
 
1246 serge 354
        (usermode->height != 0) &&
355
        ( (usermode->width  != rdisplay->width)  ||
356
          (usermode->height != rdisplay->height) ||
357
          (usermode->freq   != rdisplay->vrefresh) ) )
358
    {
359
360
 
361
    }
362
363
 
364
    {
365
        rdisplay->restore_cursor(0,0);
366
        rdisplay->init_cursor    = init_cursor;
367
        rdisplay->select_cursor  = select_cursor_kms;
368
        rdisplay->show_cursor    = NULL;
369
        rdisplay->move_cursor    = move_cursor_kms;
370
        rdisplay->restore_cursor = restore_cursor;
371
1268 serge 372
 
373
        radeon_show_cursor_kms(rdisplay->crtc);
1246 serge 374
    };
375
    safe_sti(ifl);
376
377
 
378
379
 
380
};
381
382
 
383
{
384
    int err = -1;
385
386
 
387
388
 
389
390
 
391
    {
392
        *count = rdisplay->supported_modes;
393
        err = 0;
394
    }
395
    else if( mode != NULL )
396
    {
397
        struct drm_display_mode  *drmmode;
398
        int i = 0;
399
400
 
401
            *count = rdisplay->supported_modes;
402
403
 
404
        {
405
            if( i < *count)
406
            {
407
                mode->width  = drm_mode_width(drmmode);
408
                mode->height = drm_mode_height(drmmode);
409
                mode->bpp    = 32;
410
                mode->freq   = drm_mode_vrefresh(drmmode);
411
                i++;
412
                mode++;
413
            }
414
            else break;
415
        };
416
        *count = i;
417
        err = 0;
418
    };
419
    LEAVE();
420
    return err;
421
}
422
423
 
424
{
425
    int err = -1;
426
427
 
428
429
 
430
               mode->width, mode->height, mode->freq);
431
432
 
433
        (mode->height != 0)  &&
434
        (mode->freq   != 0 ) &&
435
        ( (mode->width   != rdisplay->width)  ||
436
          (mode->height  != rdisplay->height) ||
437
          (mode->freq    != rdisplay->vrefresh) ) )
438
    {
439
        if( set_mode(rdisplay->ddev, rdisplay->connector, mode, true) )
440
            err = 0;
441
    };
442
443
 
444
    return err;
445
};
446