blob: 7a9e569488587df083d0c659ad960362bff0c853 [file] [log] [blame]
Udaya Bhaskara Reddy Mallavarapu7b868342017-06-12 15:07:28 +05301/* 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
16struct 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 Mallavarapudcd97502017-08-08 17:18:35 +053019 dma_addr_t dma_base; /* DMA address of the actual data */
Udaya Bhaskara Reddy Mallavarapu7b868342017-06-12 15:07:28 +053020 u32 size; /* size of buffer in bytes */
21 int id; /* unique identifier */
22 void *user; /* user-defined data */
23};
24
25enum tspp_key_parity {
26 TSPP_KEY_PARITY_EVEN,
27 TSPP_KEY_PARITY_ODD
28};
29
30struct tspp_key {
31 enum tspp_key_parity parity;
32 int lsb;
33 int msb;
34};
35
36enum tspp_source {
37 TSPP_SOURCE_TSIF0,
38 TSPP_SOURCE_TSIF1,
39 TSPP_SOURCE_MEM,
40 TSPP_SOURCE_NONE = -1
41};
42
43enum tspp_mode {
44 TSPP_MODE_DISABLED,
45 TSPP_MODE_PES,
46 TSPP_MODE_RAW,
47 TSPP_MODE_RAW_NO_SUFFIX
48};
49
50enum 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
56struct 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
65struct 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
74enum 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 Mallavarapudcd97502017-08-08 17:18:35 +053079struct 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 Mallavarapu7b868342017-06-12 15:07:28 +053087typedef void (tspp_notifier)(int channel_id, void *user);
88typedef void* (tspp_allocator)(int channel_id, u32 size,
Udaya Bhaskara Reddy Mallavarapudcd97502017-08-08 17:18:35 +053089 phys_addr_t *phys_base, dma_addr_t *dma_base, void *user);
Udaya Bhaskara Reddy Mallavarapu7b868342017-06-12 15:07:28 +053090typedef void (tspp_memfree)(int channel_id, u32 size,
91 void *virt_base, phys_addr_t phys_base, void *user);
92
93/* Kernel API functions */
94int tspp_open_stream(u32 dev, u32 channel_id,
95 struct tspp_select_source *source);
96int tspp_close_stream(u32 dev, u32 channel_id);
97int tspp_open_channel(u32 dev, u32 channel_id);
98int tspp_close_channel(u32 dev, u32 channel_id);
99int tspp_get_ref_clk_counter(u32 dev,
100 enum tspp_source source, u32 *tcr_counter);
101int tspp_add_filter(u32 dev, u32 channel_id, struct tspp_filter *filter);
102int tspp_remove_filter(u32 dev, u32 channel_id, struct tspp_filter *filter);
103int tspp_set_key(u32 dev, u32 channel_id, struct tspp_key *key);
104int tspp_register_notification(u32 dev, u32 channel_id, tspp_notifier *notify,
105 void *data, u32 timer_ms);
106int tspp_unregister_notification(u32 dev, u32 channel_id);
107const struct tspp_data_descriptor *tspp_get_buffer(u32 dev, u32 channel_id);
108int tspp_release_buffer(u32 dev, u32 channel_id, u32 descriptor_id);
109int 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
113int tspp_get_tts_source(u32 dev, int *tts_source);
114int tspp_get_lpass_time_counter(u32 dev, enum tspp_source source,
115 u64 *lpass_time_counter);
116
Udaya Bhaskara Reddy Mallavarapudcd97502017-08-08 17:18:35 +0530117int tspp_attach_ion_dma_buff(u32 dev,
118 struct tspp_ion_dma_buf_info *ion_dma_buf);
119
120int tspp_detach_ion_dma_buff(u32 dev,
121 struct tspp_ion_dma_buf_info *ion_dma_buf);
Udaya Bhaskara Reddy Mallavarapu7b868342017-06-12 15:07:28 +0530122#endif /* _MSM_TSPP_H_ */