xref: /linux/include/media/vsp1.h (revision a61e26038143727d9b0f1bc01b0370f77f2ad7e4)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * vsp1.h  --  R-Car VSP1 API
4  *
5  * Copyright (C) 2015 Renesas Electronics Corporation
6  *
7  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8  */
9 #ifndef __MEDIA_VSP1_H__
10 #define __MEDIA_VSP1_H__
11 
12 #include <linux/scatterlist.h>
13 #include <linux/types.h>
14 #include <linux/videodev2.h>
15 
16 struct device;
17 
18 int vsp1_du_init(struct device *dev);
19 
20 #define VSP1_DU_STATUS_COMPLETE		BIT(0)
21 #define VSP1_DU_STATUS_WRITEBACK	BIT(1)
22 
23 /**
24  * struct vsp1_du_lif_config - VSP LIF configuration
25  * @width: output frame width
26  * @height: output frame height
27  * @interlaced: true for interlaced pipelines
28  * @callback: frame completion callback function (optional). When a callback
29  *	      is provided, the VSP driver guarantees that it will be called once
30  *	      and only once for each vsp1_du_atomic_flush() call.
31  * @callback_data: data to be passed to the frame completion callback
32  */
33 struct vsp1_du_lif_config {
34 	unsigned int width;
35 	unsigned int height;
36 	bool interlaced;
37 
38 	void (*callback)(void *data, unsigned int status, u32 crc);
39 	void *callback_data;
40 };
41 
42 int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
43 		      const struct vsp1_du_lif_config *cfg);
44 
45 /**
46  * struct vsp1_du_atomic_config - VSP atomic configuration parameters
47  * @pixelformat: plane pixel format (V4L2 4CC)
48  * @pitch: line pitch in bytes for the first plane
49  * @mem: DMA memory address for each plane of the frame buffer
50  * @src: source rectangle in the frame buffer (integer coordinates)
51  * @dst: destination rectangle on the display (integer coordinates)
52  * @alpha: alpha value (0: fully transparent, 255: fully opaque)
53  * @zpos: Z position of the plane (from 0 to number of planes minus 1)
54  * @premult: true for premultiplied alpha
55  * @color_encoding: color encoding (valid for YUV formats only)
56  * @color_range: color range (valid for YUV formats only)
57  */
58 struct vsp1_du_atomic_config {
59 	u32 pixelformat;
60 	unsigned int pitch;
61 	dma_addr_t mem[3];
62 	struct v4l2_rect src;
63 	struct v4l2_rect dst;
64 	unsigned int alpha;
65 	unsigned int zpos;
66 	bool premult;
67 	enum v4l2_ycbcr_encoding color_encoding;
68 	enum v4l2_quantization color_range;
69 };
70 
71 /**
72  * enum vsp1_du_crc_source - Source used for CRC calculation
73  * @VSP1_DU_CRC_NONE: CRC calculation disabled
74  * @VSP1_DU_CRC_PLANE: Perform CRC calculation on an input plane
75  * @VSP1_DU_CRC_OUTPUT: Perform CRC calculation on the composed output
76  */
77 enum vsp1_du_crc_source {
78 	VSP1_DU_CRC_NONE,
79 	VSP1_DU_CRC_PLANE,
80 	VSP1_DU_CRC_OUTPUT,
81 };
82 
83 /**
84  * struct vsp1_du_crc_config - VSP CRC computation configuration parameters
85  * @source: source for CRC calculation
86  * @index: index of the CRC source plane (when source is set to plane)
87  */
88 struct vsp1_du_crc_config {
89 	enum vsp1_du_crc_source source;
90 	unsigned int index;
91 };
92 
93 /**
94  * struct vsp1_du_writeback_config - VSP writeback configuration parameters
95  * @pixelformat: plane pixel format (V4L2 4CC)
96  * @pitch: line pitch in bytes for the first plane
97  * @mem: DMA memory address for each plane of the frame buffer
98  */
99 struct vsp1_du_writeback_config {
100 	u32 pixelformat;
101 	unsigned int pitch;
102 	dma_addr_t mem[3];
103 };
104 
105 /**
106  * struct vsp1_du_atomic_pipe_config - VSP atomic pipe configuration parameters
107  * @crc: CRC computation configuration
108  * @writeback: writeback configuration
109  */
110 struct vsp1_du_atomic_pipe_config {
111 	struct vsp1_du_crc_config crc;
112 	struct vsp1_du_writeback_config writeback;
113 };
114 
115 void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index);
116 int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
117 			  unsigned int rpf,
118 			  const struct vsp1_du_atomic_config *cfg);
119 void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
120 			  const struct vsp1_du_atomic_pipe_config *cfg);
121 int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt);
122 void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt);
123 
124 #endif /* __MEDIA_VSP1_H__ */
125