Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 1 | /* |
| 2 | * vsp1_entity.c -- R-Car VSP1 Base Entity |
| 3 | * |
Laurent Pinchart | 8a1edc5 | 2014-02-06 14:42:31 -0300 | [diff] [blame] | 4 | * Copyright (C) 2013-2014 Renesas Electronics Corporation |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 5 | * |
| 6 | * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) |
| 7 | * |
| 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. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/device.h> |
| 15 | #include <linux/gfp.h> |
| 16 | |
| 17 | #include <media/media-entity.h> |
Laurent Pinchart | a626e64 | 2013-07-10 12:03:30 -0300 | [diff] [blame] | 18 | #include <media/v4l2-ctrls.h> |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 19 | #include <media/v4l2-subdev.h> |
| 20 | |
| 21 | #include "vsp1.h" |
Laurent Pinchart | aa380ea | 2015-11-01 10:46:25 -0200 | [diff] [blame] | 22 | #include "vsp1_dl.h" |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 23 | #include "vsp1_entity.h" |
Laurent Pinchart | aa380ea | 2015-11-01 10:46:25 -0200 | [diff] [blame] | 24 | |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 25 | void vsp1_entity_route_setup(struct vsp1_entity *source, |
| 26 | struct vsp1_dl_list *dl) |
Laurent Pinchart | 665b693 | 2015-08-02 18:58:31 -0300 | [diff] [blame] | 27 | { |
| 28 | struct vsp1_entity *sink; |
| 29 | |
| 30 | if (source->route->reg == 0) |
| 31 | return; |
| 32 | |
| 33 | sink = container_of(source->sink, struct vsp1_entity, subdev.entity); |
Laurent Pinchart | 5e8dbbf | 2015-11-22 20:29:25 -0200 | [diff] [blame] | 34 | vsp1_dl_list_write(dl, source->route->reg, |
| 35 | sink->route->inputs[source->sink_pad]); |
Laurent Pinchart | 665b693 | 2015-08-02 18:58:31 -0300 | [diff] [blame] | 36 | } |
| 37 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 38 | /* ----------------------------------------------------------------------------- |
| 39 | * V4L2 Subdevice Operations |
| 40 | */ |
| 41 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 42 | /** |
| 43 | * vsp1_entity_get_pad_config - Get the pad configuration for an entity |
| 44 | * @entity: the entity |
| 45 | * @cfg: the TRY pad configuration |
| 46 | * @which: configuration selector (ACTIVE or TRY) |
| 47 | * |
| 48 | * Return the pad configuration requested by the which argument. The TRY |
| 49 | * configuration is passed explicitly to the function through the cfg argument |
| 50 | * and simply returned when requested. The ACTIVE configuration comes from the |
| 51 | * entity structure. |
| 52 | */ |
| 53 | struct v4l2_subdev_pad_config * |
| 54 | vsp1_entity_get_pad_config(struct vsp1_entity *entity, |
| 55 | struct v4l2_subdev_pad_config *cfg, |
| 56 | enum v4l2_subdev_format_whence which) |
| 57 | { |
| 58 | switch (which) { |
| 59 | case V4L2_SUBDEV_FORMAT_ACTIVE: |
| 60 | return entity->config; |
| 61 | case V4L2_SUBDEV_FORMAT_TRY: |
| 62 | default: |
| 63 | return cfg; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * vsp1_entity_get_pad_format - Get a pad format from storage for an entity |
| 69 | * @entity: the entity |
| 70 | * @cfg: the configuration storage |
| 71 | * @pad: the pad number |
| 72 | * |
| 73 | * Return the format stored in the given configuration for an entity's pad. The |
| 74 | * configuration can be an ACTIVE or TRY configuration. |
| 75 | */ |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 76 | struct v4l2_mbus_framefmt * |
| 77 | vsp1_entity_get_pad_format(struct vsp1_entity *entity, |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 78 | struct v4l2_subdev_pad_config *cfg, |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 79 | unsigned int pad) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 80 | { |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 81 | return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 82 | } |
| 83 | |
Laurent Pinchart | b7e5107 | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 84 | struct v4l2_rect * |
| 85 | vsp1_entity_get_pad_compose(struct vsp1_entity *entity, |
| 86 | struct v4l2_subdev_pad_config *cfg, |
| 87 | unsigned int pad) |
| 88 | { |
| 89 | return v4l2_subdev_get_try_compose(&entity->subdev, cfg, pad); |
| 90 | } |
| 91 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 92 | /* |
Laurent Pinchart | 0efdf0f | 2015-11-15 20:09:08 -0200 | [diff] [blame] | 93 | * vsp1_entity_init_cfg - Initialize formats on all pads |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 94 | * @subdev: V4L2 subdevice |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 95 | * @cfg: V4L2 subdev pad configuration |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 96 | * |
Laurent Pinchart | 0efdf0f | 2015-11-15 20:09:08 -0200 | [diff] [blame] | 97 | * Initialize all pad formats with default values in the given pad config. This |
| 98 | * function can be used as a handler for the subdev pad::init_cfg operation. |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 99 | */ |
Laurent Pinchart | 0efdf0f | 2015-11-15 20:09:08 -0200 | [diff] [blame] | 100 | int vsp1_entity_init_cfg(struct v4l2_subdev *subdev, |
| 101 | struct v4l2_subdev_pad_config *cfg) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 102 | { |
| 103 | struct v4l2_subdev_format format; |
| 104 | unsigned int pad; |
| 105 | |
| 106 | for (pad = 0; pad < subdev->entity.num_pads - 1; ++pad) { |
| 107 | memset(&format, 0, sizeof(format)); |
| 108 | |
| 109 | format.pad = pad; |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 110 | format.which = cfg ? V4L2_SUBDEV_FORMAT_TRY |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 111 | : V4L2_SUBDEV_FORMAT_ACTIVE; |
| 112 | |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 113 | v4l2_subdev_call(subdev, pad, set_fmt, cfg, &format); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 114 | } |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 115 | |
| 116 | return 0; |
| 117 | } |
| 118 | |
Laurent Pinchart | 3f55722 | 2016-02-24 21:10:13 -0300 | [diff] [blame] | 119 | /* |
| 120 | * vsp1_subdev_get_pad_format - Subdev pad get_fmt handler |
| 121 | * @subdev: V4L2 subdevice |
| 122 | * @cfg: V4L2 subdev pad configuration |
| 123 | * @fmt: V4L2 subdev format |
| 124 | * |
| 125 | * This function implements the subdev get_fmt pad operation. It can be used as |
| 126 | * a direct drop-in for the operation handler. |
| 127 | */ |
| 128 | int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev, |
| 129 | struct v4l2_subdev_pad_config *cfg, |
| 130 | struct v4l2_subdev_format *fmt) |
| 131 | { |
| 132 | struct vsp1_entity *entity = to_vsp1_entity(subdev); |
| 133 | struct v4l2_subdev_pad_config *config; |
| 134 | |
| 135 | config = vsp1_entity_get_pad_config(entity, cfg, fmt->which); |
| 136 | if (!config) |
| 137 | return -EINVAL; |
| 138 | |
| 139 | fmt->format = *vsp1_entity_get_pad_format(entity, config, fmt->pad); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
Laurent Pinchart | 6ad9ba9 | 2016-02-24 20:25:42 -0300 | [diff] [blame] | 144 | /* |
| 145 | * vsp1_subdev_enum_mbus_code - Subdev pad enum_mbus_code handler |
| 146 | * @subdev: V4L2 subdevice |
| 147 | * @cfg: V4L2 subdev pad configuration |
| 148 | * @code: Media bus code enumeration |
| 149 | * @codes: Array of supported media bus codes |
| 150 | * @ncodes: Number of supported media bus codes |
| 151 | * |
| 152 | * This function implements the subdev enum_mbus_code pad operation for entities |
| 153 | * that do not support format conversion. It enumerates the given supported |
| 154 | * media bus codes on the sink pad and reports a source pad format identical to |
| 155 | * the sink pad. |
| 156 | */ |
| 157 | int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev, |
| 158 | struct v4l2_subdev_pad_config *cfg, |
| 159 | struct v4l2_subdev_mbus_code_enum *code, |
| 160 | const unsigned int *codes, unsigned int ncodes) |
| 161 | { |
| 162 | struct vsp1_entity *entity = to_vsp1_entity(subdev); |
| 163 | |
| 164 | if (code->pad == 0) { |
| 165 | if (code->index >= ncodes) |
| 166 | return -EINVAL; |
| 167 | |
| 168 | code->code = codes[code->index]; |
| 169 | } else { |
| 170 | struct v4l2_subdev_pad_config *config; |
| 171 | struct v4l2_mbus_framefmt *format; |
| 172 | |
| 173 | /* The entity can't perform format conversion, the sink format |
| 174 | * is always identical to the source format. |
| 175 | */ |
| 176 | if (code->index) |
| 177 | return -EINVAL; |
| 178 | |
| 179 | config = vsp1_entity_get_pad_config(entity, cfg, code->which); |
| 180 | if (!config) |
| 181 | return -EINVAL; |
| 182 | |
| 183 | format = vsp1_entity_get_pad_format(entity, config, 0); |
| 184 | code->code = format->code; |
| 185 | } |
| 186 | |
| 187 | return 0; |
| 188 | } |
| 189 | |
Laurent Pinchart | 076e834 | 2016-02-24 20:25:42 -0300 | [diff] [blame^] | 190 | /* |
| 191 | * vsp1_subdev_enum_frame_size - Subdev pad enum_frame_size handler |
| 192 | * @subdev: V4L2 subdevice |
| 193 | * @cfg: V4L2 subdev pad configuration |
| 194 | * @fse: Frame size enumeration |
| 195 | * @min_width: Minimum image width |
| 196 | * @min_height: Minimum image height |
| 197 | * @max_width: Maximum image width |
| 198 | * @max_height: Maximum image height |
| 199 | * |
| 200 | * This function implements the subdev enum_frame_size pad operation for |
| 201 | * entities that do not support scaling or cropping. It reports the given |
| 202 | * minimum and maximum frame width and height on the sink pad, and a fixed |
| 203 | * source pad size identical to the sink pad. |
| 204 | */ |
| 205 | int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev, |
| 206 | struct v4l2_subdev_pad_config *cfg, |
| 207 | struct v4l2_subdev_frame_size_enum *fse, |
| 208 | unsigned int min_width, unsigned int min_height, |
| 209 | unsigned int max_width, unsigned int max_height) |
| 210 | { |
| 211 | struct vsp1_entity *entity = to_vsp1_entity(subdev); |
| 212 | struct v4l2_subdev_pad_config *config; |
| 213 | struct v4l2_mbus_framefmt *format; |
| 214 | |
| 215 | config = vsp1_entity_get_pad_config(entity, cfg, fse->which); |
| 216 | if (!config) |
| 217 | return -EINVAL; |
| 218 | |
| 219 | format = vsp1_entity_get_pad_format(entity, config, fse->pad); |
| 220 | |
| 221 | if (fse->index || fse->code != format->code) |
| 222 | return -EINVAL; |
| 223 | |
| 224 | if (fse->pad == 0) { |
| 225 | fse->min_width = min_width; |
| 226 | fse->max_width = max_width; |
| 227 | fse->min_height = min_height; |
| 228 | fse->max_height = max_height; |
| 229 | } else { |
| 230 | /* The size on the source pad are fixed and always identical to |
| 231 | * the size on the sink pad. |
| 232 | */ |
| 233 | fse->min_width = format->width; |
| 234 | fse->max_width = format->width; |
| 235 | fse->min_height = format->height; |
| 236 | fse->max_height = format->height; |
| 237 | } |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 242 | /* ----------------------------------------------------------------------------- |
| 243 | * Media Operations |
| 244 | */ |
| 245 | |
Laurent Pinchart | babca00 | 2015-08-05 17:14:41 -0300 | [diff] [blame] | 246 | int vsp1_entity_link_setup(struct media_entity *entity, |
| 247 | const struct media_pad *local, |
| 248 | const struct media_pad *remote, u32 flags) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 249 | { |
| 250 | struct vsp1_entity *source; |
| 251 | |
| 252 | if (!(local->flags & MEDIA_PAD_FL_SOURCE)) |
| 253 | return 0; |
| 254 | |
| 255 | source = container_of(local->entity, struct vsp1_entity, subdev.entity); |
| 256 | |
| 257 | if (!source->route) |
| 258 | return 0; |
| 259 | |
| 260 | if (flags & MEDIA_LNK_FL_ENABLED) { |
| 261 | if (source->sink) |
| 262 | return -EBUSY; |
| 263 | source->sink = remote->entity; |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 264 | source->sink_pad = remote->index; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 265 | } else { |
| 266 | source->sink = NULL; |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 267 | source->sink_pad = 0; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | return 0; |
| 271 | } |
| 272 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 273 | /* ----------------------------------------------------------------------------- |
| 274 | * Initialization |
| 275 | */ |
| 276 | |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 277 | static const struct vsp1_route vsp1_routes[] = { |
Laurent Pinchart | 629bb6d | 2013-07-10 18:03:46 -0300 | [diff] [blame] | 278 | { VSP1_ENTITY_BRU, 0, VI6_DPR_BRU_ROUTE, |
| 279 | { VI6_DPR_NODE_BRU_IN(0), VI6_DPR_NODE_BRU_IN(1), |
Laurent Pinchart | 7f2d50f | 2015-09-07 08:05:39 -0300 | [diff] [blame] | 280 | VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3), |
| 281 | VI6_DPR_NODE_BRU_IN(4) } }, |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 282 | { VSP1_ENTITY_HSI, 0, VI6_DPR_HSI_ROUTE, { VI6_DPR_NODE_HSI, } }, |
| 283 | { VSP1_ENTITY_HST, 0, VI6_DPR_HST_ROUTE, { VI6_DPR_NODE_HST, } }, |
| 284 | { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, } }, |
| 285 | { VSP1_ENTITY_LUT, 0, VI6_DPR_LUT_ROUTE, { VI6_DPR_NODE_LUT, } }, |
Laurent Pinchart | 5b22a11e | 2016-02-24 18:40:12 -0300 | [diff] [blame] | 286 | { VSP1_ENTITY_RPF, 0, VI6_DPR_RPF_ROUTE(0), { 0, } }, |
| 287 | { VSP1_ENTITY_RPF, 1, VI6_DPR_RPF_ROUTE(1), { 0, } }, |
| 288 | { VSP1_ENTITY_RPF, 2, VI6_DPR_RPF_ROUTE(2), { 0, } }, |
| 289 | { VSP1_ENTITY_RPF, 3, VI6_DPR_RPF_ROUTE(3), { 0, } }, |
| 290 | { VSP1_ENTITY_RPF, 4, VI6_DPR_RPF_ROUTE(4), { 0, } }, |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 291 | { VSP1_ENTITY_SRU, 0, VI6_DPR_SRU_ROUTE, { VI6_DPR_NODE_SRU, } }, |
| 292 | { VSP1_ENTITY_UDS, 0, VI6_DPR_UDS_ROUTE(0), { VI6_DPR_NODE_UDS(0), } }, |
| 293 | { VSP1_ENTITY_UDS, 1, VI6_DPR_UDS_ROUTE(1), { VI6_DPR_NODE_UDS(1), } }, |
| 294 | { VSP1_ENTITY_UDS, 2, VI6_DPR_UDS_ROUTE(2), { VI6_DPR_NODE_UDS(2), } }, |
| 295 | { VSP1_ENTITY_WPF, 0, 0, { VI6_DPR_NODE_WPF(0), } }, |
| 296 | { VSP1_ENTITY_WPF, 1, 0, { VI6_DPR_NODE_WPF(1), } }, |
| 297 | { VSP1_ENTITY_WPF, 2, 0, { VI6_DPR_NODE_WPF(2), } }, |
| 298 | { VSP1_ENTITY_WPF, 3, 0, { VI6_DPR_NODE_WPF(3), } }, |
| 299 | }; |
| 300 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 301 | int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 302 | const char *name, unsigned int num_pads, |
| 303 | const struct v4l2_subdev_ops *ops) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 304 | { |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 305 | struct v4l2_subdev *subdev; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 306 | unsigned int i; |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 307 | int ret; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 308 | |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 309 | for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) { |
| 310 | if (vsp1_routes[i].type == entity->type && |
| 311 | vsp1_routes[i].index == entity->index) { |
| 312 | entity->route = &vsp1_routes[i]; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 317 | if (i == ARRAY_SIZE(vsp1_routes)) |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 318 | return -EINVAL; |
| 319 | |
| 320 | entity->vsp1 = vsp1; |
| 321 | entity->source_pad = num_pads - 1; |
| 322 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 323 | /* Allocate and initialize pads. */ |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 324 | entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads), |
| 325 | GFP_KERNEL); |
| 326 | if (entity->pads == NULL) |
| 327 | return -ENOMEM; |
| 328 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 329 | for (i = 0; i < num_pads - 1; ++i) |
| 330 | entity->pads[i].flags = MEDIA_PAD_FL_SINK; |
| 331 | |
| 332 | entity->pads[num_pads - 1].flags = MEDIA_PAD_FL_SOURCE; |
| 333 | |
| 334 | /* Initialize the media entity. */ |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 335 | ret = media_entity_pads_init(&entity->subdev.entity, num_pads, |
| 336 | entity->pads); |
| 337 | if (ret < 0) |
| 338 | return ret; |
| 339 | |
| 340 | /* Initialize the V4L2 subdev. */ |
| 341 | subdev = &entity->subdev; |
| 342 | v4l2_subdev_init(subdev, ops); |
| 343 | |
| 344 | subdev->entity.ops = &vsp1->media_ops; |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 345 | subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; |
| 346 | |
| 347 | snprintf(subdev->name, sizeof(subdev->name), "%s %s", |
| 348 | dev_name(vsp1->dev), name); |
| 349 | |
Laurent Pinchart | 0efdf0f | 2015-11-15 20:09:08 -0200 | [diff] [blame] | 350 | vsp1_entity_init_cfg(subdev, NULL); |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 351 | |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 352 | /* Allocate the pad configuration to store formats and selection |
| 353 | * rectangles. |
| 354 | */ |
| 355 | entity->config = v4l2_subdev_alloc_pad_config(&entity->subdev); |
| 356 | if (entity->config == NULL) { |
| 357 | media_entity_cleanup(&entity->subdev.entity); |
| 358 | return -ENOMEM; |
| 359 | } |
| 360 | |
Laurent Pinchart | 823329d | 2015-11-15 19:42:01 -0200 | [diff] [blame] | 361 | return 0; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | void vsp1_entity_destroy(struct vsp1_entity *entity) |
| 365 | { |
Laurent Pinchart | 5243453 | 2015-11-17 12:23:23 -0200 | [diff] [blame] | 366 | if (entity->ops && entity->ops->destroy) |
| 367 | entity->ops->destroy(entity); |
Laurent Pinchart | a626e64 | 2013-07-10 12:03:30 -0300 | [diff] [blame] | 368 | if (entity->subdev.ctrl_handler) |
| 369 | v4l2_ctrl_handler_free(entity->subdev.ctrl_handler); |
Laurent Pinchart | e790c3c | 2015-11-15 19:14:22 -0200 | [diff] [blame] | 370 | v4l2_subdev_free_pad_config(entity->config); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 371 | media_entity_cleanup(&entity->subdev.entity); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 372 | } |