Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
[linux/fpc-iii.git] / drivers / staging / dt3155 / dt3155.h
blob793e2fcf44660caf6568a9b1c4300fc472413fc2
1 /*
3 Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
4 Jason Lapenta, Scott Smedley
6 This file is part of the DT3155 Device Driver.
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.
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.
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
23 -- Changes --
25 Date Programmer Description of changes made
26 -------------------------------------------------------------------
27 03-Jul-2000 JML n/a
28 10-Oct-2001 SS port to 2.4 kernel.
29 24-Jul-2002 SS remove unused code & added GPL licence.
30 05-Aug-2005 SS port to 2.6 kernel; make CCIR mode default.
34 #ifndef _DT3155_INC
35 #define _DT3155_INC
37 #include <linux/types.h>
38 #include <linux/time.h> /* struct timeval */
41 /* Uncomment this for 50Hz CCIR */
42 #define CCIR 1
44 /* Can be 1 or 2 */
45 #define MAXBOARDS 1
47 #define BOARD_MAX_BUFFS 3
48 #define MAXBUFFERS (BOARD_MAX_BUFFS*MAXBOARDS)
50 #define PCI_PAGE_SIZE (1 << 12)
52 #ifdef CCIR
53 #define DT3155_MAX_ROWS 576
54 #define DT3155_MAX_COLS 768
55 #define FORMAT50HZ 1
56 #else
57 #define DT3155_MAX_ROWS 480
58 #define DT3155_MAX_COLS 640
59 #define FORMAT50HZ 0
60 #endif
62 /* Configuration structure */
63 struct dt3155_config {
64 u32 acq_mode;
65 u32 cols, rows;
66 u32 continuous;
70 /* hold data for each frame */
71 struct frame_info {
72 u32 addr; /* address of the buffer with the frame */
73 u32 tag; /* unique number for the frame */
74 struct timeval time; /* time that capture took place */
78 * Structure for interrupt and buffer handling.
79 * This is the setup for 1 card
81 struct dt3155_fbuffer {
82 int nbuffers;
84 struct frame_info frame_info[BOARD_MAX_BUFFS];
86 int empty_buffers[BOARD_MAX_BUFFS]; /* indexes empty frames */
87 int empty_len; /* Number of empty buffers */
88 /* Zero means empty */
90 int active_buf; /* Where data is currently dma'ing */
91 int locked_buf; /* Buffers used by user */
93 int ready_que[BOARD_MAX_BUFFS];
94 u32 ready_head; /* The most recent buffer located here */
95 u32 ready_len; /* The number of ready buffers */
97 int even_happened;
98 int even_stopped;
100 int stop_acquire; /* Flag to stop interrupts */
101 u32 frame_count; /* Counter for frames acquired by this card */
106 #define DT3155_MODE_FRAME 1
107 #define DT3155_MODE_FIELD 2
109 #define DT3155_SNAP 1
110 #define DT3155_ACQ 2
112 /* There is one status structure for each card. */
113 struct dt3155_status {
114 int fixed_mode; /* if 1, we are in fixed frame mode */
115 u32 reg_addr; /* Register address for a single card */
116 u32 mem_addr; /* Buffer start addr for this card */
117 u32 mem_size; /* This is the amount of mem available */
118 u32 irq; /* this card's irq */
119 struct dt3155_config config; /* configuration struct */
120 struct dt3155_fbuffer fbuffer; /* frame buffer state struct */
121 u32 state; /* this card's state */
122 u32 device_installed; /* Flag if installed. 1=installed */
125 /* Reference to global status structure */
126 extern struct dt3155_status dt3155_status[MAXBOARDS];
128 #define DT3155_STATE_IDLE 0x00
129 #define DT3155_STATE_FRAME 0x01
130 #define DT3155_STATE_FLD 0x02
131 #define DT3155_STATE_STOP 0x100
132 #define DT3155_STATE_ERROR 0x200
133 #define DT3155_STATE_MODE 0x0ff
135 #define DT3155_IOC_MAGIC '!'
137 #define DT3155_SET_CONFIG _IOW(DT3155_IOC_MAGIC, 1, struct dt3155_config)
138 #define DT3155_GET_CONFIG _IOR(DT3155_IOC_MAGIC, 2, struct dt3155_status)
139 #define DT3155_STOP _IO(DT3155_IOC_MAGIC, 3)
140 #define DT3155_START _IO(DT3155_IOC_MAGIC, 4)
141 #define DT3155_FLUSH _IO(DT3155_IOC_MAGIC, 5)
142 #define DT3155_IOC_MAXNR 5
144 /* Error codes */
146 #define DT_ERR_NO_BUFFERS 0x10000 /* not used but it might be one day */
147 #define DT_ERR_CORRUPT 0x20000
148 #define DT_ERR_OVERRUN 0x30000
149 #define DT_ERR_I2C_TIMEOUT 0x40000
150 #define DT_ERR_MASK 0xff0000/* not used but it might be one day */
152 /* User code will probably want to declare one of these for each card */
153 struct dt3155_read {
154 u32 offset;
155 u32 frame_seq;
156 u32 state;
158 struct frame_info frame_info;
161 #endif /* _DT3155_inc */