blob: 9f6827c38b520494a058f95f73c204b617f5b671 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001TSIF driver serves piece of hardware found in Qualcomm MSM's.
2It deals with Digital Mobile Broadcast.
3
4If you are dealing with Qualcomm MSM that have relevant piece of hardware,
5read on.
6
7There are various Digital Mobile Broadcast (DMB) systems developed to receive
8audio and/or television broadcast programs by Mobile Station Modem (MSM).
9(in simplified words - cellular phone)
10
11All of these systems have similar architecture. They use radio link which
12is different from primary handset link and hence use the additional antenna.
13RF signal from the broadcast tuner goes to de-modulator.
14Regardless of actual tuner and de-modulator, all systems present
15ITU-T H.222.0 (also known as MPEG2) Transport Stream (HTS)
16to the Mobile Station Modem (MSM).
17
18TSIF stands for Transport Stream Interface;
19this is hardware block in MSM that receives HTS signal from the de-modulator.
20
21TSIF use serial interface with de-modulator;
22it buffers data received in internal registers.
23TSIF support data copying from its internal registers to the RAM
24with the Data Mover (DM).
25
26TSIF driver prevent MSM from sleeping while TSIF hardware is active.
27To achieve this, driver holds wake lock.
28
29For access to TSIF data, TSIF driver provides kernel API
30that may be used by another kernel module. As example for API usage,
31simple TSIF chardev adapter provided. It provides character device
32/dev/tsif0. This device may be opened by single process at a time.
33When read, it provides TS stream.
34
35Quick start:
36
37### copy modules to the target
38adb push msm_tsif.ko /data/local/tmp/
39adb push tsif_chrdev.ko /data/local/tmp/
40### Load modules on the target:
41adb shell mount -t debugfs debugfs /sys/kernel/debug
42adb shell insmod /data/local/tmp/msm_tsif.ko
43adb shell insmod /data/local/tmp/tsif_chrdev.ko
44### Run capture:
45adb shell cat /dev/tsif0 > /data/local/tmp/tsif.dump
46
47
48# tests:
49adb shell mount -t debugfs debugfs /sys/kernel/debug
50adb shell rmmod tsif_chrdev
51adb shell rmmod msm_tsif
52adb shell insmod /data/local/tmp/msm_tsif.ko
53adb shell insmod /data/local/tmp/tsif_chrdev.ko
54adb shell 'echo 60 > /sys/devices/platform/msm_tsif.0/time_limit'
55adb shell 'echo "16 * 8" > /sys/devices/platform/msm_tsif.0/buf_config'
56
57# separate xterm:
58watch adb shell cat /sys/devices/platform/msm_tsif.0/stats
59# separate xterm:
60watch adb shell cat /sys/kernel/debug/msm_tsif.0/dma
61# separate xterm:
62adb shell dd if=/dev/tsif0 of=/dev/null
63
64Mode of operation
65
66TSIF hardware have 2 modes of operation: mode1 and mode 2.
67They differ in serial interface signals. Mode used should match demodulator
68chip interface.
69
70In addition to these 2 modes of operation, TSIF driver have pseudo-mode 3
71that means "debug mode" where all operation controlled through debug interfaces.
72Client configure TSIF mode of operation using tsif_set_mode().
73Alternatively, mode of operation may be configured using device attribute file:
74echo 1 > /sys/devices/platform/msm_tsif.0/mode
75
76Time limit
77
78TSIF driver maintains time limit value. Its value corresponds
79to the TSIF_TIME_LIMIT register in TSIF hardware.
80Value in ticks of tsif_ref_clk. If time between the end of previous
81packet and end of current one exceeds this value, timeout status reported
82for the current TSIF packet.
83Client configure TSIF time limit using tsif_set_time_limit().
84Alternatively, time limit may be configured using device attribute file:
85echo 100 > /sys/devices/platform/msm_tsif.0/time_limit
86
87TSIF packet format
88
89TSIF driver uses 192 byte packets; where first 188 packets is HTS packet;
90last 4 bytes consists of :
913 bytes TTS in bytes 188..190; and status byte ib byte 191.
92
93Status byte contains the following fields:
94Bit Name Comment
950 Valid Always set to 1 to indicate valid HTS packet and status.
96 If set to 0, this packet is not valid and should be ignored
971 First packet When set, indicates 1-st packet of a new stream or
98 1-st valid packet after one or more packets were lost.
992 Overflow When set, indicates overflow condition in TSIF hardware;
100 one or more packets were lost. Current packet is valid.
1013 Error Indicates the tsif_error signal status
1024 Null Indicates the tsif_null signal status
1035 Reserved Don't care
1046 Timeout Indicates the 1-st packet after timeout.
105 First packet flag will also be set.
106
107Debug facilities
108
109TSIF driver provides extensive debugging facilities to assist debug both
110TSIF input and TSIF client interfaces. 2 mechanisms used:
111
112Device attribute, accessible through usual /sys hierarchy under
113/sys/devices/platform/msm_tsif.0, provides status and statistics information.
114
115Debugfs exposes more hardware and software details. In order to use debugfs,
116one need to mount it:
117
118adb shell mount -t debugfs debugfs /sys/kernel/debug
119
120When debugfs mounted, TSIF entries may be found under
121/sys/kernel/debug/msm_tsif.0
122
123Register access
124
125All TSIF hardware registers accessible through debugfs.
126$ adb shell ls -l /sys/kernel/debug/msm_tsif.0
127-r--r--r-- root root 0 1980-01-07 16:15 dma
128--w------- root root 0 1980-01-07 16:15 action
129-r--r--r-- root root 0 1980-01-07 16:15 gpios
130-r-------- root root 0 1980-01-07 16:15 data_port
131-r--r--r-- root root 0 1980-01-07 16:15 test_current
132-rw-r--r-- root root 0 1980-01-07 16:15 test_export
133--w------- root root 0 1980-01-07 16:15 test_reset
134-rw-r--r-- root root 0 1980-01-07 16:15 test_mode
135-rw-r--r-- root root 0 1980-01-07 16:15 test_ctl
136-rw-r--r-- root root 0 1980-01-07 16:15 lpbk_data
137-rw-r--r-- root root 0 1980-01-07 16:15 lpbk_flags
138-rw-r--r-- root root 0 1980-01-07 16:15 clk_ref
139-rw-r--r-- root root 0 1980-01-07 16:15 time_limit
140-rw-r--r-- root root 0 1980-01-07 16:15 sts_ctl
141
142TSIF clocks are off when TSIF is not running.
143To control TSIF through low level register access, it should be set to the
144mode 3 ("debug"); in addition, TSIF start/stop actions may be executed using
145debugfs action file:
146
147adb shell 'echo open > /sys/kernel/debug/msm_tsif.0/action'
148
149Possible actions are "open" and "close".
150
151DMA activity
152
153DMA activity may be queried using debugfs dma file:
154
155$ adb shell cat /sys/kernel/debug/msm_tsif.0/dma
156ri 16 | wi 24 | dmwi 40 | [ 24]{ 32} [ 32]{ 40}
157
158This file provides ri/wi/dmwi indexes
159(dmwi is for Data Mover write index - index for first location where
160next DMA may be scheduled);
161and 2 Data Mover transfer tasks, each in [wi] {next_wi} format.
162Here, wi is index DMA is scheduled for; next_wi is where driver's
163wi will be set after DMA completion.
164
165Driver status
166
167Driver status available through stats device attribute:
168
169$ adb shell cat /sys/devices/platform/msm_tsif.0/stats
170Device msm_tsif.0
171Mode = 1
172Time limit = 60
173State running
174Client = bf036f68
175Pkt/Buf = 64
176Pkt/chunk = 8
177--statistics--
178Rx chunks = 3288898
179Overflow = 4606
180Lost sync = 0
181Timeout = 1
182DMA error = 0
183Soft drop = 0
184IFI = 48
185--debug--
186GLBL_CLK_ENA = 0x637dfe23
187ROW_RESET = 0x000008c1
188CLK_HALT_STATEB = 0xde6d80ff
189TV_NS_REG = 0xf8e00b44
190TSIF_NS_REG = 0x00000b40
191
192GPIO
193
194Current GPIO values may be read using debugfs gpio file:
195$ adb shell cat /sys/kernel/debug/msm_tsif.0/gpios
196 tsif_clk: 0
197 tsif_en: 0
198 tsif_data: 0
199 tsif_sync: 0
200
201In normal regime, signals changed too fast for this facility to provide
202change by change log; it should be seen as random time capture.
203When debugging TSIF input connectivity, it may be helpful to run
204
205watch -d adb shell cat /sys/kernel/debug/msm_tsif.0/gpios
206
207to see if input ever changes. If nothing changes at all; it is indication
208for mis-configured input.
209
210Another tip: in case of wire connection between components, one may connect
211TSIF input pin to logical 1 instead of actual signal source,
212to verify this is the pin required.
213
214Inter frame interval
215
216To estimate incoming bit rate, TSIF driver measure average time interval
217between packets. Interval measured in tsif_ref_clk ticks. Actually, TSIF
218gets TTS from 1-st and last packets in chunk and use this time to calculate
219inter frame interval.
220Inter frame interval available as part of device statistics.
221
222Tip: to measure tsif_ref_clk frequency, this approach may be used:
223
224adb shell cat /sys/kernel/debug/msm_tsif.0/clk_ref; sleep 10; adb shell cat /sys/kernel/debug/msm_tsif.0/clk_ref
2250x8db70ec8
2260x8dc6974b
227
228Then, calculate (0x8dc6974b - 0x8db70ec8)/10 that is 101798.7 Hz
229
230
231