1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * vsp1_drm.h  --  R-Car VSP1 DRM/KMS Interface
4 *
5 * Copyright (C) 2015 Renesas Electronics Corporation
6 *
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8 */
9#ifndef __VSP1_DRM_H__
10#define __VSP1_DRM_H__
11
12#include <linux/mutex.h>
13#include <linux/videodev2.h>
14#include <linux/wait.h>
15
16#include <media/vsp1.h>
17
18#include "vsp1_pipe.h"
19
20/**
21 * struct vsp1_drm_pipeline - State for the API exposed to the DRM driver
22 * @pipe: the VSP1 pipeline used for display
23 * @width: output display width
24 * @height: output display height
25 * @force_brx_release: when set, release the BRx during the next reconfiguration
26 * @wait_queue: wait queue to wait for BRx release completion
27 * @uif: UIF entity if available for the pipeline
28 * @crc: CRC computation configuration
29 * @du_complete: frame completion callback for the DU driver (optional)
30 * @du_private: data to be passed to the du_complete callback
31 */
32struct vsp1_drm_pipeline {
33	struct vsp1_pipeline pipe;
34
35	unsigned int width;
36	unsigned int height;
37
38	bool force_brx_release;
39	wait_queue_head_t wait_queue;
40
41	struct vsp1_entity *uif;
42	struct vsp1_du_crc_config crc;
43
44	/* Frame synchronisation */
45	void (*du_complete)(void *data, unsigned int status, u32 crc);
46	void *du_private;
47};
48
49/**
50 * struct vsp1_drm - State for the API exposed to the DRM driver
51 * @pipe: the VSP1 DRM pipeline used for display
52 * @lock: protects the BRU and BRS allocation
53 * @inputs: source crop rectangle, destination compose rectangle and z-order
54 *	position for every input (indexed by RPF index)
55 */
56struct vsp1_drm {
57	struct vsp1_drm_pipeline pipe[VSP1_MAX_LIF];
58	struct mutex lock;
59
60	struct {
61		struct v4l2_rect crop;
62		struct v4l2_rect compose;
63		unsigned int zpos;
64	} inputs[VSP1_MAX_RPF];
65};
66
67static inline struct vsp1_drm_pipeline *
68to_vsp1_drm_pipeline(struct vsp1_pipeline *pipe)
69{
70	return container_of(pipe, struct vsp1_drm_pipeline, pipe);
71}
72
73int vsp1_drm_init(struct vsp1_device *vsp1);
74void vsp1_drm_cleanup(struct vsp1_device *vsp1);
75
76#endif /* __VSP1_DRM_H__ */
77