Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1221 serge 1
 
2
#include 
3
#include 
4
#include 
5
#include "radeon_drm.h"
6
#include "radeon.h"
7
#include "radeon_object.h"
8
9
 
10
#define CURSOR_HEIGHT 64
11
12
 
13
typedef struct tag_display display_t;
14
15
 
16
{
17
    uint32_t   magic;
18
    void      *destroy;
19
    kobj_t    *fd;
20
    kobj_t    *bk;
21
    uint32_t   pid;
22
};
23
24
 
25
{
26
    kobj_t     header;
27
28
 
29
    uint32_t   hot_x;
30
    uint32_t   hot_y;
31
32
 
33
    struct radeon_object *robj;
34
}cursor_t;
35
36
 
1230 serge 37
cursor_t*  __stdcall select_cursor(cursor_t *cursor);
38
void       __stdcall move_cursor(cursor_t *cursor, int x, int y);
39
void       __stdcall restore_cursor(int x, int y);
40
41
 
1221 serge 42
{
43
    int  x;
44
    int  y;
45
    int  width;
46
    int  height;
47
    int  bpp;
48
    int  vrefresh;
49
    int  pitch;
50
    int  lfb;
51
52
 
53
    struct drm_crtc   *crtc;
54
55
 
56
57
 
58
    int       (*init_cursor)(cursor_t*);
59
    cursor_t* (__stdcall *select_cursor)(cursor_t*);
1230 serge 60
    void      (*show_cursor)(int show);
1221 serge 61
    void      (__stdcall *move_cursor)(cursor_t *cursor, int x, int y);
1230 serge 62
    void      (__stdcall *restore_cursor)(int x, int y);
63
64
 
1221 serge 65
66
 
67
 
1230 serge 68
1221 serge 69
 
1230 serge 70
 
71
{
72
    ENTER();
73
    rdisplay->crtc = crtc;
74
    LEAVE();
75
}
76
77
 
1221 serge 78
{
79
    struct radeon_device *rdev;
80
81
 
82
    uint32_t *src;
83
84
 
85
    int       r;
86
87
 
88
89
 
90
                     false,
91
                     RADEON_GEM_DOMAIN_VRAM,
92
                     false, &cursor->robj);
93
94
 
95
        return r;
96
97
 
98
99
 
100
    if (r) {
101
         DRM_ERROR("radeon: failed to map cursor (%d).\n", r);
102
         return r;
103
    };
104
105
 
106
107
 
108
    {
109
        for(j = 0; j < 32; j++)
110
            *bits++ = *src++;
111
        for(j = 32; j < CURSOR_WIDTH; j++)
1230 serge 112
            *bits++ = 0;
1221 serge 113
    }
114
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
115
        *bits++ = 0;
116
117
 
118
119
 
120
};
121
122
 
1230 serge 123
{
1221 serge 124
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
1230 serge 125
    struct radeon_device *rdev = crtc->dev->dev_private;
126
127
 
128
        WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset);
129
        WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN |
130
                 (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT));
131
    } else {
132
        switch (radeon_crtc->crtc_id) {
133
        case 0:
134
            WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL);
135
            break;
136
        case 1:
137
            WREG32(RADEON_MM_INDEX, RADEON_CRTC2_GEN_CNTL);
138
            break;
139
        default:
140
            return;
141
        }
142
143
 
144
                      (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)),
145
             ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK));
146
    }
147
}
148
149
 
150
{
151
    cursor_t  *cursor;
1221 serge 152
153
 
1230 serge 154
1221 serge 155
 
1230 serge 156
157
 
1221 serge 158
159
 
160
    {
161
        init_cursor(cursor);
162
    };
163
1230 serge 164
 
165
166
 
1221 serge 167
};
168
169
 
1230 serge 170
{
171
    cursor_t  *cursor;
172
173
 
174
175
 
176
177
 
178
179
 
180
    rdisplay->select_cursor = select_cursor;
181
    rdisplay->show_cursor   = NULL;
182
    rdisplay->move_cursor   = move_cursor;
183
    rdisplay->restore_cursor = restore_cursor;
184
185
 
186
187
 
188
};
189
190
 
1221 serge 191
{
192
    struct radeon_device *rdev = crtc->dev->dev_private;
193
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
194
    uint32_t cur_lock;
195
196
 
197
        cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset);
198
        if (lock)
199
            cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK;
200
        else
201
            cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK;
202
        WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock);
203
    } else {
204
        cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset);
205
        if (lock)
206
            cur_lock |= RADEON_CUR_LOCK;
207
        else
208
            cur_lock &= ~RADEON_CUR_LOCK;
209
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock);
210
    }
211
}
212
213
 
1230 serge 214
{
1221 serge 215
    struct radeon_device *rdev;
216
    struct radeon_crtc   *radeon_crtc;
217
    cursor_t *old;
218
    uint32_t  gpu_addr;
219
220
 
221
    radeon_crtc = to_radeon_crtc(rdisplay->crtc);
222
223
 
1230 serge 224
1221 serge 225
 
1230 serge 226
    gpu_addr = cursor->robj->gpu_addr;
1221 serge 227
228
 
229
        WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr);
230
    else {
231
        radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr;
232
        /* offset is from DISP(2)_BASE_ADDRESS */
233
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset);
234
    }
235
1230 serge 236
 
1221 serge 237
};
238
239
 
240
 
1230 serge 241
{
1221 serge 242
    struct radeon_device *rdev;
1230 serge 243
    rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
244
    struct drm_crtc *crtc = rdisplay->crtc;
1221 serge 245
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
246
247
 
1230 serge 248
    int hot_y = cursor->hot_y;
249
1221 serge 250
 
251
    if (ASIC_IS_AVIVO(rdev))
252
    {
253
        int w = 32;
254
        int i = 0;
255
        struct drm_crtc *crtc_p;
256
257
 
258
//        x += crtc->x;
1230 serge 259
//        y += crtc->y;
260
1221 serge 261
 
262
#if 0
263
        /* avivo cursor image can't end on 128 pixel boundry or
264
         * go past the end of the frame if both crtcs are enabled
265
         */
266
        list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) {
267
            if (crtc_p->enabled)
268
                i++;
269
        }
270
        if (i > 1) {
271
            int cursor_end, frame_end;
272
273
 
274
            frame_end = crtc->x + crtc->mode.crtc_hdisplay;
275
            if (cursor_end >= frame_end) {
276
                w = w - (cursor_end - frame_end);
277
                if (!(frame_end & 0x7f))
278
                    w--;
279
            } else {
280
                if (!(cursor_end & 0x7f))
281
                    w--;
282
            }
283
            if (w <= 0)
284
                w = 1;
285
        }
286
#endif
287
        WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset,
288
               (x << 16) | y);
289
        WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset,
290
               (hot_x << 16) | hot_y);
1230 serge 291
        WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
1221 serge 292
               ((w - 1) << 16) | 31);
293
    } else {
294
        if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)
295
            y *= 2;
296
297
 
298
               (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16)));
299
        WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset,
300
               (RADEON_CUR_LOCK | (x << 16) | y));
301
302
 
303
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset,
304
         (radeon_crtc->legacy_cursor_offset + (hot_y * 256)));
305
    }
306
    radeon_lock_cursor(crtc, false);
307
}
308
309
 
1230 serge 310
{
311
};
312