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