[media] v4l: vsp1: Move video operations to vsp1_rwpf
[deliverable/linux.git] / drivers / media / platform / vsp1 / vsp1_video.h
1 /*
2 * vsp1_video.h -- R-Car VSP1 Video Node
3 *
4 * Copyright (C) 2013-2015 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13 #ifndef __VSP1_VIDEO_H__
14 #define __VSP1_VIDEO_H__
15
16 #include <linux/list.h>
17 #include <linux/spinlock.h>
18 #include <linux/wait.h>
19
20 #include <media/media-entity.h>
21 #include <media/videobuf2-v4l2.h>
22
23 struct vsp1_rwpf;
24 struct vsp1_video;
25
26 /*
27 * struct vsp1_format_info - VSP1 video format description
28 * @mbus: media bus format code
29 * @fourcc: V4L2 pixel format FCC identifier
30 * @planes: number of planes
31 * @bpp: bits per pixel
32 * @hwfmt: VSP1 hardware format
33 * @swap_yc: the Y and C components are swapped (Y comes before C)
34 * @swap_uv: the U and V components are swapped (V comes before U)
35 * @hsub: horizontal subsampling factor
36 * @vsub: vertical subsampling factor
37 * @alpha: has an alpha channel
38 */
39 struct vsp1_format_info {
40 u32 fourcc;
41 unsigned int mbus;
42 unsigned int hwfmt;
43 unsigned int swap;
44 unsigned int planes;
45 unsigned int bpp[3];
46 bool swap_yc;
47 bool swap_uv;
48 unsigned int hsub;
49 unsigned int vsub;
50 bool alpha;
51 };
52
53 enum vsp1_pipeline_state {
54 VSP1_PIPELINE_STOPPED,
55 VSP1_PIPELINE_RUNNING,
56 VSP1_PIPELINE_STOPPING,
57 };
58
59 /*
60 * struct vsp1_pipeline - A VSP1 hardware pipeline
61 * @media: the media pipeline
62 * @irqlock: protects the pipeline state
63 * @lock: protects the pipeline use count and stream count
64 */
65 struct vsp1_pipeline {
66 struct media_pipeline pipe;
67
68 spinlock_t irqlock;
69 enum vsp1_pipeline_state state;
70 wait_queue_head_t wq;
71
72 struct mutex lock;
73 unsigned int use_count;
74 unsigned int stream_count;
75 unsigned int buffers_ready;
76
77 unsigned int num_video;
78 unsigned int num_inputs;
79 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
80 struct vsp1_rwpf *output;
81 struct vsp1_entity *bru;
82 struct vsp1_entity *lif;
83 struct vsp1_entity *uds;
84 struct vsp1_entity *uds_input;
85
86 struct list_head entities;
87 };
88
89 static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
90 {
91 if (likely(e->pipe))
92 return container_of(e->pipe, struct vsp1_pipeline, pipe);
93 else
94 return NULL;
95 }
96
97 struct vsp1_video_buffer {
98 struct vb2_v4l2_buffer buf;
99 struct list_head queue;
100
101 dma_addr_t addr[3];
102 unsigned int length[3];
103 };
104
105 static inline struct vsp1_video_buffer *
106 to_vsp1_video_buffer(struct vb2_v4l2_buffer *vbuf)
107 {
108 return container_of(vbuf, struct vsp1_video_buffer, buf);
109 }
110
111 struct vsp1_video {
112 struct vsp1_device *vsp1;
113 struct vsp1_rwpf *rwpf;
114
115 struct video_device video;
116 enum v4l2_buf_type type;
117 struct media_pad pad;
118
119 struct mutex lock;
120
121 struct vsp1_pipeline pipe;
122 unsigned int pipe_index;
123
124 struct vb2_queue queue;
125 void *alloc_ctx;
126 spinlock_t irqlock;
127 struct list_head irqqueue;
128 unsigned int sequence;
129 };
130
131 static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
132 {
133 return container_of(vdev, struct vsp1_video, video);
134 }
135
136 int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf);
137 void vsp1_video_cleanup(struct vsp1_video *video);
138
139 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
140
141 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
142 struct vsp1_entity *input,
143 unsigned int alpha);
144
145 void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
146 void vsp1_pipelines_resume(struct vsp1_device *vsp1);
147
148 #endif /* __VSP1_VIDEO_H__ */
This page took 0.045612 seconds and 5 git commands to generate.