1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*
** Lua eXtended ioctl library
*/
#define lxioctllib_c
#define LUA_LIB
#include <lua/lprefix.h>
#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <lua/lua.h>
#include <lua/lauxlib.h>
#include <lua/lualib.h>
#include <kogata/syscall.h>
#include <kogata/gip.h>
#include "lxlib.h"
static int ioctl_fb_get_info(lua_State *L) {
int fd = luaL_checkinteger(L, 1);
fb_info_t mode;
int r = sc_ioctl(fd, IOCTL_FB_GET_INFO, &mode);
if (r == 1) {
lua_createtable(L, 0, 5);
setintfield(L, "width", mode.width);
setintfield(L, "height", mode.height);
setintfield(L, "pitch", mode.pitch);
setintfield(L, "bpp", mode.bpp);
setintfield(L, "memory_model", mode.memory_model);
} else {
lua_pushnil(L);
}
return 1;
}
/* }====================================================== */
static const luaL_Reg ioctllib[] = {
{"fb_get_info", ioctl_fb_get_info},
{NULL, NULL}
};
LUAMOD_API int lx_open_ioctl (lua_State *L) {
luaL_newlib(L, ioctllib);
return 1;
}
/* vim: set sts=2 ts=2 sw=2 tw=0 et :*/
|