PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / media / platform / vsp1 / vsp1_video.h
blobd8612a378345e27f540c47be9e49db51186f234b
1 /*
2 * vsp1_video.h -- R-Car VSP1 Video Node
4 * Copyright (C) 2013 Renesas Corporation
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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.
13 #ifndef __VSP1_VIDEO_H__
14 #define __VSP1_VIDEO_H__
16 #include <linux/list.h>
17 #include <linux/spinlock.h>
18 #include <linux/wait.h>
20 #include <media/media-entity.h>
21 #include <media/videobuf2-core.h>
23 struct vsp1_video;
26 * struct vsp1_format_info - VSP1 video format description
27 * @mbus: media bus format code
28 * @fourcc: V4L2 pixel format FCC identifier
29 * @planes: number of planes
30 * @bpp: bits per pixel
31 * @hwfmt: VSP1 hardware format
32 * @swap_yc: the Y and C components are swapped (Y comes before C)
33 * @swap_uv: the U and V components are swapped (V comes before U)
34 * @hsub: horizontal subsampling factor
35 * @vsub: vertical subsampling factor
37 struct vsp1_format_info {
38 u32 fourcc;
39 unsigned int mbus;
40 unsigned int hwfmt;
41 unsigned int swap;
42 unsigned int planes;
43 unsigned int bpp[3];
44 bool swap_yc;
45 bool swap_uv;
46 unsigned int hsub;
47 unsigned int vsub;
50 enum vsp1_pipeline_state {
51 VSP1_PIPELINE_STOPPED,
52 VSP1_PIPELINE_RUNNING,
53 VSP1_PIPELINE_STOPPING,
57 * struct vsp1_pipeline - A VSP1 hardware pipeline
58 * @media: the media pipeline
59 * @irqlock: protects the pipeline state
60 * @lock: protects the pipeline use count and stream count
62 struct vsp1_pipeline {
63 struct media_pipeline pipe;
65 spinlock_t irqlock;
66 enum vsp1_pipeline_state state;
67 wait_queue_head_t wq;
69 struct mutex lock;
70 unsigned int use_count;
71 unsigned int stream_count;
72 unsigned int buffers_ready;
74 unsigned int num_video;
75 unsigned int num_inputs;
76 struct vsp1_rwpf *inputs[VPS1_MAX_RPF];
77 struct vsp1_rwpf *output;
78 struct vsp1_entity *lif;
80 struct list_head entities;
83 static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
85 if (likely(e->pipe))
86 return container_of(e->pipe, struct vsp1_pipeline, pipe);
87 else
88 return NULL;
91 struct vsp1_video_buffer {
92 struct vsp1_video *video;
93 struct vb2_buffer buf;
94 struct list_head queue;
96 dma_addr_t addr[3];
97 unsigned int length[3];
100 static inline struct vsp1_video_buffer *
101 to_vsp1_video_buffer(struct vb2_buffer *vb)
103 return container_of(vb, struct vsp1_video_buffer, buf);
106 struct vsp1_video_operations {
107 void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
110 struct vsp1_video {
111 struct vsp1_device *vsp1;
112 struct vsp1_entity *rwpf;
114 const struct vsp1_video_operations *ops;
116 struct video_device video;
117 enum v4l2_buf_type type;
118 struct media_pad pad;
120 struct mutex lock;
121 struct v4l2_pix_format_mplane format;
122 const struct vsp1_format_info *fmtinfo;
124 struct vsp1_pipeline pipe;
125 unsigned int pipe_index;
127 struct vb2_queue queue;
128 void *alloc_ctx;
129 spinlock_t irqlock;
130 struct list_head irqqueue;
131 unsigned int sequence;
134 static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
136 return container_of(vdev, struct vsp1_video, video);
139 int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
140 void vsp1_video_cleanup(struct vsp1_video *video);
142 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
144 #endif /* __VSP1_VIDEO_H__ */