blob: 981708f3ee39141fa94612d00ca380fce938499a [file] [log] [blame]
Jarod Wilson7963eb42010-01-04 18:02:27 -05001/********************************************************************
2 * Copyright(c) 2006-2009 Broadcom Corporation.
3 *
4 * Name: bc_dts_glob_lnx.h
5 *
6 * Description: Wrapper to Windows dts_glob.h for Link-Linux usage.
7 * The idea is to define additional Linux related defs
8 * in this file to avoid changes to existing Windows
9 * glob file.
10 *
11 * AU
12 *
13 * HISTORY:
14 *
15 ********************************************************************
16 * This header is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License as published
18 * by the Free Software Foundation, either version 2.1 of the License.
19 *
20 * This header is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this header. If not, see <http://www.gnu.org/licenses/>.
26 *******************************************************************/
27
28#ifndef _BC_DTS_GLOB_LNX_H_
29#define _BC_DTS_GLOB_LNX_H_
30
31#ifdef __LINUX_USER__
32#include <stdio.h>
33#include <stdlib.h>
34#include <unistd.h>
35#include <fcntl.h>
36#include <ctype.h>
37#include <string.h>
38#include <errno.h>
39#include <netdb.h>
40#include <sys/time.h>
41#include <time.h>
42#include <arpa/inet.h>
Lars Lindley641b63f2010-03-11 00:21:20 +010043#include <linux/param.h>
Jarod Wilson7963eb42010-01-04 18:02:27 -050044#include <linux/ioctl.h>
45#include <sys/select.h>
46
47#define DRVIFLIB_INT_API
48
49#endif
50
Jorgyano Vieira01c32072012-02-25 21:58:21 -020051#include "crystalhd.h"
Jarod Wilson7963eb42010-01-04 18:02:27 -050052
53#define CRYSTALHD_API_NAME "crystalhd"
54#define CRYSTALHD_API_DEV_NAME "/dev/crystalhd"
55
56/*
57 * These are SW stack tunable parameters shared
58 * between the driver and the application.
59 */
Lior Dotanabfc7682010-05-18 12:46:42 +030060enum BC_DTS_GLOBALS {
Amarjargal Gundjalam7258cb62013-05-13 03:27:33 -070061 BC_MAX_FW_CMD_BUFF_SZ = 0x40, /* FW passthrough cmd/rsp buffer size */
Jarod Wilson7963eb42010-01-04 18:02:27 -050062 PCI_CFG_SIZE = 256, /* PCI config size buffer */
63 BC_IOCTL_DATA_POOL_SIZE = 8, /* BC_IOCTL_DATA Pool size */
Amarjargal Gundjalam7258cb62013-05-13 03:27:33 -070064 BC_LINK_MAX_OPENS = 3, /* Maximum simultaneous opens*/
65 BC_LINK_MAX_SGLS = 1024, /* Maximum SG elements 4M/4K */
Jarod Wilson7963eb42010-01-04 18:02:27 -050066 BC_TX_LIST_CNT = 2, /* Max Tx DMA Rings */
67 BC_RX_LIST_CNT = 8, /* Max Rx DMA Rings*/
68 BC_PROC_OUTPUT_TIMEOUT = 3000, /* Milliseconds */
69 BC_INFIFO_THRESHOLD = 0x10000,
70};
71
Lior Dotanabfc7682010-05-18 12:46:42 +030072struct BC_CMD_REG_ACC {
Jarod Wilson7963eb42010-01-04 18:02:27 -050073 uint32_t Offset;
74 uint32_t Value;
Lior Dotanabfc7682010-05-18 12:46:42 +030075};
Jarod Wilson7963eb42010-01-04 18:02:27 -050076
Lior Dotanabfc7682010-05-18 12:46:42 +030077struct BC_CMD_DEV_MEM {
Jarod Wilson7963eb42010-01-04 18:02:27 -050078 uint32_t StartOff;
79 uint32_t NumDwords;
80 uint32_t Rsrd;
Lior Dotanabfc7682010-05-18 12:46:42 +030081};
Jarod Wilson7963eb42010-01-04 18:02:27 -050082
83/* FW Passthrough command structure */
Lior Dotanabfc7682010-05-18 12:46:42 +030084enum bc_fw_cmd_flags {
Jarod Wilson7963eb42010-01-04 18:02:27 -050085 BC_FW_CMD_FLAGS_NONE = 0,
86 BC_FW_CMD_PIB_QS = 0x01,
87};
88
Lior Dotanabfc7682010-05-18 12:46:42 +030089struct BC_FW_CMD {
Jarod Wilson7963eb42010-01-04 18:02:27 -050090 uint32_t cmd[BC_MAX_FW_CMD_BUFF_SZ];
91 uint32_t rsp[BC_MAX_FW_CMD_BUFF_SZ];
92 uint32_t flags;
93 uint32_t add_data;
Lior Dotanabfc7682010-05-18 12:46:42 +030094};
Jarod Wilson7963eb42010-01-04 18:02:27 -050095
Lior Dotanabfc7682010-05-18 12:46:42 +030096struct BC_HW_TYPE {
Jarod Wilson7963eb42010-01-04 18:02:27 -050097 uint16_t PciDevId;
98 uint16_t PciVenId;
99 uint8_t HwRev;
100 uint8_t Align[3];
Lior Dotanabfc7682010-05-18 12:46:42 +0300101};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500102
Lior Dotanabfc7682010-05-18 12:46:42 +0300103struct BC_PCI_CFG {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500104 uint32_t Size;
105 uint32_t Offset;
106 uint8_t pci_cfg_space[PCI_CFG_SIZE];
Lior Dotanabfc7682010-05-18 12:46:42 +0300107};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500108
Lior Dotanabfc7682010-05-18 12:46:42 +0300109struct BC_VERSION_INFO {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500110 uint8_t DriverMajor;
111 uint8_t DriverMinor;
112 uint16_t DriverRevision;
Lior Dotanabfc7682010-05-18 12:46:42 +0300113};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500114
Lior Dotanabfc7682010-05-18 12:46:42 +0300115struct BC_START_RX_CAP {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500116 uint32_t Rsrd;
117 uint32_t StartDeliveryThsh;
118 uint32_t PauseThsh;
119 uint32_t ResumeThsh;
Lior Dotanabfc7682010-05-18 12:46:42 +0300120};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500121
Lior Dotanabfc7682010-05-18 12:46:42 +0300122struct BC_FLUSH_RX_CAP {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500123 uint32_t Rsrd;
124 uint32_t bDiscardOnly;
Lior Dotanabfc7682010-05-18 12:46:42 +0300125};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500126
Lior Dotanabfc7682010-05-18 12:46:42 +0300127struct BC_DTS_STATS {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500128 uint8_t drvRLL;
129 uint8_t drvFLL;
130 uint8_t eosDetected;
131 uint8_t pwr_state_change;
132
133 /* Stats from App */
134 uint32_t opFrameDropped;
135 uint32_t opFrameCaptured;
136 uint32_t ipSampleCnt;
137 uint64_t ipTotalSize;
138 uint32_t reptdFrames;
139 uint32_t pauseCount;
140 uint32_t pibMisses;
141 uint32_t discCounter;
142
143 /* Stats from Driver */
144 uint32_t TxFifoBsyCnt;
145 uint32_t intCount;
146 uint32_t DrvIgnIntrCnt;
147 uint32_t DrvTotalFrmDropped;
148 uint32_t DrvTotalHWErrs;
149 uint32_t DrvTotalPIBFlushCnt;
150 uint32_t DrvTotalFrmCaptured;
151 uint32_t DrvPIBMisses;
152 uint32_t DrvPauseTime;
153 uint32_t DrvRepeatedFrms;
154 uint32_t res1[13];
155
Lior Dotanabfc7682010-05-18 12:46:42 +0300156};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500157
Lior Dotanabfc7682010-05-18 12:46:42 +0300158struct BC_PROC_INPUT {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500159 uint8_t *pDmaBuff;
160 uint32_t BuffSz;
161 uint8_t Mapped;
162 uint8_t Encrypted;
163 uint8_t Rsrd[2];
164 uint32_t DramOffset; /* For debug use only */
Lior Dotanabfc7682010-05-18 12:46:42 +0300165};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500166
Lior Dotanabfc7682010-05-18 12:46:42 +0300167struct BC_DEC_YUV_BUFFS {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500168 uint32_t b422Mode;
169 uint8_t *YuvBuff;
170 uint32_t YuvBuffSz;
171 uint32_t UVbuffOffset;
172 uint32_t YBuffDoneSz;
173 uint32_t UVBuffDoneSz;
174 uint32_t RefCnt;
Lior Dotanabfc7682010-05-18 12:46:42 +0300175};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500176
Arvydas Sidorenko831e5ba2011-09-08 18:46:08 +0200177enum DECOUT_COMPLETION_FLAGS {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500178 COMP_FLAG_NO_INFO = 0x00,
179 COMP_FLAG_FMT_CHANGE = 0x01,
180 COMP_FLAG_PIB_VALID = 0x02,
181 COMP_FLAG_DATA_VALID = 0x04,
182 COMP_FLAG_DATA_ENC = 0x08,
183 COMP_FLAG_DATA_BOT = 0x10,
184};
185
Arvydas Sidorenko831e5ba2011-09-08 18:46:08 +0200186struct BC_DEC_OUT_BUFF {
Lior Dotanabfc7682010-05-18 12:46:42 +0300187 struct BC_DEC_YUV_BUFFS OutPutBuffs;
188 struct BC_PIC_INFO_BLOCK PibInfo;
Jarod Wilson7963eb42010-01-04 18:02:27 -0500189 uint32_t Flags;
190 uint32_t BadFrCnt;
Lior Dotanabfc7682010-05-18 12:46:42 +0300191};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500192
Lior Dotanabfc7682010-05-18 12:46:42 +0300193struct BC_NOTIFY_MODE {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500194 uint32_t Mode;
195 uint32_t Rsvr[3];
Lior Dotanabfc7682010-05-18 12:46:42 +0300196};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500197
Lior Dotanabfc7682010-05-18 12:46:42 +0300198struct BC_CLOCK {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500199 uint32_t clk;
200 uint32_t Rsvr[3];
Lior Dotanabfc7682010-05-18 12:46:42 +0300201};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500202
Lior Dotanabfc7682010-05-18 12:46:42 +0300203struct BC_IOCTL_DATA {
204 enum BC_STATUS RetSts;
Jarod Wilson7963eb42010-01-04 18:02:27 -0500205 uint32_t IoctlDataSz;
206 uint32_t Timeout;
207 union {
Lior Dotanabfc7682010-05-18 12:46:42 +0300208 struct BC_CMD_REG_ACC regAcc;
209 struct BC_CMD_DEV_MEM devMem;
210 struct BC_FW_CMD fwCmd;
211 struct BC_HW_TYPE hwType;
212 struct BC_PCI_CFG pciCfg;
213 struct BC_VERSION_INFO VerInfo;
214 struct BC_PROC_INPUT ProcInput;
215 struct BC_DEC_YUV_BUFFS RxBuffs;
216 struct BC_DEC_OUT_BUFF DecOutData;
217 struct BC_START_RX_CAP RxCap;
218 struct BC_FLUSH_RX_CAP FlushRxCap;
219 struct BC_DTS_STATS drvStat;
220 struct BC_NOTIFY_MODE NotifyMode;
221 struct BC_CLOCK clockValue;
Jarod Wilson7963eb42010-01-04 18:02:27 -0500222 } u;
223 struct _BC_IOCTL_DATA *next;
Lior Dotanabfc7682010-05-18 12:46:42 +0300224};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500225
Lior Dotanabfc7682010-05-18 12:46:42 +0300226enum BC_DRV_CMD {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500227 DRV_CMD_VERSION = 0, /* Get SW version */
228 DRV_CMD_GET_HWTYPE, /* Get HW version and type Dozer/Tank */
229 DRV_CMD_REG_RD, /* Read Device Register */
230 DRV_CMD_REG_WR, /* Write Device Register */
231 DRV_CMD_FPGA_RD, /* Read FPGA Register */
232 DRV_CMD_FPGA_WR, /* Wrtie FPGA Reister */
233 DRV_CMD_MEM_RD, /* Read Device Memory */
234 DRV_CMD_MEM_WR, /* Write Device Memory */
235 DRV_CMD_RD_PCI_CFG, /* Read PCI Config Space */
236 DRV_CMD_WR_PCI_CFG, /* Write the PCI Configuration Space*/
237 DRV_CMD_FW_DOWNLOAD, /* Download Firmware */
238 DRV_ISSUE_FW_CMD, /* Issue FW Cmd (pass through mode) */
239 DRV_CMD_PROC_INPUT, /* Process Input Sample */
240 DRV_CMD_ADD_RXBUFFS, /* Add Rx side buffers to driver pool */
241 DRV_CMD_FETCH_RXBUFF, /* Get Rx DMAed buffer */
242 DRV_CMD_START_RX_CAP, /* Start Rx Buffer Capture */
Amarjargal Gundjalam7258cb62013-05-13 03:27:33 -0700243 DRV_CMD_FLUSH_RX_CAP, /* Stop the capture for now...
244 we will enhance this later*/
Jarod Wilson7963eb42010-01-04 18:02:27 -0500245 DRV_CMD_GET_DRV_STAT, /* Get Driver Internal Statistics */
246 DRV_CMD_RST_DRV_STAT, /* Reset Driver Internal Statistics */
Amarjargal Gundjalam7258cb62013-05-13 03:27:33 -0700247 DRV_CMD_NOTIFY_MODE, /* Notify the Mode to driver
248 in which the application is Operating*/
249 DRV_CMD_CHANGE_CLOCK, /* Change the core clock to either save power
250 or improve performance */
Jarod Wilson7963eb42010-01-04 18:02:27 -0500251
252 /* MUST be the last one.. */
253 DRV_CMD_END, /* End of the List.. */
Lior Dotanabfc7682010-05-18 12:46:42 +0300254};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500255
256#define BC_IOC_BASE 'b'
257#define BC_IOC_VOID _IOC_NONE
258#define BC_IOC_IOWR(nr, type) _IOWR(BC_IOC_BASE, nr, type)
Lior Dotanabfc7682010-05-18 12:46:42 +0300259#define BC_IOCTL_MB struct BC_IOCTL_DATA
Jarod Wilson7963eb42010-01-04 18:02:27 -0500260
261#define BCM_IOC_GET_VERSION BC_IOC_IOWR(DRV_CMD_VERSION, BC_IOCTL_MB)
262#define BCM_IOC_GET_HWTYPE BC_IOC_IOWR(DRV_CMD_GET_HWTYPE, BC_IOCTL_MB)
263#define BCM_IOC_REG_RD BC_IOC_IOWR(DRV_CMD_REG_RD, BC_IOCTL_MB)
264#define BCM_IOC_REG_WR BC_IOC_IOWR(DRV_CMD_REG_WR, BC_IOCTL_MB)
265#define BCM_IOC_MEM_RD BC_IOC_IOWR(DRV_CMD_MEM_RD, BC_IOCTL_MB)
266#define BCM_IOC_MEM_WR BC_IOC_IOWR(DRV_CMD_MEM_WR, BC_IOCTL_MB)
267#define BCM_IOC_FPGA_RD BC_IOC_IOWR(DRV_CMD_FPGA_RD, BC_IOCTL_MB)
268#define BCM_IOC_FPGA_WR BC_IOC_IOWR(DRV_CMD_FPGA_WR, BC_IOCTL_MB)
269#define BCM_IOC_RD_PCI_CFG BC_IOC_IOWR(DRV_CMD_RD_PCI_CFG, BC_IOCTL_MB)
270#define BCM_IOC_WR_PCI_CFG BC_IOC_IOWR(DRV_CMD_WR_PCI_CFG, BC_IOCTL_MB)
271#define BCM_IOC_PROC_INPUT BC_IOC_IOWR(DRV_CMD_PROC_INPUT, BC_IOCTL_MB)
272#define BCM_IOC_ADD_RXBUFFS BC_IOC_IOWR(DRV_CMD_ADD_RXBUFFS, BC_IOCTL_MB)
273#define BCM_IOC_FETCH_RXBUFF BC_IOC_IOWR(DRV_CMD_FETCH_RXBUFF, BC_IOCTL_MB)
274#define BCM_IOC_FW_CMD BC_IOC_IOWR(DRV_ISSUE_FW_CMD, BC_IOCTL_MB)
275#define BCM_IOC_START_RX_CAP BC_IOC_IOWR(DRV_CMD_START_RX_CAP, BC_IOCTL_MB)
276#define BCM_IOC_FLUSH_RX_CAP BC_IOC_IOWR(DRV_CMD_FLUSH_RX_CAP, BC_IOCTL_MB)
277#define BCM_IOC_GET_DRV_STAT BC_IOC_IOWR(DRV_CMD_GET_DRV_STAT, BC_IOCTL_MB)
278#define BCM_IOC_RST_DRV_STAT BC_IOC_IOWR(DRV_CMD_RST_DRV_STAT, BC_IOCTL_MB)
279#define BCM_IOC_NOTIFY_MODE BC_IOC_IOWR(DRV_CMD_NOTIFY_MODE, BC_IOCTL_MB)
280#define BCM_IOC_FW_DOWNLOAD BC_IOC_IOWR(DRV_CMD_FW_DOWNLOAD, BC_IOCTL_MB)
281#define BCM_IOC_CHG_CLK BC_IOC_IOWR(DRV_CMD_CHANGE_CLOCK, BC_IOCTL_MB)
282#define BCM_IOC_END BC_IOC_VOID
283
284/* Wrapper for main IOCTL data */
Lior Dotanabfc7682010-05-18 12:46:42 +0300285struct crystalhd_ioctl_data {
286 struct BC_IOCTL_DATA udata; /* IOCTL from App..*/
Jarod Wilson7963eb42010-01-04 18:02:27 -0500287 uint32_t u_id; /* Driver specific user ID */
288 uint32_t cmd; /* Cmd ID for driver's use. */
Amarjargal Gundjalam7258cb62013-05-13 03:27:33 -0700289 void *add_cdata; /* Additional command specific data..*/
290 uint32_t add_cdata_sz; /* Additional command specific data size */
Lior Dotanabfc7682010-05-18 12:46:42 +0300291 struct crystalhd_ioctl_data *next; /* List/Fifo management */
292};
Jarod Wilson7963eb42010-01-04 18:02:27 -0500293
Arvydas Sidorenko831e5ba2011-09-08 18:46:08 +0200294enum crystalhd_kmod_ver {
Jarod Wilson7963eb42010-01-04 18:02:27 -0500295 crystalhd_kmod_major = 0,
296 crystalhd_kmod_minor = 9,
297 crystalhd_kmod_rev = 27,
298};
299
300#endif