Subversion Repositories Kolibri OS

Rev

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

Rev 6131 Rev 6283
Line 9... Line 9...
9
#include 
9
#include 
10
 
10
 
Line 11... Line 11...
11
#include 
11
#include 
Line 12... Line 12...
12
 
12
 
13
#include "bitmap.h"
13
//#include "bitmap.h"
Line -... Line 14...
-
 
14
#include 
-
 
15
 
-
 
16
void  FASTCALL sysSetFramebuffer(void *fb)__asm__("SetFramebuffer");
-
 
17
void kolibri_framebuffer_update(struct drm_i915_private *dev_priv, struct kos_framebuffer *kfb);
-
 
18
void init_system_cursors(struct drm_device *dev);
Line 14... Line 19...
14
#include 
19
 
15
 
-
 
16
 
-
 
Line 17... Line 20...
17
display_t *os_display;
20
addr_t dummy_fb_page;
18
struct drm_i915_gem_object *main_fb_obj;
21
 
Line 19... Line 22...
19
struct drm_framebuffer     *main_framebuffer;
22
display_t *os_display;
20
 
23
 
Line 21... Line -...
21
u32 cmd_buffer;
-
 
22
u32 cmd_offset;
-
 
23
 
-
 
24
void init_render();
-
 
25
int  sna_init();
-
 
26
 
-
 
27
static cursor_t*  __stdcall select_cursor_kms(cursor_t *cursor);
-
 
28
static void       __stdcall move_cursor_kms(cursor_t *cursor, int x, int y);
-
 
29
 
-
 
30
void __stdcall restore_cursor(int x, int y)
-
 
31
{};
-
 
32
 
24
u32 cmd_buffer;
33
void disable_mouse(void)
25
u32 cmd_offset;
34
{};
26
 
Line 35... Line 27...
35
 
27
void init_render();
Line 57... Line 49...
57
 
49
 
Line 58... Line 50...
58
    return count;
50
    return count;
59
};
51
};
Line -... Line 52...
-
 
52
 
-
 
53
struct drm_framebuffer *get_framebuffer(struct drm_device *dev, struct drm_display_mode *mode, int tiling)
-
 
54
{
-
 
55
    struct drm_i915_private *dev_priv = dev->dev_private;
-
 
56
    struct intel_fbdev     *ifbdev = dev_priv->fbdev;
-
 
57
    struct intel_framebuffer *intel_fb = ifbdev->fb;
-
 
58
    struct drm_framebuffer *fb = &intel_fb->base;
-
 
59
    struct drm_i915_gem_object *obj = NULL;
-
 
60
    int stride, size;
-
 
61
 
-
 
62
ENTER();
-
 
63
 
-
 
64
    stride = mode->hdisplay *4;
-
 
65
 
-
 
66
    if(tiling)
-
 
67
    {
-
 
68
        int gen3size;
-
 
69
 
-
 
70
        if(IS_GEN3(dev))
-
 
71
            for (stride = 512; stride < mode->hdisplay * 4; stride <<= 1);
-
 
72
        else
-
 
73
            stride = ALIGN(stride, 512);
-
 
74
        size = stride * ALIGN(mode->vdisplay, 8);
-
 
75
 
-
 
76
        if(IS_GEN3(dev))
-
 
77
        {
-
 
78
            for (gen3size = 1024*1024; gen3size < size; gen3size <<= 1);
-
 
79
            size = gen3size;
-
 
80
        }
-
 
81
        else
-
 
82
            size = ALIGN(size, 4096);
-
 
83
    }
-
 
84
    else
-
 
85
    {
-
 
86
        stride = ALIGN(stride, 64);
-
 
87
        size = stride * ALIGN(mode->vdisplay, 2);
-
 
88
    }
-
 
89
 
-
 
90
    dbgprintf("size %x stride %x\n", size, stride);
-
 
91
 
-
 
92
    if(intel_fb == NULL || size > intel_fb->obj->base.size)
-
 
93
    {
-
 
94
        struct drm_mode_fb_cmd2 mode_cmd = {};
-
 
95
        int ret;
-
 
96
 
-
 
97
        DRM_DEBUG_KMS("remove old framebuffer\n");
-
 
98
        drm_framebuffer_remove(fb);
-
 
99
        ifbdev->fb = NULL;
-
 
100
        fb = NULL;
-
 
101
        DRM_DEBUG_KMS("create new framebuffer\n");
-
 
102
 
-
 
103
        mode_cmd.width  = mode->hdisplay;
-
 
104
        mode_cmd.height = mode->vdisplay;
-
 
105
 
-
 
106
        mode_cmd.pitches[0] = stride;
-
 
107
        mode_cmd.pixel_format = DRM_FORMAT_XRGB8888;
-
 
108
 
-
 
109
        mutex_lock(&dev->struct_mutex);
-
 
110
 
-
 
111
        /* If the FB is too big, just don't use it since fbdev is not very
-
 
112
        * important and we should probably use that space with FBC or other
-
 
113
        * features. */
-
 
114
        if (size * 2 < dev_priv->gtt.stolen_usable_size)
-
 
115
            obj = i915_gem_object_create_stolen(dev, size);
-
 
116
        if (obj == NULL)
-
 
117
            obj = i915_gem_alloc_object(dev, size);
-
 
118
        if (!obj) {
-
 
119
            DRM_ERROR("failed to allocate framebuffer\n");
-
 
120
            ret = -ENOMEM;
-
 
121
            goto out;
-
 
122
        }
-
 
123
 
-
 
124
        fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
-
 
125
        if (IS_ERR(fb)) {
-
 
126
            ret = PTR_ERR(fb);
-
 
127
            goto out_unref;
-
 
128
        }
-
 
129
 
-
 
130
        /* Flush everything out, we'll be doing GTT only from now on */
-
 
131
        ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL, NULL, NULL);
-
 
132
        if (ret) {
-
 
133
            DRM_ERROR("failed to pin obj: %d\n", ret);
-
 
134
            goto out_fb;
-
 
135
        }
-
 
136
        mutex_unlock(&dev->struct_mutex);
-
 
137
        ifbdev->fb = to_intel_framebuffer(fb);
-
 
138
    }
