Sreelakshmi Gownipalli | cb8893d | 2016-10-19 16:02:34 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | #ifndef DIAG_MUX_H |
| 13 | #define DIAG_MUX_H |
| 14 | #include "diagchar.h" |
| 15 | |
| 16 | struct diag_mux_state_t { |
| 17 | struct diag_logger_t *logger; |
| 18 | struct diag_logger_t *usb_ptr; |
| 19 | struct diag_logger_t *md_ptr; |
| 20 | unsigned int mux_mask; |
| 21 | unsigned int mode; |
| 22 | }; |
| 23 | |
| 24 | struct diag_mux_ops { |
| 25 | int (*open)(int id, int mode); |
| 26 | int (*close)(int id, int mode); |
| 27 | int (*read_done)(unsigned char *buf, int len, int id); |
| 28 | int (*write_done)(unsigned char *buf, int len, int buf_ctx, |
| 29 | int id); |
| 30 | }; |
| 31 | |
| 32 | #define DIAG_USB_MODE 0 |
| 33 | #define DIAG_MEMORY_DEVICE_MODE 1 |
| 34 | #define DIAG_NO_LOGGING_MODE 2 |
| 35 | #define DIAG_MULTI_MODE 3 |
| 36 | |
| 37 | #define DIAG_MUX_LOCAL 0 |
| 38 | #define DIAG_MUX_LOCAL_LAST 1 |
| 39 | #define DIAG_MUX_BRIDGE_BASE DIAG_MUX_LOCAL_LAST |
| 40 | #define DIAG_MUX_MDM (DIAG_MUX_BRIDGE_BASE) |
| 41 | #define DIAG_MUX_MDM2 (DIAG_MUX_BRIDGE_BASE + 1) |
| 42 | #define DIAG_MUX_SMUX (DIAG_MUX_BRIDGE_BASE + 2) |
| 43 | #define DIAG_MUX_BRIDGE_LAST (DIAG_MUX_BRIDGE_BASE + 3) |
| 44 | |
| 45 | #ifndef CONFIG_DIAGFWD_BRIDGE_CODE |
| 46 | #define NUM_MUX_PROC DIAG_MUX_LOCAL_LAST |
| 47 | #else |
| 48 | #define NUM_MUX_PROC DIAG_MUX_BRIDGE_LAST |
| 49 | #endif |
| 50 | |
| 51 | struct diag_logger_ops { |
| 52 | void (*open)(void); |
| 53 | void (*close)(void); |
| 54 | int (*queue_read)(int id); |
| 55 | int (*write)(int id, unsigned char *buf, int len, int ctx); |
| 56 | int (*close_peripheral)(int id, uint8_t peripheral); |
| 57 | }; |
| 58 | |
| 59 | struct diag_logger_t { |
| 60 | int mode; |
| 61 | struct diag_mux_ops *ops[NUM_MUX_PROC]; |
| 62 | struct diag_logger_ops *log_ops; |
| 63 | }; |
| 64 | |
| 65 | extern struct diag_mux_state_t *diag_mux; |
| 66 | |
| 67 | int diag_mux_init(void); |
| 68 | void diag_mux_exit(void); |
| 69 | int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops); |
| 70 | int diag_mux_queue_read(int proc); |
| 71 | int diag_mux_write(int proc, unsigned char *buf, int len, int ctx); |
| 72 | int diag_mux_close_peripheral(int proc, uint8_t peripheral); |
| 73 | int diag_mux_open_all(struct diag_logger_t *logger); |
| 74 | int diag_mux_close_all(void); |
| 75 | int diag_mux_switch_logging(int *new_mode, int *peripheral_mask); |
| 76 | #endif |