From 2efe0a33c4434f3b5048be67bef84338d1dab9ab Mon Sep 17 00:00:00 2001 From: Chun Xu Date: Wed, 18 Jul 2018 15:19:06 +0800 Subject: [PATCH] tegra-cec: add interface to get post_recovery Provide IOCTL interface for usersapce to get whether current boot is from booting from recovery. Bug 200394215 Change-Id: I45f492b766a75542ff470366001f92fa2fd65d23 Signed-off-by: Chun Xu Reviewed-on: https://git-master.nvidia.com/r/1780659 (cherry picked from commit 8a4bda6d7e0904ce9c0cafabac4aefb49e879b8b) Reviewed-on: https://git-master.nvidia.com/r/1792946 GVS: Gerrit_Virtual_Submit Reviewed-by: Prafull Suryawanshi Reviewed-by: Sachin Nikam Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/misc/tegra-cec/tegra_cec.c | 20 +++++++++++++------- drivers/misc/tegra-cec/tegra_cec.h | 11 ++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/misc/tegra-cec/tegra_cec.c b/drivers/misc/tegra-cec/tegra_cec.c index affe3cde..81957418 100644 --- a/drivers/misc/tegra-cec/tegra_cec.c +++ b/drivers/misc/tegra-cec/tegra_cec.c @@ -57,7 +57,7 @@ */ #define CEC_XFER_TIMEOUT_MS (5 * 400 + 100) -static bool previous_reboot_reason_is_recovery, text_view_on_sent; +static bool post_recovery, text_view_on_sent; static u8 text_view_on_command[] = { LOGICAL_ADDRESS_RESERVED2 << 4 | LOGICAL_ADDRESS_TV, TEXT_VIEW_ON @@ -400,6 +400,13 @@ static long tegra_cec_ioctl(struct file *file, unsigned int cmd, return -EFAULT; } break; + case TEGRA_CEC_IOCTL_GET_POST_RECOVERY: + err = !access_ok(VERIFY_WRITE, arg, sizeof(u32)); + if (err) + return -EFAULT; + if (copy_to_user((bool *) arg, &post_recovery, sizeof(bool))) + return -EFAULT; + break; default: dev_err(cec->dev, "unsupported ioctl\n"); return -EINVAL; @@ -531,7 +538,7 @@ static void tegra_cec_init(struct tegra_cec *cec) atomic_set(&cec->init_done, 1); wake_up_interruptible(&cec->init_waitq); - if (!text_view_on_sent && !previous_reboot_reason_is_recovery) + if (!text_view_on_sent && !post_recovery) tegra_cec_send_one_touch_play(cec); dev_notice(cec->dev, "%s Done.\n", __func__); } @@ -803,17 +810,16 @@ static int tegra_cec_resume(struct platform_device *pdev) } #endif -static int __init check_previous_reboot_reason_is_recovery(char *options) +static int __init check_post_recovery(char *options) { - previous_reboot_reason_is_recovery = true; + post_recovery = true; - pr_info("tegra_cec: the previous_reboot_reason is%s recovery.\n", - previous_reboot_reason_is_recovery ? "" : " not"); + pr_info("tegra_cec: the post_recovery is %d .\n", post_recovery); return 0; } -early_param("post_recovery", check_previous_reboot_reason_is_recovery); +early_param("post_recovery", check_post_recovery); static struct tegra_cec_soc tegra210_soc_data = { .powergate_id = TEGRA210_POWER_DOMAIN_DISA, diff --git a/drivers/misc/tegra-cec/tegra_cec.h b/drivers/misc/tegra-cec/tegra_cec.h index 70881a3d..cd3bdf3d 100644 --- a/drivers/misc/tegra-cec/tegra_cec.h +++ b/drivers/misc/tegra-cec/tegra_cec.h @@ -77,7 +77,7 @@ static int tegra_cec_remove(struct platform_device *pdev); #define TEGRA_CEC_INT_MASK 0X034 #define TEGRA_CEC_HW_DEBUG_RX 0X038 #define TEGRA_CEC_HW_DEBUG_TX 0X03C -#define TEGRA_CEC_HW_SPARE 0X03C +#define TEGRA_CEC_HW_SPARE 0X040 #define TEGRA_CEC_MAX_LOGICAL_ADDR 15 #define TEGRA_CEC_HWCTRL_RX_LADDR_UNREG 0x0 @@ -167,9 +167,10 @@ static int tegra_cec_remove(struct platform_device *pdev); #define TEGRA_CEC_IOC_MAGIC 'C' -#define TEGRA_CEC_IOCTL_ERROR_RECOVERY _IO(TEGRA_CEC_IOC_MAGIC, 1) -#define TEGRA_CEC_IOCTL_DUMP_REGISTERS _IO(TEGRA_CEC_IOC_MAGIC, 2) -#define TEGRA_CEC_IOCTL_SET_RX_SNOOP _IO(TEGRA_CEC_IOC_MAGIC, 3) -#define TEGRA_CEC_IOCTL_GET_RX_SNOOP _IO(TEGRA_CEC_IOC_MAGIC, 4) +#define TEGRA_CEC_IOCTL_ERROR_RECOVERY _IO(TEGRA_CEC_IOC_MAGIC, 1) +#define TEGRA_CEC_IOCTL_DUMP_REGISTERS _IO(TEGRA_CEC_IOC_MAGIC, 2) +#define TEGRA_CEC_IOCTL_SET_RX_SNOOP _IO(TEGRA_CEC_IOC_MAGIC, 3) +#define TEGRA_CEC_IOCTL_GET_RX_SNOOP _IO(TEGRA_CEC_IOC_MAGIC, 4) +#define TEGRA_CEC_IOCTL_GET_POST_RECOVERY _IO(TEGRA_CEC_IOC_MAGIC, 5) #endif /* TEGRA_CEC_H */