]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/platform/vsp1/vsp1_pipe.h
Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
[karo-tx-linux.git] / drivers / media / platform / vsp1 / vsp1_pipe.h
1 /*
2  * vsp1_pipe.h  --  R-Car VSP1 Pipeline
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_PIPE_H__
14 #define __VSP1_PIPE_H__
15
16 #include <linux/kref.h>
17 #include <linux/list.h>
18 #include <linux/spinlock.h>
19 #include <linux/wait.h>
20
21 #include <media/media-entity.h>
22
23 struct vsp1_dl_list;
24 struct vsp1_rwpf;
25
26 /*
27  * struct vsp1_format_info - VSP1 video format description
28  * @fourcc: V4L2 pixel format FCC identifier
29  * @mbus: media bus format code
30  * @hwfmt: VSP1 hardware format
31  * @swap: swap register control
32  * @planes: number of planes
33  * @bpp: bits per pixel
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
38  * @alpha: has an alpha channel
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;
51         bool alpha;
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  * @pipe: the media pipeline
63  * @irqlock: protects the pipeline state
64  * @state: current state
65  * @wq: wait queue to wait for state change completion
66  * @frame_end: frame end interrupt handler
67  * @lock: protects the pipeline use count and stream count
68  * @kref: pipeline reference count
69  * @stream_count: number of streaming video nodes
70  * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
71  * @sequence: frame sequence number
72  * @num_inputs: number of RPFs
73  * @inputs: array of RPFs in the pipeline (indexed by RPF index)
74  * @output: WPF at the output of the pipeline
75  * @bru: BRU entity, if present
76  * @hgo: HGO entity, if present
77  * @hgt: HGT entity, if present
78  * @lif: LIF entity, if present
79  * @uds: UDS entity, if present
80  * @uds_input: entity at the input of the UDS, if the UDS is present
81  * @entities: list of entities in the pipeline
82  * @dl: display list associated with the pipeline
83  * @div_size: The maximum allowed partition size for the pipeline
84  * @partitions: The number of partitions used to process one frame
85  * @current_partition: The partition number currently being configured
86  */
87 struct vsp1_pipeline {
88         struct media_pipeline pipe;
89
90         spinlock_t irqlock;
91         enum vsp1_pipeline_state state;
92         wait_queue_head_t wq;
93
94         void (*frame_end)(struct vsp1_pipeline *pipe);
95
96         struct mutex lock;
97         struct kref kref;
98         unsigned int stream_count;
99         unsigned int buffers_ready;
100         unsigned int sequence;
101
102         unsigned int num_inputs;
103         struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
104         struct vsp1_rwpf *output;
105         struct vsp1_entity *bru;
106         struct vsp1_entity *hgo;
107         struct vsp1_entity *hgt;
108         struct vsp1_entity *lif;
109         struct vsp1_entity *uds;
110         struct vsp1_entity *uds_input;
111
112         struct list_head entities;
113
114         struct vsp1_dl_list *dl;
115
116         unsigned int div_size;
117         unsigned int partitions;
118         struct v4l2_rect partition;
119         unsigned int current_partition;
120 };
121
122 void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
123 void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
124
125 void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
126 bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
127 int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
128 bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
129
130 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
131
132 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
133                                    struct vsp1_dl_list *dl, unsigned int alpha);
134
135 void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
136 void vsp1_pipelines_resume(struct vsp1_device *vsp1);
137
138 const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,
139                                                     u32 fourcc);
140
141 #endif /* __VSP1_PIPE_H__ */