From 68128e79975bd12744faa128854db90a3cf0daad Mon Sep 17 00:00:00 2001 From: luwh0708 Date: Thu, 21 Apr 2022 15:41:11 +0800 Subject: [PATCH 1/2] - deps Change-Id: I34e7dd0db30f62a4f586d26d84e2ae2a03b0fb5c --- hardware/display/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/hardware/display/BUILD.gn b/hardware/display/BUILD.gn index c6672471..a1cc51df 100644 --- a/hardware/display/BUILD.gn +++ b/hardware/display/BUILD.gn @@ -66,8 +66,6 @@ ohos_shared_library("display_gralloc") { deps = [ ":higbm", "//third_party/libdrm:libdrm", - "//third_party/wayland_standard:libwayland_client", - "//third_party/weston:drm_auth_protocol", "//utils/native/base:utils", ] -- Gitee From 7c54e0089e12b0f73ee2ca087885364f78b2df7a Mon Sep 17 00:00:00 2001 From: luwh0708 Date: Thu, 21 Apr 2022 15:41:14 +0800 Subject: [PATCH 2/2] - impl: wayland_drm_auth_client Change-Id: I30beb2874e4274da7f26b7a0a9e2acb4bb4a758e --- hardware/display/BUILD.gn | 1 - .../src/display_gralloc/display_gralloc_gbm.c | 1 - .../display_gralloc/wayland_drm_auth_client.c | 113 ------------------ .../display_gralloc/wayland_drm_auth_client.h | 41 ------- 4 files changed, 156 deletions(-) delete mode 100644 hardware/display/src/display_gralloc/wayland_drm_auth_client.c delete mode 100644 hardware/display/src/display_gralloc/wayland_drm_auth_client.h diff --git a/hardware/display/BUILD.gn b/hardware/display/BUILD.gn index a1cc51df..b4832e65 100644 --- a/hardware/display/BUILD.gn +++ b/hardware/display/BUILD.gn @@ -45,7 +45,6 @@ ohos_shared_library("display_gralloc") { sources = [ "src/display_gralloc/display_gralloc.c", "src/display_gralloc/display_gralloc_gbm.c", - "src/display_gralloc/wayland_drm_auth_client.c", ] include_dirs = [ "include", diff --git a/hardware/display/src/display_gralloc/display_gralloc_gbm.c b/hardware/display/src/display_gralloc/display_gralloc_gbm.c index daab1d74..6f9f5ba3 100644 --- a/hardware/display/src/display_gralloc/display_gralloc_gbm.c +++ b/hardware/display/src/display_gralloc/display_gralloc_gbm.c @@ -26,7 +26,6 @@ #include #include #include -#include "wayland_drm_auth_client.h" #include "drm_fourcc.h" #include "hisilicon_drm.h" #include "hi_gbm.h" diff --git a/hardware/display/src/display_gralloc/wayland_drm_auth_client.c b/hardware/display/src/display_gralloc/wayland_drm_auth_client.c deleted file mode 100644 index d5b1cda3..00000000 --- a/hardware/display/src/display_gralloc/wayland_drm_auth_client.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wayland_drm_auth_client.h" -#include -#include -#include "xf86drm.h" -#include "wayland-client.h" -#include "drm-auth-client-protocol.h" -#include "display_common.h" - -typedef struct { - struct wl_display *display; - struct wl_registry *registry; - struct wl_drm_auth *drmAuth; - enum wl_drm_auth_status authStatus; -} WaylandDisplay; - -const char *AUTH_INTERFACE_NAME = "wl_drm_auth"; - -static void AuthenticationStatus(void *data, struct wl_drm_auth *wlDrmAuth, uint32_t status) -{ - (void)wlDrmAuth; - DISPLAY_DEBUGLOG("AuthenticationStatus the status %{public}d", status); - WaylandDisplay *display = data; - display->authStatus = status; -} - -static const struct wl_drm_auth_listener g_drmAuthListener = { AuthenticationStatus }; - -static void RegistryHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const char *interface, - uint32_t version) -{ - WaylandDisplay *display = data; - DISPLAY_DEBUGLOG("interface global : %{public}s", interface); - if (strcmp(interface, wl_drm_auth_interface.name) == 0) { - display->drmAuth = wl_registry_bind(registry, id, &wl_drm_auth_interface, 1); - wl_drm_auth_add_listener(display->drmAuth, &g_drmAuthListener, display); - } -} - -static void RegistryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) -{ - DISPLAY_DEBUGLOG("RegistryHandleGlobalRemove %{publuc}d name ", name); -} - -static const struct wl_registry_listener g_registrListener = { RegistryHandleGlobal, RegistryHandleGlobalRemove }; - -void DeInitWaylandClient(WaylandDisplay *display) -{ - DISPLAY_DEBUGLOG("DeInitWaylandClient"); - DISPLAY_CHK_RETURN_NOT_VALUE((display == NULL), DISPLAY_DEBUGLOG("display is NULL")); - if (display->registry != NULL) { - wl_registry_destroy(display->registry); - } - - if (display->display != NULL) { - wl_display_flush(display->display); - wl_display_disconnect(display->display); - } - free(display); -} - -WaylandDisplay *InitWaylandClient(void) -{ - WaylandDisplay *dsp; - int ret; - dsp = calloc(1, sizeof(WaylandDisplay)); - DISPLAY_CHK_RETURN((dsp == NULL), NULL, DISPLAY_LOGE("can not alloc memory errno : %{public}d", errno)); - dsp->display = wl_display_connect(NULL); - DISPLAY_CHK_RETURN((dsp->display == NULL), NULL, DISPLAY_LOGE("display connect failed, errno: %{public}d", errno); - DeInitWaylandClient(dsp)); - dsp->registry = wl_display_get_registry(dsp->display); - DISPLAY_CHK_RETURN((dsp->registry == NULL), NULL, DISPLAY_LOGE("can not get registry"); - DeInitWaylandClient(dsp)); - ret = wl_registry_add_listener(dsp->registry, &g_registrListener, dsp); - DISPLAY_CHK_RETURN((ret < 0), NULL, DISPLAY_LOGE("add listener failed")); - wl_display_roundtrip(dsp->display); // for get registry - wl_display_roundtrip(dsp->display); // for the listener will bind the service - return dsp; -} - -int32_t WaylandDrmAuth(int drmFd) -{ - WaylandDisplay *dsp; - drm_magic_t magic; - int ret; - dsp = InitWaylandClient(); - DISPLAY_CHK_RETURN((dsp == NULL), AUTH_FAILED, DISPLAY_LOGE("init wayland client failed")); - ret = drmGetMagic(drmFd, &magic); - DISPLAY_CHK_RETURN((ret != 0), AUTH_FAILED, DISPLAY_LOGE("can not get magic")); - DISPLAY_CHK_RETURN((dsp->drmAuth == NULL), AUTH_FAILED, DISPLAY_LOGE("drm auth service no find")); - wl_drm_auth_authenticate(dsp->drmAuth, magic); - wl_display_roundtrip(dsp->display); // wait for authenticate status return - DISPLAY_DEBUGLOG("the status of authenticate is %{public}d", dsp->authStatus); - if (dsp->authStatus == WL_DRM_AUTH_STATUS_SUCCESS) { - ret = AUTH_SCUCCESS; - } - DeInitWaylandClient(dsp); - return ret; -} diff --git a/hardware/display/src/display_gralloc/wayland_drm_auth_client.h b/hardware/display/src/display_gralloc/wayland_drm_auth_client.h deleted file mode 100644 index 69be0fa0..00000000 --- a/hardware/display/src/display_gralloc/wayland_drm_auth_client.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WAYLAND_DRM_AUTH_CLIENT_H -#define WAYLAND_DRM_AUTH_CLIENT_H -#include - -typedef enum { - AUTH_SCUCCESS = 0, /* * authenticate sucess */ - AUTH_FAILED = 1 /* * authenticate failed */ -} AuthStatus; - -/* * - * @brief authenticate the drm fd - * - * it will connect to the wayland server, and will block to authenticate the drm fd, then disconnect the wayland - * - * @param display Indicates the pointer of wayland display - * - * @param drmFd Indicates the file descriptor of drm device - * - * @return Returns AUTH_SCUCCESS if the operation is successful else returns AUTH_FAILED - * otherwise. - * @since 1.0 - * @version 1.0 - */ -int32_t WaylandDrmAuth(int drmFd); - -#endif // WAYLAND_DRM_AUTH_CLIENT_H -- Gitee