-
 
139
 
-
 
140
    obj = ifbdev->fb->obj;
-
 
141
 
-
 
142
    if(tiling)
-
 
143
    {
-
 
144
        obj->tiling_mode = I915_TILING_X;
-
 
145
        fb->modifier[0]  = I915_FORMAT_MOD_X_TILED;
-
 
146
        obj->fence_dirty = true;
-
 
147
        obj->stride      = stride;
-
 
148
    };
-
 
149
 
-
 
150
    fb->width  = mode->hdisplay;
-
 
151
    fb->height = mode->vdisplay;
-
 
152
 
-
 
153
    fb->pitches[0]  =
-
 
154
    fb->pitches[1]  =
-
 
155
    fb->pitches[2]  =
-
 
156
    fb->pitches[3]  = stride;
-
 
157
 
-
 
158
    fb->bits_per_pixel = 32;
-
 
159
    fb->depth = 24;
-
 
160
LEAVE();
-
 
161
    return fb;
-
 
162
 
-
 
163
out_fb:
-
 
164
    drm_framebuffer_remove(fb);
-
 
165
out_unref:
-
 
166
    drm_gem_object_unreference(&obj->base);
-
 
167
out:
-
 
168
    mutex_unlock(&dev->struct_mutex);
-
 
169
    return NULL;
-
 
170
}
60
 
171
 
61
static int set_mode(struct drm_device *dev, struct drm_connector *connector,
172
static int set_mode(struct drm_device *dev, struct drm_connector *connector,
62
                    struct drm_crtc *crtc, videomode_t *reqmode, bool strict)
173
                    struct drm_crtc *crtc, videomode_t *reqmode, bool strict)
63
{
174
{
64
    struct drm_i915_private *dev_priv   = dev->dev_private;
-
 
65
 
175
    struct drm_i915_private *dev_priv   = dev->dev_private;
66
    struct drm_mode_config  *config     = &dev->mode_config;
176
    struct drm_mode_config  *config     = &dev->mode_config;
67
    struct drm_display_mode *mode       = NULL, *tmpmode;
177
    struct drm_display_mode *mode       = NULL, *tmpmode;
68
    struct drm_connector    *tmpc;
178
    struct drm_connector    *tmpc;
69
    struct drm_framebuffer  *fb         = NULL;
179
    struct drm_framebuffer  *fb         = NULL;
70
    struct drm_mode_set     set;
180
    struct drm_mode_set     set;
71
    const char *con_name;
-
 
72
    unsigned hdisplay, vdisplay;
-
 
73
    int stride;
181
    char  con_edid[128];
Line 74... Line 182...
74
    int ret;
182
    int ret;
Line 75... Line 183...
75
 
183
 
Line 106... Line 214...
106
            }
214
            }
107
        };
215
        };
108
    };
216
    };
109
 
217
 
Line -... Line 218...
-
 
218
out:
-
 
219
    drm_modeset_unlock_all(dev);
110
    DRM_ERROR("%s failed\n", __FUNCTION__);
220
    DRM_ERROR("%s failed\n", __FUNCTION__);
111
 
-
 
112
    return -1;
221
    return -1;
Line 113... Line 222...
113
 
222
 
Line -... Line 223...
-
 
223
do_set:
Line -... Line 224...
-
 
224
 
-
 
225
    drm_modeset_unlock_all(dev);
-
 
226
 
-
 
227
    fb = get_framebuffer(dev, mode, 1);
-
 
228
    if(fb == NULL)
-
 
229
    {
114
do_set:
230
        DRM_ERROR("%s failed\n", __FUNCTION__);
Line 115... Line 231...
115
 
231
        return -1;
Line 116... Line 232...
116
 
232
    };
-
 
233
    drm_framebuffer_reference(fb);
-
 
234
 
117
    con_name = connector->name;
235
    drm_modeset_lock_all(dev);
-
 
236
 
-
 
237
    memcpy(con_edid, connector->edid_blob_ptr->data, 128);
118
 
238
 
119
    char  con_edid[128];
239
    DRM_DEBUG_KMS("set mode %dx%d: crtc %d connector %s\n"
120
 
240
                  "monitor: %s model %x serial number %u\n",
121
    memcpy(con_edid, connector->edid_blob_ptr->data, 128);
241
                mode->hdisplay, mode->vdisplay,
Line 122... Line -...
122
    DRM_DEBUG_KMS("Manufacturer: %s Model %x Serial Number %u\n",
-
 
123
            manufacturer_name(con_edid + 0x08),
-
 
124
            (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)),
-
 
125
            (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8)
-
 
126
            + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24)));
242
                crtc->base.id, connector->name,
Line 127... Line -...
127
 
-
 
128
    DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s\n",
-
 
129
              reqmode->width, reqmode->height, crtc->base.id,
-