]>
Commit | Line | Data |
---|---|---|
443c1228 ST |
1 | /* |
2 | * Driver for the NXP SAA7164 PCIe bridge | |
3 | * | |
63a412ec | 4 | * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com> |
443c1228 ST |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * | |
15 | * GNU General Public License for more details. | |
443c1228 ST |
16 | */ |
17 | ||
18 | /* TODO: Cleanup and shorten the namespace */ | |
19 | ||
20 | /* Some structues are passed directly to/from the firmware and | |
21 | * have strict alignment requirements. This is one of them. | |
22 | */ | |
4d270cfb | 23 | struct tmComResHWDescr { |
443c1228 ST |
24 | u8 bLength; |
25 | u8 bDescriptorType; | |
26 | u8 bDescriptorSubtype; | |
27 | u16 bcdSpecVersion; | |
28 | u32 dwClockFrequency; | |
29 | u32 dwClockUpdateRes; | |
30 | u8 bCapabilities; | |
31 | u32 dwDeviceRegistersLocation; | |
32 | u32 dwHostMemoryRegion; | |
33 | u32 dwHostMemoryRegionSize; | |
34 | u32 dwHostHibernatMemRegion; | |
35 | u32 dwHostHibernatMemRegionSize; | |
4d270cfb | 36 | } __attribute__((packed)); |
443c1228 ST |
37 | |
38 | /* This is DWORD aligned on windows but I can't find the right | |
39 | * gcc syntax to match the binary data from the device. | |
40 | * I've manually padded with Reserved[3] bytes to match the hardware, | |
41 | * but this could break if GCC decies to pack in a different way. | |
42 | */ | |
4d270cfb | 43 | struct tmComResInterfaceDescr { |
443c1228 ST |
44 | u8 bLength; |
45 | u8 bDescriptorType; | |
46 | u8 bDescriptorSubtype; | |
47 | u8 bFlags; | |
48 | u8 bInterfaceType; | |
49 | u8 bInterfaceId; | |
50 | u8 bBaseInterface; | |
51 | u8 bInterruptId; | |
52 | u8 bDebugInterruptId; | |
53 | u8 BARLocation; | |
54 | u8 Reserved[3]; | |
4d270cfb | 55 | }; |
443c1228 | 56 | |
4d270cfb | 57 | struct tmComResBusDescr { |
443c1228 ST |
58 | u64 CommandRing; |
59 | u64 ResponseRing; | |
60 | u32 CommandWrite; | |
61 | u32 CommandRead; | |
62 | u32 ResponseWrite; | |
63 | u32 ResponseRead; | |
4d270cfb | 64 | }; |
443c1228 | 65 | |
4d270cfb | 66 | enum tmBusType { |
443c1228 ST |
67 | NONE = 0, |
68 | TYPE_BUS_PCI = 1, | |
69 | TYPE_BUS_PCIe = 2, | |
70 | TYPE_BUS_USB = 3, | |
71 | TYPE_BUS_I2C = 4 | |
4d270cfb | 72 | }; |
443c1228 | 73 | |
4d270cfb MCC |
74 | struct tmComResBusInfo { |
75 | enum tmBusType Type; | |
443c1228 | 76 | u16 m_wMaxReqSize; |
065e1477 | 77 | u8 __iomem *m_pdwSetRing; |
443c1228 | 78 | u32 m_dwSizeSetRing; |
065e1477 | 79 | u8 __iomem *m_pdwGetRing; |
443c1228 | 80 | u32 m_dwSizeGetRing; |
60665829 ST |
81 | u32 m_dwSetWritePos; |
82 | u32 m_dwSetReadPos; | |
83 | u32 m_dwGetWritePos; | |
84 | u32 m_dwGetReadPos; | |
443c1228 ST |
85 | |
86 | /* All access is protected */ | |
87 | struct mutex lock; | |
88 | ||
4d270cfb | 89 | }; |
443c1228 | 90 | |
4d270cfb | 91 | struct tmComResInfo { |
443c1228 ST |
92 | u8 id; |
93 | u8 flags; | |
94 | u16 size; | |
95 | u32 command; | |
96 | u16 controlselector; | |
97 | u8 seqno; | |
4d270cfb | 98 | } __attribute__((packed)); |
443c1228 | 99 | |
4d270cfb | 100 | enum tmComResCmd { |
443c1228 ST |
101 | SET_CUR = 0x01, |
102 | GET_CUR = 0x81, | |
103 | GET_MIN = 0x82, | |
104 | GET_MAX = 0x83, | |
105 | GET_RES = 0x84, | |
106 | GET_LEN = 0x85, | |
107 | GET_INFO = 0x86, | |
108 | GET_DEF = 0x87 | |
4d270cfb | 109 | }; |
443c1228 ST |
110 | |
111 | struct cmd { | |
112 | u8 seqno; | |
113 | u32 inuse; | |
114 | u32 timeout; | |
115 | u32 signalled; | |
116 | struct mutex lock; | |
117 | wait_queue_head_t wait; | |
118 | }; | |
119 | ||
4d270cfb | 120 | struct tmDescriptor { |
443c1228 ST |
121 | u32 pathid; |
122 | u32 size; | |
123 | void *descriptor; | |
4d270cfb | 124 | }; |
443c1228 | 125 | |
4d270cfb | 126 | struct tmComResDescrHeader { |
443c1228 ST |
127 | u8 len; |
128 | u8 type; | |
129 | u8 subtype; | |
130 | u8 unitid; | |
4d270cfb | 131 | } __attribute__((packed)); |
443c1228 | 132 | |
4d270cfb | 133 | struct tmComResExtDevDescrHeader { |
443c1228 ST |
134 | u8 len; |
135 | u8 type; | |
136 | u8 subtype; | |
137 | u8 unitid; | |
138 | u32 devicetype; | |
139 | u16 deviceid; | |
140 | u32 numgpiopins; | |
141 | u8 numgpiogroups; | |
142 | u8 controlsize; | |
4d270cfb | 143 | } __attribute__((packed)); |
443c1228 | 144 | |
4d270cfb | 145 | struct tmComResGPIO { |
443c1228 ST |
146 | u32 pin; |
147 | u8 state; | |
4d270cfb | 148 | } __attribute__((packed)); |
443c1228 | 149 | |
4d270cfb | 150 | struct tmComResPathDescrHeader { |
443c1228 ST |
151 | u8 len; |
152 | u8 type; | |
153 | u8 subtype; | |
154 | u8 pathid; | |
4d270cfb | 155 | } __attribute__((packed)); |
443c1228 ST |
156 | |
157 | /* terminaltype */ | |
4d270cfb | 158 | enum tmComResTermType { |
443c1228 ST |
159 | ITT_ANTENNA = 0x0203, |
160 | LINE_CONNECTOR = 0x0603, | |
161 | SPDIF_CONNECTOR = 0x0605, | |
162 | COMPOSITE_CONNECTOR = 0x0401, | |
163 | SVIDEO_CONNECTOR = 0x0402, | |
164 | COMPONENT_CONNECTOR = 0x0403, | |
165 | STANDARD_DMA = 0xF101 | |
4d270cfb | 166 | }; |
443c1228 | 167 | |
4d270cfb | 168 | struct tmComResAntTermDescrHeader { |
443c1228 ST |
169 | u8 len; |
170 | u8 type; | |
171 | u8 subtype; | |
172 | u8 terminalid; | |
173 | u16 terminaltype; | |
174 | u8 assocterminal; | |
175 | u8 iterminal; | |
176 | u8 controlsize; | |
4d270cfb | 177 | } __attribute__((packed)); |
443c1228 | 178 | |
4d270cfb | 179 | struct tmComResTunerDescrHeader { |
443c1228 ST |
180 | u8 len; |
181 | u8 type; | |
182 | u8 subtype; | |
183 | u8 unitid; | |
184 | u8 sourceid; | |
185 | u8 iunit; | |
186 | u32 tuningstandards; | |
187 | u8 controlsize; | |
188 | u32 controls; | |
4d270cfb | 189 | } __attribute__((packed)); |
443c1228 | 190 | |
4d270cfb | 191 | enum tmBufferFlag { |
443c1228 ST |
192 | /* the buffer does not contain any valid data */ |
193 | TM_BUFFER_FLAG_EMPTY, | |
194 | ||
195 | /* the buffer is filled with valid data */ | |
196 | TM_BUFFER_FLAG_DONE, | |
197 | ||
198 | /* the buffer is the dummy buffer - TODO??? */ | |
199 | TM_BUFFER_FLAG_DUMMY_BUFFER | |
4d270cfb | 200 | }; |
443c1228 | 201 | |
4d270cfb | 202 | struct tmBuffer { |
443c1228 ST |
203 | u64 *pagetablevirt; |
204 | u64 pagetablephys; | |
205 | u16 offset; | |
206 | u8 *context; | |
207 | u64 timestamp; | |
4d270cfb | 208 | enum tmBufferFlag BufferFlag; |
443c1228 ST |
209 | u32 lostbuffers; |
210 | u32 validbuffers; | |
211 | u64 *dummypagevirt; | |
212 | u64 dummypagephys; | |
213 | u64 *addressvirt; | |
4d270cfb | 214 | }; |
443c1228 | 215 | |
4d270cfb | 216 | struct tmHWStreamParameters { |
443c1228 ST |
217 | u32 bitspersample; |
218 | u32 samplesperline; | |
219 | u32 numberoflines; | |
220 | u32 pitch; | |
221 | u32 linethreshold; | |
222 | u64 **pagetablelistvirt; | |
223 | u64 *pagetablelistphys; | |
224 | u32 numpagetables; | |
225 | u32 numpagetableentries; | |
4d270cfb | 226 | }; |
443c1228 | 227 | |
4d270cfb MCC |
228 | struct tmStreamParameters { |
229 | struct tmHWStreamParameters HWStreamParameters; | |
443c1228 ST |
230 | u64 qwDummyPageTablePhys; |
231 | u64 *pDummyPageTableVirt; | |
4d270cfb | 232 | }; |
443c1228 | 233 | |
4d270cfb | 234 | struct tmComResDMATermDescrHeader { |
443c1228 ST |
235 | u8 len; |
236 | u8 type; | |
237 | u8 subtyle; | |
238 | u8 unitid; | |
239 | u16 terminaltype; | |
240 | u8 assocterminal; | |
241 | u8 sourceid; | |
242 | u8 iterminal; | |
243 | u32 BARLocation; | |
244 | u8 flags; | |
245 | u8 interruptid; | |
246 | u8 buffercount; | |
247 | u8 metadatasize; | |
248 | u8 numformats; | |
249 | u8 controlsize; | |
4d270cfb | 250 | } __attribute__((packed)); |
443c1228 ST |
251 | |
252 | /* | |
253 | * | |
254 | * Description: | |
255 | * This is the transport stream format header. | |
256 | * | |
257 | * Settings: | |
258 | * bLength - The size of this descriptor in bytes. | |
259 | * bDescriptorType - CS_INTERFACE. | |
260 | * bDescriptorSubtype - VS_FORMAT_MPEG2TS descriptor subtype. | |
261 | * bFormatIndex - A non-zero constant that uniquely identifies the | |
262 | * format. | |
263 | * bDataOffset - Offset to TSP packet within MPEG-2 TS transport | |
264 | * stride, in bytes. | |
265 | * bPacketLength - Length of TSP packet, in bytes (typically 188). | |
266 | * bStrideLength - Length of MPEG-2 TS transport stride. | |
267 | * guidStrideFormat - A Globally Unique Identifier indicating the | |
268 | * format of the stride data (if any). Set to zeros | |
269 | * if there is no Stride Data, or if the Stride | |
270 | * Data is to be ignored by the application. | |
271 | * | |
272 | */ | |
4d270cfb | 273 | struct tmComResTSFormatDescrHeader { |
443c1228 ST |
274 | u8 len; |
275 | u8 type; | |
276 | u8 subtype; | |
277 | u8 bFormatIndex; | |
278 | u8 bDataOffset; | |
279 | u8 bPacketLength; | |
280 | u8 bStrideLength; | |
281 | u8 guidStrideFormat[16]; | |
4d270cfb | 282 | } __attribute__((packed)); |
443c1228 | 283 | |
335961ca ST |
284 | /* Encoder related structures */ |
285 | ||
286 | /* A/V Mux Selector */ | |
4d270cfb | 287 | struct tmComResSelDescrHeader { |
335961ca ST |
288 | u8 len; |
289 | u8 type; | |
290 | u8 subtype; | |
291 | u8 unitid; | |
292 | u8 nrinpins; | |
293 | u8 sourceid; | |
4d270cfb | 294 | } __attribute__((packed)); |
335961ca ST |
295 | |
296 | /* A/V Audio processor definitions */ | |
4d270cfb | 297 | struct tmComResProcDescrHeader { |
335961ca ST |
298 | u8 len; |
299 | u8 type; | |
300 | u8 subtype; | |
301 | u8 unitid; | |
302 | u8 sourceid; | |
303 | u16 wreserved; | |
304 | u8 controlsize; | |
4d270cfb | 305 | } __attribute__((packed)); |
335961ca ST |
306 | |
307 | /* Video bitrate control message */ | |
2600d71c ST |
308 | #define EU_VIDEO_BIT_RATE_MODE_CONSTANT (0) |
309 | #define EU_VIDEO_BIT_RATE_MODE_VARIABLE_AVERAGE (1) | |
310 | #define EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK (2) | |
4d270cfb | 311 | struct tmComResEncVideoBitRate { |
335961ca ST |
312 | u8 ucVideoBitRateMode; |
313 | u32 dwVideoBitRate; | |
314 | u32 dwVideoBitRatePeak; | |
4d270cfb | 315 | } __attribute__((packed)); |
335961ca ST |
316 | |
317 | /* Video Encoder Aspect Ratio message */ | |
4d270cfb | 318 | struct tmComResEncVideoInputAspectRatio { |
335961ca ST |
319 | u8 width; |
320 | u8 height; | |
4d270cfb | 321 | } __attribute__((packed)); |
335961ca | 322 | |
eafea210 ST |
323 | /* Video Encoder GOP IBP message */ |
324 | /* 1. IPPPPPPPPPPPPPP */ | |
325 | /* 2. IBPBPBPBPBPBPBP */ | |
326 | /* 3. IBBPBBPBBPBBP */ | |
c7e242ba | 327 | #define SAA7164_ENCODER_DEFAULT_GOP_DIST (1) |
eafea210 | 328 | #define SAA7164_ENCODER_DEFAULT_GOP_SIZE (15) |
4d270cfb | 329 | struct tmComResEncVideoGopStructure { |
eafea210 ST |
330 | u8 ucGOPSize; /* GOP Size 12, 15 */ |
331 | u8 ucRefFrameDist; /* Reference Frame Distance */ | |
4d270cfb | 332 | } __attribute__((packed)); |
eafea210 | 333 | |
335961ca | 334 | /* Encoder processor definition */ |
4d270cfb | 335 | struct tmComResEncoderDescrHeader { |
335961ca ST |
336 | u8 len; |
337 | u8 type; | |
338 | u8 subtype; | |
339 | u8 unitid; | |
340 | u8 vsourceid; | |
341 | u8 asourceid; | |
342 | u8 iunit; | |
343 | u32 dwmControlCap; | |
344 | u32 dwmProfileCap; | |
345 | u32 dwmVidFormatCap; | |
346 | u8 bmVidBitrateCap; | |
347 | u16 wmVidResolutionsCap; | |
348 | u16 wmVidFrmRateCap; | |
349 | u32 dwmAudFormatCap; | |
350 | u8 bmAudBitrateCap; | |
4d270cfb | 351 | } __attribute__((packed)); |
335961ca ST |
352 | |
353 | /* Audio processor definition */ | |
4d270cfb | 354 | struct tmComResAFeatureDescrHeader { |
335961ca ST |
355 | u8 len; |
356 | u8 type; | |
357 | u8 subtype; | |
358 | u8 unitid; | |
359 | u8 sourceid; | |
360 | u8 controlsize; | |
4d270cfb | 361 | } __attribute__((packed)); |
335961ca ST |
362 | |
363 | /* Audio control messages */ | |
4d270cfb | 364 | struct tmComResAudioDefaults { |
335961ca ST |
365 | u8 ucDecoderLevel; |
366 | u8 ucDecoderFM_Level; | |
367 | u8 ucMonoLevel; | |
368 | u8 ucNICAM_Level; | |
369 | u8 ucSAP_Level; | |
370 | u8 ucADC_Level; | |
4d270cfb | 371 | } __attribute__((packed)); |
335961ca ST |
372 | |
373 | /* Audio bitrate control message */ | |
4d270cfb | 374 | struct tmComResEncAudioBitRate { |
335961ca ST |
375 | u8 ucAudioBitRateMode; |
376 | u32 dwAudioBitRate; | |
377 | u32 dwAudioBitRatePeak; | |
4d270cfb | 378 | } __attribute__((packed)); |
335961ca ST |
379 | |
380 | /* Tuner / AV Decoder messages */ | |
4d270cfb | 381 | struct tmComResTunerStandard { |
335961ca ST |
382 | u8 std; |
383 | u32 country; | |
4d270cfb | 384 | } __attribute__((packed)); |
335961ca | 385 | |
4d270cfb | 386 | struct tmComResTunerStandardAuto { |
335961ca | 387 | u8 mode; |
4d270cfb | 388 | } __attribute__((packed)); |
335961ca ST |
389 | |
390 | /* EEPROM definition for PS stream types */ | |
4d270cfb | 391 | struct tmComResPSFormatDescrHeader { |
335961ca ST |
392 | u8 len; |
393 | u8 type; | |
394 | u8 subtype; | |
395 | u8 bFormatIndex; | |
396 | u16 wPacketLength; | |
397 | u16 wPackLength; | |
398 | u8 bPackDataType; | |
4d270cfb | 399 | } __attribute__((packed)); |
335961ca | 400 | |
e8ce2f21 | 401 | /* VBI control structure */ |
4d270cfb | 402 | struct tmComResVBIFormatDescrHeader { |
e8ce2f21 ST |
403 | u8 len; |
404 | u8 type; | |
405 | u8 subtype; /* VS_FORMAT_VBI */ | |
406 | u8 bFormatIndex; | |
407 | u32 VideoStandard; /* See KS_AnalogVideoStandard, NTSC = 1 */ | |
408 | u8 StartLine; /* NTSC Start = 10 */ | |
409 | u8 EndLine; /* NTSC = 21 */ | |
410 | u8 FieldRate; /* 60 for NTSC */ | |
25985edc | 411 | u8 bNumLines; /* Unused - scheduled for removal */ |
4d270cfb | 412 | } __attribute__((packed)); |
e8ce2f21 | 413 | |
4d270cfb | 414 | struct tmComResProbeCommit { |
e8ce2f21 ST |
415 | u16 bmHint; |
416 | u8 bFormatIndex; | |
417 | u8 bFrameIndex; | |
4d270cfb | 418 | } __attribute__((packed)); |
e48836b8 | 419 | |
4d270cfb | 420 | struct tmComResDebugSetLevel { |
e48836b8 | 421 | u32 dwDebugLevel; |
4d270cfb | 422 | } __attribute__((packed)); |
e48836b8 | 423 | |
4d270cfb | 424 | struct tmComResDebugGetData { |
e48836b8 ST |
425 | u32 dwResult; |
426 | u8 ucDebugData[256]; | |
4d270cfb | 427 | } __attribute__((packed)); |
e48836b8 | 428 | |
4d270cfb | 429 | struct tmFwInfoStruct { |
1247ff5c ST |
430 | u32 status; |
431 | u32 mode; | |
432 | u32 devicespec; | |
433 | u32 deviceinst; | |
434 | u32 CPULoad; | |
435 | u32 RemainHeap; | |
436 | u32 CPUClock; | |
437 | u32 RAMSpeed; | |
4d270cfb | 438 | } __attribute__((packed)); |