1f9f848faSopenharmony_ci/* 2f9f848faSopenharmony_ci * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. 3f9f848faSopenharmony_ci * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved. 4f9f848faSopenharmony_ci * 5f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 6f9f848faSopenharmony_ci * are permitted provided that the following conditions are met: 7f9f848faSopenharmony_ci * 8f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 9f9f848faSopenharmony_ci * conditions and the following disclaimer. 10f9f848faSopenharmony_ci * 11f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12f9f848faSopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 13f9f848faSopenharmony_ci * provided with the distribution. 14f9f848faSopenharmony_ci * 15f9f848faSopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16f9f848faSopenharmony_ci * to endorse or promote products derived from this software without specific prior written 17f9f848faSopenharmony_ci * permission. 18f9f848faSopenharmony_ci * 19f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20f9f848faSopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21f9f848faSopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22f9f848faSopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23f9f848faSopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24f9f848faSopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25f9f848faSopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26f9f848faSopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27f9f848faSopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28f9f848faSopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29f9f848faSopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30f9f848faSopenharmony_ci */ 31f9f848faSopenharmony_ci 32f9f848faSopenharmony_ci#ifndef __USB_INIT_H__ 33f9f848faSopenharmony_ci#define __USB_INIT_H__ 34f9f848faSopenharmony_ci 35f9f848faSopenharmony_ci#include <los_memory.h> 36f9f848faSopenharmony_ci 37f9f848faSopenharmony_ci#include "implementation/global_implementation.h" 38f9f848faSopenharmony_ci#include "usb_process.h" 39f9f848faSopenharmony_ci 40f9f848faSopenharmony_ci#ifdef __cplusplus 41f9f848faSopenharmony_ci#if __cplusplus 42f9f848faSopenharmony_ciextern "C" { 43f9f848faSopenharmony_ci#endif /* __cplusplus */ 44f9f848faSopenharmony_ci#endif /* __cplusplus */ 45f9f848faSopenharmony_ci 46f9f848faSopenharmony_ci/* Controller type */ 47f9f848faSopenharmony_citypedef enum controller_type { 48f9f848faSopenharmony_ci HOST = 0, 49f9f848faSopenharmony_ci DEVICE 50f9f848faSopenharmony_ci} controller_type; 51f9f848faSopenharmony_ci 52f9f848faSopenharmony_ci/* device type */ 53f9f848faSopenharmony_citypedef enum device_type { 54f9f848faSopenharmony_ci DEV_SERIAL = 1, /* used for serial */ 55f9f848faSopenharmony_ci DEV_ETHERNET, /* used for rndis */ 56f9f848faSopenharmony_ci DEV_SER_ETH, /* used for serial and rndis */ 57f9f848faSopenharmony_ci DEV_DFU, /* used for DFU */ 58f9f848faSopenharmony_ci DEV_MASS, /* used for mass */ 59f9f848faSopenharmony_ci DEV_UVC, /* used for USB video */ 60f9f848faSopenharmony_ci DEV_UAC, /* used for USB audio */ 61f9f848faSopenharmony_ci DEV_CAMERA, /* used for USB camera */ 62f9f848faSopenharmony_ci DEV_HID, /* used for USB hid */ 63f9f848faSopenharmony_ci DEV_GENERIC, /* used for USB generic */ 64f9f848faSopenharmony_ci} device_type; 65f9f848faSopenharmony_ci 66f9f848faSopenharmony_ci/* 67f9f848faSopenharmony_ci * Function:usb_init 68f9f848faSopenharmony_ci * Description: initialize the controller of usb, attach the usb protocol. 69f9f848faSopenharmony_ci * Input: ctype ------ the type of usb's controller, the legal value is one of 'controller_type'; 70f9f848faSopenharmony_ci * if it is HOST , 'dtype' can be any value of 'device_type'; 71f9f848faSopenharmony_ci * if it is DEVICE, 'dtype' must be one of 'device_type' that user needs. 72f9f848faSopenharmony_ci * dtype ------ the type of device, the legal value is one of 'device_type'; 73f9f848faSopenharmony_ci * if 'ctype' is DEVICE, it is determined by the use requirements. 74f9f848faSopenharmony_ci * Output: None 75f9f848faSopenharmony_ci * Return: success is LOS_OK, failure is LOS_NOK. 76f9f848faSopenharmony_ci */ 77f9f848faSopenharmony_ciuint32_t usb_init(controller_type ctype, device_type dtype); 78f9f848faSopenharmony_ci 79f9f848faSopenharmony_ci/* 80f9f848faSopenharmony_ci * Function:usb_deinit 81f9f848faSopenharmony_ci * Description: uninitialize the controller of usb, dettach the usb protocol. 82f9f848faSopenharmony_ci * Input: None 83f9f848faSopenharmony_ci * Output: None 84f9f848faSopenharmony_ci * Return: success is LOS_OK, failure is LOS_NOK. 85f9f848faSopenharmony_ci */ 86f9f848faSopenharmony_ciuint32_t usb_deinit(void); 87f9f848faSopenharmony_ci 88f9f848faSopenharmony_ci/* 89f9f848faSopenharmony_ci * Function:usb_is_devicemode 90f9f848faSopenharmony_ci * Description: check usb device mode. 91f9f848faSopenharmony_ci * Input: None 92f9f848faSopenharmony_ci * Output: None 93f9f848faSopenharmony_ci * Return: true is usb device mode, false is not linked or not usb device mode. 94f9f848faSopenharmony_ci */ 95f9f848faSopenharmony_cibool usb_is_devicemode(void); 96f9f848faSopenharmony_ci 97f9f848faSopenharmony_ci#ifdef __cplusplus 98f9f848faSopenharmony_ci#if __cplusplus 99f9f848faSopenharmony_ci} 100f9f848faSopenharmony_ci#endif /* __cplusplus */ 101f9f848faSopenharmony_ci#endif /* __cplusplus */ 102f9f848faSopenharmony_ci 103f9f848faSopenharmony_ci#endif 104