Subversion Repositories Kolibri OS

Rev

Rev 3248 | 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
 
3292 Serge 26
void sna_fini();
27
2349 Serge 28
 
3292 Serge 29
void sna_destroy_bitmap(bitmap_t *bitmap);
30
void sna_lock_bitmap(bitmap_t *bitmap);
31
int  sna_blit_copy(bitmap_t *src_bitmap, int dst_x, int dst_y,
32
                  int w, int h, int src_x, int src_y);
33
int  sna_blit_tex(bitmap_t *src_bitmap, int dst_x, int dst_y,
34
                  int w, int h, int src_x, int src_y);
35
3068 serge 36
 
3292 Serge 37
 
2349 Serge 38
static uint32_t blit_caps;
39
static uint32_t screen_width;
3068 serge 40
static uint32_t screen_height;
41
2349 Serge 42
 
43
{
44
  unsigned      handle;
3068 serge 45
  unsigned      io_code;
46
  void          *input;
47
  int           inp_size;
48
  void          *output;
49
  int           out_size;
50
}ioctl_t;
51
52
 
53
 
54
{
55
    uint32_t  idx;
2349 Serge 56
    union
57
    {
58
        uint32_t opt[2];
59
        struct {
60
            uint32_t max_tex_width;
61
            uint32_t max_tex_height;
62
        }cap1;
63
    };
64
}hwcaps_t;
65
66
 
3068 serge 67
{
68
     uint32_t retval;
69
70
 
71
     "int $0x40"
72
     :"=a"(retval)
73
     :"a"(61), "b"(1));
74
     return retval;
75
}
76
77
 
2349 Serge 78
{
79
  uint32_t retval = 0;
80
  asm volatile ("int $0x40"
81
      :"=a"(retval)
82
      :"a"(68),"b"(16),"c"(name)
83
      :"memory");
84
85
 
86
};
87
88
 
89
{
90
  int retval;
91
92
 
93
      :"=a"(retval)
94
      :"a"(68),"b"(17),"c"(io)
95
      :"memory","cc");
96
97
 
98
};
99
100
 
101
 
3248 Serge 102
{
2349 Serge 103
    uint32_t  api_version;
104
    uint32_t  screensize;
3068 serge 105
    hwcaps_t  hwcaps;
3248 Serge 106
    ioctl_t   io;
107
2349 Serge 108
 
109
110
 
3068 serge 111
    screen_width  = screensize >> 16;
112
    screen_height = screensize & 0xFFFF;
113
114
 
2349 Serge 115
    if(service == 0)
116
        goto fail;
117
118
 
119
    io.io_code  = SRV_GETVERSION;
120
    io.input    = NULL;
121
    io.inp_size = 0;
122
    io.output   = &api_version;
123
    io.out_size = BUFFER_SIZE(1);
124
125
 
126
        goto fail;
127
128
 
129
        (DISPLAY_VERSION < (api_version >> 16)))
130
        goto fail;
131
132
 
3292 Serge 133
/*
2349 Serge 134
 * Let's see what this service can do
135
*/
136
    hwcaps.idx  = 0;
137
138
 
139
    io.io_code  = SRV_GET_CAPS;
140
    io.input    = &hwcaps;
141
    io.inp_size = sizeof(hwcaps);
142
    io.output   = NULL;
143
    io.out_size = 0;
144
145
 
146
        goto fail;
147
148
 
149
150
 
151
152
 
