xref: /kernel/linux/linux-5.10/include/media/vsp1.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * vsp1.h  --  R-Car VSP1 API
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2015 Renesas Electronics Corporation
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef __MEDIA_VSP1_H__
108c2ecf20Sopenharmony_ci#define __MEDIA_VSP1_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/scatterlist.h>
138c2ecf20Sopenharmony_ci#include <linux/types.h>
148c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cistruct device;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciint vsp1_du_init(struct device *dev);
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define VSP1_DU_STATUS_COMPLETE		BIT(0)
218c2ecf20Sopenharmony_ci#define VSP1_DU_STATUS_WRITEBACK	BIT(1)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/**
248c2ecf20Sopenharmony_ci * struct vsp1_du_lif_config - VSP LIF configuration
258c2ecf20Sopenharmony_ci * @width: output frame width
268c2ecf20Sopenharmony_ci * @height: output frame height
278c2ecf20Sopenharmony_ci * @interlaced: true for interlaced pipelines
288c2ecf20Sopenharmony_ci * @callback: frame completion callback function (optional). When a callback
298c2ecf20Sopenharmony_ci *	      is provided, the VSP driver guarantees that it will be called once
308c2ecf20Sopenharmony_ci *	      and only once for each vsp1_du_atomic_flush() call.
318c2ecf20Sopenharmony_ci * @callback_data: data to be passed to the frame completion callback
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_cistruct vsp1_du_lif_config {
348c2ecf20Sopenharmony_ci	unsigned int width;
358c2ecf20Sopenharmony_ci	unsigned int height;
368c2ecf20Sopenharmony_ci	bool interlaced;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	void (*callback)(void *data, unsigned int status, u32 crc);
398c2ecf20Sopenharmony_ci	void *callback_data;
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciint vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
438c2ecf20Sopenharmony_ci		      const struct vsp1_du_lif_config *cfg);
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/**
468c2ecf20Sopenharmony_ci * struct vsp1_du_atomic_config - VSP atomic configuration parameters
478c2ecf20Sopenharmony_ci * @pixelformat: plane pixel format (V4L2 4CC)
488c2ecf20Sopenharmony_ci * @pitch: line pitch in bytes for the first plane
498c2ecf20Sopenharmony_ci * @mem: DMA memory address for each plane of the frame buffer
508c2ecf20Sopenharmony_ci * @src: source rectangle in the frame buffer (integer coordinates)
518c2ecf20Sopenharmony_ci * @dst: destination rectangle on the display (integer coordinates)
528c2ecf20Sopenharmony_ci * @alpha: alpha value (0: fully transparent, 255: fully opaque)
538c2ecf20Sopenharmony_ci * @zpos: Z position of the plane (from 0 to number of planes minus 1)
548c2ecf20Sopenharmony_ci */
558c2ecf20Sopenharmony_cistruct vsp1_du_atomic_config {
568c2ecf20Sopenharmony_ci	u32 pixelformat;
578c2ecf20Sopenharmony_ci	unsigned int pitch;
588c2ecf20Sopenharmony_ci	dma_addr_t mem[3];
598c2ecf20Sopenharmony_ci	struct v4l2_rect src;
608c2ecf20Sopenharmony_ci	struct v4l2_rect dst;
618c2ecf20Sopenharmony_ci	unsigned int alpha;
628c2ecf20Sopenharmony_ci	unsigned int zpos;
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/**
668c2ecf20Sopenharmony_ci * enum vsp1_du_crc_source - Source used for CRC calculation
678c2ecf20Sopenharmony_ci * @VSP1_DU_CRC_NONE: CRC calculation disabled
688c2ecf20Sopenharmony_ci * @VSP1_DU_CRC_PLANE: Perform CRC calculation on an input plane
698c2ecf20Sopenharmony_ci * @VSP1_DU_CRC_OUTPUT: Perform CRC calculation on the composed output
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_cienum vsp1_du_crc_source {
728c2ecf20Sopenharmony_ci	VSP1_DU_CRC_NONE,
738c2ecf20Sopenharmony_ci	VSP1_DU_CRC_PLANE,
748c2ecf20Sopenharmony_ci	VSP1_DU_CRC_OUTPUT,
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/**
788c2ecf20Sopenharmony_ci * struct vsp1_du_crc_config - VSP CRC computation configuration parameters
798c2ecf20Sopenharmony_ci * @source: source for CRC calculation
808c2ecf20Sopenharmony_ci * @index: index of the CRC source plane (when source is set to plane)
818c2ecf20Sopenharmony_ci */
828c2ecf20Sopenharmony_cistruct vsp1_du_crc_config {
838c2ecf20Sopenharmony_ci	enum vsp1_du_crc_source source;
848c2ecf20Sopenharmony_ci	unsigned int index;
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/**
888c2ecf20Sopenharmony_ci * struct vsp1_du_writeback_config - VSP writeback configuration parameters
898c2ecf20Sopenharmony_ci * @pixelformat: plane pixel format (V4L2 4CC)
908c2ecf20Sopenharmony_ci * @pitch: line pitch in bytes for the first plane
918c2ecf20Sopenharmony_ci * @mem: DMA memory address for each plane of the frame buffer
928c2ecf20Sopenharmony_ci */
938c2ecf20Sopenharmony_cistruct vsp1_du_writeback_config {
948c2ecf20Sopenharmony_ci	u32 pixelformat;
958c2ecf20Sopenharmony_ci	unsigned int pitch;
968c2ecf20Sopenharmony_ci	dma_addr_t mem[3];
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/**
1008c2ecf20Sopenharmony_ci * struct vsp1_du_atomic_pipe_config - VSP atomic pipe configuration parameters
1018c2ecf20Sopenharmony_ci * @crc: CRC computation configuration
1028c2ecf20Sopenharmony_ci * @writeback: writeback configuration
1038c2ecf20Sopenharmony_ci */
1048c2ecf20Sopenharmony_cistruct vsp1_du_atomic_pipe_config {
1058c2ecf20Sopenharmony_ci	struct vsp1_du_crc_config crc;
1068c2ecf20Sopenharmony_ci	struct vsp1_du_writeback_config writeback;
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_civoid vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index);
1108c2ecf20Sopenharmony_ciint vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
1118c2ecf20Sopenharmony_ci			  unsigned int rpf,
1128c2ecf20Sopenharmony_ci			  const struct vsp1_du_atomic_config *cfg);
1138c2ecf20Sopenharmony_civoid vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
1148c2ecf20Sopenharmony_ci			  const struct vsp1_du_atomic_pipe_config *cfg);
1158c2ecf20Sopenharmony_ciint vsp1_du_map_sg(struct device *dev, struct sg_table *sgt);
1168c2ecf20Sopenharmony_civoid vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt);
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#endif /* __MEDIA_VSP1_H__ */
119