2 * vsp1_entity.h -- R-Car VSP1 Base Entity
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 #ifndef __VSP1_ENTITY_H__
14 #define __VSP1_ENTITY_H__
16 #include <linux/list.h>
17 #include <linux/mutex.h>
19 #include <media/v4l2-subdev.h>
25 enum vsp1_entity_type
{
39 * enum vsp1_entity_params - Entity configuration parameters class
40 * @VSP1_ENTITY_PARAMS_INIT - Initial parameters
41 * @VSP1_ENTITY_PARAMS_PARTITION - Per-image partition parameters
42 * @VSP1_ENTITY_PARAMS_RUNTIME - Runtime-configurable parameters
44 enum vsp1_entity_params
{
45 VSP1_ENTITY_PARAMS_INIT
,
46 VSP1_ENTITY_PARAMS_PARTITION
,
47 VSP1_ENTITY_PARAMS_RUNTIME
,
50 #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
53 * struct vsp1_route - Entity routing configuration
54 * @type: Entity type this routing entry is associated with
55 * @index: Entity index this routing entry is associated with
56 * @reg: Output routing configuration register
57 * @inputs: Target node value for each input
58 * @output: Target node value for entity output
60 * Each $vsp1_route entry describes routing configuration for the entity
61 * specified by the entry's @type and @index. @reg indicates the register that
62 * holds output routing configuration for the entity, and the @inputs array
63 * store the target node value for each input of the entity. The @output field
64 * stores the target node value of the entity output when used as a source for
65 * histogram generation.
68 enum vsp1_entity_type type
;
71 unsigned int inputs
[VSP1_ENTITY_MAX_INPUTS
];
76 * struct vsp1_entity_operations - Entity operations
77 * @destroy: Destroy the entity.
78 * @configure: Setup the hardware based on the entity state (pipeline, formats,
79 * selection rectangles, ...)
80 * @max_width: Return the max supported width of data that the entity can
81 * process in a single operation.
83 struct vsp1_entity_operations
{
84 void (*destroy
)(struct vsp1_entity
*);
85 void (*configure
)(struct vsp1_entity
*, struct vsp1_pipeline
*,
86 struct vsp1_dl_list
*, enum vsp1_entity_params
);
87 unsigned int (*max_width
)(struct vsp1_entity
*, struct vsp1_pipeline
*);
91 struct vsp1_device
*vsp1
;
93 const struct vsp1_entity_operations
*ops
;
95 enum vsp1_entity_type type
;
97 const struct vsp1_route
*route
;
99 struct list_head list_dev
;
100 struct list_head list_pipe
;
102 struct media_pad
*pads
;
103 unsigned int source_pad
;
105 struct media_entity
*sink
;
106 unsigned int sink_pad
;
108 struct v4l2_subdev subdev
;
109 struct v4l2_subdev_pad_config
*config
;
111 struct mutex lock
; /* Protects the pad config */
114 static inline struct vsp1_entity
*to_vsp1_entity(struct v4l2_subdev
*subdev
)
116 return container_of(subdev
, struct vsp1_entity
, subdev
);
119 int vsp1_entity_init(struct vsp1_device
*vsp1
, struct vsp1_entity
*entity
,
120 const char *name
, unsigned int num_pads
,
121 const struct v4l2_subdev_ops
*ops
, u32 function
);
122 void vsp1_entity_destroy(struct vsp1_entity
*entity
);
124 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops
;
126 int vsp1_entity_link_setup(struct media_entity
*entity
,
127 const struct media_pad
*local
,
128 const struct media_pad
*remote
, u32 flags
);
130 struct v4l2_subdev_pad_config
*
131 vsp1_entity_get_pad_config(struct vsp1_entity
*entity
,
132 struct v4l2_subdev_pad_config
*cfg
,
133 enum v4l2_subdev_format_whence which
);
134 struct v4l2_mbus_framefmt
*
135 vsp1_entity_get_pad_format(struct vsp1_entity
*entity
,
136 struct v4l2_subdev_pad_config
*cfg
,
139 vsp1_entity_get_pad_selection(struct vsp1_entity
*entity
,
140 struct v4l2_subdev_pad_config
*cfg
,
141 unsigned int pad
, unsigned int target
);
142 int vsp1_entity_init_cfg(struct v4l2_subdev
*subdev
,
143 struct v4l2_subdev_pad_config
*cfg
);
145 void vsp1_entity_route_setup(struct vsp1_entity
*source
,
146 struct vsp1_dl_list
*dl
);
148 int vsp1_subdev_get_pad_format(struct v4l2_subdev
*subdev
,
149 struct v4l2_subdev_pad_config
*cfg
,
150 struct v4l2_subdev_format
*fmt
);
151 int vsp1_subdev_enum_mbus_code(struct v4l2_subdev
*subdev
,
152 struct v4l2_subdev_pad_config
*cfg
,
153 struct v4l2_subdev_mbus_code_enum
*code
,
154 const unsigned int *codes
, unsigned int ncodes
);
155 int vsp1_subdev_enum_frame_size(struct v4l2_subdev
*subdev
,
156 struct v4l2_subdev_pad_config
*cfg
,
157 struct v4l2_subdev_frame_size_enum
*fse
,
158 unsigned int min_w
, unsigned int min_h
,
159 unsigned int max_w
, unsigned int max_h
);
161 #endif /* __VSP1_ENTITY_H__ */