/alps/ipecamera

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to driver/pciDriver.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-27 00:28:57 UTC
  • Revision ID: csa@suren.me-20150427002857-82fk6r3e8rfgy4wr
First stand-alone ipecamera implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PCIDRIVER_H_
2
 
#define PCIDRIVER_H_
3
 
 
4
 
/**
5
 
 * This is a full rewrite of the pciDriver.
6
 
 * New default is to support kernel 2.6, using kernel 2.6 APIs.
7
 
 * 
8
 
 * This header defines the interface to the outside world.
9
 
 * 
10
 
 * $Revision: 1.6 $
11
 
 * $Date: 2008-01-24 14:21:36 $
12
 
 * 
13
 
 */
14
 
 
15
 
/*
16
 
 * Change History:
17
 
 * 
18
 
 * $Log: not supported by cvs2svn $
19
 
 * Revision 1.5  2008-01-11 10:15:14  marcus
20
 
 * Removed unused interrupt code.
21
 
 * Added intSource to the wait interrupt call.
22
 
 *
23
 
 * Revision 1.4  2006/11/17 18:44:42  marcus
24
 
 * Type of SG list can now be selected at runtime. Added type to sglist.
25
 
 *
26
 
 * Revision 1.3  2006/11/17 16:23:02  marcus
27
 
 * Added slot number to the PCI info IOctl.
28
 
 *
29
 
 * Revision 1.2  2006/11/13 12:29:09  marcus
30
 
 * Added a IOctl call, to confiure the interrupt response. (testing pending).
31
 
 * Basic interrupts are now supported.
32
 
 *
33
 
 * Revision 1.1  2006/10/10 14:46:52  marcus
34
 
 * Initial commit of the new pciDriver for kernel 2.6
35
 
 *
36
 
 * Revision 1.7  2006/10/06 15:18:06  marcus
37
 
 * Updated PCI info and PCI cmd
38
 
 *
39
 
 * Revision 1.6  2006/09/25 16:51:07  marcus
40
 
 * Added PCI config IOctls, and implemented basic mmap functions.
41
 
 *
42
 
 * Revision 1.5  2006/09/18 17:13:12  marcus
43
 
 * backup commit.
44
 
 *
45
 
 * Revision 1.4  2006/09/15 15:44:41  marcus
46
 
 * backup commit.
47
 
 *
48
 
 * Revision 1.3  2006/08/15 11:40:02  marcus
49
 
 * backup commit.
50
 
 *
51
 
 * Revision 1.2  2006/08/12 18:28:42  marcus
52
 
 * Sync with the laptop
53
 
 *
54
 
 * Revision 1.1  2006/08/11 15:30:46  marcus
55
 
 * Sync with the laptop
56
 
 *
57
 
 */
58
 
 
59
 
#include <linux/ioctl.h>
60
 
#include "../pcilib_types.h"
61
 
 
62
 
/* Identifies the PCI-E Xilinx ML605 */
63
 
#define PCIE_XILINX_VENDOR_ID 0x10ee
64
 
#define PCIE_ML605_DEVICE_ID 0x6024
65
 
 
66
 
/* Identifies the PCI-E IPE Camera */
67
 
#define PCIE_IPECAMERA_DEVICE_ID 0x6081
68
 
#define PCIE_KAPTURE_DEVICE_ID 0x6028
69
 
//#define PCIE_IPECAMERA_DEVICE_ID 0x6018
70
 
 
71
 
 
72
 
/* Possible values for ioctl commands */
73
 
 
74
 
/* PCI mmap areas */
75
 
#define PCIDRIVER_BAR0          0
76
 
#define PCIDRIVER_BAR1          1
77
 
#define PCIDRIVER_BAR2          2
78
 
#define PCIDRIVER_BAR3          3
79
 
#define PCIDRIVER_BAR4          4
80
 
#define PCIDRIVER_BAR5          5
81
 
 
82
 
/* mmap mode of the device */
83
 
#define PCIDRIVER_MMAP_PCI      0
84
 
#define PCIDRIVER_MMAP_KMEM 1
85
 
 
86
 
/* Direction of a DMA operation */
87
 
#define PCIDRIVER_DMA_BIDIRECTIONAL     0
88
 
#define PCIDRIVER_DMA_TODEVICE          PCILIB_KMEM_SYNC_TODEVICE
89
 
#define PCIDRIVER_DMA_FROMDEVICE        PCILIB_KMEM_SYNC_FROMDEVICE
90
 
 
91
 
/* Possible sizes in a PCI command */
92
 
#define PCIDRIVER_PCI_CFG_SZ_BYTE  1
93
 
#define PCIDRIVER_PCI_CFG_SZ_WORD  2
94
 
#define PCIDRIVER_PCI_CFG_SZ_DWORD 3
95
 
 
96
 
/* Possible types of SG lists */
97
 
#define PCIDRIVER_SG_NONMERGED 0
98
 
#define PCIDRIVER_SG_MERGED 1
99
 
 
100
 
/* Maximum number of interrupt sources */
101
 
#define PCIDRIVER_INT_MAXSOURCES 16
102
 
 
103
 
 
104
 
#define KMEM_FLAG_REUSE 1       /**< Try to reuse existing buffer with the same use & item */
105
 
#define KMEM_FLAG_EXCLUSIVE 2   /**< Allow only a single application accessing a specified use & item */
106
 
#define KMEM_FLAG_PERSISTENT 4  /**< Sets persistent mode */
107
 
