]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/dt3155/dt3155.h
Staging: dt3155: add needed #include
[karo-tx-linux.git] / drivers / staging / dt3155 / dt3155.h
1 /*
2
3 Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
4                          Jason Lapenta, Scott Smedley
5
6 This file is part of the DT3155 Device Driver.
7
8 The DT3155 Device Driver is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
12
13 The DT3155 Device Driver is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with the DT3155 Device Driver; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 MA 02111-1307 USA
22
23   $Id: dt3155.h,v 1.11 2005/08/09 06:08:51 ssmedley Exp $
24
25 -- Changes --
26
27   Date     Programmer  Description of changes made
28   -------------------------------------------------------------------
29   03-Jul-2000 JML     n/a
30   10-Oct-2001 SS      port to 2.4 kernel.
31   24-Jul-2002 SS      remove unused code & added GPL licence.
32   05-Aug-2005 SS      port to 2.6 kernel; make CCIR mode default.
33
34 */
35
36 #ifndef _DT3155_INC
37 #define _DT3155_INC
38
39 #ifdef __KERNEL__
40 #include <linux/types.h>        /* u_int etc. */
41 #include <linux/time.h>         /* struct timeval */
42 #else
43 #include <sys/ioctl.h>
44 #include <sys/param.h>
45 #include <sys/time.h>
46 #include <unistd.h>
47 #endif
48
49
50 #define TRUE  1
51 #define FALSE 0
52
53 /* Uncomment this for 50Hz CCIR */
54 #define CCIR 1
55
56 /* Can be 1 or 2 */
57 #define MAXBOARDS 1
58
59 #define BOARD_MAX_BUFFS 3
60 #define MAXBUFFERS BOARD_MAX_BUFFS*MAXBOARDS
61
62 #define PCI_PAGE_SIZE (1 << 12)
63
64 #ifdef CCIR
65 #define DT3155_MAX_ROWS 576
66 #define DT3155_MAX_COLS 768
67 #define FORMAT50HZ TRUE
68 #else
69 #define DT3155_MAX_ROWS 480
70 #define DT3155_MAX_COLS 640
71 #define FORMAT50HZ FALSE
72 #endif
73
74 /* Configuration structure */
75 struct dt3155_config_s {
76   u_int acq_mode;
77   u_int cols, rows;
78   u_int continuous;
79 };
80
81
82 /* hold data for each frame */
83 typedef struct
84 {
85   u_long addr;          /* address of the buffer with the frame */
86   u_long tag;           /* unique number for the frame */
87   struct timeval time;  /* time that capture took place */
88 } frame_info_t;
89
90 /* Structure for interrupt and buffer handling.  */
91 /* This is the setup for 1 card                  */
92 struct dt3155_fbuffer_s {
93   int    nbuffers;
94
95   frame_info_t frame_info[ BOARD_MAX_BUFFS ];
96
97   int empty_buffers[ BOARD_MAX_BUFFS ];    /* indexes empty frames */
98   int empty_len;                /* Number of empty buffers  */
99                                 /* Zero means empty */
100
101   int active_buf;               /* Where data is currently dma'ing */
102   int locked_buf;               /* Buffers used by user */
103
104   int ready_que[ BOARD_MAX_BUFFS ];
105   u_long ready_head;  /* The most recent buffer located here */
106   u_long ready_len;   /* The number of ready buffers */
107
108   int even_happened;
109   int even_stopped;
110
111   int stop_acquire;             /* Flag to stop interrupts */
112   u_long frame_count;           /* Counter for frames acquired by this card */
113
114 };
115
116
117
118 #define DT3155_MODE_FRAME 1
119 #define DT3155_MODE_FIELD 2
120
121 #define DT3155_SNAP 1
122 #define DT3155_ACQ  2
123
124 /* There is one status structure for each card. */
125 typedef struct dt3155_status_s
126 {
127   int fixed_mode;              /* if 1, we are in fixed frame mode */
128   u_long reg_addr;             /* Register address for a single card */
129   u_long mem_addr;             /* Buffer start addr for this card */
130   u_long mem_size;             /* This is the amount of mem available  */
131   u_int  irq;                  /* this card's irq */
132   struct dt3155_config_s config;  /* configuration struct */
133   struct dt3155_fbuffer_s fbuffer;/* frame buffer state struct */
134   u_long state;                /* this card's state */
135   u_int device_installed;      /* Flag if installed. 1=installed */
136 } dt3155_status_t;
137
138 /* Reference to global status structure */
139 extern struct dt3155_status_s dt3155_status[MAXBOARDS];
140
141 #define DT3155_STATE_IDLE    0x00
142 #define DT3155_STATE_FRAME   0x01
143 #define DT3155_STATE_FLD     0x02
144 #define DT3155_STATE_STOP   0x100
145 #define DT3155_STATE_ERROR  0x200
146 #define DT3155_STATE_MODE   0x0ff
147
148 #define DT3155_IOC_MAGIC     '!'
149
150 #define DT3155_SET_CONFIG  _IOW( DT3155_IOC_MAGIC, 1, struct dt3155_config_s )
151 #define DT3155_GET_CONFIG  _IOR( DT3155_IOC_MAGIC, 2, struct dt3155_status_s )
152 #define DT3155_STOP        _IO(  DT3155_IOC_MAGIC, 3 )
153 #define DT3155_START       _IO(  DT3155_IOC_MAGIC, 4 )
154 #define DT3155_FLUSH       _IO(  DT3155_IOC_MAGIC, 5 )
155 #define DT3155_IOC_MAXNR   5
156
157 /* Error codes */
158
159 #define DT_ERR_NO_BUFFERS   0x10000 /* not used but it might be one day - SS */
160 #define DT_ERR_CORRUPT      0x20000
161 #define DT_ERR_OVERRUN      0x30000
162 #define DT_ERR_I2C_TIMEOUT  0x40000
163 #define DT_ERR_MASK         0xff0000/* not used but it might be one day - SS */
164
165 /* User code will probably want to declare one of these for each card */
166 typedef struct dt3155_read_s
167 {
168   u_long offset;
169   u_long frame_seq;
170   u_long state;
171
172   frame_info_t frame_info;
173 } dt3155_read_t;
174
175 #endif /* _DT3155_inc */