Subversion Repositories Kolibri OS

Rev

Details | 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);