Skip to content

Commit 6aeca64

Browse files
Add host command to check privacy switch status (#513)
1 parent 6004af3 commit 6aeca64

File tree

6 files changed

+83
-2
lines changed

6 files changed

+83
-2
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2022 The Chromium OS Authors. All rights reserved.
3+
* Use of this source code is governed by a BSD-style license that can be
4+
* found in the LICENSE file.
5+
*/
6+
7+
#include "console.h"
8+
#include "chipset.h"
9+
#include "gpio.h"
10+
#include "ec_commands.h"
11+
#include "host_command.h"
12+
#include "host_command_customization.h"
13+
#include "baseboard_host_commands.h"
14+
#include "hooks.h"
15+
#include "keyboard_customization.h"
16+
#include "lid_switch.h"
17+
#include "lpc.h"
18+
#include "power_button.h"
19+
#include "switch.h"
20+
#include "system.h"
21+
#include "task.h"
22+
#include "timer.h"
23+
#include "util.h"
24+
#include "cypress5525.h"
25+
#include "board.h"
26+
#include "ps2mouse.h"
27+
#include "keyboard_8042_sharedlib.h"
28+
#include "diagnostics.h"
29+
#include "driver/als_cm32183.h"
30+
#include "cpu_power.h"
31+
#include "flash_storage.h"
32+
#define CPRINTS(format, args...) cprints(CC_SWITCH, format, ## args)
33+
34+
35+
/*****************************************************************************/
36+
/* Hooks */
37+
38+
static enum ec_status privacy_switches_check(struct host_cmd_handler_args *args)
39+
{
40+
struct ec_response_privacy_switches_check *r = args->response;
41+
42+
/*
43+
* Camera is low when off, microphone is high when off
44+
* Return 0 when off/close and 1 when high/open
45+
*/
46+
r->microphone = !gpio_get_level(GPIO_MIC_SW);
47+
r->camera = gpio_get_level(GPIO_CAM_SW);
48+
49+
CPRINTS("Microphone switch open: %d", r->microphone);
50+
CPRINTS("Camera switch open: %d", r->camera);
51+
52+
args->response_size = sizeof(*r);
53+
54+
return EC_RES_SUCCESS;
55+
56+
}
57+
DECLARE_HOST_COMMAND(EC_CMD_PRIVACY_SWITCHES_CHECK_MODE, privacy_switches_check, EC_VER_MASK(0));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Copyright 2022 The Chromium OS Authors. All rights reserved.
2+
* Use of this source code is governed by a BSD-style license that can be
3+
* found in the LICENSE file.
4+
*/
5+
6+
/* host command customization configuration */
7+
8+
#ifndef __BASEBOARD_HOST_COMMANDS_H
9+
#define __BASEBOARD_HOST_COMMANDS_H
10+
11+
#define EC_CMD_PRIVACY_SWITCHES_CHECK_MODE 0x3E14
12+
13+
struct ec_response_privacy_switches_check {
14+
uint8_t microphone;
15+
uint8_t camera;
16+
} __ec_align1;
17+
18+
#endif /* __BASEBOARD_HOST_COMMANDS_H */

baseboard/fwk/build.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ baseboard-$(CONFIG_BATTERY_SMART)+=battery.o
1111
baseboard-$(CONFIG_FANS)+=fan.o
1212
baseboard-$(CONFIG_SYSTEMSERIAL_DEBUG) += system_serial.o
1313
baseboard-$(CONFIG_8042_AUX) += ps2mouse.o
14+
baseboard-$(HAS_TASK_HOSTCMD) += baseboard_host_commands.o

board/hx30/board.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ const enum gpio_signal hibernate_wake_pins[] = {
312312
GPIO_POWER_BUTTON_L,
313313
GPIO_AC_PRESENT,
314314
GPIO_ON_OFF_BTN_L,
315+
GPIO_CAM_SW,
316+
GPIO_MIC_SW,
315317
};
316318
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
317319

board/hx30/gpio.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ GPIO_INT(CHASSIS_OPEN, PIN(0161), GPIO_INT_BOTH, chassis_control_interrupt) /
3838
GPIO_INT(ADP_IN, PIN(0172), GPIO_INT_BOTH, extpower_interrupt) /* Adaptor in from charger ACOK pin */
3939
GPIO_INT(PLT_RST_L, PIN(024), GPIO_INT_BOTH, soc_plt_reset_interrupt) /* CPU triggered Platform reset */
4040

41+
/* Privacy switches */
42+
GPIO(CAM_SW, PIN(067), GPIO_INT_BOTH) /* Monitor open/close of camera privacy switch */
43+
GPIO(MIC_SW, PIN(0175), GPIO_INT_BOTH) /* Monitor open/close of microphone privacy switch */
44+
4145
/* UART input */
4246
GPIO_INT(UART0_RX, PIN(0105), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, \
4347
uart_deepsleep_interrupt)
@@ -104,8 +108,6 @@ GPIO(MUX_SBU_UART_FLIP, PIN(0255), GPIO_OUT_LOW) /* SBU debug mux enable */
104108
GPIO(EC_PROCHOT_L, PIN(0222), GPIO_INPUT | GPIO_ODR_HIGH)
105109
GPIO(FAN_SPEED, PIN(050), GPIO_INPUT)
106110
GPIO(FP_CTRL, PIN(0245), GPIO_INPUT) /* Fingerprint control */
107-
GPIO(CAM_SW, PIN(067), GPIO_INPUT) /* (UNIMPLEMENTED) Monitor to close CAM PWR */
108-
GPIO(MIC_SW, PIN(0175), GPIO_INPUT) /* (UNIMPLEMENTED) DMIC function */
109111
GPIO(SOC_EC_INT_L, PIN(0246), GPIO_INPUT | GPIO_ODR_HIGH) /* HID interrupt, notify host to read data */
110112

111113
GPIO(TYPEC_G_DRV2_EN, PIN(0101), GPIO_OUT_HIGH) /* LED drv */

board/hx30/host_command_customization.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,4 @@ static enum ec_status standalone_mode(struct host_cmd_handler_args *args)
349349

350350
}
351351
DECLARE_HOST_COMMAND(EC_CMD_STANDALONE_MODE, standalone_mode, EC_VER_MASK(0));
352+

0 commit comments

Comments
 (0)