From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 714D22096965D for ; Mon, 21 May 2018 02:55:52 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id j5-v6so25546048wme.5 for ; Mon, 21 May 2018 02:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GC9l+Eznb9OfZO7e99MgXomoBRGOd7Ypt4JvEzKp3xY=; b=IcQZ4RsVC/MvrXy99n42M/VAFLjUqM/FKpziN8aKSlTQVyWLn/spBpmd9p0e2IAoid S0gj9CFr/PxCiUzsJFJNyaoMYaV3hccolpztmLdbcBLBrZbJLxM/l5cQXhGmNk99CYaD KgxJaHEYX9N+GCFyMORa1BOTj0HEwrBmjqluc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GC9l+Eznb9OfZO7e99MgXomoBRGOd7Ypt4JvEzKp3xY=; b=rfYIG5SfIVOmmrNIpuRyW0rRLmQVZTxPDc4u/1cYZcoTT7euS4YLO5w6AiYoKsMpun R/UJ0nA7+KNVkMQOtQM8W4ptle4ub4zv/6gGyHk5xtsLtNbyQlg20xNgmVu15qL6QBlD BFETt6xRXsnGN9QfhS9zG7AxjTn1Vn8HXwr+eu7zTVatpOQeXe3S/YsBU14r1OaCIDog JFLVDrl/I5O7UFud5VFeyrUdKnMim+xQeakBB4hh6bwXud98oAF0rxK8tVsYfPN1ukbt kxbCfiVb7vn6Bu4ohvfhZnFOTu21D2A50tOo3B+WOMWtjqeN/Gl5RxucYtRhVUCsun0b Cqcg== X-Gm-Message-State: ALKqPwfIGvMllMZ4XUDp58LcxeN++7R7ChTQQ6gOZxBJ3ZV8uNnatwE4 pzlwHskhJSjxYQnBtTA2YL9W+Q== X-Google-Smtp-Source: AB8JxZohWe/KhDbk6QOB91/qtv2GNj5tVMswBgekbw8DJwoaUfSwraN0hYVA/9EAfyD3esv5gWfVVg== X-Received: by 2002:a1c:b646:: with SMTP id g67-v6mr11027492wmf.88.1526896550861; Mon, 21 May 2018 02:55:50 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 135-v6sm16626612wmx.21.2018.05.21.02.55.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 02:55:49 -0700 (PDT) Date: Mon, 21 May 2018 10:55:48 +0100 From: Leif Lindholm To: Haojian Zhuang Cc: edk2-devel@lists.01.org, Ard Biesheuvel Message-ID: <20180521095548.5drln5dffqxxgorf@bivouac.eciton.net> References: <1526272473-25565-1-git-send-email-haojian.zhuang@linaro.org> <1526272473-25565-7-git-send-email-haojian.zhuang@linaro.org> MIME-Version: 1.0 In-Reply-To: <1526272473-25565-7-git-send-email-haojian.zhuang@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v4 6/6] Platform/HiKey: enable virtual keyboard X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 09:55:52 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 14, 2018 at 12:34:33PM +0800, Haojian Zhuang wrote: > Enable virtual keyboard on HiKey platform. It detects the pattern > in memory and GPIO pin setting, and simulates them into virtual > key. > > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Haojian Zhuang Some of this code looks like it could be turned into a common library for HiKey/HiKey960. Let's not worry about it for now, but please keep in mind for future. Reviewed-by: Leif Lindholm > --- > Platform/Hisilicon/HiKey/HiKey.dsc | 5 ++ > Platform/Hisilicon/HiKey/HiKey.fdf | 5 ++ > Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c | 98 ++++++++++++++++++++++++++ > Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf | 5 ++ > 4 files changed, 113 insertions(+) > > diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc b/Platform/Hisilicon/HiKey/HiKey.dsc > index 5cc4ff27f01b..83dd68a820b1 100644 > --- a/Platform/Hisilicon/HiKey/HiKey.dsc > +++ b/Platform/Hisilicon/HiKey/HiKey.dsc > @@ -192,6 +192,11 @@ [Components.common] > Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf > ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf > > + # > + # Virtual Keyboard > + # > + EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf > + > Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf > > # > diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf b/Platform/Hisilicon/HiKey/HiKey.fdf > index 39020d27dbcd..2bca7232b6e5 100644 > --- a/Platform/Hisilicon/HiKey/HiKey.fdf > +++ b/Platform/Hisilicon/HiKey/HiKey.fdf > @@ -123,6 +123,11 @@ [FV.FvMain] > INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf > INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf > > + # > + # Virtual Keyboard > + # > + INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf > + > INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf > > # > diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c > index 19987e0b29c3..8f4f9157835c 100644 > --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c > +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c > @@ -12,10 +12,15 @@ > * > **/ > > +#include > #include > #include > +#include > #include > > +#include > +#include > + > #include > #include > > @@ -31,6 +36,8 @@ > #define ADB_REBOOT_BOOTLOADER 0x77665500 > #define ADB_REBOOT_NONE 0x77665501 > > +STATIC EMBEDDED_GPIO *mGpio; > + > STATIC > VOID > UartInit ( > @@ -104,6 +111,90 @@ HiKeyInitPeripherals ( > > EFI_STATUS > EFIAPI > +VirtualKeyboardRegister ( > + IN VOID > + ) > +{ > + EFI_STATUS Status; > + > + Status = gBS->LocateProtocol ( > + &gEmbeddedGpioProtocolGuid, > + NULL, > + (VOID **) &mGpio > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +EFIAPI > +VirtualKeyboardReset ( > + IN VOID > + ) > +{ > + EFI_STATUS Status; > + > + if (mGpio == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT); > + return Status; > +} > + > +BOOLEAN > +EFIAPI > +VirtualKeyboardQuery ( > + IN VIRTUAL_KBD_KEY *VirtualKey > + ) > +{ > + EFI_STATUS Status; > + UINTN Value = 0; > + > + if ((VirtualKey == NULL) || (mGpio == NULL)) { > + return FALSE; > + } > + if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) { > + goto Done; > + } else { > + Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, &Value); > + if (EFI_ERROR (Status) || (Value != 0)) { > + return FALSE; > + } > + } > +Done: > + VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE; > + VirtualKey->Key.ScanCode = SCAN_NULL; > + VirtualKey->Key.UnicodeChar = L'f'; > + return TRUE; > +} > + > +EFI_STATUS > +EFIAPI > +VirtualKeyboardClear ( > + IN VIRTUAL_KBD_KEY *VirtualKey > + ) > +{ > + if (VirtualKey == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) { > + MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE); > + WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4); > + } > + return EFI_SUCCESS; > +} > + > +PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = { > + VirtualKeyboardRegister, > + VirtualKeyboardReset, > + VirtualKeyboardQuery, > + VirtualKeyboardClear > +}; > + > +EFI_STATUS > +EFIAPI > HiKeyEntryPoint ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > @@ -115,5 +206,12 @@ HiKeyEntryPoint ( > if (EFI_ERROR (Status)) { > return Status; > } > + > + Status = gBS->InstallProtocolInterface ( > + &ImageHandle, > + &gPlatformVirtualKeyboardProtocolGuid, > + EFI_NATIVE_INTERFACE, > + &mVirtualKeyboard > + ); > return Status; > } > diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf > index 34734391b45a..41aa7f8081ed 100644 > --- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf > +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf > @@ -28,11 +28,16 @@ [Packages] > MdePkg/MdePkg.dec > > [LibraryClasses] > + CacheMaintenanceLib > DebugLib > IoLib > UefiLib > UefiDriverEntryPoint > > +[Protocols] > + gEmbeddedGpioProtocolGuid > + gPlatformVirtualKeyboardProtocolGuid > + > [Guids] > gEfiEndOfDxeEventGroupGuid > > -- > 2.7.4 >