Path: blob/master/drivers/media/video/ivtv/ivtv-queue.h
17633 views
/*1buffer queues.2Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>3Copyright (C) 2004 Chris Kennedy <[email protected]>4Copyright (C) 2005-2007 Hans Verkuil <[email protected]>56This program is free software; you can redistribute it and/or modify7it under the terms of the GNU General Public License as published by8the Free Software Foundation; either version 2 of the License, or9(at your option) any later version.1011This program is distributed in the hope that it will be useful,12but WITHOUT ANY WARRANTY; without even the implied warranty of13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14GNU General Public License for more details.1516You should have received a copy of the GNU General Public License17along with this program; if not, write to the Free Software18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*/2021#ifndef IVTV_QUEUE_H22#define IVTV_QUEUE_H2324#define IVTV_DMA_UNMAPPED ((u32) -1)25#define SLICED_VBI_PIO 02627/* ivtv_buffer utility functions */2829static inline int ivtv_might_use_pio(struct ivtv_stream *s)30{31return s->dma == PCI_DMA_NONE || (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI);32}3334static inline int ivtv_use_pio(struct ivtv_stream *s)35{36struct ivtv *itv = s->itv;3738return s->dma == PCI_DMA_NONE ||39(SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set);40}4142static inline int ivtv_might_use_dma(struct ivtv_stream *s)43{44return s->dma != PCI_DMA_NONE;45}4647static inline int ivtv_use_dma(struct ivtv_stream *s)48{49return !ivtv_use_pio(s);50}5152static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)53{54if (ivtv_use_dma(s))55pci_dma_sync_single_for_cpu(s->itv->pdev, buf->dma_handle,56s->buf_size + 256, s->dma);57}5859static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)60{61if (ivtv_use_dma(s))62pci_dma_sync_single_for_device(s->itv->pdev, buf->dma_handle,63s->buf_size + 256, s->dma);64}6566int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src, int copybytes);67void ivtv_buf_swap(struct ivtv_buffer *buf);6869/* ivtv_queue utility functions */70void ivtv_queue_init(struct ivtv_queue *q);71void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q);72struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q);73int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal,74struct ivtv_queue *to, int needed_bytes);75void ivtv_flush_queues(struct ivtv_stream *s);7677/* ivtv_stream utility functions */78int ivtv_stream_alloc(struct ivtv_stream *s);79void ivtv_stream_free(struct ivtv_stream *s);8081static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)82{83if (ivtv_use_dma(s))84pci_dma_sync_single_for_cpu(s->itv->pdev, s->sg_handle,85sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);86}8788static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)89{90if (ivtv_use_dma(s))91pci_dma_sync_single_for_device(s->itv->pdev, s->sg_handle,92sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);93}9495#endif969798