Path: blob/master/drivers/media/video/cx18/cx18-queue.h
17621 views
/*1* cx18 buffer queues2*3* Derived from ivtv-queue.h4*5* Copyright (C) 2007 Hans Verkuil <[email protected]>6* Copyright (C) 2008 Andy Walls <[email protected]>7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (at your option) any later version.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA21* 02111-1307 USA22*/2324#define CX18_DMA_UNMAPPED ((u32) -1)2526/* cx18_buffer utility functions */2728static inline void cx18_buf_sync_for_cpu(struct cx18_stream *s,29struct cx18_buffer *buf)30{31pci_dma_sync_single_for_cpu(s->cx->pci_dev, buf->dma_handle,32s->buf_size, s->dma);33}3435static inline void cx18_buf_sync_for_device(struct cx18_stream *s,36struct cx18_buffer *buf)37{38pci_dma_sync_single_for_device(s->cx->pci_dev, buf->dma_handle,39s->buf_size, s->dma);40}4142void _cx18_mdl_sync_for_device(struct cx18_stream *s, struct cx18_mdl *mdl);4344static inline void cx18_mdl_sync_for_device(struct cx18_stream *s,45struct cx18_mdl *mdl)46{47if (list_is_singular(&mdl->buf_list))48cx18_buf_sync_for_device(s, list_first_entry(&mdl->buf_list,49struct cx18_buffer,50list));51else52_cx18_mdl_sync_for_device(s, mdl);53}5455void cx18_buf_swap(struct cx18_buffer *buf);56void _cx18_mdl_swap(struct cx18_mdl *mdl);5758static inline void cx18_mdl_swap(struct cx18_mdl *mdl)59{60if (list_is_singular(&mdl->buf_list))61cx18_buf_swap(list_first_entry(&mdl->buf_list,62struct cx18_buffer, list));63else64_cx18_mdl_swap(mdl);65}6667/* cx18_queue utility functions */68struct cx18_queue *_cx18_enqueue(struct cx18_stream *s, struct cx18_mdl *mdl,69struct cx18_queue *q, int to_front);7071static inline72struct cx18_queue *cx18_enqueue(struct cx18_stream *s, struct cx18_mdl *mdl,73struct cx18_queue *q)74{75return _cx18_enqueue(s, mdl, q, 0); /* FIFO */76}7778static inline79struct cx18_queue *cx18_push(struct cx18_stream *s, struct cx18_mdl *mdl,80struct cx18_queue *q)81{82return _cx18_enqueue(s, mdl, q, 1); /* LIFO */83}8485void cx18_queue_init(struct cx18_queue *q);86struct cx18_mdl *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q);87struct cx18_mdl *cx18_queue_get_mdl(struct cx18_stream *s, u32 id,88u32 bytesused);89void cx18_flush_queues(struct cx18_stream *s);9091/* queue MDL reconfiguration helpers */92void cx18_unload_queues(struct cx18_stream *s);93void cx18_load_queues(struct cx18_stream *s);9495/* cx18_stream utility functions */96int cx18_stream_alloc(struct cx18_stream *s);97void cx18_stream_free(struct cx18_stream *s);9899100