Subversion Repositories Kolibri OS

Rev

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

Rev 6283 Rev 6296
Line 69... Line 69...
69
};
69
};
Line 70... Line 70...
70
 
70
 
71
static int init_cursor(cursor_t *cursor)
71
static int init_cursor(cursor_t *cursor)
72
{
72
{
-
 
73
    display_t *display = GetDisplay();
73
    display_t *display = GetDisplay();
74
    struct drm_device *dev = display->ddev;
74
    struct drm_i915_private *dev_priv = display->ddev->dev_private;
75
    struct drm_i915_private *dev_priv = dev->dev_private;
75
    struct drm_i915_gem_object *obj;
76
    struct drm_i915_gem_object *obj;
76
    uint32_t *bits;
77
    uint32_t *bits;
77
    uint32_t *src;
78
    uint32_t *src;
Line 78... Line 79...
78
    void     *mapped;
79
    void     *mapped;
79
 
80
 
Line -... Line 81...
-
 
81
    int       i,j;
-
 
82
    int       ret;
80
    int       i,j;
83
 
81
    int       ret;
84
    mutex_lock(&dev->struct_mutex);
82
 
85
 
83
    if (dev_priv->info.cursor_needs_physical)
86
    if (dev_priv->info.cursor_needs_physical)
-
 
87
    {
84
    {
88
        bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8);
-
 
89
        if (unlikely(bits == NULL))
-
 
90
        {
85
        bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8);
91
            ret = -ENOMEM;
86
        if (unlikely(bits == NULL))
92
            goto unlock;
87
            return ENOMEM;
93
        };
88
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
94
        cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits);
89
    }
95
    }
90
    else
96
    else
-
 
97
    {
91
    {
98
        obj = i915_gem_alloc_object(display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4);
-
 
99
        if (unlikely(obj == NULL))
-
 
100
        {
Line 92... Line 101...
92
        obj = i915_gem_alloc_object(display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4);
101
            ret = -ENOMEM;
93
        if (unlikely(obj == NULL))
102
            goto unlock;
94
            return -ENOMEM;
-
 
95
 
103
        };
96
        ret = i915_gem_object_ggtt_pin(obj, &i915_ggtt_view_normal, 128*1024, PIN_GLOBAL);
-
 
Line 97... Line 104...
97
        if (ret) {
104
 
98
            drm_gem_object_unreference(&obj->base);
105
        ret = i915_gem_object_ggtt_pin(obj, &i915_ggtt_view_normal, 128*1024, PIN_GLOBAL);
99
            return ret;
-
 
100
        }
-
 
101
 
-
 
102
        ret = i915_gem_object_set_to_gtt_domain(obj, true);
106
        if (ret)
103
        if (ret)
107
            goto unref;
104
        {
108
 
105
            i915_gem_object_ggtt_unpin(obj);
109
        ret = i915_gem_object_set_to_gtt_domain(obj, true);
Line 106... Line 110...
106
            drm_gem_object_unreference(&obj->base);
110
        if (ret)
107
            return ret;
111
            goto unpin;
Line 108... Line 112...
108
        }
112
 
109
/* You don't need to worry about fragmentation issues.
113
/* You don't need to worry about fragmentation issues.
110
 * GTT space is continuous. I guarantee it.                           */
114
 * GTT space is continuous. I guarantee it.                           */
111
 
-
 
112
        mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
115
 
113
                    KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW);
116
        mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
114
 
117
                    KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW);
115
        if (unlikely(bits == NULL))
118
 
Line -... Line 119...
-
 
119
        if (unlikely(bits == NULL))
-
 
120
        {
116
        {
121
            ret = -ENOMEM;
Line 117... Line 122...
117
            i915_gem_object_ggtt_unpin(obj);
122
            goto unpin;
118
            drm_gem_object_unreference(&obj->base);
123
        };
119
            return -ENOMEM;
124
        cursor->cobj = obj;
Line 137... Line 142...
137
    KernelFree(cursor->data);
142
    KernelFree(cursor->data);
138
    cursor->data = bits;
143
    cursor->data = bits;
139
    cursor->header.destroy = destroy_cursor;
144
    cursor->header.destroy = destroy_cursor;
Line 140... Line 145...
140
 
145
 
-
 
146
    return 0;
-
 
147
 
-
 
148
unpin:
-
 
149
    i915_gem_object_ggtt_unpin(obj);
-
 
150
unref:
-
 
151
    drm_gem_object_unreference(&obj->base);
-
 
152
unlock:
-
 
153
    mutex_unlock(&dev->struct_mutex);
141
    return 0;
154
    return ret;
Line 142... Line 155...
142
}
155
}
143
 
156
 
144
void init_system_cursors(struct drm_device *dev)
157
void init_system_cursors(struct drm_device *dev)
Line 148... Line 161...
148
    u32      ifl;
161
    u32      ifl;
Line 149... Line 162...
149
 
162
 
Line 150... Line 163...
150
    display = GetDisplay();
163
    display = GetDisplay();
151
 
-
 
Line 152... Line 164...
152
    mutex_init(&cursor_lock);
164
 
153
    mutex_lock(&dev->struct_mutex);
165
    mutex_init(&cursor_lock);
154
 
166
 
155
    ifl = safe_cli();
167
    ifl = safe_cli();
Line 170... Line 182...
170
        display->crtc->cursor_y = display->height/2;
182
        display->crtc->cursor_y = display->height/2;
Line 171... Line 183...
171
 
183
 
172
        select_cursor_kms(display->cursor);
184
        select_cursor_kms(display->cursor);
173
    };
185
    };
174
    safe_sti(ifl);
-
 
175
 
-
 
176
    mutex_unlock(&dev->struct_mutex);
186
    safe_sti(ifl);