3 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
4 Copyright (C) 2004 Chris Kennedy <c@groovy.org>
5 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define IVTV_DMA_UNMAPPED ((u32) -1)
24 /* ivtv_buffer utility functions */
25 static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream
*s
, struct ivtv_buffer
*buf
)
27 if (s
->dma
!= PCI_DMA_NONE
)
28 pci_dma_sync_single_for_cpu(s
->itv
->dev
, buf
->dma_handle
,
29 s
->buf_size
+ 256, s
->dma
);
32 static inline void ivtv_buf_sync_for_device(struct ivtv_stream
*s
, struct ivtv_buffer
*buf
)
34 if (s
->dma
!= PCI_DMA_NONE
)
35 pci_dma_sync_single_for_device(s
->itv
->dev
, buf
->dma_handle
,
36 s
->buf_size
+ 256, s
->dma
);
39 int ivtv_buf_copy_from_user(struct ivtv_stream
*s
, struct ivtv_buffer
*buf
, const char __user
*src
, int copybytes
);
40 void ivtv_buf_swap(struct ivtv_buffer
*buf
);
42 /* ivtv_queue utility functions */
43 void ivtv_queue_init(struct ivtv_queue
*q
);
44 void ivtv_enqueue(struct ivtv_stream
*s
, struct ivtv_buffer
*buf
, struct ivtv_queue
*q
);
45 struct ivtv_buffer
*ivtv_dequeue(struct ivtv_stream
*s
, struct ivtv_queue
*q
);
46 int ivtv_queue_move(struct ivtv_stream
*s
, struct ivtv_queue
*from
, struct ivtv_queue
*steal
,
47 struct ivtv_queue
*to
, int needed_bytes
);
48 void ivtv_flush_queues(struct ivtv_stream
*s
);
50 /* ivtv_stream utility functions */
51 int ivtv_stream_alloc(struct ivtv_stream
*s
);
52 void ivtv_stream_free(struct ivtv_stream
*s
);
54 static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream
*s
)
56 pci_dma_sync_single_for_cpu(s
->itv
->dev
, s
->SG_handle
,
57 sizeof(struct ivtv_SG_element
) * s
->buffers
, PCI_DMA_TODEVICE
);
60 static inline void ivtv_stream_sync_for_device(struct ivtv_stream
*s
)
62 pci_dma_sync_single_for_device(s
->itv
->dev
, s
->SG_handle
,
63 sizeof(struct ivtv_SG_element
) * s
->buffers
, PCI_DMA_TODEVICE
);