1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * vsp1_entity.h -- R-Car VSP1 Base Entity
5 * Copyright (C) 2013-2014 Renesas Electronics Corporation
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
9 #ifndef __VSP1_ENTITY_H__
10 #define __VSP1_ENTITY_H__
12 #include <linux/list.h>
13 #include <linux/mutex.h>
15 #include <media/v4l2-subdev.h>
21 struct vsp1_partition
;
22 struct vsp1_partition_window
;
24 enum vsp1_entity_type
{
41 #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
44 * struct vsp1_route - Entity routing configuration
45 * @type: Entity type this routing entry is associated with
46 * @index: Entity index this routing entry is associated with
47 * @reg: Output routing configuration register
48 * @inputs: Target node value for each input
49 * @output: Target node value for entity output
51 * Each $vsp1_route entry describes routing configuration for the entity
52 * specified by the entry's @type and @index. @reg indicates the register that
53 * holds output routing configuration for the entity, and the @inputs array
54 * store the target node value for each input of the entity. The @output field
55 * stores the target node value of the entity output when used as a source for
56 * histogram generation.
59 enum vsp1_entity_type type
;
62 unsigned int inputs
[VSP1_ENTITY_MAX_INPUTS
];
67 * struct vsp1_entity_operations - Entity operations
68 * @destroy: Destroy the entity.
69 * @configure_stream: Setup the hardware parameters for the stream which do
70 * not vary between frames (pipeline, formats).
71 * @configure_frame: Configure the runtime parameters for each frame.
72 * @configure_partition: Configure partition specific parameters.
73 * @max_width: Return the max supported width of data that the entity can
74 * process in a single operation.
75 * @partition: Process the partition construction based on this entity's
78 struct vsp1_entity_operations
{
79 void (*destroy
)(struct vsp1_entity
*);
80 void (*configure_stream
)(struct vsp1_entity
*, struct vsp1_pipeline
*,
81 struct vsp1_dl_body
*);
82 void (*configure_frame
)(struct vsp1_entity
*, struct vsp1_pipeline
*,
83 struct vsp1_dl_list
*, struct vsp1_dl_body
*);
84 void (*configure_partition
)(struct vsp1_entity
*,
85 struct vsp1_pipeline
*,
86 struct vsp1_dl_list
*,
87 struct vsp1_dl_body
*);
88 unsigned int (*max_width
)(struct vsp1_entity
*, struct vsp1_pipeline
*);
89 void (*partition
)(struct vsp1_entity
*, struct vsp1_pipeline
*,
90 struct vsp1_partition
*, unsigned int,
91 struct vsp1_partition_window
*);
95 struct vsp1_device
*vsp1
;
97 const struct vsp1_entity_operations
*ops
;
99 enum vsp1_entity_type type
;
101 const struct vsp1_route
*route
;
103 struct vsp1_pipeline
*pipe
;
105 struct list_head list_dev
;
106 struct list_head list_pipe
;
108 struct media_pad
*pads
;
109 unsigned int source_pad
;
111 struct vsp1_entity
**sources
;
112 struct vsp1_entity
*sink
;
113 unsigned int sink_pad
;
115 struct v4l2_subdev subdev
;
116 struct v4l2_subdev_pad_config
*config
;
118 struct mutex lock
; /* Protects the pad config */
121 static inline struct vsp1_entity
*to_vsp1_entity(struct v4l2_subdev
*subdev
)
123 return container_of(subdev
, struct vsp1_entity
, subdev
);
126 int vsp1_entity_init(struct vsp1_device
*vsp1
, struct vsp1_entity
*entity
,
127 const char *name
, unsigned int num_pads
,
128 const struct v4l2_subdev_ops
*ops
, u32 function
);
129 void vsp1_entity_destroy(struct vsp1_entity
*entity
);
131 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops
;
133 int vsp1_entity_link_setup(struct media_entity
*entity
,
134 const struct media_pad
*local
,
135 const struct media_pad
*remote
, u32 flags
);
137 struct v4l2_subdev_pad_config
*
138 vsp1_entity_get_pad_config(struct vsp1_entity
*entity
,
139 struct v4l2_subdev_pad_config
*cfg
,
140 enum v4l2_subdev_format_whence which
);
141 struct v4l2_mbus_framefmt
*
142 vsp1_entity_get_pad_format(struct vsp1_entity
*entity
,
143 struct v4l2_subdev_pad_config
*cfg
,
146 vsp1_entity_get_pad_selection(struct vsp1_entity
*entity
,
147 struct v4l2_subdev_pad_config
*cfg
,
148 unsigned int pad
, unsigned int target
);
149 int vsp1_entity_init_cfg(struct v4l2_subdev
*subdev
,
150 struct v4l2_subdev_pad_config
*cfg
);
152 void vsp1_entity_route_setup(struct vsp1_entity
*entity
,
153 struct vsp1_pipeline
*pipe
,
154 struct vsp1_dl_body
*dlb
);
156 void vsp1_entity_configure_stream(struct vsp1_entity
*entity
,
157 struct vsp1_pipeline
*pipe
,
158 struct vsp1_dl_body
*dlb
);
160 void vsp1_entity_configure_frame(struct vsp1_entity
*entity
,
161 struct vsp1_pipeline
*pipe
,
162 struct vsp1_dl_list
*dl
,
163 struct vsp1_dl_body
*dlb
);
165 void vsp1_entity_configure_partition(struct vsp1_entity
*entity
,
166 struct vsp1_pipeline
*pipe
,
167 struct vsp1_dl_list
*dl
,
168 struct vsp1_dl_body
*dlb
);
170 struct media_pad
*vsp1_entity_remote_pad(struct media_pad
*pad
);
172 int vsp1_subdev_get_pad_format(struct v4l2_subdev
*subdev
,
173 struct v4l2_subdev_pad_config
*cfg
,
174 struct v4l2_subdev_format
*fmt
);
175 int vsp1_subdev_set_pad_format(struct v4l2_subdev
*subdev
,
176 struct v4l2_subdev_pad_config
*cfg
,
177 struct v4l2_subdev_format
*fmt
,
178 const unsigned int *codes
, unsigned int ncodes
,
179 unsigned int min_width
, unsigned int min_height
,
180 unsigned int max_width
, unsigned int max_height
);
181 int vsp1_subdev_enum_mbus_code(struct v4l2_subdev
*subdev
,
182 struct v4l2_subdev_pad_config
*cfg
,
183 struct v4l2_subdev_mbus_code_enum
*code
,
184 const unsigned int *codes
, unsigned int ncodes
);
185 int vsp1_subdev_enum_frame_size(struct v4l2_subdev
*subdev
,
186 struct v4l2_subdev_pad_config
*cfg
,
187 struct v4l2_subdev_frame_size_enum
*fse
,
188 unsigned int min_w
, unsigned int min_h
,
189 unsigned int max_w
, unsigned int max_h
);
191 #endif /* __VSP1_ENTITY_H__ */