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/spinlock.h>
19 #include <media/v4l2-subdev.h>
25 enum vsp1_entity_type
{
37 #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
40 * struct vsp1_route - Entity routing configuration
41 * @type: Entity type this routing entry is associated with
42 * @index: Entity index this routing entry is associated with
43 * @reg: Output routing configuration register
44 * @inputs: Target node value for each input
45 * @output: Target node value for entity output
47 * Each $vsp1_route entry describes routing configuration for the entity
48 * specified by the entry's @type and @index. @reg indicates the register that
49 * holds output routing configuration for the entity, and the @inputs array
50 * store the target node value for each input of the entity. The @output field
51 * stores the target node value of the entity output when used as a source for
52 * histogram generation.
55 enum vsp1_entity_type type
;
58 unsigned int inputs
[VSP1_ENTITY_MAX_INPUTS
];
63 * struct vsp1_entity_operations - Entity operations
64 * @destroy: Destroy the entity.
65 * @set_memory: Setup memory buffer access. This operation applies the settings
66 * stored in the rwpf mem field to the display list. Valid for RPF
68 * @configure: Setup the hardware based on the entity state (pipeline, formats,
69 * selection rectangles, ...)
71 struct vsp1_entity_operations
{
72 void (*destroy
)(struct vsp1_entity
*);
73 void (*set_memory
)(struct vsp1_entity
*, struct vsp1_dl_list
*dl
);
74 void (*configure
)(struct vsp1_entity
*, struct vsp1_pipeline
*,
75 struct vsp1_dl_list
*);
79 struct vsp1_device
*vsp1
;
81 const struct vsp1_entity_operations
*ops
;
83 enum vsp1_entity_type type
;
85 const struct vsp1_route
*route
;
87 struct list_head list_dev
;
88 struct list_head list_pipe
;
90 struct media_pad
*pads
;
91 unsigned int source_pad
;
93 struct media_entity
*sink
;
94 unsigned int sink_pad
;
96 struct v4l2_subdev subdev
;
97 struct v4l2_subdev_pad_config
*config
;
100 static inline struct vsp1_entity
*to_vsp1_entity(struct v4l2_subdev
*subdev
)
102 return container_of(subdev
, struct vsp1_entity
, subdev
);
105 int vsp1_entity_init(struct vsp1_device
*vsp1
, struct vsp1_entity
*entity
,
106 const char *name
, unsigned int num_pads
,
107 const struct v4l2_subdev_ops
*ops
, u32 function
);
108 void vsp1_entity_destroy(struct vsp1_entity
*entity
);
110 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops
;
112 int vsp1_entity_link_setup(struct media_entity
*entity
,
113 const struct media_pad
*local
,
114 const struct media_pad
*remote
, u32 flags
);
116 struct v4l2_subdev_pad_config
*
117 vsp1_entity_get_pad_config(struct vsp1_entity
*entity
,
118 struct v4l2_subdev_pad_config
*cfg
,
119 enum v4l2_subdev_format_whence which
);
120 struct v4l2_mbus_framefmt
*
121 vsp1_entity_get_pad_format(struct vsp1_entity
*entity
,
122 struct v4l2_subdev_pad_config
*cfg
,
125 vsp1_entity_get_pad_selection(struct vsp1_entity
*entity
,
126 struct v4l2_subdev_pad_config
*cfg
,
127 unsigned int pad
, unsigned int target
);
128 int vsp1_entity_init_cfg(struct v4l2_subdev
*subdev
,
129 struct v4l2_subdev_pad_config
*cfg
);
131 void vsp1_entity_route_setup(struct vsp1_entity
*source
,
132 struct vsp1_dl_list
*dl
);
134 int vsp1_subdev_get_pad_format(struct v4l2_subdev
*subdev
,
135 struct v4l2_subdev_pad_config
*cfg
,
136 struct v4l2_subdev_format
*fmt
);
137 int vsp1_subdev_enum_mbus_code(struct v4l2_subdev
*subdev
,
138 struct v4l2_subdev_pad_config
*cfg
,
139 struct v4l2_subdev_mbus_code_enum
*code
,
140 const unsigned int *codes
, unsigned int ncodes
);
141 int vsp1_subdev_enum_frame_size(struct v4l2_subdev
*subdev
,
142 struct v4l2_subdev_pad_config
*cfg
,
143 struct v4l2_subdev_frame_size_enum
*fse
,
144 unsigned int min_w
, unsigned int min_h
,
145 unsigned int max_w
, unsigned int max_h
);
147 #endif /* __VSP1_ENTITY_H__ */