Udaya Bhaskara Reddy Mallavarapu | 7b86834 | 2017-06-12 15:07:28 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012-2017, 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 | |
| 13 | #ifndef _MSM_TSPP_H_ |
| 14 | #define _MSM_TSPP_H_ |
| 15 | |
| 16 | struct tspp_data_descriptor { |
| 17 | void *virt_base; /* logical address of the actual data */ |
| 18 | phys_addr_t phys_base; /* physical address of the actual data */ |
Udaya Bhaskara Reddy Mallavarapu | dcd9750 | 2017-08-08 17:18:35 +0530 | [diff] [blame] | 19 | dma_addr_t dma_base; /* DMA address of the actual data */ |
Udaya Bhaskara Reddy Mallavarapu | 7b86834 | 2017-06-12 15:07:28 +0530 | [diff] [blame] | 20 | u32 size; /* size of buffer in bytes */ |
| 21 | int id; /* unique identifier */ |
| 22 | void *user; /* user-defined data */ |
| 23 | }; |
| 24 | |
| 25 | enum tspp_key_parity { |
| 26 | TSPP_KEY_PARITY_EVEN, |
| 27 | TSPP_KEY_PARITY_ODD |
| 28 | }; |
| 29 | |
| 30 | struct tspp_key { |
| 31 | enum tspp_key_parity parity; |
| 32 | int lsb; |
| 33 | int msb; |
| 34 | }; |
| 35 | |
| 36 | enum tspp_source { |
| 37 | TSPP_SOURCE_TSIF0, |
| 38 | TSPP_SOURCE_TSIF1, |
| 39 | TSPP_SOURCE_MEM, |
| 40 | TSPP_SOURCE_NONE = -1 |
| 41 | }; |
| 42 | |
| 43 | enum tspp_mode { |
| 44 | TSPP_MODE_DISABLED, |
| 45 | TSPP_MODE_PES, |
| 46 | TSPP_MODE_RAW, |
| 47 | TSPP_MODE_RAW_NO_SUFFIX |
| 48 | }; |
| 49 | |
| 50 | enum tspp_tsif_mode { |
| 51 | TSPP_TSIF_MODE_LOOPBACK, /* loopback mode */ |
| 52 | TSPP_TSIF_MODE_1, /* without sync */ |
| 53 | TSPP_TSIF_MODE_2 /* with sync signal */ |
| 54 | }; |
| 55 | |
| 56 | struct tspp_filter { |
| 57 | int pid; |
| 58 | int mask; |
| 59 | enum tspp_mode mode; |
| 60 | unsigned int priority; /* 0 - 15 */ |
| 61 | int decrypt; |
| 62 | enum tspp_source source; |
| 63 | }; |
| 64 | |
| 65 | struct tspp_select_source { |
| 66 | enum tspp_source source; |
| 67 | enum tspp_tsif_mode mode; |
| 68 | int clk_inverse; |
| 69 | int data_inverse; |
| 70 | int sync_inverse; |
| 71 | int enable_inverse; |
| 72 | }; |
| 73 | |
| 74 | enum tsif_tts_source { |
| 75 | TSIF_TTS_TCR = 0, /* Time stamps from TCR counter */ |
| 76 | TSIF_TTS_LPASS_TIMER /* Time stamps from AV/Qtimer Timer */ |
| 77 | }; |
| 78 | |
Udaya Bhaskara Reddy Mallavarapu | dcd9750 | 2017-08-08 17:18:35 +0530 | [diff] [blame] | 79 | struct tspp_ion_dma_buf_info { |
| 80 | struct dma_buf *dbuf; |
| 81 | struct dma_buf_attachment *attach; |
| 82 | struct sg_table *table; |
| 83 | bool smmu_map; |
| 84 | dma_addr_t dma_map_base; |
| 85 | }; |
| 86 | |
Udaya Bhaskara Reddy Mallavarapu | 7b86834 | 2017-06-12 15:07:28 +0530 | [diff] [blame] | 87 | typedef void (tspp_notifier)(int channel_id, void *user); |
| 88 | typedef void* (tspp_allocator)(int channel_id, u32 size, |
Udaya Bhaskara Reddy Mallavarapu | dcd9750 | 2017-08-08 17:18:35 +0530 | [diff] [blame] | 89 | phys_addr_t *phys_base, dma_addr_t *dma_base, void *user); |
Udaya Bhaskara Reddy Mallavarapu | 7b86834 | 2017-06-12 15:07:28 +0530 | [diff] [blame] | 90 | typedef void (tspp_memfree)(int channel_id, u32 size, |
| 91 | void *virt_base, phys_addr_t phys_base, void *user); |
| 92 | |
| 93 | /* Kernel API functions */ |
| 94 | int tspp_open_stream(u32 dev, u32 channel_id, |
| 95 | struct tspp_select_source *source); |
| 96 | int tspp_close_stream(u32 dev, u32 channel_id); |
| 97 | int tspp_open_channel(u32 dev, u32 channel_id); |
| 98 | int tspp_close_channel(u32 dev, u32 channel_id); |
| 99 | int tspp_get_ref_clk_counter(u32 dev, |
| 100 | enum tspp_source source, u32 *tcr_counter); |
| 101 | int tspp_add_filter(u32 dev, u32 channel_id, struct tspp_filter *filter); |
| 102 | int tspp_remove_filter(u32 dev, u32 channel_id, struct tspp_filter *filter); |
| 103 | int tspp_set_key(u32 dev, u32 channel_id, struct tspp_key *key); |
| 104 | int tspp_register_notification(u32 dev, u32 channel_id, tspp_notifier *notify, |
| 105 | void *data, u32 timer_ms); |
| 106 | int tspp_unregister_notification(u32 dev, u32 channel_id); |
| 107 | const struct tspp_data_descriptor *tspp_get_buffer(u32 dev, u32 channel_id); |
| 108 | int tspp_release_buffer(u32 dev, u32 channel_id, u32 descriptor_id); |
| 109 | int tspp_allocate_buffers(u32 dev, u32 channel_id, u32 count, |
| 110 | u32 size, u32 int_freq, tspp_allocator *alloc, |
| 111 | tspp_memfree *memfree, void *user); |
| 112 | |
| 113 | int tspp_get_tts_source(u32 dev, int *tts_source); |
| 114 | int tspp_get_lpass_time_counter(u32 dev, enum tspp_source source, |
| 115 | u64 *lpass_time_counter); |
| 116 | |
Udaya Bhaskara Reddy Mallavarapu | dcd9750 | 2017-08-08 17:18:35 +0530 | [diff] [blame] | 117 | int tspp_attach_ion_dma_buff(u32 dev, |
| 118 | struct tspp_ion_dma_buf_info *ion_dma_buf); |
| 119 | |
| 120 | int tspp_detach_ion_dma_buff(u32 dev, |
| 121 | struct tspp_ion_dma_buf_info *ion_dma_buf); |
Udaya Bhaskara Reddy Mallavarapu | 7b86834 | 2017-06-12 15:07:28 +0530 | [diff] [blame] | 122 | #endif /* _MSM_TSPP_H_ */ |