diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | hw/usb_client/CMakeLists.txt | 19 | ||||
-rw-r--r-- | hw/usb_client/usb_client.c | 112 |
3 files changed, 132 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fe66040..8d65243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,3 +36,4 @@ ADD_SUBDIRECTORY(hw/battery) ADD_SUBDIRECTORY(hw/display) ADD_SUBDIRECTORY(hw/external_connection) ADD_SUBDIRECTORY(hw/usb_gadget) +ADD_SUBDIRECTORY(hw/usb_client) diff --git a/hw/usb_client/CMakeLists.txt b/hw/usb_client/CMakeLists.txt new file mode 100644 index 0000000..f7b32c1 --- /dev/null +++ b/hw/usb_client/CMakeLists.txt @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(usb_client C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(usb_client_pkgs REQUIRED hwcommon dlog glib-2.0) + +FOREACH(flag ${usb_client_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} MODULE usb_client.c ../shared.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_client_pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries) diff --git a/hw/usb_client/usb_client.c b/hw/usb_client/usb_client.c new file mode 100644 index 0000000..9a90967 --- /dev/null +++ b/hw/usb_client/usb_client.c @@ -0,0 +1,112 @@ +/* + * device-node + * + * Copyright (c) 2016 Samsung Electronics 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 <hw/usb_client.h> + +#include <limits.h> +#include <stdio.h> +#include <string.h> + +#define zalloc(amount) calloc(1, amount) + +static int legacy_get_current_gadget(struct usb_client *usb, + struct usb_gadget **_gadget) +{ + return -ENOTSUP; +} + +static bool legacy_is_function_supported(struct usb_client *usb, + struct usb_function *func) +{ + return false; +} + +static bool legacy_is_gadget_supported(struct usb_client *usb, + struct usb_gadget *gadget) +{ + return false; +} + +static int legacy_reconfigure_gadget(struct usb_client *usb, + struct usb_gadget *gadget) +{ + return 0; +} + +static int legacy_enable(struct usb_client *usb) +{ + return 0; +} + +static int legacy_disable(struct usb_client *usb) +{ + return 0; +} + +static void legacy_free_gadget(struct usb_gadget *gadget) +{ +} + +static int legacy_gadget_open(struct hw_info *info, + const char *id, struct hw_common **common) +{ + struct usb_client *legacy; + + if (!info || !common) + return -EINVAL; + + legacy = zalloc(sizeof(*legacy)); + if (!legacy) + return -ENOMEM; + + legacy->common.info = info; + legacy->get_current_gadget = legacy_get_current_gadget; + legacy->reconfigure_gadget = legacy_reconfigure_gadget; + legacy->is_gadget_supported = legacy_is_gadget_supported; + legacy->is_function_supported = legacy_is_function_supported; + legacy->enable = legacy_enable; + legacy->disable = legacy_disable; + legacy->free_gadget = legacy_free_gadget; + + *common = &legacy->common; + return 0; +} + +static int legacy_gadget_close(struct hw_common *common) +{ + struct usb_client *legacy; + + if (!common) + return -EINVAL; + + legacy = container_of(common, struct usb_client, + common); + + free(legacy); + return 0; +} + +HARDWARE_MODULE_STRUCTURE = { + .magic = HARDWARE_INFO_TAG, + .hal_version = HARDWARE_INFO_VERSION, + .device_version = USB_CLIENT_HARDWARE_DEVICE_VERSION, + .id = USB_CLIENT_HARDWARE_DEVICE_ID, + .name = "legacy-gadget", + .open = legacy_gadget_open, + .close = legacy_gadget_close, +}; |