#define KMEM_FLAG_HW 8          /**< The buffer may be accessed by hardware, the hardware access will not occur any more if passed to _free function */
108
 
#define KMEM_FLAG_FORCE 16      /**< Force memory cleanup even if references are present */
109
 
#define KMEM_FLAG_MASS 32       /**< Apply to all buffers of selected use */
110
 
#define KMEM_FLAG_TRY 64        /**< Do not allocate buffers, try to reuse and fail if not possible */
111
 
 
112
 
#define KMEM_FLAG_REUSED 1              /**< Indicates if buffer with specified use & item was already allocated and reused */
113
 
#define KMEM_FLAG_REUSED_PERSISTENT 4   /**< Indicates that reused buffer was persistent before the call */
114
 
#define KMEM_FLAG_REUSED_HW 8           /**< Indicates that reused buffer had a HW reference before the call */
115
 
 
116
 
 
117
 
/* Types */
118
 
typedef struct {
119
 
        unsigned long type;
120
 
        unsigned long pa;
121
 
        unsigned long size;
122
 
        unsigned long align;
123
 
        unsigned long use;
124
 
        unsigned long item;
125
 
        int flags;
126
 
        int handle_id;
127
 
} kmem_handle_t;
128
 
 
129
 
typedef struct {
130
 
        unsigned long addr;
131
 
        unsigned long size;
132
 
} umem_sgentry_t;
133
 
 
134
 
typedef struct {
135
 
        int handle_id;
136
 
        int type;
137
 
        int nents;
138
 
        umem_sgentry_t *sg;
139
 
} umem_sglist_t;
140
 
 
141
 
typedef struct {
142
 
        unsigned long vma;
143
 
        unsigned long size;
144
 
        int handle_id;
145
 
        int dir;
146
 
} umem_handle_t;
147
 
 
148
 
typedef struct {
149
 
        kmem_handle_t handle;
150
 
        int dir;
151
 
} kmem_sync_t;
152
 
 
153
 
typedef struct {
154
 
    unsigned long count;
155
 
    unsigned long timeout;      // microseconds
156
 
    unsigned int source;
157
 
} interrupt_wait_t;
158
 
 
159
 
typedef struct {
160
 
        int size;
161
 
        int addr;
162
 
        union {
163
 
                unsigned char byte;
164
 
                unsigned short word;
165
 
                unsigned int dword;     /* not strict C, but if not can have problems */
166
 
        } val;
167
 
} pci_cfg_cmd;
168
 
 
169
 
typedef struct {
170
 
        unsigned short vendor_id;
171
 
        unsigned short device_id;
172
 
        unsigned short bus;
173
 
        unsigned short slot;
174
 
        unsigned short func;
175
 
        unsigned short devfn;
176
 
        unsigned char interrupt_pin;
177
 
        unsigned char interrupt_line;
178
 
        unsigned int irq;
179
 
        unsigned long bar_start[6];
180
 
        unsigned long bar_length[6];
181
 
        unsigned long bar_flags[6];
182
 
} pcilib_board_info_t;
183
 
 
184
 
 
185
 
/* ioctl interface */
186
 
/* See documentation for a detailed usage explanation */
187
 
 
188
 
/* 
189
 
 * one of the problems of ioctl, is that requires a type definition.
190
 
 * This type is only 8-bits wide, and half-documented in 
191
 
 * <linux-src>/Documentation/ioctl-number.txt.
192
 
 * previous SHL -> 'S' definition, conflicts with several devices,
193
 
 * so I changed it to be pci -> 'p', in the range 0xA0-AF
194
 
 */
195
 
#define PCIDRIVER_IOC_MAGIC 'p'
196
 
#define PCIDRIVER_IOC_BASE  0xA0
197
 
 
198
 
#define PCIDRIVER_IOC_MMAP_MODE  _IO(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 0 )
199
 
#define PCIDRIVER_IOC_MMAP_AREA  _IO(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 1 )
200
 
#define PCIDRIVER_IOC_KMEM_ALLOC _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 2, kmem_handle_t * )
201
 
#define PCIDRIVER_IOC_KMEM_FREE  _IOW ( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 3, kmem_handle_t * )
202
 
#define PCIDRIVER_IOC_KMEM_SYNC  _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 4, kmem_sync_t * )
203
 
#define PCIDRIVER_IOC_UMEM_SGMAP _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 5, umem_handle_t * )
204
 
#define PCIDRIVER_IOC_UMEM_SGUNMAP _IOW(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 6, umem_handle_t * )
205
 
#define PCIDRIVER_IOC_UMEM_SGGET _IOWR( PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 7, umem_sglist_t * )
206
 
#define PCIDRIVER_IOC_UMEM_SYNC  _IOW(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 8, umem_handle_t * )
207
 
#define PCIDRIVER_IOC_WAITI      _IO(   PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 9 )
208
 
 
209
 
/* And now, the methods to access the PCI configuration area */
210
 
#define PCIDRIVER_IOC_PCI_CFG_RD  _IOWR(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 10, pci_cfg_cmd * )
211
 
#define PCIDRIVER_IOC_PCI_CFG_WR  _IOWR(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 11, pci_cfg_cmd * )
212
 
#define PCIDRIVER_IOC_PCI_INFO    _IOWR(  PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 12, pcilib_board_info_t * )
213
 
 
214
 
/* Clear interrupt queues */
215
 
#define PCIDRIVER_IOC_CLEAR_IOQ   _IO(   PCIDRIVER_IOC_MAGIC, PCIDRIVER_IOC_BASE + 13 )
216
 
 
217
 
#endif