vsp1_entity.h 5.6 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0+ */
2 3 4
/*
 * vsp1_entity.h  --  R-Car VSP1 Base Entity
 *
5
 * Copyright (C) 2013-2014 Renesas Electronics Corporation
6 7 8 9 10 11 12
 *
 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
 */
#ifndef __VSP1_ENTITY_H__
#define __VSP1_ENTITY_H__

#include <linux/list.h>
13
#include <linux/mutex.h>
14 15 16 17

#include <media/v4l2-subdev.h>

struct vsp1_device;
18
struct vsp1_dl_list;
19
struct vsp1_pipeline;
20 21
struct vsp1_partition;
struct vsp1_partition_window;
22 23

enum vsp1_entity_type {
24
	VSP1_ENTITY_BRS,
25
	VSP1_ENTITY_BRU,
26
	VSP1_ENTITY_CLU,
27 28
	VSP1_ENTITY_HGO,
	VSP1_ENTITY_HGT,
29 30
	VSP1_ENTITY_HSI,
	VSP1_ENTITY_HST,
31
	VSP1_ENTITY_LIF,
32
	VSP1_ENTITY_LUT,
33
	VSP1_ENTITY_RPF,
34
	VSP1_ENTITY_SRU,
35
	VSP1_ENTITY_UDS,
36
	VSP1_ENTITY_UIF,
37 38 39
	VSP1_ENTITY_WPF,
};

40
/**
41 42
 * enum vsp1_entity_params - Entity configuration parameters class
 * @VSP1_ENTITY_PARAMS_INIT - Initial parameters
43
 * @VSP1_ENTITY_PARAMS_PARTITION - Per-image partition parameters
44 45 46 47
 * @VSP1_ENTITY_PARAMS_RUNTIME - Runtime-configurable parameters
 */
enum vsp1_entity_params {
	VSP1_ENTITY_PARAMS_INIT,
48
	VSP1_ENTITY_PARAMS_PARTITION,
49 50 51
	VSP1_ENTITY_PARAMS_RUNTIME,
};

52 53
#define VSP1_ENTITY_MAX_INPUTS		5	/* For the BRU */

54 55 56 57 58 59
/*
 * struct vsp1_route - Entity routing configuration
 * @type: Entity type this routing entry is associated with
 * @index: Entity index this routing entry is associated with
 * @reg: Output routing configuration register
 * @inputs: Target node value for each input
60
 * @output: Target node value for entity output
61 62 63 64
 *
 * Each $vsp1_route entry describes routing configuration for the entity
 * specified by the entry's @type and @index. @reg indicates the register that
 * holds output routing configuration for the entity, and the @inputs array
65 66 67
 * store the target node value for each input of the entity. The @output field
 * stores the target node value of the entity output when used as a source for
 * histogram generation.
68 69 70 71 72
 */
struct vsp1_route {
	enum vsp1_entity_type type;
	unsigned int index;
	unsigned int reg;
73
	unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
74
	unsigned int output;
75 76
};

77 78 79
/**
 * struct vsp1_entity_operations - Entity operations
 * @destroy:	Destroy the entity.
80 81
 * @configure:	Setup the hardware based on the entity state (pipeline, formats,
 *		selection rectangles, ...)
82 83
 * @max_width:	Return the max supported width of data that the entity can
 *		process in a single operation.
84 85
 * @partition:	Process the partition construction based on this entity's
 *		configuration.
86 87 88
 */
struct vsp1_entity_operations {
	void (*destroy)(struct vsp1_entity *);
89
	void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
90
			  struct vsp1_dl_list *, enum vsp1_entity_params);
91
	unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
92 93 94
	void (*partition)(struct vsp1_entity *, struct vsp1_pipeline *,
			  struct vsp1_partition *, unsigned int,
			  struct vsp1_partition_window *);
95 96
};

97 98 99
struct vsp1_entity {
	struct vsp1_device *vsp1;

100
	const struct vsp1_entity_operations *ops;
101

102 103
	enum vsp1_entity_type type;
	unsigned int index;
104
	const struct vsp1_route *route;
105

106 107
	struct vsp1_pipeline *pipe;

108 109 110 111 112 113
	struct list_head list_dev;
	struct list_head list_pipe;

	struct media_pad *pads;
	unsigned int source_pad;

114 115
	struct vsp1_entity **sources;
	struct vsp1_entity *sink;
116
	unsigned int sink_pad;
117 118

	struct v4l2_subdev subdev;
119
	struct v4l2_subdev_pad_config *config;
120 121

	struct mutex lock;	/* Protects the pad config */
122 123 124 125 126 127 128 129
};

static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
{
	return container_of(subdev, struct vsp1_entity, subdev);
}

int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
130
		     const char *name, unsigned int num_pads,
131
		     const struct v4l2_subdev_ops *ops, u32 function);
132 133 134
void vsp1_entity_destroy(struct vsp1_entity *entity);

extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
135 136 137 138

int vsp1_entity_link_setup(struct media_entity *entity,
			   const struct media_pad *local,
			   const struct media_pad *remote, u32 flags);
139

140 141 142 143
struct v4l2_subdev_pad_config *
vsp1_entity_get_pad_config(struct vsp1_entity *entity,
			   struct v4l2_subdev_pad_config *cfg,
			   enum v4l2_subdev_format_whence which);
144 145
struct v4l2_mbus_framefmt *
vsp1_entity_get_pad_format(struct vsp1_entity *entity,
146
			   struct v4l2_subdev_pad_config *cfg,
147
			   unsigned int pad);
148
struct v4l2_rect *
149 150 151
vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
			      struct v4l2_subdev_pad_config *cfg,
			      unsigned int pad, unsigned int target);
152 153
int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
			 struct v4l2_subdev_pad_config *cfg);
154

155 156
void vsp1_entity_route_setup(struct vsp1_entity *entity,
			     struct vsp1_pipeline *pipe,
157
			     struct vsp1_dl_list *dl);
158

159 160
struct media_pad *vsp1_entity_remote_pad(struct media_pad *pad);

161 162 163
int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
			       struct v4l2_subdev_pad_config *cfg,
			       struct v4l2_subdev_format *fmt);
164 165 166 167 168 169
int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
			       struct v4l2_subdev_pad_config *cfg,
			       struct v4l2_subdev_format *fmt,
			       const unsigned int *codes, unsigned int ncodes,
			       unsigned int min_width, unsigned int min_height,
			       unsigned int max_width, unsigned int max_height);
170 171 172 173
int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
			       struct v4l2_subdev_pad_config *cfg,
			       struct v4l2_subdev_mbus_code_enum *code,
			       const unsigned int *codes, unsigned int ncodes);
174 175 176 177 178
int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
				struct v4l2_subdev_pad_config *cfg,
				struct v4l2_subdev_frame_size_enum *fse,
				unsigned int min_w, unsigned int min_h,
				unsigned int max_w, unsigned int max_h);
179

180
#endif /* __VSP1_ENTITY_H__ */