|
| 1 | +/* |
| 2 | + * BSD-3-Clause |
| 3 | + * |
| 4 | + * Copyright (c) 2022 - 2024, Realtek Semiconductor Corp. All rights reserved. |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without modification, |
| 7 | + * are permitted provided that the following conditions are met: |
| 8 | + * |
| 9 | + * * Redistributions of source code must retain the above copyright notice, this |
| 10 | + * list of conditions and the following disclaimer. |
| 11 | + * |
| 12 | + * * Redistributions in binary form must reproduce the above copyright notice, |
| 13 | + * this list of conditions and the following disclaimer in the documentation |
| 14 | + * and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * * Neither the name of the Realtek nor the names of its contributors may |
| 17 | + * be used to endorse or promote products derived from this software without |
| 18 | + * specific prior written permission. |
| 19 | + * |
| 20 | + * |
| 21 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 22 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 23 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 24 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 25 | + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 27 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 29 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 30 | + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | + */ |
| 32 | + |
| 33 | +#ifndef _BRIDGE_FUNC_H_ |
| 34 | +#define _BRIDGE_FUNC_H_ |
| 35 | + |
| 36 | +#ifdef __cplusplus |
| 37 | +extern "C" { |
| 38 | +#endif |
| 39 | + |
| 40 | +#ifndef ARRAY_SIZE |
| 41 | +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) |
| 42 | +#endif |
| 43 | + |
| 44 | +#define MAX_DISKS 10 |
| 45 | + |
| 46 | +#ifdef CONFIG_ARGB_DEV |
| 47 | +#define M_BRIDGE_CHECK_VID_PID argb_bridge_check_vid_pid |
| 48 | +#define M_BRIDGE_WRITE_UNLOCK argb_bridge_write_unlock |
| 49 | +#define M_BRIDGE_DISCONNECT argb_bridge_disconnect |
| 50 | +#define M_BRIDGE_CHECK_TARGET argb_bridge_check_target |
| 51 | +#define M_BRIDGE_GET_IC_GEN argb_bridge_get_ic_gen |
| 52 | +#define M_BRIDGE_GET_UUID argb_bridge_get_uuid |
| 53 | +#define M_BRIDGE_GET_CUST_PAGE argb_bridge_get_cust_page |
| 54 | +#define M_BRIDGE_SET_CUST_PAGE argb_bridge_set_cust_page |
| 55 | +#define M_BRIDGE_GET_FW_VER argb_bridge_get_fw_ver |
| 56 | +#define M_BRIDGE_GET_BUF_SIZE argb_bridge_get_buf_size |
| 57 | +#define M_BRIDGE_GET_USB_SPEED argb_bridge_get_usb_speed |
| 58 | +#define M_BRIDGE_GET_API_VER argb_bridge_get_api_ver |
| 59 | +#define M_BRIDGE_INQUIRY argb_bridge_inquiry |
| 60 | +#define M_BRIDGE_GET_NAME argb_bridge_get_name |
| 61 | +#define M_BRIDGE_GET_VENDOR_NAME argb_bridge_get_vendor_name |
| 62 | +#define M_BRIDGE_GET_PRODUCT_NAME argb_bridge_get_product_name |
| 63 | +#define M_BRIDGE_GET_DEBUG_LEVEL argb_bridge_get_debug_level |
| 64 | +#define M_BRIDGE_SET_DEBUG_LEVEL argb_bridge_set_debug_level |
| 65 | +#define M_BRIDGE_REPORT_LUNS argb_bridge_report_luns |
| 66 | +#else |
| 67 | +#define M_BRIDGE_CHECK_VID_PID bridge_check_vid_pid |
| 68 | +#define M_BRIDGE_WRITE_UNLOCK bridge_write_unlock |
| 69 | +#define M_BRIDGE_DISCONNECT bridge_disconnect |
| 70 | +#define M_BRIDGE_CHECK_TARGET bridge_check_target |
| 71 | +#define M_BRIDGE_GET_IC_GEN bridge_get_ic_gen |
| 72 | +#define M_BRIDGE_GET_UUID bridge_get_uuid |
| 73 | +#define M_BRIDGE_GET_CUST_PAGE bridge_get_cust_page |
| 74 | +#define M_BRIDGE_SET_CUST_PAGE bridge_set_cust_page |
| 75 | +#define M_BRIDGE_GET_FW_VER bridge_get_fw_ver |
| 76 | +#define M_BRIDGE_GET_BUF_SIZE bridge_get_buf_size |
| 77 | +#define M_BRIDGE_GET_USB_SPEED bridge_get_usb_speed |
| 78 | +#define M_BRIDGE_GET_API_VER bridge_get_api_ver |
| 79 | +#define M_BRIDGE_INQUIRY bridge_inquiry |
| 80 | +#define M_BRIDGE_GET_NAME bridge_get_name |
| 81 | +#define M_BRIDGE_GET_VENDOR_NAME bridge_get_vendor_name |
| 82 | +#define M_BRIDGE_GET_PRODUCT_NAME bridge_get_product_name |
| 83 | +#define M_BRIDGE_GET_DEBUG_LEVEL bridge_get_debug_level |
| 84 | +#define M_BRIDGE_SET_DEBUG_LEVEL bridge_set_debug_level |
| 85 | +#define M_BRIDGE_REPORT_LUNS bridge_report_luns |
| 86 | +#endif |
| 87 | + |
| 88 | +struct bridge_fw_version { |
| 89 | + uint32_t fw_major_ver; |
| 90 | + uint32_t fw_minor_ver; |
| 91 | + uint32_t fw_extra_ver; |
| 92 | + uint32_t fw_build_ver; |
| 93 | + uint32_t fw_build_date; |
| 94 | +}; |
| 95 | + |
| 96 | +#ifdef CONFIG_ARGB_DEV |
| 97 | +int argb_bridge_check_vid_pid(uint16_t vid, |
| 98 | + uint16_t pid, |
| 99 | + struct usb_id *id, |
| 100 | + int id_num); |
| 101 | +int argb_bridge_write_unlock(dHandle fd); |
| 102 | +int argb_bridge_disconnect(dHandle fd, int type); |
| 103 | +int argb_bridge_get_ic_gen(dHandle fd); |
| 104 | +bool argb_bridge_check_target(dHandle fd); |
| 105 | +int argb_bridge_get_uuid(dHandle fd, uint8_t *uuid); |
| 106 | +int argb_bridge_get_cust_page(dHandle fd, uint8_t *cust_page); |
| 107 | +int argb_bridge_set_cust_page(dHandle fd, uint8_t *cust_page); |
| 108 | +int argb_bridge_get_fw_ver(dHandle fd, struct bridge_fw_version *fw_ver); |
| 109 | +int argb_bridge_get_buf_size(dHandle fd, uint32_t *buf_size); |
| 110 | +int argb_bridge_get_usb_speed(dHandle fd, uint32_t *speed); |
| 111 | +void argb_bridge_get_api_ver(uint32_t *ver_main1, |
| 112 | + uint32_t *ver_main2, |
| 113 | + uint32_t *ver_sub1, |
| 114 | + uint32_t *ver_sub2); |
| 115 | +int argb_bridge_inquiry(dHandle fd, uint8_t *buf, uint32_t buflen); |
| 116 | +int argb_bridge_get_name(dHandle fd, char *name, uint32_t len); |
| 117 | +int argb_bridge_get_vendor_name(dHandle fd, char *name, uint32_t len); |
| 118 | +int argb_bridge_get_product_name(dHandle fd, char *name, uint32_t len); |
| 119 | + |
| 120 | +int argb_bridge_get_debug_level(const char *debug, int *lvl); |
| 121 | +int argb_bridge_set_debug_level(int lvl); |
| 122 | + |
| 123 | +int argb_bridge_report_luns(dHandle fd, |
| 124 | + uint8_t *lun, |
| 125 | + uint32_t *total_luns); |
| 126 | +#else |
| 127 | +int bridge_check_vid_pid(uint16_t vid, |
| 128 | + uint16_t pid, |
| 129 | + struct usb_id *id, |
| 130 | + int id_num); |
| 131 | +int bridge_write_unlock(dHandle fd); |
| 132 | +int bridge_disconnect(dHandle fd, int type); |
| 133 | +int bridge_get_ic_gen(dHandle fd); |
| 134 | +bool bridge_check_target(dHandle fd); |
| 135 | +int bridge_get_uuid(dHandle fd, uint8_t *uuid); |
| 136 | +int bridge_get_cust_page(dHandle fd, uint8_t *cust_page); |
| 137 | +int bridge_set_cust_page(dHandle fd, uint8_t *cust_page); |
| 138 | +int bridge_get_fw_ver(dHandle fd, struct bridge_fw_version *fw_ver); |
| 139 | +int bridge_get_buf_size(dHandle fd, uint32_t *buf_size); |
| 140 | +int bridge_get_usb_speed(dHandle fd, uint32_t *speed); |
| 141 | +void bridge_get_api_ver(uint32_t *ver_main1, |
| 142 | + uint32_t *ver_main2, |
| 143 | + uint32_t *ver_sub1, |
| 144 | + uint32_t *ver_sub2); |
| 145 | +int bridge_inquiry(dHandle fd, uint8_t *buf, uint32_t buflen); |
| 146 | +int bridge_get_name(dHandle fd, char *name, uint32_t len); |
| 147 | +int bridge_get_vendor_name(dHandle fd, char *name, uint32_t len); |
| 148 | +int bridge_get_product_name(dHandle fd, char *name, uint32_t len); |
| 149 | + |
| 150 | +int bridge_get_debug_level(const char *debug, int *lvl); |
| 151 | +int bridge_set_debug_level(int lvl); |
| 152 | + |
| 153 | +int bridge_report_luns(dHandle fd, |
| 154 | + uint8_t *lun, |
| 155 | + uint32_t *total_luns); |
| 156 | +#endif |
| 157 | + |
| 158 | +#ifdef __cplusplus |
| 159 | +} |
| 160 | +#endif |
| 161 | + |
| 162 | +#endif /* _BRIDGE_FUNC_H_ */ |
0 commit comments