Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3248 Serge 1
 
2349 Serge 2
#include 
3248 Serge 3
#include "system.h"
3068 serge 4
2349 Serge 5
 
3068 serge 6
 
2349 Serge 7
8
 
9
#define SRV_GET_CAPS         3
10
11
 
3248 Serge 12
#define SRV_DESTROY_SURFACE     11
3068 serge 13
#define SRV_LOCK_SURFACE    12
3248 Serge 14
#define SRV_UNLOCK_SURFACE      13
3068 serge 15
#define SRV_RESIZE_SURFACE      14
16
#define SRV_BLIT_BITMAP         15
17
#define SRV_BLIT_TEXTURE        16
18
#define SRV_BLIT_VIDEO          17
19
2415 Serge 20
 
3248 Serge 21
 
22
#define __ALIGN_MASK(x,mask)  (((x)+(mask))&~(mask))
2349 Serge 23
#define ALIGN(x,a)            __ALIGN_MASK(x,(typeof(x))(a)-1)
24
25
 
26
 
3068 serge 27
 
2349 Serge 28
static uint32_t blit_caps;
29
static uint32_t screen_width;
3068 serge 30
static uint32_t screen_height;
31
2349 Serge 32
 
33
{
34
  unsigned      handle;
3068 serge 35
  unsigned      io_code;
36
  void          *input;
37
  int           inp_size;
38
  void          *output;
39
  int           out_size;
40
}ioctl_t;
41
42
 
43
 
44
 
45
{
46
    uint32_t  idx;
2349 Serge 47
    union
48
    {
49
        uint32_t opt[2];
50
        struct {
51
            uint32_t max_tex_width;
52
            uint32_t max_tex_height;
53
        }cap1;
54
    };
55
}hwcaps_t;
56
57
 
3068 serge 58
{
59
     uint32_t retval;
60
61
 
62
     "int $0x40"
63
     :"=a"(retval)
64
     :"a"(61), "b"(1));
65
     return retval;
66
}
67
68
 
2349 Serge 69
{
70
  uint32_t retval = 0;
71
  asm volatile ("int $0x40"
72
      :"=a"(retval)
73
      :"a"(68),"b"(16),"c"(name)
74
      :"memory");
75
76
 
77
};
78
79
 
80
{
81
  int retval;
82
83
 
84
      :"=a"(retval)
85
      :"a"(68),"b"(17),"c"(io)
86
      :"memory","cc");
87
88
 
89
};
90
91
 
92
 
3248 Serge 93
{
2349 Serge 94
    uint32_t  api_version;
95
    uint32_t  screensize;
3068 serge 96
    hwcaps_t  hwcaps;
3248 Serge 97
    ioctl_t   io;
98
2349 Serge 99
 
100
101
 
3068 serge 102
    screen_width  = screensize >> 16;
103
    screen_height = screensize & 0xFFFF;
104
105
 
2349 Serge 106
    if(service == 0)
107
        goto fail;
108
109
 
110
    io.io_code  = SRV_GETVERSION;
111
    io.input    = NULL;
112
    io.inp_size = 0;
113
    io.output   = &api_version;
114
    io.out_size = BUFFER_SIZE(1);
115
116
 
117
        goto fail;
118
119
 
120
        (DISPLAY_VERSION < (api_version >> 16)))
121
        goto fail;
122
123
 
124
 * Let's see what this service can do
125
*/
126
    hwcaps.idx  = 0;
127
128
 
129
    io.io_code  = SRV_GET_CAPS;
130
    io.input    = &hwcaps;
131
    io.inp_size = sizeof(hwcaps);
132
    io.output   = NULL;
133
    io.out_size = 0;
134
135
 
136
        goto fail;
137
138
 
139
140
 
141
142
 
