Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  Driver for the NXP SAA7164 PCIe bridge
0004  *
0005  *  Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
0006  */
0007 
0008 /* TODO: Cleanup and shorten the namespace */
0009 
0010 /* Some structures are passed directly to/from the firmware and
0011  * have strict alignment requirements. This is one of them.
0012  */
0013 struct tmComResHWDescr {
0014     u8  bLength;
0015     u8  bDescriptorType;
0016     u8  bDescriptorSubtype;
0017     u16 bcdSpecVersion;
0018     u32 dwClockFrequency;
0019     u32 dwClockUpdateRes;
0020     u8  bCapabilities;
0021     u32 dwDeviceRegistersLocation;
0022     u32 dwHostMemoryRegion;
0023     u32 dwHostMemoryRegionSize;
0024     u32 dwHostHibernatMemRegion;
0025     u32 dwHostHibernatMemRegionSize;
0026 } __attribute__((packed));
0027 
0028 /* This is DWORD aligned on windows but I can't find the right
0029  * gcc syntax to match the binary data from the device.
0030  * I've manually padded with Reserved[3] bytes to match the hardware,
0031  * but this could break if GCC decides to pack in a different way.
0032  */
0033 struct tmComResInterfaceDescr {
0034     u8  bLength;
0035     u8  bDescriptorType;
0036     u8  bDescriptorSubtype;
0037     u8  bFlags;
0038     u8  bInterfaceType;
0039     u8  bInterfaceId;
0040     u8  bBaseInterface;
0041     u8  bInterruptId;
0042     u8  bDebugInterruptId;
0043     u8  BARLocation;
0044     u8  Reserved[3];
0045 };
0046 
0047 struct tmComResBusDescr {
0048     u64 CommandRing;
0049     u64 ResponseRing;
0050     u32 CommandWrite;
0051     u32 CommandRead;
0052     u32 ResponseWrite;
0053     u32 ResponseRead;
0054 };
0055 
0056 enum tmBusType {
0057     NONE        = 0,
0058     TYPE_BUS_PCI    = 1,
0059     TYPE_BUS_PCIe   = 2,
0060     TYPE_BUS_USB    = 3,
0061     TYPE_BUS_I2C    = 4
0062 };
0063 
0064 struct tmComResBusInfo {
0065     enum tmBusType Type;
0066     u16 m_wMaxReqSize;
0067     u8 __iomem *m_pdwSetRing;
0068     u32 m_dwSizeSetRing;
0069     u8 __iomem *m_pdwGetRing;
0070     u32 m_dwSizeGetRing;
0071     u32 m_dwSetWritePos;
0072     u32 m_dwSetReadPos;
0073     u32 m_dwGetWritePos;
0074     u32 m_dwGetReadPos;
0075 
0076     /* All access is protected */
0077     struct mutex lock;
0078 
0079 };
0080 
0081 struct tmComResInfo {
0082     u8  id;
0083     u8  flags;
0084     u16 size;
0085     u32 command;
0086     u16 controlselector;
0087     u8  seqno;
0088 } __attribute__((packed));
0089 
0090 enum tmComResCmd {
0091     SET_CUR  = 0x01,
0092     GET_CUR  = 0x81,
0093     GET_MIN  = 0x82,
0094     GET_MAX  = 0x83,
0095     GET_RES  = 0x84,
0096     GET_LEN  = 0x85,
0097     GET_INFO = 0x86,
0098     GET_DEF  = 0x87
0099 };
0100 
0101 struct cmd {
0102     u8 seqno;
0103     u32 inuse;
0104     u32 timeout;
0105     u32 signalled;
0106     struct mutex lock;
0107     wait_queue_head_t wait;
0108 };
0109 
0110 struct tmDescriptor {
0111     u32 pathid;
0112     u32 size;
0113     void    *descriptor;
0114 };
0115 
0116 struct tmComResDescrHeader {
0117     u8  len;
0118     u8  type;
0119     u8  subtype;
0120     u8  unitid;
0121 } __attribute__((packed));
0122 
0123 struct tmComResExtDevDescrHeader {
0124     u8  len;
0125     u8  type;
0126     u8  subtype;
0127     u8  unitid;
0128     u32 devicetype;
0129     u16 deviceid;
0130     u32 numgpiopins;
0131     u8  numgpiogroups;
0132     u8  controlsize;
0133 } __attribute__((packed));
0134 
0135 struct tmComResGPIO {
0136     u32 pin;
0137     u8  state;
0138 } __attribute__((packed));
0139 
0140 struct tmComResPathDescrHeader {
0141     u8  len;
0142     u8  type;
0143     u8  subtype;
0144     u8  pathid;
0145 } __attribute__((packed));
0146 
0147 /* terminaltype */
0148 enum tmComResTermType {
0149     ITT_ANTENNA              = 0x0203,
0150     LINE_CONNECTOR           = 0x0603,
0151     SPDIF_CONNECTOR          = 0x0605,
0152     COMPOSITE_CONNECTOR      = 0x0401,
0153     SVIDEO_CONNECTOR         = 0x0402,
0154     COMPONENT_CONNECTOR      = 0x0403,
0155     STANDARD_DMA             = 0xF101
0156 };
0157 
0158 struct tmComResAntTermDescrHeader {
0159     u8  len;
0160     u8  type;
0161     u8  subtype;
0162     u8  terminalid;
0163     u16 terminaltype;
0164     u8  assocterminal;
0165     u8  iterminal;
0166     u8  controlsize;
0167 } __attribute__((packed));
0168 
0169 struct tmComResTunerDescrHeader {
0170     u8  len;
0171     u8  type;
0172     u8  subtype;
0173     u8  unitid;
0174     u8  sourceid;
0175     u8  iunit;
0176     u32 tuningstandards;
0177     u8  controlsize;
0178     u32 controls;
0179 } __attribute__((packed));
0180 
0181 enum tmBufferFlag {
0182     /* the buffer does not contain any valid data */
0183     TM_BUFFER_FLAG_EMPTY,
0184 
0185     /* the buffer is filled with valid data */
0186     TM_BUFFER_FLAG_DONE,
0187 
0188     /* the buffer is the dummy buffer - TODO??? */
0189     TM_BUFFER_FLAG_DUMMY_BUFFER
0190 };
0191 
0192 struct tmBuffer {
0193     u64     *pagetablevirt;
0194     u64     pagetablephys;
0195     u16     offset;
0196     u8      *context;
0197     u64     timestamp;
0198     enum tmBufferFlag BufferFlag;
0199     u32     lostbuffers;
0200     u32     validbuffers;
0201     u64     *dummypagevirt;
0202     u64     dummypagephys;
0203     u64     *addressvirt;
0204 };
0205 
0206 struct tmHWStreamParameters {
0207     u32 bitspersample;
0208     u32 samplesperline;
0209     u32 numberoflines;
0210     u32 pitch;
0211     u32 linethreshold;
0212     u64 **pagetablelistvirt;
0213     u64 *pagetablelistphys;
0214     u32 numpagetables;
0215     u32 numpagetableentries;
0216 };
0217 
0218 struct tmStreamParameters {
0219     struct tmHWStreamParameters HWStreamParameters;
0220     u64             qwDummyPageTablePhys;
0221     u64             *pDummyPageTableVirt;
0222 };
0223 
0224 struct tmComResDMATermDescrHeader {
0225     u8  len;
0226     u8  type;
0227     u8  subtyle;
0228     u8  unitid;
0229     u16 terminaltype;
0230     u8  assocterminal;
0231     u8  sourceid;
0232     u8  iterminal;
0233     u32 BARLocation;
0234     u8  flags;
0235     u8  interruptid;
0236     u8  buffercount;
0237     u8  metadatasize;
0238     u8  numformats;
0239     u8  controlsize;
0240 } __attribute__((packed));
0241 
0242 /*
0243  *
0244  * Description:
0245  *  This is the transport stream format header.
0246  *
0247  * Settings:
0248  *  bLength                 - The size of this descriptor in bytes.
0249  *  bDescriptorType         - CS_INTERFACE.
0250  *  bDescriptorSubtype      - VS_FORMAT_MPEG2TS descriptor subtype.
0251  *  bFormatIndex            - A non-zero constant that uniquely identifies the
0252  *                            format.
0253  *  bDataOffset             - Offset to TSP packet within MPEG-2 TS transport
0254  *                            stride, in bytes.
0255  *  bPacketLength           - Length of TSP packet, in bytes (typically 188).
0256  *  bStrideLength           - Length of MPEG-2 TS transport stride.
0257  *  guidStrideFormat        - A Globally Unique Identifier indicating the
0258  *                            format of the stride data (if any). Set to zeros
0259  *                            if there is no Stride Data, or if the Stride
0260  *                            Data is to be ignored by the application.
0261  *
0262  */
0263 struct tmComResTSFormatDescrHeader {
0264     u8  len;
0265     u8  type;
0266     u8  subtype;
0267     u8  bFormatIndex;
0268     u8  bDataOffset;
0269     u8  bPacketLength;
0270     u8  bStrideLength;
0271     u8  guidStrideFormat[16];
0272 } __attribute__((packed));
0273 
0274 /* Encoder related structures */
0275 
0276 /* A/V Mux Selector */
0277 struct tmComResSelDescrHeader {
0278     u8  len;
0279     u8  type;
0280     u8  subtype;
0281     u8  unitid;
0282     u8  nrinpins;
0283     u8  sourceid;
0284 } __attribute__((packed));
0285 
0286 /* A/V Audio processor definitions */
0287 struct tmComResProcDescrHeader {
0288     u8  len;
0289     u8  type;
0290     u8  subtype;
0291     u8  unitid;
0292     u8  sourceid;
0293     u16 wreserved;
0294     u8  controlsize;
0295 } __attribute__((packed));
0296 
0297 /* Video bitrate control message */
0298 #define EU_VIDEO_BIT_RATE_MODE_CONSTANT     (0)
0299 #define EU_VIDEO_BIT_RATE_MODE_VARIABLE_AVERAGE (1)
0300 #define EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK    (2)
0301 struct tmComResEncVideoBitRate {
0302     u8  ucVideoBitRateMode;
0303     u32 dwVideoBitRate;
0304     u32 dwVideoBitRatePeak;
0305 } __attribute__((packed));
0306 
0307 /* Video Encoder Aspect Ratio message */
0308 struct tmComResEncVideoInputAspectRatio {
0309     u8  width;
0310     u8  height;
0311 } __attribute__((packed));
0312 
0313 /* Video Encoder GOP IBP message */
0314 /* 1. IPPPPPPPPPPPPPP */
0315 /* 2. IBPBPBPBPBPBPBP */
0316 /* 3. IBBPBBPBBPBBP   */
0317 #define SAA7164_ENCODER_DEFAULT_GOP_DIST (1)
0318 #define SAA7164_ENCODER_DEFAULT_GOP_SIZE (15)
0319 struct tmComResEncVideoGopStructure {
0320     u8  ucGOPSize;  /* GOP Size 12, 15 */
0321     u8  ucRefFrameDist; /* Reference Frame Distance */
0322 } __attribute__((packed));
0323 
0324 /* Encoder processor definition */
0325 struct tmComResEncoderDescrHeader {
0326     u8  len;
0327     u8  type;
0328     u8  subtype;
0329     u8  unitid;
0330     u8  vsourceid;
0331     u8  asourceid;
0332     u8  iunit;
0333     u32 dwmControlCap;
0334     u32 dwmProfileCap;
0335     u32 dwmVidFormatCap;
0336     u8  bmVidBitrateCap;
0337     u16 wmVidResolutionsCap;
0338     u16 wmVidFrmRateCap;
0339     u32 dwmAudFormatCap;
0340     u8  bmAudBitrateCap;
0341 } __attribute__((packed));
0342 
0343 /* Audio processor definition */
0344 struct tmComResAFeatureDescrHeader {
0345     u8  len;
0346     u8  type;
0347     u8  subtype;
0348     u8  unitid;
0349     u8  sourceid;
0350     u8  controlsize;
0351 } __attribute__((packed));
0352 
0353 /* Audio control messages */
0354 struct tmComResAudioDefaults {
0355     u8  ucDecoderLevel;
0356     u8  ucDecoderFM_Level;
0357     u8  ucMonoLevel;
0358     u8  ucNICAM_Level;
0359     u8  ucSAP_Level;
0360     u8  ucADC_Level;
0361 } __attribute__((packed));
0362 
0363 /* Audio bitrate control message */
0364 struct tmComResEncAudioBitRate {
0365     u8  ucAudioBitRateMode;
0366     u32 dwAudioBitRate;
0367     u32 dwAudioBitRatePeak;
0368 } __attribute__((packed));
0369 
0370 /* Tuner / AV Decoder messages */
0371 struct tmComResTunerStandard {
0372     u8  std;
0373     u32 country;
0374 } __attribute__((packed));
0375 
0376 struct tmComResTunerStandardAuto {
0377     u8  mode;
0378 } __attribute__((packed));
0379 
0380 /* EEPROM definition for PS stream types */
0381 struct tmComResPSFormatDescrHeader {
0382     u8  len;
0383     u8  type;
0384     u8  subtype;
0385     u8  bFormatIndex;
0386     u16 wPacketLength;
0387     u16 wPackLength;
0388     u8  bPackDataType;
0389 } __attribute__((packed));
0390 
0391 /* VBI control structure */
0392 struct tmComResVBIFormatDescrHeader {
0393     u8  len;
0394     u8  type;
0395     u8  subtype; /* VS_FORMAT_VBI */
0396     u8  bFormatIndex;
0397     u32 VideoStandard; /* See KS_AnalogVideoStandard, NTSC = 1 */
0398     u8  StartLine; /* NTSC Start = 10 */
0399     u8  EndLine; /* NTSC = 21 */
0400     u8  FieldRate; /* 60 for NTSC */
0401     u8  bNumLines; /* Unused - scheduled for removal */
0402 } __attribute__((packed));
0403 
0404 struct tmComResProbeCommit {
0405     u16 bmHint;
0406     u8  bFormatIndex;
0407     u8  bFrameIndex;
0408 } __attribute__((packed));
0409 
0410 struct tmComResDebugSetLevel {
0411     u32 dwDebugLevel;
0412 } __attribute__((packed));
0413 
0414 struct tmComResDebugGetData {
0415     u32 dwResult;
0416     u8  ucDebugData[256];
0417 } __attribute__((packed));
0418 
0419 struct tmFwInfoStruct {
0420     u32 status;
0421     u32 mode;
0422     u32 devicespec;
0423     u32 deviceinst;
0424     u32 CPULoad;
0425     u32 RemainHeap;
0426     u32 CPUClock;
0427     u32 RAMSpeed;
0428 } __attribute__((packed));