0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef IVTV_QUEUE_H
0011 #define IVTV_QUEUE_H
0012
0013 #define IVTV_DMA_UNMAPPED ((u32) -1)
0014 #define SLICED_VBI_PIO 0
0015
0016
0017
0018 static inline int ivtv_might_use_pio(struct ivtv_stream *s)
0019 {
0020 return s->dma == DMA_NONE || (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI);
0021 }
0022
0023 static inline int ivtv_use_pio(struct ivtv_stream *s)
0024 {
0025 struct ivtv *itv = s->itv;
0026
0027 return s->dma == DMA_NONE ||
0028 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set);
0029 }
0030
0031 static inline int ivtv_might_use_dma(struct ivtv_stream *s)
0032 {
0033 return s->dma != DMA_NONE;
0034 }
0035
0036 static inline int ivtv_use_dma(struct ivtv_stream *s)
0037 {
0038 return !ivtv_use_pio(s);
0039 }
0040
0041 static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)
0042 {
0043 if (ivtv_use_dma(s))
0044 dma_sync_single_for_cpu(&s->itv->pdev->dev, buf->dma_handle,
0045 s->buf_size + 256, s->dma);
0046 }
0047
0048 static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)
0049 {
0050 if (ivtv_use_dma(s))
0051 dma_sync_single_for_device(&s->itv->pdev->dev,
0052 buf->dma_handle, s->buf_size + 256,
0053 s->dma);
0054 }
0055
0056 int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src, int copybytes);
0057 void ivtv_buf_swap(struct ivtv_buffer *buf);
0058
0059
0060 void ivtv_queue_init(struct ivtv_queue *q);
0061 void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q);
0062 struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q);
0063 int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal,
0064 struct ivtv_queue *to, int needed_bytes);
0065 void ivtv_flush_queues(struct ivtv_stream *s);
0066
0067
0068 int ivtv_stream_alloc(struct ivtv_stream *s);
0069 void ivtv_stream_free(struct ivtv_stream *s);
0070
0071 static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)
0072 {
0073 if (ivtv_use_dma(s))
0074 dma_sync_single_for_cpu(&s->itv->pdev->dev, s->sg_handle,
0075 sizeof(struct ivtv_sg_element),
0076 DMA_TO_DEVICE);
0077 }
0078
0079 static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)
0080 {
0081 if (ivtv_use_dma(s))
0082 dma_sync_single_for_device(&s->itv->pdev->dev, s->sg_handle,
0083 sizeof(struct ivtv_sg_element),
0084 DMA_TO_DEVICE);
0085 }
0086
0087 #endif