143
        printf("service caps %s%s%s\n",
144
               (blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"",
145
               (blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"",
146
               (blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":"");
147
148
 
149
    return blit_caps;
150
151
 
152
    service = 0;
153
    return 0;
154
};
155
156
 
157
 
158
{
159
 //    __asm__ __volatile__("int3");
160
161
 
3248 Serge 162
    {
2349 Serge 163
        struct __attribute__((packed))  /*     SRV_CREATE_SURFACE    */
164
        {
165
            uint32_t  handle;           // ignored
166
            void      *data;            // ignored
167
168
 
169
            uint32_t  height;
170
            uint32_t  pitch;            // ignored
171
172
 
173
            uint32_t  max_height;
174
            uint32_t  format;           // reserved mbz
175
        }io_10;
176
177
 
178
        int     err;
179
180
 
181
//                bitmap->width, bitmap->height);
182
183
 
184
        io_10.height     = bitmap->height;
185
        io_10.max_width  = screen_width;
3068 serge 186
        io_10.max_height = screen_height;
187
        io_10.format     = 0;
2349 Serge 188
189
 
190
        io.io_code  = SRV_CREATE_SURFACE;
191
        io.input    = &io_10;
192
        io.inp_size = BUFFER_SIZE(8);
193
        io.output   = NULL;
194
        io.out_size = 0;
195
196
 
197
        if(err==0)
198
        {
199
            bitmap->handle = io_10.handle;
200
            bitmap->pitch  = io_10.pitch;
201
            bitmap->data   = io_10.data;
202
//            printf("Create hardware surface %x pitch %d, buffer %x\n",
203
//                     bitmap->handle, bitmap->pitch, bitmap->data);
204
            return 0;
205
        };
206
    };
207
208
 
209
    uint32_t   pitch;
210
    uint8_t   *buffer;
211
212
 
213
    size  = pitch * bitmap->height;
214
215
 
216
    if( buffer )
217
    {
218
        bitmap->handle = 0;
219
        bitmap->pitch  = pitch;
220
        bitmap->data   = buffer;
221
        bitmap->flags  = 0;
3248 Serge 222
        return 0;
2349 Serge 223
    };
224
225
 
226
227
 
228
};
229
230
 
2415 Serge 231
{
232
 //    __asm__ __volatile__("int3");
233
    int err = 0;
3068 serge 234
2415 Serge 235
 
3248 Serge 236
    {
2415 Serge 237
        struct __attribute__((packed))  /*     SRV_LOCK_SURFACE    */
3068 serge 238
        {
2415 Serge 239
            uint32_t  handle;
3068 serge 240
            void      *data;
241
            uint32_t  pitch;
242
2415 Serge 243
 
244
245
 
246
247
 
248
        io_12.pitch   = 0;
249
        io_12.data    = 0;
250
251
 
252
        io.io_code  = SRV_LOCK_SURFACE;
253
        io.input    = &io_12;
254
        io.inp_size = BUFFER_SIZE(3);
3068 serge 255
        io.output   = NULL;
2415 Serge 256
        io.out_size = 0;
257
258
 
259
        if(err==0)
260
        {
261
            bitmap->pitch  = io_12.pitch;
262
            bitmap->data   = io_12.data;
263
//            printf("Lock hardware surface %x pitch %d, buffer %x\n",
264
//                     bitmap->handle, bitmap->pitch, bitmap->data);
265
        };
266
    };
267
268
 
3068 serge 269
};
2415 Serge 270
271
 
2349 Serge 272
                int w, int h)
273
{
274
    int err;
3068 serge 275
2349 Serge 276
 
3248 Serge 277
    {
2349 Serge 278
279
 
280
 *   Now you will experience the full power of the dark side...
281
*/
282
283
 
284
        {
285
            uint32_t handle;
286
            int      dst_x;
287
            int      dst_y;
288
            int      src_x;
289
            int      src_y;
290
            uint32_t w;
291
            uint32_t h;
292
        }io_15;
3068 serge 293
2349 Serge 294
 
295
296
 
3068 serge 297
        io_15.dst_x  = dst_x;
298
        io_15.dst_y  = dst_y;
299
        io_15.src_x  = 0;
300
        io_15.src_y  = 0;
301
        io_15.w      = w;
302
        io_15.h      = h;
303
2349 Serge 304
 
305
        io.io_code   = SRV_BLIT_BITMAP;
3068 serge 306
        io.input     = &io_15;
307
        io.inp_size  = BUFFER_SIZE(7);
2349 Serge 308
        io.output    = NULL;
309
        io.out_size  = 0;
310
311
 
312
//                bitmap->pitch);
313
        err = call_service(&io);
314
        return err;
315
    };
316
317
 
3068 serge 318
2349 Serge 319
 
320
    bc.dsty = dst_y;
321
    bc.w    = w;
322
    bc.h    = h;
323
    bc.srcx = 0;
324
    bc.srcy = 0;
325
    bc.srcw = w;
326
    bc.srch = h;
327
    bc.stride = bitmap->pitch;
328
    bc.bitmap = bitmap->data;
329
330
 
331
    "int $0x40"
332
    :"=a"(err)
3068 serge 333
    :"a"(73),"b"(0x00),"c"(&bc)
334
    :"memory");
2693 Serge 335
3248 Serge 336
 
3068 serge 337
};
2349 Serge 338
339
 
340
{
341
 //    __asm__ __volatile__("int3");
342
343
 
3248 Serge 344
    {
2349 Serge 345
        struct __attribute__((packed))
3068 serge 346
        {
347
            uint32_t  handle;
348
            char     *data;
349
            uint32_t  new_w;
350
            uint32_t  new_h;
351
            uint32_t  pitch;
352
        }io_14;
353
354
 
355
        int     err;
356
357
 
358
        io_14.new_w  = bitmap->width;
359
        io_14.new_h  = bitmap->height;
360
361
 
362
        io.io_code   = SRV_RESIZE_SURFACE;
363
        io.input     = &io_14;
364
        io.inp_size  = BUFFER_SIZE(5);
365
        io.output    = NULL;
366
        io.out_size  = 0;
367
368
 
369
        if(err==0)
370
    {
3248 Serge 371
            bitmap->pitch  = io_14.pitch;
3068 serge 372
            bitmap->data   = io_14.data;
373
        };
374
        return err;
375
    };
2349 Serge 376
377
 
378
    uint32_t   pitch;
379
    uint8_t   *buffer;
380
381
 
382
    size  = pitch * bitmap->height;
383
384
 
385
    if( buffer )
386
    {
387
        bitmap->handle = 0;
388
        bitmap->pitch  = pitch;
389
        bitmap->data   = buffer;
390
        return 0;
391
    };
392
393
 
394
395
 
396
};
397