summaryrefslogtreecommitdiffstats
path: root/klaptopdaemon/smapidev.h
blob: 22deedbe1ed0e646573788d78c6e3ae96f20d10c (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273

/*********************************************************************
 *                
 * Filename:      smapidev.h
 * Description:   Header for the SMAPI device driver access library
 * Author:        Bill Mair, Thomas Hood
 * Created:       13 July 1999
 *
 * Please report bugs to the author ASAP.
 * 
 *     Copyright (c) 1999 Bill Mair, All rights reserved
 *     
 *     This program is free software; you can redistribute it and/or 
 *     modify it under the terms of the GNU General Public License as 
 *     published by the Free Software Foundation; either version 2 of 
 *     the License, or (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *     GNU General Public License for more details.
 * 
 *     To receive a copy of the GNU General Public License, please write
 *     to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *     Boston, MA 02110-1301 USA
 *     
 ********************************************************************/

#ifndef __SMAPIDEV_H__
#define __SMAPIDEV_H__

/****** defines ******/

/*** smapidev function error codes ***/
/*
 * These codes must not fall in the range 0x0-0xFF which is
 * reserved for SMAPI BIOS error codes
 */
#define ERR_SMAPIDEV_MIN                          ((int)0x1000)
#define ERR_SMAPIDEV_PARM_INVALID                 ((int)0x1050)
#define ERR_SMAPIDEV_STRUCTURE_SIZE_INVALID       ((int)0x1051)
#define ERR_SMAPIDEV_SMAPI_RESULT_NOT_UNDERSTOOD  ((int)0x1090)
#define ERR_SMAPIDEV_MAX                          ((int)0x10FF)

/****** typedefs ******/

/*** enum ***/

typedef enum _smapidev_stateplace {
	SMAPIDEV_STATEPLACE_CURR=0,
	SMAPIDEV_STATEPLACE_CMOS,
	SMAPIDEV_STATEPLACE_CMOS_AND_CURR
} smapidev_stateplace_t;

typedef enum _smapidev_ablestate {
	SMAPIDEV_ABLESTATE_DISABLED=0,
	SMAPIDEV_ABLESTATE_ENABLED,
	SMAPIDEV_ABLESTATE_AUTO
} smapidev_ablestate_t;

typedef enum _smapidev_displaycaptv {
	SMAPIDEV_DISPLAYCAPTV_NONE=0,
	SMAPIDEV_DISPLAYCAPTV_NONSIMULTANEOUS,
	SMAPIDEV_DISPLAYCAPTV_OTHER
} smapidev_displaycaptv_t;

/*
 * The following are the display modes that can be enabled or disabled
 */
typedef enum _smapidev_dispmode {
	SMAPIDEV_DISPMODE_INTERNAL=0,
	SMAPIDEV_DISPMODE_CRT,
	SMAPIDEV_DISPMODE_TV,
	SMAPIDEV_DISPMODE_CRT_DETECTION_IGNORE,
	SMAPIDEV_DISPMODE_DUAL,
	SMAPIDEV_DISPMODE_SELECT_TV
} smapidev_dispmode_t;

typedef enum _smapidev_fnkeymode {
	SMAPIDEV_FNKEY_NORMAL=0,
	SMAPIDEV_FNKEY_STICKY,
	SMAPIDEV_FNKEY_LOCKED
} smapidev_fnkeymode_t;

typedef enum _smapidev_ternality {
	SMAPIDEV_TERNALITY_IN=0,
	SMAPIDEV_TERNALITY_EX
} smapidev_ternality_t;

typedef enum _smapidev_powersrc {
	SMAPIDEV_POWERSRC_AC=0,
	SMAPIDEV_POWERSRC_BATTERY
} smapidev_powersrc_t;

typedef enum _smapidev_powermode {
	SMAPIDEV_POWERMODE_HIGH=0,
	SMAPIDEV_POWERMODE_AUTO,
	SMAPIDEV_POWERMODE_MANUAL,
	SMAPIDEV_POWERMODE_UNRECOGNIZED
} smapidev_powermode_t;


/*** struct ***/

typedef struct _smapidev_info
{
	char	szVersion[LEN_VERSION_MAX+1];
} smapidev_info_t;

typedef struct _smapidev_biosinfo
{
	size_t	sizeStruct;
	word	wSysId;
	word	wCountryCode;
	word	wSysBiosRevMajor;
	word	wSysBiosRevMinor;
	word	wSysMgmtBiosRevMajor;
	word	wSysMgmtBiosRevMinor;
	word	wSmapiBiosIfaceRevMajor;
	word	wSmapiBiosIfaceRevMinor;
	word	wVideoBiosRevMajor;
	word	wVideoBiosRevMinor;
} smapidev_biosinfo_t;

typedef struct _smapidev_cpuinfo
{
	size_t	sizeStruct;
	word	wManufacturer;
	word	wType;
	word	wStepping;
	word	wClock;
	word	wInternalClock;
} smapidev_cpuinfo_t;

typedef struct _smapidev_displayinfo
{
	size_t	sizeStruct;
	byte	bPanelType;
	byte	bPanelDim;
	byte	bCrtType;
	byte	bCrtFeatures;
} smapidev_displayinfo_t;

typedef struct _smapidev_dockinginfo
{
	size_t	sizeStruct;
	word	wID;
	flag_t	fDocked;
	flag_t	fKeyUnlocked;
	flag_t	fBusConnected;
} smapidev_dockinginfo_t;

typedef struct _smapidev_ultrabayinfo
{
	size_t	sizeStruct;
	byte	bType;  
	byte	bID;
} smapidev_ultrabayinfo_t;

typedef struct _smapidev_slaveinfo
{
	size_t	sizeStruct;
	flag_t	fAscii;
	char	szID[3];
	word	wIDMajor;
	word	wIDMinor;
} smapidev_slaveinfo_t;

typedef struct _smapidev_sensorinfo
{
	size_t	sizeStruct;
	flag_t	fLidClosed;
	flag_t	fKeyboardOpen;
	flag_t	fACAdapterAttached;
} smapidev_sensorinfo_t;

typedef struct _smapidev_screenrefreshinfo
{
	size_t	sizeStruct;
	flag_t	f43i;
	flag_t	f48i;
	flag_t	f56;
	flag_t	f60;
	flag_t	f70;
	flag_t	f72;
	flag_t	f75;
	flag_t	f85;
} smapidev_screenrefreshinfo_t;

typedef struct _smapidev_displaycap {
	size_t	sizeStruct;
	flag_t  fSupported;
	smapidev_displaycaptv_t tv;
} smapidev_displaycap_t;


/****** function declarations ******/

bcd8_t bcd8_of_byte( byte bThe );
byte byte_of_bcd8( bcd8_t bcd8The );
int ioctl_smapi( int intFiledesc, smapi_ioparm_t *pioparmThe );

/*** Get/Set####Info ***/

int smapidev_GetInfo( smapidev_info_t *pinfoThe );
int smapidev_GetBiosInfo(
	int intFiledesc,
	smapidev_biosinfo_t *pbiosinfoThe
);
int smapidev_GetCpuInfo(
	int intFiledesc,
	smapidev_cpuinfo_t *pcpuinfoThe
);
int smapidev_GetDisplayInfo(
	int intFiledesc,
	smapidev_displayinfo_t *pdisplayinfoThe
);
int smapidev_GetDockingInfo(
	int intFiledesc,
	smapidev_dockinginfo_t *pdockinginfoThe
);
int smapidev_GetUltrabayInfo(
	int intFiledesc,
	smapidev_ultrabayinfo_t *pultrabayinfoThe
);
int smapidev_GetSlaveControllerInfo(
	int intFiledesc,
	smapidev_slaveinfo_t *pslaveinfoThe
);
int smapidev_GetSensorInfo(
	int intFiledesc,
	smapidev_sensorinfo_t *psensorinfoThe
);
int smapidev_GetScreenRefreshInfo(
	int intFiledesc,
	word wMode,
	smapidev_screenrefreshinfo_t *pscreenrefreshinfoThe
);

/*** Get/Set####State ***/

int smapidev_GetDisplayCapability(
	int intFiledesc,
	smapidev_stateplace_t stateplace,
	smapidev_displaycap_t *pdisplaycap
);
int smapidev_GetDisplayState(
	int intFiledesc,
	smapidev_stateplace_t stateplace,
	smapidev_dispmode_t dispmode,
	smapidev_ablestate_t *pablestate
);
int smapidev_SetDisplayState(
	int intFiledesc,
	smapidev_stateplace_t stateplace,
	smapidev_dispmode_t dispmode,
	smapidev_ablestate_t ablestate
);

/*** PM ***/

int smapidev_GetPowerExpenditureMode(
	int intFiledesc,
	smapidev_powersrc_t powersrc,
	smapidev_powermode_t *ppowermode
);
int smapidev_SetPowerExpenditureMode(
	int intFiledesc,
	smapidev_powersrc_t powersrc,
	smapidev_powermode_t powermode
);

#endif