Skip to content

Commit 5017814

Browse files
committed
fwk: Add host command for privacy switches
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 66fc847 commit 5017814

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

zephyr/program/lotus/azalea/gpio.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
ec_smb_da7 {
6060
gpios = <&gpiob 2 GPIO_INPUT>;
6161
};
62-
mic_sw {
62+
gpio_mic_sw: mic_sw {
6363
gpios = <&gpioc 1 GPIO_INPUT>;
6464
};
6565
gpio_on_off_btn_l: on_off_btn_l {
@@ -157,7 +157,7 @@
157157
gpio_apu_ec_int2_l: apu_ec_int2_l {
158158
gpios = <&gpio7 4 GPIO_ODR_HIGH>; /* EC notify host HID interrupt 2*/
159159
};
160-
cam_sw {
160+
gpio_cam_sw: cam_sw {
161161
gpios = <&gpio9 3 GPIO_INPUT>;
162162
};
163163
gpio_spok: pwr_3v5v_pg {

zephyr/program/lotus/include/board_host_command.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ struct ec_params_standalone_mode {
240240
uint8_t enable;
241241
} __ec_align1;
242242

243+
/*****************************************************************************/
244+
/*
245+
* This command returns the current state of the camera and microphone privacy switches
246+
*/
247+
#define EC_CMD_PRIVACY_SWITCHES_CHECK_MODE 0x3E14
248+
249+
struct ec_response_privacy_switches_check {
250+
uint8_t microphone;
251+
uint8_t camera;
252+
} __ec_align1;
243253

244254
/*****************************************************************************/
245255
/*

zephyr/program/lotus/lotus/gpio.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
ec_smb_da7 {
7878
gpios = <&gpiob 2 GPIO_INPUT>;
7979
};
80-
mic_sw {
80+
gpio_mic_sw: mic_sw {
8181
gpios = <&gpioc 1 GPIO_INPUT>;
8282
};
8383
gpu_b_gpio00_ec {
@@ -257,7 +257,7 @@
257257
i2c_int_tp_2 {
258258
gpios = <&gpio9 6 GPIO_INPUT>; /* HUB board TP module */
259259
};
260-
cam_sw {
260+
gpio_cam_sw: cam_sw {
261261
gpios = <&gpio9 3 GPIO_INPUT>;
262262
};
263263
gpio_spok: spok {

zephyr/program/lotus/src/board_host_command.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,27 @@ static enum ec_status host_command_uefi_app_btn_status(struct host_cmd_handler_a
417417
DECLARE_HOST_COMMAND(EC_CMD_UEFI_APP_BTN_STATUS, host_command_uefi_app_btn_status, EC_VER_MASK(0));
418418
#endif /* CONFIG_BOARD_LOTUS */
419419

420+
static enum ec_status privacy_switches_check(struct host_cmd_handler_args *args)
421+
{
422+
struct ec_response_privacy_switches_check *r = args->response;
423+
424+
/*
425+
* Camera is low when off, microphone is high when off
426+
* Return 0 when off/close and 1 when high/open
427+
*/
428+
r->microphone = !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_mic_sw));
429+
r->camera = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_cam_sw));
430+
431+
CPRINTS("Microphone switch open: %d", r->microphone);
432+
CPRINTS("Camera switch open: %d", r->camera);
433+
434+
args->response_size = sizeof(*r);
435+
436+
return EC_RES_SUCCESS;
437+
438+
}
439+
DECLARE_HOST_COMMAND(EC_CMD_PRIVACY_SWITCHES_CHECK_MODE, privacy_switches_check, EC_VER_MASK(0));
440+
420441
/*******************************************************************************/
421442
/* EC console command for Project */
422443
/*******************************************************************************/

0 commit comments

Comments
 (0)