]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - drivers/media/platform/xilinx/xilinx-dma.h
xilinx: v4l2: dma: Add multiple output support
[zynq/linux.git] / drivers / media / platform / xilinx / xilinx-dma.h
1 /*
2  * Xilinx Video DMA
3  *
4  * Copyright (C) 2013-2015 Ideas on Board
5  * Copyright (C) 2013-2015 Xilinx, Inc.
6  *
7  * Contacts: Hyun Kwon <hyun.kwon@xilinx.com>
8  *           Laurent Pinchart <laurent.pinchart@ideasonboard.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #ifndef __XILINX_VIP_DMA_H__
16 #define __XILINX_VIP_DMA_H__
17
18 #include <linux/dmaengine.h>
19 #include <linux/mutex.h>
20 #include <linux/spinlock.h>
21 #include <linux/videodev2.h>
22
23 #include <media/media-entity.h>
24 #include <media/v4l2-dev.h>
25 #include <media/videobuf2-v4l2.h>
26
27 struct dma_chan;
28 struct xvip_composite_device;
29 struct xvip_video_format;
30
31 /**
32  * struct xvip_pipeline - Xilinx Video IP pipeline structure
33  * @pipe: media pipeline
34  * @lock: protects the pipeline @stream_count
35  * @use_count: number of DMA engines using the pipeline
36  * @stream_count: number of DMA engines currently streaming
37  * @num_dmas: number of DMA engines in the pipeline
38  * @xdev: Composite device the pipe belongs to
39  */
40 struct xvip_pipeline {
41         struct media_pipeline pipe;
42
43         struct mutex lock;
44         unsigned int use_count;
45         unsigned int stream_count;
46
47         unsigned int num_dmas;
48         struct xvip_composite_device *xdev;
49 };
50
51 static inline struct xvip_pipeline *to_xvip_pipeline(struct media_entity *e)
52 {
53         return container_of(e->pipe, struct xvip_pipeline, pipe);
54 }
55
56 /**
57  * struct xvip_dma - Video DMA channel
58  * @list: list entry in a composite device dmas list
59  * @video: V4L2 video device associated with the DMA channel
60  * @pad: media pad for the video device entity
61  * @remote_subdev_med_bus: media bus format of sub-device
62  * @xdev: composite device the DMA channel belongs to
63  * @pipe: pipeline belonging to the DMA channel
64  * @port: composite device DT node port number for the DMA channel
65  * @lock: protects the @format, @fmtinfo and @queue fields
66  * @format: active V4L2 pixel format
67  * @fmtinfo: format information corresponding to the active @format
68  * @poss_v4l2_fmts: All possible v4l formats supported
69  * @poss_v4l2_fmt_cnt: number of supported v4l formats
70  * @queue: vb2 buffers queue
71  * @sequence: V4L2 buffers sequence number
72  * @queued_bufs: list of queued buffers
73  * @queued_lock: protects the buf_queued list
74  * @dma: DMA engine channel
75  * @align: transfer alignment required by the DMA channel (in bytes)
76  * @xt: dma interleaved template for dma configuration
77  * @sgl: data chunk structure for dma_interleaved_template
78  * @prev_fid: Previous Field ID
79  */
80 struct xvip_dma {
81         struct list_head list;
82         struct video_device video;
83         struct media_pad pad;
84         u32 remote_subdev_med_bus;
85
86         struct xvip_composite_device *xdev;
87         struct xvip_pipeline pipe;
88         unsigned int port;
89
90         struct mutex lock;
91         struct v4l2_format format;
92         const struct xvip_video_format *fmtinfo;
93         u32 *poss_v4l2_fmts;
94         u32 poss_v4l2_fmt_cnt;
95
96         struct vb2_queue queue;
97         unsigned int sequence;
98
99         struct list_head queued_bufs;
100         spinlock_t queued_lock;
101
102         struct dma_chan *dma;
103         unsigned int align;
104         struct dma_interleaved_template xt;
105         struct data_chunk sgl[1];
106
107         u32 prev_fid;
108 };
109
110 #define to_xvip_dma(vdev)       container_of(vdev, struct xvip_dma, video)
111
112 int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
113                   enum v4l2_buf_type type, unsigned int port);
114 void xvip_dma_cleanup(struct xvip_dma *dma);
115
116 #endif /* __XILINX_VIP_DMA_H__ */