| 1 |
|
| 2 | |
| 3 | * vsp1.h -- R-Car VSP1 API
|
| 4 | *
|
| 5 | * Copyright (C) 2015 Renesas Electronics Corporation
|
| 6 | *
|
| 7 | * Contact: Laurent Pinchart ([email protected])
|
| 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 | struct vsp1_dl_list;
|
| 18 |
|
| 19 | |
| 20 | * VSP1 DU interface
|
| 21 |
|
| 22 |
|
| 23 | int vsp1_du_init(struct device *dev);
|
| 24 |
|
| 25 | #define VSP1_DU_STATUS_COMPLETE BIT(0)
|
| 26 | #define VSP1_DU_STATUS_WRITEBACK BIT(1)
|
| 27 |
|
| 28 | |
| 29 | * struct vsp1_du_lif_config - VSP LIF configuration
|
| 30 | * @width: output frame width
|
| 31 | * @height: output frame height
|
| 32 | * @interlaced: true for interlaced pipelines
|
| 33 | * @callback: frame completion callback function (optional). When a callback
|
| 34 | * is provided, the VSP driver guarantees that it will be called once
|
| 35 | * and only once for each vsp1_du_atomic_flush() call.
|
| 36 | * @callback_data: data to be passed to the frame completion callback
|
| 37 |
|
| 38 | struct vsp1_du_lif_config {
|
| 39 | unsigned int width;
|
| 40 | unsigned int height;
|
| 41 | bool interlaced;
|
| 42 |
|
| 43 | void (*callback)(void *data, unsigned int status, u32 crc);
|
| 44 | void *callback_data;
|
| 45 | };
|
| 46 |
|
| 47 | int vsp1_du_enable(struct device *dev, unsigned int pipe_index,
|
| 48 | const struct vsp1_du_lif_config *cfg);
|
| 49 | int vsp1_du_disable(struct device *dev, unsigned int pipe_index);
|
| 50 |
|
| 51 | |
| 52 | * struct vsp1_du_atomic_config - VSP atomic configuration parameters
|
| 53 | * @pixelformat: plane pixel format (V4L2 4CC)
|
| 54 | * @pitch: line pitch in bytes for the first plane
|
| 55 | * @mem: DMA memory address for each plane of the frame buffer
|
| 56 | * @src: source rectangle in the frame buffer (integer coordinates)
|
| 57 | * @dst: destination rectangle on the display (integer coordinates)
|
| 58 | * @alpha: alpha value (0: fully transparent, 255: fully opaque)
|
| 59 | * @zpos: Z position of the plane (from 0 to number of planes minus 1)
|
| 60 | * @premult: true for premultiplied alpha
|
| 61 | * @color_encoding: color encoding (valid for YUV formats only)
|
| 62 | * @color_range: color range (valid for YUV formats only)
|
| 63 |
|
| 64 | struct vsp1_du_atomic_config {
|
| 65 | u32 pixelformat;
|
| 66 | unsigned int pitch;
|
| 67 | dma_addr_t mem[3];
|
| 68 | struct v4l2_rect src;
|
| 69 | struct v4l2_rect dst;
|
| 70 | unsigned int alpha;
|
| 71 | unsigned int zpos;
|
| 72 | bool premult;
|
| 73 | enum v4l2_ycbcr_encoding color_encoding;
|
| 74 | enum v4l2_quantization color_range;
|
| 75 | };
|
| 76 |
|
| 77 | |
| 78 | * enum vsp1_du_crc_source - Source used for CRC calculation
|
| 79 | * @VSP1_DU_CRC_NONE: CRC calculation disabled
|
| 80 | * @VSP1_DU_CRC_PLANE: Perform CRC calculation on an input plane
|
| 81 | * @VSP1_DU_CRC_OUTPUT: Perform CRC calculation on the composed output
|
| 82 |
|
| 83 | enum vsp1_du_crc_source {
|
| 84 | VSP1_DU_CRC_NONE,
|
| 85 | VSP1_DU_CRC_PLANE,
|
| 86 | VSP1_DU_CRC_OUTPUT,
|
| 87 | };
|
| 88 |
|
| 89 | |
| 90 | * struct vsp1_du_crc_config - VSP CRC computation configuration parameters
|
| 91 | * @source: source for CRC calculation
|
| 92 | * @index: index of the CRC source plane (when source is set to plane)
|
| 93 |
|
| 94 | struct vsp1_du_crc_config {
|
| 95 | enum vsp1_du_crc_source source;
|
| 96 | unsigned int index;
|
| 97 | };
|
| 98 |
|
| 99 | |
| 100 | * struct vsp1_du_writeback_config - VSP writeback configuration parameters
|
| 101 | * @pixelformat: plane pixel format (V4L2 4CC)
|
| 102 | * @pitch: line pitch in bytes for the first plane
|
| 103 | * @mem: DMA memory address for each plane of the frame buffer
|
| 104 |
|
| 105 | struct vsp1_du_writeback_config {
|
| 106 | u32 pixelformat;
|
| 107 | unsigned int pitch;
|
| 108 | dma_addr_t mem[3];
|
| 109 | };
|
| 110 |
|
| 111 | |
| 112 | * struct vsp1_du_atomic_pipe_config - VSP atomic pipe configuration parameters
|
| 113 | * @crc: CRC computation configuration
|
| 114 | * @writeback: writeback configuration
|
| 115 |
|
| 116 | struct vsp1_du_atomic_pipe_config {
|
| 117 | struct vsp1_du_crc_config crc;
|
| 118 | struct vsp1_du_writeback_config writeback;
|
| 119 | };
|
| 120 |
|
| 121 | void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index);
|
| 122 | int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
|
| 123 | unsigned int rpf,
|
| 124 | const struct vsp1_du_atomic_config *cfg);
|
| 125 | void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
|
| 126 | const struct vsp1_du_atomic_pipe_config *cfg);
|
| 127 | int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt);
|
| 128 | void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt);
|
| 129 |
|
| 130 | |
| 131 | * VSP1 ISP interface
|
| 132 |
|
| 133 |
|
| 134 | |
| 135 | * struct vsp1_isp_buffer_desc - Describe a buffer allocated by VSPX
|
| 136 | * @size: Byte size of the buffer allocated by VSPX
|
| 137 | * @cpu_addr: CPU-mapped address of a buffer allocated by VSPX
|
| 138 | * @dma_addr: bus address of a buffer allocated by VSPX
|
| 139 |
|
| 140 | struct vsp1_isp_buffer_desc {
|
| 141 | size_t size;
|
| 142 | void *cpu_addr;
|
| 143 | dma_addr_t dma_addr;
|
| 144 | };
|
| 145 |
|
| 146 | |
| 147 | * struct vsp1_isp_job_desc - Describe a VSPX buffer transfer request
|
| 148 | * @config: ConfigDMA buffer descriptor
|
| 149 | * @config.pairs: number of reg-value pairs in the ConfigDMA buffer
|
| 150 | * @config.mem: bus address of the ConfigDMA buffer
|
| 151 | * @img: RAW image buffer descriptor
|
| 152 | * @img.fmt: RAW image format
|
| 153 | * @img.mem: bus address of the RAW image buffer
|
| 154 | * @dl: pointer to the display list populated by the VSPX driver in the
|
| 155 | * vsp1_isp_job_prepare() function
|
| 156 | *
|
| 157 | * Describe a transfer request for the VSPX to perform on behalf of the ISP.
|
| 158 | * The job descriptor contains an optional ConfigDMA buffer and one RAW image
|
| 159 | * buffer. Set config.pairs to 0 if no ConfigDMA buffer should be transferred.
|
| 160 | * The minimum number of config.pairs that can be written using ConfigDMA is 17.
|
| 161 | * A number of pairs < 16 corrupts the output image. A number of pairs == 16
|
| 162 | * freezes the VSPX operation. If the ISP driver has to write less than 17 pairs
|
| 163 | * it shall pad the buffer with writes directed to registers that have no effect
|
| 164 | * or avoid using ConfigDMA at all for such small write sequences.
|
| 165 | *
|
| 166 | * The ISP driver shall pass an instance this type to the vsp1_isp_job_prepare()
|
| 167 | * function that will populate the display list pointer @dl using the @config
|
| 168 | * and @img descriptors. When the job has to be run on the VSPX, the descriptor
|
| 169 | * shall be passed to vsp1_isp_job_run() which consumes the display list.
|
| 170 | *
|
| 171 | * Job descriptors not yet run shall be released with a call to
|
| 172 | * vsp1_isp_job_release() when stopping the streaming in order to properly
|
| 173 | * release the resources acquired by vsp1_isp_job_prepare().
|
| 174 |
|
| 175 | struct vsp1_isp_job_desc {
|
| 176 | struct {
|
| 177 | unsigned int pairs;
|
| 178 | dma_addr_t mem;
|
| 179 | } config;
|
| 180 | struct {
|
| 181 | struct v4l2_pix_format_mplane fmt;
|
| 182 | dma_addr_t mem;
|
| 183 | } img;
|
| 184 | struct vsp1_dl_list *dl;
|
| 185 | };
|
| 186 |
|
| 187 | |
| 188 | * struct vsp1_vspx_frame_end - VSPX frame end callback data
|
| 189 | * @vspx_frame_end: Frame end callback. Called after a transfer job has been
|
| 190 | * completed. If the job includes both a ConfigDMA and a
|
| 191 | * RAW image, the callback is called after both have been
|
| 192 | * transferred
|
| 193 | * @frame_end_data: Frame end callback data, passed to vspx_frame_end
|
| 194 |
|
| 195 | struct vsp1_vspx_frame_end {
|
| 196 | void (*vspx_frame_end)(void *data);
|
| 197 | void *frame_end_data;
|
| 198 | };
|
| 199 |
|
| 200 | int vsp1_isp_init(struct device *dev);
|
| 201 | struct device *vsp1_isp_get_bus_master(struct device *dev);
|
| 202 | int vsp1_isp_alloc_buffer(struct device *dev, size_t size,
|
| 203 | struct vsp1_isp_buffer_desc *buffer_desc);
|
| 204 | void vsp1_isp_free_buffer(struct device *dev,
|
| 205 | struct vsp1_isp_buffer_desc *buffer_desc);
|
| 206 | int vsp1_isp_start_streaming(struct device *dev,
|
| 207 | struct vsp1_vspx_frame_end *frame_end);
|
| 208 | void vsp1_isp_stop_streaming(struct device *dev);
|
| 209 | int vsp1_isp_job_prepare(struct device *dev,
|
| 210 | struct vsp1_isp_job_desc *job);
|
| 211 | int vsp1_isp_job_run(struct device *dev, struct vsp1_isp_job_desc *job);
|
| 212 | void vsp1_isp_job_release(struct device *dev, struct vsp1_isp_job_desc *job);
|
| 213 |
|
| 214 | #endif
|