Subversion Repositories Kolibri OS

Rev

Rev 1230 | Go to most recent revision | Details | 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
 
37
{
38
    int  x;
39
    int  y;
40
    int  width;
41
    int  height;
42
    int  bpp;
43
    int  vrefresh;
44
    int  pitch;
45
    int  lfb;
46
47
 
48
    struct drm_crtc   *crtc;
49
50
 
51
52
 
53
    int       (*init_cursor)(cursor_t*);
54
    cursor_t* (*select_cursor)(display_t*, cursor_t*);
55
    void      (*show_cursor)(int show);
56
    void      (*move_cursor)(int x, int y);
57
};
58
59
 
60
 
61
62
 
63
{
64
    struct radeon_device *rdev;
65
66
 
67
    uint32_t *src;
68
69
 
70
    int       r;
71
72
 
73
74
 
75
                     false,
76
                     RADEON_GEM_DOMAIN_VRAM,
77
                     false, &cursor->robj);
78
79
 
80
        return r;
81
82
 
83
84
 
85
    if (r) {
86
         DRM_ERROR("radeon: failed to map cursor (%d).\n", r);
87
         return r;
88
    };
89
90
 
91
92
 
93
    {
94
        for(j = 0; j < 32; j++)
95
            *bits++ = *src++;
96
        for(j = 0; j < CURSOR_WIDTH-32; j++)
97
            *bits++ = 0;
98
    }
99
    for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
100
        *bits++ = 0;
101
102
 
103
104
 
105
};
106
107
 
108
{
109
    cursor_t  *cursor;
110
111
 
112
113
 
114
115
 
116
    {
117
        init_cursor(cursor);
118
    };
119
    return 1;
120
};
121
122
 
123
{
124
    struct radeon_device *rdev = crtc->dev->dev_private;
125
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
126
    uint32_t cur_lock;
127
128
 
129
        cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset);
130
        if (lock)
131
            cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK;
132
        else
133
            cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK;
134
        WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock);
135
    } else {
136
        cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset);
137
        if (lock)
138
            cur_lock |= RADEON_CUR_LOCK;
139
        else
140
            cur_lock &= ~RADEON_CUR_LOCK;
141
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock);
142
    }
143
}
144
145
 
146
{
147
    struct radeon_device *rdev;
148
    struct radeon_crtc   *radeon_crtc;
149
    cursor_t *old;
150
    uint32_t  gpu_addr;
151
152
 
153
    radeon_crtc = to_radeon_crtc(rdisplay->crtc);
154
155
 
156
157
 
158
    gpu_addr = cursor->robj->gpu_addr;
159
160
 
161
        WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr);
162
    else {
163
        radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr;
164
        /* offset is from DISP(2)_BASE_ADDRESS */
165
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset);
166
    }
167
    return old;
168
};
169
170
 
171
 
172
{
173
    struct drm_crtc *crtc = rdisplay->crtc;
174
    struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
175
    struct radeon_device *rdev = crtc->dev->dev_private;
176
177
 
178
    int hot_y = rdisplay->cursor->hot_y - 1;
179
180
 
181
    if (ASIC_IS_AVIVO(rdev))
182
    {
183
        int w = 32;
184
        int i = 0;
185
        struct drm_crtc *crtc_p;
186
187
 
188
        x += crtc->x;
189
        y += crtc->y;
190
191
 
192
#if 0
193
        /* avivo cursor image can't end on 128 pixel boundry or
194
         * go past the end of the frame if both crtcs are enabled
195
         */
196
        list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) {
197
            if (crtc_p->enabled)
198
                i++;
199
        }
200
        if (i > 1) {
201
            int cursor_end, frame_end;
202
203
 
204
            frame_end = crtc->x + crtc->mode.crtc_hdisplay;
205
            if (cursor_end >= frame_end) {
206
                w = w - (cursor_end - frame_end);
207
                if (!(frame_end & 0x7f))
208
                    w--;
209
            } else {
210
                if (!(cursor_end & 0x7f))
211
                    w--;
212
            }
213
            if (w <= 0)
214
                w = 1;
215
        }
216
#endif
217
218
 
219
               (x << 16) | y);
220
        WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset,
221
               (hot_x << 16) | hot_y-1);
222
        WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
223
               ((w - 1) << 16) | 31);
224
    } else {
225
        if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN)
226
            y *= 2;
227
228
 
229
               (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16)));
230
        WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset,
231
               (RADEON_CUR_LOCK | (x << 16) | y));
232
233
 
234
        WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset,
235
         (radeon_crtc->legacy_cursor_offset + (hot_y * 256)));
236
    }
237
    radeon_lock_cursor(crtc, false);
238
239
 
240
}
241