1 /***************************************************************************
2 * Copyright (C) 2006-2010 by Marin Mitov *
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. *
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. *
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 ***************************************************************************/
21 #ifndef _DT3155_BUFS_H_
22 #define _DT3155_BUFS_H_
24 #include <linux/pci.h>
26 /* 4 chunks of 4MB, 9 buffers each = 36 buffers (> VIDEO_MAX_FRAME) */
27 #define DT3155_CHUNK_NUM 4
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)
33 /* DT3155_BUF_SIZE = 108 * PAGE_SIZE, so each buf is PAGE_SIZE alligned */
34 #define DT3155_BUF_SIZE (768 * 576)
37 * struct dt3155_buf - image buffer structure
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
47 struct dt3155_buf *next;
52 * struct dt3155_fifo - fifo structure
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
59 struct dt3155_buf *head;
60 struct dt3155_buf *tail;
64 struct dt3155_buf * __must_check
65 dt3155_init_chunks_buf(void);
67 dt3155_free_chunks_buf(struct dt3155_buf *buf);
69 struct dt3155_fifo * __must_check
70 dt3155_init_fifo(void);
71 #define dt3155_free_fifo(x) kfree(x)
73 struct dt3155_buf * __must_check
74 dt3155_get_buf(struct dt3155_fifo *fifo);
76 dt3155_put_buf(struct dt3155_buf *buf, struct dt3155_fifo *fifo);
78 struct dt3155_fifo * __must_check
79 dt3155_init_chunks_fifo(void);
81 dt3155_free_chunks_fifo(struct dt3155_fifo *chunks);
83 struct dt3155_fifo * __must_check
84 dt3155_init_ibufs_fifo(struct dt3155_fifo *chunks, int buf_size);
86 dt3155_free_ibufs_fifo(struct dt3155_fifo *fifo);
88 #endif /* _DT3155_BUFS_H_ */