|
| 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)); |
0 commit comments