153
        printf("service caps %s%s%s\n",
154
               (blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"",
155
               (blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"",
156
               (blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":"");
157
#endif
3292 Serge 158
2349 Serge 159
 
3292 Serge 160
161
 
162
        printf("service caps %s%s%s\n",
163
               (blit_caps & HW_BIT_BLIT) != 0 ?"HW_BIT_BLIT ":"",
164
               (blit_caps & HW_TEX_BLIT) != 0 ?"HW_TEX_BLIT ":"",
165
               (blit_caps & HW_VID_BLIT) != 0 ?"HW_VID_BLIT ":"");
166
167
 
2349 Serge 168
169
 
170
    service = 0;
171
    return 0;
172
};
173
174
 
3292 Serge 175
{
176
177
 
178
179
 
180
2349 Serge 181
 
3292 Serge 182
 
2349 Serge 183
{
184
 //    __asm__ __volatile__("int3");
185
186
 
187
    uint32_t   pitch;
188
    uint8_t   *buffer;
189
190
 
3292 Serge 191
        return sna_create_bitmap(bitmap);
192
193
 
194
//        return sna_create_bitmap(bitmap);
195
196
 
2349 Serge 197
    size  = pitch * bitmap->height;
198
199
 
200
    if( buffer )
201
    {
202
        bitmap->handle = 0;
203
        bitmap->pitch  = pitch;
204
        bitmap->data   = buffer;
205
        bitmap->flags  = 0;
3248 Serge 206
        return 0;
2349 Serge 207
    };
208
209
 
210
211
 
212
3292 Serge 213
 
2349 Serge 214
215
 
3292 Serge 216
{
217
    if( bitmap->flags & (HW_BIT_BLIT | HW_TEX_BLIT ))
218
        sna_destroy_bitmap(bitmap);
219
    return 0;
220
};
221
222
 
2415 Serge 223
{
224
 //    __asm__ __volatile__("int3");
225
226
 
3292 Serge 227
        sna_lock_bitmap(bitmap);
228
2415 Serge 229
 
3292 Serge 230
};
2415 Serge 231
232
 
2349 Serge 233
                int w, int h)
234
{
235
    int err;
3068 serge 236
2349 Serge 237
 
3292 Serge 238
        return sna_blit_tex(bitmap, dst_x, dst_y, w, h, 0, 0);
239
2349 Serge 240
 
241
 
3068 serge 242
2349 Serge 243
 
244
    bc.dsty = dst_y;
245
    bc.w    = w;
246
    bc.h    = h;
247
    bc.srcx = 0;
248
    bc.srcy = 0;
249
    bc.srcw = w;
250
    bc.srch = h;
251
    bc.stride = bitmap->pitch;
252
    bc.bitmap = bitmap->data;
253
254
 
255
    "int $0x40"
256
    :"=a"(err)
3068 serge 257
    :"a"(73),"b"(0x00),"c"(&bc)
258
    :"memory");
2693 Serge 259
3248 Serge 260
 
3068 serge 261
};
2349 Serge 262
263
 
264
{
265
 //    __asm__ __volatile__("int3");
266
267
 
3248 Serge 268
    {
2349 Serge 269
        struct __attribute__((packed))
3068 serge 270
        {
271
            uint32_t  handle;
272
            char     *data;
273
            uint32_t  new_w;
274
            uint32_t  new_h;
275
            uint32_t  pitch;
276
        }io_14;
277
278
 
279
        int     err;
280
281
 
282
        io_14.new_w  = bitmap->width;
283
        io_14.new_h  = bitmap->height;
284
285
 
286
        io.io_code   = SRV_RESIZE_SURFACE;
287
        io.input     = &io_14;
288
        io.inp_size  = BUFFER_SIZE(5);
289
        io.output    = NULL;
290
        io.out_size  = 0;
291
292
 
293
        if(err==0)
294
    {
3248 Serge 295
            bitmap->pitch  = io_14.pitch;
3068 serge 296
            bitmap->data   = io_14.data;
297
        };
298
        return err;
299
    };
2349 Serge 300
301
 
302
    uint32_t   pitch;
303
    uint8_t   *buffer;
304
305
 
306
    size  = pitch * bitmap->height;
307
308
 
309
    if( buffer )
310
    {
311
        bitmap->handle = 0;
312
        bitmap->pitch  = pitch;
313
        bitmap->data   = buffer;
314
        return 0;
315
    };
316
317
 
318
319
 
320
};
321