Skip to content

Commit 9114706

Browse files
committed
Directly use ec_commands.h from CrosEC
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 8452786 commit 9114706

4 files changed

Lines changed: 8998 additions & 38 deletions

File tree

FrameworkSensors/AccelerometerClient.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ UINT8 CrosEcGetMotionSensorCount(HANDLE Handle)
5454
req.MaxSensorCount = 0;
5555
if (0 == CrosEcSendCommand(
5656
Handle,
57-
EC_CMD_MOTION_SENSE,
57+
EC_CMD_MOTION_SENSE_CMD,
5858
1,
5959
&req,
6060
sizeof(req),
@@ -97,7 +97,7 @@ CrosEcGetAccelIndeces(HANDLE Handle, UINT8 *BaseSensor, UINT8 *LidSensor)
9797
req.SensorNum = i;
9898
if (0 == CrosEcSendCommand(
9999
Handle,
100-
EC_CMD_MOTION_SENSE,
100+
EC_CMD_MOTION_SENSE_CMD,
101101
1,
102102
&req,
103103
sizeof(req),
@@ -107,18 +107,18 @@ CrosEcGetAccelIndeces(HANDLE Handle, UINT8 *BaseSensor, UINT8 *LidSensor)
107107
TraceError("%!FUNC! EC_CMD_MOTION_SENSE_INFO failed for sensor %d", i);
108108
continue;
109109
}
110-
if (res.SensorType != MOTION_SENSE_TYPE_ACCEL) {
110+
if (res.SensorType != MOTIONSENSE_TYPE_ACCEL) {
111111
TraceError("%!FUNC! Found sensor of type %d. Not Accelerometer - ignoring.", res.SensorType);
112112
continue;
113113
}
114114

115115
switch (res.Location) {
116-
case MOTION_SENSE_LOCATION_BASE:
116+
case MOTIONSENSE_LOC_BASE:
117117
TraceInformation("%!FUNC! Found base accel sensor at index: %d", i);
118118
FoundBase = TRUE;
119119
*BaseSensor = i;
120120
break;
121-
case MOTION_SENSE_LOCATION_LID:
121+
case MOTIONSENSE_LOC_LID:
122122
TraceInformation("%!FUNC! Found lid accel sensor at index: %d", i);
123123
FoundLid = TRUE;
124124
*LidSensor = i;

FrameworkSensors/EcCommunication.h

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//SPDX-License-Identifier: MS-PL
22
//
33
//Copyright (C) Framework Computer Inc
4-
//Copyright (C) 2014 The ChromiumOS Authors
54
//
65
//Abstract:
76
//
@@ -18,24 +17,11 @@ extern "C" {
1817
#include <wdf.h>
1918
#include "Trace.h"
2019

21-
/* Command version mask */
22-
#define EC_VER_MASK(version) (1UL << (version))
23-
24-
#define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */
25-
/* Unused 0x84 - 0x8f */
26-
#define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/
27-
/* Unused 0x91 */
28-
#define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */
29-
/* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */
30-
/* 0x94 - 0x99: 1st Accelerometer */
31-
/* 0x9a - 0x9f: 2nd Accelerometer */
32-
33-
/* Define the format of the accelerometer mapped memory status byte. */
34-
#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
35-
// BIT(4)
36-
#define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
37-
// BIT(7)
38-
#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
20+
#include "ec_compat_win.h"
21+
#pragma pack(push, 1)
22+
#include "ec_commands.h"
23+
#pragma pack(pop)
24+
#pragma warning(pop) /* matches push in ec_compat_win.h */
3925

4026
#define FILE_DEVICE_CROS_EMBEDDED_CONTROLLER 0x80EC
4127

@@ -51,10 +37,6 @@ NTSTATUS ConnectToEc(
5137
_Inout_ HANDLE* Handle
5238
);
5339

54-
#define EC_CMD_MOTION_SENSE 0x002B
55-
#define EC_CMD_RGBKBD_SET_COLOR 0x013A
56-
#define EC_CMD_RGBKBD 0x013B
57-
5840
#define EC_RES_SUCCESS 0
5941
#define EC_INVALID_COMMAND 1
6042
#define EC_ERROR 2
@@ -117,16 +99,6 @@ typedef struct {
11799
UINT8 SensorNum;
118100
} EC_REQUEST_MOTION_SENSE_INFO;
119101

120-
#define MOTION_SENSE_TYPE_ACCEL 0x00
121-
#define MOTION_SENSE_TYPE_GYRO 0x01
122-
#define MOTION_SENSE_TYPE_MAG 0x02
123-
#define MOTION_SENSE_TYPE_PROX 0x03
124-
#define MOTION_SENSE_TYPE_LIGHT 0x04
125-
126-
#define MOTION_SENSE_LOCATION_BASE 0x00
127-
#define MOTION_SENSE_LOCATION_LID 0x01
128-
#define MOTION_SENSE_LOCATION_CAMERA 0x02
129-
130102
typedef struct {
131103
UINT8 SensorType;
132104
UINT8 Location;

0 commit comments

Comments
 (0)