ivtv-queue.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. buffer queues.
  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>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (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.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #define IVTV_DMA_UNMAPPED ((u32) -1)
  19. /* ivtv_buffer utility functions */
  20. static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)
  21. {
  22. if (s->dma != PCI_DMA_NONE)
  23. pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle,
  24. s->buf_size + 256, s->dma);
  25. }
  26. static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)
  27. {
  28. if (s->dma != PCI_DMA_NONE)
  29. pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle,
  30. s->buf_size + 256, s->dma);
  31. }
  32. int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src, int copybytes);
  33. void ivtv_buf_swap(struct ivtv_buffer *buf);
  34. /* ivtv_queue utility functions */
  35. void ivtv_queue_init(struct ivtv_queue *q);
  36. void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q);
  37. struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q);
  38. int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal,
  39. struct ivtv_queue *to, int needed_bytes);
  40. void ivtv_flush_queues(struct ivtv_stream *s);
  41. /* ivtv_stream utility functions */
  42. int ivtv_stream_alloc(struct ivtv_stream *s);
  43. void ivtv_stream_free(struct ivtv_stream *s);
  44. static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)
  45. {
  46. pci_dma_sync_single_for_cpu(s->itv->dev, s->SG_handle,
  47. sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
  48. }
  49. static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)
  50. {
  51. pci_dma_sync_single_for_device(s->itv->dev, s->SG_handle,
  52. sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
  53. }