-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
PROJECT(hal-api-tbm C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(LIBDIR ${CMAKE_LIBDIR_PREFIX})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/protocol)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(PKG_MODULES
hal-api-common
dlog
+ wayland-client
+ wayland-server
+ wayland-scanner
+ libdrm
)
INCLUDE(FindPkgConfig)
ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_TBM\"")
SET(SRCS
- src/hal-api-tbm.c)
+ protocol/wayland-tbm-drm-auth-protocol.c
+ src/hal-api-tbm.c
+ src/hal-tbm-drm-helper-server.c
+ src/hal-tbm-drm-helper-client.c
+ src/hal-tbm-log.c)
ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm -Wl,-z,nodelete,--no-undefined)
#ifndef __HAL_TBM_INTERFACE__
#define __HAL_TBM_INTERFACE__
-#include <hal/hal-common-interface.h>
-#include "hal-tbm-types.h"
-
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct _hal_tbm_bufmgr_func {
+#include <hal-tbm-types.h>
+
+typedef struct _hal_tbm_bufmgr_funcs hal_tbm_bufmgr_funcs;
+typedef struct _hal_tbm_bo_funcs hal_tbm_bo_funcs;
+
+struct _hal_tbm_backend_data {
+ hal_tbm_bufmgr_data *bufmgr_data; // handle for calling the hal_tbm_bufmgr_funcs
+ hal_tbm_bufmgr_funcs *bufmgr_funcs;
+ hal_tbm_bo_funcs *bo_funcs;
+};
+
+struct _hal_tbm_bufmgr_funcs {
/* tbm_bufmgr_func */
hal_tbm_bufmgr_capability (*bufmgr_get_capabilities)(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_error *error);
hal_tbm_error (*bufmgr_bind_native_display)(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_native_display *native_display);
hal_tbm_bo_memory_type flags, int bo_idx, hal_tbm_error *error);
hal_tbm_bo_data *(*bufmgr_import_fd)(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_fd fd, hal_tbm_error *error);
hal_tbm_bo_data *(*bufmgr_import_key)(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_key key, hal_tbm_error *error);
-} hal_tbm_bufmgr_func;
+};
-typedef struct _hal_tbm_bo_func {
+struct _hal_tbm_bo_funcs {
void (*bo_free)(hal_tbm_bo_data *bo_data);
int (*bo_get_size)(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
hal_tbm_bo_memory_type (*bo_get_memory_types)(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
hal_tbm_error (*bo_unlock)(hal_tbm_bo_data *bo_data);
hal_tbm_fd (*bo_export_fd)(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
hal_tbm_key (*bo_export_key)(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
-} hal_tbm_bo_func;
-
-int hal_tbm_query_display_server(hal_tbm_error *error);
-hal_tbm_bufmgr_func *hal_tbm_alloc_bufmgr_func(hal_tbm_error *error);
-void hal_tbm_free_bufmgr_func(hal_tbm_bufmgr_func *func);
-hal_tbm_error hal_tbm_register_bufmgr_func(hal_tbm_bufmgr_func *func);
-hal_tbm_bo_func *hal_tbm_alloc_bo_func(hal_tbm_error *error);
-void hal_tbm_free_bo_func(hal_tbm_bo_func *func);
-hal_tbm_error hal_tbm_register_bo_func(hal_tbm_bo_func *func);
+};
+
+/**
+ * @brief Initialize authentication server in display server.
+ * @details
+ * In DRM system, client sholud get authenticated fd from display server for using drm.
+ Tbm provides wayland protocol and helper function for passing and authenticating
+ fd from display server.
+ * @param[in] wl_display wayland display
+ * @param[in] fd fd of drm_master
+ * @param[in] device_name name of drm device
+ * @param[in] flags flags
+ * @see #hal_tbm_drm_helper_wl_auth_server_deinit()
+ */
+int hal_tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags);
+
+/**
+ * @brief Deinitialize authentication server in display server
+ * @details
+ * In DRM system, client sholud get authenticated fd from display server for using drm.
+ Tbm provides wayland protocol and helper function for passing and authenticating
+ fd from display server.
+ * @see #tdm_helper_set_tbm_master_fd()
+ * @see #hal_tbm_drm_helper_unset_tbm_master_fd()
+ */
+void hal_tbm_drm_helper_wl_auth_server_deinit(void);
+
+/**
+ * @brief Get a drm master fd.
+ * @details
+ * This function will dup the drm master fd.
+ The Caller SHOULD close the fd.
+ In DRM system, a drm master fd SHOULD be shared between TDM backend and
+ TBM backend in display server side.
+ * @return fd if success. Otherwise, -1.
+ * @see #hal_tbm_drm_helper_set_tbm_master_fd()
+ * @see #hal_tbm_drm_helper_unset_tbm_master_fd()
+ */
+int hal_tbm_drm_helper_get_master_fd(void);
+
+/**
+ * @brief Set a drm master fd with the given fd.
+ * @details
+ * In DRM system, a drm master fd @b SHOULD be shared between TDM backend and
+ TBM backend in display server side.
+ * @param[in] fd The given fd
+ * @see #hal_tbm_drm_helper_get_master_fd()
+ * @see #hal_tbm_drm_helper_unset_tbm_master_fd()
+ */
+void hal_tbm_drm_helper_set_tbm_master_fd(int fd);
+
+/**
+ * @brief Unset a drm master fd.
+ * @see #hal_tbm_drm_helper_get_master_fd()
+ * @see #hal_tbm_drm_helper_set_tbm_master_fd()
+ */
+void hal_tbm_drm_helper_unset_tbm_master_fd(void);
+
+/**
+ * @brief Get infomation of drm authentication.
+ * @details
+ * In DRM system, client sholud get authenticated fd from display server for using drm.
+ Tbm provides wayland protocol and helper function for passing and authenticating
+ fd from display server.
+ * @param[out] fd The authenticated fd
+ * @param[out] device The device name
+ * @param[out] capabilities The capabilities of device
+ * @see #tdm_helper_set_tbm_master_fd()
+ * @see #hal_tbm_drm_helper_unset_tbm_master_fd()
+ */
+int hal_tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities);
+
+/**
+ * @brief Set drm fd with the given fd.
+ * @details
+ * Some client want to get drm fd used tbm_backend.
+ if tbm_backend allow that client use drm_fd, it SHOULD be set.
+ * @param[in] fd The given fd
+ * @see #hal_tbm_drm_helper_get_fd()
+ */
+void hal_tbm_drm_helper_set_fd(int fd);
+
+/**
+ * @brief Unset drm fd.
+ * @details
+ * Some client want to get drm fd used tbm_backend.
+ if tbm_backend allow that client use drm_fd, it SHOULD be set.
+ * @param[in] fd The given fd
+ * @see #hal_tbm_drm_helper_get_fd()
+ */
+void hal_tbm_drm_helper_unset_fd(void);
+
+/**
+ * @brief Get drm fd.
+ * @details
+ * Some client want to get drm fd used tbm_backend.
+ client can get drm fd from this fucntion.
+ The Caller SHOULD close the fd.
+ * @return fd if success. Otherwise, -1.
+ * @see #tdm_helper_set_tbm_master_fd()
+ * @see #hal_tbm_drm_helper_unset_tbm_master_fd()
+ */
+int hal_tbm_drm_helper_get_fd(void);
#ifdef __cplusplus
}
#define _HAL_TBM_TYPES_H_
#include <stdint.h>
+#include <unistd.h>
#include <tizen.h>
#ifdef __cplusplus
HAL_TBM_OPTION_VENDOR = (0xffff0000), /**< the the vendor specific option that depends on the backend */
} tbm_bo_access_option;
+enum {
+ TBM_LOG_LEVEL_NONE,
+ HAL_TBM_LOG_LEVEL_ERR,
+ HAL_TBM_LOG_LEVEL_WRN,
+ HAL_TBM_LOG_LEVEL_INFO,
+ HAL_TBM_LOG_LEVEL_DBG,
+};
+
/**
* @brief hal_tbm_bo_handle abstraction of the memory handle by HAL_TBM_DEVICE_TYPE
*/
} hal_tbm_bo_handle;
/**
- * @brief Definition for hal_tbm_bufmgr handle
+ * @brief Definition for hal_tbm_backend_data handle
*/
-typedef struct _hal_tbm_bufmgr hal_tbm_bufmgr;
+typedef struct _hal_tbm_backend_data hal_tbm_backend_data;
/**
* @brief Definition for hal_tbm_bufmgr_data handle created by hal tbm backend
#include <hal-tbm-types.h>
-hal_tbm_error hal_tbm_get_backend(hal_tbm_bufmgr_data *bufmgr_data);
-void hal_tbm_put_backend(void);
+hal_tbm_error hal_tbm_get_backend(hal_tbm_backend_data *backend_data);
+void hal_tbm_put_backend(void);
+hal_tbm_bufmgr_data *hal_tbm_get_bufmgr_data(hal_tbm_backend_data *backend_data);
-/* hal_tbm_bufmgr_func */
+/* hal_tbm_bufmgr_funcs */
hal_tbm_bufmgr_capability hal_tbm_bufmgr_get_capabilities(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_error *error);
hal_tbm_error hal_tbm_bufmgr_bind_native_display(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_native_display *native_display);
hal_tbm_error hal_tbm_bufmgr_get_supported_formats(hal_tbm_bufmgr_data *bufmgr_data, uint32_t **formats, uint32_t *num);
hal_tbm_bo_data *hal_tbm_bufmgr_import_fd(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_fd fd, hal_tbm_error *error);
hal_tbm_bo_data *hal_tbm_bufmgr_import_key(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_key key, hal_tbm_error *error);
-/* hal_tbm_bo_func*/
+/* hal_tbm_bo_funcs*/
void hal_tbm_bo_free(hal_tbm_bo_data *bo_data);
int hal_tbm_bo_get_size(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
hal_tbm_bo_memory_type hal_tbm_bo_get_memory_types(hal_tbm_bo_data *bo_data, hal_tbm_error *error);
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(wayland-server)
+BuildRequires: pkgconfig(wayland-client)
+BuildRequires: pkgconfig(libdrm)
%description
%{name} interface
--- /dev/null
+/* Generated by wayland-scanner 1.18.92 */
+
+#ifndef TBM_DRM_AUTH_CLIENT_PROTOCOL_H
+#define TBM_DRM_AUTH_CLIENT_PROTOCOL_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @page page_tbm_drm_auth The tbm_drm_auth protocol
+ * @section page_ifaces_tbm_drm_auth Interfaces
+ * - @subpage page_iface_wl_tbm_drm_auth -
+ * @section page_copyright_tbm_drm_auth Copyright
+ * <pre>
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ * </pre>
+ */
+struct wl_tbm_drm_auth;
+
+#ifndef WL_TBM_DRM_AUTH_INTERFACE
+#define WL_TBM_DRM_AUTH_INTERFACE
+/**
+ * @page page_iface_wl_tbm_drm_auth wl_tbm_drm_auth
+ * @section page_iface_wl_tbm_drm_auth_api API
+ * See @ref iface_wl_tbm_drm_auth.
+ */
+/**
+ * @defgroup iface_wl_tbm_drm_auth The wl_tbm_drm_auth interface
+ */
+extern const struct wl_interface wl_tbm_drm_auth_interface;
+#endif
+
+#ifndef WL_TBM_DRM_AUTH_ERROR_ENUM
+#define WL_TBM_DRM_AUTH_ERROR_ENUM
+enum wl_tbm_drm_auth_error {
+ WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL = 0,
+};
+#endif /* WL_TBM_DRM_AUTH_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ * @struct wl_tbm_drm_auth_listener
+ */
+struct wl_tbm_drm_auth_listener {
+ /**
+ */
+ void (*authentication_info)(void *data,
+ struct wl_tbm_drm_auth *wl_tbm_drm_auth,
+ const char *device_name,
+ uint32_t capabilities,
+ int32_t auth_fd);
+};
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+static inline int
+wl_tbm_drm_auth_add_listener(struct wl_tbm_drm_auth *wl_tbm_drm_auth,
+ const struct wl_tbm_drm_auth_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_tbm_drm_auth,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_TBM_DRM_AUTH_GET_AUTHENTICATION_INFO 0
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+#define WL_TBM_DRM_AUTH_AUTHENTICATION_INFO_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+#define WL_TBM_DRM_AUTH_GET_AUTHENTICATION_INFO_SINCE_VERSION 1
+
+/** @ingroup iface_wl_tbm_drm_auth */
+static inline void
+wl_tbm_drm_auth_set_user_data(struct wl_tbm_drm_auth *wl_tbm_drm_auth, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_tbm_drm_auth, user_data);
+}
+
+/** @ingroup iface_wl_tbm_drm_auth */
+static inline void *
+wl_tbm_drm_auth_get_user_data(struct wl_tbm_drm_auth *wl_tbm_drm_auth)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_tbm_drm_auth);
+}
+
+static inline uint32_t
+wl_tbm_drm_auth_get_version(struct wl_tbm_drm_auth *wl_tbm_drm_auth)
+{
+ return wl_proxy_get_version((struct wl_proxy *) wl_tbm_drm_auth);
+}
+
+/** @ingroup iface_wl_tbm_drm_auth */
+static inline void
+wl_tbm_drm_auth_destroy(struct wl_tbm_drm_auth *wl_tbm_drm_auth)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_tbm_drm_auth);
+}
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+static inline void
+wl_tbm_drm_auth_get_authentication_info(struct wl_tbm_drm_auth *wl_tbm_drm_auth)
+{
+ wl_proxy_marshal((struct wl_proxy *) wl_tbm_drm_auth,
+ WL_TBM_DRM_AUTH_GET_AUTHENTICATION_INFO);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/* Generated by wayland-scanner 1.18.92 */
+
+/*
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+
+static const struct wl_interface *tbm_drm_auth_types[] = {
+ NULL,
+ NULL,
+ NULL,
+};
+
+static const struct wl_message wl_tbm_drm_auth_requests[] = {
+ { "get_authentication_info", "", tbm_drm_auth_types + 0 },
+};
+
+static const struct wl_message wl_tbm_drm_auth_events[] = {
+ { "authentication_info", "suh", tbm_drm_auth_types + 0 },
+};
+
+WL_EXPORT const struct wl_interface wl_tbm_drm_auth_interface = {
+ "wl_tbm_drm_auth", 1,
+ 1, wl_tbm_drm_auth_requests,
+ 1, wl_tbm_drm_auth_events,
+};
+
--- /dev/null
+/* Generated by wayland-scanner 1.18.92 */
+
+#ifndef TBM_DRM_AUTH_SERVER_PROTOCOL_H
+#define TBM_DRM_AUTH_SERVER_PROTOCOL_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-server.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct wl_client;
+struct wl_resource;
+
+/**
+ * @page page_tbm_drm_auth The tbm_drm_auth protocol
+ * @section page_ifaces_tbm_drm_auth Interfaces
+ * - @subpage page_iface_wl_tbm_drm_auth -
+ * @section page_copyright_tbm_drm_auth Copyright
+ * <pre>
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ * </pre>
+ */
+struct wl_tbm_drm_auth;
+
+#ifndef WL_TBM_DRM_AUTH_INTERFACE
+#define WL_TBM_DRM_AUTH_INTERFACE
+/**
+ * @page page_iface_wl_tbm_drm_auth wl_tbm_drm_auth
+ * @section page_iface_wl_tbm_drm_auth_api API
+ * See @ref iface_wl_tbm_drm_auth.
+ */
+/**
+ * @defgroup iface_wl_tbm_drm_auth The wl_tbm_drm_auth interface
+ */
+extern const struct wl_interface wl_tbm_drm_auth_interface;
+#endif
+
+#ifndef WL_TBM_DRM_AUTH_ERROR_ENUM
+#define WL_TBM_DRM_AUTH_ERROR_ENUM
+enum wl_tbm_drm_auth_error {
+ WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL = 0,
+};
+#endif /* WL_TBM_DRM_AUTH_ERROR_ENUM */
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ * @struct wl_tbm_drm_auth_interface
+ */
+struct wl_tbm_drm_auth_interface {
+ /**
+ */
+ void (*get_authentication_info)(struct wl_client *client,
+ struct wl_resource *resource);
+};
+
+#define WL_TBM_DRM_AUTH_AUTHENTICATION_INFO 0
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+#define WL_TBM_DRM_AUTH_AUTHENTICATION_INFO_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ */
+#define WL_TBM_DRM_AUTH_GET_AUTHENTICATION_INFO_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_wl_tbm_drm_auth
+ * Sends an authentication_info event to the client owning the resource.
+ * @param resource_ The client's resource
+ */
+static inline void
+wl_tbm_drm_auth_send_authentication_info(struct wl_resource *resource_, const char *device_name, uint32_t capabilities, int32_t auth_fd)
+{
+ wl_resource_post_event(resource_, WL_TBM_DRM_AUTH_AUTHENTICATION_INFO, device_name, capabilities, auth_fd);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="tbm_drm_auth">
+
+ <copyright>
+ Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that\n the above copyright notice appear in
+ all copies and that both that copyright notice and this permission
+ notice appear in supporting documentation, and that the name of
+ the copyright holders not be used in advertising or publicity
+ pertaining to distribution of the software without specific,
+ written prior permission. The copyright holders make no
+ representations about the suitability of this software for any
+ purpose. It is provided "as is" without express or implied
+ warranty.
+
+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ THIS SOFTWARE.
+ </copyright>
+
+ <!-- tbm support. This object is created by the server and published
+ using the display's global event. -->
+ <interface name="wl_tbm_drm_auth" version="1">
+ <enum name="error">
+ <entry name="authenticate_fail" value="0"/>
+ </enum>
+
+ <request name="get_authentication_info">
+ </request>
+
+ <event name="authentication_info">
+ <arg name="device_name" type="string"/>
+ <arg name="capabilities" type="uint"/>
+ <arg name="auth_fd" type="fd"/>
+ </event>
+
+ </interface>
+
+</protocol>
#ifndef __COMMON_H__
#define __COMMON_H__
+#include <sys/syscall.h>
+#include <time.h>
#include <dlog.h>
+
#define _D(fmt, args...) SLOGD(fmt, ##args)
#define _I(fmt, args...) SLOGI(fmt, ##args)
#define _W(fmt, args...) SLOGW(fmt, ##args)
#define _E(fmt, args...) SLOGE(fmt, ##args)
+/* log level */
+void hal_tbm_log_print(int level, const char *fmt, ...);
+
+#define HAL_TBM_DBG(fmt, args...) \
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ hal_tbm_log_print(HAL_TBM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt, \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
+
+#define HAL_TBM_INFO(fmt, args...) \
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ hal_tbm_log_print(HAL_TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
+
+#define HAL_TBM_WRN(fmt, args...) \
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ hal_tbm_log_print(HAL_TBM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt, \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
+
+#define HAL_TBM_ERR(fmt, args...) \
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ hal_tbm_log_print(HAL_TBM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt, \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
+
+#define HAL_TBM_RETURN_IF_FAIL(cond) {\
+ if (!(cond)) {\
+ HAL_TBM_ERR("'%s' failed.\n", #cond);\
+ return;\
+ } \
+}
+#define HAL_TBM_RETURN_VAL_IF_FAIL(cond, val) {\
+ if (!(cond)) {\
+ HAL_TBM_ERR("'%s' failed.\n", #cond);\
+ return val;\
+ } \
+}
+#define HAL_TBM_GOTO_VAL_IF_FAIL(cond, val) {\
+ if (!(cond)) {\
+ HAL_TBM_ERR("'%s' failed.\n", #cond);\
+ goto val;\
+ } \
+}
+
#endif /* __COMMON_H__ */
#include <stdint.h>
#include <stdlib.h>
-#include <hal/hal-common.h>
+#include <hal-common.h>
#include "common.h"
-#include "hal-tbm-types.h"
#include "hal-tbm.h"
#include "hal-tbm-interface.h"
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
#define BUFMGR_ENTRY() \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr) return HAL_TBM_ERROR_NOT_SUPPORTED;
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!g_tbm_backend_data) return HAL_TBM_ERROR_NOT_SUPPORTED;
#define BUFMGR_ENTRY_NULL() \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; }
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!g_hal_tbm_backend_data) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; }
#define BUFMGR_ENTRY_VOID() \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr) return;
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!g_hal_tbm_backend_data) return;
#define BUFMGR_ENTRY_GOTO(__goto__) \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr) goto __goto__;
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!g_hal_tbm_backend_data) goto __goto__;
#define BUFMGR_FUNC_ENTRY(__func__) \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bufmgr_func) return HAL_TBM_ERROR_NOT_SUPPORTED; \
- bufmgr_func = g_hal_tbm_bufmgr->bufmgr_func; \
- if (!bufmgr_func->__func__) return HAL_TBM_ERROR_NOT_SUPPORTED;
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!bufmgr_data) return HAL_TBM_ERROR_INVALID_PARAMETER; \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bufmgr_funcs) return HAL_TBM_ERROR_NOT_SUPPORTED; \
+ bufmgr_funcs = g_hal_tbm_backend_data->bufmgr_funcs; \
+ if (!bufmgr_funcs->__func__) return HAL_TBM_ERROR_NOT_SUPPORTED;
#define BUFMGR_FUNC_ENTRY_NULL(__func__) \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bufmgr_func) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; } \
- bufmgr_func = g_hal_tbm_bufmgr->bufmgr_func; \
- if (!bufmgr_func->__func__) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; };
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!bufmgr_data) { if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return NULL; } \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bufmgr_funcs) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; } \
+ bufmgr_funcs = g_hal_tbm_backend_data->bufmgr_funcs; \
+ if (!bufmgr_funcs->__func__) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; };
#define BUFMGR_FUNC_ENTRY_GOTO(__func__, __goto__) \
- hal_tbm_bufmgr_func *bufmgr_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bufmgr_func) goto __goto__; \
- bufmgr_func = g_hal_tbm_bufmgr->bufmgr_func; \
- if (!bufmgr_func->__func__) goto __goto__;
+ hal_tbm_bufmgr_funcs *bufmgr_funcs; \
+ if (!bufmgr_data) goto __goto__; \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bufmgr_funcs) goto __goto__; \
+ bufmgr_funcs = (hal_tbm_bufmgr_funcs *)g_hal_tbm_backend_data->bufmgr_funcs; \
+ if (!bufmgr_funcs->__func__) goto __goto__;
#define BO_FUNC_ENTRY(__func__) \
- hal_tbm_bo_func *bo_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bo_func) return HAL_TBM_ERROR_NOT_SUPPORTED; \
- bo_func = g_hal_tbm_bufmgr->bo_func; \
- if (!bo_func->__func__) return HAL_TBM_ERROR_NOT_SUPPORTED;
+ hal_tbm_bo_funcs *bo_funcs; \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bo_funcs) return HAL_TBM_ERROR_NOT_SUPPORTED; \
+ bo_funcs = g_hal_tbm_backend_data->bo_funcs; \
+ if (!bo_funcs->__func__) return HAL_TBM_ERROR_NOT_SUPPORTED;
#define BO_FUNC_ENTRY_VOID(__func__) \
- hal_tbm_bo_func *bo_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bo_func) return; \
- bo_func = g_hal_tbm_bufmgr->bo_func; \
- if (!bo_func->__func__) return;
+ hal_tbm_bo_funcs *bo_funcs; \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bo_funcs) return; \
+ bo_funcs = g_hal_tbm_backend_data->bo_funcs; \
+ if (!bo_funcs->__func__) return;
#define BO_FUNC_ENTRY_GOTO(__func__, __goto__) \
- hal_tbm_bo_func *bo_func; \
- if (!g_hal_tbm_bufmgr || !g_hal_tbm_bufmgr->bo_func) goto __goto__; \
- bo_func = g_hal_tbm_bufmgr->bo_func; \
- if (!bo_func->__func__) goto __goto__;
+ hal_tbm_bo_funcs *bo_funcs; \
+ if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bo_funcs) goto __goto__; \
+ bo_funcs = g_hal_tbm_backend_data->bo_funcs; \
+ if (!bo_funcs->__func__) goto __goto__;
-typedef struct _hal_tbm_bufmgr
-{
- hal_tbm_bufmgr_func *bufmgr_func;
- hal_tbm_bo_func *bo_func;
-} hal_tbm_bufmgr;
-
-static hal_tbm_bufmgr *g_hal_tbm_bufmgr = NULL;
+static hal_tbm_backend_data *g_hal_tbm_backend_data = NULL;
EXTERN hal_tbm_error
-hal_tbm_get_backend(hal_tbm_bufmgr_data *bufmgr_data)
+hal_tbm_get_backend(hal_tbm_backend_data *backend_data)
{
int ret;
- if (g_hal_tbm_bufmgr)
+ if (g_hal_tbm_backend_data)
return HAL_TBM_ERROR_INVALID_OPERATION;
- g_hal_tbm_bufmgr = calloc(1, sizeof(hal_tbm_bufmgr));
- if (!g_hal_tbm_bufmgr)
- return HAL_TBM_ERROR_OUT_OF_MEMORY;
-
- ret = hal_common_get_backend(HAL_MODULE_TBM, (void **)&bufmgr_data);
+ ret = hal_common_get_backend(HAL_MODULE_TBM, (void **)&backend_data);
if (ret < 0) {
_E("Failed to get backend\n");
- free(g_hal_tbm_bufmgr);
- g_hal_tbm_bufmgr = NULL;
+ free(g_hal_tbm_backend_data);
+ g_hal_tbm_backend_data = NULL;
return HAL_TBM_ERROR_NOT_SUPPORTED;
}
+ g_hal_tbm_backend_data = (hal_tbm_backend_data *)backend_data;
+
_I("hal_tbm_get_backend");
return HAL_TBM_ERROR_NONE;
EXTERN void
hal_tbm_put_backend(void)
{
- if (!g_hal_tbm_bufmgr)
+ if (!g_hal_tbm_backend_data)
return;
hal_common_put_backend(HAL_MODULE_TBM, NULL);
- free(g_hal_tbm_bufmgr);
- g_hal_tbm_bufmgr = NULL;
+ free(g_hal_tbm_backend_data);
+ g_hal_tbm_backend_data = NULL;
_I("hal_tbm_put_backend");
}
+EXTERN hal_tbm_bufmgr_data *
+hal_tbm_get_bufmgr_data(hal_tbm_backend_data *backend_data)
+{
+ hal_tbm_bufmgr_data *bufmgr_data;
+
+ if (!g_hal_tbm_backend_data) {
+ _E("no backend_data\n");
+ return NULL;
+ }
+
+ bufmgr_data = g_hal_tbm_backend_data->bufmgr_data;
+ if (!bufmgr_data) {
+ _E("no bufmgr_data\n");
+ return NULL;
+ }
+
+ return bufmgr_data;
+}
/* tbm_bufmgr_func */
EXTERN hal_tbm_bufmgr_capability
{
BUFMGR_FUNC_ENTRY_GOTO(bufmgr_get_capabilities, fail);
- return bufmgr_func->bufmgr_get_capabilities((hal_tbm_bufmgr_data *)bufmgr_data, error);
+ return bufmgr_funcs->bufmgr_get_capabilities((hal_tbm_bufmgr_data *)bufmgr_data, error);
fail:
if (error)
{
BUFMGR_FUNC_ENTRY(bufmgr_bind_native_display);
- return bufmgr_func->bufmgr_bind_native_display((hal_tbm_bufmgr_data *)bufmgr_data, native_display);
+ return bufmgr_funcs->bufmgr_bind_native_display((hal_tbm_bufmgr_data *)bufmgr_data, native_display);
}
EXTERN hal_tbm_error
{
BUFMGR_FUNC_ENTRY(bufmgr_get_supported_formats);
- return bufmgr_func->bufmgr_get_supported_formats((hal_tbm_bufmgr_data *)bufmgr_data, formats, num);
+ return bufmgr_funcs->bufmgr_get_supported_formats((hal_tbm_bufmgr_data *)bufmgr_data, formats, num);
}
EXTERN hal_tbm_error
{
BUFMGR_FUNC_ENTRY(bufmgr_get_plane_data);
- return bufmgr_func->bufmgr_get_plane_data((hal_tbm_bufmgr_data *)bufmgr_data, format, plane_idx, width, height, size, offset, pitch, bo_idx);
+ return bufmgr_funcs->bufmgr_get_plane_data((hal_tbm_bufmgr_data *)bufmgr_data, format, plane_idx, width, height, size, offset, pitch, bo_idx);
}
EXTERN hal_tbm_bo_data *
{
BUFMGR_FUNC_ENTRY_NULL(bufmgr_alloc_bo);
- return bufmgr_func->bufmgr_alloc_bo((hal_tbm_bufmgr_data *)bufmgr_data, size, mem_types, error);
+ return bufmgr_funcs->bufmgr_alloc_bo((hal_tbm_bufmgr_data *)bufmgr_data, size, mem_types, error);
}
EXTERN hal_tbm_bo_data *
{
BUFMGR_FUNC_ENTRY_NULL(bufmgr_alloc_bo_with_format);
- return bufmgr_func->bufmgr_alloc_bo_with_format((hal_tbm_bufmgr_data *)bufmgr_data, format, bo_idx, width, height, mem_types, error);
+ return bufmgr_funcs->bufmgr_alloc_bo_with_format((hal_tbm_bufmgr_data *)bufmgr_data, format, bo_idx, width, height, mem_types, error);
}
EXTERN hal_tbm_bo_data *
{
BUFMGR_FUNC_ENTRY_NULL(bufmgr_alloc_bo_with_tiled_format);
- return bufmgr_func->bufmgr_alloc_bo_with_tiled_format((hal_tbm_bufmgr_data *)bufmgr_data, width, height, bpp, format, flags, bo_idx, error);
+ return bufmgr_funcs->bufmgr_alloc_bo_with_tiled_format((hal_tbm_bufmgr_data *)bufmgr_data, width, height, bpp, format, flags, bo_idx, error);
}
EXTERN hal_tbm_bo_data *
{
BUFMGR_FUNC_ENTRY_NULL(bufmgr_import_fd);
- return bufmgr_func->bufmgr_import_fd((hal_tbm_bufmgr_data *)bufmgr_data, fd, error);
+ return bufmgr_funcs->bufmgr_import_fd((hal_tbm_bufmgr_data *)bufmgr_data, fd, error);
}
EXTERN hal_tbm_bo_data *
{
BUFMGR_FUNC_ENTRY_NULL(bufmgr_import_key);
- return bufmgr_func->bufmgr_import_key((hal_tbm_bufmgr_data *)bufmgr_data, key, error);
+ return bufmgr_funcs->bufmgr_import_key((hal_tbm_bufmgr_data *)bufmgr_data, key, error);
}
hal_tbm_bo_free(hal_tbm_bo_data *bo_data)
{
BO_FUNC_ENTRY_VOID(bo_free);
- bo_func->bo_free((hal_tbm_bo_data *)bo_data);
+
+ bo_funcs->bo_free((hal_tbm_bo_data *)bo_data);
}
EXTERN int
{
BO_FUNC_ENTRY_GOTO(bo_get_size, fail);
- return bo_func->bo_get_size((hal_tbm_bo_data *)bo_data, error);
+ return bo_funcs->bo_get_size((hal_tbm_bo_data *)bo_data, error);
fail:
if (error)
{
BO_FUNC_ENTRY_GOTO(bo_get_memory_types, fail);
- return bo_func->bo_get_memory_types((hal_tbm_bo_data *)bo_data, error);
+ return bo_funcs->bo_get_memory_types((hal_tbm_bo_data *)bo_data, error);
fail:
if (error)
{
BO_FUNC_ENTRY_GOTO(bo_get_handle, fail);
- return bo_func->bo_get_handle((hal_tbm_bo_data *)bo_data, device, error);
+ return bo_funcs->bo_get_handle((hal_tbm_bo_data *)bo_data, device, error);
fail:
if (error)
{
BO_FUNC_ENTRY_GOTO(bo_map, fail);
- return bo_func->bo_map((hal_tbm_bo_data *)bo_data, device, opt, error);
+ return bo_funcs->bo_map((hal_tbm_bo_data *)bo_data, device, opt, error);
fail:
if (error)
{
BO_FUNC_ENTRY(bo_unmap);
- return bo_func->bo_unmap((hal_tbm_bo_data *)bo_data);
+ return bo_funcs->bo_unmap((hal_tbm_bo_data *)bo_data);
}
EXTERN hal_tbm_error
{
BO_FUNC_ENTRY(bo_unmap);
- return bo_func->bo_lock((hal_tbm_bo_data *)bo_data, device, opt);
+ return bo_funcs->bo_lock((hal_tbm_bo_data *)bo_data, device, opt);
}
EXTERN hal_tbm_error
{
BO_FUNC_ENTRY(bo_unmap);
- return bo_func->bo_unlock((hal_tbm_bo_data *)bo_data);
+ return bo_funcs->bo_unlock((hal_tbm_bo_data *)bo_data);
}
EXTERN hal_tbm_fd
{
BO_FUNC_ENTRY_GOTO(bo_export_fd, fail);
- return bo_func->bo_export_fd((hal_tbm_bo_data *)bo_data, error);
+ return bo_funcs->bo_export_fd((hal_tbm_bo_data *)bo_data, error);
fail:
if (error)
{
BO_FUNC_ENTRY_GOTO(bo_export_key, fail);
- return bo_func->bo_export_key((hal_tbm_bo_data *)bo_data, error);
+ return bo_funcs->bo_export_key((hal_tbm_bo_data *)bo_data, error);
fail:
if (error)
return 0;
}
-
-
-/* tbm_func*/
-EXTERN int
-hal_tbm_query_display_server(hal_tbm_error *error)
-{
-// BUFMGR_ENTRY_NULL();
-
- //TODO:
- return 0;
-}
-
-EXTERN hal_tbm_bufmgr_func *
-hal_tbm_alloc_bufmgr_func(hal_tbm_error *error)
-{
- BUFMGR_ENTRY_NULL();
-
- bufmgr_func = calloc(1, sizeof(hal_tbm_bufmgr_func));
- if (!bufmgr_func) {
- _E("error: fail to allocate the tbm_bufmgr_func\n");
- if (error)
- *error = HAL_TBM_ERROR_OUT_OF_MEMORY;
-
- return NULL;
- }
-
- if (error)
- *error = HAL_TBM_ERROR_NONE;
-
- return bufmgr_func;
-}
-
-EXTERN void
-hal_tbm_free_bufmgr_func(hal_tbm_bufmgr_func *func)
-{
- BUFMGR_ENTRY_VOID();
-
- if (func)
- free(func);
-
- g_hal_tbm_bufmgr->bufmgr_func = NULL;
-}
-
-EXTERN hal_tbm_error
-hal_tbm_register_bufmgr_func(hal_tbm_bufmgr_func *func)
-{
- if (!g_hal_tbm_bufmgr) return HAL_TBM_ERROR_INVALID_OPERATION;
- if (g_hal_tbm_bufmgr->bufmgr_func) return HAL_TBM_ERROR_INVALID_OPERATION;
- if (!func) return HAL_TBM_ERROR_INVALID_PARAMETER;
- g_hal_tbm_bufmgr->bufmgr_func = func;
-
- return HAL_TBM_ERROR_NONE;
-}
-
-EXTERN hal_tbm_bo_func *
-hal_tbm_alloc_bo_func(hal_tbm_error *error)
-{
- BUFMGR_ENTRY_NULL();
-
- hal_tbm_bo_func *bo_func;
-
- bo_func = calloc(1, sizeof(hal_tbm_bo_func));
- if (!bo_func) {
- _E("error: fail to allocate the tbm_bufmgr_func\n");
- if (error)
- *error = HAL_TBM_ERROR_OUT_OF_MEMORY;
-
- return NULL;
- }
-
- if (error)
- *error = HAL_TBM_ERROR_NONE;
-
- return bo_func;
-}
-
-EXTERN void
-hal_tbm_free_bo_func(hal_tbm_bo_func *func)
-{
- BUFMGR_ENTRY_VOID();
-
- if (func)
- free(func);
-
- g_hal_tbm_bufmgr->bo_func = NULL;
-}
-
-EXTERN hal_tbm_error
-hal_tbm_register_bo_func(hal_tbm_bo_func *func)
-{
- if (!g_hal_tbm_bufmgr) return HAL_TBM_ERROR_INVALID_OPERATION;
- if (g_hal_tbm_bufmgr->bo_func) return HAL_TBM_ERROR_INVALID_OPERATION;
- if (!func) return HAL_TBM_ERROR_INVALID_PARAMETER;
- g_hal_tbm_bufmgr->bo_func = func;
-
- return HAL_TBM_ERROR_NONE;
-}
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ *
+ * hal-api-tbm
+ *
+ * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: SooChan Lim <sc1.lim@samsung.com>,
+ * Junkyeong Kim <jk0430.kim@samsung.com>,
+ * Changyeon Lee <cyeon.lee@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#define WL_HIDE_DEPRECATED
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/resource.h>
+#include "common.h"
+#include "hal-tbm-types.h"
+#include "wayland-tbm-drm-auth-client-protocol.h"
+
+struct wayland_tbm_drm_auth_client {
+ struct wl_display *display;
+ struct wl_tbm_drm_auth *wl_tbm_drm_auth;
+ int auth_fd;
+ char *device;
+ uint32_t capabilities;
+};
+
+static int tbm_drm_fd = -1;
+
+/* LCOV_EXCL_START */
+static void
+handle_tbm_drm_authentication_info(void *data, struct wl_tbm_drm_auth *wl_tbm_drm_auth, const char *device_name, uint32_t capabilities, int32_t auth_fd)
+{
+ struct wayland_tbm_drm_auth_client *tbm_drm_client = (struct wayland_tbm_drm_auth_client *)data;
+
+ /* client authentication infomation */
+ tbm_drm_client->auth_fd = auth_fd;
+ tbm_drm_client->capabilities = capabilities;
+ if (device_name)
+ tbm_drm_client->device = strdup(device_name);
+}
+
+static const struct wl_tbm_drm_auth_listener wl_tbm_drm_auth_client_listener = {
+ handle_tbm_drm_authentication_info
+};
+
+static void
+_wayland_tbm_drm_auth_client_registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
+{
+ struct wayland_tbm_drm_auth_client *tbm_drm_client = (struct wayland_tbm_drm_auth_client *)data;
+
+ if (!strcmp(interface, "wl_tbm_drm_auth")) {
+ tbm_drm_client->wl_tbm_drm_auth = wl_registry_bind(registry, name, &wl_tbm_drm_auth_interface, version);
+ HAL_TBM_RETURN_IF_FAIL(tbm_drm_client->wl_tbm_drm_auth != NULL);
+
+ wl_tbm_drm_auth_add_listener(tbm_drm_client->wl_tbm_drm_auth, &wl_tbm_drm_auth_client_listener, tbm_drm_client);
+ }
+}
+
+static void
+_wayland_tbm_drm_auth_client_registry_remove_global(void *data, struct wl_registry *registry, uint32_t name)
+{
+}
+
+static const struct wl_registry_listener registry_listener = {
+ _wayland_tbm_drm_auth_client_registry_handle_global,
+ _wayland_tbm_drm_auth_client_registry_remove_global
+};
+
+int
+hal_tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities)
+{
+ struct wl_display *display;
+ struct wl_registry *wl_registry;
+ struct wayland_tbm_drm_auth_client *tbm_drm_client;
+
+ tbm_drm_client = calloc(1, sizeof(struct wayland_tbm_drm_auth_client));
+ HAL_TBM_RETURN_VAL_IF_FAIL(tbm_drm_client != NULL, 0);
+
+ tbm_drm_client->auth_fd = -1;
+
+ display = wl_display_connect("tbm-drm-auth");
+ if (!display) {
+ HAL_TBM_ERR("Failed to connect display\n");
+ free(tbm_drm_client);
+
+ return 0;
+ }
+
+ tbm_drm_client->display = display;
+
+ wl_registry = wl_display_get_registry(display);
+ if (!wl_registry) {
+ HAL_TBM_ERR("Failed to get registry\n");
+ wl_display_disconnect(display);
+ free(tbm_drm_client);
+
+ return 0;
+ }
+
+ wl_registry_add_listener(wl_registry, ®istry_listener, tbm_drm_client);
+ if (wl_display_roundtrip(display) < 0) { //For Gloabl registry
+ HAL_TBM_ERR("Failed to wl_display_roundtrip for global registry\n");
+ wl_registry_destroy(wl_registry);
+ wl_display_disconnect(display);
+ free(tbm_drm_client);
+ return 0;
+ }
+
+ if (!tbm_drm_client->wl_tbm_drm_auth) {
+ HAL_TBM_ERR("Failed to get wl_tbm_drm_auth interface\n");
+ wl_registry_destroy(wl_registry);
+ wl_display_disconnect(display);
+ free(tbm_drm_client);
+
+ return 0;
+ }
+
+ wl_tbm_drm_auth_get_authentication_info(tbm_drm_client->wl_tbm_drm_auth);
+ if (wl_display_roundtrip(display) < 0) {
+ HAL_TBM_ERR("Failed to wl_display_roundtrip get auth info\n");
+ wl_tbm_drm_auth_set_user_data(tbm_drm_client->wl_tbm_drm_auth, NULL);
+ wl_tbm_drm_auth_destroy(tbm_drm_client->wl_tbm_drm_auth);
+ wl_registry_destroy(wl_registry);
+ wl_display_disconnect(display);
+ free(tbm_drm_client);
+ return 0;
+ }
+
+ if (tbm_drm_client->auth_fd < 0) {
+ HAL_TBM_ERR("Failed to get auth info\n");
+ wl_tbm_drm_auth_set_user_data(tbm_drm_client->wl_tbm_drm_auth, NULL);
+ wl_tbm_drm_auth_destroy(tbm_drm_client->wl_tbm_drm_auth);
+ wl_registry_destroy(wl_registry);
+ wl_display_disconnect(display);
+ free(tbm_drm_client);
+
+ return 0;
+ }
+
+ if (auth_fd)
+ *auth_fd = tbm_drm_client->auth_fd;
+ else
+ close(tbm_drm_client->auth_fd);
+
+ if (capabilities)
+ *capabilities = tbm_drm_client->capabilities;
+
+ if (device) {
+ if (tbm_drm_client->device)
+ *device = strdup(tbm_drm_client->device);
+ else
+ *device = NULL;
+ }
+
+ wl_tbm_drm_auth_set_user_data(tbm_drm_client->wl_tbm_drm_auth, NULL);
+ wl_tbm_drm_auth_destroy(tbm_drm_client->wl_tbm_drm_auth);
+
+ if (tbm_drm_client->device)
+ free(tbm_drm_client->device);
+
+ free(tbm_drm_client);
+
+ wl_registry_destroy(wl_registry);
+ wl_display_disconnect(display);
+
+ return 1;
+}
+
+static int _hal_tbm_drm_helper_client_get_fd_limit(void)
+{
+ struct rlimit lim;
+
+ if (getrlimit(RLIMIT_NOFILE, &lim))
+ return 1024;
+
+ return (int)lim.rlim_cur;
+}
+
+void
+hal_tbm_drm_helper_set_fd(int fd)
+{
+ int fd_max = _hal_tbm_drm_helper_client_get_fd_limit();
+
+ if (tbm_drm_fd == fd)
+ return;
+
+ if (fd < 0 || fd > fd_max) {
+ HAL_TBM_ERR("%d out of fd range\n", fd);
+ return;
+ }
+
+ if (tbm_drm_fd != -1)
+ HAL_TBM_WRN("already has TBM_DRM_FD: %d\n", tbm_drm_fd);
+
+ tbm_drm_fd = fd;
+
+ HAL_TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
+}
+
+void
+hal_tbm_drm_helper_unset_fd(void)
+{
+ tbm_drm_fd = -1;
+ HAL_TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
+}
+
+int
+hal_tbm_drm_helper_get_fd(void)
+{
+ int new_fd, flags;
+
+ if (tbm_drm_fd == -1) {
+ HAL_TBM_ERR("no drm fd");
+ return -1;
+ }
+
+ HAL_TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
+
+ flags = fcntl(tbm_drm_fd, F_GETFD);
+ if (flags == -1) {
+ HAL_TBM_ERR("fcntl failed: %m");
+ return -1;
+ }
+
+ new_fd = dup(tbm_drm_fd);
+ if (new_fd < 0) {
+ HAL_TBM_ERR("dup failed: %m");
+ return -1;
+ }
+
+ if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
+ HAL_TBM_ERR("failed to set fd\n");
+ close(new_fd);
+ return -1;
+ }
+
+ HAL_TBM_INFO("Return TBM_FD: %d\n", new_fd);
+
+ return new_fd;
+}
+
+/* LCOV_EXCL_STOP */
--- /dev/null
+/**************************************************************************
+ *
+ * hal-api-tbm
+ *
+ * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: SooChan Lim <sc1.lim@samsung.com>,
+ * Junkyeong Kim <jk0430.kim@samsung.com>,
+ * Changyeon Lee <cyeon.lee@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#define WL_HIDE_DEPRECATED
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <xf86drm.h>
+#include <grp.h>
+#include "common.h"
+#include "hal-tbm-types.h"
+#include "wayland-tbm-drm-auth-server-protocol.h"
+
+struct wayland_tbm_drm_auth_server {
+ struct wl_display *display;
+ struct wl_global *wl_tbm_drm_auth_global;
+
+ char *device_name;
+ uint32_t fd;
+ uint32_t flags;
+};
+
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
+struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv;
+
+static int tbm_drm_master_fd = -1;
+
+/* LCOV_EXCL_START */
+static void
+_send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
+ struct wl_resource *resource)
+{
+ int fd = -1;
+ uint32_t capabilities;
+ char *device_name = NULL;
+ drm_magic_t magic = 0;
+
+ fd = open(tbm_drm_auth_srv->device_name, O_RDWR | O_CLOEXEC);
+ if (fd == -1 && errno == EINVAL) {
+ fd = open(tbm_drm_auth_srv->device_name, O_RDWR);
+ if (fd != -1) {
+ if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) == -1) {
+ HAL_TBM_ERR("failed to set fd\n");
+ goto fini;
+ }
+ }
+ }
+
+ if (fd < 0) {
+ HAL_TBM_ERR("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
+
+ wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
+ "authenicate failed::open_drm");
+ goto fini;
+ }
+
+ if (drmGetMagic(fd, &magic) < 0) {
+ if (errno != EACCES) {
+ HAL_TBM_ERR("failed to get magic\n");
+
+ wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
+ "authenicate failed::get_magic");
+ goto fini;
+ }
+ }
+
+ if (drmAuthMagic(tbm_drm_auth_srv->fd, magic) < 0) {
+ HAL_TBM_ERR("failed to authenticate magic\n");
+
+ wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
+ "authenicate failed::auth_magic");
+ goto fini;
+ }
+
+ capabilities = tbm_drm_auth_srv->flags;
+ device_name = tbm_drm_auth_srv->device_name;
+
+ /* send */
+ wl_tbm_drm_auth_send_authentication_info(resource, device_name, capabilities, fd);
+
+fini:
+ if (fd >= 0)
+ close(fd);
+
+ if (device_name && device_name != tbm_drm_auth_srv->device_name)
+ free(device_name);
+
+}
+
+static void
+_wayland_tbm_drm_auth_server_impl_get_authentication_info(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv = wl_resource_get_user_data(resource);
+
+ /* if display server is the client of the host display server, for embedded server */
+ _send_server_auth_info(tbm_drm_auth_srv, resource);
+}
+
+
+static const struct wl_tbm_drm_auth_interface _wayland_tbm_drm_auth_server_implementation = {
+ _wayland_tbm_drm_auth_server_impl_get_authentication_info,
+};
+
+static void
+_wayland_tbm_drm_auth_server_bind_cb(struct wl_client *client, void *data,
+ uint32_t version,
+ uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_resource_create(client, &wl_tbm_drm_auth_interface, MIN(version, 1), id);
+ if (!resource) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource,
+ &_wayland_tbm_drm_auth_server_implementation,
+ data,
+ NULL);
+}
+
+static int
+_tbm_getgrnam_r(const char *name)
+{
+ struct group *grp = NULL;
+ struct group *grp_res = NULL;
+ char* buf = NULL;
+ size_t buf_len;
+ int ret;
+ int id;
+
+ buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (buf_len == -1)
+ buf_len = 2048;
+
+ buf = calloc(1, buf_len * sizeof(char));
+ if (!buf) {
+ HAL_TBM_ERR("creating buffer failed\n");
+ goto failed;
+ }
+
+ grp = calloc(1, sizeof(struct group));
+ if (!grp) {
+ HAL_TBM_ERR("creating group failed\n");
+ goto failed;
+ }
+
+ ret = getgrnam_r(name, grp, buf, buf_len, &grp_res);
+ if (ret < 0) {
+ HAL_TBM_ERR("getgrnam_r failed errno:%d(%m)\n", ret);
+ goto failed;
+ }
+
+ if (grp_res == NULL) {
+ HAL_TBM_ERR("finding name:%s group failed\n", name);
+ goto failed;
+ }
+
+ id = grp->gr_gid;
+ free(buf);
+ free(grp);
+
+ return id;
+
+failed:
+ if (buf)
+ free(buf);
+ if (grp)
+ free(grp);
+
+ return -1;
+}
+
+static void
+_tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
+{
+ const char *dir = NULL;
+ char socket_path[128];
+ int ret = -1;
+ uid_t uid;
+ gid_t gid;
+
+ dir = getenv("XDG_RUNTIME_DIR");
+ if (!dir) {
+ HAL_TBM_WRN("getting XDG_RUNTIME_DIR failed\n");
+ return;
+ }
+
+ snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, "tbm-drm-auth");
+
+ ret = chmod(socket_path, 509);
+ if (ret < 0) {
+ HAL_TBM_WRN("changing modes of socket file failed:%s (%m)\n", socket_path);
+ return;
+ }
+
+ ret = _tbm_getgrnam_r("root");
+ if (ret < 0) {
+ HAL_TBM_WRN("getting uid failed\n");
+ return;
+ }
+ uid = ret;
+
+ ret = _tbm_getgrnam_r("display");
+ if (ret < 0) {
+ HAL_TBM_WRN("getting gid failed\n");
+ return;
+ }
+ gid = ret;
+
+ ret = chown(socket_path, uid, gid);
+ if (ret < 0) {
+ HAL_TBM_WRN("changing owner of socket file failed:%s (%m)\n", socket_path);
+ return;
+ }
+}
+
+int
+hal_tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags)
+{
+ if (!tbm_drm_auth_srv) {
+ HAL_TBM_RETURN_VAL_IF_FAIL(wl_display != NULL, 0);
+
+ tbm_drm_auth_srv = calloc(1, sizeof(struct wayland_tbm_drm_auth_server));
+ HAL_TBM_RETURN_VAL_IF_FAIL(tbm_drm_auth_srv != NULL, 0);
+
+ tbm_drm_auth_srv->display = (struct wl_display *)wl_display;
+ tbm_drm_auth_srv->device_name = strdup(device_name);
+ tbm_drm_auth_srv->fd = fd;
+ tbm_drm_auth_srv->flags = flags;
+
+ if (wl_display_add_socket(tbm_drm_auth_srv->display, "tbm-drm-auth")) {
+ HAL_TBM_ERR("[TBM_DRM] fail to add socket\n");
+
+ if (tbm_drm_auth_srv->device_name)
+ free(tbm_drm_auth_srv->device_name);
+
+ free(tbm_drm_auth_srv);
+ tbm_drm_auth_srv = NULL;
+
+ return 0;
+ }
+
+ _tbm_drm_auth_socket_init(tbm_drm_auth_srv);
+
+ /* init the client resource list */
+ tbm_drm_auth_srv->wl_tbm_drm_auth_global = wl_global_create(tbm_drm_auth_srv->display, &wl_tbm_drm_auth_interface, 1,
+ tbm_drm_auth_srv, _wayland_tbm_drm_auth_server_bind_cb);
+ }
+
+ return 1;
+}
+
+void
+hal_tbm_drm_helper_wl_auth_server_deinit(void)
+{
+ if (tbm_drm_auth_srv) {
+ wl_global_destroy(tbm_drm_auth_srv->wl_tbm_drm_auth_global);
+
+ if (tbm_drm_auth_srv->device_name)
+ free(tbm_drm_auth_srv->device_name);
+
+ free(tbm_drm_auth_srv);
+ tbm_drm_auth_srv = NULL;
+ }
+}
+
+int
+hal_tbm_drm_helper_get_master_fd(void)
+{
+ int new_fd, flags, fd = -1;
+
+ fd = tbm_drm_master_fd;
+ if (fd == -1) {
+ HAL_TBM_INFO("no presetted TBM DRM MASTER FD");
+ return -1;
+ }
+
+ HAL_TBM_INFO("TBM DRM MASTER FD: %d\n", fd);
+
+ flags = fcntl(fd, F_GETFD);
+ if (flags == -1) {
+ HAL_TBM_ERR("fcntl failed: %m");
+ return -1;
+ }
+
+ new_fd = dup(fd);
+ if (new_fd < 0) {
+ HAL_TBM_ERR("dup failed: %m");
+ return -1;
+ }
+
+ if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
+ HAL_TBM_ERR("failed to set fd\n");
+ close(new_fd);
+ return -1;
+ }
+
+ HAL_TBM_INFO("Return MASTER_FD: %d\n", new_fd);
+
+ return new_fd;
+}
+
+static int _hal_tbm_drm_helper_server_get_fd_limit(void)
+{
+ struct rlimit lim;
+
+ if (getrlimit(RLIMIT_NOFILE, &lim))
+ return 1024;
+
+ return (int)lim.rlim_cur;
+}
+
+void
+hal_tbm_drm_helper_set_tbm_master_fd(int fd)
+{
+ int fd_max = _hal_tbm_drm_helper_server_get_fd_limit();
+
+ if (tbm_drm_master_fd == fd)
+ return;
+
+ if (fd < 0 || fd > fd_max) {
+ HAL_TBM_ERR("%d out of fd range\n", fd);
+ return;
+ }
+
+ if (tbm_drm_master_fd != -1)
+ HAL_TBM_WRN("already has TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+
+ tbm_drm_master_fd = fd;
+
+ HAL_TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+}
+
+void
+hal_tbm_drm_helper_unset_tbm_master_fd(void)
+{
+ tbm_drm_master_fd = -1;
+ HAL_TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+}
+/* LCOV_EXCL_STOP */
+
--- /dev/null
+#include <dlog.h>
+#include "hal-tbm-types.h"
+
+unsigned int tbm_log_debug_level = HAL_TBM_LOG_LEVEL_INFO;
+
+static void
+_tbm_log_dlog_print(int level, const char *fmt, va_list arg)
+{
+ log_priority dlog_prio;
+
+ switch (level) {
+ case HAL_TBM_LOG_LEVEL_ERR:
+ dlog_prio = DLOG_ERROR;
+ break;
+ case HAL_TBM_LOG_LEVEL_WRN:
+ dlog_prio = DLOG_WARN;
+ break;
+ case HAL_TBM_LOG_LEVEL_INFO:
+ dlog_prio = DLOG_INFO;
+ break;
+ case HAL_TBM_LOG_LEVEL_DBG:
+ dlog_prio = DLOG_DEBUG;
+ break;
+ default:
+ return;
+ }
+ __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmt, arg);
+}
+
+void
+hal_tbm_log_print(int level, const char *fmt, ...)
+{
+ va_list arg;
+
+ if (level > tbm_log_debug_level)
+ return;
+
+ va_start(arg, fmt);
+ _tbm_log_dlog_print(level, fmt, arg);
+ va_end(arg);
+}
\ No newline at end of file