Commit | Line | Data |
---|---|---|
26e0ca22 LP |
1 | /* |
2 | * vsp1_video.h -- R-Car VSP1 Video Node | |
3 | * | |
139c9286 | 4 | * Copyright (C) 2013-2015 Renesas Electronics Corporation |
26e0ca22 LP |
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> | |
c139990e | 21 | #include <media/videobuf2-v4l2.h> |
26e0ca22 | 22 | |
b58faa95 LP |
23 | #include "vsp1_rwpf.h" |
24 | ||
26e0ca22 LP |
25 | struct vsp1_video; |
26 | ||
27 | /* | |
28 | * struct vsp1_format_info - VSP1 video format description | |
29 | * @mbus: media bus format code | |
30 | * @fourcc: V4L2 pixel format FCC identifier | |
31 | * @planes: number of planes | |
32 | * @bpp: bits per pixel | |
33 | * @hwfmt: VSP1 hardware format | |
34 | * @swap_yc: the Y and C components are swapped (Y comes before C) | |
35 | * @swap_uv: the U and V components are swapped (V comes before U) | |
36 | * @hsub: horizontal subsampling factor | |
37 | * @vsub: vertical subsampling factor | |
7a52b6de | 38 | * @alpha: has an alpha channel |
26e0ca22 LP |
39 | */ |
40 | struct vsp1_format_info { | |
41 | u32 fourcc; | |
42 | unsigned int mbus; | |
43 | unsigned int hwfmt; | |
44 | unsigned int swap; | |
45 | unsigned int planes; | |
46 | unsigned int bpp[3]; | |
47 | bool swap_yc; | |
48 | bool swap_uv; | |
49 | unsigned int hsub; | |
50 | unsigned int vsub; | |
7a52b6de | 51 | bool alpha; |
26e0ca22 LP |
52 | }; |
53 | ||
54 | enum vsp1_pipeline_state { | |
55 | VSP1_PIPELINE_STOPPED, | |
56 | VSP1_PIPELINE_RUNNING, | |
57 | VSP1_PIPELINE_STOPPING, | |
58 | }; | |
59 | ||
60 | /* | |
61 | * struct vsp1_pipeline - A VSP1 hardware pipeline | |
62 | * @media: the media pipeline | |
63 | * @irqlock: protects the pipeline state | |
64 | * @lock: protects the pipeline use count and stream count | |
65 | */ | |
66 | struct vsp1_pipeline { | |
67 | struct media_pipeline pipe; | |
68 | ||
69 | spinlock_t irqlock; | |
70 | enum vsp1_pipeline_state state; | |
71 | wait_queue_head_t wq; | |
72 | ||
73 | struct mutex lock; | |
74 | unsigned int use_count; | |
75 | unsigned int stream_count; | |
76 | unsigned int buffers_ready; | |
77 | ||
26e0ca22 | 78 | unsigned int num_inputs; |
7005a817 | 79 | struct vsp1_rwpf *inputs[VSP1_MAX_RPF]; |
26e0ca22 | 80 | struct vsp1_rwpf *output; |
629bb6d4 | 81 | struct vsp1_entity *bru; |
26e0ca22 | 82 | struct vsp1_entity *lif; |
bdc2df62 LP |
83 | struct vsp1_entity *uds; |
84 | struct vsp1_entity *uds_input; | |
26e0ca22 LP |
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 | ||
f7ebf3ca | 97 | struct vsp1_vb2_buffer { |
2d700715 | 98 | struct vb2_v4l2_buffer buf; |
26e0ca22 | 99 | struct list_head queue; |
b58faa95 | 100 | struct vsp1_rwpf_memory mem; |
26e0ca22 LP |
101 | }; |
102 | ||
f7ebf3ca LP |
103 | static inline struct vsp1_vb2_buffer * |
104 | to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf) | |
26e0ca22 | 105 | { |
f7ebf3ca | 106 | return container_of(vbuf, struct vsp1_vb2_buffer, buf); |
26e0ca22 LP |
107 | } |
108 | ||
26e0ca22 | 109 | struct vsp1_video { |
9d40637a | 110 | struct list_head list; |
26e0ca22 | 111 | struct vsp1_device *vsp1; |
8b4a0563 | 112 | struct vsp1_rwpf *rwpf; |
26e0ca22 | 113 | |
26e0ca22 LP |
114 | struct video_device video; |
115 | enum v4l2_buf_type type; | |
116 | struct media_pad pad; | |
117 | ||
118 | struct mutex lock; | |
26e0ca22 LP |
119 | |
120 | struct vsp1_pipeline pipe; | |
121 | unsigned int pipe_index; | |
122 | ||
123 | struct vb2_queue queue; | |
124 | void *alloc_ctx; | |
125 | spinlock_t irqlock; | |
126 | struct list_head irqqueue; | |
127 | unsigned int sequence; | |
128 | }; | |
129 | ||
130 | static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev) | |
131 | { | |
132 | return container_of(vdev, struct vsp1_video, video); | |
133 | } | |
134 | ||
9d40637a LP |
135 | struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1, |
136 | struct vsp1_rwpf *rwpf); | |
26e0ca22 LP |
137 | void vsp1_video_cleanup(struct vsp1_video *video); |
138 | ||
139 | void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe); | |
140 | ||
bdc2df62 LP |
141 | void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, |
142 | struct vsp1_entity *input, | |
143 | unsigned int alpha); | |
144 | ||
139c9286 SF |
145 | void vsp1_pipelines_suspend(struct vsp1_device *vsp1); |
146 | void vsp1_pipelines_resume(struct vsp1_device *vsp1); | |
147 | ||
26e0ca22 | 148 | #endif /* __VSP1_VIDEO_H__ */ |