|
Lines 63-68
Link Here
|
| 63 |
static int asmc_probe(device_t dev); |
63 |
static int asmc_probe(device_t dev); |
| 64 |
static int asmc_attach(device_t dev); |
64 |
static int asmc_attach(device_t dev); |
| 65 |
static int asmc_detach(device_t dev); |
65 |
static int asmc_detach(device_t dev); |
|
|
66 |
static int asmc_resume(device_t dev); |
| 66 |
|
67 |
|
| 67 |
/* |
68 |
/* |
| 68 |
* SMC functions. |
69 |
* SMC functions. |
|
Lines 137-146
Link Here
|
| 137 |
#define ASMC_SMS_FUNCS asmc_mb_sysctl_sms_x, asmc_mb_sysctl_sms_y, \ |
138 |
#define ASMC_SMS_FUNCS asmc_mb_sysctl_sms_x, asmc_mb_sysctl_sms_y, \ |
| 138 |
asmc_mb_sysctl_sms_z |
139 |
asmc_mb_sysctl_sms_z |
| 139 |
|
140 |
|
|
|
141 |
#define ASMC_SMS_FUNCS_DISABLED NULL,NULL,NULL |
| 142 |
|
| 140 |
#define ASMC_FAN_FUNCS asmc_mb_sysctl_fanid, asmc_mb_sysctl_fanspeed, asmc_mb_sysctl_fansafespeed, \ |
143 |
#define ASMC_FAN_FUNCS asmc_mb_sysctl_fanid, asmc_mb_sysctl_fanspeed, asmc_mb_sysctl_fansafespeed, \ |
| 141 |
asmc_mb_sysctl_fanminspeed, \ |
144 |
asmc_mb_sysctl_fanminspeed, \ |
| 142 |
asmc_mb_sysctl_fanmaxspeed, \ |
145 |
asmc_mb_sysctl_fanmaxspeed, \ |
| 143 |
asmc_mb_sysctl_fantargetspeed |
146 |
asmc_mb_sysctl_fantargetspeed |
|
|
147 |
|
| 148 |
#define ASMC_FAN_FUNCS2 asmc_mb_sysctl_fanid, asmc_mb_sysctl_fanspeed, NULL, \ |
| 149 |
asmc_mb_sysctl_fanminspeed, \ |
| 150 |
asmc_mb_sysctl_fanmaxspeed, \ |
| 151 |
asmc_mb_sysctl_fantargetspeed |
| 152 |
|
| 144 |
#define ASMC_LIGHT_FUNCS asmc_mbp_sysctl_light_left, \ |
153 |
#define ASMC_LIGHT_FUNCS asmc_mbp_sysctl_light_left, \ |
| 145 |
asmc_mbp_sysctl_light_right, \ |
154 |
asmc_mbp_sysctl_light_right, \ |
| 146 |
asmc_mbp_sysctl_light_control |
155 |
asmc_mbp_sysctl_light_control |
|
Lines 158-163
Link Here
|
| 158 |
ASMC_MB_TEMPS, ASMC_MB_TEMPNAMES, ASMC_MB_TEMPDESCS |
167 |
ASMC_MB_TEMPS, ASMC_MB_TEMPNAMES, ASMC_MB_TEMPDESCS |
| 159 |
}, |
168 |
}, |
| 160 |
|
169 |
|
|
|
170 |
{ |
| 171 |
"MacBook3,1", "Apple SMC MacBook Core 2 Duo", |
| 172 |
ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, NULL, NULL, NULL, |
| 173 |
ASMC_MB31_TEMPS, ASMC_MB31_TEMPNAMES, ASMC_MB31_TEMPDESCS |
| 174 |
}, |
| 175 |
|
| 161 |
{ |
176 |
{ |
| 162 |
"MacBookPro1,1", "Apple SMC MacBook Pro Core Duo (15-inch)", |
177 |
"MacBookPro1,1", "Apple SMC MacBook Pro Core Duo (15-inch)", |
| 163 |
ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, |
178 |
ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, |
|
Lines 260-271
Link Here
|
| 260 |
ASMC_MBA3_TEMPS, ASMC_MBA3_TEMPNAMES, ASMC_MBA3_TEMPDESCS |
275 |
ASMC_MBA3_TEMPS, ASMC_MBA3_TEMPNAMES, ASMC_MBA3_TEMPDESCS |
| 261 |
}, |
276 |
}, |
| 262 |
|
277 |
|
|
|
278 |
{ |
| 279 |
"MacBookAir5,1", "Apple SMC MacBook Air 11-inch (Mid 2012)", |
| 280 |
ASMC_SMS_FUNCS_DISABLED, |
| 281 |
ASMC_FAN_FUNCS2, |
| 282 |
ASMC_LIGHT_FUNCS, |
| 283 |
ASMC_MBA5_TEMPS, ASMC_MBA5_TEMPNAMES, ASMC_MBA5_TEMPDESCS |
| 284 |
}, |
| 285 |
|
| 286 |
{ |
| 287 |
"MacBookAir5,2", "Apple SMC MacBook Air 13-inch (Mid 2012)", |
| 288 |
ASMC_SMS_FUNCS_DISABLED, |
| 289 |
ASMC_FAN_FUNCS2, |
| 290 |
ASMC_LIGHT_FUNCS, |
| 291 |
ASMC_MBA5_TEMPS, ASMC_MBA5_TEMPNAMES, ASMC_MBA5_TEMPDESCS |
| 292 |
}, |
| 293 |
|
| 263 |
|
294 |
|
| 264 |
{ NULL, NULL } |
295 |
{ NULL, NULL } |
| 265 |
}; |
296 |
}; |
| 266 |
|
297 |
|
| 267 |
#undef ASMC_SMS_FUNCS |
298 |
#undef ASMC_SMS_FUNCS |
|
|
299 |
#undef ASMC_SMS_FUNCS_DISABLED |
| 268 |
#undef ASMC_FAN_FUNCS |
300 |
#undef ASMC_FAN_FUNCS |
|
|
301 |
#undef ASMC_FAN_FUNCS2 |
| 269 |
#undef ASMC_LIGHT_FUNCS |
302 |
#undef ASMC_LIGHT_FUNCS |
| 270 |
|
303 |
|
| 271 |
/* |
304 |
/* |
|
Lines 275-280
Link Here
|
| 275 |
DEVMETHOD(device_probe, asmc_probe), |
308 |
DEVMETHOD(device_probe, asmc_probe), |
| 276 |
DEVMETHOD(device_attach, asmc_attach), |
309 |
DEVMETHOD(device_attach, asmc_attach), |
| 277 |
DEVMETHOD(device_detach, asmc_detach), |
310 |
DEVMETHOD(device_detach, asmc_detach), |
|
|
311 |
DEVMETHOD(device_resume, asmc_resume), |
| 278 |
|
312 |
|
| 279 |
{ 0, 0 } |
313 |
{ 0, 0 } |
| 280 |
}; |
314 |
}; |
|
Lines 301-306
Link Here
|
| 301 |
|
335 |
|
| 302 |
static devclass_t asmc_devclass; |
336 |
static devclass_t asmc_devclass; |
| 303 |
|
337 |
|
|
|
338 |
static unsigned int light_control = 0; |
| 339 |
|
| 304 |
DRIVER_MODULE(asmc, acpi, asmc_driver, asmc_devclass, NULL, NULL); |
340 |
DRIVER_MODULE(asmc, acpi, asmc_driver, asmc_devclass, NULL, NULL); |
| 305 |
MODULE_DEPEND(asmc, acpi, 1, 1, 1); |
341 |
MODULE_DEPEND(asmc, acpi, 1, 1, 1); |
| 306 |
|
342 |
|
|
Lines 581-586
Link Here
|
| 581 |
return (0); |
617 |
return (0); |
| 582 |
} |
618 |
} |
| 583 |
|
619 |
|
|
|
620 |
static int |
| 621 |
asmc_resume(device_t dev) |
| 622 |
{ |
| 623 |
uint8_t buf[2]; |
| 624 |
buf[0] = light_control; |
| 625 |
buf[1] = 0x00; |
| 626 |
asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof buf); |
| 627 |
return (0); |
| 628 |
} |
| 629 |
|
| 630 |
|
| 584 |
#ifdef DEBUG |
631 |
#ifdef DEBUG |
| 585 |
void asmc_dumpall(device_t dev) |
632 |
void asmc_dumpall(device_t dev) |
| 586 |
{ |
633 |
{ |
|
Lines 879-885
Link Here
|
| 879 |
snprintf(buf, sizeof(buf), "key %d is: %s, type %s " |
926 |
snprintf(buf, sizeof(buf), "key %d is: %s, type %s " |
| 880 |
"(len %d), data", number, key, type, maxlen); |
927 |
"(len %d), data", number, key, type, maxlen); |
| 881 |
for (i = 0; i < maxlen; i++) { |
928 |
for (i = 0; i < maxlen; i++) { |
| 882 |
snprintf(buf2, sizeof(buf), " %02x", v[i]); |
929 |
snprintf(buf2, sizeof(buf2), " %02x", v[i]); |
| 883 |
strlcat(buf, buf2, sizeof(buf)); |
930 |
strlcat(buf, buf2, sizeof(buf)); |
| 884 |
} |
931 |
} |
| 885 |
strlcat(buf, " \n", sizeof(buf)); |
932 |
strlcat(buf, " \n", sizeof(buf)); |
|
Lines 1324-1340
Link Here
|
| 1324 |
device_t dev = (device_t) arg1; |
1371 |
device_t dev = (device_t) arg1; |
| 1325 |
uint8_t buf[2]; |
1372 |
uint8_t buf[2]; |
| 1326 |
int error; |
1373 |
int error; |
| 1327 |
static unsigned int level; |
|
|
| 1328 |
int v; |
1374 |
int v; |
| 1329 |
|
1375 |
|
| 1330 |
v = level; |
1376 |
v = light_control; |
| 1331 |
error = sysctl_handle_int(oidp, &v, 0, req); |
1377 |
error = sysctl_handle_int(oidp, &v, 0, req); |
| 1332 |
|
1378 |
|
| 1333 |
if (error == 0 && req->newptr != NULL) { |
1379 |
if (error == 0 && req->newptr != NULL) { |
| 1334 |
if (v < 0 || v > 255) |
1380 |
if (v < 0 || v > 255) |
| 1335 |
return (EINVAL); |
1381 |
return (EINVAL); |
| 1336 |
level = v; |
1382 |
light_control = v; |
| 1337 |
buf[0] = level; |
1383 |
buf[0] = light_control; |
| 1338 |
buf[1] = 0x00; |
1384 |
buf[1] = 0x00; |
| 1339 |
asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof buf); |
1385 |
asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof buf); |
| 1340 |
} |
1386 |
} |