Staging: vt6655: remove VOID definition and use
[safe/jmp/linux-2.6] / drivers / staging / dt3155v4l / dt3155-bufs.h
1 /***************************************************************************
2  *   Copyright (C) 2006-2010 by Marin Mitov                                *
3  *   mitov@issp.bas.bg                                                     *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _DT3155_BUFS_H_
22 #define _DT3155_BUFS_H_
23
24 #include <linux/pci.h>
25
26 /* 4 chunks of 4MB, 9 buffers each = 36 buffers (> VIDEO_MAX_FRAME) */
27 #define DT3155_CHUNK_NUM 4
28
29 /* DT3155_CHUNK_SIZE should be 4M (2^22) or less, but more than image size */
30 #define DT3155_CHUNK_SIZE (1U << 22)
31 #define DT3155_CHUNK_FLAGS (GFP_KERNEL | GFP_DMA32 | __GFP_COLD | __GFP_NOWARN)
32
33 /* DT3155_BUF_SIZE = 108 * PAGE_SIZE, so each buf is PAGE_SIZE alligned  */
34 #define DT3155_BUF_SIZE (768 * 576)
35
36 /**
37  * struct dt3155_buf - image buffer structure
38  *
39  * @cpu:        virtual kernel address of the buffer
40  * @dma:        dma (bus) address of the buffer
41  * @next:       pointer to the next buffer in the fifo
42  * @tv:         time value when the image has been acquired
43  */
44 struct dt3155_buf {
45         void *cpu;
46         dma_addr_t dma;
47         struct dt3155_buf *next;
48         struct timeval tv;
49 };
50
51 /**
52  * struct dt3155_fifo - fifo structure
53  *
54  * @head:       pointer to the head of the fifo
55  * @tail:       pionter to the tail of the fifo
56  * @lock:       spin_lock to protect the fifo
57  */
58 struct dt3155_fifo {
59         struct dt3155_buf *head;
60         struct dt3155_buf *tail;
61         spinlock_t lock;
62 };
63
64 struct dt3155_buf * __must_check
65 dt3155_init_chunks_buf(void);
66 void
67 dt3155_free_chunks_buf(struct dt3155_buf *buf);
68
69 struct dt3155_fifo * __must_check
70 dt3155_init_fifo(void);
71 #define dt3155_free_fifo(x) kfree(x)
72
73 struct dt3155_buf * __must_check
74 dt3155_get_buf(struct dt3155_fifo *fifo);
75 void
76 dt3155_put_buf(struct dt3155_buf *buf, struct dt3155_fifo *fifo);
77
78 struct dt3155_fifo * __must_check
79 dt3155_init_chunks_fifo(void);
80 void
81 dt3155_free_chunks_fifo(struct dt3155_fifo *chunks);
82
83 struct dt3155_fifo * __must_check
84 dt3155_init_ibufs_fifo(struct dt3155_fifo *chunks, int buf_size);
85 void
86 dt3155_free_ibufs_fifo(struct dt3155_fifo *fifo);
87
88 #endif /*  _DT3155_BUFS_H_  */