updated readme file due to moving CMake scripts to the root folder
[platform/upstream/dldt.git] / inference-engine / thirdparty / movidius / mvnc / src / mvnc_data.c
1 /*
2 * Copyright 2017-2019 Intel Corporation.
3 * The source code, information and material ("Material") contained herein is
4 * owned by Intel Corporation or its suppliers or licensors, and title to such
5 * Material remains with Intel Corporation or its suppliers or licensors.
6 * The Material contains proprietary information of Intel or its suppliers and
7 * licensors. The Material is protected by worldwide copyright laws and treaty
8 * provisions.
9 * No part of the Material may be used, copied, reproduced, modified, published,
10 * uploaded, posted, transmitted, distributed or disclosed in any way without
11 * Intel's prior express written permission. No license under any patent,
12 * copyright or other intellectual property rights in the Material is granted to
13 * or conferred upon you, either expressly, by implication, inducement, estoppel
14 * or otherwise.
15 * Any license under such intellectual property rights must be express and
16 * approved by Intel in writing.
17 */
18
19 #include <string.h>
20 #include "mvnc_data.h"
21 #define MVLOG_UNIT_NAME ncTool
22 #include "mvLog.h"
23 #include "mvStringUtils.h"
24 #include "mvnc_tool.h"
25
26 XLinkProtocol_t convertProtocolToXlink(
27     const ncDeviceProtocol_t ncProtocol) {
28     switch (ncProtocol) {
29         case NC_ANY_PROTOCOL: return X_LINK_ANY_PROTOCOL;
30         case NC_USB:          return X_LINK_USB_VSC;
31         case NC_PCIE:         return X_LINK_PCIE;
32         default:              return X_LINK_ANY_PROTOCOL;
33     }
34 }
35
36 ncDeviceProtocol_t convertProtocolToNC(
37     const XLinkProtocol_t xLinkProtocol) {
38     switch (xLinkProtocol) {
39         case X_LINK_ANY_PROTOCOL:   return NC_ANY_PROTOCOL;
40         case X_LINK_USB_VSC:        return NC_USB;
41         case X_LINK_PCIE:           return NC_PCIE;
42         default:
43             mvLog(MVLOG_WARN, "This convertation not supported, set to ANY_PROTOCOL");
44             return NC_ANY_PROTOCOL;
45     }
46 }
47
48 XLinkPlatform_t convertPlatformToXlink(
49     const ncDevicePlatform_t ncProtocol) {
50     switch (ncProtocol) {
51         case NC_ANY_PLATFORM: return X_LINK_ANY_PLATFORM;
52         case NC_MYRIAD_2:     return X_LINK_MYRIAD_2;
53         case NC_MYRIAD_X:     return X_LINK_MYRIAD_X;
54         default:           return X_LINK_ANY_PLATFORM;
55     }
56 }
57
58 ncDevicePlatform_t convertPlatformToNC(
59     const XLinkPlatform_t xLinkProtocol) {
60     switch (xLinkProtocol) {
61         case X_LINK_ANY_PLATFORM:   return NC_ANY_PLATFORM;
62         case X_LINK_MYRIAD_2:       return NC_MYRIAD_2;
63         case X_LINK_MYRIAD_X:       return NC_MYRIAD_X;
64         default:
65             mvLog(MVLOG_WARN, "This convertation not supported, set to NC_ANY_PLATFORM");
66             return NC_ANY_PLATFORM;
67     }
68 }
69
70 int copyNcDeviceDescrToXLink(const struct ncDeviceDescr_t *in_ncDeviceDesc,
71                                     deviceDesc_t *out_deviceDesc) {
72     CHECK_HANDLE_CORRECT(in_ncDeviceDesc);
73     CHECK_HANDLE_CORRECT(out_deviceDesc);
74
75     out_deviceDesc->protocol = convertProtocolToXlink(in_ncDeviceDesc->protocol);
76     out_deviceDesc->platform = convertPlatformToXlink(in_ncDeviceDesc->platform);
77     mv_strncpy(out_deviceDesc->name, XLINK_MAX_NAME_SIZE, in_ncDeviceDesc->name, XLINK_MAX_NAME_SIZE - 1);
78
79     return NC_OK;
80 }
81
82 int copyXLinkDeviceDescrToNc(const deviceDesc_t *in_DeviceDesc,
83                                     struct ncDeviceDescr_t *out_ncDeviceDesc) {
84     CHECK_HANDLE_CORRECT(in_DeviceDesc);
85     CHECK_HANDLE_CORRECT(out_ncDeviceDesc);
86
87     out_ncDeviceDesc->protocol = convertProtocolToNC(in_DeviceDesc->protocol);
88     out_ncDeviceDesc->platform = convertPlatformToNC(in_DeviceDesc->platform);
89     mv_strncpy(out_ncDeviceDesc->name, XLINK_MAX_NAME_SIZE, in_DeviceDesc->name, XLINK_MAX_NAME_SIZE - 1);
90
91     return NC_OK;
92 }